VirtualBox

Changeset 17056 in vbox for trunk


Ignore:
Timestamp:
Feb 24, 2009 12:06:19 PM (16 years ago)
Author:
vboxsync
Message:

NAT: introduced (port) service slection for correct bind operation.
some services require special value for source port.

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

Legend:

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

    r17043 r17056  
    11191119                int inq, outq;
    11201120                int status;
     1121                socklen_t optlen = sizeof(int);
    11211122                inq = outq = 0;
    1122                 socklen_t optlen = sizeof(int);
    11231123                status = getsockopt(so->s, SOL_SOCKET, SO_ERROR, &err, &optlen);
    11241124                if (status != 0)
     
    15581558}
    15591559#endif
     1560
     1561uint16_t slirp_get_service(int proto, uint16_t dport, uint16_t sport)
     1562{
     1563    uint16_t hdport, hsport, service;
     1564    hdport = ntohs(dport);
     1565    hsport = ntohs(sport);
     1566    Log2(("proto: %d, dport: %d sport: %d\n", proto, hdport, hsport));
     1567    service = 0;
     1568    switch (hdport)
     1569    {
     1570        case 500:
     1571            if (hsport == 500) service = 500;
     1572        break;
     1573    }
     1574    Log2(("service : %d\n", service));
     1575    return htons(service);
     1576}
  • trunk/src/VBox/Devices/Network/slirp/slirp.h

    r16226 r17056  
    321321struct tcpcb *tcp_drop(PNATState, struct tcpcb *tp, int err);
    322322
     323uint16_t slirp_get_service(int proto, uint16_t dport, uint16_t sport);
     324
    323325#define MIN_MRU 128
    324326#define MAX_MRU 16384
  • trunk/src/VBox/Devices/Network/slirp/udp.c

    r16946 r17056  
    202202        if ((so = socreate()) == NULL)
    203203            goto bad;
    204         if (udp_attach(pData, so) == -1)
     204        if (udp_attach(pData, so, slirp_get_service(IPPROTO_UDP, uh->uh_dport, uh->uh_sport)) == -1)
    205205        {
    206206            DEBUG_MISC((dfd," udp_attach errno = %d-%s\n",
     
    349349
    350350int
    351 udp_attach(PNATState pData, struct socket *so)
     351udp_attach(PNATState pData, struct socket *so, int service_port)
    352352{
    353353    struct sockaddr_in addr;
     
    364364         */
    365365        addr.sin_family = AF_INET;
    366         addr.sin_port = 0;
     366        addr.sin_port = service_port;
    367367        addr.sin_addr.s_addr = INADDR_ANY;
    368368        fd_nonblock(so->s);
  • trunk/src/VBox/Devices/Network/slirp/udp.h

    r16946 r17056  
    105105void udp_input _P((PNATState, register struct mbuf *, int));
    106106int udp_output _P((PNATState, struct socket *, struct mbuf *, struct sockaddr_in *));
    107 int udp_attach _P((PNATState, struct socket *));
     107int udp_attach _P((PNATState, struct socket *, int service_port));
    108108void udp_detach _P((PNATState, struct socket *));
    109109u_int8_t udp_tos _P((struct socket *));
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