Skip to content

Instantly share code, notes, and snippets.

@drdaeman
Created February 17, 2012 03:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save drdaeman/1850425 to your computer and use it in GitHub Desktop.
Save drdaeman/1850425 to your computer and use it in GitHub Desktop.
rp-pppoe service-name related patches
--- rp-pppoe-3.8/src/pppoe-server.c 2010-07-15 16:42:39.031057949 +0400
+++ rp-pppoe-3.8/src/pppoe-server.c 2010-07-15 16:48:14.078605821 +0400
@@ -97,6 +97,7 @@
#define MAX_SERVICE_NAMES 64
static int NumServiceNames = 0;
static char const *ServiceNames[MAX_SERVICE_NAMES];
+static int ReactionOnNoServiceName = 1;
PppoeSessionFunctionTable DefaultSessionFunctionTable = {
PppoeStopSession,
@@ -604,10 +605,10 @@
}
}
} else {
- ok = 1; /* Default service requested */
+ ok = ReactionOnNoServiceName; /* Default service requested */
}
} else {
- ok = 1; /* No Service-Name tag in PADI */
+ ok = ReactionOnNoServiceName; /* No Service-Name tag in PADI */
}
if (!ok) {
@@ -999,6 +1000,7 @@
fprintf(stderr, " -l -- Increment local IP address for each session.\n");
fprintf(stderr, " -R ip -- Set start address of remote IP pool.\n");
fprintf(stderr, " -S name -- Advertise specified service-name.\n");
+ fprintf(stderr, " -Q -- Do not reply to PADI without our explicit service-name.\n");
fprintf(stderr, " -O fname -- Use PPPD options from specified file\n");
fprintf(stderr, " (default %s).\n", PPPOE_SERVER_OPTIONS);
fprintf(stderr, " -p fname -- Optain IP address pool from specified file.\n");
@@ -1097,6 +1099,9 @@
}
NumServiceNames++;
break;
+ case 'Q':
+ ReactionOnNoServiceName = 0;
+ break;
case 'c':
#ifndef HAVE_LICENSE
fprintf(stderr, "Clustering capability not available.\n");
--- rp-pppoe-3.8/src/pppoe-server.c 2010-11-12 12:44:27.222006988 +0300
+++ rp-pppoe-3.8/src/pppoe-server.c 2010-11-12 12:46:46.560755947 +0300
@@ -98,6 +98,7 @@
static int NumServiceNames = 0;
static char const *ServiceNames[MAX_SERVICE_NAMES];
static int ReactionOnNoServiceName = 1;
+#define PPPOE_PADI_ONLY_REQUESTED_SERVICE_NAME
PppoeSessionFunctionTable DefaultSessionFunctionTable = {
PppoeStopSession,
@@ -646,15 +647,52 @@
cursor += TAG_HDR_SIZE;
plen += TAG_HDR_SIZE;
} else {
- for (i=0; i<NumServiceNames; i++) {
- int slen = strlen(ServiceNames[i]);
- servname.length = htons(slen);
- CHECK_ROOM(cursor, pado.payload, TAG_HDR_SIZE+slen);
- memcpy(cursor, &servname, TAG_HDR_SIZE);
- memcpy(cursor+TAG_HDR_SIZE, ServiceNames[i], slen);
- cursor += TAG_HDR_SIZE+slen;
- plen += TAG_HDR_SIZE+slen;
+ /* If there was a specific service-name requested, only put it
+ (D-Link routers fail otherwise) */
+ int rs_slen = 0;
+ if (requestedService.type) {
+ rs_slen = ntohs(requestedService.length);
+ if (rs_slen) {
+ servname.length = requestedService.length;
+ CHECK_ROOM(cursor, pado.payload, TAG_HDR_SIZE+rs_slen);
+ memcpy(cursor, &servname, TAG_HDR_SIZE);
+ memcpy(cursor+TAG_HDR_SIZE, &requestedService.payload, rs_slen);
+ cursor += TAG_HDR_SIZE+rs_slen;
+ plen += TAG_HDR_SIZE+rs_slen;
+ }
+ }
+ /* If PPPOE_PADI_ONLY_REQUESTED_SERVICE_NAME is not defined put the
+ rest of the service-names.
+ Or, unconditionally, supply all of them if nothing specific
+ was requested. */
+#ifdef PPPOE_PADI_ONLY_REQUESTED_SERVICE_NAME
+ if (!rs_slen) {
+#endif
+ for (i=0; i<NumServiceNames; i++) {
+ int slen = strlen(ServiceNames[i]);
+#ifndef PPPOE_PADI_ONLY_REQUESTED_SERVICE_NAME
+ int skip = 0;
+ if (rs_slen) {
+ if (slen == rs_slen &&
+ !memcmp(ServiceNames[i], &requestedService.payload, slen)) {
+ skip = 1;
+ }
+ }
+ if (!skip) {
+#endif
+ servname.length = htons(slen);
+ CHECK_ROOM(cursor, pado.payload, TAG_HDR_SIZE+slen);
+ memcpy(cursor, &servname, TAG_HDR_SIZE);
+ memcpy(cursor+TAG_HDR_SIZE, ServiceNames[i], slen);
+ cursor += TAG_HDR_SIZE+slen;
+ plen += TAG_HDR_SIZE+slen;
+#ifndef PPPOE_PADI_ONLY_REQUESTED_SERVICE_NAME
+ }
+#endif
+ }
+#ifdef PPPOE_PADI_ONLY_REQUESTED_SERVICE_NAME
}
+#endif
}
CHECK_ROOM(cursor, pado.payload, TAG_HDR_SIZE + COOKIE_LEN);
@mcr
Copy link

mcr commented Apr 15, 2014

Did you get any reply to this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment