~ubuntu-branches/ubuntu/quantal/virtualbox/quantal

« back to all changes in this revision

Viewing changes to src/VBox/Devices/Network/slirp/libalias/alias_db.c

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-04-05 12:41:55 UTC
  • mfrom: (3.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20120405124155-i7b39tv5ddwhubbe
Tags: 4.1.12-dfsg-2
* Upstream has replaced the 4.1.12 tarball with a new one that fixes a
  crash when creating host only interfaces. (Closes: #667460)
  - Add 36-tarball-respin.patch which contains the diff between the old
    and the new tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
344
344
     * managment and deletion are in repsponsible of Slirp.
345
345
     */
346
346
    int     sockfd; /* socket descriptor                   */
 
347
#  else
 
348
    struct socket *pSo;
347
349
# endif
348
350
#endif
349
351
            LIST_ENTRY    (alias_link) list_out;    /* Linked list of
568
570
/* Local prototypes */
569
571
static int  GetNewPort(struct libalias *, struct alias_link *, int);
570
572
#ifndef NO_USE_SOCKETS
 
573
# ifdef VBOX
 
574
static u_short  GetSocket(struct libalias *, u_short, struct alias_link*, int);
 
575
# else
571
576
static u_short  GetSocket(struct libalias *, u_short, int *, int);
 
577
# endif
572
578
#endif
573
579
static void CleanupAliasData(struct libalias *);
574
580
 
686
692
#ifndef VBOX
687
693
                if (GetSocket(la, port_net, &lnk->sockfd, lnk->link_type)) {
688
694
#else
689
 
                if (GetSocket(la, port_net, NULL, lnk->link_type)) {
 
695
                if (GetSocket(la, port_net, lnk, lnk->link_type)) {
690
696
#endif
691
697
                    lnk->alias_port = port_net;
692
698
                    return (0);
714
720
 
715
721
#ifndef NO_USE_SOCKETS
716
722
static      u_short
 
723
# ifndef VBOX
717
724
GetSocket(struct libalias *la, u_short port_net, int *sockfd, int link_type)
 
725
# else
 
726
GetSocket(struct libalias *la, u_short port_net, struct alias_link *pLnk, int link_type)
 
727
# endif
718
728
{
719
729
    int err;
720
730
    int sock;
801
811
        else
802
812
            Assert(!"Shouldn't be here");
803
813
        LogFunc(("bind called for socket: %R[natsock]\n", so));
 
814
        pLnk->pSo = so;
 
815
        so->so_pvLnk = pLnk;
804
816
#else
805
817
        *sockfd = sock;
806
818
#endif
955
967
        la->cleanupIndex = 0;
956
968
}
957
969
 
 
970
#ifdef VBOX
 
971
/**
 
972
 * when slirp delete the link we need inform libalias about it.
 
973
 */
 
974
void slirpDeleteLinkSocket(void *pvLnk)
 
975
{
 
976
    struct alias_link *lnk = (struct alias_link *)pvLnk;
 
977
    if (   lnk
 
978
        && lnk->pSo)
 
979
    {
 
980
        struct libalias *la = lnk->la;
 
981
        la->sockCount--;
 
982
        lnk->pSo = NULL;
 
983
    }
 
984
}
 
985
#endif /* !VBOX */
 
986
 
958
987
static void
959
988
DeleteLink(struct alias_link *lnk)
960
989
{
961
990
    struct libalias *la = lnk->la;
 
991
    LogFlowFunc(("ENTER: lnk->pSo:%R[natsock]\n", lnk->pSo));
962
992
 
963
993
    LIBALIAS_LOCK_ASSERT(la);
964
994
/* Don't do anything if the link is marked permanent */
993
1023
        close(lnk->sockfd);
994
1024
    }
995
1025
# else
996
 
    /* Slirp will close the socket in its own way */
 
1026
    if (lnk->pSo)
 
1027
    {
 
1028
        /* libalias's sockCount decremented in slirpDeleteLinkSocket,
 
1029
         * which called from sofree
 
1030
         */
 
1031
        /* la->sockCount--; */
 
1032
        /* should we be more smart, or it's enough to be
 
1033
         * narrow-minded and just do sofree here
 
1034
         */
 
1035
        sofree(la->pData, lnk->pSo);
 
1036
        lnk->pSo = NULL;
 
1037
    }
997
1038
# endif
998
1039
#endif
999
1040
/* Link-type dependent cleanup */
1033
1074
    if (la->packetAliasMode & PKT_ALIAS_LOG) {
1034
1075
        ShowAliasStats(la);
1035
1076
    }
 
1077
    LogFlowFuncLeave();
1036
1078
}
1037
1079
 
1038
1080
 
1066
1108
#ifndef NO_USE_SOCKETS
1067
1109
# ifndef VBOX
1068
1110
        lnk->sockfd = -1;
 
1111
# else
 
1112
        lnk->pSo = NULL;
1069
1113
# endif
1070
1114
#endif
1071
1115
        lnk->flags = 0;