| 1 |
/* |
| 2 |
* Cisco router simulation platform. |
| 3 |
* Copyright (c) 2006 Christophe Fillot ([email protected]) |
| 4 |
* |
| 5 |
* NetIO bridge. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef __NET_IO_BRIDGE_H__ |
| 9 |
#define __NET_IO_BRIDGE_H__ |
| 10 |
|
| 11 |
#include <pthread.h> |
| 12 |
|
| 13 |
#include "utils.h" |
| 14 |
#include "net_io.h" |
| 15 |
|
| 16 |
#define NETIO_BRIDGE_MAX_NIO 32 |
| 17 |
|
| 18 |
typedef struct netio_bridge netio_bridge_t; |
| 19 |
struct netio_bridge { |
| 20 |
char *name; |
| 21 |
pthread_mutex_t lock; |
| 22 |
netio_desc_t *nio[NETIO_BRIDGE_MAX_NIO]; |
| 23 |
}; |
| 24 |
|
| 25 |
#define NETIO_BRIDGE_LOCK(t) pthread_mutex_lock(&(t)->lock) |
| 26 |
#define NETIO_BRIDGE_UNLOCK(t) pthread_mutex_unlock(&(t)->lock) |
| 27 |
|
| 28 |
/* Acquire a reference to NetIO bridge from the registry (inc ref count) */ |
| 29 |
netio_desc_t *netio_bridge_acquire(char *name); |
| 30 |
|
| 31 |
/* Release a NetIO bridge (decrement reference count) */ |
| 32 |
int netio_bridge_release(char *name); |
| 33 |
|
| 34 |
/* Create a virtual bridge */ |
| 35 |
netio_bridge_t *netio_bridge_create(char *name); |
| 36 |
|
| 37 |
/* Add a NetIO descriptor to a virtual bridge */ |
| 38 |
int netio_bridge_add_netio(netio_bridge_t *t,char *nio_name); |
| 39 |
|
| 40 |
/* Remove a NetIO descriptor from a virtual bridge */ |
| 41 |
int netio_bridge_remove_netio(netio_bridge_t *t,char *nio_name); |
| 42 |
|
| 43 |
/* Save the configuration of a brdige */ |
| 44 |
void netio_bridge_save_config(netio_bridge_t *t,FILE *fd); |
| 45 |
|
| 46 |
/* Save configurations of all NIO bridges */ |
| 47 |
void netio_bridge_save_config_all(FILE *fd); |
| 48 |
|
| 49 |
/* Delete a virtual bridge */ |
| 50 |
int netio_bridge_delete(char *name); |
| 51 |
|
| 52 |
/* Delete all virtual bridges */ |
| 53 |
int netio_bridge_delete_all(void); |
| 54 |
|
| 55 |
/* Start a virtual bridge */ |
| 56 |
int netio_bridge_start(char *filename); |
| 57 |
|
| 58 |
#endif |