--- upstream/dynamips-0.2.6-RC2/net_io.c 2007/10/06 16:05:34 3 +++ upstream/dynamips-0.2.7-RC2/net_io.c 2007/10/06 16:24:54 8 @@ -1,5 +1,5 @@ /* - * Cisco 7200 (Predator) simulation platform. + * Cisco router) simulation platform. * Copyright (c) 2005,2006 Christophe Fillot (cf@utc.fr) * * Network Input/Output Abstraction Layer. @@ -206,6 +206,14 @@ return(-1); } + /* Apply the bidirectional filter */ + if (nio->both_filter != NULL) { + res = nio->both_filter->pkt_handler(nio,pkt,len,nio->both_filter_data); + + if (res == NETIO_FILTER_ACTION_DROP) + return(-1); + } + return(nio->send(nio->dptr,pkt,len)); } @@ -235,6 +243,14 @@ return(-1); } + /* Apply the bidirectional filter */ + if (nio->both_filter != NULL) { + res = nio->both_filter->pkt_handler(nio,pkt,len,nio->both_filter_data); + + if (res == NETIO_FILTER_ACTION_DROP) + return(-1); + } + return(len); } @@ -1327,6 +1343,7 @@ if (nio) { netio_filter_unbind(nio,NETIO_FILTER_DIR_RX); netio_filter_unbind(nio,NETIO_FILTER_DIR_TX); + netio_filter_unbind(nio,NETIO_FILTER_DIR_BOTH); switch(nio->type) { case NETIO_TYPE_UNIX: @@ -1444,14 +1461,14 @@ static void *netio_rxl_spec_thread(void *arg) { struct netio_rx_listener *rxl = arg; - u_char pkt[NETIO_MAX_PKT_SIZE]; + netio_desc_t *nio = rxl->nio; ssize_t pkt_len; while(rxl->running) { - pkt_len = netio_recv(rxl->nio,pkt,sizeof(pkt)); + pkt_len = netio_recv(nio,nio->rx_pkt,sizeof(nio->rx_pkt)); if (pkt_len > 0) - 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); } return NULL; @@ -1461,7 +1478,6 @@ void *netio_rxl_gen_thread(void *arg) { struct netio_rx_listener *rxl; - u_char pkt[NETIO_MAX_PKT_SIZE]; ssize_t pkt_len; netio_desc_t *nio; struct timeval tv; @@ -1516,14 +1532,16 @@ NETIO_RXL_LOCK(); for(rxl=netio_rxl_list;rxl;rxl=rxl->next) { - if ((fd = netio_get_fd(rxl->nio)) == -1) + nio = rxl->nio; + + if ((fd = netio_get_fd(nio)) == -1) continue; if (FD_ISSET(fd,&rfds)) { - pkt_len = netio_recv(rxl->nio,pkt,sizeof(pkt)); + pkt_len = netio_recv(nio,nio->rx_pkt,sizeof(nio->rx_pkt)); if (pkt_len > 0) - 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); } }