VirtualBox

Changeset 34305 in vbox


Ignore:
Timestamp:
Nov 24, 2010 6:21:52 AM (14 years ago)
Author:
vboxsync
Message:

NAT: routines printing TCB and TCP segment.

File:
1 edited

Legend:

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

    r34209 r34305  
    297297            IP4_ADDR_PRINTF_DECOMP(RT_N2H_U32(in_addr->sin_addr.s_addr)),
    298298            RT_N2H_U16(in_addr->sin_port));
     299}
     300
     301/**
     302 *  Print callback dumping TCP Control Block in terms of RFC 793.
     303 */
     304static DECLCALLBACK(size_t)
     305printTcpcbRfc793(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
     306                 const char *pszType, void const *pvValue,
     307                 int cchWidth, int cchPrecision, unsigned fFlags,
     308                 void *pvUser)
     309{
     310    size_t cb = 0;
     311    const struct tcpcb *tp = (const struct tcpcb *)pvValue;
     312    AssertReturn(RTStrCmp(pszType, "tcpcb793") == 0 && tp, 0);
     313    cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "TCB793[ SND(UNA: %x, NXT: %x, UP: %x, WND: %x, WL1:%x, WL2:%x, ISS:%x), ",
     314                      tp->snd_una, tp->snd_nxt, tp->snd_up, tp->snd_wnd, tp->snd_wl1, tp->snd_wl2, tp->iss);
     315    cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "RCV(WND: %x, NXT: %x, UP: %x, IRS:%x)]", tp->rcv_wnd, tp->rcv_nxt, tp->rcv_up, tp->irs);
     316    return cb;
     317}
     318/*
     319 * Prints TCP segment in terms of RFC 793.
     320 */
     321static DECLCALLBACK(size_t)
     322printTcpSegmentRfc793(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
     323                 const char *pszType, void const *pvValue,
     324                 int cchWidth, int cchPrecision, unsigned fFlags,
     325                 void *pvUser)
     326{
     327    size_t cb = 0;
     328    const struct tcpiphdr *ti = (const struct tcpiphdr *)pvValue;
     329    AssertReturn(RTStrCmp(pszType, "tcpseg793") == 0 && ti, 0);
     330    cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SEG[ACK: %x, SEQ: %x, LEN: %x, WND: %x, UP: %x]",
     331                      ti->ti_ack, ti->ti_seq, ti->ti_len, ti->ti_win, ti->ti_urp);
     332    return cb;
    299333}
    300334
     
    369403            print_networkevents, NULL);
    370404        AssertRC(rc);
     405        rc = RTStrFormatTypeRegister("tcpcb793", printTcpcbRfc793, NULL);
     406        AssertRC(rc);
     407        rc = RTStrFormatTypeRegister("tcpseg793", printTcpSegmentRfc793, NULL);
     408        AssertRC(rc);
    371409        g_fFormatRegistered = 1;
    372410    }
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