VirtualBox

Changeset 14882 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Dec 2, 2008 6:12:45 AM (16 years ago)
Author:
vboxsync
Message:

registered log formatter prining IPv4 addresses on %R[IP4]

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

Legend:

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

    r14476 r14882  
    88
    99#include <slirp.h>
     10#include <iprt/string.h>
     11#include <iprt/stream.h>
    1012
    1113
     
    215217        }
    216218}
    217 
     219static size_t
     220print_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);
     249}
     250
     251int
     252debug_init()
     253{
     254        int status = VINF_SUCCESS;
     255        status = RTStrFormatTypeRegister("IP4", print_ipv4_address, NULL);
     256        AssertRC(status);
     257        return (status);
     258}
  • trunk/src/VBox/Devices/Network/slirp/debug.h

    r14476 r14882  
    6262#endif  /* !LOG_ENABLED */
    6363
    64 void debug_init _P((char *, int));
     64int debug_init _P((void));
    6565void ipstats _P((PNATState));
    6666void tcpstats _P((PNATState));
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r14642 r14882  
    243243    link_up = 1;
    244244
     245    debug_init();
    245246    if_init(pData);
    246247    ip_init(pData);
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