VirtualBox

Changeset 34209 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 19, 2010 4:04:55 PM (14 years ago)
Author:
vboxsync
Message:

NAT: added 'info nat%d' handler

Location:
trunk/src/VBox/Devices/Network
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvNAT.cpp

    r34014 r34209  
    991991
    992992/**
     993 * Info handler.
     994 */
     995static DECLCALLBACK(void) drvNATInfo(PPDMDRVINS pDrvIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
     996{
     997    PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT);
     998    slirp_info(pThis->pNATState, pHlp, pszArgs);
     999}
     1000
     1001
     1002/**
    9931003 * Sets up the redirectors.
    9941004 *
     
    13131323            rc = RTCritSectInit(&pThis->XmitLock);
    13141324            AssertRCReturn(rc, rc);
     1325
     1326            char szTmp[128];
     1327            RTStrPrintf(szTmp, sizeof(szTmp), "nat%d", pDrvIns->iInstance);
     1328            PDMDrvHlpDBGFInfoRegister(pDrvIns, szTmp, "NAT info.", drvNATInfo);
    13151329
    13161330#ifndef RT_OS_WINDOWS
  • trunk/src/VBox/Devices/Network/slirp/debug.c

    r34103 r34209  
    279279    if (so->so_state == SS_NOFDREF || so->s == -1)
    280280        return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0,
    281                 "socket(%d) SS_NODREF",so->s);
     281                "socket(%d) SS_NOFDREF", so->s);
     282
    282283    status = getsockname(so->s, &addr, &socklen);
    283 
    284284    if(status != 0 || addr.sa_family != AF_INET)
    285285    {
    286286        return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0,
    287                 "socket(%d) is invalid(probably closed)",so->s);
     287                "socket(%d) is invalid(probably closed)", so->s);
    288288    }
    289289
    290290    in_addr = (struct sockaddr_in *)&addr;
    291291    ip = RT_N2H_U32(so->so_faddr.s_addr);
    292     return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "socket %4d:(proto:%u) "
     292    return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "socket %d:(proto:%u) "
    293293            "state=%04x ip=" IP4_ADDR_PRINTF_FORMAT ":%d "
    294294            "name=" IP4_ADDR_PRINTF_FORMAT ":%d",
  • trunk/src/VBox/Devices/Network/slirp/libslirp.h

    r33825 r34209  
    3838
    3939#include <VBox/types.h>
     40#include <VBox/dbgf.h>
    4041
    4142typedef struct NATState *PNATState;
     
    9091void slirp_set_tcp_sndspace(PNATState pData, int kilobytes);
    9192
    92 int slirp_set_binding_address(PNATState, char *addr);
     93int  slirp_set_binding_address(PNATState, char *addr);
    9394void slirp_set_mtu(PNATState, int);
     95void slirp_info(PNATState pData, PCDBGFINFOHLP pHlp, const char *pszArgs);
    9496
    9597#if defined(RT_OS_WINDOWS)
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r34103 r34209  
    20712071    if_mru = mtu;
    20722072}
     2073
     2074/**
     2075 * Info handler.
     2076 */
     2077void slirp_info(PNATState pData, PCDBGFINFOHLP pHlp, const char *pszArgs)
     2078{
     2079    struct socket *so, *so_next;
     2080    struct arp_cache_entry *ac;
     2081    struct port_forward_rule *rule;
     2082
     2083    pHlp->pfnPrintf(pHlp, "NAT parameters: MTU=%d\n", if_mtu);
     2084    pHlp->pfnPrintf(pHlp, "NAT TCP ports:\n");
     2085    QSOCKET_FOREACH(so, so_next, tcp)
     2086    /* { */
     2087        pHlp->pfnPrintf(pHlp, " %R[natsock]\n", so);
     2088    }
     2089
     2090    pHlp->pfnPrintf(pHlp, "NAT UDP ports:\n");
     2091    QSOCKET_FOREACH(so, so_next, udp)
     2092    /* { */
     2093        pHlp->pfnPrintf(pHlp, " %R[natsock]\n", so);
     2094    }
     2095
     2096    pHlp->pfnPrintf(pHlp, "NAT ARP cache:\n");
     2097    LIST_FOREACH(ac, &pData->arp_cache, list)
     2098    {
     2099        pHlp->pfnPrintf(pHlp, " %R[IP4] %R[ether]\n", &ac->ip, &ac->ether);
     2100    }
     2101
     2102    pHlp->pfnPrintf(pHlp, "NAT rules:\n");
     2103    LIST_FOREACH(rule, &pData->port_forward_rule_head, list)
     2104    {
     2105        pHlp->pfnPrintf(pHlp, " %s %d => %R[IP4]:%d %c\n",
     2106                        rule->proto == IPPROTO_UDP ? "UDP" : "TCP",
     2107                        rule->host_port, &rule->guest_addr.s_addr, rule->guest_port,
     2108                        rule->activated ? ' ' : '*');
     2109    }
     2110}
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