VirtualBox

Changeset 1076 in vbox


Ignore:
Timestamp:
Feb 27, 2007 1:24:42 PM (18 years ago)
Author:
vboxsync
Message:

Removed tons of ifdef VBOX conditionals to make slirp readable again

Location:
trunk/src/VBox/Devices/Network/slirp
Files:
35 edited

Legend:

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

    r1033 r1076  
    2626/* XXX: only DHCP is supported */
    2727
    28 #ifndef VBOX
    29 #define NB_ADDR 16
    30 
    31 #define START_ADDR 15
    32 
    33 #define LEASE_TIME (24 * 3600)
    34 
    35 typedef struct {
    36     uint8_t allocated;
    37     uint8_t macaddr[6];
    38 } BOOTPClient;
    39 
    40 BOOTPClient bootp_clients[NB_ADDR];
    41 
    42 const char *bootp_filename;
    43 #endif /* !VBOX */
    4428
    4529static const uint8_t rfc1533_cookie[] = { RFC1533_COOKIE };
    4630
    47 #ifndef VBOX
    48 #ifdef DEBUG
    49 #define dprintf(fmt, args...) \
    50 if (slirp_debug & DBG_CALL) { fprintf(dfd, fmt, ## args); fflush(dfd); }
    51 #else
    52 #define dprintf(fmt, args...)
    53 #endif
    54 #else /* VBOX */
    5531DECLINLINE(void) dprintf(const char *pszFormat, ...)
    5632{
     
    6238#endif
    6339}
    64 #endif /* VBOX */
    65 
    66 #ifdef VBOX
     40
    6741static BOOTPClient *get_new_addr(PNATState pData, struct in_addr *paddr)
    68 #else /* !VBOX */
    69 static BOOTPClient *get_new_addr(struct in_addr *paddr)
    70 #endif /* !VBOX */
    7142{
    7243    BOOTPClient *bc;
     
    8556}
    8657
    87 #ifdef VBOX
    8858static void release_addr(PNATState pData, struct in_addr *paddr)
    8959{
     
    9666    bootp_clients[i].allocated = 0;
    9767}
    98 #endif /* VBOX */
    99 
    100 #ifdef VBOX
     68
    10169static BOOTPClient *find_addr(PNATState pData, struct in_addr *paddr, const uint8_t *macaddr)
    102 #else /* !VBOX */
    103 static BOOTPClient *find_addr(struct in_addr *paddr, const uint8_t *macaddr)
    104 #endif /* !VBOX */
    10570{
    10671    BOOTPClient *bc;
     
    160125}
    161126
    162 #ifdef VBOX
    163127static void bootp_reply(PNATState pData, struct bootp_t *bp)
    164 #else /* !VBOX */
    165 static void bootp_reply(struct bootp_t *bp)
    166 #endif /* !VBOX */
    167128{
    168129    BOOTPClient *bc;
     
    170131    struct bootp_t *rbp;
    171132    struct sockaddr_in saddr, daddr;
    172 #ifdef VBOX
    173133    struct in_addr dns_addr_dhcp;
    174 #else /* !VBOX */
    175     struct in_addr dns_addr;
    176 #endif /* !VBOX */
    177134    int dhcp_msg_type, val;
    178135    uint8_t *q;
     
    185142        dhcp_msg_type = DHCPREQUEST; /* Force reply for old BOOTP clients */
    186143
    187 #ifdef VBOX
    188144    if (dhcp_msg_type == DHCPRELEASE) {
    189145        uint32_t addr = ntohl(bp->bp_ciaddr.s_addr);
     
    195151        return;
    196152    }
    197 #endif /* VBOX */
    198153    if (dhcp_msg_type != DHCPDISCOVER &&
    199154        dhcp_msg_type != DHCPREQUEST)
     
    202157    memcpy(client_ethaddr, bp->bp_hwaddr, 6);
    203158
    204 #ifdef VBOX
    205159    if ((m = m_get(pData)) == NULL)
    206 #else /* !VBOX */
    207     if ((m = m_get()) == NULL)
    208 #endif /* !VBOX */
    209160        return;
    210161    m->m_data += if_maxlinkhdr;
     
    214165
    215166    if (dhcp_msg_type == DHCPDISCOVER) {
    216 #ifdef VBOX
    217167        /* Do not allocate a new lease for clients that forgot that they had a lease. */
    218168        bc = find_addr(pData, &daddr.sin_addr, bp->bp_hwaddr);
    219         if (bc)
    220             goto reuse_lease;
    221 #endif /* VBOX */
     169        if (!bc)
     170        {
    222171    new_addr:
    223 #ifdef VBOX
    224         bc = get_new_addr(pData, &daddr.sin_addr);
    225 #else /* !VBOX */
    226         bc = get_new_addr(&daddr.sin_addr);
    227 #endif /* !VBOX */
    228         if (!bc) {
    229 #ifdef VBOX
    230             LogRel(("NAT: DHCP no IP address left\n"));
    231 #endif /* VBOX */
    232             dprintf("no address left\n");
    233             return;
    234         }
    235         memcpy(bc->macaddr, client_ethaddr, 6);
    236 #ifdef VBOX
    237     reuse_lease: ;
    238 #endif /* VBOX */
     172            bc = get_new_addr(pData, &daddr.sin_addr);
     173            if (!bc) {
     174                LogRel(("NAT: DHCP no IP address left\n"));
     175                dprintf("no address left\n");
     176                return;
     177            }
     178            memcpy(bc->macaddr, client_ethaddr, 6);
     179        }
    239180    } else {
    240 #ifdef VBOX
    241181        bc = find_addr(pData, &daddr.sin_addr, bp->bp_hwaddr);
    242 #else /* !VBOX */
    243         bc = find_addr(&daddr.sin_addr, bp->bp_hwaddr);
    244 #endif /* !VBOX */
    245182        if (!bc) {
    246183            /* if never assigned, behaves as if it was already
     
    251188
    252189    if (bootp_filename)
    253 #ifndef VBOX
    254         snprintf((char*)rbp->bp_file, sizeof(rbp->bp_file), "%s", bootp_filename);
    255 #else
    256190        RTStrPrintf((char*)rbp->bp_file, sizeof(rbp->bp_file), "%s", bootp_filename);
    257 #endif
    258 
    259 #ifdef VBOX
     191
    260192    {
    261193        uint32_t addr = ntohl(daddr.sin_addr.s_addr);
     
    263195                addr >> 24, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff));
    264196    }
    265 #endif /* VBOX */
    266197    dprintf("offered addr=%08x\n", ntohl(daddr.sin_addr.s_addr));
    267198
     
    315246        *q++ = RFC1533_DNS;
    316247        *q++ = 4;
    317 #ifdef VBOX
    318248        dns_addr_dhcp.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_DNS);
    319249        memcpy(q, &dns_addr_dhcp, 4);
    320 #else /* !VBOX */
    321         dns_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_DNS);
    322         memcpy(q, &dns_addr, 4);
    323 #endif /* !VBOX */
    324250        q += 4;
    325251
     
    342268    m->m_len = sizeof(struct bootp_t) -
    343269        sizeof(struct ip) - sizeof(struct udphdr);
    344 #ifdef VBOX
    345270    /* Reply to the broadcast address, as some clients perform paranoid checks. */
    346271    daddr.sin_addr.s_addr = INADDR_BROADCAST;
    347272    udp_output2(pData, NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
    348 #else /* !VBOX */
    349     udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
    350 #endif /* !VBOX */
    351 }
    352 
    353 #ifdef VBOX
     273}
     274
    354275void bootp_input(PNATState pData, struct mbuf *m)
    355 #else /* !VBOX */
    356 void bootp_input(struct mbuf *m)
    357 #endif /* !VBOX */
    358276{
    359277    struct bootp_t *bp = mtod(m, struct bootp_t *);
    360278
    361279    if (bp->bp_op == BOOTP_REQUEST) {
    362 #ifdef VBOX
    363280        bootp_reply(pData, bp);
    364 #else /* !VBOX */
    365         bootp_reply(bp);
    366 #endif /* !VBOX */
    367     }
    368 }
     281    }
     282}
  • trunk/src/VBox/Devices/Network/slirp/bootp.h

    r1033 r1076  
    7272#define DHCPREQUEST             3
    7373#define DHCPACK                 5
    74 #ifdef VBOX
    7574#define DHCPRELEASE             7
    76 #endif /* VBOX */
    7775
    7876#define RFC1533_VENDOR_MAJOR    0
     
    114112};
    115113
    116 #ifdef VBOX
    117114void bootp_input(PNATState, struct mbuf *m);
    118 #else /* !VBOX */
    119 void bootp_input(struct mbuf *m);
    120 #endif /* !VBOX */
  • trunk/src/VBox/Devices/Network/slirp/debug.c

    r1033 r1076  
    99#include <slirp.h>
    1010
    11 #ifndef VBOX
    12 FILE *dfd = NULL;
    13 #ifdef DEBUG
    14 int dostats = 1;
    15 #else
    16 int dostats = 0;
    17 #endif
    18 int slirp_debug = 0;
    19 #endif /* !VBOX */
    20 
    21 #ifndef VBOX
    22 extern char *strerror _P((int));
    23 #endif
    2411
    2512/* Carry over one item from main.c so that the tty's restored.
     
    2916
    3017
    31 #ifndef VBOX
    32 void
    33 debug_init(file, dbg)
    34         char *file;
    35         int dbg;
    36 {
    37         /* Close the old debugging file */
    38         if (dfd)
    39            fclose(dfd);
    40 
    41         dfd = fopen(file,"w");
    42         if (dfd != NULL) {
    43 #if 0
    44                 fprintf(dfd,"Slirp %s - Debugging Started.\n", SLIRP_VERSION);
    45 #endif
    46                 fprintf(dfd,"Debugging Started level %i.\r\n",dbg);
    47                 fflush(dfd);
    48                 slirp_debug = dbg;
    49         } else {
    50                 lprint("Error: Debugging file \"%s\" could not be opened: %s\r\n",
    51                         file, strerror(errno));
    52         }
    53 }
    54 #endif /* !VBOX */
    55 
    56 #ifndef VBOX
    5718/*
    5819 * Dump a packet in the same format as tcpdump -x
     
    6425        int n;
    6526{
    66 #ifndef VBOX
    67         u_char *pptr = (u_char *)dat;
    68         int j,k;
    69 
    70         n /= 16;
    71         n++;
    72         DEBUG_MISC((dfd, "PACKET DUMPED: \n"));
    73         for(j = 0; j < n; j++) {
    74                 for(k = 0; k < 6; k++)
    75                         DEBUG_MISC((dfd, "%02x ", *pptr++));
    76                 DEBUG_MISC((dfd, "\n"));
    77                 fflush(dfd);
    78         }
    79 #else /* VBOX */
    8027        Log(("nat: PACKET DUMPED:\n%.*Vhxd\n", n, dat));
    81 #endif /* VBOX */
    82 }
    83 #endif
    84 #endif /* !VBOX */
     28}
     29#endif
    8530
    8631#if 0
     
    14388
    14489void
    145 #ifdef VBOX
    14690ipstats(PNATState pData)
    147 #else /* !VBOX */
    148 ipstats()
    149 #endif /* !VBOX */
    15091{
    15192        lprint(" \r\n");
     
    190131
    191132void
    192 #ifdef VBOX
    193133tcpstats(PNATState pData)
    194 #else /* !VBOX */
    195 tcpstats()
    196 #endif /* !VBOX */
    197134{
    198135        lprint(" \r\n");
     
    262199
    263200void
    264 #ifdef VBOX
    265201udpstats(PNATState pData)
    266 #else /* !VBOX */
    267 udpstats()
    268 #endif /* !VBOX */
    269202{
    270203        lprint(" \r\n");
     
    280213
    281214void
    282 #ifdef VBOX
    283215icmpstats(PNATState pData)
    284 #else /* !VBOX */
    285 icmpstats()
    286 #endif /* !VBOX */
    287216{
    288217        lprint(" \r\n");
     
    297226
    298227void
    299 #ifdef VBOX
    300228mbufstats(PNATState pData)
    301 #else /* !VBOX */
    302 mbufstats()
    303 #endif /* !VBOX */
    304229{
    305230        struct mbuf *m;
     
    325250
    326251void
    327 #ifdef VBOX
    328252sockstats(PNATState pData)
    329 #else /* !VBOX */
    330 sockstats()
    331 #endif /* !VBOX */
    332253{
    333254        char buff[256];
  • trunk/src/VBox/Devices/Network/slirp/debug.h

    r1033 r1076  
    99#define PRN_SPRINTF     2
    1010
    11 #ifdef VBOX
    1211/* Unused anyway, using VBox Log facility. */
    1312#define dfd NULL
    14 #else /* !VBOX */
    15 extern FILE *dfd;
    16 extern FILE *lfd;
    17 #endif /* !VBOX */
    1813extern int dostats;
    1914extern int slirp_debug;
     
    2318#define DBG_ERROR 0x4
    2419#define DEBUG_DEFAULT DBG_CALL|DBG_MISC|DBG_ERROR
    25 
    26 #ifndef VBOX
    27 #ifdef DEBUG
    28 #define DEBUG_CALL(x) if (slirp_debug & DBG_CALL) { fprintf(dfd, "%s...\n", x); fflush(dfd); }
    29 #define DEBUG_ARG(x, y) if (slirp_debug & DBG_CALL) { fputc(' ', dfd); fprintf(dfd, x, y); fputc('\n', dfd); fflush(dfd); }
    30 #define DEBUG_ARGS(x) if (slirp_debug & DBG_CALL) { fprintf x ; fflush(dfd); }
    31 #define DEBUG_MISC(x) if (slirp_debug & DBG_MISC) { fprintf x ; fflush(dfd); }
    32 #define DEBUG_ERROR(x) if (slirp_debug & DBG_ERROR) {fprintf x ; fflush(dfd); }
    33 
    34 
    35 #else
    36 
    37 #define DEBUG_CALL(x)
    38 #define DEBUG_ARG(x, y)
    39 #define DEBUG_ARGS(x)
    40 #define DEBUG_MISC(x)
    41 #define DEBUG_ERROR(x)
    42 
    43 #endif
    44 #else /* VBOX */
    4520
    4621#include <VBox/log.h>
     
    8762#endif  /* !LOG_ENABLED */
    8863
    89 #endif  /* VBOX */
    90 
    9164void debug_init _P((char *, int));
    9265/*void ttystats _P((struct ttys *)); */
    9366void allttystats _P((void));
    94 #ifdef VBOX
    9567void ipstats _P((PNATState));
    9668void tcpstats _P((PNATState));
     
    9971void mbufstats _P((PNATState));
    10072void sockstats _P((PNATState));
    101 #else /* !VBOX */
    102 void ipstats _P((void));
    103 void vjstats _P((void));
    104 void tcpstats _P((void));
    105 void udpstats _P((void));
    106 void icmpstats _P((void));
    107 void mbufstats _P((void));
    108 void sockstats _P((void));
    109 #endif /* VBOX */
    110 #ifndef VBOX
    111 void slirp_exit _P((int));
    112 #endif /* VBOX */
    11373
  • trunk/src/VBox/Devices/Network/slirp/icmp_var.h

    r1033 r1076  
    4242 * of the internet control message protocol.
    4343 */
    44 #ifdef VBOX
    4544struct icmpstat_t {
    46 #else /* !VBOX */
    47 struct icmpstat {
    48 #endif /* !VBOX */
    4945/* statistics related to input messages processed */
    5046        u_long  icps_received;          /* #ICMP packets received */
     
    6965}
    7066
    71 #ifndef VBOX
    72 extern struct icmpstat icmpstat;
    73 #endif /* !VBOX */
    74 
    7567#endif
  • trunk/src/VBox/Devices/Network/slirp/if.c

    r1048 r1076  
    88#include <slirp.h>
    99
    10 #ifndef VBOX
    11 int if_mtu, if_mru;
    12 int if_comp;
    13 int if_maxlinkhdr;
    14 int     if_queued = 0;                  /* Number of packets queued so far */
    15 int     if_thresh = 10;                 /* Number of packets queued before we start sending
    16                                          * (to prevent allocing too many mbufs) */
    17 
    18 struct  mbuf if_fastq;                  /* fast queue (for interactive data) */
    19 struct  mbuf if_batchq;                 /* queue for non-interactive data */
    20 struct  mbuf *next_m;                   /* Pointer to next mbuf to output */
    21 #endif /* !VBOX */
    2210
    2311#define ifs_init(ifm) ((ifm)->ifs_next = (ifm)->ifs_prev = (ifm))
    2412
    25 #ifndef VBOX
    26 void
    27 ifs_insque(ifm, ifmhead)
    28         struct mbuf *ifm, *ifmhead;
    29 #else /* VBOX */
    3013static void ifs_insque(struct mbuf *ifm, struct mbuf *ifmhead)
    31 #endif /* VBOX */
    3214{
    3315        ifm->ifs_next = ifmhead->ifs_next;
     
    3719}
    3820
    39 #ifndef VBOX
    40 void
    41 ifs_remque(ifm)
    42         struct mbuf *ifm;
    43 #else /* VBOX */
    4421static void ifs_remque(struct mbuf *ifm)
    45 #endif /* VBOX */
    4622{
    4723        ifm->ifs_prev->ifs_next = ifm->ifs_next;
     
    5026
    5127void
    52 #ifdef VBOX
    5328if_init(PNATState pData)
    54 #else /* !VBOX */
    55 if_init()
    56 #endif /* !VBOX */
    5729{
    5830#if 0
     
    7042        if_maxlinkhdr = 2 + 14 + 40;
    7143#endif
    72 #ifdef VBOX
    7344        if_queued = 0;
    7445        if_thresh = 10;
    75 #endif /* VBOX */
    7646        if_mtu = 1500;
    7747        if_mru = 1500;
     
    176146 */
    177147void
    178 #ifdef VBOX
    179148if_output(PNATState pData, struct socket *so, struct mbuf *ifm)
    180 #else /* !VBOX */
    181 if_output(so, ifm)
    182         struct socket *so;
    183         struct mbuf *ifm;
    184 #endif /* !VBOX */
    185149{
    186150        struct mbuf *ifq;
     
    269233        if (link_up) {
    270234                /* if_start will check towrite */
    271 #ifdef VBOX
    272235                if_start(pData);
    273 #else /* !VBOX */
    274                 if_start();
    275 #endif /* !VBOX */
    276236        }
    277237#endif
     
    291251 */
    292252void
    293 #ifdef VBOX
    294253if_start(PNATState pData)
    295 #else /* !VBOX */
    296 if_start(void)
    297 #endif /* !VBOX */
    298254{
    299255        struct mbuf *ifm, *ifqt;
     
    306262 again:
    307263        /* check if we can really output */
    308 #ifdef VBOX
    309264        if (!slirp_can_output(pData->pvUser))
    310 #else /* !VBOX */
    311         if (!slirp_can_output())
    312 #endif /* !VBOX */
    313265            return;
    314266
     
    348300
    349301        /* Encapsulate the packet for sending */
    350 #ifndef VBOX
    351         if_encap(ifm->m_data, ifm->m_len);
    352 #else /* VBOX */
    353302        if_encap(pData, (const uint8_t *)ifm->m_data, ifm->m_len);
    354 #endif /* VBOX */
    355 
    356 #ifdef VBOX
     303
    357304        m_free(pData, ifm);
    358 #else /* !VBOX */
    359         m_free(ifm);
    360 #endif /* !VBOX */
    361305
    362306        if (if_queued)
  • trunk/src/VBox/Devices/Network/slirp/ip.h

    r1033 r1076  
    7878 */
    7979struct ip {
    80 #ifdef VBOX
    8180/*
    8281 * bitfield types must be u_int8_t for MSVC, otherwise it will use a full dword (for u_int)
    8382 */
    84 #endif
    8583#ifdef WORDS_BIGENDIAN
    8684        u_int ip_v:4,                   /* version */
     
    153151        u_int8_t        ipt_len;                /* size of structure (variable) */
    154152        u_int8_t        ipt_ptr;                /* index of current entry */
    155 #ifdef VBOX
    156153/*
    157154 * bitfield types must be u_int8_t for MSVC, otherwise it will use a full dword (for u_int)
    158155 */
    159 #endif
    160156#ifdef WORDS_BIGENDIAN
    161157        u_int   ipt_oflw:4,             /* overflow counter */
     
    300296 */
    301297
    302 #ifdef VBOX
    303298struct  ipstat_t {
    304 #else /* !VBOX */
    305 struct  ipstat {
    306 #endif /* !VBOX */
    307299        u_long  ips_total;              /* total packets received */
    308300        u_long  ips_badsum;             /* checksum bad */
     
    332324};
    333325
    334 #ifndef VBOX
    335 extern struct   ipstat  ipstat;
    336 extern struct   ipq     ipq;                    /* ip reass. queue */
    337 extern u_int16_t        ip_id;                          /* ip packet ctr, for ids */
    338 extern int      ip_defttl;                      /* default IP ttl */
    339 #endif /* !VBOX */
    340 
    341 #endif
     326
     327#endif
  • trunk/src/VBox/Devices/Network/slirp/ip_icmp.c

    r1033 r1076  
    3838#include "ip_icmp.h"
    3939
    40 #ifndef VBOX
    41 struct icmpstat icmpstat;
    42 #endif /* !VBOX */
    4340
    4441/* The message sent when emulating PING */
    4542/* Be nice and tell them it's just a psuedo-ping packet */
    46 #ifdef VBOX
    4743static const char icmp_ping_msg[] = "This is a psuedo-PING packet used by Slirp to emulate ICMP ECHO-REQUEST packets.\n";
    48 #else /* !VBOX */
    49 char icmp_ping_msg[] = "This is a psuedo-PING packet used by Slirp to emulate ICMP ECHO-REQUEST packets.\n";
    50 #endif /* !VBOX */
    5144
    5245/* list of actions for icmp_error() on RX of an icmp message */
    53 #ifdef VBOX
    5446static const int icmp_flush[19] = {
    55 #else /* !VBOX */
    56 static int icmp_flush[19] = {
    57 #endif /* !VBOX */
    5847/*  ECHO REPLY (0)  */   0,
    5948                         1,
     
    8170 */
    8271void
    83 #ifdef VBOX
    8472icmp_input(PNATState pData, struct mbuf *m, int hlen)
    85 #else /* !VBOX */
    86 icmp_input(m, hlen)
    87      struct mbuf *m;
    88      int hlen;
    89 #endif /* !VBOX */
    9073{
    9174  register struct icmp *icp;
     
    10790    icmpstat.icps_tooshort++;
    10891  freeit:
    109 #ifdef VBOX
    11092    m_freem(pData, m);
    111 #else /* !VBOX */
    112     m_freem(m);
    113 #endif /* !VBOX */
    11493    goto end_error;
    11594  }
     
    134113    ip->ip_len += hlen;              /* since ip_input subtracts this */
    135114    if (ip->ip_dst.s_addr == alias_addr.s_addr) {
    136 #ifdef VBOX
    137115      icmp_reflect(pData, m);
    138 #else /* !VBOX */
    139       icmp_reflect(m);
    140 #endif /* !VBOX */
    141116    } else {
    142117      struct socket *so;
    143118      struct sockaddr_in addr;
    144119      if ((so = socreate()) == NULL) goto freeit;
    145 #ifdef VBOX
    146120      if(udp_attach(pData, so) == -1) {
    147 #else /* !VBOX */
    148       if(udp_attach(so) == -1) {
    149 #endif /* !VBOX */
    150121        DEBUG_MISC((dfd,"icmp_input udp_attach errno = %d-%s\n",
    151122                    errno,strerror(errno)));
    152 #ifdef VBOX
    153123        sofree(pData, so);
    154124        m_free(pData, m);
    155 #else /* !VBOX */
    156         sofree(so);
    157         m_free(m);
    158 #endif /* !VBOX */
    159125        goto end_error;
    160126      }
     
    189155        DEBUG_MISC((dfd,"icmp_input udp sendto tx errno = %d-%s\n",
    190156                    errno,strerror(errno)));
    191 #ifdef VBOX
    192157        icmp_error(pData, m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
    193158        udp_detach(pData, so);
    194 #else /* !VBOX */
    195         icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
    196         udp_detach(so);
    197 #endif /* !VBOX */
    198159      }
    199160    } /* if ip->ip_dst.s_addr == alias_addr.s_addr */
     
    208169  case ICMP_REDIRECT:
    209170    icmpstat.icps_notsupp++;
    210 #ifdef VBOX
    211171    m_freem(pData, m);
    212 #else /* !VBOX */
    213     m_freem(m);
    214 #endif /* !VBOX */
    215172    break;
    216173
    217174  default:
    218175    icmpstat.icps_badtype++;
    219 #ifdef VBOX
    220176    m_freem(pData, m);
    221 #else /* !VBOX */
    222     m_freem(m);
    223 #endif /* !VBOX */
    224177  } /* swith */
    225178
     
    249202
    250203#define ICMP_MAXDATALEN (IP_MSS-28)
    251 #ifndef VBOX
    252 void
    253 icmp_error(msrc, type, code, minsize, message)
    254      struct mbuf *msrc;
    255      u_char type;
    256      u_char code;
    257      int minsize;
    258      char *message;
    259 #else /* VBOX */
    260204void icmp_error(PNATState pData, struct mbuf *msrc, u_char type, u_char code, int minsize, char *message)
    261 #endif /* VBOX */
    262205{
    263206  unsigned hlen, shlen, s_ip_len;
     
    296239
    297240  /* make a copy */
    298 #ifdef VBOX
    299241  if(!(m=m_get(pData))) goto end_error;               /* get mbuf */
    300 #else /* !VBOX */
    301   if(!(m=m_get())) goto end_error;               /* get mbuf */
    302 #endif /* !VBOX */
    303242  { int new_m_size;
    304243    new_m_size=sizeof(struct ip )+ICMP_MINLEN+msrc->m_len+ICMP_MAXDATALEN;
     
    365304  ip->ip_src = alias_addr;
    366305
    367 #ifdef VBOX
    368306  (void ) ip_output(pData, (struct socket *)NULL, m);
    369 #else /* !VBOX */
    370   (void ) ip_output((struct socket *)NULL, m);
    371 #endif /* !VBOX */
    372307
    373308  icmpstat.icps_reflect++;
     
    382317 */
    383318void
    384 #ifdef VBOX
    385319icmp_reflect(PNATState pData, struct mbuf *m)
    386 #else /* !VBOX */
    387 icmp_reflect(m)
    388      struct mbuf *m;
    389 #endif /* !VBOX */
    390320{
    391321  register struct ip *ip = mtod(m, struct ip *);
     
    430360  }
    431361
    432 #ifdef VBOX
    433362  (void ) ip_output(pData, (struct socket *)NULL, m);
    434 #else /* !VBOX */
    435   (void ) ip_output((struct socket *)NULL, m);
    436 #endif /* !VBOX */
    437363
    438364  icmpstat.icps_reflect++;
  • trunk/src/VBox/Devices/Network/slirp/ip_icmp.h

    r1033 r1076  
    158158        (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
    159159
    160 #ifdef VBOX
    161160void icmp_input _P((PNATState, struct mbuf *, int));
    162161void icmp_error _P((PNATState, struct mbuf *, u_char, u_char, int, char *));
    163162void icmp_reflect _P((PNATState, struct mbuf *));
    164 #else /* !VBOX */
    165 void icmp_input _P((struct mbuf *, int));
    166 void icmp_error _P((struct mbuf *, u_char, u_char, int, char *));
    167 void icmp_reflect _P((struct mbuf *));
    168 #endif /* !VBOX */
    169163
    170164#endif
  • trunk/src/VBox/Devices/Network/slirp/ip_input.c

    r1048 r1076  
    4646#include "ip_icmp.h"
    4747
    48 #ifndef VBOX
    49 int ip_defttl;
    50 struct ipstat ipstat;
    51 struct ipq ipq;
    52 #endif /* !VBOX */
    5348
    5449/*
     
    5752 */
    5853void
    59 #ifdef VBOX
    6054ip_init(PNATState pData)
    61 #else /* !VBOX */
    62 ip_init()
    63 #endif /* !VBOX */
    6455{
    6556        ipq.next = ipq.prev = ptr_to_u32(pData, &ipq);
    66 #ifdef VBOX
    6757        ip_currid = tt.tv_sec & 0xffff;
    6858        udp_init(pData);
    6959        tcp_init(pData);
    70 #else /* !VBOX */
    71         ip_id = tt.tv_sec & 0xffff;
    72         udp_init();
    73         tcp_init();
    74 #endif /* !VBOX */
    75 #ifndef VBOX
    76         ip_defttl = IPDEFTTL;
    77 #endif /* !VBOX */
    7860}
    7961
     
    8365 */
    8466void
    85 #ifdef VBOX
    8667ip_input(PNATState pData, struct mbuf *m)
    87 #else /* !VBOX */
    88 ip_input(m)
    89         struct mbuf *m;
    90 #endif /* !VBOX */
    9168{
    9269        register struct ip *ip;
     
    153130        /* check ip_ttl for a correct ICMP reply */
    154131        if(ip->ip_ttl==0 || ip->ip_ttl==1) {
    155 #ifdef VBOX
    156132          icmp_error(pData, m, ICMP_TIMXCEED,ICMP_TIMXCEED_INTRANS, 0,"ttl");
    157 #else /* !VBOX */
    158           icmp_error(m, ICMP_TIMXCEED,ICMP_TIMXCEED_INTRANS, 0,"ttl");
    159 #endif /* !VBOX */
    160133          goto bad;
    161134        }
     
    216189                if (((struct ipasfrag *)ip)->ipf_mff & 1 || ip->ip_off) {
    217190                        ipstat.ips_fragments++;
    218 #ifdef VBOX
    219191                        ip = ip_reass(pData, (struct ipasfrag *)ip, fp);
    220 #else /* !VBOX */
    221                         ip = ip_reass((struct ipasfrag *)ip, fp);
    222 #endif /* !VBOX */
    223192                        if (ip == 0)
    224193                                return;
    225194                        ipstat.ips_reassembled++;
    226 #ifdef VBOX
    227195                        m = dtom(pData, ip);
    228 #else /* !VBOX */
    229                         m = dtom(ip);
    230 #endif /* !VBOX */
    231196                } else
    232197                        if (fp)
    233 #ifdef VBOX
    234198                           ip_freef(pData, fp);
    235 #else /* !VBOX */
    236                            ip_freef(fp);
    237 #endif /* !VBOX */
    238199
    239200        } else
     
    246207        switch (ip->ip_p) {
    247208         case IPPROTO_TCP:
    248 #ifdef VBOX
    249209                tcp_input(pData, m, hlen, (struct socket *)NULL);
    250 #else /* !VBOX */
    251                 tcp_input(m, hlen, (struct socket *)NULL);
    252 #endif /* !VBOX */
    253210                break;
    254211         case IPPROTO_UDP:
    255 #ifdef VBOX
    256212                udp_input(pData, m, hlen);
    257 #else /* !VBOX */
    258                 udp_input(m, hlen);
    259 #endif /* !VBOX */
    260213                break;
    261214         case IPPROTO_ICMP:
    262 #ifdef VBOX
    263215                icmp_input(pData, m, hlen);
    264 #else /* !VBOX */
    265                 icmp_input(m, hlen);
    266 #endif /* !VBOX */
    267216                break;
    268217         default:
    269218                ipstat.ips_noproto++;
    270 #ifdef VBOX
    271219                m_free(pData, m);
    272 #else /* !VBOX */
    273                 m_free(m);
    274 #endif /* !VBOX */
    275220        }
    276221        return;
    277222bad:
    278 #ifdef VBOX
    279223        m_freem(pData, m);
    280 #else /* !VBOX */
    281         m_freem(m);
    282 #endif /* !VBOX */
    283224        return;
    284225}
     
    291232 */
    292233struct ip *
    293 #ifdef VBOX
    294234ip_reass(PNATState pData, register struct ipasfrag *ip, register struct ipq_t *fp)
    295 #else /* !VBOX */
    296 ip_reass(ip, fp)
    297         register struct ipasfrag *ip;
    298         register struct ipq_t *fp;
    299 #endif /* !VBOX */
    300 {
    301 #ifdef VBOX
     235{
    302236        register struct mbuf *m = dtom(pData, ip);
    303 #else /* !VBOX */
    304         register struct mbuf *m = dtom(ip);
    305 #endif /* !VBOX */
    306237        register struct ipasfrag *q;
    307238        int hlen = ip->ip_hl << 2;
     
    326257        if (fp == 0) {
    327258          struct mbuf *t;
    328 #ifdef VBOX
    329259          if ((t = m_get(pData)) == NULL) goto dropfrag;
    330 #else /* !VBOX */
    331           if ((t = m_get()) == NULL) goto dropfrag;
    332 #endif /* !VBOX */
    333260          fp = mtod(t, struct ipq_t *);
    334261          insque_32(pData, fp, &ipq);
     
    362289                        if (i >= ip->ip_len)
    363290                                goto dropfrag;
    364 #ifdef VBOX
    365291                        m_adj(dtom(pData, ip), i);
    366 #else /* !VBOX */
    367                         m_adj(dtom(ip), i);
    368 #endif /* !VBOX */
    369292                        ip->ip_off += i;
    370293                        ip->ip_len -= i;
     
    381304                        q->ip_len -= i;
    382305                        q->ip_off += i;
    383 #ifdef VBOX
    384306                        m_adj(dtom(pData, q), i);
    385 #else /* !VBOX */
    386                         m_adj(dtom(q), i);
    387 #endif /* !VBOX */
    388307                        break;
    389308                }
     
    413332         */
    414333        q = u32_to_ptr(pData, fp->ipq_next, struct ipasfrag *);
    415 #ifdef VBOX
    416334        m = dtom(pData, q);
    417 #else /* !VBOX */
    418         m = dtom(q);
    419 #endif /* !VBOX */
    420335
    421336        q = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *);
    422337        while (q != (struct ipasfrag *)fp) {
    423338          struct mbuf *t;
    424 #ifdef VBOX
    425339          t = dtom(pData, q);
    426 #else /* !VBOX */
    427           t = dtom(q);
    428 #endif /* !VBOX */
    429340          q = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *);
    430 #ifdef VBOX
    431341          m_cat(pData, m, t);
    432 #else /* !VBOX */
    433           m_cat(m, t);
    434 #endif /* !VBOX */
    435342        }
    436343
     
    464371        ((struct ip *)ip)->ip_dst = fp->ipq_dst;
    465372        remque_32(pData, fp);
    466 #ifdef VBOX
    467373        (void) m_free(pData, dtom(pData, fp));
    468374        m = dtom(pData, ip);
    469 #else /* !VBOX */
    470         (void) m_free(dtom(fp));
    471         m = dtom(ip);
    472 #endif /* !VBOX */
    473375        m->m_len += (ip->ip_hl << 2);
    474376        m->m_data -= (ip->ip_hl << 2);
     
    478380dropfrag:
    479381        ipstat.ips_fragdropped++;
    480 #ifdef VBOX
    481382        m_freem(pData, m);
    482 #else /* !VBOX */
    483         m_freem(m);
    484 #endif /* !VBOX */
    485383        return (0);
    486384}
     
    491389 */
    492390void
    493 #ifdef VBOX
    494391ip_freef(PNATState pData, struct ipq_t *fp)
    495 #else /* !VBOX */
    496 ip_freef(fp)
    497         struct ipq_t *fp;
    498 #endif /* !VBOX */
    499392{
    500393        register struct ipasfrag *q, *p;
     
    504397                p = u32_to_ptr(pData, q->ipf_next, struct ipasfrag *);
    505398                ip_deq(pData, q);
    506 #ifdef VBOX
    507399                m_freem(pData, dtom(pData, q));
    508 #else /* !VBOX */
    509                 m_freem(dtom(q));
    510 #endif /* !VBOX */
    511400        }
    512401        remque_32(pData, fp);
    513 #ifdef VBOX
    514402        (void) m_free(pData, dtom(pData, fp));
    515 #else /* !VBOX */
    516         (void) m_free(dtom(fp));
    517 #endif /* !VBOX */
    518403}
    519404
     
    552437 */
    553438void
    554 #ifdef VBOX
    555439ip_slowtimo(PNATState pData)
    556 #else /* !VBOX */
    557 ip_slowtimo()
    558 #endif /* !VBOX */
    559440{
    560441        register struct ipq_t *fp;
  • trunk/src/VBox/Devices/Network/slirp/ip_output.c

    r1033 r1076  
    4545#include <slirp.h>
    4646
    47 #ifndef VBOX
    48 u_int16_t ip_id;
    49 #endif /* !VBOX */
    5047
    5148/*
     
    5653 */
    5754int
    58 #ifdef VBOX
    5955ip_output(PNATState pData, struct socket *so, struct mbuf *m0)
    60 #else /* !VBOX */
    61 ip_output(so, m0)
    62         struct socket *so;
    63         struct mbuf *m0;
    64 #endif /* !VBOX */
    6556{
    6657        register struct ip *ip;
     
    8576        ip->ip_v = IPVERSION;
    8677        ip->ip_off &= IP_DF;
    87 #ifdef VBOX
    8878        ip->ip_id = htons(ip_currid++);
    89 #else /* !VBOX */
    90         ip->ip_id = htons(ip_id++);
    91 #endif /* !VBOX */
    9279        ip->ip_hl = hlen >> 2;
    9380        ipstat.ips_localout++;
     
    113100                ip->ip_sum = cksum(m, hlen);
    114101
    115 #ifdef VBOX
    116102                if_output(pData, so, m);
    117 #else /* !VBOX */
    118                 if_output(so, m);
    119 #endif /* !VBOX */
    120103                goto done;
    121104        }
     
    149132        for (off = hlen + len; off < (u_int16_t)ip->ip_len; off += len) {
    150133          register struct ip *mhip;
    151 #ifdef VBOX
    152134          m = m_get(pData);
    153 #else /* !VBOX */
    154           m = m_get();
    155 #endif /* !VBOX */
    156135          if (m == 0) {
    157136            error = -1;
     
    206185                m->m_nextpkt = 0;
    207186                if (error == 0)
    208 #ifdef VBOX
    209187                        if_output(pData, so, m);
    210 #else /* !VBOX */
    211                         if_output(so, m);
    212 #endif /* !VBOX */
    213188                else
    214 #ifdef VBOX
    215189                        m_freem(pData, m);
    216 #else /* !VBOX */
    217                         m_freem(m);
    218 #endif /* !VBOX */
    219190        }
    220191
     
    227198
    228199bad:
    229 #ifdef VBOX
    230200        m_freem(pData, m0);
    231 #else /* !VBOX */
    232         m_freem(m0);
    233 #endif /* !VBOX */
    234201        goto done;
    235202}
  • trunk/src/VBox/Devices/Network/slirp/libslirp.h

    r1039 r1076  
    44#ifdef _WIN32
    55#include <winsock2.h>
    6 #if defined(VBOX) && defined(__cplusplus)
     6#ifdef __cplusplus
    77extern "C" {
    88#endif
    99int inet_aton(const char *cp, struct in_addr *ia);
    10 #if defined(VBOX) && defined(__cplusplus)
     10#ifdef __cplusplus
    1111}
    1212#endif
    1313#else
    14 #if defined(VBOX) && defined(__OS2__) /* temporary workaround, see ticket #127 */
     14#ifdef __OS2__ /* temporary workaround, see ticket #127 */
    1515# include <sys/time.h>
    1616#endif
     
    1919#endif
    2020
    21 #ifdef VBOX
    2221#include <VBox/types.h>
    2322
    2423typedef struct NATState *PNATState;
    25 #endif /* VBOX */
    2624
    2725#ifdef __cplusplus
     
    2927#endif
    3028
    31 #ifndef VBOX
    32 void slirp_init(void);
    33 #else /* VBOX */
    3429int slirp_init(PNATState *, const char *, void *);
    3530void slirp_term(PNATState);
    3631void slirp_link_up(PNATState);
    3732void slirp_link_down(PNATState);
    38 #endif /* VBOX */
    3933
    40 #ifdef VBOX
    4134void slirp_select_fill(PNATState pData, int *pnfds,
    4235                       fd_set *readfds, fd_set *writefds, fd_set *xfds);
     
    4538
    4639void slirp_input(PNATState pData, const uint8_t *pkt, int pkt_len);
    47 #else /* !VBOX */
    48 void slirp_select_fill(int *pnfds,
    49                        fd_set *readfds, fd_set *writefds, fd_set *xfds);
    5040
    51 void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds);
    52 
    53 void slirp_input(const uint8_t *pkt, int pkt_len);
    54 #endif /* !VBOX */
    55 
    56 #ifdef VBOX
    5741/* you must provide the following functions: */
    5842int slirp_can_output(void * pvUser);
     
    6347int slirp_add_exec(PNATState pData, int do_pty, const char *args, int addr_low_byte,
    6448                   int guest_port);
    65 #else /* !VBOX */
    66 /* you must provide the following functions: */
    67 int slirp_can_output(void);
    68 void slirp_output(const uint8_t *pkt, int pkt_len);
    6949
    70 int slirp_redir(int is_udp, int host_port,
    71                 struct in_addr guest_addr, int guest_port);
    72 int slirp_add_exec(int do_pty, const char *args, int addr_low_byte,
    73                    int guest_port);
    74 #endif /* !VBOX */
    75 
    76 #ifndef VBOX
    77 extern const char *tftp_prefix;
    78 extern char slirp_hostname[33];
    79 #endif /* !VBOX */
    8050
    8151#ifdef __cplusplus
  • trunk/src/VBox/Devices/Network/slirp/main.h

    r1033 r1076  
    1212#define TOWRITEMAX 512
    1313
    14 #ifndef VBOX
    15 extern struct timeval tt;
    16 extern int link_up;
    17 extern int slirp_socket;
    18 extern int slirp_socket_unit;
    19 extern int slirp_socket_port;
    20 extern u_int32_t slirp_socket_addr;
    21 extern char *slirp_socket_passwd;
    22 extern int ctty_closed;
    23 #endif /* !VBOX */
    2414
    2515/*
     
    3121#define TIME_DIFF(x,y) (x)-(y) < 0 ? ~0-(y)+(x) : (x)-(y)
    3222
    33 #ifndef VBOX
    34 extern char *slirp_tty;
    35 extern char *exec_shell;
    36 extern u_int curtime;
    37 extern fd_set *global_readfds, *global_writefds, *global_xfds;
    38 extern struct in_addr ctl_addr;
    39 extern struct in_addr special_addr;
    40 extern struct in_addr alias_addr;
    41 extern struct in_addr our_addr;
    42 extern struct in_addr loopback_addr;
    43 extern struct in_addr dns_addr;
    44 extern char *username;
    45 extern char *socket_path;
    46 extern int towrite_max;
    47 extern int ppp_exit;
    48 extern int so_options;
    49 extern int tcp_keepintvl;
    50 extern uint8_t client_ethaddr[6];
    51 #endif /* !VBOX */
    5223
    5324#define PROTO_SLIP 0x1
     
    5627#endif
    5728
    58 #ifdef VBOX
    5929void if_encap(PNATState pData, const uint8_t *ip_data, int ip_data_len);
    60 #else /* !VBOX */
    61 void if_encap(const uint8_t *ip_data, int ip_data_len);
    62 #endif /* !VBOX */
  • trunk/src/VBox/Devices/Network/slirp/mbuf.c

    r1048 r1076  
    1818#include <slirp.h>
    1919
    20 #ifndef VBOX
    21 struct  mbuf *mbutl;
    22 char    *mclrefcnt;
    23 int mbuf_alloced = 0;
    24 struct mbuf m_freelist, m_usedlist;
    25 int mbuf_thresh = 30;
    26 int mbuf_max = 0;
    27 int msize;
    28 #endif /* !VBOX */
    29 
    30 void
    31 #ifdef VBOX
     20
     21void
    3222m_init(PNATState pData)
    33 #else /* !VBOX */
    34 m_init()
    35 #endif /* !VBOX */
    3623{
    3724        m_freelist.m_next = m_freelist.m_prev = &m_freelist;
    3825        m_usedlist.m_next = m_usedlist.m_prev = &m_usedlist;
    39 #ifdef VBOX
    4026        mbuf_alloced = 0;
    4127        msize_init(pData);
    42 #else /* !VBOX */
    43         msize_init();
    44 #endif /* !VBOX */
    45 }
    46 
    47 void
    48 #ifdef VBOX
     28}
     29
     30void
    4931msize_init(PNATState pData)
    50 #else /* !VBOX */
    51 msize_init()
    52 #endif /* !VBOX */
    5332{
    5433        /*
     
    6948 */
    7049struct mbuf *
    71 #ifdef VBOX
    7250m_get(PNATState pData)
    73 #else /* !VBOX */
    74 m_get()
    75 #endif /* !VBOX */
    7651{
    7752        register struct mbuf *m;
     
    10984
    11085void
    111 #ifdef VBOX
    11286m_free(PNATState pData, struct mbuf *m)
    113 #else /* !VBOX */
    114 m_free(m)
    115         struct mbuf *m;
    116 #endif /* !VBOX */
    11787{
    11888
     
    149119 */
    150120void
    151 #ifdef VBOX
    152121m_cat(PNATState pData, register struct mbuf *m, register struct mbuf *n)
    153 #else /* !VBOX */
    154 m_cat(m, n)
    155         register struct mbuf *m, *n;
    156 #endif /* !VBOX */
    157122{
    158123        /*
     
    165130        m->m_len += n->m_len;
    166131
    167 #ifdef VBOX
    168132        m_free(pData, n);
    169 #else /* !VBOX */
    170         m_free(n);
    171 #endif /* !VBOX */
    172133}
    173134
     
    253214 */
    254215struct mbuf *
    255 #ifdef VBOX
    256216dtom(PNATState pData, void *dat)
    257 #else /* !VBOX */
    258 dtom(dat)
    259         void *dat;
    260 #endif /* !VBOX */
    261217{
    262218        struct mbuf *m;
  • trunk/src/VBox/Devices/Network/slirp/mbuf.h

    r1033 r1076  
    135135extern int mbuf_max;
    136136
    137 #ifdef VBOX
    138137void m_init _P((PNATState));
    139138void msize_init _P((PNATState));
     
    141140void m_free _P((PNATState, struct mbuf *));
    142141void m_cat _P((PNATState, register struct mbuf *, register struct mbuf *));
    143 #else /* !VBOX */
    144 void m_init _P((void));
    145 void msize_init _P((void));
    146 struct mbuf * m_get _P((void));
    147 void m_free _P((struct mbuf *));
    148 void m_cat _P((register struct mbuf *, register struct mbuf *));
    149 #endif /* !VBOX */
    150142void m_inc _P((struct mbuf *, int));
    151143void m_adj _P((struct mbuf *, int));
    152144int m_copy _P((struct mbuf *, struct mbuf *, int, int));
    153 #ifdef VBOX
    154145struct mbuf * dtom _P((PNATState, void *));
    155 #else /* !VBOX */
    156 struct mbuf * dtom _P((void *));
    157 #endif /* !VBOX */
    158146
    159147#endif
  • trunk/src/VBox/Devices/Network/slirp/misc.c

    r1050 r1076  
    99#include <slirp.h>
    1010
    11 #ifndef VBOX
    12 u_int curtime, time_fasttimo, last_slowtimo, detach_time;
    13 u_int detach_wait = 600000;     /* 10 minutes */
    14 #endif /* !VBOX */
    1511
    1612#if 0
     
    8884 */
    8985void
    90 #ifdef VBOX
    9186getouraddr(PNATState pData)
    92 #else /* !VBOX */
    93 getouraddr()
    94 #endif /* !VBOX */
    9587{
    9688        char buff[256];
     
    151143};
    152144
    153 #if defined(VBOX) && defined(_MSC_VER)
     145#ifdef _MSC_VER
    154146void
    155147#else
     
    167159}
    168160
    169 #if defined(VBOX) && defined(_MSC_VER)
     161#ifdef _MSC_VER
    170162void
    171163#else
     
    235227
    236228int
    237 #ifdef VBOX
    238229fork_exec(PNATState pData, struct socket *so, char *ex, int do_pty)
    239 #else /* !VBOX */
    240 fork_exec(so, ex, do_pty)
    241         struct socket *so;
    242         char *ex;
    243         int do_pty;
    244 #endif /* !VBOX */
    245230{
    246231    /* not implemented */
     
    249234
    250235#else
    251 
    252 #ifndef VBOX
    253 int
    254 slirp_openpty(amaster, aslave)
    255      int *amaster, *aslave;
    256 {
    257         register int master, slave;
    258 
    259 #ifdef HAVE_GRANTPT
    260         char *ptr;
    261 
    262         if ((master = open("/dev/ptmx", O_RDWR)) < 0 ||
    263             grantpt(master) < 0 ||
    264             unlockpt(master) < 0 ||
    265             (ptr = ptsname(master)) == NULL)  {
    266                 close(master);
    267                 return -1;
    268         }
    269 
    270         if ((slave = open(ptr, O_RDWR)) < 0 ||
    271             ioctl(slave, I_PUSH, "ptem") < 0 ||
    272             ioctl(slave, I_PUSH, "ldterm") < 0 ||
    273             ioctl(slave, I_PUSH, "ttcompat") < 0) {
    274                 close(master);
    275                 close(slave);
    276                 return -1;
    277         }
    278 
    279         *amaster = master;
    280         *aslave = slave;
    281         return 0;
    282 
    283 #else
    284 
    285         static char line[] = "/dev/ptyXX";
    286         register const char *cp1, *cp2;
    287 
    288         for (cp1 = "pqrsPQRS"; *cp1; cp1++) {
    289                 line[8] = *cp1;
    290                 for (cp2 = "0123456789abcdefghijklmnopqrstuv"; *cp2; cp2++) {
    291                         line[9] = *cp2;
    292                         if ((master = open(line, O_RDWR, 0)) == -1) {
    293                                 if (errno == ENOENT)
    294                                    return (-1);    /* out of ptys */
    295                         } else {
    296                                 line[5] = 't';
    297                                 /* These will fail */
    298                                 (void) chown(line, getuid(), 0);
    299                                 (void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP);
    300 #ifdef HAVE_REVOKE
    301                                 (void) revoke(line);
    302 #endif
    303                                 if ((slave = open(line, O_RDWR, 0)) != -1) {
    304                                         *amaster = master;
    305                                         *aslave = slave;
    306                                         return 0;
    307                                 }
    308                                 (void) close(master);
    309                                 line[5] = 'p';
    310                         }
    311                 }
    312         }
    313         errno = ENOENT; /* out of ptys */
    314         return (-1);
    315 #endif
    316 }
    317 #endif /* !VBOX */
    318236
    319237/*
     
    329247 */
    330248int
    331 #ifdef VBOX
    332249fork_exec(PNATState pData, struct socket *so, char *ex, int do_pty)
    333 #else /* !VBOX */
    334 fork_exec(so, ex, do_pty)
    335         struct socket *so;
    336         char *ex;
    337         int do_pty;
    338 #endif /* !VBOX */
    339250{
    340251        int s;
    341252        struct sockaddr_in addr;
    342 #ifndef VBOX
    343         int addrlen = sizeof(addr);
    344 #else /* VBOX */
    345253        socklen_t addrlen = sizeof(addr);
    346 #endif /* VBOX */
    347254        int opt;
    348255        int master;
     
    362269
    363270        if (do_pty == 2) {
    364 #ifdef VBOX
    365271                AssertRelease(do_pty != 2);
    366272                /* shut up gcc */
    367273                s = 0;
    368274                master = 0;
    369 #else /* !VBOX */
    370                 if (slirp_openpty(&master, &s) == -1) {
    371                         lprint("Error: openpty failed: %s\n", strerror(errno));
    372                         return 0;
    373                 }
    374 #endif /* !VBOX */
    375275        } else {
    376276                addr.sin_family = AF_INET;
     
    492392                /* Append the telnet options now */
    493393                if (so->so_m != 0 && do_pty == 1)  {
    494 #ifdef VBOX
    495394                        sbappend(pData, so, so->so_m);
    496 #else /* !VBOX */
    497                         sbappend(so, so->so_m);
    498 #endif /* !VBOX */
    499395                        so->so_m = 0;
    500396                }
     
    649545#endif
    650546
    651 #ifndef VBOX
    652 int (*lprint_print) _P((void *, const char *, va_list));
    653 char *lprint_ptr, *lprint_ptr2, **lprint_arg;
    654 
    655 void
    656 #ifdef __STDC__
    657 lprint(const char *format, ...)
    658 #else
    659 lprint(va_alist) va_dcl
    660 #endif
    661 {
    662         va_list args;
    663 
    664 #ifdef __STDC__
    665         va_start(args, format);
    666 #else
    667         char *format;
    668         va_start(args);
    669         format = va_arg(args, char *);
    670 #endif
    671 #if 0
    672         /* If we're printing to an sbuf, make sure there's enough room */
    673         /* XXX +100? */
    674         if (lprint_sb) {
    675                 if ((lprint_ptr - lprint_sb->sb_wptr) >=
    676                     (lprint_sb->sb_datalen - (strlen(format) + 100))) {
    677                         int deltaw = lprint_sb->sb_wptr - lprint_sb->sb_data;
    678                         int deltar = lprint_sb->sb_rptr - lprint_sb->sb_data;
    679                         int deltap = lprint_ptr -         lprint_sb->sb_data;
    680 
    681                         lprint_sb->sb_data = (char *)realloc(lprint_sb->sb_data,
    682                                                              lprint_sb->sb_datalen + TCP_SNDSPACE);
    683 
    684                         /* Adjust all values */
    685                         lprint_sb->sb_wptr = lprint_sb->sb_data + deltaw;
    686                         lprint_sb->sb_rptr = lprint_sb->sb_data + deltar;
    687                         lprint_ptr =         lprint_sb->sb_data + deltap;
    688 
    689                         lprint_sb->sb_datalen += TCP_SNDSPACE;
    690                 }
    691         }
    692 #endif
    693         if (lprint_print)
    694            lprint_ptr += (*lprint_print)(*lprint_arg, format, args);
    695 
    696         /* Check if they want output to be logged to file as well */
    697         if (lfd) {
    698                 /*
    699                  * Remove \r's
    700                  * otherwise you'll get ^M all over the file
    701                  */
    702                 int len = strlen(format);
    703                 char *bptr1, *bptr2;
    704 
    705                 bptr1 = bptr2 = strdup(format);
    706 
    707                 while (len--) {
    708                         if (*bptr1 == '\r')
    709                            memcpy(bptr1, bptr1+1, len+1);
    710                         else
    711                            bptr1++;
    712                 }
    713                 vfprintf(lfd, bptr2, args);
    714                 free(bptr2);
    715         }
    716         va_end(args);
    717 }
    718 
    719 void
    720 add_emu(buff)
    721         char *buff;
    722 {
    723         u_int lport, fport;
    724         u_int8_t tos = 0, emu = 0;
    725         char buff1[256], buff2[256], buff4[128];
    726         char *buff3 = buff4;
    727         struct emu_t *emup;
    728         struct socket *so;
    729 
    730         if (sscanf(buff, "%256s %256s", buff2, buff1) != 2) {
    731                 lprint("Error: Bad arguments\r\n");
    732                 return;
    733         }
    734 
    735         if (sscanf(buff1, "%d:%d", &lport, &fport) != 2) {
    736                 lport = 0;
    737                 if (sscanf(buff1, "%d", &fport) != 1) {
    738                         lprint("Error: Bad first argument\r\n");
    739                         return;
    740                 }
    741         }
    742 
    743         if (sscanf(buff2, "%128[^:]:%128s", buff1, buff3) != 2) {
    744                 buff3 = 0;
    745                 if (sscanf(buff2, "%256s", buff1) != 1) {
    746                         lprint("Error: Bad second argument\r\n");
    747                         return;
    748                 }
    749         }
    750 
    751         if (buff3) {
    752                 if (strcmp(buff3, "lowdelay") == 0)
    753                    tos = IPTOS_LOWDELAY;
    754                 else if (strcmp(buff3, "throughput") == 0)
    755                    tos = IPTOS_THROUGHPUT;
    756                 else {
    757                         lprint("Error: Expecting \"lowdelay\"/\"throughput\"\r\n");
    758                         return;
    759                 }
    760         }
    761 
    762         if (strcmp(buff1, "ftp") == 0)
    763            emu = EMU_FTP;
    764         else if (strcmp(buff1, "irc") == 0)
    765            emu = EMU_IRC;
    766         else if (strcmp(buff1, "none") == 0)
    767            emu = EMU_NONE; /* ie: no emulation */
    768         else {
    769                 lprint("Error: Unknown service\r\n");
    770                 return;
    771         }
    772 
    773         /* First, check that it isn't already emulated */
    774         for (emup = tcpemu; emup; emup = emup->next) {
    775                 if (emup->lport == lport && emup->fport == fport) {
    776                         lprint("Error: port already emulated\r\n");
    777                         return;
    778                 }
    779         }
    780 
    781         /* link it */
    782         emup = (struct emu_t *)malloc(sizeof (struct emu_t));
    783         emup->lport = (u_int16_t)lport;
    784         emup->fport = (u_int16_t)fport;
    785         emup->tos = tos;
    786         emup->emu = emu;
    787         emup->next = tcpemu;
    788         tcpemu = emup;
    789 
    790         /* And finally, mark all current sessions, if any, as being emulated */
    791         for (so = tcb.so_next; so != &tcb; so = so->so_next) {
    792                 if ((lport && lport == ntohs(so->so_lport)) ||
    793                     (fport && fport == ntohs(so->so_fport))) {
    794                         if (emu)
    795                            so->so_emu = emu;
    796                         if (tos)
    797                            so->so_iptos = tos;
    798                 }
    799         }
    800 
    801         lprint("Adding emulation for %s to port %d/%d\r\n", buff1, emup->lport, emup->fport);
    802 }
    803 #endif /* !VBOX */
    804 
    805547#ifdef BAD_SPRINTF
    806548
  • trunk/src/VBox/Devices/Network/slirp/misc.h

    r1048 r1076  
    1818
    1919extern struct ex_list *exec_list;
    20 #ifndef VBOX
    21 extern u_int curtime, time_fasttimo, last_slowtimo, detach_time, detach_wait;
    22 #endif /* !VBOX */
    23 
    24 #ifndef VBOX
    25 extern int (*lprint_print) _P((void *, const char *, va_list));
    26 extern char *lprint_ptr, *lprint_ptr2, **lprint_arg;
    27 extern struct sbuf *lprint_sb;
    28 #endif /* !VBOX */
    2920
    3021#ifndef HAVE_STRDUP
     
    7465int show_x _P((char *, struct socket *));
    7566void redir_x _P((u_int32_t, int, int, int));
    76 #ifdef VBOX
    7767void getouraddr _P((PNATState));
    78 #else /* !VBOX */
    79 void getouraddr _P((void));
    80 #endif /* !VBOX */
    8168inline  void slirp_insque  _P((PNATState, void *, void *));
    8269inline  void slirp_remque  _P((PNATState, void *));
    8370int add_exec _P((struct ex_list **, int, char *, int, int));
    8471int slirp_openpty _P((int *, int *));
    85 #ifdef VBOX
    8672int fork_exec _P((PNATState, struct socket *, char *, int));
    87 #else /* !VBOX */
    88 int fork_exec _P((struct socket *, char *, int));
    89 #endif /* !VBOX */
    9073void snooze_hup _P((int));
    9174void snooze _P((void));
     
    9780int rsh_exec _P((struct socket *, struct socket *, char *, char *, char *));
    9881
    99 #if defined(VBOX) && defined(_MSC_VER)
     82#ifdef _MSC_VER
    10083void insque(void *a, void *b);
    10184void remque(void *a);
  • trunk/src/VBox/Devices/Network/slirp/sbuf.c

    r1033 r1076  
    7373 */
    7474void
    75 #ifdef VBOX
    7675sbappend(PNATState pData, struct socket *so, struct mbuf *m)
    77 #else /* !VBOX */
    78 sbappend(so, m)
    79         struct socket *so;
    80         struct mbuf *m;
    81 #endif /* !VBOX */
    8276{
    8377        int ret = 0;
     
    9084        /* Shouldn't happen, but...  e.g. foreign host closes connection */
    9185        if (m->m_len <= 0) {
    92 #ifdef VBOX
    9386                m_free(pData, m);
    94 #else /* !VBOX */
    95                 m_free(m);
    96 #endif /* !VBOX */
    9787                return;
    9888        }
     
    10595        if (so->so_urgc) {
    10696                sbappendsb(&so->so_rcv, m);
    107 #ifdef VBOX
    10897                m_free(pData, m);
    109 #else /* !VBOX */
    110                 m_free(m);
    111 #endif /* !VBOX */
    11298                sosendoob(so);
    11399                return;
     
    139125        } /* else */
    140126        /* Whatever happened, we free the mbuf */
    141 #ifdef VBOX
    142127        m_free(pData, m);
    143 #else /* !VBOX */
    144         m_free(m);
    145 #endif /* !VBOX */
    146128}
    147129
  • trunk/src/VBox/Devices/Network/slirp/sbuf.h

    r1033 r1076  
    2525void sbdrop _P((struct sbuf *, int));
    2626void sbreserve _P((struct sbuf *, int));
    27 #ifdef VBOX
    2827void sbappend _P((PNATState, struct socket *, struct mbuf *));
    29 #else /* !VBOX */
    30 void sbappend _P((struct socket *, struct mbuf *));
    31 #endif /* !VBOX */
    3228void sbappendsb _P((struct sbuf *, struct mbuf *));
    3329void sbcopy _P((struct sbuf *, int, int, char *));
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r1039 r1076  
    33# include <paths.h>
    44#endif
    5 #ifdef VBOX
    6 # include <VBox/err.h>
    7 # include <iprt/assert.h>
    8 #endif
    9 
    10 #ifndef VBOX
    11 /* host address */
    12 struct in_addr our_addr;
    13 /* host dns address */
    14 struct in_addr dns_addr;
    15 /* host loopback address */
    16 struct in_addr loopback_addr;
    17 
    18 /* address for slirp virtual addresses */
    19 struct in_addr special_addr;
    20 /* virtual address alias for host */
    21 struct in_addr alias_addr;
    22 #endif /* !VBOX */
    23 
    24 #ifdef VBOX
     5
     6#include <VBox/err.h>
     7#include <iprt/assert.h>
     8
    259static const uint8_t special_ethaddr[6] = {
    26 #else /* !VBOX */
    27 const uint8_t special_ethaddr[6] = {
    28 #endif /* !VBOX */
    2910    0x52, 0x54, 0x00, 0x12, 0x35, 0x00
    3011};
    3112
    32 #ifndef VBOX
    33 uint8_t client_ethaddr[6];
    34 
    35 int do_slowtimo;
    36 int link_up;
    37 struct timeval tt;
    38 FILE *lfd;
    39 struct ex_list *exec_list;
    40 #endif /* !VBOX */
    41 
    42 #ifndef VBOX
    43 /* XXX: suppress those select globals */
    44 fd_set *global_readfds, *global_writefds, *global_xfds;
    45 
    46 char slirp_hostname[33];
    47 #endif /* !VBOX */
    48 
    4913#ifdef _WIN32
    5014
    51 #ifdef VBOX
    5215static int get_dns_addr(PNATState pData, struct in_addr *pdns_addr)
    53 #else /* !VBOX */
    54 static int get_dns_addr(struct in_addr *pdns_addr)
    55 #endif /* !VBOX */
    5616{
    5717    FIXED_INFO *FixedInfo=NULL;
     
    7333
    7434    if ((ret = GetNetworkParams(FixedInfo, &BufLen)) != ERROR_SUCCESS) {
    75 #ifndef VBOX
    76         printf("GetNetworkParams failed. ret = %08x\n", (u_int)ret );
    77 #else /* VBOX */
    7835        Log(("GetNetworkParams failed. ret = %08x\n", (u_int)ret ));
    79 #endif /* VBOX */
    8036        if (FixedInfo) {
    8137            GlobalFree(FixedInfo);
     
    8844    inet_aton(pIPAddr->IpAddress.String, &tmp_addr);
    8945    *pdns_addr = tmp_addr;
    90 #ifndef VBOX
    91 #if 0
    92     printf( "DNS Servers:\n" );
    93     printf( "DNS Addr:%s\n", pIPAddr->IpAddress.String );
    94 
    95     pIPAddr = FixedInfo -> DnsServerList.Next;
    96     while ( pIPAddr ) {
    97             printf( "DNS Addr:%s\n", pIPAddr ->IpAddress.String );
    98             pIPAddr = pIPAddr ->Next;
    99     }
    100 #endif
    101 #else /* VBOX */
    10246    Log(("nat: DNS Servers:\n"));
    10347    Log(("nat: DNS Addr:%s\n", pIPAddr->IpAddress.String));
     
    10852            pIPAddr = pIPAddr ->Next;
    10953    }
    110 #endif /* VBOX */
    11154    if (FixedInfo) {
    11255        GlobalFree(FixedInfo);
     
    11861#else
    11962
    120 #ifdef VBOX
    12163static int get_dns_addr(PNATState pData, struct in_addr *pdns_addr)
    122 #else /* !VBOX */
    123 static int get_dns_addr(struct in_addr *pdns_addr)
    124 #endif /* !VBOX */
    12564{
    12665    char buff[512];
     
    15392        return -1;
    15493
    155 #ifndef VBOX
    156     lprint("IP address of your DNS(s): ");
    157 #else /* VBOX */
    15894    Log(("nat: IP address of your DNS(s): \n"));
    159 #endif /* VBOX */
    16095    while (fgets(buff, 512, f) != NULL) {
    16196        if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) {
     
    167102            if (!found)
    168103                *pdns_addr = tmp_addr;
    169 #ifndef VBOX
    170             else
    171                 lprint(", ");
    172 #endif /* !VBOX */
    173104            if (++found > 3) {
    174 #ifndef VBOX
    175                 lprint("(more)");
    176 #else /* VBOX */
    177105                Log(("nat: (more)\n"));
    178 #endif /* VBOX */
    179106                break;
    180107            } else
    181 #ifndef VBOX
    182                 lprint("%s", inet_ntoa(tmp_addr));
    183 #else /* VBOX */
    184108                Log(("nat: %s\n", inet_ntoa(tmp_addr)));
    185 #endif /* VBOX */
    186109        }
    187110    }
     
    194117#endif
    195118
    196 #ifndef VBOX
    197 #ifdef _WIN32
    198 void slirp_cleanup(void)
    199 {
    200     WSACleanup();
    201 }
    202 #endif
    203 #endif /* !VBOX (see slirp_term) */
    204 
    205 #ifndef VBOX
    206 void slirp_init(void)
    207 {
    208     /*    debug_init("/tmp/slirp.log", DEBUG_DEFAULT); */
    209 #else /* VBOX */
    210 /** Number of slirp users. Used for making sure init and term are only executed once. */
    211119int slirp_init(PNATState *ppData, const char *pszNetAddr, void *pvUser)
    212120{
     
    220128    pData->cpvHashUsed = 1;
    221129#endif
    222 #endif /* VBOX */
    223130
    224131#ifdef _WIN32
     
    226133        WSADATA Data;
    227134        WSAStartup(MAKEWORD(2,0), &Data);
    228 #ifndef VBOX
    229         atexit(slirp_cleanup);
    230 #endif /* !VBOX */
    231     }
    232 #endif
    233 
    234 #ifdef VBOX
     135    }
     136#endif
     137
    235138    Assert(sizeof(struct ip) == 20);
    236 #endif /* VBOX */
    237139    link_up = 1;
    238140
    239 #ifdef VBOX
    240141    if_init(pData);
    241142    ip_init(pData);
    242 #else /* !VBOX */
    243     if_init();
    244     ip_init();
    245 #endif /* !VBOX */
    246143
    247144    /* Initialise mbufs *after* setting the MTU */
    248 #ifdef VBOX
    249145    m_init(pData);
    250 #else /* !VBOX */
    251     m_init();
    252 #endif /* !VBOX */
    253146
    254147    /* set default addresses */
    255148    inet_aton("127.0.0.1", &loopback_addr);
    256149
    257 #ifdef VBOX
    258150    if (get_dns_addr(pData, &dns_addr) < 0) {
    259 #else /* !VBOX */
    260     if (get_dns_addr(&dns_addr) < 0) {
    261 #endif /* !VBOX */
    262 #ifndef VBOX
    263         dns_addr = loopback_addr;
    264         fprintf (stderr, "Warning: No DNS servers found\n");
    265 #else
    266151        return VERR_NAT_DNS;
    267 #endif
    268     }
    269 
    270 #ifdef VBOX
     152    }
     153
    271154    inet_aton(pszNetAddr, &special_addr);
    272 #else /* !VBOX */
    273     inet_aton(CTL_SPECIAL, &special_addr);
    274 #endif /* !VBOX */
    275155    alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
    276 #ifdef VBOX
    277156    getouraddr(pData);
    278157    return VINF_SUCCESS;
    279 #else /* !VBOX */
    280     getouraddr();
    281 #endif /* !VBOX */
    282 }
    283 
    284 #ifdef VBOX
     158}
     159
    285160/**
    286161 * Marks the link as up, making it possible to establish new connections.
     
    343218    free(pData);
    344219}
    345 #endif /* VBOX */
    346220
    347221
     
    354228 */
    355229#ifdef _WIN32
    356 #ifdef VBOX
    357230static void updtime(PNATState pData)
    358 #else /* !VBOX */
    359 static void updtime(void)
    360 #endif /* !VBOX */
    361231{
    362232    struct _timeb tb;
     
    367237}
    368238#else
    369 #ifdef VBOX
    370239static void updtime(PNATState pData)
    371 #else /* !VBOX */
    372 static void updtime(void)
    373 #endif /* !VBOX */
    374240{
    375241        gettimeofday(&tt, 0);
     
    383249#endif
    384250
    385 #ifdef VBOX
    386251void slirp_select_fill(PNATState pData, int *pnfds,
    387252                       fd_set *readfds, fd_set *writefds, fd_set *xfds)
    388 #else /* !VBOX */
    389 void slirp_select_fill(int *pnfds,
    390                        fd_set *readfds, fd_set *writefds, fd_set *xfds)
    391 #endif /* !VBOX */
    392253{
    393254    struct socket *so, *so_next;
     
    395256    int nfds;
    396257    int tmp_time;
    397 
    398 #ifndef VBOX
    399     /* fail safe */
    400     global_readfds = NULL;
    401     global_writefds = NULL;
    402     global_xfds = NULL;
    403 #endif /* !VBOX */
    404258
    405259    nfds = *pnfds;
     
    481335                        if (so->so_expire) {
    482336                                if (so->so_expire <= curtime) {
    483 #ifdef VBOX
    484337                                        udp_detach(pData, so);
    485 #else /* !VBOX */
    486                                         udp_detach(so);
    487 #endif /* !VBOX */
    488338                                        continue;
    489339                                } else
     
    544394}
    545395
    546 #ifdef VBOX
    547396void slirp_select_poll(PNATState pData, fd_set *readfds, fd_set *writefds, fd_set *xfds)
    548 #else /* !VBOX */
    549 void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds)
    550 #endif /* !VBOX */
    551397{
    552398    struct socket *so, *so_next;
    553399    int ret;
    554400
    555 #ifndef VBOX
    556     global_readfds = readfds;
    557     global_writefds = writefds;
    558     global_xfds = xfds;
    559 #endif /* !VBOX */
    560 
    561401        /* Update time */
    562 #ifdef VBOX
    563402        updtime(pData);
    564 #else /* !VBOX */
    565         updtime();
    566 #endif /* !VBOX */
    567403
    568404        /*
     
    571407        if (link_up) {
    572408                if (time_fasttimo && ((curtime - time_fasttimo) >= 2)) {
    573 #ifdef VBOX
    574409                        tcp_fasttimo(pData);
    575 #else /* !VBOX */
    576                         tcp_fasttimo();
    577 #endif /* !VBOX */
    578410                        time_fasttimo = 0;
    579411                }
    580412                if (do_slowtimo && ((curtime - last_slowtimo) >= 499)) {
    581 #ifdef VBOX
    582413                        ip_slowtimo(pData);
    583414                        tcp_slowtimo(pData);
    584 #else /* !VBOX */
    585                         ip_slowtimo();
    586                         tcp_slowtimo();
    587 #endif /* !VBOX */
    588415                        last_slowtimo = curtime;
    589416                }
     
    613440                         */
    614441                        if (FD_ISSET(so->s, xfds))
    615 #ifdef VBOX
    616442                           sorecvoob(pData, so);
    617 #else /* !VBOX */
    618                            sorecvoob(so);
    619 #endif /* !VBOX */
    620443                        /*
    621444                         * Check sockets for reading
     
    626449                                 */
    627450                                if (so->so_state & SS_FACCEPTCONN) {
    628 #ifdef VBOX
    629451                                        tcp_connect(pData, so);
    630 #else /* !VBOX */
    631                                         tcp_connect(so);
    632 #endif /* !VBOX */
    633452                                        continue;
    634453                                } /* else */
    635 #ifdef VBOX
    636454                                ret = soread(pData, so);
    637 #else /* !VBOX */
    638                                 ret = soread(so);
    639 #endif /* !VBOX */
    640455
    641456                                /* Output it if we read something */
    642457                                if (ret > 0)
    643 #ifdef VBOX
    644458                                   tcp_output(pData, sototcpcb(so));
    645 #else /* !VBOX */
    646                                    tcp_output(sototcpcb(so));
    647 #endif /* !VBOX */
    648459                        }
    649460
     
    674485                             * Continue tcp_input
    675486                             */
    676 #ifdef VBOX
    677487                            tcp_input(pData, (struct mbuf *)NULL, sizeof(struct ip), so);
    678 #else /* !VBOX */
    679                             tcp_input((struct mbuf *)NULL, sizeof(struct ip), so);
    680 #endif /* !VBOX */
    681488                            /* continue; */
    682489                          } else
    683 #ifdef VBOX
    684490                            ret = sowrite(pData, so);
    685 #else /* !VBOX */
    686                             ret = sowrite(so);
    687 #endif /* !VBOX */
    688491                          /*
    689492                           * XXXXX If we wrote something (a lot), there
     
    739542
    740543                        if (so->s != -1 && FD_ISSET(so->s, readfds)) {
    741 #ifdef VBOX
    742544                            sorecvfrom(pData, so);
    743 #else /* !VBOX */
    744                             sorecvfrom(so);
    745 #endif /* !VBOX */
    746545                        }
    747546                }
     
    752551         */
    753552        if (if_queued && link_up)
    754 #ifdef VBOX
    755553           if_start(pData);
    756 #else /* !VBOX */
    757            if_start();
    758 #endif /* !VBOX */
    759 
    760 #ifndef VBOX
    761         /* clear global file descriptor sets.
    762          * these reside on the stack in vl.c
    763          * so they're unusable if we're not in
    764          * slirp_select_fill or slirp_select_poll.
    765          */
    766          global_readfds = NULL;
    767          global_writefds = NULL;
    768          global_xfds = NULL;
    769 #endif /* !VBOX */
    770554}
    771555
     
    803587};
    804588
    805 #ifdef VBOX
    806589static
    807590void arp_input(PNATState pData, const uint8_t *pkt, int pkt_len)
    808 #else /* !VBOX */
    809 void arp_input(const uint8_t *pkt, int pkt_len)
    810 #endif /* !VBOX */
    811591{
    812592    struct ethhdr *eh = (struct ethhdr *)pkt;
     
    848628            memcpy(rah->ar_tha, ah->ar_sha, ETH_ALEN);
    849629            memcpy(rah->ar_tip, ah->ar_sip, 4);
    850 #ifdef VBOX
    851630            slirp_output(pData->pvUser, arp_reply, sizeof(arp_reply));
    852 #else /* !VBOX */
    853             slirp_output(arp_reply, sizeof(arp_reply));
    854 #endif /* !VBOX */
    855631        }
    856632        break;
     
    860636}
    861637
    862 #ifdef VBOX
    863638void slirp_input(PNATState pData, const uint8_t *pkt, int pkt_len)
    864 #else /* !VBOX */
    865 void slirp_input(const uint8_t *pkt, int pkt_len)
    866 #endif /* !VBOX */
    867639{
    868640    struct mbuf *m;
     
    875647    switch(proto) {
    876648    case ETH_P_ARP:
    877 #ifdef VBOX
    878649        arp_input(pData, pkt, pkt_len);
    879 #else /* !VBOX */
    880         arp_input(pkt, pkt_len);
    881 #endif /* !VBOX */
    882650        break;
    883651    case ETH_P_IP:
    884 #ifdef VBOX
    885652        m = m_get(pData);
    886 #else /* !VBOX */
    887         m = m_get();
    888 #endif /* !VBOX */
    889653        if (!m)
    890654            return;
     
    896660        m->m_len -= 2 + ETH_HLEN;
    897661
    898 #ifdef VBOX
    899662        ip_input(pData, m);
    900 #else /* !VBOX */
    901         ip_input(m);
    902 #endif /* !VBOX */
    903663        break;
    904664    default:
     
    908668
    909669/* output the IP packet to the ethernet device */
    910 #ifdef VBOX
    911670void if_encap(PNATState pData, const uint8_t *ip_data, int ip_data_len)
    912 #else /* !VBOX */
    913 void if_encap(const uint8_t *ip_data, int ip_data_len)
    914 #endif /* !VBOX */
    915671{
    916672    uint8_t buf[1600];
     
    926682    eh->h_proto = htons(ETH_P_IP);
    927683    memcpy(buf + sizeof(struct ethhdr), ip_data, ip_data_len);
    928 #ifdef VBOX
    929684    slirp_output(pData->pvUser, buf, ip_data_len + ETH_HLEN);
    930 #else /* !VBOX */
    931     slirp_output(buf, ip_data_len + ETH_HLEN);
    932 #endif /* !VBOX */
    933685}
    934686
     
    937689{
    938690    if (is_udp) {
    939 #ifdef VBOX
    940691        if (!udp_listen(pData, htons(host_port), guest_addr.s_addr,
    941692                        htons(guest_port), 0))
    942 #else /* !VBOX */
    943         if (!udp_listen(htons(host_port), guest_addr.s_addr,
    944                         htons(guest_port), 0))
    945 #endif /* !VBOX */
    946693            return -1;
    947694    } else {
    948 #ifdef VBOX
    949695        if (!solisten(pData, htons(host_port), guest_addr.s_addr,
    950696                      htons(guest_port), 0))
    951 #else /* !VBOX */
    952         if (!solisten(htons(host_port), guest_addr.s_addr,
    953                       htons(guest_port), 0))
    954 #endif /* !VBOX */
    955697            return -1;
    956698    }
     
    958700}
    959701
    960 #ifdef VBOX
    961702int slirp_add_exec(PNATState pData, int do_pty, const char *args, int addr_low_byte,
    962703                  int guest_port)
    963 #else /* !VBOX */
    964 int slirp_add_exec(int do_pty, const char *args, int addr_low_byte,
    965                   int guest_port)
    966 #endif /* !VBOX */
    967704{
    968705    return add_exec(&exec_list, do_pty, (char *)args,
  • trunk/src/VBox/Devices/Network/slirp/slirp.h

    r1045 r1076  
    22#define __COMMON_H__
    33
    4 #if defined(VBOX) && defined(__WIN__)
     4#ifdef __WIN__
    55# include <winsock2.h>
    66typedef int socklen_t;
    77#endif
    8 #if defined(VBOX) && defined(__OS2__) /* temporary workaround, see ticket #127 */
     8#ifdef __OS2__ /* temporary workaround, see ticket #127 */
    99# define mbstat mbstat_os2
    1010# include <sys/socket.h>
     
    1515#define CONFIG_QEMU
    1616
    17 #ifndef VBOX
    18 #define DEBUG 1
    19 #else /* VBOX */
    20 # ifdef DEBUG
    21 #  undef  DEBUG
    22 #  define DEBUG 1
    23 # endif
    24 #endif /* VBOX */
     17#ifdef DEBUG
     18# undef  DEBUG
     19# define DEBUG 1
     20#endif
    2521
    2622#ifndef CONFIG_QEMU
    2723#include "version.h"
    2824#endif
    29 #ifndef VBOX
    30 #include "config.h"
    31 #else /* VBOX */
    32 # define LOG_GROUP LOG_GROUP_DRV_NAT
    33 # include <VBox/log.h>
    34 # include <iprt/mem.h>
    35 # ifdef __WIN__
    36 #  include <windows.h>
    37 #  include <io.h>
    38 # endif
    39 # include <iprt/assert.h>
    40 # include <iprt/string.h>
    41 # include <VBox/types.h>
     25#define LOG_GROUP LOG_GROUP_DRV_NAT
     26#include <VBox/log.h>
     27#include <iprt/mem.h>
     28#ifdef __WIN__
     29# include <windows.h>
     30# include <io.h>
     31#endif
     32#include <iprt/assert.h>
     33#include <iprt/string.h>
     34#include <VBox/types.h>
    4235
    4336# define malloc(a)       RTMemAllocZ(a)
     
    4538# define realloc(a,b)    RTMemRealloc(a, b)
    4639
    47 #endif /* VBOX */
    4840#include "slirp_config.h"
    4941
     
    5244#ifndef _MSC_VER
    5345# include <inttypes.h>
    54 #endif /* !VBOX */
     46#endif
    5547
    5648typedef uint8_t u_int8_t;
     
    6052typedef char *caddr_t;
    6153
    62 #ifndef VBOX
    63 # include <windows.h>
    64 # include <winsock2.h>
    65 #endif /* !VBOX */
    6654# include <sys/timeb.h>
    6755# include <iphlpapi.h>
     
    238226#endif
    239227
    240 #ifdef VBOX
    241228#include "libslirp.h"
    242 #endif /* !VBOX */
    243229
    244230#include "debug.h"
     
    265251#include "bootp.h"
    266252#include "tftp.h"
    267 #ifndef VBOX
    268 #include "libslirp.h"
    269 #endif /* !VBOX */
    270 
    271 #ifdef VBOX
     253
    272254#include "slirp_state.h"
    273 #endif /* VBOX */
    274 
    275 #ifndef VBOX
    276 extern struct ttys *ttys_unit[MAX_INTERFACES];
    277 #endif /* !VBOX */
    278255
    279256#ifndef NULL
     
    281258#endif
    282259
    283 #ifdef VBOX
    284260void if_start _P((PNATState));
    285 #else /* !VBOX */
    286 #ifndef FULL_BOLT
    287 void if_start _P((void));
    288 #else
    289 void if_start _P((struct ttys *));
    290 #endif
    291 #endif /* !VBOX */
    292261
    293262#ifdef BAD_SPRINTF
     
    317286#endif
    318287
    319 #ifndef VBOX
    320 void lprint _P((const char *, ...));
    321 #else
    322288DECLINLINE(void) lprint (const char *pszFormat, ...)
    323289{
     
    333299#endif
    334300}
    335 #endif
    336301
    337302extern int do_echo;
     
    360325
    361326/* if.c */
    362 #ifdef VBOX
    363327void if_init _P((PNATState));
    364328void if_output _P((PNATState, struct socket *, struct mbuf *));
    365 #else /* VBOX */
    366 void if_init _P((void));
    367 void if_output _P((struct socket *, struct mbuf *));
    368 #endif /* VBOX */
    369329
    370330/* ip_input.c */
    371 #ifdef VBOX
    372331void ip_init _P((PNATState));
    373332void ip_input _P((PNATState, struct mbuf *));
     
    377336void ip_deq _P((PNATState, register struct ipasfrag *));
    378337void ip_slowtimo _P((PNATState));
    379 #else /* !VBOX */
    380 void ip_init _P((void));
    381 void ip_input _P((struct mbuf *));
    382 struct ip * ip_reass _P((register struct ipasfrag *, register struct ipq *));
    383 void ip_freef _P((struct ipq *));
    384 void ip_enq _P((register struct ipasfrag *, register struct ipasfrag *));
    385 void ip_deq _P((register struct ipasfrag *));
    386 void ip_slowtimo _P((void));
    387 #endif /* !VBOX */
    388338void ip_stripoptions _P((register struct mbuf *, struct mbuf *));
    389339
    390340/* ip_output.c */
    391 #ifdef VBOX
    392341int ip_output _P((PNATState, struct socket *, struct mbuf *));
    393 #else /* !VBOX */
    394 int ip_output _P((struct socket *, struct mbuf *));
    395 #endif /* !VBOX */
    396342
    397343/* tcp_input.c */
    398 #ifdef VBOX
    399344int tcp_reass _P((PNATState, register struct tcpcb *, register struct tcpiphdr *, struct mbuf *));
    400345void tcp_input _P((PNATState, register struct mbuf *, int, struct socket *));
     
    402347void tcp_xmit_timer _P((PNATState, register struct tcpcb *, int));
    403348int tcp_mss _P((PNATState, register struct tcpcb *, u_int));
    404 #else /* !VBOX */
    405 int tcp_reass _P((register struct tcpcb *, register struct tcpiphdr *, struct mbuf *));
    406 void tcp_input _P((register struct mbuf *, int, struct socket *));
    407 void tcp_dooptions _P((struct tcpcb *, u_char *, int, struct tcpiphdr *));
    408 void tcp_xmit_timer _P((register struct tcpcb *, int));
    409 int tcp_mss _P((register struct tcpcb *, u_int));
    410 #endif /* !VBOX */
    411349
    412350/* tcp_output.c */
    413 #ifdef VBOX
    414351int tcp_output _P((PNATState, register struct tcpcb *));
    415 #else /* !VBOX */
    416 int tcp_output _P((register struct tcpcb *));
    417 #endif /* !VBOX */
    418352void tcp_setpersist _P((register struct tcpcb *));
    419353
    420354/* tcp_subr.c */
    421 #ifdef VBOX
    422355void tcp_init _P((PNATState));
    423 #else /* !VBOX */
    424 void tcp_init _P((void));
    425 #endif /* !VBOX */
    426356void tcp_template _P((struct tcpcb *));
    427 #ifdef VBOX
    428357void tcp_respond _P((PNATState, struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
    429358struct tcpcb * tcp_newtcpcb _P((PNATState, struct socket *));
    430359struct tcpcb * tcp_close _P((PNATState, register struct tcpcb *));
    431 #else /* !VBOX */
    432 void tcp_respond _P((struct tcpcb *, register struct tcpiphdr *, register struct mbuf *, tcp_seq, tcp_seq, int));
    433 struct tcpcb * tcp_newtcpcb _P((struct socket *));
    434 struct tcpcb * tcp_close _P((register struct tcpcb *));
    435 #endif /* !VBOX */
    436360void tcp_drain _P((void));
    437 #ifdef VBOX
    438361void tcp_sockclosed _P((PNATState, struct tcpcb *));
    439362int tcp_fconnect _P((PNATState, struct socket *));
    440363void tcp_connect _P((PNATState, struct socket *));
    441364int tcp_attach _P((PNATState, struct socket *));
    442 #else /* !VBOX */
    443 void tcp_sockclosed _P((struct tcpcb *));
    444 int tcp_fconnect _P((struct socket *));
    445 void tcp_connect _P((struct socket *));
    446 int tcp_attach _P((struct socket *));
    447 #endif /* !VBOX */
    448365u_int8_t tcp_tos _P((struct socket *));
    449 #ifdef VBOX
    450366int tcp_emu _P((PNATState, struct socket *, struct mbuf *));
    451367int tcp_ctl _P((PNATState, struct socket *));
    452368struct tcpcb *tcp_drop(PNATState, struct tcpcb *tp, int err);
    453 #else /* !VBOX */
    454 int tcp_emu _P((struct socket *, struct mbuf *));
    455 int tcp_ctl _P((struct socket *));
    456 struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
    457 #endif /* !VBOX */
    458369
    459370#ifdef USE_PPP
  • trunk/src/VBox/Devices/Network/slirp/slirp_config.h

    r1 r1076  
    5555#undef DUMMY_PPP
    5656
    57 #if defined(VBOX) && defined(_MSC_VER)
     57#ifdef _MSC_VER
    5858#undef HAVE_UNISTD_H
    5959#else
    6060/* Define if you have unistd.h */
    6161#define HAVE_UNISTD_H
    62 #endif /* VBOX */
     62#endif
    6363
    6464/* Define if you have stdlib.h */
     
    133133
    134134/* Define to whatever your compiler thinks inline should be */
    135 #ifndef VBOX
    136 #define inline inline
    137 #else /* VBOX */
    138135#if defined(_MSC_VER) && !defined(__cplusplus)
    139136# define inline _inline
     
    141138# define inline inline
    142139#endif
    143 #endif /* VBOX */
    144140
    145141/* Define to whatever your compiler thinks const should be */
     
    165161
    166162/* Define to sizeof(char *) */
    167 #ifdef VBOX
    168163#define HOST_LONG_BITS ARCH_BITS
    169 #endif /* VBOX */
    170164#define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
    171165
  • trunk/src/VBox/Devices/Network/slirp/socket.c

    r1048 r1076  
    6868 */
    6969void
    70 #ifdef VBOX
    7170sofree(PNATState pData, struct socket *so)
    72 #else /* !VBOX */
    73 sofree(so)
    74         struct socket *so;
    75 #endif /* !VBOX */
    7671{
    7772  if (so->so_emu==EMU_RSH && so->extra) {
    78 #ifdef VBOX
    7973        sofree(pData, so->extra);
    80 #else /* !VBOX */
    81         sofree(so->extra);
    82 #endif /* !VBOX */
    8374        so->extra=NULL;
    8475  }
     
    8879    udp_last_so = &udb;
    8980
    90 #ifdef VBOX
    9181  m_free(pData, so->so_m);
    92 #else /* !VBOX */
    93   m_free(so->so_m);
    94 #endif /* !VBOX */
    9582
    9683  if(so->so_next && so->so_prev)
     
    10693 */
    10794int
    108 #ifdef VBOX
    10995soread(PNATState pData, struct socket *so)
    110 #else /* !VBOX */
    111 soread(so)
    112         struct socket *so;
    113 #endif /* !VBOX */
    11496{
    11597        int n, nn, lss, total;
     
    180162                        DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno)));
    181163                        sofcantrcvmore(so);
    182 #ifdef VBOX
    183164                        tcp_sockclosed(pData, sototcpcb(so));
    184 #else /* !VBOX */
    185                         tcp_sockclosed(sototcpcb(so));
    186 #endif /* !VBOX */
    187165                        return -1;
    188166                }
     
    225203 */
    226204void
    227 #ifdef VBOX
    228205sorecvoob(PNATState pData, struct socket *so)
    229 #else /* !VBOX */
    230 sorecvoob(so)
    231         struct socket *so;
    232 #endif /* !VBOX */
    233206{
    234207        struct tcpcb *tp = sototcpcb(so);
     
    245218         * urgent data.
    246219         */
    247 #ifdef VBOX
    248220        soread(pData, so);
    249 #else /* !VBOX */
    250         soread(so);
    251 #endif /* !VBOX */
    252221        tp->snd_up = tp->snd_una + so->so_snd.sb_cc;
    253222        tp->t_force = 1;
    254 #ifdef VBOX
    255223        tcp_output(pData, tp);
    256 #else /* !VBOX */
    257         tcp_output(tp);
    258 #endif /* !VBOX */
    259224        tp->t_force = 0;
    260225}
     
    324289 */
    325290int
    326 #ifdef VBOX
    327291sowrite(PNATState pData, struct socket *so)
    328 #else /* !VBOX */
    329 sowrite(so)
    330         struct socket *so;
    331 #endif /* !VBOX */
    332292{
    333293        int  n,nn;
     
    387347                        so->so_state, errno));
    388348                sofcantsendmore(so);
    389 #ifdef VBOX
    390349                tcp_sockclosed(pData, sototcpcb(so));
    391 #else /* !VBOX */
    392                 tcp_sockclosed(sototcpcb(so));
    393 #endif /* !VBOX */
    394350                return -1;
    395351        }
     
    425381 */
    426382void
    427 #ifdef VBOX
    428383sorecvfrom(PNATState pData, struct socket *so)
    429 #else /* !VBOX */
    430 sorecvfrom(so)
    431         struct socket *so;
    432 #endif /* !VBOX */
    433384{
    434385        struct sockaddr_in addr;
    435 #ifndef VBOX
    436         int addrlen = sizeof(struct sockaddr_in);
    437 #else /* VBOX */
    438386        socklen_t addrlen = sizeof(struct sockaddr_in);
    439 #endif /* VBOX */
    440387
    441388        DEBUG_CALL("sorecvfrom");
     
    458405            DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
    459406                        errno,strerror(errno)));
    460 #ifdef VBOX
    461407            icmp_error(pData, so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
    462 #else /* !VBOX */
    463             icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
    464 #endif /* !VBOX */
    465408          } else {
    466 #ifdef VBOX
    467409            icmp_reflect(pData, so->so_m);
    468 #else /* !VBOX */
    469             icmp_reflect(so->so_m);
    470 #endif /* !VBOX */
    471410            so->so_m = 0; /* Don't m_free() it again! */
    472411          }
    473412          /* No need for this socket anymore, udp_detach it */
    474 #ifdef VBOX
    475413          udp_detach(pData, so);
    476 #else /* !VBOX */
    477           udp_detach(so);
    478 #endif /* !VBOX */
    479414        } else {                                /* A "normal" UDP packet */
    480415          struct mbuf *m;
    481416          int len, n;
    482417
    483 #ifdef VBOX
    484418          if (!(m = m_get(pData))) return;
    485 #else /* !VBOX */
    486           if (!(m = m_get())) return;
    487 #endif /* !VBOX */
    488419          m->m_data += if_maxlinkhdr;
    489420
     
    514445
    515446            DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
    516 #ifdef VBOX
    517447            icmp_error(pData, so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
    518448            m_free(pData, m);
    519 #else /* !VBOX */
    520             icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
    521             m_free(m);
    522 #endif /* !VBOX */
    523449          } else {
    524450          /*
     
    545471             * make it look like that's where it came from, done by udp_output
    546472             */
    547 #ifdef VBOX
    548473            udp_output(pData, so, m, &addr);
    549 #else /* !VBOX */
    550             udp_output(so, m, &addr);
    551 #endif /* !VBOX */
    552474          } /* rx error */
    553475        } /* if ping packet */
     
    558480 */
    559481int
    560 #ifdef VBOX
    561482sosendto(PNATState pData, struct socket *so, struct mbuf *m)
    562 #else /* !VBOX */
    563 sosendto(so, m)
    564         struct socket *so;
    565         struct mbuf *m;
    566 #endif /* !VBOX */
    567483{
    568484        int ret;
     
    611527 */
    612528struct socket *
    613 #ifdef VBOX
    614529solisten(PNATState pData, u_int port, u_int32_t laddr, u_int lport, int flags)
    615 #else /* !VBOX */
    616 solisten(port, laddr, lport, flags)
    617         u_int port;
    618         u_int32_t laddr;
    619         u_int lport;
    620         int flags;
    621 #endif /* !VBOX */
    622530{
    623531        struct sockaddr_in addr;
    624532        struct socket *so;
    625 #ifndef VBOX
    626         int s, addrlen = sizeof(addr), opt = 1;
    627 #else /* VBOX */
    628533        socklen_t addrlen = sizeof(addr);
    629534        int s, opt = 1;
    630 #endif /* VBOX */
    631535
    632536        DEBUG_CALL("solisten");
     
    666570            (bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) ||
    667571            (listen(s,1) < 0)) {
    668 #ifndef VBOX
    669                 int tmperrno = errno; /* Don't clobber the real reason we failed */
    670 
    671                 close(s);
    672                 sofree(so);
    673                 /* Restore the real errno */
    674 #ifdef _WIN32
    675                 WSASetLastError(tmperrno);
    676 #else
    677                 errno = tmperrno;
    678 #endif
    679 #else /* VBOX */
    680572#ifdef __WIN__
    681573                int tmperrno = WSAGetLastError(); /* Don't clobber the real reason we failed */
     
    691583                errno = tmperrno;
    692584#endif
    693 #endif /* VBOX */
    694585                return NULL;
    695586        }
     
    761652        if ((so->so_state & SS_NOFDREF) == 0) {
    762653                shutdown(so->s,0);
    763 #ifndef VBOX
    764                 if(global_writefds) {
    765                   FD_CLR(so->s,global_writefds);
    766                 }
    767 #endif /* !VBOX */
    768654        }
    769655        so->so_state &= ~(SS_ISFCONNECTING);
     
    780666        if ((so->so_state & SS_NOFDREF) == 0) {
    781667            shutdown(so->s,1);           /* send FIN to fhost */
    782 #ifndef VBOX
    783             if (global_readfds) {
    784                 FD_CLR(so->s,global_readfds);
    785             }
    786             if (global_xfds) {
    787                 FD_CLR(so->s,global_xfds);
    788             }
    789 #endif /* !VBOX */
    790668        }
    791669        so->so_state &= ~(SS_ISFCONNECTING);
  • trunk/src/VBox/Devices/Network/slirp/socket.h

    r1033 r1076  
    8585struct socket * solookup _P((struct socket *, struct in_addr, u_int, struct in_addr, u_int));
    8686struct socket * socreate _P((void));
    87 #ifdef VBOX
    8887void sofree _P((PNATState, struct socket *));
    8988int soread _P((PNATState, struct socket *));
    9089void sorecvoob _P((PNATState, struct socket *));
    91 #else /* !VBOX */
    92 void sofree _P((struct socket *));
    93 int soread _P((struct socket *));
    94 void sorecvoob _P((struct socket *));
    95 #endif /* !VBOX */
    9690int sosendoob _P((struct socket *));
    97 #ifdef VBOX
    9891int sowrite _P((PNATState, struct socket *));
    9992void sorecvfrom _P((PNATState, struct socket *));
    10093int sosendto _P((PNATState, struct socket *, struct mbuf *));
    10194struct socket * solisten _P((PNATState, u_int, u_int32_t, u_int, int));
    102 #else /* !VBOX */
    103 int sowrite _P((struct socket *));
    104 void sorecvfrom _P((struct socket *));
    105 int sosendto _P((struct socket *, struct mbuf *));
    106 struct socket * solisten _P((u_int, u_int32_t, u_int, int));
    107 #endif /* !VBOX */
    10895void sorwakeup _P((struct socket *));
    10996void sowwakeup _P((struct socket *));
  • trunk/src/VBox/Devices/Network/slirp/tcp.h

    r1033 r1076  
    5959        tcp_seq th_seq;                 /* sequence number */
    6060        tcp_seq th_ack;                 /* acknowledgement number */
    61 #ifdef VBOX
    6261/*
    6362 * bitfield types must be u_int8_t for MSVC, otherwise it will use a full dword (for u_int)
    6463 */
    65 #endif
    6664#ifdef WORDS_BIGENDIAN
    6765        u_int   th_off:4,               /* data offset */
     
    180178#define TCP_ISSINCR     (125*1024)      /* increment for tcp_iss each second */
    181179
    182 #ifndef VBOX
    183 extern tcp_seq tcp_iss;                /* tcp initial send seq # */
    184 #endif /* !VBOX */
    185180
    186 #ifdef VBOX
    187181extern const char * const tcpstates[];
    188 #else /* !VBOX */
    189 extern char *tcpstates[];
    190 #endif /* !VBOX */
    191182
    192183#endif
  • trunk/src/VBox/Devices/Network/slirp/tcp_input.c

    r1048 r1076  
    4646#include "ip_icmp.h"
    4747
    48 #ifndef VBOX
    49 struct socket tcb;
    50 
    51 int     tcprexmtthresh = 3;
    52 struct  socket *tcp_last_so = &tcb;
    53 
    54 tcp_seq tcp_iss;                /* tcp initial send seq # */
    55 #endif /* !VBOX */
    5648
    5749#define TCP_PAWS_IDLE   (24 * 24 * 60 * 60 * PR_SLOWHZ)
     
    7163 * when segments are out of order (so fast retransmit can work).
    7264 */
    73 #ifdef VBOX
    7465#ifdef TCP_ACK_HACK
    7566#define TCP_REASS(pData, tp, ti, m, so, flags) {\
     
    116107}
    117108#endif
    118 #else /* !VBOX */
    119 #ifdef TCP_ACK_HACK
    120 #define TCP_REASS(tp, ti, m, so, flags) {\
    121        if ((ti)->ti_seq == (tp)->rcv_nxt && \
    122            u32_to_ptr((tp)->seg_next, struct tcpcb *) == (tp) && \
    123            (tp)->t_state == TCPS_ESTABLISHED) {\
    124                if (ti->ti_flags & TH_PUSH) \
    125                        tp->t_flags |= TF_ACKNOW; \
    126                else \
    127                        tp->t_flags |= TF_DELACK; \
    128                (tp)->rcv_nxt += (ti)->ti_len; \
    129                flags = (ti)->ti_flags & TH_FIN; \
    130                tcpstat.tcps_rcvpack++;\
    131                tcpstat.tcps_rcvbyte += (ti)->ti_len;\
    132                if (so->so_emu) { \
    133                        if (tcp_emu((so),(m))) sbappend((so), (m)); \
    134                } else \
    135                        sbappend((so), (m)); \
    136 /*               sorwakeup(so); */ \
    137         } else {\
    138                (flags) = tcp_reass((tp), (ti), (m)); \
    139                tp->t_flags |= TF_ACKNOW; \
    140        } \
    141 }
    142 #else
    143 #define TCP_REASS(tp, ti, m, so, flags) { \
    144         if ((ti)->ti_seq == (tp)->rcv_nxt && \
    145             u32_to_ptr((tp)->seg_next, struct tcpcb *) == (tp) && \
    146             (tp)->t_state == TCPS_ESTABLISHED) { \
    147                 tp->t_flags |= TF_DELACK; \
    148                 (tp)->rcv_nxt += (ti)->ti_len; \
    149                 flags = (ti)->ti_flags & TH_FIN; \
    150                 tcpstat.tcps_rcvpack++;\
    151                 tcpstat.tcps_rcvbyte += (ti)->ti_len;\
    152                 if (so->so_emu) { \
    153                         if (tcp_emu((so),(m))) sbappend(so, (m)); \
    154                 } else \
    155                         sbappend((so), (m)); \
    156 /*              sorwakeup(so); */ \
    157         } else { \
    158                 (flags) = tcp_reass((tp), (ti), (m)); \
    159                 tp->t_flags |= TF_ACKNOW; \
    160         } \
    161 }
    162 #endif
    163 #endif /* !VBOX */
    164109
    165110int
    166 #ifdef VBOX
    167111tcp_reass(PNATState pData, register struct tcpcb *tp, register struct tcpiphdr *ti, struct mbuf *m)
    168 #else /* !VBOX */
    169 tcp_reass(tp, ti, m)
    170         register struct tcpcb *tp;
    171         register struct tcpiphdr *ti;
    172         struct mbuf *m;
    173 #endif /* !VBOX */
    174112{
    175113        register struct tcpiphdr *q;
     
    206144                                tcpstat.tcps_rcvduppack++;
    207145                                tcpstat.tcps_rcvdupbyte += ti->ti_len;
    208 #ifdef VBOX
    209146                                m_freem(pData, m);
    210 #else /* !VBOX */
    211                                 m_freem(m);
    212 #endif /* !VBOX */
    213147                                /*
    214148                                 * Try to present any queued data
     
    246180                m = REASS_MBUF_GET(u32_to_ptr(pData, q->ti_prev, struct tcpiphdr *));
    247181                remque_32(pData, u32_to_ptr(pData, q->ti_prev, struct tcpiphdr *));
    248 #ifdef VBOX
    249182                m_freem(pData, m);
    250 #else /* !VBOX */
    251                 m_freem(m);
    252 #endif /* !VBOX */
    253183        }
    254184
     
    278208/*              if (so->so_state & SS_FCANTRCVMORE) */
    279209                if (so->so_state & SS_FCANTSENDMORE)
    280 #ifdef VBOX
    281210                        m_freem(pData, m);
    282 #else /* !VBOX */
    283                         m_freem(m);
    284 #endif /* !VBOX */
    285211                else {
    286212                        if (so->so_emu) {
    287 #ifdef VBOX
    288213                                if (tcp_emu(pData, so,m)) sbappend(pData, so, m);
    289 #else /* !VBOX */
    290                                 if (tcp_emu(so,m)) sbappend(so, m);
    291 #endif /* !VBOX */
    292214                        } else
    293 #ifdef VBOX
    294215                                sbappend(pData, so, m);
    295 #else /* !VBOX */
    296                                 sbappend(so, m);
    297 #endif /* !VBOX */
    298216                }
    299217        } while (ti != (struct tcpiphdr *)tp && ti->ti_seq == tp->rcv_nxt);
     
    307225 */
    308226void
    309 #ifdef VBOX
    310227tcp_input(PNATState pData, register struct mbuf *m, int iphlen, struct socket *inso)
    311 #else /* !VBOX */
    312 tcp_input(m, iphlen, inso)
    313         register struct mbuf *m;
    314         int iphlen;
    315         struct socket *inso;
    316 #endif /* !VBOX */
    317228{
    318229        struct ip save_ip, *ip;
     
    475386          if ((so = socreate()) == NULL)
    476387            goto dropwithreset;
    477 #ifdef VBOX
    478388          if (tcp_attach(pData, so) < 0) {
    479 #else /* !VBOX */
    480           if (tcp_attach(so) < 0) {
    481 #endif /* !VBOX */
    482389            free(so); /* Not sofree (if it failed, it's not insqued) */
    483390            goto dropwithreset;
     
    540447         */
    541448        if (optp && tp->t_state != TCPS_LISTEN)
    542 #ifdef VBOX
    543449                tcp_dooptions(pData, tp, (u_char *)optp, optlen, ti);
    544 #else /* !VBOX */
    545                 tcp_dooptions(tp, (u_char *)optp, optlen, ti);
    546 #endif /* !VBOX */
    547450/* , */
    548451/*                      &ts_present, &ts_val, &ts_ecr); */
     
    595498 */                                  if (tp->t_rtt &&
    596499                                            SEQ_GT(ti->ti_ack, tp->t_rtseq))
    597 #ifdef VBOX
    598500                                        tcp_xmit_timer(pData, tp, tp->t_rtt);
    599 #else /* !VBOX */
    600                                         tcp_xmit_timer(tp, tp->t_rtt);
    601 #endif /* !VBOX */
    602501                                acked = ti->ti_ack - tp->snd_una;
    603502                                tcpstat.tcps_rcvackpack++;
     
    605504                                sbdrop(&so->so_snd, acked);
    606505                                tp->snd_una = ti->ti_ack;
    607 #ifdef VBOX
    608506                                m_freem(pData, m);
    609 #else /* !VBOX */
    610                                 m_freem(m);
    611 #endif /* !VBOX */
    612507
    613508                                /*
     
    638533                                 */
    639534                                if (so->so_snd.sb_cc)
    640 #ifdef VBOX
    641535                                        (void) tcp_output(pData, tp);
    642 #else /* !VBOX */
    643                                         (void) tcp_output(tp);
    644 #endif /* !VBOX */
    645536
    646537                                return;
     
    662553                         */
    663554                        if (so->so_emu) {
    664 #ifdef VBOX
    665555                                if (tcp_emu(pData, so,m)) sbappend(pData, so, m);
    666 #else /* !VBOX */
    667                                 if (tcp_emu(so,m)) sbappend(so, m);
    668 #endif /* !VBOX */
    669556                        } else
    670 #ifdef VBOX
    671557                                sbappend(pData, so, m);
    672 #else /* !VBOX */
    673                                 sbappend(so, m);
    674 #endif /* !VBOX */
    675558
    676559                        /*
     
    690573                         */
    691574                        tp->t_flags |= TF_ACKNOW;
    692 #ifdef VBOX
    693575                        tcp_output(pData, tp);
    694 #else /* !VBOX */
    695                         tcp_output(tp);
    696 #endif /* !VBOX */
    697576                        return;
    698577                }
     
    774653          }
    775654
    776 #ifdef VBOX
    777655          if((tcp_fconnect(pData, so) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) {
    778 #else /* !VBOX */
    779           if((tcp_fconnect(so) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) {
    780 #endif /* !VBOX */
    781656            u_char code=ICMP_UNREACH_NET;
    782657            DEBUG_MISC((dfd," tcp fconnect errno = %d-%s\n",
     
    784659            if(errno == ECONNREFUSED) {
    785660              /* ACK the SYN, send RST to refuse the connection */
    786 #ifdef VBOX
    787661              tcp_respond(pData, tp, ti, m, ti->ti_seq+1, (tcp_seq)0,
    788662                          TH_RST|TH_ACK);
    789 #else /* !VBOX */
    790               tcp_respond(tp, ti, m, ti->ti_seq+1, (tcp_seq)0,
    791                           TH_RST|TH_ACK);
    792 #endif /* !VBOX */
    793663            } else {
    794664              if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST;
     
    800670              m->m_len  += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
    801671              *ip=save_ip;
    802 #ifdef VBOX
    803672              icmp_error(pData, m, ICMP_UNREACH,code, 0,strerror(errno));
    804 #else /* !VBOX */
    805               icmp_error(m, ICMP_UNREACH,code, 0,strerror(errno));
    806 #endif /* !VBOX */
    807673            }
    808 #ifdef VBOX
    809674            tp = tcp_close(pData, tp);
    810675            m_free(pData, m);
    811 #else /* !VBOX */
    812             tp = tcp_close(tp);
    813             m_free(m);
    814 #endif /* !VBOX */
    815676          } else {
    816677            /*
     
    832693           */
    833694          if (so->so_state & SS_NOFDREF) {
    834 #ifdef VBOX
    835695            tp = tcp_close(pData, tp);
    836 #else /* !VBOX */
    837             tp = tcp_close(tp);
    838 #endif /* !VBOX */
    839696            goto dropwithreset;
    840697          }
     
    843700
    844701          if (optp)
    845 #ifdef VBOX
    846702            tcp_dooptions(pData, tp, (u_char *)optp, optlen, ti);
    847 #else /* !VBOX */
    848             tcp_dooptions(tp, (u_char *)optp, optlen, ti);
    849 #endif /* !VBOX */
    850703          /* , */
    851704          /*                            &ts_present, &ts_val, &ts_ecr); */
     
    886739                if (tiflags & TH_RST) {
    887740                        if (tiflags & TH_ACK)
    888 #ifdef VBOX
    889741                                tp = tcp_drop(pData, tp,0); /* XXX Check t_softerror! */
    890 #else /* !VBOX */
    891                                 tp = tcp_drop(tp,0); /* XXX Check t_softerror! */
    892 #endif /* !VBOX */
    893742                        goto drop;
    894743                }
     
    918767 *                      }
    919768 */
    920 #ifdef VBOX
    921769                        (void) tcp_reass(pData, tp, (struct tcpiphdr *)0,
    922770                                (struct mbuf *)0);
    923 #else /* !VBOX */
    924                         (void) tcp_reass(tp, (struct tcpiphdr *)0,
    925                                 (struct mbuf *)0);
    926 #endif /* !VBOX */
    927771                        /*
    928772                         * if we didn't have to retransmit the SYN,
     
    930774                         */
    931775                        if (tp->t_rtt)
    932 #ifdef VBOX
    933776                                tcp_xmit_timer(pData, tp, tp->t_rtt);
    934 #else /* !VBOX */
    935                                 tcp_xmit_timer(tp, tp->t_rtt);
    936 #endif /* !VBOX */
    937777                } else
    938778                        tp->t_state = TCPS_SYN_RECEIVED;
     
    1044884        if ((so->so_state & SS_NOFDREF) &&
    1045885            tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) {
    1046 #ifdef VBOX
    1047886                tp = tcp_close(pData, tp);
    1048 #else /* !VBOX */
    1049                 tp = tcp_close(tp);
    1050 #endif /* !VBOX */
    1051887                tcpstat.tcps_rcvafterclose++;
    1052888                goto dropwithreset;
     
    1072908                            SEQ_GT(ti->ti_seq, tp->rcv_nxt)) {
    1073909                                iss = tp->rcv_nxt + TCP_ISSINCR;
    1074 #ifdef VBOX
    1075910                                tp = tcp_close(pData, tp);
    1076 #else /* !VBOX */
    1077                                 tp = tcp_close(tp);
    1078 #endif /* !VBOX */
    1079911                                goto findso;
    1080912                        }
     
    1134966                tp->t_state = TCPS_CLOSED;
    1135967                tcpstat.tcps_drops++;
    1136 #ifdef VBOX
    1137968                tp = tcp_close(pData, tp);
    1138 #else /* !VBOX */
    1139                 tp = tcp_close(tp);
    1140 #endif /* !VBOX */
    1141969                goto drop;
    1142970
     
    1144972        case TCPS_LAST_ACK:
    1145973        case TCPS_TIME_WAIT:
    1146 #ifdef VBOX
    1147974                tp = tcp_close(pData, tp);
    1148 #else /* !VBOX */
    1149                 tp = tcp_close(tp);
    1150 #endif /* !VBOX */
    1151975                goto drop;
    1152976        }
     
    1157981         */
    1158982        if (tiflags & TH_SYN) {
    1159 #ifdef VBOX
    1160983                tp = tcp_drop(pData, tp,0);
    1161 #else /* !VBOX */
    1162                 tp = tcp_drop(tp,0);
    1163 #endif /* !VBOX */
    1164984                goto dropwithreset;
    1165985        }
     
    11961016                if (so->so_state & SS_CTL) {
    11971017                  /* So tcp_ctl reports the right state */
    1198 #ifdef VBOX
    11991018                  ret = tcp_ctl(pData, so);
    1200 #else /* !VBOX */
    1201                   ret = tcp_ctl(so);
    1202 #endif /* !VBOX */
    12031019                  if (ret == 1) {
    12041020                    soisfconnected(so);
     
    12211037 *              }
    12221038 */
    1223 #ifdef VBOX
    12241039                (void) tcp_reass(pData, tp, (struct tcpiphdr *)0, (struct mbuf *)0);
    1225 #else /* !VBOX */
    1226                 (void) tcp_reass(tp, (struct tcpiphdr *)0, (struct mbuf *)0);
    1227 #endif /* !VBOX */
    12281040                tp->snd_wl1 = ti->ti_seq - 1;
    12291041                /* Avoid ack processing; snd_una==ti_ack  =>  dup ack */
     
    12921104                                        tp->snd_nxt = ti->ti_ack;
    12931105                                        tp->snd_cwnd = tp->t_maxseg;
    1294 #ifdef VBOX
    12951106                                        (void) tcp_output(pData, tp);
    1296 #else /* !VBOX */
    1297                                         (void) tcp_output(tp);
    1298 #endif /* !VBOX */
    12991107                                        tp->snd_cwnd = tp->snd_ssthresh +
    13001108                                               tp->t_maxseg * tp->t_dupacks;
     
    13041112                                } else if (tp->t_dupacks > tcprexmtthresh) {
    13051113                                        tp->snd_cwnd += tp->t_maxseg;
    1306 #ifdef VBOX
    13071114                                        (void) tcp_output(pData, tp);
    1308 #else /* !VBOX */
    1309                                         (void) tcp_output(tp);
    1310 #endif /* !VBOX */
    13111115                                        goto drop;
    13121116                                }
     
    13461150 */
    13471151                     if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq))
    1348 #ifdef VBOX
    13491152                        tcp_xmit_timer(pData, tp,tp->t_rtt);
    1350 #else /* !VBOX */
    1351                         tcp_xmit_timer(tp,tp->t_rtt);
    1352 #endif /* !VBOX */
    13531153
    13541154                /*
     
    14451245                case TCPS_LAST_ACK:
    14461246                        if (ourfinisacked) {
    1447 #ifdef VBOX
    14481247                                tp = tcp_close(pData, tp);
    1449 #else /* !VBOX */
    1450                                 tp = tcp_close(tp);
    1451 #endif /* !VBOX */
    14521248                                goto drop;
    14531249                        }
     
    15431339        if ((ti->ti_len || (tiflags&TH_FIN)) &&
    15441340            TCPS_HAVERCVDFIN(tp->t_state) == 0) {
    1545 #ifdef VBOX
    15461341                TCP_REASS(pData, tp, ti, m, so, tiflags);
    1547 #else /* !VBOX */
    1548                 TCP_REASS(tp, ti, m, so, tiflags);
    1549 #endif /* !VBOX */
    15501342                /*
    15511343                 * Note the amount of data that peer has sent into
     
    15551347                len = so->so_rcv.sb_datalen - (tp->rcv_adv - tp->rcv_nxt);
    15561348        } else {
    1557 #ifdef VBOX
    15581349                m_free(pData, m);
    1559 #else /* !VBOX */
    1560                 m_free(m);
    1561 #endif /* !VBOX */
    15621350                tiflags &= ~TH_FIN;
    15631351        }
     
    16501438         */
    16511439        if (needoutput || (tp->t_flags & TF_ACKNOW)) {
    1652 #ifdef VBOX
    16531440                (void) tcp_output(pData, tp);
    1654 #else /* !VBOX */
    1655                 (void) tcp_output(tp);
    1656 #endif /* !VBOX */
    16571441        }
    16581442        return;
     
    16651449        if (tiflags & TH_RST)
    16661450                goto drop;
    1667 #ifdef VBOX
    16681451        m_freem(pData, m);
    1669 #else /* !VBOX */
    1670         m_freem(m);
    1671 #endif /* !VBOX */
    16721452        tp->t_flags |= TF_ACKNOW;
    1673 #ifdef VBOX
    16741453        (void) tcp_output(pData, tp);
    1675 #else /* !VBOX */
    1676         (void) tcp_output(tp);
    1677 #endif /* !VBOX */
    16781454        return;
    16791455
     
    16811457        /* reuses m if m!=NULL, m_free() unnecessary */
    16821458        if (tiflags & TH_ACK)
    1683 #ifdef VBOX
    16841459                tcp_respond(pData, tp, ti, m, (tcp_seq)0, ti->ti_ack, TH_RST);
    1685 #else /* !VBOX */
    1686                 tcp_respond(tp, ti, m, (tcp_seq)0, ti->ti_ack, TH_RST);
    1687 #endif /* !VBOX */
    16881460        else {
    16891461                if (tiflags & TH_SYN) ti->ti_len++;
    1690 #ifdef VBOX
    16911462                tcp_respond(pData, tp, ti, m, ti->ti_seq+ti->ti_len, (tcp_seq)0,
    16921463                    TH_RST|TH_ACK);
    1693 #else /* !VBOX */
    1694                 tcp_respond(tp, ti, m, ti->ti_seq+ti->ti_len, (tcp_seq)0,
    1695                     TH_RST|TH_ACK);
    1696 #endif /* !VBOX */
    16971464        }
    16981465
     
    17031470         * Drop space held by incoming segment and return.
    17041471         */
    1705 #ifdef VBOX
    17061472        m_free(pData, m);
    1707 #else /* !VBOX */
    1708         m_free(m);
    1709 #endif /* !VBOX */
    17101473
    17111474        return;
     
    17171480 */
    17181481void
    1719 #ifdef VBOX
    17201482tcp_dooptions(PNATState pData, struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti)
    1721 #else /* !VBOX */
    1722 tcp_dooptions(tp, cp, cnt, ti)
    1723         struct tcpcb *tp;
    1724         u_char *cp;
    1725         int cnt;
    1726         struct tcpiphdr *ti;
    1727 #endif /* !VBOX */
    17281483{
    17291484        u_int16_t mss;
     
    17561511                        memcpy((char *) &mss, (char *) cp + 2, sizeof(mss));
    17571512                        NTOHS(mss);
    1758 #ifdef VBOX
    17591513                        (void) tcp_mss(pData, tp, mss); /* sets t_maxseg */
    1760 #else /* !VBOX */
    1761                         (void) tcp_mss(tp, mss);        /* sets t_maxseg */
    1762 #endif /* !VBOX */
    17631514                        break;
    17641515
     
    18401591
    18411592void
    1842 #ifdef VBOX
    18431593tcp_xmit_timer(PNATState pData, register struct tcpcb *tp, int rtt)
    1844 #else /* !VBOX */
    1845 tcp_xmit_timer(tp, rtt)
    1846         register struct tcpcb *tp;
    1847         int rtt;
    1848 #endif /* !VBOX */
    18491594{
    18501595        register short delta;
     
    19341679
    19351680int
    1936 #ifdef VBOX
    19371681tcp_mss(PNATState pData, register struct tcpcb *tp, u_int offer)
    1938 #else /* !VBOX */
    1939 tcp_mss(tp, offer)
    1940         register struct tcpcb *tp;
    1941         u_int offer;
    1942 #endif /* !VBOX */
    19431682{
    19441683        struct socket *so = tp->t_socket;
  • trunk/src/VBox/Devices/Network/slirp/tcp_output.c

    r1033 r1076  
    4949 * names instead of the REAL names
    5050 */
    51 #ifdef VBOX
    5251const char * const tcpstates[] = {
    53 #else /* !VBOX */
    54 char *tcpstates[] = {
    55 #endif /* !VBOX */
    5652/*      "CLOSED",       "LISTEN",       "SYN_SENT",     "SYN_RCVD", */
    5753        "REDIRECT",     "LISTEN",       "SYN_SENT",     "SYN_RCVD",
     
    6056};
    6157
    62 #ifdef VBOX
    6358static const u_char  tcp_outflags[TCP_NSTATES] = {
    64 #else /* !VBOX */
    65 u_char  tcp_outflags[TCP_NSTATES] = {
    66 #endif /* !VBOX */
    6759        TH_RST|TH_ACK, 0,      TH_SYN,        TH_SYN|TH_ACK,
    6860        TH_ACK,        TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK,
     
    7769 */
    7870int
    79 #ifdef VBOX
    8071tcp_output(PNATState pData, register struct tcpcb *tp)
    81 #else /* !VBOX */
    82 tcp_output(tp)
    83         register struct tcpcb *tp;
    84 #endif /* !VBOX */
    8572{
    8673        register struct socket *so = tp->t_socket;
     
    298285                        opt[0] = TCPOPT_MAXSEG;
    299286                        opt[1] = 4;
    300 #ifdef VBOX
    301287                        mss = htons((u_int16_t) tcp_mss(pData, tp, 0));
    302 #else /* !VBOX */
    303                         mss = htons((u_int16_t) tcp_mss(tp, 0));
    304 #endif /* !VBOX */
    305288                        memcpy((caddr_t)(opt + 2), (caddr_t)&mss, sizeof(mss));
    306289                        optlen = 4;
     
    365348                }
    366349
    367 #ifdef VBOX
    368350                m = m_get(pData);
    369 #else /* !VBOX */
    370                 m = m_get();
    371 #endif /* !VBOX */
    372351                if (m == NULL) {
    373352/*                      error = ENOBUFS; */
     
    411390                        tcpstat.tcps_sndwinup++;
    412391
    413 #ifdef VBOX
    414392                m = m_get(pData);
    415 #else /* !VBOX */
    416                 m = m_get();
    417 #endif /* !VBOX */
    418393                if (m == NULL) {
    419394/*                      error = ENOBUFS; */
     
    569544 *          so->so_options & SO_DONTROUTE, 0);
    570545 */
    571 #ifdef VBOX
    572546        error = ip_output(pData, so, m);
    573 #else /* !VBOX */
    574         error = ip_output(so, m);
    575 #endif /* !VBOX */
    576547
    577548/* #else
  • trunk/src/VBox/Devices/Network/slirp/tcp_subr.c

    r1052 r1076  
    4646#include <slirp.h>
    4747
    48 #ifndef VBOX
    49 /* patchable/settable parameters for tcp */
    50 int     tcp_mssdflt = TCP_MSS;
    51 int     tcp_rttdflt = TCPTV_SRTTDFLT / PR_SLOWHZ;
    52 int     tcp_do_rfc1323 = 0;     /* Don't do rfc1323 performance enhancements */
    53 int     tcp_rcvspace;   /* You may want to change this */
    54 int     tcp_sndspace;   /* Keep small if you have an error prone link */
    55 #endif /* !VBOX */
    5648
    5749/*
     
    5951 */
    6052void
    61 #ifdef VBOX
    6253tcp_init(PNATState pData)
    63 #else /* !VBOX */
    64 tcp_init()
    65 #endif /* !VBOX */
    6654{
    6755        tcp_iss = 1;            /* wrong */
    6856        tcb.so_next = tcb.so_prev = &tcb;
    69 #ifdef VBOX
    7057        tcp_last_so = &tcb;
    71 #endif /* VBOX */
    72 
    73 #ifndef VBOX
    74         /* tcp_rcvspace = our Window we advertise to the remote */
    75         tcp_rcvspace = TCP_RCVSPACE;
    76         tcp_sndspace = TCP_SNDSPACE;
    77 
    78         /* Make sure tcp_sndspace is at least 2*MSS */
    79         if (tcp_sndspace < 2*(min(if_mtu, if_mru) - sizeof(struct tcpiphdr)))
    80                 tcp_sndspace = 2*(min(if_mtu, if_mru) - sizeof(struct tcpiphdr));
    81 #endif /* !VBOX */
    8258}
    8359
     
    129105 */
    130106void
    131 #ifdef VBOX
    132107tcp_respond(PNATState pData, struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m, tcp_seq ack, tcp_seq seq, int flags)
    133 #else /* !VBOX */
    134 tcp_respond(tp, ti, m, ack, seq, flags)
    135         struct tcpcb *tp;
    136         register struct tcpiphdr *ti;
    137         register struct mbuf *m;
    138         tcp_seq ack, seq;
    139         int flags;
    140 #endif /* !VBOX */
    141108{
    142109        register int tlen;
     
    154121                win = sbspace(&tp->t_socket->so_rcv);
    155122        if (m == 0) {
    156 #ifdef VBOX
    157123                if ((m = m_get(pData)) == NULL)
    158 #else /* !VBOX */
    159                 if ((m = m_get()) == NULL)
    160 #endif /* !VBOX */
    161124                        return;
    162125#ifdef TCP_COMPAT_42
     
    208171          ((struct ip *)ti)->ip_ttl = ip_defttl;
    209172
    210 #ifdef VBOX
    211173        (void) ip_output(pData, (struct socket *)0, m);
    212 #else /* !VBOX */
    213         (void) ip_output((struct socket *)0, m);
    214 #endif /* !VBOX */
    215174}
    216175
     
    263222 * then send a RST to peer.
    264223 */
    265 #ifdef VBOX
    266224struct tcpcb *tcp_drop(PNATState pData, struct tcpcb *tp, int err)
    267 #else /* !VBOX */
    268 struct tcpcb *tcp_drop(struct tcpcb *tp, int err)
    269 #endif /* !VBOX */
    270225{
    271226/* tcp_drop(tp, errno)
     
    281236        if (TCPS_HAVERCVDSYN(tp->t_state)) {
    282237                tp->t_state = TCPS_CLOSED;
    283 #ifdef VBOX
    284238                (void) tcp_output(pData, tp);
    285 #else /* !VBOX */
    286                 (void) tcp_output(tp);
    287 #endif /* !VBOX */
    288239                tcpstat.tcps_drops++;
    289240        } else
     
    293244 */
    294245/*      so->so_error = errno; */
    295 #ifdef VBOX
    296246        return (tcp_close(pData, tp));
    297 #else /* !VBOX */
    298         return (tcp_close(tp));
    299 #endif /* !VBOX */
    300247}
    301248
     
    307254 */
    308255struct tcpcb *
    309 #ifdef VBOX
    310256tcp_close(PNATState pData, register struct tcpcb *tp)
    311 #else /* !VBOX */
    312 tcp_close(tp)
    313         register struct tcpcb *tp;
    314 #endif /* !VBOX */
    315257{
    316258        register struct tcpiphdr *t;
     
    327269                m = REASS_MBUF_GET(u32_to_ptr(pData, t->ti_prev, struct tcpiphdr *));
    328270                remque_32(pData, u32_to_ptr(pData, t->ti_prev, struct tcpiphdr *));
    329 #ifdef VBOX
    330271                m_freem(pData, m);
    331 #else /* !VBOX */
    332                 m_freem(m);
    333 #endif /* !VBOX */
    334272        }
    335273        /* It's static */
     
    348286        sbfree(&so->so_rcv);
    349287        sbfree(&so->so_snd);
    350 #ifdef VBOX
    351288        sofree(pData, so);
    352 #else /* !VBOX */
    353         sofree(so);
    354 #endif /* !VBOX */
    355289        tcpstat.tcps_closed++;
    356290        return ((struct tcpcb *)0);
     
    398332 */
    399333void
    400 #ifdef VBOX
    401334tcp_sockclosed(PNATState pData, struct tcpcb *tp)
    402 #else /* !VBOX */
    403 tcp_sockclosed(tp)
    404         struct tcpcb *tp;
    405 #endif /* !VBOX */
    406335{
    407336
     
    415344        case TCPS_SYN_SENT:
    416345                tp->t_state = TCPS_CLOSED;
    417 #ifdef VBOX
    418346                tp = tcp_close(pData, tp);
    419 #else /* !VBOX */
    420                 tp = tcp_close(tp);
    421 #endif /* !VBOX */
    422347                break;
    423348
     
    435360                soisfdisconnected(tp->t_socket);
    436361        if (tp)
    437 #ifdef VBOX
    438362                tcp_output(pData, tp);
    439 #else /* !VBOX */
    440                 tcp_output(tp);
    441 #endif /* !VBOX */
    442363}
    443364
     
    452373 * not wait for ACK+SYN.
    453374 */
    454 #ifdef VBOX
    455375int tcp_fconnect(PNATState pData, struct socket *so)
    456 #else /* !VBOX */
    457 int tcp_fconnect(so)
    458      struct socket *so;
    459 #endif /* !VBOX */
    460376{
    461377  int ret=0;
     
    519435 */
    520436void
    521 #ifdef VBOX
    522437tcp_connect(PNATState pData, struct socket *inso)
    523 #else /* !VBOX */
    524 tcp_connect(inso)
    525         struct socket *inso;
    526 #endif /* !VBOX */
    527438{
    528439        struct socket *so;
    529440        struct sockaddr_in addr;
    530 #ifndef VBOX
    531         int addrlen = sizeof(struct sockaddr_in);
    532 #else /* VBOX */
    533441        socklen_t addrlen = sizeof(struct sockaddr_in);
    534 #endif /* VBOX */
    535442        struct tcpcb *tp;
    536443        int s, opt;
     
    552459                        return;
    553460                }
    554 #ifdef VBOX
    555461                if (tcp_attach(pData, so) < 0) {
    556 #else /* !VBOX */
    557                 if (tcp_attach(so) < 0) {
    558 #endif /* !VBOX */
    559462                        free(so); /* NOT sofree */
    560463                        return;
     
    564467        }
    565468
    566 #ifdef VBOX
    567469        (void) tcp_mss(pData, sototcpcb(so), 0);
    568 #else /* !VBOX */
    569         (void) tcp_mss(sototcpcb(so), 0);
    570 #endif /* !VBOX */
    571470
    572471        if ((s = accept(inso->s,(struct sockaddr *)&addr,&addrlen)) < 0) {
    573 #ifdef VBOX
    574472                tcp_close(pData, sototcpcb(so)); /* This will sofree() as well */
    575 #else /* !VBOX */
    576                 tcp_close(sototcpcb(so)); /* This will sofree() as well */
    577 #endif /* !VBOX */
    578473                return;
    579474        }
     
    619514        tcp_iss += TCP_ISSINCR/2;
    620515        tcp_sendseqinit(tp);
    621 #ifdef VBOX
    622516        tcp_output(pData, tp);
    623 #else /* !VBOX */
    624         tcp_output(tp);
    625 #endif /* !VBOX */
    626517}
    627518
     
    630521 */
    631522int
    632 #ifdef VBOX
    633523tcp_attach(PNATState pData, struct socket *so)
    634 #else /* !VBOX */
    635 tcp_attach(so)
    636         struct socket *so;
    637 #endif /* !VBOX */
    638524{
    639525        if ((so->so_tcpcb = tcp_newtcpcb(pData, so)) == NULL)
     
    648534 * Set the socket's type of service field
    649535 */
    650 #ifdef VBOX
    651536static const struct tos_t tcptos[] = {
    652 #else /* !VBOX */
    653 struct tos_t tcptos[] = {
    654 #endif /* !VBOX */
    655537          {0, 20, IPTOS_THROUGHPUT, 0}, /* ftp data */
    656538          {21, 21, IPTOS_LOWDELAY,  EMU_FTP},   /* ftp control */
     
    668550};
    669551
    670 #ifndef VBOX
    671 struct emu_t *tcpemu = 0;
    672 #endif /* !VBOX */
    673 
    674552/*
    675553 * Return TOS according to the above table
     
    680558{
    681559        int i = 0;
    682 #ifndef VBOX
    683         struct emu_t *emup;
    684 #endif /* !VBOX */
    685560
    686561        while(tcptos[i].tos) {
     
    693568        }
    694569
    695 #ifdef VBOX
    696         /* No user-added emulators supported. */
    697 #else /* !VBOX */
    698         /* Nope, lets see if there's a user-added one */
    699         for (emup = tcpemu; emup; emup = emup->next) {
    700                 if ((emup->fport && (ntohs(so->so_fport) == emup->fport)) ||
    701                     (emup->lport && (ntohs(so->so_lport) == emup->lport))) {
    702                         so->so_emu = emup->emu;
    703                         return emup->tos;
    704                 }
    705         }
    706 #endif /* !VBOX */
    707 
    708570        return 0;
    709571}
    710 
    711 #ifndef VBOX
    712 int do_echo = -1;
    713 #endif /* !VBOX */
    714572
    715573/*
     
    738596 */
    739597int
    740 #ifdef VBOX
    741598tcp_emu(PNATState pData, struct socket *so, struct mbuf *m)
    742 #else /* !VBOX */
    743 tcp_emu(so, m)
    744         struct socket *so;
    745         struct mbuf *m;
    746 #endif /* !VBOX */
    747599{
    748600        u_int n1, n2, n3, n4, n5, n6;
     
    767619                        struct socket *tmpso;
    768620                        struct sockaddr_in addr;
    769 #ifndef VBOX
    770                         int addrlen = sizeof(struct sockaddr_in);
    771 #else /* VBOX */
    772621                        socklen_t addrlen = sizeof(struct sockaddr_in);
    773 #endif /* VBOX */
    774622                        struct sbuf *so_rcv = &so->so_rcv;
    775623
     
    779627                        m->m_data[m->m_len] = 0; /* NULL terminate */
    780628                        if (strchr(m->m_data, '\r') || strchr(m->m_data, '\n')) {
    781 #ifdef VBOX
    782629                                if (sscanf(so_rcv->sb_data, "%u%*[ ,]%u", &n1, &n2) == 2) {
    783 #else
    784                                 if (sscanf(so_rcv->sb_data, "%d%*[ ,]%d", &n1, &n2) == 2) {
    785 #endif
    786630                                        HTONS(n1);
    787631                                        HTONS(n2);
     
    803647                                so_rcv->sb_wptr = so_rcv->sb_data + so_rcv->sb_cc;
    804648                        }
    805 #ifdef VBOX
    806649                        m_free(pData, m);
    807 #else /* !VBOX */
    808                         m_free(m);
    809 #endif /* !VBOX */
    810650                        return 0;
    811651                }
     
    1113953                         * Need to emulate the PORT command
    1114954                         */
    1115 #ifdef VBOX
    1116955                        x = sscanf(bptr, "ORT %u,%u,%u,%u,%u,%u\r\n%256[^\177]",
    1117956                                   &n1, &n2, &n3, &n4, &n5, &n6, buff);
    1118 #else
    1119                         x = sscanf(bptr, "ORT %d,%d,%d,%d,%d,%d\r\n%256[^\177]",
    1120                                    &n1, &n2, &n3, &n4, &n5, &n6, buff);
    1121 #endif
    1122957                        if (x < 6)
    1123958                           return 1;
     
    1126961                        lport = htons((n5 << 8) | (n6));
    1127962
    1128 #ifdef VBOX
    1129963                        if ((so = solisten(pData, 0, laddr, lport, SS_FACCEPTONCE)) == NULL)
    1130 #else /* !VBOX */
    1131                         if ((so = solisten(0, laddr, lport, SS_FACCEPTONCE)) == NULL)
    1132 #endif /* !VBOX */
    1133964                           return 1;
    1134965
     
    1153984                         * Need to emulate the PASV response
    1154985                         */
    1155 #ifdef VBOX
    1156986                        x = sscanf(bptr, "27 Entering Passive Mode (%u,%u,%u,%u,%u,%u)\r\n%256[^\177]",
    1157987                                   &n1, &n2, &n3, &n4, &n5, &n6, buff);
    1158 #else
    1159                         x = sscanf(bptr, "27 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n%256[^\177]",
    1160                                    &n1, &n2, &n3, &n4, &n5, &n6, buff);
    1161 #endif
    1162988                        if (x < 6)
    1163989                           return 1;
     
    1166992                        lport = htons((n5 << 8) | (n6));
    1167993
    1168 #ifdef VBOX
    1169994                        if ((so = solisten(pData, 0, laddr, lport, SS_FACCEPTONCE)) == NULL)
    1170 #else /* !VBOX */
    1171                         if ((so = solisten(0, laddr, lport, SS_FACCEPTONCE)) == NULL)
    1172 #endif /* !VBOX */
    1173995                           return 1;
    1174996
     
    12091031                }
    12101032                if (m->m_data[m->m_len-1] == '\0' && lport != 0 &&
    1211 #ifdef VBOX
    12121033                    (so = solisten(pData, 0, so->so_laddr.s_addr, htons(lport), SS_FACCEPTONCE)) != NULL)
    1213 #else /* !VBOX */
    1214                     (so = solisten(0, so->so_laddr.s_addr, htons(lport), SS_FACCEPTONCE)) != NULL)
    1215 #endif /* !VBOX */
    12161034                        m->m_len = sprintf(m->m_data, "%d", ntohs(so->so_fport))+1;
    12171035                return 1;
     
    12271045                /* The %256s is for the broken mIRC */
    12281046                if (sscanf(bptr, "DCC CHAT %256s %u %u", buff, &laddr, &lport) == 3) {
    1229 #ifdef VBOX
    12301047                        if ((so = solisten(pData, 0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
    1231 #else /* !VBOX */
    1232                         if ((so = solisten(0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
    1233 #endif /* !VBOX */
    12341048                                return 1;
    12351049
     
    12391053                             ntohs(so->so_fport), 1);
    12401054                } else if (sscanf(bptr, "DCC SEND %256s %u %u %u", buff, &laddr, &lport, &n1) == 4) {
    1241 #ifdef VBOX
    12421055                        if ((so = solisten(pData, 0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
    1243 #else /* !VBOX */
    1244                         if ((so = solisten(0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
    1245 #endif /* !VBOX */
    12461056                                return 1;
    12471057
     
    12511061                              ntohs(so->so_fport), n1, 1);
    12521062                } else if (sscanf(bptr, "DCC MOVE %256s %u %u %u", buff, &laddr, &lport, &n1) == 4) {
    1253 #ifdef VBOX
    12541063                        if ((so = solisten(pData, 0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
    1255 #else /* !VBOX */
    1256                         if ((so = solisten(0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL)
    1257 #endif /* !VBOX */
    12581064                                return 1;
    12591065
     
    14091215 */
    14101216int
    1411 #ifdef VBOX
    14121217tcp_ctl(PNATState pData, struct socket *so)
    1413 #else /* !VBOX */
    1414 tcp_ctl(so)
    1415         struct socket *so;
    1416 #endif /* !VBOX */
    14171218{
    14181219        struct sbuf *sb = &so->so_snd;
     
    14651266        do_exec:
    14661267                DEBUG_MISC((dfd, " executing %s \n",ex_ptr->ex_exec));
    1467 #ifdef VBOX
    14681268                return(fork_exec(pData, so, ex_ptr->ex_exec, do_pty));
    1469 #else /* !VBOX */
    1470                 return(fork_exec(so, ex_ptr->ex_exec, do_pty));
    1471 #endif /* !VBOX */
    14721269
    14731270#if 0
     
    14941291}
    14951292
    1496 #if defined(VBOX) && SIZEOF_CHAR_P != 4
     1293#if SIZEOF_CHAR_P != 4
    14971294/**
    14981295 * Slow pointer hashing that deals with automatic inserting and collisions.
  • trunk/src/VBox/Devices/Network/slirp/tcp_timer.c

    r1033 r1076  
    3737#include <slirp.h>
    3838
    39 #ifndef VBOX
    40 int     tcp_keepidle = TCPTV_KEEP_IDLE;
    41 int     tcp_keepintvl = TCPTV_KEEPINTVL;
    42 int     tcp_maxidle;
    43 int     so_options = DO_KEEPALIVE;
    44 
    45 struct   tcpstat tcpstat;        /* tcp statistics */
    46 u_int32_t        tcp_now;                /* for RFC 1323 timestamps */
    47 #endif /* !VBOX */
    4839
    4940/*
     
    5142 */
    5243void
    53 #ifdef VBOX
    5444tcp_fasttimo(PNATState pData)
    55 #else /* !VBOX */
    56 tcp_fasttimo()
    57 #endif /* !VBOX */
    5845{
    5946        register struct socket *so;
     
    7057                        tp->t_flags |= TF_ACKNOW;
    7158                        tcpstat.tcps_delack++;
    72 #ifdef VBOX
    7359                        (void) tcp_output(pData, tp);
    74 #else /*! VBOX */
    75                         (void) tcp_output(tp);
    76 #endif /* !VBOX */
    7760                }
    7861}
     
    8467 */
    8568void
    86 #ifdef VBOX
    8769tcp_slowtimo(PNATState pData)
    88 #else /* !VBOX */
    89 tcp_slowtimo()
    90 #endif /* !VBOX */
    9170{
    9271        register struct socket *ip, *ipnxt;
     
    9675        DEBUG_CALL("tcp_slowtimo");
    9776
    98 #ifndef VBOX
    99         tcp_maxidle = TCPTV_KEEPCNT * tcp_keepintvl;
    100 #endif /* !VBOX */
    10177        /*
    10278         * Search through tcb's and update active timers.
     
    11288                for (i = 0; i < TCPT_NTIMERS; i++) {
    11389                        if (tp->t_timer[i] && --tp->t_timer[i] == 0) {
    114 #ifdef VBOX
    11590                                tcp_timers(pData, tp,i);
    116 #else /* !VBOX */
    117                                 tcp_timers(tp,i);
    118 #endif /* !VBOX */
    11991                                if (ipnxt->so_prev != ip)
    12092                                        goto tpgone;
     
    148120}
    149121
    150 #ifdef VBOX
    151122const int       tcp_backoff[TCP_MAXRXTSHIFT + 1] =
    152 #else /* !VBOX */
    153 int     tcp_backoff[TCP_MAXRXTSHIFT + 1] =
    154 #endif /* !VBOX */
    155123   { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
    156124
     
    159127 */
    160128struct tcpcb *
    161 #ifdef VBOX
    162129tcp_timers(PNATState pData, register struct tcpcb *tp, int timer)
    163 #else /* !VBOX */
    164 tcp_timers(tp, timer)
    165         register struct tcpcb *tp;
    166         int timer;
    167 #endif /* !VBOX */
    168130{
    169131        register int rexmt;
     
    184146                        tp->t_timer[TCPT_2MSL] = tcp_keepintvl;
    185147                else
    186 #ifdef VBOX
    187148                        tp = tcp_close(pData, tp);
    188 #else /* !VBOX */
    189                         tp = tcp_close(tp);
    190 #endif /* !VBOX */
    191149                break;
    192150
     
    226184                                tp->t_rxtshift = TCP_MAXRXTSHIFT;
    227185                                tcpstat.tcps_timeoutdrop++;
    228 #ifdef VBOX
    229186                                tp = tcp_drop(pData, tp, tp->t_softerror);
    230 #else /* !VBOX */
    231                                 tp = tcp_drop(tp, tp->t_softerror);
    232 #endif /* !VBOX */
    233187                                /* tp->t_softerror : ETIMEDOUT); */ /* XXX */
    234188                                return (tp); /* XXX */
     
    296250                tp->t_dupacks = 0;
    297251                }
    298 #ifdef VBOX
    299252                (void) tcp_output(pData, tp);
    300 #else /* !VBOX */
    301                 (void) tcp_output(tp);
    302 #endif /* !VBOX */
    303253                break;
    304254
     
    311261                tcp_setpersist(tp);
    312262                tp->t_force = 1;
    313 #ifdef VBOX
    314263                (void) tcp_output(pData, tp);
    315 #else /* !VBOX */
    316                 (void) tcp_output(tp);
    317 #endif /* !VBOX */
    318264                tp->t_force = 0;
    319265                break;
     
    353299                            tp->rcv_nxt - 1, tp->snd_una - 1, 0);
    354300#else
    355 #ifdef VBOX
    356301                        tcp_respond(pData, tp, &tp->t_template, (struct mbuf *)NULL,
    357302                            tp->rcv_nxt, tp->snd_una - 1, 0);
    358 #else /* !VBOX */
    359                         tcp_respond(tp, &tp->t_template, (struct mbuf *)NULL,
    360                             tp->rcv_nxt, tp->snd_una - 1, 0);
    361 #endif /* !VBOX */
    362303#endif
    363304                        tp->t_timer[TCPT_KEEP] = tcp_keepintvl;
     
    368309        dropit:
    369310                tcpstat.tcps_keepdrops++;
    370 #ifdef VBOX
    371311                tp = tcp_drop(pData, tp, 0); /* ETIMEDOUT); */
    372 #else /* !VBOX */
    373                 tp = tcp_drop(tp, 0); /* ETIMEDOUT); */
    374 #endif /* !VBOX */
    375312                break;
    376313        }
  • trunk/src/VBox/Devices/Network/slirp/tcp_timer.h

    r1033 r1076  
    127127}
    128128
    129 #ifndef VBOX
    130 extern int tcp_keepidle;                /* time before keepalive probes begin */
    131 extern int tcp_keepintvl;               /* time between keepalive probes */
    132 extern int tcp_maxidle;                 /* time to drop after starting probes */
    133 #endif /* !VBOX */
    134 extern int tcp_ttl;                     /* time to live for TCP segs */
    135 #ifdef VBOX
    136129extern const int tcp_backoff[];
    137 #else /* !VBOX */
    138 extern int tcp_backoff[];
    139 #endif /* !VBOX */
    140130
    141131struct tcpcb;
    142132
    143 #ifdef VBOX
    144133void tcp_fasttimo _P((PNATState));
    145134void tcp_slowtimo _P((PNATState));
    146 #else /* !VBOX */
    147 void tcp_fasttimo _P((void));
    148 void tcp_slowtimo _P((void));
    149 #endif /* !VBOX */
    150135void tcp_canceltimers _P((struct tcpcb *));
    151 #ifdef VBOX
    152136struct tcpcb * tcp_timers _P((PNATState, register struct tcpcb *, int));
    153 #else /* !VBOX */
    154 struct tcpcb * tcp_timers _P((register struct tcpcb *, int));
    155 #endif /* !VBOX */
    156137
    157138#endif
  • trunk/src/VBox/Devices/Network/slirp/tcp_var.h

    r1051 r1076  
    4343#if SIZEOF_CHAR_P == 4
    4444 typedef struct tcpiphdr *tcpiphdrp_32;
    45   /* VBox change that's to much bother to #ifdef. */
    4645# define u32ptr_done(pData, u32, ptr)  do {} while (0)
    4746# define ptr_to_u32(pData, ptr)        (ptr)
     
    4948#else
    5049 typedef u_int32_t tcpiphdrp_32;
    51 # ifdef VBOX
    52 #  include <iprt/types.h>
    53 #  include <iprt/assert.h>
    54 
    55    /* VBox change that's to much bother to #ifdef. */
    56 #  define u32ptr_done(pData, u32, ptr) VBoxU32PtrDone((pData), (ptr), (u32))
    57 #  define ptr_to_u32(pData, ptr)       VBoxU32PtrHash((pData), (ptr))
    58 #  define u32_to_ptr(pData, u32, type) ((type)VBoxU32PtrLookup((pData), (u32)))
    59 
    60 # else /* !VBOX */
    61    /* VBox change that's to much bother to #ifdef. */
    62 #  define u32ptr_done(u32, ptr)   do {} while (0)
    63 #  define ptr_to_u32(ptr)         (ptr)
    64 #  define u32_to_ptr(u32, type)   ((type)(u32))
    65 # endif /* !VBOX */
     50# include <iprt/types.h>
     51# include <iprt/assert.h>
     52
     53# define u32ptr_done(pData, u32, ptr) VBoxU32PtrDone((pData), (ptr), (u32))
     54# define ptr_to_u32(pData, ptr)       VBoxU32PtrHash((pData), (ptr))
     55# define u32_to_ptr(pData, u32, type) ((type)VBoxU32PtrLookup((pData), (u32)))
     56
    6657#endif
    6758
     
    216207 * but that's inconvenient at the moment.
    217208 */
    218 #ifdef VBOX
    219209struct tcpstat_t {
    220 #else /* !VBOX */
    221 struct tcpstat {
    222 #endif /* !VBOX */
    223210        u_long  tcps_connattempt;       /* connections initiated */
    224211        u_long  tcps_accepts;           /* connections accepted */
     
    276263};
    277264
    278 #ifndef VBOX
    279 extern struct   tcpstat tcpstat;        /* tcp statistics */
    280 extern u_int32_t        tcp_now;                /* for RFC 1323 timestamps */
    281 #endif /* !VBOX */
    282265
    283266#endif
  • trunk/src/VBox/Devices/Network/slirp/tftp.c

    r1033 r1076  
    2525#include <slirp.h>
    2626
    27 #ifndef VBOX
    28 struct tftp_session {
    29     int in_use;
    30     unsigned char filename[TFTP_FILENAME_MAX];
    31 
    32     struct in_addr client_ip;
    33     u_int16_t client_port;
    34 
    35     int timestamp;
    36 };
    37 
    38 struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX];
    39 
    40 const char *tftp_prefix;
    41 #endif /* !VBOX */
    42 
    43 #ifdef VBOX
     27
    4428static void tftp_session_update(PNATState pData, struct tftp_session *spt)
    45 #else /* !VBOX */
    46 static void tftp_session_update(struct tftp_session *spt)
    47 #endif /* !VBOX */
    4829{
    4930    spt->timestamp = curtime;
     
    5637}
    5738
    58 #ifdef VBOX
    5939static int tftp_session_allocate(PNATState pData, struct tftp_t *tp)
    60 #else /* !VBOX */
    61 static int tftp_session_allocate(struct tftp_t *tp)
    62 #endif /* !VBOX */
    6340{
    6441  struct tftp_session *spt;
     
    8360  spt->client_port = tp->udp.uh_sport;
    8461
    85 #ifdef VBOX
    8662  tftp_session_update(pData, spt);
    87 #else /* !VBOX */
    88   tftp_session_update(spt);
    89 #endif /* !VBOX */
    9063
    9164  return k;
    9265}
    9366
    94 #ifdef VBOX
    9567static int tftp_session_find(PNATState pData, struct tftp_t *tp)
    96 #else /* !VBOX */
    97 static int tftp_session_find(struct tftp_t *tp)
    98 #endif /* !VBOX */
    9968{
    10069  struct tftp_session *spt;
     
    11685}
    11786
    118 #ifdef VBOX
    11987static int tftp_read_data(PNATState pData, struct tftp_session *spt, u_int16_t block_nr,
    12088                          u_int8_t *buf, int len)
    121 #else /* !VBOX */
    122 static int tftp_read_data(struct tftp_session *spt, u_int16_t block_nr,
    123                           u_int8_t *buf, int len)
    124 #endif /* !VBOX */
    12589{
    12690  int fd;
     
    12993  int n;
    13094
    131 #ifndef VBOX
    132   n = snprintf(buffer, sizeof(buffer), "%s/%s",
    133                tftp_prefix, spt->filename);
    134 #else
    13595  n = RTStrPrintf(buffer, sizeof(buffer), "%s/%s",
    13696               tftp_prefix, spt->filename);
    137 #endif
    13897  if (n >= sizeof(buffer))
    13998    return -1;
     
    156115}
    157116
    158 #ifdef VBOX
    159117static int tftp_send_oack(PNATState pData,
    160118                          struct tftp_session *spt,
    161119                          const char *key, uint32_t value,
    162120                          struct tftp_t *recv_tp)
    163 #else /* !VBOX */
    164 static int tftp_send_oack(struct tftp_session *spt,
    165                           const char *key, uint32_t value,
    166                           struct tftp_t *recv_tp)
    167 #endif /* !VBOX */
    168121{
    169122    struct sockaddr_in saddr, daddr;
     
    172125    int n = 0;
    173126
    174 #ifdef VBOX
    175127    m = m_get(pData);
    176 #else /* !VBOX */
    177     m = m_get();
    178 #endif /* !VBOX */
    179128
    180129    if (!m)
     
    188137
    189138    tp->tp_op = htons(TFTP_OACK);
    190 #ifdef VBOX
    191139    n += sprintf((char *)tp->x.tp_buf + n, "%s", key) + 1;
    192140    n += sprintf((char *)tp->x.tp_buf + n, "%u", value) + 1;
    193 #else /* !VBOX */
    194     n += sprintf(tp->x.tp_buf + n, "%s", key) + 1;
    195     n += sprintf(tp->x.tp_buf + n, "%u", value) + 1;
    196 #endif /* !VBOX */
    197141
    198142    saddr.sin_addr = recv_tp->ip.ip_dst;
     
    204148    m->m_len = sizeof(struct tftp_t) - 514 + n -
    205149        sizeof(struct ip) - sizeof(struct udphdr);
    206 #ifdef VBOX
    207150    udp_output2(pData, NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
    208 #else /* !VBOX */
    209     udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
    210 #endif /* !VBOX */
    211151
    212152    return 0;
     
    215155
    216156
    217 #ifdef VBOX
    218157static int tftp_send_error(PNATState pData,
    219158                           struct tftp_session *spt,
    220159                           u_int16_t errorcode, const char *msg,
    221160                           struct tftp_t *recv_tp)
    222 #else /* !VBOX */
    223 static int tftp_send_error(struct tftp_session *spt,
    224                            u_int16_t errorcode, const char *msg,
    225                            struct tftp_t *recv_tp)
    226 #endif /* !VBOX */
    227161{
    228162  struct sockaddr_in saddr, daddr;
     
    231165  int nobytes;
    232166
    233 #ifdef VBOX
    234167  m = m_get(pData);
    235 #else /* !VBOX */
    236   m = m_get();
    237 #endif /* !VBOX */
    238168
    239169  if (!m) {
     
    249179  tp->tp_op = htons(TFTP_ERROR);
    250180  tp->x.tp_error.tp_error_code = htons(errorcode);
    251 #ifndef VBOX
    252   strcpy(tp->x.tp_error.tp_msg, msg);
    253 #else /* VBOX */
    254181  strcpy((char *)tp->x.tp_error.tp_msg, msg);
    255 #endif /* VBOX */
    256182
    257183  saddr.sin_addr = recv_tp->ip.ip_dst;
     
    266192        sizeof(struct ip) - sizeof(struct udphdr);
    267193
    268 #ifdef VBOX
    269194  udp_output2(pData, NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
    270 #else /* !VBOX */
    271   udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
    272 #endif /* !VBOX */
    273195
    274196  tftp_session_terminate(spt);
     
    277199}
    278200
    279 #ifdef VBOX
    280201static int tftp_send_data(PNATState pData,
    281202                          struct tftp_session *spt,
    282203                          u_int16_t block_nr,
    283204                          struct tftp_t *recv_tp)
    284 #else /* !VBOX */
    285 static int tftp_send_data(struct tftp_session *spt,
    286                           u_int16_t block_nr,
    287                           struct tftp_t *recv_tp)
    288 #endif /* !VBOX */
    289205{
    290206  struct sockaddr_in saddr, daddr;
     
    297213  }
    298214
    299 #ifdef VBOX
    300215  m = m_get(pData);
    301 #else /* !VBOX */
    302   m = m_get();
    303 #endif /* !VBOX */
    304216
    305217  if (!m) {
     
    322234  daddr.sin_port = spt->client_port;
    323235
    324 #ifdef VBOX
    325236  nobytes = tftp_read_data(pData, spt, block_nr - 1, tp->x.tp_data.tp_buf, 512);
    326 #else /* !VBOX */
    327   nobytes = tftp_read_data(spt, block_nr - 1, tp->x.tp_data.tp_buf, 512);
    328 #endif /* !VBOX */
    329237
    330238  if (nobytes < 0) {
    331 #ifdef VBOX
    332239    m_free(pData, m);
    333 #else /* !VBOX */
    334     m_free(m);
    335 #endif /* !VBOX */
    336240
    337241    /* send "file not found" error back */
    338242
    339 #ifdef VBOX
    340243    tftp_send_error(pData, spt, 1, "File not found", tp);
    341 #else /* !VBOX */
    342     tftp_send_error(spt, 1, "File not found", tp);
    343 #endif /* !VBOX */
    344244
    345245    return -1;
     
    349249        sizeof(struct ip) - sizeof(struct udphdr);
    350250
    351 #ifdef VBOX
    352251  udp_output2(pData, NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
    353 #else /* !VBOX */
    354   udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
    355 #endif /* !VBOX */
    356252
    357253  if (nobytes == 512) {
    358 #ifdef VBOX
    359254    tftp_session_update(pData, spt);
    360 #else /* !VBOX */
    361     tftp_session_update(spt);
    362 #endif /* !VBOX */
    363255  }
    364256  else {
     
    369261}
    370262
    371 #ifdef VBOX
    372263static void tftp_handle_rrq(PNATState pData, struct tftp_t *tp, int pktlen)
    373 #else /* !VBOX */
    374 static void tftp_handle_rrq(struct tftp_t *tp, int pktlen)
    375 #endif /* !VBOX */
    376264{
    377265  struct tftp_session *spt;
     
    379267  u_int8_t *src, *dst;
    380268
    381 #ifdef VBOX
    382269  s = tftp_session_allocate(pData, tp);
    383 #else /* !VBOX */
    384   s = tftp_session_allocate(tp);
    385 #endif /* !VBOX */
    386270
    387271  if (s < 0) {
     
    422306
    423307  if (memcmp(&src[k], "octet\0", 6) != 0) {
    424 #ifdef VBOX
    425308      tftp_send_error(pData, spt, 4, "Unsupported transfer mode", tp);
    426 #else /* !VBOX */
    427       tftp_send_error(spt, 4, "Unsupported transfer mode", tp);
    428 #endif /* !VBOX */
    429309      return;
    430310  }
     
    434314  /* do sanity checks on the filename */
    435315
    436 #ifndef VBOX
    437   if ((spt->filename[0] != '/')
    438       || (spt->filename[strlen(spt->filename) - 1] == '/')
    439       ||  strstr(spt->filename, "/../")) {
    440       tftp_send_error(spt, 2, "Access violation", tp);
    441 #else /* VBOX */
    442316  if ((spt->filename[0] != '/')
    443317      || (spt->filename[strlen((const char *)spt->filename) - 1] == '/')
    444318      ||  strstr((char *)spt->filename, "/../")) {
    445319      tftp_send_error(pData, spt, 2, "Access violation", tp);
    446 #endif /* VBOX */
    447320      return;
    448321  }
     
    451324
    452325  if (!tftp_prefix) {
    453 #ifdef VBOX
    454326      tftp_send_error(pData, spt, 2, "Access violation", tp);
    455 #else /* !VBOX */
    456       tftp_send_error(spt, 2, "Access violation", tp);
    457 #endif /* !VBOX */
    458327      return;
    459328  }
     
    461330  /* check if the file exists */
    462331
    463 #ifdef VBOX
    464332  if (tftp_read_data(pData, spt, 0, spt->filename, 0) < 0) {
    465333      tftp_send_error(pData, spt, 1, "File not found", tp);
    466 #else /* !VBOX */
    467   if (tftp_read_data(spt, 0, spt->filename, 0) < 0) {
    468       tftp_send_error(spt, 1, "File not found", tp);
    469 #endif /* !VBOX */
    470334      return;
    471335  }
    472336
    473337  if (src[n - 1] != 0) {
    474 #ifdef VBOX
    475338      tftp_send_error(pData, spt, 2, "Access violation", tp);
    476 #else /* !VBOX */
    477       tftp_send_error(spt, 2, "Access violation", tp);
    478 #endif /* !VBOX */
    479339      return;
    480340  }
     
    483343      const char *key, *value;
    484344
    485 #ifdef VBOX
    486345      key = (const char *)src + k;
    487 #else /* !VBOX */
    488       key = src + k;
    489 #endif /* !VBOX */
    490346      k += strlen(key) + 1;
    491347
    492348      if (k >= n) {
    493 #ifdef VBOX
    494349          tftp_send_error(pData, spt, 2, "Access violation", tp);
    495 #else /* !VBOX */
    496           tftp_send_error(spt, 2, "Access violation", tp);
    497 #endif /* !VBOX */
    498350          return;
    499351      }
    500352
    501 #ifdef VBOX
    502353      value = (const char *)src + k;
    503 #else /* !VBOX */
    504       value = src + k;
    505 #endif /* !VBOX */
    506354      k += strlen(value) + 1;
    507355
     
    514362              int len;
    515363
    516 #ifndef VBOX
    517               len = snprintf(buffer, sizeof(buffer), "%s/%s",
    518                              tftp_prefix, spt->filename);
    519 #else
    520364              len = RTStrPrintf(buffer, sizeof(buffer), "%s/%s",
    521365                             tftp_prefix, spt->filename);
    522 #endif
    523366
    524367              if (stat(buffer, &stat_p) == 0)
    525368                  tsize = stat_p.st_size;
    526369              else {
    527 #ifdef VBOX
    528370                  tftp_send_error(pData, spt, 1, "File not found", tp);
    529 #else /* !VBOX */
    530                   tftp_send_error(spt, 1, "File not found", tp);
    531 #endif /* !VBOX */
    532371                  return;
    533372              }
    534373          }
    535374
    536 #ifdef VBOX
    537375          tftp_send_oack(pData, spt, "tsize", tsize, tp);
    538 #else /* !VBOX */
    539           tftp_send_oack(spt, "tsize", tsize, tp);
    540 #endif /* !VBOX */
    541376      }
    542377  }
    543378
    544 #ifdef VBOX
    545379  tftp_send_data(pData, spt, 1, tp);
    546 #else /* !VBOX */
    547   tftp_send_data(spt, 1, tp);
    548 #endif /* !VBOX */
    549 }
    550 
    551 #ifdef VBOX
     380}
     381
    552382static void tftp_handle_ack(PNATState pData, struct tftp_t *tp, int pktlen)
    553 #else /* !VBOX */
    554 static void tftp_handle_ack(struct tftp_t *tp, int pktlen)
    555 #endif /* !VBOX */
    556383{
    557384  int s;
    558385
    559 #ifdef VBOX
    560386  s = tftp_session_find(pData, tp);
    561 #else /* !VBOX */
    562   s = tftp_session_find(tp);
    563 #endif /* !VBOX */
    564387
    565388  if (s < 0) {
     
    567390  }
    568391
    569 #ifdef VBOX
    570392  if (tftp_send_data(pData, &tftp_sessions[s],
    571393                     ntohs(tp->x.tp_data.tp_block_nr) + 1,
    572394                     tp) < 0) {
    573 #else /* !VBOX */
    574   if (tftp_send_data(&tftp_sessions[s],
    575                      ntohs(tp->x.tp_data.tp_block_nr) + 1,
    576                      tp) < 0) {
    577 #endif /* !VBOX */
    578395    return;
    579396  }
    580397}
    581398
    582 #ifdef VBOX
    583399void tftp_input(PNATState pData, struct mbuf *m)
    584 #else /* !VBOX */
    585 void tftp_input(struct mbuf *m)
    586 #endif /* !VBOX */
    587400{
    588401  struct tftp_t *tp = (struct tftp_t *)m->m_data;
     
    590403  switch(ntohs(tp->tp_op)) {
    591404  case TFTP_RRQ:
    592 #ifdef VBOX
    593405    tftp_handle_rrq(pData, tp, m->m_len);
    594 #else /* !VBOX */
    595     tftp_handle_rrq(tp, m->m_len);
    596 #endif /* !VBOX */
    597406    break;
    598407
    599408  case TFTP_ACK:
    600 #ifdef VBOX
    601409    tftp_handle_ack(pData, tp, m->m_len);
    602 #else /* !VBOX */
    603     tftp_handle_ack(tp, m->m_len);
    604 #endif /* !VBOX */
    605410    break;
    606411  }
  • trunk/src/VBox/Devices/Network/slirp/tftp.h

    r1033 r1076  
    3131};
    3232
    33 #ifdef VBOX
    3433void tftp_input(PNATState pData, struct mbuf *m);
    35 #else /* !VBOX */
    36 void tftp_input(struct mbuf *m);
    37 #endif /* !VBOX */
  • trunk/src/VBox/Devices/Network/slirp/udp.c

    r1048 r1076  
    4646#include "ip_icmp.h"
    4747
    48 #ifndef VBOX
    49 struct udpstat udpstat;
    50 
    51 struct socket udb;
    52 #endif /* !VBOX */
    5348
    5449/*
     
    5651 * Per RFC 768, August, 1980.
    5752 */
    58 #ifdef VBOX
    5953#define udpcksum 1
    60 #else /* !VBOX */
    61 #ifndef COMPAT_42
    62 int     udpcksum = 1;
    63 #else
    64 int     udpcksum = 0;           /* XXX */
    65 #endif
    66 #endif /* !VBOX */
    67 
    68 #ifndef VBOX
    69 struct  socket *udp_last_so = &udb;
    70 #endif /* !VBOX */
    7154
    7255void
    73 #ifdef VBOX
    7456udp_init(PNATState pData)
    75 #else /* !VBOX */
    76 udp_init()
    77 #endif /* !VBOX */
    78 {
    79 #ifdef VBOX
     57{
    8058        udp_last_so = &udb;
    81 #endif /* VBOX */
    8259        udb.so_next = udb.so_prev = &udb;
    8360}
     61
    8462/* m->m_data  points at ip packet header
    8563 * m->m_len   length ip packet
     
    8765 */
    8866void
    89 #ifdef VBOX
    9067udp_input(PNATState pData, register struct mbuf *m, int iphlen)
    91 #else /* !VBOX */
    92 udp_input(m, iphlen)
    93         register struct mbuf *m;
    94         int iphlen;
    95 #endif /* !VBOX */
    9668{
    9769        register struct ip *ip;
     
    169141         */
    170142        if (ntohs(uh->uh_dport) == BOOTP_SERVER) {
    171 #ifdef VBOX
    172143            bootp_input(pData, m);
    173 #else /* !VBOX */
    174             bootp_input(m);
    175 #endif /* !VBOX */
    176144            goto bad;
    177145        }
     
    181149         */
    182150        if (ntohs(uh->uh_dport) == TFTP_SERVER) {
    183 #ifdef VBOX
    184151            tftp_input(pData, m);
    185 #else /* !VBOX */
    186             tftp_input(m);
    187 #endif /* !VBOX */
    188152            goto bad;
    189153        }
     
    200164                        if (tmp->so_lport == uh->uh_sport &&
    201165                            tmp->so_laddr.s_addr == ip->ip_src.s_addr) {
    202 #ifndef VBOX /* Move this further down, as it must be done also for the cache hit case. */
    203                                 tmp->so_faddr.s_addr = ip->ip_dst.s_addr;
    204                                 tmp->so_fport = uh->uh_dport;
    205 #endif /* !VBOX */
    206166                                so = tmp;
    207167                                break;
     
    222182           */
    223183          if ((so = socreate()) == NULL) goto bad;
    224 #ifdef VBOX
    225184          if(udp_attach(pData, so) == -1) {
    226 #else /* !VBOX */
    227           if(udp_attach(so) == -1) {
    228 #endif /* !VBOX */
    229185            DEBUG_MISC((dfd," udp_attach errno = %d-%s\n",
    230186                        errno,strerror(errno)));
    231 #ifdef VBOX
    232187            sofree(pData, so);
    233 #else /* !VBOX */
    234             sofree(so);
    235 #endif /* !VBOX */
    236188            goto bad;
    237189          }
     
    264216         */
    265217        if (so->so_emu)
    266 #ifdef VBOX
    267218           udp_emu(pData, so, m);
    268 #else /* !VBOX */
    269            udp_emu(so, m);
    270 #endif /* !VBOX */
    271 
    272 #ifdef VBOX
     219
    273220        if(sosendto(pData, so,m) == -1) {
    274 #else /* !VBOX */
    275         if(sosendto(so,m) == -1) {
    276 #endif /* !VBOX */
    277221          m->m_len += iphlen;
    278222          m->m_data -= iphlen;
    279223          *ip=save_ip;
    280224          DEBUG_MISC((dfd,"udp tx errno = %d-%s\n",errno,strerror(errno)));
    281 #ifdef VBOX
    282225          icmp_error(pData, m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
    283 #else /* !VBOX */
    284           icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
    285 #endif /* !VBOX */
    286         }
    287 
    288 #ifdef VBOX
     226        }
     227
    289228        m_free(pData, so->so_m);   /* used for ICMP if error on sorecvfrom */
    290 #else /* !VBOX */
    291         m_free(so->so_m);   /* used for ICMP if error on sorecvfrom */
    292 #endif /* !VBOX */
    293229
    294230        /* restore the orig mbuf packet */
     
    300236        return;
    301237bad:
    302 #ifdef VBOX
    303238        m_freem(pData, m);
    304 #else /* !VBOX */
    305         m_freem(m);
    306 #endif /* !VBOX */
    307239        /* if (opts) m_freem(opts); */
    308240        return;
    309241}
    310242
    311 #ifdef VBOX
    312243int udp_output2(PNATState pData, struct socket *so, struct mbuf *m,
    313244                struct sockaddr_in *saddr, struct sockaddr_in *daddr,
    314245                int iptos)
    315 #else /* !VBOX */
    316 int udp_output2(struct socket *so, struct mbuf *m,
    317                 struct sockaddr_in *saddr, struct sockaddr_in *daddr,
    318                 int iptos)
    319 #endif /* !VBOX */
    320246{
    321247        register struct udpiphdr *ui;
     
    365291        udpstat.udps_opackets++;
    366292
    367 #ifdef VBOX
    368293        error = ip_output(pData, so, m);
    369 #else /* !VBOX */
    370         error = ip_output(so, m);
    371 #endif /* !VBOX */
    372294
    373295        return (error);
    374296}
    375297
    376 #ifdef VBOX
    377298int udp_output(PNATState pData, struct socket *so, struct mbuf *m,
    378299               struct sockaddr_in *addr)
    379 #else /* !VBOX */
    380 int udp_output(struct socket *so, struct mbuf *m,
    381                struct sockaddr_in *addr)
    382 #endif /* !VBOX */
    383300{
    384301    struct sockaddr_in saddr, daddr;
     
    393310    daddr.sin_port = so->so_lport;
    394311
    395 #ifdef VBOX
    396312    return udp_output2(pData, so, m, &saddr, &daddr, so->so_iptos);
    397 #else /* !VBOX */
    398     return udp_output2(so, m, &saddr, &daddr, so->so_iptos);
    399 #endif /* !VBOX */
    400313}
    401314
    402315int
    403 #ifdef VBOX
    404316udp_attach(PNATState pData, struct socket *so)
    405 #else /* !VBOX */
    406 udp_attach(so)
    407      struct socket *so;
    408 #endif /* !VBPX */
    409317{
    410318  struct sockaddr_in addr;
     
    439347
    440348void
    441 #ifdef VBOX
    442349udp_detach(PNATState pData, struct socket *so)
    443 #else /* !VBOX */
    444 udp_detach(so)
    445         struct socket *so;
    446 #endif /* !VBOX */
    447 {
    448 #ifdef VBOX
     350{
    449351        /* Correctly update list if detaching last socket in list. */
    450352        if (so == udp_last_so) udp_last_so = &udb;
    451 #endif /* VBOX */
    452353        closesocket(so->s);
    453354        /* if (so->so_m) m_free(so->so_m);    done by sofree */
    454355
    455 #ifdef VBOX
    456356        sofree(pData, so);
    457 #else /* !VBOX */
    458         sofree(so);
    459 #endif /* !VBOX */
    460 }
    461 
    462 #ifdef VBOX
     357}
     358
    463359static const struct tos_t udptos[] = {
    464 #else /* !VBOX */
    465 struct tos_t udptos[] = {
    466 #endif /* !VBOX */
    467360        {0, 53, IPTOS_LOWDELAY, 0},                     /* DNS */
    468361        {517, 517, IPTOS_LOWDELAY, EMU_TALK},   /* talk */
     
    498391 */
    499392void
    500 #ifdef VBOX
    501393udp_emu(PNATState pData, struct socket *so, struct mbuf *m)
    502 #else /* !VBOX */
    503 udp_emu(so, m)
    504         struct socket *so;
    505         struct mbuf *m;
    506 #endif /* !VBOX */
    507394{
    508395        struct sockaddr_in addr;
    509 #ifndef VBOX
    510         int addrlen = sizeof(addr);
    511 #else /* VBOX */
    512396        socklen_t addrlen = sizeof(addr);
    513 #endif /* VBOX */
    514397#ifdef EMULATE_TALK
    515398        CTL_MSG_OLD *omsg;
     
    734617
    735618struct socket *
    736 #ifdef VBOX
    737619udp_listen(PNATState pData, u_int port, u_int32_t laddr, u_int lport, int flags)
    738 #else /* !VBOX */
    739 udp_listen(port, laddr, lport, flags)
    740         u_int port;
    741         u_int32_t laddr;
    742         u_int lport;
    743         int flags;
    744 #endif /* !VBOX */
    745620{
    746621        struct sockaddr_in addr;
    747622        struct socket *so;
    748 #ifndef VBOX
    749         int addrlen = sizeof(struct sockaddr_in), opt = 1;
    750 #else /* VBOX */
    751623        socklen_t addrlen = sizeof(struct sockaddr_in);
    752624        int opt = 1;
    753 #endif /* VBOX */
    754625
    755626        if ((so = socreate()) == NULL) {
     
    766637
    767638        if (bind(so->s,(struct sockaddr *)&addr, addrlen) < 0) {
    768 #ifdef VBOX
    769639                udp_detach(pData, so);
    770 #else /* !VBOX */
    771                 udp_detach(so);
    772 #endif /* !VBOX */
    773640                return NULL;
    774641        }
  • trunk/src/VBox/Devices/Network/slirp/udp.h

    r1033 r1076  
    7373#define ui_sum          ui_u.uh_sum
    7474
    75 #ifdef VBOX
    7675struct udpstat_t {
    77 #else /* !VBOX */
    78 struct udpstat {
    79 #endif /* !VBOX */
    8076                                        /* input statistics: */
    8177                u_long  udps_ipackets;          /* total input packets */
     
    10197struct mbuf;
    10298
    103 #ifdef VBOX
    10499void udp_init _P((PNATState));
    105100void udp_input _P((PNATState, register struct mbuf *, int));
     
    107102int udp_attach _P((PNATState, struct socket *));
    108103void udp_detach _P((PNATState, struct socket *));
    109 #else /* !VBOX */
    110 void udp_init _P((void));
    111 void udp_input _P((register struct mbuf *, int));
    112 int udp_output _P((struct socket *, struct mbuf *, struct sockaddr_in *));
    113 int udp_attach _P((struct socket *));
    114 void udp_detach _P((struct socket *));
    115 #endif /* !VBOX */
    116104u_int8_t udp_tos _P((struct socket *));
    117 #ifdef VBOX
    118 #else /* !VBOX */
    119 #endif /* !VBOX */
    120 #ifdef VBOX
    121105void udp_emu _P((PNATState, struct socket *, struct mbuf *));
    122106struct socket * udp_listen _P((PNATState, u_int, u_int32_t, u_int, int));
     
    124108                struct sockaddr_in *saddr, struct sockaddr_in *daddr,
    125109                int iptos);
    126 #else /* !VBOX */
    127 void udp_emu _P((struct socket *, struct mbuf *));
    128 struct socket * udp_listen _P((u_int, u_int32_t, u_int, int));
    129 int udp_output2(struct socket *so, struct mbuf *m,
    130                 struct sockaddr_in *saddr, struct sockaddr_in *daddr,
    131                 int iptos);
    132 #endif /* !VBOX */
    133110
    134111#endif
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