1 |
/* |
/* |
2 |
* Cisco 7200 (Predator) simulation platform. |
* Cisco router) simulation platform. |
3 |
* Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) |
* Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) |
4 |
* |
* |
5 |
* Network Input/Output Abstraction Layer. |
* Network Input/Output Abstraction Layer. |
206 |
return(-1); |
return(-1); |
207 |
} |
} |
208 |
|
|
209 |
|
/* Apply the bidirectional filter */ |
210 |
|
if (nio->both_filter != NULL) { |
211 |
|
res = nio->both_filter->pkt_handler(nio,pkt,len,nio->both_filter_data); |
212 |
|
|
213 |
|
if (res == NETIO_FILTER_ACTION_DROP) |
214 |
|
return(-1); |
215 |
|
} |
216 |
|
|
217 |
return(nio->send(nio->dptr,pkt,len)); |
return(nio->send(nio->dptr,pkt,len)); |
218 |
} |
} |
219 |
|
|
243 |
return(-1); |
return(-1); |
244 |
} |
} |
245 |
|
|
246 |
|
/* Apply the bidirectional filter */ |
247 |
|
if (nio->both_filter != NULL) { |
248 |
|
res = nio->both_filter->pkt_handler(nio,pkt,len,nio->both_filter_data); |
249 |
|
|
250 |
|
if (res == NETIO_FILTER_ACTION_DROP) |
251 |
|
return(-1); |
252 |
|
} |
253 |
|
|
254 |
return(len); |
return(len); |
255 |
} |
} |
256 |
|
|
1343 |
if (nio) { |
if (nio) { |
1344 |
netio_filter_unbind(nio,NETIO_FILTER_DIR_RX); |
netio_filter_unbind(nio,NETIO_FILTER_DIR_RX); |
1345 |
netio_filter_unbind(nio,NETIO_FILTER_DIR_TX); |
netio_filter_unbind(nio,NETIO_FILTER_DIR_TX); |
1346 |
|
netio_filter_unbind(nio,NETIO_FILTER_DIR_BOTH); |
1347 |
|
|
1348 |
switch(nio->type) { |
switch(nio->type) { |
1349 |
case NETIO_TYPE_UNIX: |
case NETIO_TYPE_UNIX: |
1461 |
static void *netio_rxl_spec_thread(void *arg) |
static void *netio_rxl_spec_thread(void *arg) |
1462 |
{ |
{ |
1463 |
struct netio_rx_listener *rxl = arg; |
struct netio_rx_listener *rxl = arg; |
1464 |
u_char pkt[NETIO_MAX_PKT_SIZE]; |
netio_desc_t *nio = rxl->nio; |
1465 |
ssize_t pkt_len; |
ssize_t pkt_len; |
1466 |
|
|
1467 |
while(rxl->running) { |
while(rxl->running) { |
1468 |
pkt_len = netio_recv(rxl->nio,pkt,sizeof(pkt)); |
pkt_len = netio_recv(nio,nio->rx_pkt,sizeof(nio->rx_pkt)); |
1469 |
|
|
1470 |
if (pkt_len > 0) |
if (pkt_len > 0) |
1471 |
rxl->rx_handler(rxl->nio,pkt,pkt_len,rxl->arg1,rxl->arg2); |
rxl->rx_handler(nio,nio->rx_pkt,pkt_len,rxl->arg1,rxl->arg2); |
1472 |
} |
} |
1473 |
|
|
1474 |
return NULL; |
return NULL; |
1478 |
void *netio_rxl_gen_thread(void *arg) |
void *netio_rxl_gen_thread(void *arg) |
1479 |
{ |
{ |
1480 |
struct netio_rx_listener *rxl; |
struct netio_rx_listener *rxl; |
|
u_char pkt[NETIO_MAX_PKT_SIZE]; |
|
1481 |
ssize_t pkt_len; |
ssize_t pkt_len; |
1482 |
netio_desc_t *nio; |
netio_desc_t *nio; |
1483 |
struct timeval tv; |
struct timeval tv; |
1532 |
NETIO_RXL_LOCK(); |
NETIO_RXL_LOCK(); |
1533 |
|
|
1534 |
for(rxl=netio_rxl_list;rxl;rxl=rxl->next) { |
for(rxl=netio_rxl_list;rxl;rxl=rxl->next) { |
1535 |
if ((fd = netio_get_fd(rxl->nio)) == -1) |
nio = rxl->nio; |
1536 |
|
|
1537 |
|
if ((fd = netio_get_fd(nio)) == -1) |
1538 |
continue; |
continue; |
1539 |
|
|
1540 |
if (FD_ISSET(fd,&rfds)) { |
if (FD_ISSET(fd,&rfds)) { |
1541 |
pkt_len = netio_recv(rxl->nio,pkt,sizeof(pkt)); |
pkt_len = netio_recv(nio,nio->rx_pkt,sizeof(nio->rx_pkt)); |
1542 |
|
|
1543 |
if (pkt_len > 0) |
if (pkt_len > 0) |
1544 |
rxl->rx_handler(rxl->nio,pkt,pkt_len,rxl->arg1,rxl->arg2); |
rxl->rx_handler(nio,nio->rx_pkt,pkt_len,rxl->arg1,rxl->arg2); |
1545 |
} |
} |
1546 |
} |
} |
1547 |
|
|