VirtualBox

Changeset 22024 in vbox


Ignore:
Timestamp:
Aug 6, 2009 11:30:01 AM (15 years ago)
Author:
vboxsync
Message:

NAT: cleaning VBOX_WITHOUT_SLIRP_CLIENT_ETHER

Location:
trunk/src/VBox/Devices
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Makefile.kmk

    r22013 r22024  
    759759
    760760# some day will be deleted
    761 VBOX_WITHOUT_SLIRP_CLIENT_ETHER=1
    762761
    763762Drivers_SOURCES += $(VBOX_SLIRP_SOURCES)
     
    765764  $(file)_DEFS += \
    766765      $(if $(VBOX_WITH_SLIRP_MEMORY_CHECK),RTMEM_WRAP_TO_EF_APIS,) \
    767       $(if $(VBOX_WITHOUT_SLIRP_CLIENT_ETHER),VBOX_WITHOUT_SLIRP_CLIENT_ETHER,) \
    768766      $(if $(VBOX_WITH_DEBUG_NAT_SOCKETS),VBOX_WITH_DEBUG_NAT_SOCKETS,) \
    769767      $(if $(VBOX_WITH_SLIRP_MT),VBOX_WITH_SLIRP_MT,)
  • trunk/src/VBox/Devices/Network/slirp/bootp.c

    r22019 r22024  
    4141            bc->allocated = 1;
    4242            paddr->s_addr = htonl(ntohl(special_addr.s_addr) | (i + START_ADDR));
    43 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    4443            bc->addr.s_addr = paddr->s_addr;
    45 #endif
    4644            return bc;
    4745        }
     
    130128}
    131129
    132 #ifndef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    133 static void bootp_reply(PNATState pData, struct bootp_t *bp)
    134 #else
    135130static void bootp_reply(PNATState pData, struct mbuf *m0)
    136 #endif
    137131{
    138132    BOOTPClient *bc;
    139133    struct mbuf *m; /* XXX: @todo vasily - it'd be better to reuse this mbuf here */
    140 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    141134    struct bootp_t *bp = mtod(m0, struct bootp_t *);
    142135    struct ethhdr *eh;
    143 #endif
    144136    struct bootp_t *rbp;
    145137    struct sockaddr_in saddr, daddr;
     
    189181        return;
    190182
    191 #ifndef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    192     /* XXX: this is a hack to get the client mac address */
    193     memcpy(client_ethaddr, bp->bp_hwaddr, 6);
    194 #endif
    195 
    196183    if ((m = m_get(pData)) == NULL)
    197184        return;
    198 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    199185    eh = mtod(m, struct ethhdr *);
    200186    memcpy(eh->h_source, bp->bp_hwaddr, ETH_ALEN); /* XXX: if_encap just swap source with dest*/
    201 #endif
    202187    m->m_data += if_maxlinkhdr; /*reserve ether header */
    203188    rbp = mtod(m, struct bootp_t *);
     
    218203                return;
    219204            }
    220 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    221205            memcpy(bc->macaddr, bp->bp_hwaddr, 6);
    222 #else
    223             memcpy(bc->macaddr, client_ethaddr, 6);
    224 #endif
    225206        }
    226207    }
     
    386367
    387368    if (bp->bp_op == BOOTP_REQUEST)
    388 #ifndef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    389         bootp_reply(pData, bp);
    390 #else
    391369        bootp_reply(pData, m);
    392 #endif
    393 }
     370}
  • trunk/src/VBox/Devices/Network/slirp/ip_output.c

    r22020 r22024  
    4646#include "alias.h"
    4747
    48 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    4948static const uint8_t* rt_lookup_in_cache(PNATState pData, uint32_t dst)
    5049{
     
    6766    return NULL;
    6867}
    69 #endif
    7068
    7169/*
     
    8280    register int hlen = sizeof(struct ip );
    8381    int len, off, error = 0;
    84 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    8582    extern uint8_t zerro_ethaddr[ETH_ALEN];
    8683    struct ethhdr *eh = NULL;
    8784    const uint8_t *eth_dst = NULL;
    88 #endif
     85
    8986    STAM_PROFILE_START(&pData->StatIP_output, a);
    9087
     
    126123    }
    127124#endif
    128 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    129125      /* Current TCP/IP stack hasn't routing information at
    130126       * all so we need to calculate destination ethernet address
     
    133129     if (memcmp(eh->h_source, zerro_ethaddr, ETH_ALEN) == 0)
    134130         eth_dst = rt_lookup_in_cache(pData, ip->ip_dst.s_addr);
    135 #endif
    136131
    137132    /*
     
    144139        ip->ip_sum = 0;
    145140        ip->ip_sum = cksum(m, hlen);
    146 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    147         if (eth_dst != NULL) {
     141        if (eth_dst != NULL)
    148142            memcpy(eh->h_source, eth_dst, ETH_ALEN);
    149         }
    150 #endif
    151143        {
    152144            int rc;
     
    203195            mhip = mtod(m, struct ip *);
    204196            *mhip = *ip;
    205 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    206197            /* we've calculated eth_dst for first packet */
    207198            eh = (struct ethhdr *)MBUF_HEAD(m);
     
    209200                memcpy(eh->h_source, eth_dst, ETH_ALEN);
    210201            }
    211 #endif
    212202
    213203#if 0 /* No options */
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r22021 r22024  
    528528    special_addr.s_addr = u32NetAddr;
    529529#endif
    530 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    531530    pData->slirp_ethaddr = &special_ethaddr[0];
    532 #endif
    533531    alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
    534532    /* @todo: add ability to configure this staff */
     
    12971295}
    12981296
    1299 #ifndef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    1300 #define ETH_ALEN        6
    1301 #define ETH_HLEN        14
    1302 
    1303 #define ARPOP_REQUEST   1               /* ARP request                  */
    1304 #define ARPOP_REPLY     2               /* ARP reply                    */
    1305 
    1306 struct ethhdr
    1307 {
    1308     unsigned char   h_dest[ETH_ALEN];           /* destination eth addr */
    1309     unsigned char   h_source[ETH_ALEN];         /* source ether addr    */
    1310     unsigned short  h_proto;                    /* packet type ID field */
    1311 };
    1312 AssertCompileSize(struct ethhdr, 14);
    1313 #endif
    13141297
    13151298struct arphdr
     
    13481331
    13491332    mr = m_get(pData);
    1350 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
     1333
    13511334    reh = mtod(mr, struct ethhdr *);
    13521335    memcpy(reh->h_source, eh->h_source, ETH_ALEN); /* XXX: if_encap will swap src and dst*/
     
    13541337        reh->h_source, reh->h_dest));
    13551338    Log4(("NAT: arp: %R[IP4]\n", &tip));
    1356 #endif
     1339
    13571340    mr->m_data += if_maxlinkhdr;
    13581341    mr->m_len = sizeof(struct arphdr);
     
    14231406    }
    14241407    Log4(("NAT: in:%R[ether]->%R[ether]\n", &eh->h_source, &eh->h_dest));
    1425 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
     1408
    14261409    if (memcmp(eh->h_source, special_ethaddr, ETH_ALEN) == 0)
    14271410    {
     
    14311414        return;
    14321415    }
    1433 #endif
    14341416
    14351417    m = m_get(pData);
     
    14971479    }
    14981480
    1499 #ifndef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    1500     memcpy(eh->h_dest, client_ethaddr, ETH_ALEN);
    1501     memcpy(eh->h_source, special_ethaddr, ETH_ALEN - 1);
    1502     /* XXX: not correct */
    1503     eh->h_source[5] = CTL_ALIAS;
    1504 #else
    15051481    if (memcmp(eh->h_source, special_ethaddr, ETH_ALEN) != 0)
    15061482    {
     
    15141490        }
    15151491    }
    1516 #endif
     1492
    15171493    eh->h_proto = htons(eth_proto);
    15181494    memcpy(buf, mtod(m, uint8_t *), m->m_len);
  • trunk/src/VBox/Devices/Network/slirp/slirp.h

    r22014 r22024  
    326326#endif
    327327
    328 # ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    329 #  define ETH_ALEN        6
    330 #  define ETH_HLEN        14
    331 
    332 #  define ARPOP_REQUEST   1               /* ARP request                  */
    333 #  define ARPOP_REPLY     2               /* ARP reply                    */
     328# define ETH_ALEN        6
     329# define ETH_HLEN        14
     330
     331# define ARPOP_REQUEST   1               /* ARP request                  */
     332# define ARPOP_REPLY     2               /* ARP reply                    */
    334333
    335334struct ethhdr
     
    340339};
    341340AssertCompileSize(struct ethhdr, 14);
    342 # endif
    343341#if defined(VBOX_SLIRP_ALIAS)
    344342
  • trunk/src/VBox/Devices/Network/slirp/slirp_state.h

    r22020 r22024  
    4040    bool allocated;
    4141    uint8_t macaddr[6];
    42 #ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    4342    struct in_addr addr;
    44 #endif
    4543} BOOTPClient;
    4644
     
    142140    struct in_addr loopback_addr;
    143141    uint32_t netmask;
    144 #ifndef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
     142#ifndef VBOX_WITH_NAT_SERVICE
    145143    uint8_t client_ethaddr[6];
    146 #else
    147 # ifndef VBOX_WITH_NAT_SERVICE
    148     uint8_t client_ethaddr[6];
    149 # endif
     144#endif
    150145    const uint8_t *slirp_ethaddr;
    151 #endif
    152146    struct ex_list *exec_list;
    153147    char slirp_hostname[33];
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