/[dynamips]/trunk/net_io.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/net_io.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

upstream/dynamips-0.2.6-RC2/net_io.c revision 3 by dpavlin, Sat Oct 6 16:05:34 2007 UTC upstream/dynamips-0.2.7-RC3/net_io.c revision 9 by dpavlin, Sat Oct 6 16:26:06 2007 UTC
# Line 1  Line 1 
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.
# Line 206  ssize_t netio_send(netio_desc_t *nio,voi Line 206  ssize_t netio_send(netio_desc_t *nio,voi
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    
# Line 235  ssize_t netio_recv(netio_desc_t *nio,voi Line 243  ssize_t netio_recv(netio_desc_t *nio,voi
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    
# Line 1327  static int netio_free(void *data,void *a Line 1343  static int netio_free(void *data,void *a
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:
# Line 1444  static void netio_rxl_add_internal(struc Line 1461  static void netio_rxl_add_internal(struc
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;
# Line 1461  static void *netio_rxl_spec_thread(void Line 1478  static void *netio_rxl_spec_thread(void
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;
# Line 1516  void *netio_rxl_gen_thread(void *arg) Line 1532  void *netio_rxl_gen_thread(void *arg)
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    

Legend:
Removed from v.3  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26