VirtualBox

Changeset 19977 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
May 25, 2009 12:16:47 AM (16 years ago)
Author:
vboxsync
Message:

NAT: some glue code and experiments with default NAT rule

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

Legend:

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

    r19759 r19977  
    4545#include <slirp.h>
    4646#include "ip_icmp.h"
     47#ifdef VBOX_WITH_SLIRP_ALIAS
     48# include "alias.h"
     49#endif
    4750
    4851
     
    171174     * Switch out to protocol's input routine.
    172175     */
     176#ifdef VBOX_WITH_SLIRP_ALIAS
     177    {
     178        int rc;
     179        rc = LibAliasIn(LIST_FIRST(&instancehead), mtod(m, char *), ip->ip_len);
     180        Log2(("NAT: LibAlias return %d\n", rc));
     181    }
     182#endif
    173183    ipstat.ips_delivered++;
    174184    switch (ip->ip_p)
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r19839 r19977  
    1717# define _WINSOCK2API_
    1818# include <IPHlpApi.h>
     19#endif
     20#ifdef VBOX_WITH_SLIRP_ALIAS
     21# include<alias.h>
    1922#endif
    2023
     
    662665#endif
    663666#ifdef VBOX_WITHOUT_SLIRP_CLIENT_ETHER
    664     pData->slirp_ethaddr = &special_ethaddr;
     667    pData->slirp_ethaddr = &special_ethaddr[0];
    665668#endif
    666669    alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
     
    682685
    683686    getouraddr(pData);
     687
     688#ifdef VBOX_WITH_SLIRP_ALIAS
     689    {
     690        struct libalias *lib = NULL;
     691        lib = LibAliasInit(pData, NULL);
     692        if (lib == NULL)
     693        {
     694            LogRel(("NAT: LibAlias default rule wasn't initialized\n"));
     695            AssertMsgFailed(("NAT: LibAlias default rule wasn't initialized\n"));
     696        }
     697        LibAliasSetAddress(lib, special_addr);
     698       
     699    }
     700#endif
    684701    return fNATfailed ? VINF_NAT_DNS : VINF_SUCCESS;
    685702}
  • trunk/src/VBox/Devices/Network/slirp/slirp.h

    r19839 r19977  
    3636#include <iprt/string.h>
    3737#include <iprt/dir.h>
     38#include <iprt/rand.h>
    3839#include <VBox/types.h>
    3940
     
    373374AssertCompileSize(struct ethhdr, 14);
    374375# endif
    375 #endif
     376#if defined(VBOX_WITH_SLIRP_ALIAS) && defined(VBOX_SLIRP_ALIAS)
     377# define ip_next(ip) (uintptr_t)((uint8_t *)(ip) + ((ip)->ip_hl << 2))
     378# define bcopy(src, dst, len) memcpy((dst), (src), (len))
     379# define NO_FW_PUNCH
     380# ifdef alias_addr
     381#  error  alias_addr has already defined!!!
     382# endif
     383# define arc4random() RTRandU32()
     384# undef malloc
     385# undef calloc
     386# undef free
     387# define        malloc(x) RTMemAlloc((x))
     388# define        calloc(x, n) RTMemAllocZ((x)*(n))
     389# define        free(x) RTMemFree((x))
     390# ifndef __unused
     391#  define __unused
     392# endif
     393#endif
     394#endif
  • trunk/src/VBox/Devices/Network/slirp/slirp_state.h

    r19839 r19977  
    226226    bool use_dns_proxy;
    227227#endif
     228#ifdef VBOX_WITH_SLIRP_ALIAS
     229    LIST_HEAD(, libalias) instancehead;
     230#endif
    228231    STAMPROFILE StatFill;
    229232    STAMPROFILE StatPoll;
     
    308311#define tt pData->tt
    309312#define our_addr pData->our_addr
    310 #define alias_addr pData->alias_addr
     313#ifndef VBOX_SLIRP_ALIAS
     314# define alias_addr pData->alias_addr
     315#endif
    311316#define special_addr pData->special_addr
    312317#define dns_addr pData->dns_addr
     
    665670#endif
    666671
     672#ifdef VBOX_WITH_SLIRP_ALIAS
     673# define instancehead pData->instancehead
     674#endif
     675
    667676#endif /* !_slirp_state_h_ */
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