| 1 |
/* |
| 2 |
* Cisco router simulation platform. |
| 3 |
* Copyright (c) 2006 Christophe Fillot ([email protected]) |
| 4 |
* |
| 5 |
* Frame-Relay definitions. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef __FRAME_RELAY_H__ |
| 9 |
#define __FRAME_RELAY_H__ |
| 10 |
|
| 11 |
#include <pthread.h> |
| 12 |
|
| 13 |
#include "utils.h" |
| 14 |
#include "mempool.h" |
| 15 |
#include "net_io.h" |
| 16 |
|
| 17 |
/* DLCIs used for LMI */ |
| 18 |
#define FR_DLCI_LMI_ANSI 0 /* ANSI LMI */ |
| 19 |
#define FR_DLCI_LMI_CISCO 1023 /* Cisco LMI */ |
| 20 |
|
| 21 |
#define FR_LMI_ANSI_STATUS_OFFSET 5 |
| 22 |
#define FR_LMI_ANSI_STATUS_ENQUIRY 0x75 /* sent by user */ |
| 23 |
#define FR_LMI_ANSI_STATUS 0x7d /* sent by network */ |
| 24 |
|
| 25 |
/* Maximum packet size */ |
| 26 |
#define FR_MAX_PKT_SIZE 2048 |
| 27 |
|
| 28 |
/* Frame-Relay switch table */ |
| 29 |
typedef struct frsw_conn frsw_conn_t; |
| 30 |
struct frsw_conn { |
| 31 |
frsw_conn_t *hash_next,*next,**pprev; |
| 32 |
netio_desc_t *input,*output; |
| 33 |
u_int dlci_in,dlci_out; |
| 34 |
m_uint64_t count; |
| 35 |
}; |
| 36 |
|
| 37 |
/* Virtual Frame-Relay switch table */ |
| 38 |
#define FRSW_HASH_SIZE 256 |
| 39 |
|
| 40 |
typedef struct frsw_table frsw_table_t; |
| 41 |
struct frsw_table { |
| 42 |
char *name; |
| 43 |
pthread_mutex_t lock; |
| 44 |
mempool_t mp; |
| 45 |
m_uint64_t drop; |
| 46 |
frsw_conn_t *dlci_table[FRSW_HASH_SIZE]; |
| 47 |
}; |
| 48 |
|
| 49 |
#define FRSW_LOCK(t) pthread_mutex_lock(&(t)->lock) |
| 50 |
#define FRSW_UNLOCK(t) pthread_mutex_unlock(&(t)->lock) |
| 51 |
|
| 52 |
/* Acquire a reference to a Frame-Relay switch (increment reference count) */ |
| 53 |
frsw_table_t *frsw_acquire(char *name); |
| 54 |
|
| 55 |
/* Release a Frame-Relay switch (decrement reference count) */ |
| 56 |
int frsw_release(char *name); |
| 57 |
|
| 58 |
/* Create a virtual switch table */ |
| 59 |
frsw_table_t *frsw_create_table(char *name); |
| 60 |
|
| 61 |
/* Delete a Frame-Relay switch */ |
| 62 |
int frsw_delete(char *name); |
| 63 |
|
| 64 |
/* Delete all Frame-Relay switches */ |
| 65 |
int frsw_delete_all(void); |
| 66 |
|
| 67 |
/* Create a switch connection */ |
| 68 |
int frsw_create_vc(frsw_table_t *t,char *nio_input,u_int dlci_in, |
| 69 |
char *nio_output,u_int dlci_out); |
| 70 |
|
| 71 |
/* Remove a switch connection */ |
| 72 |
int frsw_delete_vc(frsw_table_t *t,char *nio_input,u_int dlci_in, |
| 73 |
char *nio_output,u_int dlci_out); |
| 74 |
|
| 75 |
/* Save the configuration of a Frame-Relay switch */ |
| 76 |
void frsw_save_config(frsw_table_t *t,FILE *fd); |
| 77 |
|
| 78 |
/* Save configurations of all Frame-Relay switches */ |
| 79 |
void frsw_save_config_all(FILE *fd); |
| 80 |
|
| 81 |
/* Start a virtual Frame-Relay switch */ |
| 82 |
int frsw_start(char *filename); |
| 83 |
|
| 84 |
#endif |