VirtualBox

Changeset 19846 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
May 20, 2009 6:04:28 AM (16 years ago)
Author:
vboxsync
Message:

NAT: some refactoring of ip fragmentation code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/ip_output.c

    r19839 r19846  
    4949{
    5050    int i;
    51    /* temporary do for dhcp client */
     51   /* @todo (r - vasily) to quick ramp up on routing rails
     52    * we use information from DHCP server leasings, this
     53    * code couldn't detect any changes in network topology
     54    * and should be borrowed from other places
     55    */
    5256    for(i = 0; i < NB_ADDR; i++)
    5357    {
     
    7983    register int hlen = sizeof(struct ip );
    8084    int len, off, error = 0;
     85#ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
     86    extern uint8_t zerro_ethaddr[ETH_ALEN];
     87    struct ethhdr *eh;
     88    uint8_t *eth_dst;
     89#endif
    8190
    8291    DEBUG_CALL("ip_output");
     
    117126    }
    118127#endif
     128#ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
     129      /* Current TCP/IP stack hasn't routing information at
     130       * all so we need to calculate destination ethernet address
     131       */
     132     eh = (struct ethhdr *)MBUF_HEAD(m);
     133     if (memcmp(eh->h_source, zerro_ethaddr, ETH_ALEN) == 0) {
     134         eth_dst = rt_lookup_in_cache(pData, ip->ip_dst.s_addr);
     135     }
     136       
     137#endif
    119138
    120139    /*
     
    128147        ip->ip_sum = cksum(m, hlen);
    129148#ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    130         /* Current TCP/IP stack hasn't routing information at
    131          * all so we need to calculate destination ethernet address
    132          */
    133         {
    134             extern uint8_t zerro_ethaddr[ETH_ALEN];
    135             struct ethhdr *eh;
    136             eh = (struct ethhdr *)MBUF_HEAD(m);
    137             if (memcmp(eh->h_source, zerro_ethaddr, ETH_ALEN) == 0) {
    138                 char *dst = rt_lookup_in_cache(pData, ip->ip_dst.s_addr);
    139                 if (dst != NULL) {
    140                     memcpy(eh->h_source, dst, ETH_ALEN);
    141                 }
    142             }
     149        if (eth_dst != NULL) {
     150            memcpy(eh->h_source, eth_dst, ETH_ALEN);
    143151        }
    144152#endif
     
    178186        for (off = hlen + len; off < (u_int16_t)ip->ip_len; off += len)
    179187        {
    180 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    181             struct ethhdr *eh0;
    182             struct ethhdr *eh;
    183 #endif
    184188            register struct ip *mhip;
    185189            m = m_get(pData);
     
    190194                goto sendorfree;
    191195            }
    192 #ifdef VBOX_WITH_NAT_SERVICE
    193             eh0 = (struct ethhdr *)MBUF_HEAD(m0);
    194             eh = (struct ethhdr *)MBUF_HEAD(m);
    195             memcpy(eh->h_source, eh0->h_source, ETH_ALEN);
    196 #endif
    197196            m_adj(m, if_maxlinkhdr);
    198197            mhip = mtod(m, struct ip *);
    199198            *mhip = *ip;
     199#ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
     200            /* we've calculated eth_dst for first packet */
     201            eh = (struct ethhdr *)MBUF_HEAD(m);
     202            if (eth_dst != NULL) {
     203                memcpy(eh->h_source, eth_dst, ETH_ALEN);
     204            }
     205#endif
    200206
    201207#if 0 /* No options */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette