Changeset 10469
- Timestamp:
- 10/07/08 16:03:33 (5 years ago)
- Location:
- src/router/rp-pppoe-3.5/src
- Files:
-
- 20 edited
-
common.c (modified) (1 diff)
-
debug.c (modified) (1 diff)
-
discovery.c (modified) (8 diffs)
-
if.c (modified) (2 diffs)
-
libevent/event.c (modified) (3 diffs)
-
libevent/event.h (modified) (1 diff)
-
libevent/event_sig.c (modified) (1 diff)
-
libevent/event_tcp.c (modified) (1 diff)
-
libevent/event_tcp.h (modified) (1 diff)
-
libevent/eventpriv.h (modified) (1 diff)
-
libevent/hash.c (modified) (1 diff)
-
plugin.c (modified) (5 diffs)
-
ppp.c (modified) (1 diff)
-
pppoe-server.c (modified) (10 diffs)
-
pppoe-server.h (modified) (1 diff)
-
pppoe-sniff.c (modified) (1 diff)
-
pppoe.c (modified) (6 diffs)
-
pppoe.h (modified) (1 diff)
-
relay.c (modified) (1 diff)
-
relay.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/router/rp-pppoe-3.5/src/common.c
r7294 r10469 17 17 18 18 static char const RCSID[] = 19 "$Id : common.c,v 1.21 2006/01/03 03:20:38 dfs Exp$";19 "$Id$"; 20 20 /* For vsnprintf prototype */ 21 21 #define _ISOC99_SOURCE 1 -
src/router/rp-pppoe-3.5/src/debug.c
r1905 r10469 17 17 18 18 static char const RCSID[] = 19 "$Id : debug.c,v 1.6 2006/01/03 03:05:06 dfs Exp$";19 "$Id$"; 20 20 21 21 #include "pppoe.h" -
src/router/rp-pppoe-3.5/src/discovery.c
r1905 r10469 12 12 13 13 static char const RCSID[] = 14 "$Id : discovery.c,v 1.25 2006/01/03 03:20:38 dfs Exp$";14 "$Id$"; 15 15 16 16 #include "pppoe.h" … … 27 27 #include <sys/time.h> 28 28 #endif 29 #include <time.h> 29 30 30 31 #ifdef HAVE_SYS_UIO_H … … 323 324 int r; 324 325 struct timeval tv; 326 struct timeval expire_at; 327 struct timeval now; 328 325 329 PPPoEPacket packet; 326 330 int len; … … 333 337 pc.seenServiceName = 0; 334 338 339 if (gettimeofday(&expire_at, NULL) < 0) { 340 fatalSys("gettimeofday (waitForPADO)"); 341 } 342 expire_at.tv_sec += timeout; 343 335 344 do { 336 345 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 } 339 364 340 365 FD_ZERO(&readable); … … 348 373 fatalSys("select (waitForPADO)"); 349 374 } 350 if (r == 0) return; /* Timed out */ 375 if (r == 0) { 376 /* Timed out */ 377 return; 378 } 351 379 } 352 380 … … 509 537 int r; 510 538 struct timeval tv; 539 struct timeval expire_at; 540 struct timeval now; 541 511 542 PPPoEPacket packet; 512 543 int len; 513 544 545 if (gettimeofday(&expire_at, NULL) < 0) { 546 fatalSys("gettimeofday (waitForPADS)"); 547 } 548 expire_at.tv_sec += timeout; 549 514 550 do { 515 551 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 } 518 570 519 571 FD_ZERO(&readable); … … 527 579 fatalSys("select (waitForPADS)"); 528 580 } 529 if (r == 0) return; 581 if (r == 0) { 582 /* Timed out */ 583 return; 584 } 530 585 } 531 586 … … 596 651 int padrAttempts = 0; 597 652 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);607 653 608 654 /* Skip discovery? */ -
src/router/rp-pppoe-3.5/src/if.c
r1905 r10469 17 17 18 18 static char const RCSID[] = 19 "$Id : if.c,v 1.18 2006/01/03 03:05:06 dfs Exp$";19 "$Id$"; 20 20 21 21 #include "pppoe.h" … … 100 100 static unsigned char *bpfBuffer; /* Packet filter buffer */ 101 101 static int bpfLength = 0; /* Packet filter buffer length */ 102 staticint bpfSize = 0; /* Number of unread bytes in buffer */102 int bpfSize = 0; /* Number of unread bytes in buffer */ 103 103 static int bpfOffset = 0; /* Current offset in bpfBuffer */ 104 104 #endif -
src/router/rp-pppoe-3.5/src/libevent/event.c
r1905 r10469 16 16 17 17 static char const RCSID[] = 18 "$Id : event.c,v 1.3 2006/02/23 15:38:08 dfs Exp$";18 "$Id$"; 19 19 20 20 #include "event.h" … … 87 87 struct timeval abs_timeout, now; 88 88 89 /* Avoid compiler warning */90 abs_timeout.tv_sec = 0;91 abs_timeout.tv_usec = 0;92 89 struct timeval timeout; 93 90 struct timeval *tm; … … 101 98 int maxfd = -1; 102 99 int pastDue; 100 101 /* Avoid compiler warning */ 102 abs_timeout.tv_sec = 0; 103 abs_timeout.tv_usec = 0; 103 104 104 105 EVENT_DEBUG(("Enter Event_HandleEvent(es=%p)\n", (void *) es)); -
src/router/rp-pppoe-3.5/src/libevent/event.h
r1905 r10469 11 11 * General Public License, version 2 or (at your option) any later version. 12 12 * 13 * $Id : event.h,v 1.5 2002/07/05 19:37:26 dfs Exp$13 * $Id$ 14 14 * 15 15 * LIC: GPL -
src/router/rp-pppoe-3.5/src/libevent/event_sig.c
r1905 r10469 16 16 17 17 static char const RCSID[] = 18 "$Id : event_sig.c,v 1.5 2002/07/05 19:37:26 dfs Exp$";18 "$Id$"; 19 19 20 20 #define _POSIX_SOURCE 1 /* For sigaction defines */ -
src/router/rp-pppoe-3.5/src/libevent/event_tcp.c
r1905 r10469 13 13 14 14 static char const RCSID[] = 15 "$Id : event_tcp.c,v 1.6 2002/05/08 13:54:24 dfs Exp$";15 "$Id$"; 16 16 17 17 #include "event_tcp.h" -
src/router/rp-pppoe-3.5/src/libevent/event_tcp.h
r1905 r10469 8 8 * Copyright (C) 2001 Roaring Penguin Software Inc. 9 9 * 10 * $Id : event_tcp.h,v 1.3 2002/04/09 20:52:03 dfs Exp$10 * $Id$ 11 11 * 12 12 * This program may be distributed according to the terms of the GNU -
src/router/rp-pppoe-3.5/src/libevent/eventpriv.h
r1905 r10469 12 12 * General Public License, version 2 or (at your option) any later version. 13 13 * 14 * $Id : eventpriv.h,v 1.3 2002/04/09 17:28:40 dfs Exp$14 * $Id$ 15 15 * 16 16 * LIC: GPL -
src/router/rp-pppoe-3.5/src/libevent/hash.c
r1905 r10469 16 16 17 17 static char const RCSID[] = 18 "$Id : hash.c,v 1.4 2002/06/12 20:15:51 dfs Exp$";18 "$Id$"; 19 19 20 20 #include "hash.h" -
src/router/rp-pppoe-3.5/src/plugin.c
r6581 r10469 26 26 27 27 static char const RCSID[] = 28 "$Id : plugin.c,v 1.33 2005/08/09 14:19:02 dfs Exp$";28 "$Id$"; 29 29 30 30 #define _GNU_SOURCE 1 … … 53 53 #include <net/if_arp.h> 54 54 #include <linux/ppp_defs.h> 55 #include <linux/if_ppp.h>56 55 #include <linux/if_pppox.h> 57 56 … … 137 136 struct sockaddr_pppox sp; 138 137 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 139 149 strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam)); 140 150 if (existingSession) { … … 151 161 } 152 162 } else { 153 discovery(conn); 163 conn->discoverySocket = 164 openInterface(conn->ifName, Eth_PPPOE_Discovery, conn->myEth); 165 discovery(conn); 154 166 if (conn->discoveryState != STATE_SESSION) { 155 167 error("Unable to complete PPPoE Discovery"); … … 161 173 ppp_session_number = ntohs(conn->session); 162 174 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 }169 175 sp.sa_family = AF_PPPOX; 170 176 sp.sa_protocol = PX_PROTO_OE; -
src/router/rp-pppoe-3.5/src/ppp.c
r1905 r10469 17 17 18 18 static char const RCSID[] = 19 "$Id : ppp.c,v 1.7 2006/01/03 03:05:06 dfs Exp$";19 "$Id$"; 20 20 21 21 #include "pppoe.h" -
src/router/rp-pppoe-3.5/src/pppoe-server.c
r7305 r10469 12 12 * General Public License, version 2 or (at your option) any later version. 13 13 * 14 * $Id : pppoe-server.c,v 1.96 2006/02/23 15:40:42 dfs Exp$14 * $Id$ 15 15 * 16 16 * LIC: GPL … … 19 19 20 20 static char const RCSID[] = 21 "$Id : pppoe-server.c,v 1.96 2006/02/23 15:40:42 dfs Exp$";21 "$Id$"; 22 22 23 23 #include "config.h" … … 120 120 size_t NumSessionSlots; 121 121 122 /* Maximum number of sessions per MAC address */ 123 int MaxSessionsPerMac; 124 122 125 /* Number of active sessions */ 123 126 size_t NumActiveSessions = 0; … … 178 181 179 182 #define HOSTNAMELEN 256 183 184 static int 185 count_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 } 180 195 181 196 /********************************************************************** … … 532 547 } 533 548 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 534 565 acname.type = htons(TAG_AC_NAME); 535 566 acname_len = strlen(ACName); … … 729 760 } 730 761 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 } 731 777 parsePacket(packet, parsePADRTags, NULL); 732 778 … … 963 1009 printf( " -r -- Randomize session numbers.\n"); 964 1010 printf( " -d -- Debug session creation.\n"); 1011 printf( " -x n -- Limit to 'n' sessions/MAC address.\n"); 965 1012 printf( " -P -- Check pool file for correctness and exit.\n"); 966 1013 #ifdef HAVE_LICENSE … … 1007 1054 1008 1055 #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"; 1010 1057 #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"; 1012 1059 #endif 1013 1060 … … 1025 1072 /* Default number of session slots */ 1026 1073 NumSessionSlots = DEFAULT_MAX_SESSIONS; 1074 MaxSessionsPerMac = 0; /* No limit */ 1027 1075 NumActiveSessions = 0; 1028 1076 … … 1030 1078 while((opt = getopt(argc, argv, options)) != -1) { 1031 1079 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 1032 1090 #ifdef HAVE_LINUX_KERNEL_PPPOE 1033 1091 case 'k': -
src/router/rp-pppoe-3.5/src/pppoe-server.h
r7294 r10469 12 12 * LIC: GPL 13 13 * 14 * $Id : pppoe-server.h,v 1.29 2006/02/23 15:40:42 dfs Exp$14 * $Id$ 15 15 * 16 16 ***********************************************************************/ -
src/router/rp-pppoe-3.5/src/pppoe-sniff.c
r7294 r10469 16 16 17 17 static char const RCSID[] = 18 "$Id : pppoe-sniff.c,v 1.8 2004/10/04 15:08:29 dfs Exp$";18 "$Id$"; 19 19 20 20 #include "pppoe.h" -
src/router/rp-pppoe-3.5/src/pppoe.c
r7294 r10469 15 15 16 16 static char const RCSID[] = 17 "$Id : pppoe.c,v 1.43 2006/02/23 15:40:42 dfs Exp$";17 "$Id$"; 18 18 19 19 #include "pppoe.h" … … 232 232 int maxFD = 0; 233 233 int r; 234 235 /* Open a session socket */236 conn->sessionSocket = openInterface(conn->ifName, Eth_PPPOE_Session, conn->myEth);237 234 238 235 /* Drop privileges */ … … 410 407 FILE *pidfile; 411 408 unsigned int discoveryType, sessionType; 409 char const *options; 412 410 413 411 PPPoEConnection conn; … … 435 433 openlog("pppoe", LOG_PID, LOG_DAEMON); 436 434 437 char const *options;438 435 #ifdef DEBUGGING_ENABLED 439 436 options = "I:VAT:D:hS:C:Usm:np:e:kdf:F:t:"; … … 618 615 printf( "Sending discovery flood %d\n", n+1); 619 616 } 617 conn.discoverySocket = 618 openInterface(conn.ifName, Eth_PPPOE_Discovery, conn.myEth); 620 619 discovery(&conn); 621 620 conn.discoveryState = STATE_SENT_PADI; … … 625 624 } 626 625 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 } 628 642 if (optSkipSession) { 629 643 printf("%u:%02x:%02x:%02x:%02x:%02x:%02x\n", -
src/router/rp-pppoe-3.5/src/pppoe.h
r1905 r10469 12 12 * LIC: GPL 13 13 * 14 * $Id : pppoe.h,v 1.31 2006/02/21 00:13:14 dfs Exp$14 * $Id$ 15 15 * 16 16 ***********************************************************************/ -
src/router/rp-pppoe-3.5/src/relay.c
r7294 r10469 14 14 * LIC: GPL 15 15 * 16 * $Id : relay.c,v 1.28 2006/02/23 15:40:42 dfs Exp$16 * $Id$ 17 17 * 18 18 ***********************************************************************/ 19 19 static char const RCSID[] = 20 "$Id : relay.c,v 1.28 2006/02/23 15:40:42 dfs Exp$";20 "$Id$"; 21 21 22 22 #define _GNU_SOURCE 1 /* For SA_RESTART */ -
src/router/rp-pppoe-3.5/src/relay.h
r7294 r10469 12 12 * LIC: GPL 13 13 * 14 * $Id : relay.h,v 1.13 2006/02/23 15:40:42 dfs Exp$14 * $Id$ 15 15 * 16 16 ***********************************************************************/
Note: See TracChangeset
for help on using the changeset viewer.
