Changeset 10469


Ignore:
Timestamp:
10/07/08 16:03:33 (5 years ago)
Author:
BrainSlayer
Message:

update to 3.10

Location:
src/router/rp-pppoe-3.5/src
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • src/router/rp-pppoe-3.5/src/common.c

    r7294 r10469  
    1717 
    1818static char const RCSID[] = 
    19 "$Id: common.c,v 1.21 2006/01/03 03:20:38 dfs Exp $"; 
     19"$Id$"; 
    2020/* For vsnprintf prototype */ 
    2121#define _ISOC99_SOURCE 1 
  • src/router/rp-pppoe-3.5/src/debug.c

    r1905 r10469  
    1717 
    1818static char const RCSID[] = 
    19 "$Id: debug.c,v 1.6 2006/01/03 03:05:06 dfs Exp $"; 
     19"$Id$"; 
    2020 
    2121#include "pppoe.h" 
  • src/router/rp-pppoe-3.5/src/discovery.c

    r1905 r10469  
    1212 
    1313static char const RCSID[] = 
    14 "$Id: discovery.c,v 1.25 2006/01/03 03:20:38 dfs Exp $"; 
     14"$Id$"; 
    1515 
    1616#include "pppoe.h" 
     
    2727#include <sys/time.h> 
    2828#endif 
     29#include <time.h> 
    2930 
    3031#ifdef HAVE_SYS_UIO_H 
     
    323324    int r; 
    324325    struct timeval tv; 
     326    struct timeval expire_at; 
     327    struct timeval now; 
     328 
    325329    PPPoEPacket packet; 
    326330    int len; 
     
    333337    pc.seenServiceName = 0; 
    334338 
     339    if (gettimeofday(&expire_at, NULL) < 0) { 
     340        fatalSys("gettimeofday (waitForPADO)"); 
     341    } 
     342    expire_at.tv_sec += timeout; 
     343 
    335344    do { 
    336345        if (BPF_BUFFER_IS_EMPTY) { 
    337             tv.tv_sec = timeout; 
    338             tv.tv_usec = 0; 
     346            if (gettimeofday(&now, NULL) < 0) { 
     347                fatalSys("gettimeofday (waitForPADO)"); 
     348            } 
     349            tv.tv_sec = expire_at.tv_sec - now.tv_sec; 
     350            tv.tv_usec = expire_at.tv_usec - now.tv_usec; 
     351            if (tv.tv_usec < 0) { 
     352                tv.tv_usec += 1000000; 
     353                if (tv.tv_sec) { 
     354                    tv.tv_sec--; 
     355                } else { 
     356                    /* Timed out */ 
     357                    return; 
     358                } 
     359            } 
     360            if (tv.tv_sec <= 0 && tv.tv_usec <= 0) { 
     361                /* Timed out */ 
     362                return; 
     363            } 
    339364 
    340365            FD_ZERO(&readable); 
     
    348373                fatalSys("select (waitForPADO)"); 
    349374            } 
    350             if (r == 0) return;        /* Timed out */ 
     375            if (r == 0) { 
     376                /* Timed out */ 
     377                return; 
     378            } 
    351379        } 
    352380 
     
    509537    int r; 
    510538    struct timeval tv; 
     539    struct timeval expire_at; 
     540    struct timeval now; 
     541 
    511542    PPPoEPacket packet; 
    512543    int len; 
    513544 
     545    if (gettimeofday(&expire_at, NULL) < 0) { 
     546        fatalSys("gettimeofday (waitForPADS)"); 
     547    } 
     548    expire_at.tv_sec += timeout; 
     549 
    514550    do { 
    515551        if (BPF_BUFFER_IS_EMPTY) { 
    516             tv.tv_sec = timeout; 
    517             tv.tv_usec = 0; 
     552            if (gettimeofday(&now, NULL) < 0) { 
     553                fatalSys("gettimeofday (waitForPADS)"); 
     554            } 
     555            tv.tv_sec = expire_at.tv_sec - now.tv_sec; 
     556            tv.tv_usec = expire_at.tv_usec - now.tv_usec; 
     557            if (tv.tv_usec < 0) { 
     558                tv.tv_usec += 1000000; 
     559                if (tv.tv_sec) { 
     560                    tv.tv_sec--; 
     561                } else { 
     562                    /* Timed out */ 
     563                    return; 
     564                } 
     565            } 
     566            if (tv.tv_sec <= 0 && tv.tv_usec <= 0) { 
     567                /* Timed out */ 
     568                return; 
     569            } 
    518570 
    519571            FD_ZERO(&readable); 
     
    527579                fatalSys("select (waitForPADS)"); 
    528580            } 
    529             if (r == 0) return; 
     581            if (r == 0) { 
     582                /* Timed out */ 
     583                return; 
     584            } 
    530585        } 
    531586 
     
    596651    int padrAttempts = 0; 
    597652    int timeout = conn->discoveryTimeout; 
    598  
    599     /* Skip discovery and don't open discovery socket? */ 
    600     if (conn->skipDiscovery && conn->noDiscoverySocket) { 
    601         conn->discoveryState = STATE_SESSION; 
    602         return; 
    603     } 
    604  
    605     conn->discoverySocket = 
    606         openInterface(conn->ifName, Eth_PPPOE_Discovery, conn->myEth); 
    607653 
    608654    /* Skip discovery? */ 
  • src/router/rp-pppoe-3.5/src/if.c

    r1905 r10469  
    1717 
    1818static char const RCSID[] = 
    19 "$Id: if.c,v 1.18 2006/01/03 03:05:06 dfs Exp $"; 
     19"$Id$"; 
    2020 
    2121#include "pppoe.h" 
     
    100100static unsigned char *bpfBuffer;        /* Packet filter buffer */ 
    101101static int bpfLength = 0;               /* Packet filter buffer length */ 
    102 static int bpfSize = 0;                 /* Number of unread bytes in buffer */ 
     102      int bpfSize = 0;                 /* Number of unread bytes in buffer */ 
    103103static int bpfOffset = 0;               /* Current offset in bpfBuffer */ 
    104104#endif 
  • src/router/rp-pppoe-3.5/src/libevent/event.c

    r1905 r10469  
    1616 
    1717static char const RCSID[] = 
    18 "$Id: event.c,v 1.3 2006/02/23 15:38:08 dfs Exp $"; 
     18"$Id$"; 
    1919 
    2020#include "event.h" 
     
    8787    struct timeval abs_timeout, now; 
    8888 
    89     /* Avoid compiler warning */ 
    90     abs_timeout.tv_sec = 0; 
    91     abs_timeout.tv_usec = 0; 
    9289    struct timeval timeout; 
    9390    struct timeval *tm; 
     
    10198    int maxfd = -1; 
    10299    int pastDue; 
     100 
     101    /* Avoid compiler warning */ 
     102    abs_timeout.tv_sec = 0; 
     103    abs_timeout.tv_usec = 0; 
    103104 
    104105    EVENT_DEBUG(("Enter Event_HandleEvent(es=%p)\n", (void *) es)); 
  • src/router/rp-pppoe-3.5/src/libevent/event.h

    r1905 r10469  
    1111* General Public License, version 2 or (at your option) any later version. 
    1212* 
    13 * $Id: event.h,v 1.5 2002/07/05 19:37:26 dfs Exp $ 
     13* $Id$ 
    1414* 
    1515* LIC: GPL 
  • src/router/rp-pppoe-3.5/src/libevent/event_sig.c

    r1905 r10469  
    1616 
    1717static char const RCSID[] = 
    18 "$Id: event_sig.c,v 1.5 2002/07/05 19:37:26 dfs Exp $"; 
     18"$Id$"; 
    1919 
    2020#define _POSIX_SOURCE 1 /* For sigaction defines */ 
  • src/router/rp-pppoe-3.5/src/libevent/event_tcp.c

    r1905 r10469  
    1313 
    1414static char const RCSID[] = 
    15 "$Id: event_tcp.c,v 1.6 2002/05/08 13:54:24 dfs Exp $"; 
     15"$Id$"; 
    1616 
    1717#include "event_tcp.h" 
  • src/router/rp-pppoe-3.5/src/libevent/event_tcp.h

    r1905 r10469  
    88* Copyright (C) 2001 Roaring Penguin Software Inc. 
    99* 
    10 * $Id: event_tcp.h,v 1.3 2002/04/09 20:52:03 dfs Exp $ 
     10* $Id$ 
    1111* 
    1212* This program may be distributed according to the terms of the GNU 
  • src/router/rp-pppoe-3.5/src/libevent/eventpriv.h

    r1905 r10469  
    1212* General Public License, version 2 or (at your option) any later version. 
    1313* 
    14 * $Id: eventpriv.h,v 1.3 2002/04/09 17:28:40 dfs Exp $ 
     14* $Id$ 
    1515* 
    1616* LIC: GPL 
  • src/router/rp-pppoe-3.5/src/libevent/hash.c

    r1905 r10469  
    1616 
    1717static char const RCSID[] = 
    18 "$Id: hash.c,v 1.4 2002/06/12 20:15:51 dfs Exp $"; 
     18"$Id$"; 
    1919 
    2020#include "hash.h" 
  • src/router/rp-pppoe-3.5/src/plugin.c

    r6581 r10469  
    2626 
    2727static char const RCSID[] = 
    28 "$Id: plugin.c,v 1.33 2005/08/09 14:19:02 dfs Exp $"; 
     28"$Id$"; 
    2929 
    3030#define _GNU_SOURCE 1 
     
    5353#include <net/if_arp.h> 
    5454#include <linux/ppp_defs.h> 
    55 #include <linux/if_ppp.h> 
    5655#include <linux/if_pppox.h> 
    5756 
     
    137136    struct sockaddr_pppox sp; 
    138137 
     138    /* Open session socket before discovery phase, to avoid losing session */ 
     139    /* packets sent by peer just after PADS packet (noted on some Cisco    */ 
     140    /* server equipment).                                                  */ 
     141    /* Opening this socket just before waitForPADS in the discovery()      */ 
     142    /* function would be more appropriate, but it would mess-up the code   */ 
     143    conn->sessionSocket = socket(AF_PPPOX, SOCK_STREAM, PX_PROTO_OE); 
     144    if (conn->sessionSocket < 0) { 
     145        error("Failed to create PPPoE socket: %m"); 
     146        return -1; 
     147    } 
     148 
    139149    strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam)); 
    140150    if (existingSession) { 
     
    151161        } 
    152162    } else { 
    153         discovery(conn); 
     163        conn->discoverySocket = 
     164            openInterface(conn->ifName, Eth_PPPOE_Discovery, conn->myEth); 
     165        discovery(conn); 
    154166        if (conn->discoveryState != STATE_SESSION) { 
    155167            error("Unable to complete PPPoE Discovery"); 
     
    161173    ppp_session_number = ntohs(conn->session); 
    162174 
    163     /* Make the session socket */ 
    164     conn->sessionSocket = socket(AF_PPPOX, SOCK_STREAM, PX_PROTO_OE); 
    165     if (conn->sessionSocket < 0) { 
    166         error("Failed to create PPPoE socket: %m"); 
    167         return -1; 
    168     } 
    169175    sp.sa_family = AF_PPPOX; 
    170176    sp.sa_protocol = PX_PROTO_OE; 
  • src/router/rp-pppoe-3.5/src/ppp.c

    r1905 r10469  
    1717 
    1818static char const RCSID[] = 
    19 "$Id: ppp.c,v 1.7 2006/01/03 03:05:06 dfs Exp $"; 
     19"$Id$"; 
    2020 
    2121#include "pppoe.h" 
  • src/router/rp-pppoe-3.5/src/pppoe-server.c

    r7305 r10469  
    1212* General Public License, version 2 or (at your option) any later version. 
    1313* 
    14 * $Id: pppoe-server.c,v 1.96 2006/02/23 15:40:42 dfs Exp $ 
     14* $Id$ 
    1515* 
    1616* LIC: GPL 
     
    1919 
    2020static char const RCSID[] = 
    21 "$Id: pppoe-server.c,v 1.96 2006/02/23 15:40:42 dfs Exp $"; 
     21"$Id$"; 
    2222 
    2323#include "config.h" 
     
    120120size_t NumSessionSlots; 
    121121 
     122/* Maximum number of sessions per MAC address */ 
     123int MaxSessionsPerMac; 
     124 
    122125/* Number of active sessions */ 
    123126size_t NumActiveSessions = 0; 
     
    178181 
    179182#define HOSTNAMELEN 256 
     183 
     184static int 
     185count_sessions_from_mac(unsigned char *eth) 
     186{ 
     187    int n=0; 
     188    ClientSession *s = BusySessions; 
     189    while(s) { 
     190        if (!memcmp(eth, s->eth, ETH_ALEN)) n++; 
     191        s = s->next; 
     192    } 
     193    return n; 
     194} 
    180195 
    181196/********************************************************************** 
     
    532547    } 
    533548 
     549    /* If number of sessions per MAC is limited, check here and don't 
     550       send PADO if already max number of sessions. */ 
     551    if (MaxSessionsPerMac) { 
     552        if (count_sessions_from_mac(packet->ethHdr.h_source) >= MaxSessionsPerMac) { 
     553            syslog(LOG_INFO, "PADI: Client %02x:%02x:%02x:%02x:%02x:%02x attempted to create more than %d session(s)", 
     554                   packet->ethHdr.h_source[0], 
     555                   packet->ethHdr.h_source[1], 
     556                   packet->ethHdr.h_source[2], 
     557                   packet->ethHdr.h_source[3], 
     558                   packet->ethHdr.h_source[4], 
     559                   packet->ethHdr.h_source[5], 
     560                   MaxSessionsPerMac); 
     561            return; 
     562        } 
     563    } 
     564 
    534565    acname.type = htons(TAG_AC_NAME); 
    535566    acname_len = strlen(ACName); 
     
    729760    } 
    730761 
     762    /* If number of sessions per MAC is limited, check here and don't 
     763       send PADS if already max number of sessions. */ 
     764    if (MaxSessionsPerMac) { 
     765        if (count_sessions_from_mac(packet->ethHdr.h_source) >= MaxSessionsPerMac) { 
     766            syslog(LOG_INFO, "PADR: Client %02x:%02x:%02x:%02x:%02x:%02x attempted to create more than %d session(s)", 
     767                   packet->ethHdr.h_source[0], 
     768                   packet->ethHdr.h_source[1], 
     769                   packet->ethHdr.h_source[2], 
     770                   packet->ethHdr.h_source[3], 
     771                   packet->ethHdr.h_source[4], 
     772                   packet->ethHdr.h_source[5], 
     773                   MaxSessionsPerMac); 
     774            return; 
     775        } 
     776    } 
    731777    parsePacket(packet, parsePADRTags, NULL); 
    732778 
     
    9631009    printf( "   -r             -- Randomize session numbers.\n"); 
    9641010    printf( "   -d             -- Debug session creation.\n"); 
     1011    printf( "   -x n           -- Limit to 'n' sessions/MAC address.\n"); 
    9651012    printf( "   -P             -- Check pool file for correctness and exit.\n"); 
    9661013#ifdef HAVE_LICENSE 
     
    10071054 
    10081055#ifndef HAVE_LINUX_KERNEL_PPPOE 
    1009     char *options = "hI:C:L:R:T:m:FN:f:O:o:sp:lrudPc:S:1"; 
     1056    char *options = "x:hI:C:L:R:T:m:FN:f:O:o:sp:lrudPc:S:1"; 
    10101057#else 
    1011     char *options = "hI:C:L:R:T:m:FN:f:O:o:skp:lrudPc:S:1"; 
     1058    char *options = "x:hI:C:L:R:T:m:FN:f:O:o:skp:lrudPc:S:1"; 
    10121059#endif 
    10131060 
     
    10251072    /* Default number of session slots */ 
    10261073    NumSessionSlots = DEFAULT_MAX_SESSIONS; 
     1074    MaxSessionsPerMac = 0; /* No limit */ 
    10271075    NumActiveSessions = 0; 
    10281076 
     
    10301078    while((opt = getopt(argc, argv, options)) != -1) { 
    10311079        switch(opt) { 
     1080        case 'x': 
     1081            if (sscanf(optarg, "%d", &MaxSessionsPerMac) != 1) { 
     1082                usage(argv[0]); 
     1083                exit(EXIT_FAILURE); 
     1084            } 
     1085            if (MaxSessionsPerMac < 0) { 
     1086                MaxSessionsPerMac = 0; 
     1087            } 
     1088            break; 
     1089 
    10321090#ifdef HAVE_LINUX_KERNEL_PPPOE 
    10331091        case 'k': 
  • src/router/rp-pppoe-3.5/src/pppoe-server.h

    r7294 r10469  
    1212* LIC: GPL 
    1313* 
    14 * $Id: pppoe-server.h,v 1.29 2006/02/23 15:40:42 dfs Exp $ 
     14* $Id$ 
    1515* 
    1616***********************************************************************/ 
  • src/router/rp-pppoe-3.5/src/pppoe-sniff.c

    r7294 r10469  
    1616 
    1717static char const RCSID[] = 
    18 "$Id: pppoe-sniff.c,v 1.8 2004/10/04 15:08:29 dfs Exp $"; 
     18"$Id$"; 
    1919 
    2020#include "pppoe.h" 
  • src/router/rp-pppoe-3.5/src/pppoe.c

    r7294 r10469  
    1515 
    1616static char const RCSID[] = 
    17 "$Id: pppoe.c,v 1.43 2006/02/23 15:40:42 dfs Exp $"; 
     17"$Id$"; 
    1818 
    1919#include "pppoe.h" 
     
    232232    int maxFD = 0; 
    233233    int r; 
    234  
    235     /* Open a session socket */ 
    236     conn->sessionSocket = openInterface(conn->ifName, Eth_PPPOE_Session, conn->myEth); 
    237234 
    238235    /* Drop privileges */ 
     
    410407    FILE *pidfile; 
    411408    unsigned int discoveryType, sessionType; 
     409    char const *options; 
    412410 
    413411    PPPoEConnection conn; 
     
    435433    openlog("pppoe", LOG_PID, LOG_DAEMON); 
    436434 
    437     char const *options; 
    438435#ifdef DEBUGGING_ENABLED 
    439436    options = "I:VAT:D:hS:C:Usm:np:e:kdf:F:t:"; 
     
    618615                printf( "Sending discovery flood %d\n", n+1); 
    619616            } 
     617            conn.discoverySocket = 
     618                openInterface(conn.ifName, Eth_PPPOE_Discovery, conn.myEth); 
    620619            discovery(&conn); 
    621620            conn.discoveryState = STATE_SENT_PADI; 
     
    625624    } 
    626625 
    627     discovery(&conn); 
     626    /* Open session socket before discovery phase, to avoid losing session */ 
     627    /* packets sent by peer just after PADS packet (noted on some Cisco    */ 
     628    /* server equipment).                                                  */ 
     629    /* Opening this socket just before waitForPADS in the discovery()      */ 
     630    /* function would be more appropriate, but it would mess-up the code   */ 
     631    if (!optSkipSession) 
     632        conn.sessionSocket = openInterface(conn.ifName, Eth_PPPOE_Session, conn.myEth); 
     633 
     634    /* Skip discovery and don't open discovery socket? */ 
     635    if (conn.skipDiscovery && conn.noDiscoverySocket) { 
     636        conn.discoveryState = STATE_SESSION; 
     637    } else { 
     638        conn.discoverySocket = 
     639            openInterface(conn.ifName, Eth_PPPOE_Discovery, conn.myEth); 
     640        discovery(&conn); 
     641    } 
    628642    if (optSkipSession) { 
    629643        printf("%u:%02x:%02x:%02x:%02x:%02x:%02x\n", 
  • src/router/rp-pppoe-3.5/src/pppoe.h

    r1905 r10469  
    1212* LIC: GPL 
    1313* 
    14 * $Id: pppoe.h,v 1.31 2006/02/21 00:13:14 dfs Exp $ 
     14* $Id$ 
    1515* 
    1616***********************************************************************/ 
  • src/router/rp-pppoe-3.5/src/relay.c

    r7294 r10469  
    1414* LIC: GPL 
    1515* 
    16 * $Id: relay.c,v 1.28 2006/02/23 15:40:42 dfs Exp $ 
     16* $Id$ 
    1717* 
    1818***********************************************************************/ 
    1919static char const RCSID[] = 
    20 "$Id: relay.c,v 1.28 2006/02/23 15:40:42 dfs Exp $"; 
     20"$Id$"; 
    2121 
    2222#define _GNU_SOURCE 1 /* For SA_RESTART */ 
  • src/router/rp-pppoe-3.5/src/relay.h

    r7294 r10469  
    1212* LIC: GPL 
    1313* 
    14 * $Id: relay.h,v 1.13 2006/02/23 15:40:42 dfs Exp $ 
     14* $Id$ 
    1515* 
    1616***********************************************************************/ 
Note: See TracChangeset for help on using the changeset viewer.