VirtualBox

Changeset 15054 in vbox for trunk


Ignore:
Timestamp:
Dec 5, 2008 8:07:25 PM (16 years ago)
Author:
vboxsync
Message:

slirp: code readability

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

Legend:

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

    r9109 r15054  
    2626/* XXX: only DHCP is supported */
    2727
    28 
    2928static const uint8_t rfc1533_cookie[] = { RFC1533_COOKIE };
    3029
    31 DECLINLINE(void) dprintf(const char *pszFormat, ...)
    32 {
    33 #ifdef LOG_ENABLED
    34     va_list args;
    35     va_start(args, pszFormat);
    36     Log(("dhcp: %N", pszFormat, &args));
    37     va_end(args);
    38 #endif
    39 }
    40 
    4130static BOOTPClient *get_new_addr(PNATState pData, struct in_addr *paddr)
    4231{
    43     BOOTPClient *bc;
    4432    int i;
    4533
    46     for(i = 0; i < NB_ADDR; i++) {
     34    for(i = 0; i < NB_ADDR; i++)
     35    {
    4736        if (!bootp_clients[i].allocated)
    48             goto found;
     37        {
     38            BOOTPClient *bc;
     39
     40            bc = &bootp_clients[i];
     41            bc->allocated = 1;
     42            paddr->s_addr = htonl(ntohl(special_addr.s_addr) | (i + START_ADDR));
     43            return bc;
     44        }
    4945    }
    5046    return NULL;
    51  found:
    52     bc = &bootp_clients[i];
    53     bc->allocated = 1;
    54     paddr->s_addr = htonl(ntohl(special_addr.s_addr) | (i + START_ADDR));
    55     return bc;
    5647}
    5748
     
    6354    if (i >= NB_ADDR)
    6455        return 0;
     56
    6557    memset(bootp_clients[i].macaddr, '\0', 6);
    6658    bootp_clients[i].allocated = 0;
     
    7062static BOOTPClient *find_addr(PNATState pData, struct in_addr *paddr, const uint8_t *macaddr)
    7163{
    72     BOOTPClient *bc;
    7364    int i;
    7465
    75     for(i = 0; i < NB_ADDR; i++) {
     66    for(i = 0; i < NB_ADDR; i++)
     67    {
    7668        if (!memcmp(macaddr, bootp_clients[i].macaddr, 6))
    77             goto found;
     69        {
     70            BOOTPClient *bc;
     71
     72            bc = &bootp_clients[i];
     73            bc->allocated = 1;
     74            paddr->s_addr = htonl(ntohl(special_addr.s_addr) | (i + START_ADDR));
     75            return bc;
     76        }
    7877    }
    7978    return NULL;
    80  found:
    81     bc = &bootp_clients[i];
    82     bc->allocated = 1;
    83     paddr->s_addr = htonl(ntohl(special_addr.s_addr) | (i + START_ADDR));
    84     return bc;
    8579}
    8680
     
    10094        return;
    10195    p += 4;
    102     while (p < p_end) {
     96    while (p < p_end)
     97    {
    10398        tag = p[0];
    104         if (tag == RFC1533_PAD) {
     99        if (tag == RFC1533_PAD)
    105100            p++;
    106         } else if (tag == RFC1533_END) {
     101        else if (tag == RFC1533_END)
    107102            break;
    108         } else {
     103        else
     104        {
    109105            p++;
    110106            if (p >= p_end)
    111107                break;
    112108            len = *p++;
    113             dprintf("dhcp: tag=0x%02x len=%d\n", tag, len);
    114 
    115             switch(tag) {
    116             case RFC2132_REQ_ADDR:
    117                 if (len >= 4)
    118                     *req_ip = *(struct in_addr*)p;
    119                 break;
    120             case RFC2132_MSG_TYPE:
    121                 if (len >= 1)
    122                     *pmsg_type = p[0];
    123                 break;
    124             default:
    125                 break;
     109            Log(("dhcp: tag=0x%02x len=%d\n", tag, len));
     110
     111            switch(tag)
     112            {
     113                case RFC2132_REQ_ADDR:
     114                    if (len >= 4)
     115                        *req_ip = *(struct in_addr*)p;
     116                    break;
     117                case RFC2132_MSG_TYPE:
     118                    if (len >= 1)
     119                        *pmsg_type = p[0];
     120                    break;
     121                default:
     122                    break;
    126123            }
    127124            p += len;
     
    141138    struct in_addr requested_ip; /* the requested IP in DHCPREQUEST */
    142139    int send_nak = 0;
    143     uint32_t ipv4_addr;
    144140
    145141    /* extract exact DHCP msg type */
    146142    requested_ip.s_addr = 0xffffffff;
    147143    dhcp_decode(bp->bp_vend, DHCP_OPT_LEN, &dhcp_msg_type, &requested_ip);
    148     dprintf("bootp packet op=%d msgtype=%d\n", bp->bp_op, dhcp_msg_type);
     144    Log(("bootp packet op=%d msgtype=%d\n", bp->bp_op, dhcp_msg_type));
    149145
    150146    if (dhcp_msg_type == 0)
    151147        dhcp_msg_type = DHCPREQUEST; /* Force reply for old BOOTP clients */
    152148
    153     if (dhcp_msg_type == DHCPRELEASE) {
     149    if (dhcp_msg_type == DHCPRELEASE)
     150    {
    154151        int rc;
    155         ipv4_addr = ntohl(bp->bp_ciaddr.s_addr);
    156152        rc = release_addr(pData, &bp->bp_ciaddr);
    157         LogRel(("NAT: %s %u.%u.%u.%u\n",
     153        LogRel(("NAT: %s %R[IP4]\n",
    158154                rc ? "DHCP released IP address" : "Ignored DHCP release for IP address",
    159                 ipv4_addr >> 24, (ipv4_addr >> 16) & 0xff, (ipv4_addr >> 8) & 0xff, ipv4_addr & 0xff));
    160         dprintf("released addr=%08x\n", ntohl(bp->bp_ciaddr.s_addr));
     155                &bp->bp_ciaddr));
    161156        /* This message is not to be answered in any way. */
    162157        return;
    163158    }
    164     if (dhcp_msg_type != DHCPDISCOVER &&
    165         dhcp_msg_type != DHCPREQUEST)
    166         return;
     159    if (   dhcp_msg_type != DHCPDISCOVER
     160        && dhcp_msg_type != DHCPREQUEST)
     161        return;
     162
    167163    /* XXX: this is a hack to get the client mac address */
    168164    memcpy(client_ethaddr, bp->bp_hwaddr, 6);
     
    175171    memset(rbp, 0, sizeof(struct bootp_t));
    176172
    177     if (dhcp_msg_type == DHCPDISCOVER) {
     173    if (dhcp_msg_type == DHCPDISCOVER)
     174    {
    178175        /* Do not allocate a new lease for clients that forgot that they had a lease. */
    179176        bc = find_addr(pData, &daddr.sin_addr, bp->bp_hwaddr);
     
    182179    new_addr:
    183180            bc = get_new_addr(pData, &daddr.sin_addr);
    184             if (!bc) {
     181            if (!bc)
     182            {
    185183                LogRel(("NAT: DHCP no IP address left\n"));
    186                 dprintf("no address left\n");
     184                Log(("no address left\n"));
    187185                return;
    188186            }
    189187            memcpy(bc->macaddr, client_ethaddr, 6);
    190188        }
    191     } else {
     189    }
     190    else
     191    {
    192192        bc = find_addr(pData, &daddr.sin_addr, bp->bp_hwaddr);
    193         if (!bc) {
     193        if (!bc)
     194        {
    194195            /* if never assigned, behaves as if it was already
    195196               assigned (windows fix because it remembers its address) */
     
    198199    }
    199200
    200     if (tftp_prefix && RTDirExists(tftp_prefix) && bootp_filename)
     201    if (   tftp_prefix
     202        && RTDirExists(tftp_prefix)
     203        && bootp_filename)
    201204        RTStrPrintf((char*)rbp->bp_file, sizeof(rbp->bp_file), "%s", bootp_filename);
    202205
     
    219222    q += 4;
    220223
    221     if (dhcp_msg_type == DHCPDISCOVER) {
     224    if (dhcp_msg_type == DHCPDISCOVER)
     225    {
    222226        *q++ = RFC2132_MSG_TYPE;
    223227        *q++ = 1;
    224228        *q++ = DHCPOFFER;
    225     } else if (dhcp_msg_type == DHCPREQUEST) {
     229    }
     230    else if (dhcp_msg_type == DHCPREQUEST)
     231    {
    226232        *q++ = RFC2132_MSG_TYPE;
    227233        *q++ = 1;
     
    238244
    239245    if (send_nak)
    240     {
    241         ipv4_addr = ntohl(requested_ip.s_addr);
    242         LogRel(("NAT: Client requested IP address %u.%u.%u.%u -- sending NAK\n",
    243                 ipv4_addr >> 24, (ipv4_addr >> 16) & 0xff, (ipv4_addr >> 8) & 0xff, ipv4_addr & 0xff));
    244     }
     246        LogRel(("NAT: Client requested IP address %R[IP4] -- sending NAK\n",
     247                &requested_ip));
    245248    else
    246     {
    247         ipv4_addr = ntohl(daddr.sin_addr.s_addr);
    248         LogRel(("NAT: DHCP offered IP address %u.%u.%u.%u\n",
    249                 ipv4_addr >> 24, (ipv4_addr >> 16) & 0xff, (ipv4_addr >> 8) & 0xff, ipv4_addr & 0xff));
    250         dprintf("offered addr=%08x\n", ntohl(daddr.sin_addr.s_addr));
    251     }
    252 
    253     if (dhcp_msg_type == DHCPDISCOVER ||
    254         dhcp_msg_type == DHCPREQUEST) {
     249        LogRel(("NAT: DHCP offered IP address %R[IP4]\n",
     250                &daddr.sin_addr));
     251
     252    if (   dhcp_msg_type == DHCPDISCOVER
     253        || dhcp_msg_type == DHCPREQUEST)
     254    {
    255255        *q++ = RFC2132_SRV_ID;
    256256        *q++ = 4;
     
    260260
    261261    if (!send_nak &&
    262         (dhcp_msg_type == DHCPDISCOVER ||
    263          dhcp_msg_type == DHCPREQUEST)) {
     262        (   dhcp_msg_type == DHCPDISCOVER
     263         || dhcp_msg_type == DHCPREQUEST))
     264    {
    264265        *q++ = RFC1533_NETMASK;
    265266        *q++ = 4;
     
    286287        q += 4;
    287288
    288         if (*slirp_hostname) {
     289        if (*slirp_hostname)
     290        {
    289291            val = strlen(slirp_hostname);
    290292            *q++ = RFC1533_HOSTNAME;
  • trunk/src/VBox/Devices/Network/slirp/debug.c

    r14882 r15054  
    1111#include <iprt/stream.h>
    1212
    13 
    14 /* Carry over one item from main.c so that the tty's restored.
    15  * Only done when the tty being used is /dev/tty --RedWolf */
    16 extern struct termios slirp_tty_settings;
    17 extern int slirp_tty_restore;
    1813#ifdef DEBUG
    1914void dump_packet(void *, int);
    2015#endif
    21 
    2216
    2317/*
     
    2822dump_packet(void *dat, int n)
    2923{
    30         Log(("nat: PACKET DUMPED:\n%.*Vhxd\n", n, dat));
     24    Log(("nat: PACKET DUMPED:\n%.*Vhxd\n", n, dat));
    3125}
    3226#endif
    3327
     28#ifdef LOG_ENABLED
     29static void
     30lprint(const char *pszFormat, ...)
     31{
     32    va_list args;
     33    va_start(args, pszFormat);
     34    RTLogPrintfV(pszFormat, args);
     35    va_end(args);
     36}
    3437
    3538void
    3639ipstats(PNATState pData)
    3740{
    38         lprint(" \r\n");
    39 
    40         lprint("IP stats:\r\n");
    41         lprint("  %6d total packets received (%d were unaligned)\r\n",
    42                         ipstat.ips_total, ipstat.ips_unaligned);
    43         lprint("  %6d with incorrect version\r\n", ipstat.ips_badvers);
    44         lprint("  %6d with bad header checksum\r\n", ipstat.ips_badsum);
    45         lprint("  %6d with length too short (len < sizeof(iphdr))\r\n", ipstat.ips_tooshort);
    46         lprint("  %6d with length too small (len < ip->len)\r\n", ipstat.ips_toosmall);
    47         lprint("  %6d with bad header length\r\n", ipstat.ips_badhlen);
    48         lprint("  %6d with bad packet length\r\n", ipstat.ips_badlen);
    49         lprint("  %6d fragments received\r\n", ipstat.ips_fragments);
    50         lprint("  %6d fragments dropped\r\n", ipstat.ips_fragdropped);
    51         lprint("  %6d fragments timed out\r\n", ipstat.ips_fragtimeout);
    52         lprint("  %6d packets reassembled ok\r\n", ipstat.ips_reassembled);
    53         lprint("  %6d outgoing packets fragmented\r\n", ipstat.ips_fragmented);
    54         lprint("  %6d total outgoing fragments\r\n", ipstat.ips_ofragments);
    55         lprint("  %6d with bad protocol field\r\n", ipstat.ips_noproto);
    56         lprint("  %6d total packets delivered\r\n", ipstat.ips_delivered);
    57 }
    58 
     41    lprint(" \n");
     42
     43    lprint("IP stats:\n");
     44    lprint("  %6d total packets received (%d were unaligned)\n",
     45           ipstat.ips_total, ipstat.ips_unaligned);
     46    lprint("  %6d with incorrect version\n", ipstat.ips_badvers);
     47    lprint("  %6d with bad header checksum\n", ipstat.ips_badsum);
     48    lprint("  %6d with length too short (len < sizeof(iphdr))\n", ipstat.ips_tooshort);
     49    lprint("  %6d with length too small (len < ip->len)\n", ipstat.ips_toosmall);
     50    lprint("  %6d with bad header length\n", ipstat.ips_badhlen);
     51    lprint("  %6d with bad packet length\n", ipstat.ips_badlen);
     52    lprint("  %6d fragments received\n", ipstat.ips_fragments);
     53    lprint("  %6d fragments dropped\n", ipstat.ips_fragdropped);
     54    lprint("  %6d fragments timed out\n", ipstat.ips_fragtimeout);
     55    lprint("  %6d packets reassembled ok\n", ipstat.ips_reassembled);
     56    lprint("  %6d outgoing packets fragmented\n", ipstat.ips_fragmented);
     57    lprint("  %6d total outgoing fragments\n", ipstat.ips_ofragments);
     58    lprint("  %6d with bad protocol field\n", ipstat.ips_noproto);
     59    lprint("  %6d total packets delivered\n", ipstat.ips_delivered);
     60}
    5961
    6062void
    6163tcpstats(PNATState pData)
    6264{
    63         lprint(" \r\n");
    64 
    65         lprint("TCP stats:\r\n");
    66 
    67         lprint("  %6d packets sent\r\n", tcpstat.tcps_sndtotal);
    68         lprint("          %6d data packets (%d bytes)\r\n",
    69                         tcpstat.tcps_sndpack, tcpstat.tcps_sndbyte);
    70         lprint("          %6d data packets retransmitted (%d bytes)\r\n",
    71                         tcpstat.tcps_sndrexmitpack, tcpstat.tcps_sndrexmitbyte);
    72         lprint("          %6d ack-only packets (%d delayed)\r\n",
    73                         tcpstat.tcps_sndacks, tcpstat.tcps_delack);
    74         lprint("          %6d URG only packets\r\n", tcpstat.tcps_sndurg);
    75         lprint("          %6d window probe packets\r\n", tcpstat.tcps_sndprobe);
    76         lprint("          %6d window update packets\r\n", tcpstat.tcps_sndwinup);
    77         lprint("          %6d control (SYN/FIN/RST) packets\r\n", tcpstat.tcps_sndctrl);
    78         lprint("          %6d times tcp_output did nothing\r\n", tcpstat.tcps_didnuttin);
    79 
    80         lprint("  %6d packets received\r\n", tcpstat.tcps_rcvtotal);
    81         lprint("          %6d acks (for %d bytes)\r\n",
    82                         tcpstat.tcps_rcvackpack, tcpstat.tcps_rcvackbyte);
    83         lprint("          %6d duplicate acks\r\n", tcpstat.tcps_rcvdupack);
    84         lprint("          %6d acks for unsent data\r\n", tcpstat.tcps_rcvacktoomuch);
    85         lprint("          %6d packets received in sequence (%d bytes)\r\n",
    86                         tcpstat.tcps_rcvpack, tcpstat.tcps_rcvbyte);
    87         lprint("          %6d completely duplicate packets (%d bytes)\r\n",
    88                         tcpstat.tcps_rcvduppack, tcpstat.tcps_rcvdupbyte);
    89 
    90         lprint("          %6d packets with some duplicate data (%d bytes duped)\r\n",
    91                         tcpstat.tcps_rcvpartduppack, tcpstat.tcps_rcvpartdupbyte);
    92         lprint("          %6d out-of-order packets (%d bytes)\r\n",
    93                         tcpstat.tcps_rcvoopack, tcpstat.tcps_rcvoobyte);
    94         lprint("          %6d packets of data after window (%d bytes)\r\n",
    95                         tcpstat.tcps_rcvpackafterwin, tcpstat.tcps_rcvbyteafterwin);
    96         lprint("          %6d window probes\r\n", tcpstat.tcps_rcvwinprobe);
    97         lprint("          %6d window update packets\r\n", tcpstat.tcps_rcvwinupd);
    98         lprint("          %6d packets received after close\r\n", tcpstat.tcps_rcvafterclose);
    99         lprint("          %6d discarded for bad checksums\r\n", tcpstat.tcps_rcvbadsum);
    100         lprint("          %6d discarded for bad header offset fields\r\n",
    101                         tcpstat.tcps_rcvbadoff);
    102 
    103         lprint("  %6d connection requests\r\n", tcpstat.tcps_connattempt);
    104         lprint("  %6d connection accepts\r\n", tcpstat.tcps_accepts);
    105         lprint("  %6d connections established (including accepts)\r\n", tcpstat.tcps_connects);
    106         lprint("  %6d connections closed (including %d drop)\r\n",
    107                         tcpstat.tcps_closed, tcpstat.tcps_drops);
    108         lprint("  %6d embryonic connections dropped\r\n", tcpstat.tcps_conndrops);
    109         lprint("  %6d segments we tried to get rtt (%d succeeded)\r\n",
    110                         tcpstat.tcps_segstimed, tcpstat.tcps_rttupdated);
    111         lprint("  %6d retransmit timeouts\r\n", tcpstat.tcps_rexmttimeo);
    112         lprint("          %6d connections dropped by rxmt timeout\r\n",
    113                         tcpstat.tcps_timeoutdrop);
    114         lprint("  %6d persist timeouts\r\n", tcpstat.tcps_persisttimeo);
    115         lprint("  %6d keepalive timeouts\r\n", tcpstat.tcps_keeptimeo);
    116         lprint("          %6d keepalive probes sent\r\n", tcpstat.tcps_keepprobe);
    117         lprint("          %6d connections dropped by keepalive\r\n", tcpstat.tcps_keepdrops);
    118         lprint("  %6d correct ACK header predictions\r\n", tcpstat.tcps_predack);
    119         lprint("  %6d correct data packet header predictions\n", tcpstat.tcps_preddat);
    120         lprint("  %6d TCP cache misses\r\n", tcpstat.tcps_socachemiss);
    121 
    122 
    123 /*      lprint("    Packets received too short:         %d\r\n", tcpstat.tcps_rcvshort); */
    124 /*      lprint("    Segments dropped due to PAWS:       %d\r\n", tcpstat.tcps_pawsdrop); */
     65    lprint(" \n");
     66
     67    lprint("TCP stats:\n");
     68
     69    lprint("  %6d packets sent\n", tcpstat.tcps_sndtotal);
     70    lprint("          %6d data packets (%d bytes)\n",
     71            tcpstat.tcps_sndpack, tcpstat.tcps_sndbyte);
     72    lprint("          %6d data packets retransmitted (%d bytes)\n",
     73            tcpstat.tcps_sndrexmitpack, tcpstat.tcps_sndrexmitbyte);
     74    lprint("          %6d ack-only packets (%d delayed)\n",
     75            tcpstat.tcps_sndacks, tcpstat.tcps_delack);
     76    lprint("          %6d URG only packets\n", tcpstat.tcps_sndurg);
     77    lprint("          %6d window probe packets\n", tcpstat.tcps_sndprobe);
     78    lprint("          %6d window update packets\n", tcpstat.tcps_sndwinup);
     79    lprint("          %6d control (SYN/FIN/RST) packets\n", tcpstat.tcps_sndctrl);
     80    lprint("          %6d times tcp_output did nothing\n", tcpstat.tcps_didnuttin);
     81
     82    lprint("  %6d packets received\n", tcpstat.tcps_rcvtotal);
     83    lprint("          %6d acks (for %d bytes)\n",
     84            tcpstat.tcps_rcvackpack, tcpstat.tcps_rcvackbyte);
     85    lprint("          %6d duplicate acks\n", tcpstat.tcps_rcvdupack);
     86    lprint("          %6d acks for unsent data\n", tcpstat.tcps_rcvacktoomuch);
     87    lprint("          %6d packets received in sequence (%d bytes)\n",
     88            tcpstat.tcps_rcvpack, tcpstat.tcps_rcvbyte);
     89    lprint("          %6d completely duplicate packets (%d bytes)\n",
     90            tcpstat.tcps_rcvduppack, tcpstat.tcps_rcvdupbyte);
     91
     92    lprint("          %6d packets with some duplicate data (%d bytes duped)\n",
     93            tcpstat.tcps_rcvpartduppack, tcpstat.tcps_rcvpartdupbyte);
     94    lprint("          %6d out-of-order packets (%d bytes)\n",
     95            tcpstat.tcps_rcvoopack, tcpstat.tcps_rcvoobyte);
     96    lprint("          %6d packets of data after window (%d bytes)\n",
     97            tcpstat.tcps_rcvpackafterwin, tcpstat.tcps_rcvbyteafterwin);
     98    lprint("          %6d window probes\n", tcpstat.tcps_rcvwinprobe);
     99    lprint("          %6d window update packets\n", tcpstat.tcps_rcvwinupd);
     100    lprint("          %6d packets received after close\n", tcpstat.tcps_rcvafterclose);
     101    lprint("          %6d discarded for bad checksums\n", tcpstat.tcps_rcvbadsum);
     102    lprint("          %6d discarded for bad header offset fields\n",
     103            tcpstat.tcps_rcvbadoff);
     104
     105    lprint("  %6d connection requests\n", tcpstat.tcps_connattempt);
     106    lprint("  %6d connection accepts\n", tcpstat.tcps_accepts);
     107    lprint("  %6d connections established (including accepts)\n", tcpstat.tcps_connects);
     108    lprint("  %6d connections closed (including %d drop)\n",
     109            tcpstat.tcps_closed, tcpstat.tcps_drops);
     110    lprint("  %6d embryonic connections dropped\n", tcpstat.tcps_conndrops);
     111    lprint("  %6d segments we tried to get rtt (%d succeeded)\n",
     112            tcpstat.tcps_segstimed, tcpstat.tcps_rttupdated);
     113    lprint("  %6d retransmit timeouts\n", tcpstat.tcps_rexmttimeo);
     114    lprint("          %6d connections dropped by rxmt timeout\n",
     115            tcpstat.tcps_timeoutdrop);
     116    lprint("  %6d persist timeouts\n", tcpstat.tcps_persisttimeo);
     117    lprint("  %6d keepalive timeouts\n", tcpstat.tcps_keeptimeo);
     118    lprint("          %6d keepalive probes sent\n", tcpstat.tcps_keepprobe);
     119    lprint("          %6d connections dropped by keepalive\n", tcpstat.tcps_keepdrops);
     120    lprint("  %6d correct ACK header predictions\n", tcpstat.tcps_predack);
     121    lprint("  %6d correct data packet header predictions\n", tcpstat.tcps_preddat);
     122    lprint("  %6d TCP cache misses\n", tcpstat.tcps_socachemiss);
     123
     124/*  lprint("    Packets received too short:         %d\n", tcpstat.tcps_rcvshort); */
     125/*  lprint("    Segments dropped due to PAWS:       %d\n", tcpstat.tcps_pawsdrop); */
    125126
    126127}
     
    129130udpstats(PNATState pData)
    130131{
    131         lprint(" \r\n");
    132 
    133         lprint("UDP stats:\r\n");
    134         lprint("  %6d datagrams received\r\n", udpstat.udps_ipackets);
    135         lprint("  %6d with packets shorter than header\r\n", udpstat.udps_hdrops);
    136         lprint("  %6d with bad checksums\r\n", udpstat.udps_badsum);
    137         lprint("  %6d with data length larger than packet\r\n", udpstat.udps_badlen);
    138         lprint("  %6d UDP socket cache misses\r\n", udpstat.udpps_pcbcachemiss);
    139         lprint("  %6d datagrams sent\r\n", udpstat.udps_opackets);
     132    lprint(" \n");
     133
     134    lprint("UDP stats:\n");
     135    lprint("  %6d datagrams received\n", udpstat.udps_ipackets);
     136    lprint("  %6d with packets shorter than header\n", udpstat.udps_hdrops);
     137    lprint("  %6d with bad checksums\n", udpstat.udps_badsum);
     138    lprint("  %6d with data length larger than packet\n", udpstat.udps_badlen);
     139    lprint("  %6d UDP socket cache misses\n", udpstat.udpps_pcbcachemiss);
     140    lprint("  %6d datagrams sent\n", udpstat.udps_opackets);
    140141}
    141142
     
    143144icmpstats(PNATState pData)
    144145{
    145         lprint(" \r\n");
    146         lprint("ICMP stats:\r\n");
    147         lprint("  %6d ICMP packets received\r\n", icmpstat.icps_received);
    148         lprint("  %6d were too short\r\n", icmpstat.icps_tooshort);
    149         lprint("  %6d with bad checksums\r\n", icmpstat.icps_checksum);
    150         lprint("  %6d with type not supported\r\n", icmpstat.icps_notsupp);
    151         lprint("  %6d with bad type feilds\r\n", icmpstat.icps_badtype);
    152         lprint("  %6d ICMP packets sent in reply\r\n", icmpstat.icps_reflect);
     146    lprint(" \n");
     147    lprint("ICMP stats:\n");
     148    lprint("  %6d ICMP packets received\n", icmpstat.icps_received);
     149    lprint("  %6d were too short\n", icmpstat.icps_tooshort);
     150    lprint("  %6d with bad checksums\n", icmpstat.icps_checksum);
     151    lprint("  %6d with type not supported\n", icmpstat.icps_notsupp);
     152    lprint("  %6d with bad type feilds\n", icmpstat.icps_badtype);
     153    lprint("  %6d ICMP packets sent in reply\n", icmpstat.icps_reflect);
    153154}
    154155
     
    156157mbufstats(PNATState pData)
    157158{
    158         struct mbuf *m;
    159         int i;
    160 
    161         lprint(" \r\n");
    162 
    163         lprint("Mbuf stats:\r\n");
    164 
    165         lprint("  %6d mbufs allocated (%d max)\r\n", mbuf_alloced, mbuf_max);
    166 
    167         i = 0;
    168         for (m = m_freelist.m_next; m != &m_freelist; m = m->m_next)
    169                 i++;
    170         lprint("  %6d mbufs on free list\r\n",  i);
    171 
    172         i = 0;
    173         for (m = m_usedlist.m_next; m != &m_usedlist; m = m->m_next)
    174                 i++;
    175         lprint("  %6d mbufs on used list\r\n",  i);
    176         lprint("  %6d mbufs queued as packets\r\n\r\n", if_queued);
     159    struct mbuf *m;
     160    int i;
     161
     162    lprint(" \n");
     163
     164    lprint("Mbuf stats:\n");
     165
     166    lprint("  %6d mbufs allocated (%d max)\n", mbuf_alloced, mbuf_max);
     167
     168    i = 0;
     169    for (m = m_freelist.m_next; m != &m_freelist; m = m->m_next)
     170        i++;
     171    lprint("  %6d mbufs on free list\n",  i);
     172
     173    i = 0;
     174    for (m = m_usedlist.m_next; m != &m_usedlist; m = m->m_next)
     175        i++;
     176    lprint("  %6d mbufs on used list\n",  i);
     177    lprint("  %6d mbufs queued as packets\n\n", if_queued);
    177178}
    178179
     
    180181sockstats(PNATState pData)
    181182{
    182         char buff[256];
    183         int n;
    184         struct socket *so;
    185 
    186         lprint(" \r\n");
    187 
    188         lprint(
    189            "Proto[state]     Sock     Local Address, Port  Remote Address, Port RecvQ SendQ\r\n");
    190 
    191         for (so = tcb.so_next; so != &tcb; so = so->so_next) {
    192 
    193                 n = sprintf(buff, "tcp[%s]", so->so_tcpcb?tcpstates[so->so_tcpcb->t_state]:"NONE");
    194                 while (n < 17)
    195                    buff[n++] = ' ';
    196                 buff[17] = 0;
    197                 lprint("%s %3d   %15s %5d ",
    198                                 buff, so->s,
    199                                 inet_ntoa(so->so_laddr), ntohs(so->so_lport));
    200                 lprint("%15s %5d %5d %5d\r\n",
    201                                 inet_ntoa(so->so_faddr), ntohs(so->so_fport),
    202                                 so->so_rcv.sb_cc, so->so_snd.sb_cc);
    203         }
    204 
    205         for (so = udb.so_next; so != &udb; so = so->so_next) {
    206 
    207                 n = sprintf(buff, "udp[%d sec]", (so->so_expire - curtime) / 1000);
    208                 while (n < 17)
    209                    buff[n++] = ' ';
    210                 buff[17] = 0;
    211                 lprint("%s %3d  %15s %5d  ",
    212                                 buff, so->s,
    213                                 inet_ntoa(so->so_laddr), ntohs(so->so_lport));
    214                 lprint("%15s %5d %5d %5d\r\n",
    215                                 inet_ntoa(so->so_faddr), ntohs(so->so_fport),
    216                                 so->so_rcv.sb_cc, so->so_snd.sb_cc);
    217         }
    218 }
     183    char buff[256];
     184    int n;
     185    struct socket *so;
     186
     187    lprint(" \n");
     188
     189    lprint(
     190           "Proto[state]     Sock     Local Address, Port  Remote Address, Port RecvQ SendQ\n");
     191
     192    for (so = tcb.so_next; so != &tcb; so = so->so_next)
     193    {
     194        n = sprintf(buff, "tcp[%s]", so->so_tcpcb?tcpstates[so->so_tcpcb->t_state]:"NONE");
     195        while (n < 17)
     196            buff[n++] = ' ';
     197        buff[17] = 0;
     198        lprint("%s %3d   %15s %5d ",
     199               buff, so->s, inet_ntoa(so->so_laddr), ntohs(so->so_lport));
     200        lprint("%15s %5d %5d %5d\n",
     201                inet_ntoa(so->so_faddr), ntohs(so->so_fport),
     202                so->so_rcv.sb_cc, so->so_snd.sb_cc);
     203    }
     204
     205    for (so = udb.so_next; so != &udb; so = so->so_next)
     206    {
     207        n = sprintf(buff, "udp[%d sec]", (so->so_expire - curtime) / 1000);
     208        while (n < 17)
     209            buff[n++] = ' ';
     210        buff[17] = 0;
     211        lprint("%s %3d  %15s %5d  ",
     212                buff, so->s, inet_ntoa(so->so_laddr), ntohs(so->so_lport));
     213        lprint("%15s %5d %5d %5d\n",
     214                inet_ntoa(so->so_faddr), ntohs(so->so_fport),
     215                so->so_rcv.sb_cc, so->so_snd.sb_cc);
     216    }
     217}
     218#endif
     219
    219220static size_t
    220221print_ipv4_address(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
    221                                                const char *pszType, void const *pvValue,
    222                                                int cchWidth, int cchPrecision, unsigned fFlags,
    223                                                void *pvUser)
    224 {
    225         uint32_t ip;
    226         size_t cch = 0;
    227         size_t cchNum = 0;
    228         char szNum[64];
    229         if (strncmp(pszType, "IP4", 3) != 0) {
    230                 RTPrintf("%s: IP4 expected\n", __FUNCTION__);
    231         }
    232         ip = (uint32_t)pvValue;
    233 
    234         cchNum = RTStrFormatNumber(szNum, ip & ((1 << 8) - 1), 0, cchWidth, cchPrecision, fFlags);
    235         cch += pfnOutput(pvArgOutput, szNum, cchNum);
    236         cch += pfnOutput(pvArgOutput, ".", 1);
    237 
    238         cchNum = RTStrFormatNumber(szNum, (ip >> 8) & ((1 << 8) - 1), 0, cchWidth, cchPrecision, fFlags);
    239         cch += pfnOutput(pvArgOutput, szNum, cchNum);
    240         cch += pfnOutput(pvArgOutput, ".", 1);
    241 
    242         cchNum = RTStrFormatNumber(szNum, (ip >> 16) & ((1 << 8) - 1), 0, cchWidth, cchPrecision, fFlags);
    243         cch += pfnOutput(pvArgOutput, szNum, cchNum);
    244         cch += pfnOutput(pvArgOutput, ".", 1);
    245 
    246         cchNum = RTStrFormatNumber(szNum, (ip >> 24) & ((1 << 8) - 1), 0, cchWidth, cchPrecision, fFlags);
    247         cch += pfnOutput(pvArgOutput, szNum, cchNum);
    248         return (cch);
     222                   const char *pszType, void const *pvValue,
     223                   int cchWidth, int cchPrecision, unsigned fFlags,
     224                   void *pvUser)
     225{
     226    uint32_t ip;
     227
     228    AssertReturn(strcmp(pszType, "IP4") == 0, 0);
     229
     230    ip = ntohl(*(uint32_t*)pvValue);
     231    return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%u.%u.%u.%u",
     232           (ip >> 24), (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
    249233}
    250234
     
    252236debug_init()
    253237{
    254         int status = VINF_SUCCESS;
    255         status = RTStrFormatTypeRegister("IP4", print_ipv4_address, NULL);
    256         AssertRC(status);
    257         return (status);
    258 }
     238    int rc = VINF_SUCCESS;
     239
     240    rc = RTStrFormatTypeRegister("IP4", print_ipv4_address, NULL);
     241    AssertRC(rc);
     242
     243    return rc;
     244}
  • trunk/src/VBox/Devices/Network/slirp/icmp_var.h

    r14964 r15054  
    11/*
    22 * Copyright (c) 1982, 1986, 1993
    3  *      The Regents of the University of California.  All rights reserved.
     3 *      The Regents of the University of California.  All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    1313 * 3. All advertising materials mentioning features or use of this software
    1414 *    must display the following acknowledgement:
    15  *      This product includes software developed by the University of
    16  *      California, Berkeley and its contributors.
     15 *      This product includes software developed by the University of
     16 *      California, Berkeley and its contributors.
    1717 * 4. Neither the name of the University nor the names of its contributors
    1818 *    may be used to endorse or promote products derived from this software
     
    3131 * SUCH DAMAGE.
    3232 *
    33  *      @(#)icmp_var.h  8.1 (Berkeley) 6/10/93
     33 *      @(#)icmp_var.h  8.1 (Berkeley) 6/10/93
    3434 * icmp_var.h,v 1.4 1995/02/16 00:27:40 wollman Exp
    3535 */
     
    4545{
    4646/* statistics related to input messages processed */
    47     u_long  icps_received;              /* #ICMP packets received */
    48     u_long      icps_tooshort;          /* packet < ICMP_MINLEN */
    49     u_long      icps_checksum;          /* bad checksum */
    50     u_long      icps_notsupp;           /* #ICMP packets not supported */
    51     u_long  icps_badtype;               /* #with bad type feild */
    52     u_long      icps_reflect;           /* number of responses */
     47    u_long  icps_received;              /* #ICMP packets received */
     48    u_long  icps_tooshort;              /* packet < ICMP_MINLEN */
     49    u_long  icps_checksum;              /* bad checksum */
     50    u_long  icps_notsupp;               /* #ICMP packets not supported */
     51    u_long  icps_badtype;               /* #with bad type feild */
     52    u_long  icps_reflect;               /* number of responses */
    5353};
    5454
     
    5656 * Names for ICMP sysctl objects
    5757 */
    58 #define ICMPCTL_MASKREPL        1       /* allow replies to netmask requests */
    59 #define ICMPCTL_STATS           2       /* statistics (read-only) */
    60 #define ICMPCTL_MAXID           3
     58#define ICMPCTL_MASKREPL        1       /* allow replies to netmask requests */
     59#define ICMPCTL_STATS           2       /* statistics (read-only) */
     60#define ICMPCTL_MAXID           3
    6161
    6262#define ICMPCTL_NAMES { \
    63         { 0, 0 }, \
    64         { "maskrepl", CTLTYPE_INT }, \
    65         { "stats", CTLTYPE_STRUCT }, \
     63        { 0, 0 }, \
     64        { "maskrepl", CTLTYPE_INT }, \
     65        { "stats", CTLTYPE_STRUCT }, \
    6666}
    6767
  • trunk/src/VBox/Devices/Network/slirp/ip.h

    r14638 r15054  
    7070#endif
    7171
    72 typedef u_int32_t n_long;                 /* long as received from the net */
    73 
    7472/*
    7573 * Definitions for internet protocol version 4.
     
    8179 * Structure of an internet header, naked of options.
    8280 */
    83 struct ip {
    84 /*
    85  * bitfield types must be u_int8_t for MSVC, otherwise it will use a full dword (for u_int)
    86  */
     81struct ip
     82{
    8783#ifdef WORDS_BIGENDIAN
    88         u_int ip_v:4,                   /* version */
    89                 ip_hl:4;                /* header length */
    90 #else
    91 #ifdef _MSC_VER
    92         u_int8_t ip_hl:4,               /* header length */
    93 #else
    94         u_int ip_hl:4,          /* header length */
    95 #endif
    96                 ip_v:4;                 /* version */
    97 #endif
    98         u_int8_t ip_tos;                        /* type of service */
    99         u_int16_t       ip_len;                 /* total length */
    100         u_int16_t       ip_id;                  /* identification */
    101         u_int16_t       ip_off;                 /* fragment offset field */
    102 #define IP_DF 0x4000                    /* don't fragment flag */
    103 #define IP_MF 0x2000                    /* more fragments flag */
    104 #define IP_OFFMASK 0x1fff               /* mask for fragmenting bits */
    105         u_int8_t ip_ttl;                        /* time to live */
    106         u_int8_t ip_p;                  /* protocol */
    107         u_int16_t       ip_sum;                 /* checksum */
    108         struct  in_addr ip_src,ip_dst;  /* source and dest address */
    109 };
    110 
    111 #define IP_MAXPACKET    65535           /* maximum packet size */
     84# ifdef _MSC_VER
     85    uint8_t        ip_v:4;     /* version */
     86    uint8_t        ip_hl:4;    /* header length */
     87# else
     88    unsigned       ip_v:4;     /* version */
     89    unsigned       ip_hl:4;    /* header length */
     90# endif
     91#else
     92# ifdef _MSC_VER
     93    uint8_t        ip_hl:4;    /* header length */
     94    uint8_t        ip_v:4;     /* version */
     95# else
     96    unsigned       ip_hl:4;    /* header length */
     97    unsigned       ip_v:4;     /* version */
     98# endif
     99#endif
     100    uint8_t        ip_tos;     /* type of service */
     101    uint16_t       ip_len;     /* total length */
     102    uint16_t       ip_id;      /* identification */
     103    uint16_t       ip_off;     /* fragment offset field */
     104#define IP_DF       0x4000     /* don't fragment flag */
     105#define IP_MF       0x2000     /* more fragments flag */
     106#define IP_OFFMASK  0x1fff     /* mask for fragmenting bits */
     107    uint8_t        ip_ttl;     /* time to live */
     108    uint8_t        ip_p;       /* protocol */
     109    uint16_t       ip_sum;     /* checksum */
     110    struct in_addr ip_src;     /* source address */
     111    struct in_addr ip_dst;     /* destination address */
     112};
     113AssertCompileSize(struct ip, 20);
     114
     115#define IP_MAXPACKET    65535  /* maximum packet size */
    112116
    113117/*
     
    130134#define IPOPT_RESERVED2         0x60
    131135
    132 #define IPOPT_EOL               0               /* end of option list */
    133 #define IPOPT_NOP               1               /* no operation */
    134 
    135 #define IPOPT_RR                7               /* record packet route */
    136 #define IPOPT_TS                68              /* timestamp */
    137 #define IPOPT_SECURITY          130             /* provide s,c,h,tcc */
    138 #define IPOPT_LSRR              131             /* loose source route */
    139 #define IPOPT_SATID             136             /* satnet id */
    140 #define IPOPT_SSRR              137             /* strict source route */
     136#define IPOPT_EOL               0     /* end of option list */
     137#define IPOPT_NOP               1     /* no operation */
     138
     139#define IPOPT_RR                7     /* record packet route */
     140#define IPOPT_TS                68    /* timestamp */
     141#define IPOPT_SECURITY          130   /* provide s,c,h,tcc */
     142#define IPOPT_LSRR              131   /* loose source route */
     143#define IPOPT_SATID             136   /* satnet id */
     144#define IPOPT_SSRR              137   /* strict source route */
    141145
    142146/*
    143147 * Offsets to fields in options other than EOL and NOP.
    144148 */
    145 #define IPOPT_OPTVAL            0               /* option ID */
    146 #define IPOPT_OLEN              1               /* option length */
    147 #define IPOPT_OFFSET            2               /* offset within option */
    148 #define IPOPT_MINOFF            4               /* min value of above */
     149#define IPOPT_OPTVAL            0     /* option ID */
     150#define IPOPT_OLEN              1     /* option length */
     151#define IPOPT_OFFSET            2     /* offset within option */
     152#define IPOPT_MINOFF            4     /* min value of above */
    149153
    150154/*
    151155 * Time stamp option structure.
    152156 */
    153 struct  ip_timestamp {
    154         u_int8_t        ipt_code;               /* IPOPT_TS */
    155         u_int8_t        ipt_len;                /* size of structure (variable) */
    156         u_int8_t        ipt_ptr;                /* index of current entry */
    157 /*
    158  * bitfield types must be u_int8_t for MSVC, otherwise it will use a full dword (for u_int)
    159  */
     157struct  ip_timestamp
     158{
     159    uint8_t        ipt_code;          /* IPOPT_TS */
     160    uint8_t        ipt_len;           /* size of structure (variable) */
     161    uint8_t        ipt_ptr;           /* index of current entry */
    160162#ifdef WORDS_BIGENDIAN
    161         u_int   ipt_oflw:4,             /* overflow counter */
    162                 ipt_flg:4;              /* flags, see below */
    163 #else
    164 #ifdef _MSC_VER
    165         u_int8_t ipt_flg:4,             /* flags, see below */
    166 #else
    167         u_int   ipt_flg:4,              /* flags, see below */
    168 #endif
    169                 ipt_oflw:4;             /* overflow counter */
    170 #endif
    171         union ipt_timestamp {
    172                 n_long  ipt_time[1];
    173                 struct  ipt_ta {
    174                         struct in_addr ipt_addr;
    175                         n_long ipt_time;
    176                 } ipt_ta[1];
    177         } ipt_timestamp;
    178 };
     163# ifdef _MSC_VER
     164    uint8_t        ipt_oflw:4;        /* overflow counter */
     165    uint8_t        ipt_flg:4;         /* flags, see below */
     166# else
     167    unsigned       ipt_oflw:4;        /* overflow counter */
     168    unsigned       ipt_flg:4;         /* flags, see below */
     169# endif
     170#else
     171# ifdef _MSC_VER
     172    uint8_t        ipt_flg:4;         /* flags, see below */
     173    uint8_t        ipt_oflw:4;        /* overflow counter */
     174# else
     175    unsigned       ipt_flg:4;         /* flags, see below */
     176    unsigned       ipt_oflw:4;        /* overflow counter */
     177# endif
     178#endif
     179    union ipt_timestamp
     180    {
     181        uint32_t           ipt_time[1];
     182        struct ipt_ta
     183        {
     184            struct in_addr ipt_addr;
     185            uint32_t       ipt_time;
     186        } ipt_ta[1];
     187    } ipt_timestamp;
     188};
     189AssertCompileSize(struct ip_timestamp, 12);
    179190
    180191/* flag bits for ipt_flg */
    181 #define IPOPT_TS_TSONLY         0               /* timestamps only */
    182 #define IPOPT_TS_TSANDADDR      1               /* timestamps and addresses */
    183 #define IPOPT_TS_PRESPEC        3               /* specified modules only */
     192#define IPOPT_TS_TSONLY         0     /* timestamps only */
     193#define IPOPT_TS_TSANDADDR      1     /* timestamps and addresses */
     194#define IPOPT_TS_PRESPEC        3     /* specified modules only */
    184195
    185196/* bits for security (not byte swapped) */
     
    195206 * Internet implementation parameters.
    196207 */
    197 #define MAXTTL          255             /* maximum time to live (seconds) */
    198 #define IPDEFTTL        64              /* default ttl, from RFC 1340 */
    199 #define IPFRAGTTL       60              /* time to live for frags, slowhz */
    200 #define IPTTLDEC        1               /* subtracted when forwarding */
    201 
    202 #define IP_MSS          576             /* default maximum segment size */
     208#define MAXTTL          255           /* maximum time to live (seconds) */
     209#define IPDEFTTL        64            /* default ttl, from RFC 1340 */
     210#define IPFRAGTTL       60            /* time to live for frags, slowhz */
     211#define IPTTLDEC        1             /* subtracted when forwarding */
     212
     213#define IP_MSS          576           /* default maximum segment size */
    203214
    204215#ifdef HAVE_SYS_TYPES32_H  /* Overcome some Solaris 2.x junk */
     
    227238 * Overlay for ip header used by other protocols (tcp, udp).
    228239 */
    229 struct ipovly {
     240struct ipovly
     241{
    230242#if !defined(VBOX_WITH_BSD_REASS)
    231         caddr32_t       ih_next, ih_prev;       /* for protocol sequence q's */
    232         u_int8_t        ih_x1;                  /* (unused) */
     243    caddr32_t       ih_next;
     244    caddr32_t       ih_prev;          /* for protocol sequence q's */
     245    u_int8_t        ih_x1;            /* (unused) */
    233246#else /* VBOX_WITH_BSD_REASS */
    234         u_int8_t        ih_x1[9];                  /* (unused) */
     247    u_int8_t        ih_x1[9];         /* (unused) */
    235248#endif /* VBOX_WITH_BSD_REASS */
    236         u_int8_t        ih_pr;                  /* protocol */
    237         u_int16_t       ih_len;                 /* protocol length */
    238         struct  in_addr ih_src;         /* source internet address */
    239         struct  in_addr ih_dst;         /* destination internet address */
    240 };
    241 
    242 /*
    243  * Ip reassembly queue structure.  Each fragment
    244  * being reassembled is attached to one of these structures.
    245  * They are timed out after ipq_ttl drops to 0, and may also
    246  * be reclaimed if memory becomes tight.
     249    u_int8_t        ih_pr;            /* protocol */
     250    u_int16_t       ih_len;           /* protocol length */
     251    struct  in_addr ih_src;           /* source internet address */
     252    struct  in_addr ih_dst;           /* destination internet address */
     253};
     254AssertCompileSize(struct ipovly, 20);
     255
     256/*
     257 * Ip reassembly queue structure.  Each fragment being reassembled is
     258 * attached to one of these structures. They are timed out after ipq_ttl
     259 * drops to 0, and may also be reclaimed if memory becomes tight.
    247260 * size 28 bytes
    248261 */
    249 struct ipq_t {
     262struct ipq_t
     263{
    250264#ifndef VBOX_WITH_BSD_REASS
    251         ipqp_32 next,prev;      /* to other reass headers */
     265    ipqp_32         next;
     266    ipqp_32         prev;            /* to other reass headers */
    252267#else  /* VBOX_WITH_BSD_REASS */
    253         TAILQ_ENTRY(ipq_t) ipq_list;
     268    TAILQ_ENTRY(ipq_t) ipq_list;
    254269#endif /* VBOX_WITH_BSD_REASS */
    255         u_int8_t        ipq_ttl;                /* time for reass q to live */
    256         u_int8_t        ipq_p;                  /* protocol of this fragment */
    257         u_int16_t       ipq_id;                 /* sequence id for reassembly */
     270    u_int8_t        ipq_ttl;         /* time for reass q to live */
     271    u_int8_t        ipq_p;           /* protocol of this fragment */
     272    u_int16_t       ipq_id;          /* sequence id for reassembly */
    258273#ifndef VBOX_WITH_BSD_REASS
    259         ipasfragp_32 ipq_next,ipq_prev;         /* to ip headers of fragments */
     274    ipasfragp_32    ipq_next;
     275    ipasfragp_32    ipq_prev;        /* to ip headers of fragments */
    260276#else  /* VBOX_WITH_BSD_REASS */
    261         u_int8_t        ipq_nfrags;             /* # of fragments in this packet */
    262         struct mbuf *ipq_frags;                 /* to ip headers of fragments */
     277    struct mbuf     *ipq_frags;      /* to ip headers of fragments */
     278    uint8_t         ipq_nfrags;      /* # of fragments in this packet */
    263279#endif /* VBOX_WITH_BSD_REASS */
    264 
    265         struct  in_addr ipq_src,ipq_dst;
     280    struct in_addr  ipq_src;
     281    struct in_addr  ipq_dst;
    266282};
    267283
     
    283299 * Note: ipf_next must be at same offset as ipq_next above
    284300 */
    285 struct  ipasfrag {
     301struct  ipasfrag
     302{
    286303#ifdef WORDS_BIGENDIAN
    287         u_int   ip_v:4,
    288                 ip_hl:4;
    289 #else
    290 #ifdef _MSC_VER
    291         u_int8_t        ip_hl:4,
    292 #else
    293         u_int   ip_hl:4,
    294 #endif
    295                 ip_v:4;
    296 #endif
    297                                         /* BUG : u_int changed to u_int8_t.
    298                                          * sizeof(u_int)==4 on linux 2.0
    299                                          */
    300         u_int8_t ipf_mff;               /* XXX overlays ip_tos: use low bit
    301                                          * to avoid destroying tos (PPPDTRuu);
    302                                          * copied from (ip_off&IP_MF) */
    303         u_int16_t       ip_len;
    304         u_int16_t       ip_id;
    305         u_int16_t       ip_off;
    306         u_int8_t        ip_ttl;
    307         u_int8_t        ip_p;
    308         u_int16_t       ip_sum;
    309         ipasfragp_32 ipf_next;          /* next fragment */
    310         ipasfragp_32 ipf_prev;          /* previous fragment */
    311 };
     304# ifdef _MSC_VER
     305    uint8_t      ip_v:4;
     306    uint8_t      ip_hl:4;
     307# else
     308    unsigned     ip_v:4;
     309    unsigned     ip_hl:4;
     310# endif
     311#else
     312# ifdef _MSC_VER
     313    uint8_t      ip_hl:4;
     314    uint8_t      ip_v:4;
     315# else
     316    unsigned     ip_hl:4;
     317    unsigned     ip_v:4;
     318# endif
     319#endif
     320    u_int8_t     ipf_mff;           /* XXX overlays ip_tos: use low bit
     321                                     * to avoid destroying tos (PPPDTRuu);
     322                                     * copied from (ip_off & IP_MF) */
     323    u_int16_t    ip_len;
     324    u_int16_t    ip_id;
     325    u_int16_t    ip_off;
     326    u_int8_t     ip_ttl;
     327    u_int8_t     ip_p;
     328    u_int16_t    ip_sum;
     329    ipasfragp_32 ipf_next;          /* next fragment */
     330    ipasfragp_32 ipf_prev;          /* previous fragment */
     331};
     332AssertCompileSize(struct ipasfrag, 20);
    312333
    313334/*
     
    319340#define MAX_IPOPTLEN    40
    320341
    321 struct ipoption {
    322         struct  in_addr ipopt_dst;      /* first-hop dst if source routed */
    323         int8_t  ipopt_list[MAX_IPOPTLEN];       /* options proper */
     342struct ipoption
     343{
     344    struct in_addr ipopt_dst;      /* first-hop dst if source routed */
     345    int8_t         ipopt_list[MAX_IPOPTLEN]; /* options proper */
    324346};
    325347
     
    329351 */
    330352
    331 struct  ipstat_t {
    332         u_long  ips_total;              /* total packets received */
    333         u_long  ips_badsum;             /* checksum bad */
    334         u_long  ips_tooshort;           /* packet too short */
    335         u_long  ips_toosmall;           /* not enough data */
    336         u_long  ips_badhlen;            /* ip header length < data size */
    337         u_long  ips_badlen;             /* ip length < ip header length */
    338         u_long  ips_fragments;          /* fragments received */
    339         u_long  ips_fragdropped;        /* frags dropped (dups, out of space) */
    340         u_long  ips_fragtimeout;        /* fragments timed out */
    341         u_long  ips_forward;            /* packets forwarded */
    342         u_long  ips_cantforward;        /* packets rcvd for unreachable dest */
    343         u_long  ips_redirectsent;       /* packets forwarded on same net */
    344         u_long  ips_noproto;            /* unknown or unsupported protocol */
    345         u_long  ips_delivered;          /* datagrams delivered to upper level*/
    346         u_long  ips_localout;           /* total ip packets generated here */
    347         u_long  ips_odropped;           /* lost packets due to nobufs, etc. */
    348         u_long  ips_reassembled;        /* total packets reassembled ok */
    349         u_long  ips_fragmented;         /* datagrams successfully fragmented */
    350         u_long  ips_ofragments;         /* output fragments created */
    351         u_long  ips_cantfrag;           /* don't fragment flag was set, etc. */
    352         u_long  ips_badoptions;         /* error in option processing */
    353         u_long  ips_noroute;            /* packets discarded due to no route */
    354         u_long  ips_badvers;            /* ip version != 4 */
    355         u_long  ips_rawout;             /* total raw ip packets generated */
    356         u_long  ips_unaligned;          /* times the ip packet was not aligned */
    357 };
    358 
    359 
    360 #endif
     353struct  ipstat_t
     354{
     355    u_long  ips_total;              /* total packets received */
     356    u_long  ips_badsum;             /* checksum bad */
     357    u_long  ips_tooshort;           /* packet too short */
     358    u_long  ips_toosmall;           /* not enough data */
     359    u_long  ips_badhlen;            /* ip header length < data size */
     360    u_long  ips_badlen;             /* ip length < ip header length */
     361    u_long  ips_fragments;          /* fragments received */
     362    u_long  ips_fragdropped;        /* frags dropped (dups, out of space) */
     363    u_long  ips_fragtimeout;        /* fragments timed out */
     364    u_long  ips_forward;            /* packets forwarded */
     365    u_long  ips_cantforward;        /* packets rcvd for unreachable dest */
     366    u_long  ips_redirectsent;       /* packets forwarded on same net */
     367    u_long  ips_noproto;            /* unknown or unsupported protocol */
     368    u_long  ips_delivered;          /* datagrams delivered to upper level*/
     369    u_long  ips_localout;           /* total ip packets generated here */
     370    u_long  ips_odropped;           /* lost packets due to nobufs, etc. */
     371    u_long  ips_reassembled;        /* total packets reassembled ok */
     372    u_long  ips_fragmented;         /* datagrams successfully fragmented */
     373    u_long  ips_ofragments;         /* output fragments created */
     374    u_long  ips_cantfrag;           /* don't fragment flag was set, etc. */
     375    u_long  ips_badoptions;         /* error in option processing */
     376    u_long  ips_noroute;            /* packets discarded due to no route */
     377    u_long  ips_badvers;            /* ip version != 4 */
     378    u_long  ips_rawout;             /* total raw ip packets generated */
     379    u_long  ips_unaligned;          /* times the ip packet was not aligned */
     380};
     381
     382#endif
  • trunk/src/VBox/Devices/Network/slirp/ip_icmp.h

    r15035 r15054  
    11/*
    22 * Copyright (c) 1982, 1986, 1993
    3  *      The Regents of the University of California.  All rights reserved.
     3 *      The Regents of the University of California.  All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    1313 * 3. All advertising materials mentioning features or use of this software
    1414 *    must display the following acknowledgement:
    15  *      This product includes software developed by the University of
    16  *      California, Berkeley and its contributors.
     15 *      This product includes software developed by the University of
     16 *      California, Berkeley and its contributors.
    1717 * 4. Neither the name of the University nor the names of its contributors
    1818 *    may be used to endorse or promote products derived from this software
     
    3131 * SUCH DAMAGE.
    3232 *
    33  *      @(#)ip_icmp.h   8.1 (Berkeley) 6/10/93
     33 *      @(#)ip_icmp.h   8.1 (Berkeley) 6/10/93
    3434 * ip_icmp.h,v 1.4 1995/05/30 08:09:43 rgrimes Exp
    3535 */
     
    5151 * Structure of an icmp header.
    5252 */
    53 struct icmp {
    54         u_char  icmp_type;              /* type of message, see below */
    55         u_char  icmp_code;              /* type sub code */
    56         u_short icmp_cksum;             /* ones complement cksum of struct */
    57         union {
    58                 u_char ih_pptr;                 /* ICMP_PARAMPROB */
    59                 struct in_addr ih_gwaddr;       /* ICMP_REDIRECT */
    60                 struct ih_idseq {
    61                         u_short icd_id;
    62                         u_short icd_seq;
    63                 } ih_idseq;
    64                 int ih_void;
     53struct icmp
     54{
     55    uint8_t     icmp_type;              /* type of message, see below */
     56    uint8_t     icmp_code;              /* type sub code */
     57    uint16_t    icmp_cksum;             /* ones complement cksum of struct */
     58    union
     59    {
     60        uint8_t ih_pptr;                 /* ICMP_PARAMPROB */
     61        struct in_addr ih_gwaddr;       /* ICMP_REDIRECT */
     62        struct ih_idseq
     63        {
     64            uint16_t  icd_id;
     65            uint16_t  icd_seq;
     66        } ih_idseq;
     67        int ih_void;
    6568
    66                 /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
    67                 struct ih_pmtu {
    68                         u_short ipm_void;
    69                         u_short ipm_nextmtu;
    70                 } ih_pmtu;
    71         } icmp_hun;
    72 #define icmp_pptr       icmp_hun.ih_pptr
    73 #define icmp_gwaddr     icmp_hun.ih_gwaddr
    74 #define icmp_id         icmp_hun.ih_idseq.icd_id
    75 #define icmp_seq        icmp_hun.ih_idseq.icd_seq
    76 #define icmp_void       icmp_hun.ih_void
    77 #define icmp_pmvoid     icmp_hun.ih_pmtu.ipm_void
    78 #define icmp_nextmtu    icmp_hun.ih_pmtu.ipm_nextmtu
    79         union {
    80                 struct id_ts {
    81                         n_time its_otime;
    82                         n_time its_rtime;
    83                         n_time its_ttime;
    84                 } id_ts;
    85                 struct id_ip  {
    86                         struct ip idi_ip;
    87                         /* options and then 64 bits of data */
    88                 } id_ip;
    89                 uint32_t        id_mask;
    90                 char            id_data[1];
    91         } icmp_dun;
    92 #define icmp_otime      icmp_dun.id_ts.its_otime
    93 #define icmp_rtime      icmp_dun.id_ts.its_rtime
    94 #define icmp_ttime      icmp_dun.id_ts.its_ttime
    95 #define icmp_ip         icmp_dun.id_ip.idi_ip
    96 #define icmp_mask       icmp_dun.id_mask
    97 #define icmp_data       icmp_dun.id_data
     69        /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
     70        struct ih_pmtu
     71        {
     72            uint16_t ipm_void;
     73            uint16_t ipm_nextmtu;
     74        } ih_pmtu;
     75    } icmp_hun;
     76#define icmp_pptr       icmp_hun.ih_pptr
     77#define icmp_gwaddr     icmp_hun.ih_gwaddr
     78#define icmp_id         icmp_hun.ih_idseq.icd_id
     79#define icmp_seq        icmp_hun.ih_idseq.icd_seq
     80#define icmp_void       icmp_hun.ih_void
     81#define icmp_pmvoid     icmp_hun.ih_pmtu.ipm_void
     82#define icmp_nextmtu    icmp_hun.ih_pmtu.ipm_nextmtu
     83    union
     84    {
     85        struct id_ts
     86        {
     87            n_time its_otime;
     88            n_time its_rtime;
     89            n_time its_ttime;
     90        } id_ts;
     91        struct id_ip
     92        {
     93            struct ip idi_ip;
     94            /* options and then 64 bits of data */
     95        } id_ip;
     96        uint32_t        id_mask;
     97        char            id_data[1];
     98    } icmp_dun;
     99#define icmp_otime      icmp_dun.id_ts.its_otime
     100#define icmp_rtime      icmp_dun.id_ts.its_rtime
     101#define icmp_ttime      icmp_dun.id_ts.its_ttime
     102#define icmp_ip         icmp_dun.id_ip.idi_ip
     103#define icmp_mask       icmp_dun.id_mask
     104#define icmp_data       icmp_dun.id_data
    98105};
     106AssertCompileSize(struct icmp, 28);
    99107
    100108/*
     
    106114 * ip header length.
    107115 */
    108 #define ICMP_MINLEN     8                               /* abs minimum */
    109 #define ICMP_TSLEN      (8 + 3 * sizeof (n_time))       /* timestamp */
    110 #define ICMP_MASKLEN    12                              /* address mask */
    111 #define ICMP_ADVLENMIN  (8 + sizeof (struct ip) + 8)    /* min */
    112 #define ICMP_ADVLEN(p)  (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
    113         /* N.B.: must separately check that ip_hl >= 5 */
     116#define ICMP_MINLEN     8                               /* abs minimum */
     117#define ICMP_TSLEN      (8 + 3 * sizeof (n_time))       /* timestamp */
     118#define ICMP_MASKLEN    12                              /* address mask */
     119#define ICMP_ADVLENMIN  (8 + sizeof (struct ip) + 8)    /* min */
     120#define ICMP_ADVLEN(p)  (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
     121        /* N.B.: must separately check that ip_hl >= 5 */
    114122
    115123/*
    116124 * Definition of type and code field values.
    117125 */
    118 #define ICMP_ECHOREPLY          0               /* echo reply */
    119 #define ICMP_UNREACH            3               /* dest unreachable, codes: */
    120 #define         ICMP_UNREACH_NET        0               /* bad net */
    121 #define         ICMP_UNREACH_HOST       1               /* bad host */
    122 #define         ICMP_UNREACH_PROTOCOL   2               /* bad protocol */
    123 #define         ICMP_UNREACH_PORT       3               /* bad port */
    124 #define         ICMP_UNREACH_NEEDFRAG   4               /* IP_DF caused drop */
    125 #define         ICMP_UNREACH_SRCFAIL    5               /* src route failed */
    126 #define         ICMP_UNREACH_NET_UNKNOWN 6              /* unknown net */
    127 #define         ICMP_UNREACH_HOST_UNKNOWN 7             /* unknown host */
    128 #define         ICMP_UNREACH_ISOLATED   8               /* src host isolated */
    129 #define         ICMP_UNREACH_NET_PROHIB 9               /* prohibited access */
    130 #define         ICMP_UNREACH_HOST_PROHIB 10             /* ditto */
    131 #define         ICMP_UNREACH_TOSNET     11              /* bad tos for net */
    132 #define         ICMP_UNREACH_TOSHOST    12              /* bad tos for host */
    133 #define ICMP_SOURCEQUENCH       4               /* packet lost, slow down */
    134 #define ICMP_REDIRECT           5               /* shorter route, codes: */
    135 #define         ICMP_REDIRECT_NET       0               /* for network */
    136 #define         ICMP_REDIRECT_HOST      1               /* for host */
    137 #define         ICMP_REDIRECT_TOSNET    2               /* for tos and net */
    138 #define         ICMP_REDIRECT_TOSHOST   3               /* for tos and host */
    139 #define ICMP_ECHO               8               /* echo service */
    140 #define ICMP_ROUTERADVERT       9               /* router advertisement */
    141 #define ICMP_ROUTERSOLICIT      10              /* router solicitation */
    142 #define ICMP_TIMXCEED           11              /* time exceeded, code: */
    143 #define         ICMP_TIMXCEED_INTRANS   0               /* ttl==0 in transit */
    144 #define         ICMP_TIMXCEED_REASS     1               /* ttl==0 in reass */
    145 #define ICMP_PARAMPROB          12              /* ip header bad */
    146 #define         ICMP_PARAMPROB_OPTABSENT 1              /* req. opt. absent */
    147 #define ICMP_TSTAMP             13              /* timestamp request */
    148 #define ICMP_TSTAMPREPLY        14              /* timestamp reply */
    149 #define ICMP_IREQ               15              /* information request */
    150 #define ICMP_IREQREPLY          16              /* information reply */
    151 #define ICMP_MASKREQ            17              /* address mask request */
    152 #define ICMP_MASKREPLY          18              /* address mask reply */
     126#define ICMP_ECHOREPLY          0               /* echo reply */
     127#define ICMP_UNREACH            3               /* dest unreachable, codes: */
     128#define         ICMP_UNREACH_NET        0               /* bad net */
     129#define         ICMP_UNREACH_HOST       1               /* bad host */
     130#define         ICMP_UNREACH_PROTOCOL   2               /* bad protocol */
     131#define         ICMP_UNREACH_PORT       3               /* bad port */
     132#define         ICMP_UNREACH_NEEDFRAG   4               /* IP_DF caused drop */
     133#define         ICMP_UNREACH_SRCFAIL    5               /* src route failed */
     134#define         ICMP_UNREACH_NET_UNKNOWN 6              /* unknown net */
     135#define         ICMP_UNREACH_HOST_UNKNOWN 7             /* unknown host */
     136#define         ICMP_UNREACH_ISOLATED   8               /* src host isolated */
     137#define         ICMP_UNREACH_NET_PROHIB 9               /* prohibited access */
     138#define         ICMP_UNREACH_HOST_PROHIB 10             /* ditto */
     139#define         ICMP_UNREACH_TOSNET     11              /* bad tos for net */
     140#define         ICMP_UNREACH_TOSHOST    12              /* bad tos for host */
     141#define ICMP_SOURCEQUENCH       4               /* packet lost, slow down */
     142#define ICMP_REDIRECT           5               /* shorter route, codes: */
     143#define         ICMP_REDIRECT_NET       0               /* for network */
     144#define         ICMP_REDIRECT_HOST      1               /* for host */
     145#define         ICMP_REDIRECT_TOSNET    2               /* for tos and net */
     146#define         ICMP_REDIRECT_TOSHOST   3               /* for tos and host */
     147#define ICMP_ECHO               8               /* echo service */
     148#define ICMP_ROUTERADVERT       9               /* router advertisement */
     149#define ICMP_ROUTERSOLICIT      10              /* router solicitation */
     150#define ICMP_TIMXCEED           11              /* time exceeded, code: */
     151#define         ICMP_TIMXCEED_INTRANS   0               /* ttl==0 in transit */
     152#define         ICMP_TIMXCEED_REASS     1               /* ttl==0 in reass */
     153#define ICMP_PARAMPROB          12              /* ip header bad */
     154#define         ICMP_PARAMPROB_OPTABSENT 1              /* req. opt. absent */
     155#define ICMP_TSTAMP             13              /* timestamp request */
     156#define ICMP_TSTAMPREPLY        14              /* timestamp reply */
     157#define ICMP_IREQ               15              /* information request */
     158#define ICMP_IREQREPLY          16              /* information reply */
     159#define ICMP_MASKREQ            17              /* address mask request */
     160#define ICMP_MASKREPLY          18              /* address mask reply */
    153161
    154 #define ICMP_MAXTYPE            18
     162#define ICMP_MAXTYPE            18
    155163
    156 #define ICMP_INFOTYPE(type) \
    157         ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
    158         (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
    159         (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
    160         (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
    161         (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
     164#define ICMP_INFOTYPE(type) \
     165        ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
     166        (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
     167        (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
     168        (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
     169        (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
    162170
    163171void icmp_input _P((PNATState, struct mbuf *, int));
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r15035 r15054  
    599599    int error;
    600600#endif
     601    static uint32_t stat_time;
    601602
    602603    STAM_REL_PROFILE_START(&pData->StatPoll, a);
     
    604605    /* Update time */
    605606    updtime(pData);
     607
     608#ifdef LOG_ENABLED
     609    if (curtime - stat_time > 10000)
     610    {
     611        stat_time = curtime;
     612        sockstats(pData);
     613    }
     614#endif
    606615
    607616    /*
  • trunk/src/VBox/Devices/Network/slirp/slirp.h

    r14964 r15054  
    268268#endif
    269269
    270 DECLINLINE(void) lprint (const char *pszFormat, ...)
    271 {
    272 #ifdef LOG_ENABLED
    273     va_list args;
    274     va_start(args, pszFormat);
    275 #if 1 /* nearly only for stats which we always want. */
    276     RTLogPrintfV(pszFormat, args);
    277 #else
    278     Log(("%N", pszFormat, &args));
    279 #endif
    280     va_end(args);
    281 #endif
    282 }
    283 
    284 extern int do_echo;
    285 
    286270#if SIZEOF_CHAR_P == 4
    287271# define insque_32 insque
  • trunk/src/VBox/Devices/Network/slirp/slirp_state.h

    r15035 r15054  
    3535
    3636/** Entry in the table of known DHCP clients. */
    37 typedef struct {
     37typedef struct
     38{
    3839    bool allocated;
    3940    uint8_t macaddr[6];
     
    4243
    4344/** TFTP session entry. */
    44 struct tftp_session {
     45struct tftp_session
     46{
    4547    int in_use;
    4648    unsigned char filename[TFTP_FILENAME_MAX];
     
    282284#endif
    283285
    284 
    285286#endif /* !_slirp_state_h_ */
  • trunk/src/VBox/Devices/Network/slirp/tcp.h

    r1076 r15054  
    11/*
    22 * Copyright (c) 1982, 1986, 1993
    3  *      The Regents of the University of California.  All rights reserved.
     3 *      The Regents of the University of California.  All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    1313 * 3. All advertising materials mentioning features or use of this software
    1414 *    must display the following acknowledgement:
    15  *      This product includes software developed by the University of
    16  *      California, Berkeley and its contributors.
     15 *      This product includes software developed by the University of
     16 *      California, Berkeley and its contributors.
    1717 * 4. Neither the name of the University nor the names of its contributors
    1818 *    may be used to endorse or promote products derived from this software
     
    3131 * SUCH DAMAGE.
    3232 *
    33  *      @(#)tcp.h       8.1 (Berkeley) 6/10/93
     33 *      @(#)tcp.h       8.1 (Berkeley) 6/10/93
    3434 * tcp.h,v 1.3 1994/08/21 05:27:34 paul Exp
    3535 */
     
    3838#define _TCP_H_
    3939
    40 typedef u_int32_t       tcp_seq;
     40typedef uint32_t  tcp_seq;
    4141
    42 #define      PR_SLOWHZ       2               /* 2 slow timeouts per second (approx) */
    43 #define      PR_FASTHZ       5               /* 5 fast timeouts per second (not important) */
     42#define PR_SLOWHZ       2               /* 2 slow timeouts per second (approx) */
     43#define PR_FASTHZ       5               /* 5 fast timeouts per second (not important) */
    4444
    4545extern int tcp_rcvspace;
     
    5454 * Per RFC 793, September, 1981.
    5555 */
    56 struct tcphdr {
    57         u_int16_t       th_sport;               /* source port */
    58         u_int16_t       th_dport;               /* destination port */
    59         tcp_seq th_seq;                 /* sequence number */
    60         tcp_seq th_ack;                 /* acknowledgement number */
    61 /*
    62  * bitfield types must be u_int8_t for MSVC, otherwise it will use a full dword (for u_int)
    63  */
     56struct tcphdr
     57{
     58    uint16_t   th_sport;                /* source port */
     59    uint16_t   th_dport;                /* destination port */
     60    tcp_seq    th_seq;                  /* sequence number */
     61    tcp_seq    th_ack;                  /* acknowledgement number */
    6462#ifdef WORDS_BIGENDIAN
    65         u_int   th_off:4,               /* data offset */
    66                 th_x2:4;                /* (unused) */
     63# ifdef _MSC_VER
     64    uint8_t    th_off:4;               /* data offset */
     65    uint8_t    th_x2:4;                /* (unused) */
     66# else
     67    unsigned   th_off:4;               /* data offset */
     68    unsigned   th_x2:4;                /* (unused) */
     69# endif
    6770#else
    68 #ifdef _MSC_VER
    69         u_int8_t        th_x2:4,                /* (unused) */
    70 #else
    71         u_int   th_x2:4,                /* (unused) */
     71# ifdef _MSC_VER
     72    uint8_t    th_x2:4;                /* (unused) */
     73    uint8_t    th_off:4;               /* data offset */
     74# else
     75    unsigned   th_x2:4;                /* (unused) */
     76    unsigned   th_off:4;               /* data offset */
     77# endif
    7278#endif
    73                 th_off:4;               /* data offset */
    74 #endif
    75         u_int8_t        th_flags;
    76 #define TH_FIN  0x01
    77 #define TH_SYN  0x02
    78 #define TH_RST  0x04
    79 #define TH_PUSH 0x08
    80 #define TH_ACK  0x10
    81 #define TH_URG  0x20
    82         u_int16_t       th_win;                 /* window */
    83         u_int16_t       th_sum;                 /* checksum */
    84         u_int16_t       th_urp;                 /* urgent pointer */
     79    uint8_t    th_flags;
     80#define TH_FIN  0x01
     81#define TH_SYN  0x02
     82#define TH_RST  0x04
     83#define TH_PUSH 0x08
     84#define TH_ACK  0x10
     85#define TH_URG  0x20
     86    uint16_t   th_win;                 /* window */
     87    uint16_t   th_sum;                 /* checksum */
     88    uint16_t   th_urp;                 /* urgent pointer */
    8589};
     90AssertCompileSize(struct tcphdr, 20);
    8691
    8792#include "tcp_var.h"
    8893
    89 #define TCPOPT_EOL              0
    90 #define TCPOPT_NOP              1
    91 #define TCPOPT_MAXSEG           2
    92 #define    TCPOLEN_MAXSEG               4
    93 #define TCPOPT_WINDOW           3
    94 #define    TCPOLEN_WINDOW               3
    95 #define TCPOPT_SACK_PERMITTED   4               /* Experimental */
    96 #define    TCPOLEN_SACK_PERMITTED       2
    97 #define TCPOPT_SACK             5               /* Experimental */
    98 #define TCPOPT_TIMESTAMP        8
    99 #define    TCPOLEN_TIMESTAMP            10
    100 #define    TCPOLEN_TSTAMP_APPA          (TCPOLEN_TIMESTAMP+2) /* appendix A */
     94#define TCPOPT_EOL              0
     95#define TCPOPT_NOP              1
     96#define TCPOPT_MAXSEG           2
     97#define    TCPOLEN_MAXSEG               4
     98#define TCPOPT_WINDOW           3
     99#define    TCPOLEN_WINDOW               3
     100#define TCPOPT_SACK_PERMITTED   4               /* Experimental */
     101#define    TCPOLEN_SACK_PERMITTED       2
     102#define TCPOPT_SACK             5               /* Experimental */
     103#define TCPOPT_TIMESTAMP        8
     104#define    TCPOLEN_TIMESTAMP            10
     105#define    TCPOLEN_TSTAMP_APPA          (TCPOLEN_TIMESTAMP+2) /* appendix A */
    101106
    102 #define TCPOPT_TSTAMP_HDR       \
     107#define TCPOPT_TSTAMP_HDR       \
    103108    (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
    104109
     
    111116 * We make this 1460 because we only care about Ethernet in the qemu context.
    112117 */
    113 #define TCP_MSS 1460
     118#define TCP_MSS 1460
    114119
    115 #define TCP_MAXWIN      65535   /* largest value for (unscaled) window */
     120#define TCP_MAXWIN      65535   /* largest value for (unscaled) window */
    116121
    117 #define TCP_MAX_WINSHIFT        14      /* maximum window shift */
     122#define TCP_MAX_WINSHIFT        14      /* maximum window shift */
    118123
    119124/*
     
    125130 */
    126131#undef TCP_NODELAY
    127 #define TCP_NODELAY     0x01    /* don't delay send to coalesce packets */
     132#define TCP_NODELAY     0x01    /* don't delay send to coalesce packets */
    128133#undef TCP_MAXSEG
    129 /* #define      TCP_MAXSEG      0x02 */ /* set maximum segment size */
     134/* #define      TCP_MAXSEG      0x02 */ /* set maximum segment size */
    130135
    131136/*
     
    156161
    157162/*
    158  * TCP sequence numbers are 32 bit integers operated
    159  * on with modular arithmetic.  These macros can be
    160  * used to compare such integers.
     163 * TCP sequence numbers are 32 bit integers operated on with modular arithmetic.
     164 * These macros can be used to compare such integers.
    161165 */
    162166#define SEQ_LT(a,b)     ((int)((a)-(b)) < 0)
  • trunk/src/VBox/Devices/Network/slirp/tcp_var.h

    r14638 r15054  
    6969#ifdef VBOX_WITH_BSD_REASS
    7070/* TCP segment queue entry */
    71 struct tseg_qent {
    72         LIST_ENTRY(tseg_qent) tqe_q;
    73         int     tqe_len;                /* TCP segment data length */
    74         struct  tcphdr *tqe_th;         /* a pointer to tcp header */
    75         struct  mbuf    *tqe_m;         /* mbuf contains packet */
     71struct tseg_qent
     72{
     73    LIST_ENTRY(tseg_qent) tqe_q;
     74    int             tqe_len;        /* TCP segment data length */
     75    struct tcphdr   *tqe_th;        /* a pointer to tcp header */
     76    struct  mbuf    *tqe_m;         /* mbuf contains packet */
    7677};
    7778LIST_HEAD(tsegqe_head, tseg_qent);
     
    8182 * Tcp control block, one per tcp; fields:
    8283 */
    83 struct tcpcb {
     84struct tcpcb
     85{
    8486#ifndef VBOX_WITH_BSD_REASS
    85         tcpiphdrp_32 seg_next;  /* sequencing queue */
    86         tcpiphdrp_32 seg_prev;
     87    tcpiphdrp_32 seg_next;           /* sequencing queue */
     88    tcpiphdrp_32 seg_prev;
    8789#else  /* VBOX_WITH_BSD_REASS */
    88         LIST_ENTRY(tcpcb) t_list;
    89         struct  tsegqe_head t_segq;     /* segment reassembly queue */
    90         int     t_segqlen;              /* segment reassembly queue length */
     90    LIST_ENTRY(tcpcb) t_list;
     91    struct tsegqe_head t_segq;       /* segment reassembly queue */
     92    int       t_segqlen;             /* segment reassembly queue length */
    9193#endif /* VBOX_WITH_BSD_REASS */
    92         short   t_state;                /* state of this connection */
    93         short   t_timer[TCPT_NTIMERS]; /* tcp timers */
    94         short   t_rxtshift;             /* log(2) of rexmt exp. backoff */
    95         short   t_rxtcur;               /* current retransmit value */
    96         short   t_dupacks;              /* consecutive dup acks recd */
    97         u_short t_maxseg;               /* maximum segment size */
    98         char    t_force;                /* 1 if forcing out a byte */
    99         u_short t_flags;
    100 #define TF_ACKNOW       0x0001          /* ack peer immediately */
    101 #define TF_DELACK       0x0002          /* ack, but try to delay it */
    102 #define TF_NODELAY      0x0004          /* don't delay packets to coalesce */
    103 #define TF_NOOPT        0x0008          /* don't use tcp options */
    104 #define TF_SENTFIN      0x0010          /* have sent FIN */
    105 #define TF_REQ_SCALE    0x0020          /* have/will request window scaling */
    106 #define TF_RCVD_SCALE   0x0040          /* other side has requested scaling */
    107 #define TF_REQ_TSTMP    0x0080          /* have/will request timestamps */
    108 #define TF_RCVD_TSTMP   0x0100          /* a timestamp was received in SYN */
    109 #define TF_SACK_PERMIT  0x0200          /* other side said I could SACK */
    110 
    111         /* Make it static  for now */
    112 /*      struct  tcpiphdr *t_template;   / * skeletal packet for transmit */
    113         struct tcpiphdr t_template;
    114 
    115         struct socket *t_socket;               /* back pointer to socket */
     94    int16_t   t_state;               /* state of this connection */
     95    int16_t   t_timer[TCPT_NTIMERS]; /* tcp timers */
     96    int16_t   t_rxtshift;            /* log(2) of rexmt exp. backoff */
     97    int16_t   t_rxtcur;              /* current retransmit value */
     98    int16_t   t_dupacks;             /* consecutive dup acks recd */
     99    uint16_t  t_maxseg;              /* maximum segment size */
     100    char      t_force;               /* 1 if forcing out a byte */
     101    uint16_t t_flags;
     102#define TF_ACKNOW       0x0001       /* ack peer immediately */
     103#define TF_DELACK       0x0002       /* ack, but try to delay it */
     104#define TF_NODELAY      0x0004       /* don't delay packets to coalesce */
     105#define TF_NOOPT        0x0008       /* don't use tcp options */
     106#define TF_SENTFIN      0x0010       /* have sent FIN */
     107#define TF_REQ_SCALE    0x0020       /* have/will request window scaling */
     108#define TF_RCVD_SCALE   0x0040       /* other side has requested scaling */
     109#define TF_REQ_TSTMP    0x0080       /* have/will request timestamps */
     110#define TF_RCVD_TSTMP   0x0100       /* a timestamp was received in SYN */
     111#define TF_SACK_PERMIT  0x0200       /* other side said I could SACK */
     112
     113    /* Make it static  for now */
     114/*  struct  tcpiphdr *t_template;   / * skeletal packet for transmit */
     115    struct tcpiphdr t_template;
     116
     117    struct socket *t_socket;               /* back pointer to socket */
    116118/*
    117119 * The following fields are used as in the protocol specification.
    118120 * See RFC783, Dec. 1981, page 21.
    119121 */
    120 /* send sequence variables */
    121         tcp_seq snd_una;                /* send unacknowledged */
    122         tcp_seq snd_nxt;                /* send next */
    123         tcp_seq snd_up;                 /* send urgent pointer */
    124         tcp_seq snd_wl1;                /* window update seg seq number */
    125         tcp_seq snd_wl2;                /* window update seg ack number */
    126         tcp_seq iss;                    /* initial send sequence number */
    127         u_int32_t snd_wnd;              /* send window */
    128 /* receive sequence variables */
    129         u_int32_t rcv_wnd;              /* receive window */
    130         tcp_seq rcv_nxt;                /* receive next */
    131         tcp_seq rcv_up;                 /* receive urgent pointer */
    132         tcp_seq irs;                    /* initial receive sequence number */
     122    /* send sequence variables */
     123    tcp_seq   snd_una;               /* send unacknowledged */
     124    tcp_seq   snd_nxt;               /* send next */
     125    tcp_seq   snd_up;                /* send urgent pointer */
     126    tcp_seq   snd_wl1;               /* window update seg seq number */
     127    tcp_seq   snd_wl2;               /* window update seg ack number */
     128    tcp_seq   iss;                   /* initial send sequence number */
     129    uint32_t  snd_wnd;               /* send window */
     130    /* receive sequence variables */
     131    uint32_t  rcv_wnd;               /* receive window */
     132    tcp_seq   rcv_nxt;               /* receive next */
     133    tcp_seq   rcv_up;                /* receive urgent pointer */
     134    tcp_seq   irs;                   /* initial receive sequence number */
    133135/*
    134136 * Additional variables for this implementation.
    135137 */
    136 /* receive variables */
    137         tcp_seq rcv_adv;                /* advertised window */
    138 /* retransmit variables */
    139         tcp_seq snd_max;                /* highest sequence number sent;
    140                                          * used to recognize retransmits
    141                                          */
    142 /* congestion control (for slow start, source quench, retransmit after loss) */
    143         u_int32_t snd_cwnd;             /* congestion-controlled window */
    144         u_int32_t snd_ssthresh;         /* snd_cwnd size threshold for
    145                                          * for slow start exponential to
    146                                          * linear switch
    147                                          */
     138    /* receive variables */
     139    tcp_seq   rcv_adv;               /* advertised window */
     140    /* retransmit variables */
     141    tcp_seq   snd_max;               /* highest sequence number sent;
     142                                      * used to recognize retransmits
     143                                      */
     144    /* congestion control (for slow start, source quench, retransmit after loss) */
     145    uint32_t  snd_cwnd;              /* congestion-controlled window */
     146    uint32_t  snd_ssthresh;          /* snd_cwnd size threshold for
     147                                      * for slow start exponential to
     148                                      * linear switch
     149                                      */
    148150/*
    149151 * transmit timing stuff.  See below for scale of srtt and rttvar.
    150152 * "Variance" is actually smoothed difference.
    151153 */
    152         short   t_idle;                 /* inactivity time */
    153         short   t_rtt;                  /* round trip time */
    154         tcp_seq t_rtseq;                /* sequence number being timed */
    155         short   t_srtt;                 /* smoothed round-trip time */
    156         short   t_rttvar;               /* variance in round-trip time */
    157         u_short t_rttmin;               /* minimum rtt allowed */
    158         u_int32_t max_sndwnd;           /* largest window peer has offered */
     154    int16_t   t_idle;                /* inactivity time */
     155    int16_t   t_rtt;                 /* round trip time */
     156    tcp_seq   t_rtseq;               /* sequence number being timed */
     157    int16_t   t_srtt;                /* smoothed round-trip time */
     158    int16_t   t_rttvar;              /* variance in round-trip time */
     159    uint16_t  t_rttmin;              /* minimum rtt allowed */
     160    uint32_t  max_sndwnd;            /* largest window peer has offered */
    159161
    160162/* out-of-band data */
    161         char    t_oobflags;             /* have some */
    162         char    t_iobc;                 /* input character */
     163    char      t_oobflags;            /* have some */
     164    char      t_iobc;                /* input character */
    163165#define TCPOOB_HAVEDATA 0x01
    164166#define TCPOOB_HADDATA  0x02
    165         short   t_softerror;            /* possible error not yet reported */
     167    short     t_softerror;           /* possible error not yet reported */
    166168
    167169/* RFC 1323 variables */
    168         u_char  snd_scale;              /* window scaling for send window */
    169         u_char  rcv_scale;              /* window scaling for recv window */
    170         u_char  request_r_scale;        /* pending window scaling */
    171         u_char  requested_s_scale;
    172         u_int32_t       ts_recent;              /* timestamp echo data */
    173         u_int32_t       ts_recent_age;          /* when last updated */
    174         tcp_seq last_ack_sent;
    175 
     170    uint8_t   snd_scale;             /* window scaling for send window */
     171    uint8_t   rcv_scale;             /* window scaling for recv window */
     172    uint8_t   request_r_scale;       /* pending window scaling */
     173    uint8_t   requested_s_scale;
     174    uint32_t  ts_recent;             /* timestamp echo data */
     175    uint32_t  ts_recent_age;         /* when last updated */
     176    tcp_seq   last_ack_sent;
    176177};
    177178
     
    231232# define REASS_MBUF_GET(ti)    u32_to_ptr(pData, (*(mbufp_32 *)&((ti)->ti_t)), struct mbuf *)
    232233#endif
    233 /*#define REASS_MBUF(ti) (*(mbufp_32 *)&((ti)->ti_t)) - replaced by REASS_MBUF_GET/SET */
    234234
    235235/*
     
    238238 * but that's inconvenient at the moment.
    239239 */
    240 struct tcpstat_t {
    241         u_long  tcps_connattempt;       /* connections initiated */
    242         u_long  tcps_accepts;           /* connections accepted */
    243         u_long  tcps_connects;          /* connections established */
    244         u_long  tcps_drops;             /* connections dropped */
    245         u_long  tcps_conndrops;         /* embryonic connections dropped */
    246         u_long  tcps_closed;            /* conn. closed (includes drops) */
    247         u_long  tcps_segstimed;         /* segs where we tried to get rtt */
    248         u_long  tcps_rttupdated;        /* times we succeeded */
    249         u_long  tcps_delack;            /* delayed acks sent */
    250         u_long  tcps_timeoutdrop;       /* conn. dropped in rxmt timeout */
    251         u_long  tcps_rexmttimeo;        /* retransmit timeouts */
    252         u_long  tcps_persisttimeo;      /* persist timeouts */
    253         u_long  tcps_keeptimeo;         /* keepalive timeouts */
    254         u_long  tcps_keepprobe;         /* keepalive probes sent */
    255         u_long  tcps_keepdrops;         /* connections dropped in keepalive */
    256 
    257         u_long  tcps_sndtotal;          /* total packets sent */
    258         u_long  tcps_sndpack;           /* data packets sent */
    259         u_long  tcps_sndbyte;           /* data bytes sent */
    260         u_long  tcps_sndrexmitpack;     /* data packets retransmitted */
    261         u_long  tcps_sndrexmitbyte;     /* data bytes retransmitted */
    262         u_long  tcps_sndacks;           /* ack-only packets sent */
    263         u_long  tcps_sndprobe;          /* window probes sent */
    264         u_long  tcps_sndurg;            /* packets sent with URG only */
    265         u_long  tcps_sndwinup;          /* window update-only packets sent */
    266         u_long  tcps_sndctrl;           /* control (SYN|FIN|RST) packets sent */
    267 
    268         u_long  tcps_rcvtotal;          /* total packets received */
    269         u_long  tcps_rcvpack;           /* packets received in sequence */
    270         u_long  tcps_rcvbyte;           /* bytes received in sequence */
    271         u_long  tcps_rcvbadsum;         /* packets received with ccksum errs */
    272         u_long  tcps_rcvbadoff;         /* packets received with bad offset */
    273 /*      u_long  tcps_rcvshort;  */      /* packets received too short */
    274         u_long  tcps_rcvduppack;        /* duplicate-only packets received */
    275         u_long  tcps_rcvdupbyte;        /* duplicate-only bytes received */
    276         u_long  tcps_rcvpartduppack;    /* packets with some duplicate data */
    277         u_long  tcps_rcvpartdupbyte;    /* dup. bytes in part-dup. packets */
    278         u_long  tcps_rcvoopack;         /* out-of-order packets received */
    279         u_long  tcps_rcvoobyte;         /* out-of-order bytes received */
    280         u_long  tcps_rcvpackafterwin;   /* packets with data after window */
    281         u_long  tcps_rcvbyteafterwin;   /* bytes rcvd after window */
    282         u_long  tcps_rcvafterclose;     /* packets rcvd after "close" */
    283         u_long  tcps_rcvwinprobe;       /* rcvd window probe packets */
    284         u_long  tcps_rcvdupack;         /* rcvd duplicate acks */
    285         u_long  tcps_rcvacktoomuch;     /* rcvd acks for unsent data */
    286         u_long  tcps_rcvackpack;        /* rcvd ack packets */
    287         u_long  tcps_rcvackbyte;        /* bytes acked by rcvd acks */
    288         u_long  tcps_rcvwinupd;         /* rcvd window update packets */
    289 /*      u_long  tcps_pawsdrop;  */      /* segments dropped due to PAWS */
    290         u_long  tcps_predack;           /* times hdr predict ok for acks */
    291         u_long  tcps_preddat;           /* times hdr predict ok for data pkts */
    292         u_long  tcps_socachemiss;       /* tcp_last_so misses */
    293         u_long  tcps_didnuttin;         /* Times tcp_output didn't do anything XXX */
     240struct tcpstat_t
     241{
     242    u_long  tcps_connattempt;       /* connections initiated */
     243    u_long  tcps_accepts;           /* connections accepted */
     244    u_long  tcps_connects;          /* connections established */
     245    u_long  tcps_drops;             /* connections dropped */
     246    u_long  tcps_conndrops;         /* embryonic connections dropped */
     247    u_long  tcps_closed;            /* conn. closed (includes drops) */
     248    u_long  tcps_segstimed;         /* segs where we tried to get rtt */
     249    u_long  tcps_rttupdated;        /* times we succeeded */
     250    u_long  tcps_delack;            /* delayed acks sent */
     251    u_long  tcps_timeoutdrop;       /* conn. dropped in rxmt timeout */
     252    u_long  tcps_rexmttimeo;        /* retransmit timeouts */
     253    u_long  tcps_persisttimeo;      /* persist timeouts */
     254    u_long  tcps_keeptimeo;         /* keepalive timeouts */
     255    u_long  tcps_keepprobe;         /* keepalive probes sent */
     256    u_long  tcps_keepdrops;         /* connections dropped in keepalive */
     257
     258    u_long  tcps_sndtotal;          /* total packets sent */
     259    u_long  tcps_sndpack;           /* data packets sent */
     260    u_long  tcps_sndbyte;           /* data bytes sent */
     261    u_long  tcps_sndrexmitpack;     /* data packets retransmitted */
     262    u_long  tcps_sndrexmitbyte;     /* data bytes retransmitted */
     263    u_long  tcps_sndacks;           /* ack-only packets sent */
     264    u_long  tcps_sndprobe;          /* window probes sent */
     265    u_long  tcps_sndurg;            /* packets sent with URG only */
     266    u_long  tcps_sndwinup;          /* window update-only packets sent */
     267    u_long  tcps_sndctrl;           /* control (SYN|FIN|RST) packets sent */
     268
     269    u_long  tcps_rcvtotal;          /* total packets received */
     270    u_long  tcps_rcvpack;           /* packets received in sequence */
     271    u_long  tcps_rcvbyte;           /* bytes received in sequence */
     272    u_long  tcps_rcvbadsum;         /* packets received with ccksum errs */
     273    u_long  tcps_rcvbadoff;         /* packets received with bad offset */
     274/*  u_long  tcps_rcvshort;  */      /* packets received too short */
     275    u_long  tcps_rcvduppack;        /* duplicate-only packets received */
     276    u_long  tcps_rcvdupbyte;        /* duplicate-only bytes received */
     277    u_long  tcps_rcvpartduppack;    /* packets with some duplicate data */
     278    u_long  tcps_rcvpartdupbyte;    /* dup. bytes in part-dup. packets */
     279    u_long  tcps_rcvoopack;         /* out-of-order packets received */
     280    u_long  tcps_rcvoobyte;         /* out-of-order bytes received */
     281    u_long  tcps_rcvpackafterwin;   /* packets with data after window */
     282    u_long  tcps_rcvbyteafterwin;   /* bytes rcvd after window */
     283    u_long  tcps_rcvafterclose;     /* packets rcvd after "close" */
     284    u_long  tcps_rcvwinprobe;       /* rcvd window probe packets */
     285    u_long  tcps_rcvdupack;         /* rcvd duplicate acks */
     286    u_long  tcps_rcvacktoomuch;     /* rcvd acks for unsent data */
     287    u_long  tcps_rcvackpack;        /* rcvd ack packets */
     288    u_long  tcps_rcvackbyte;        /* bytes acked by rcvd acks */
     289    u_long  tcps_rcvwinupd;         /* rcvd window update packets */
     290/*  u_long  tcps_pawsdrop;  */      /* segments dropped due to PAWS */
     291    u_long  tcps_predack;           /* times hdr predict ok for acks */
     292    u_long  tcps_preddat;           /* times hdr predict ok for data pkts */
     293    u_long  tcps_socachemiss;       /* tcp_last_so misses */
     294    u_long  tcps_didnuttin;         /* Times tcp_output didn't do anything XXX */
    294295#ifdef VBOX_WITH_BSD_REASS
    295         u_long tcps_rcvmemdrop;
     296    u_long tcps_rcvmemdrop;
    296297#endif /* VBOX_WITH_BSD_REASS */
    297298};
  • trunk/src/VBox/Devices/Network/slirp/udp.h

    r14470 r15054  
    4747 * Per RFC 768, September, 1981.
    4848 */
    49 struct udphdr {
    50         u_int16_t       uh_sport;               /* source port */
    51         u_int16_t       uh_dport;               /* destination port */
    52         int16_t uh_ulen;                /* udp length */
    53         u_int16_t       uh_sum;                 /* udp checksum */
     49struct udphdr
     50{
     51    uint16_t   uh_sport;               /* source port */
     52    uint16_t   uh_dport;               /* destination port */
     53    int16_t    uh_ulen;                /* udp length */
     54    uint16_t   uh_sum;                 /* udp checksum */
    5455};
    5556
     
    5758 * UDP kernel structures and variables.
    5859 */
    59 struct udpiphdr {
    60                 struct  ipovly ui_i;            /* overlaid ip structure */
    61                 struct  udphdr ui_u;            /* udp header */
     60struct udpiphdr
     61{
     62    struct ipovly ui_i;            /* overlaid ip structure */
     63    struct udphdr ui_u;            /* udp header */
    6264};
    6365#define ui_next         ui_i.ih_next
     
    7375#define ui_sum          ui_u.uh_sum
    7476
    75 struct udpstat_t {
    76                                         /* input statistics: */
    77                 u_long  udps_ipackets;          /* total input packets */
    78                 u_long  udps_hdrops;            /* packet shorter than header */
    79                 u_long  udps_badsum;            /* checksum error */
    80                 u_long  udps_badlen;            /* data length larger than packet */
    81                 u_long  udps_noport;            /* no socket on port */
    82                 u_long  udps_noportbcast;       /* of above, arrived as broadcast */
    83                 u_long  udps_fullsock;          /* not delivered, input socket full */
    84                 u_long  udpps_pcbcachemiss;     /* input packets missing pcb cache */
    85                                         /* output statistics: */
    86                 u_long  udps_opackets;          /* total output packets */
     77struct udpstat_t
     78{
     79                                    /* input statistics: */
     80    u_long  udps_ipackets;          /* total input packets */
     81    u_long  udps_hdrops;            /* packet shorter than header */
     82    u_long  udps_badsum;            /* checksum error */
     83    u_long  udps_badlen;            /* data length larger than packet */
     84    u_long  udps_noport;            /* no socket on port */
     85    u_long  udps_noportbcast;       /* of above, arrived as broadcast */
     86    u_long  udps_fullsock;          /* not delivered, input socket full */
     87    u_long  udpps_pcbcachemiss;     /* input packets missing pcb cache */
     88                                    /* output statistics: */
     89    u_long  udps_opackets;          /* total output packets */
    8790};
    8891
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