]> git.pld-linux.org Git - packages/ppp.git/blame - ppp-rp-pppoe-update.patch
- updated for 2.4.2, please check me
[packages/ppp.git] / ppp-rp-pppoe-update.patch
CommitLineData
9c7e6b64
AM
1diff -urN ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/common.c ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/common.c
2--- ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/common.c Sun Sep 1 20:54:50 2002
3+++ ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/common.c Sun Sep 1 20:55:21 2002
e5080217
AM
4@@ -25,6 +30,7 @@
5 #include <string.h>
6 #include <errno.h>
7 #include <stdlib.h>
8+#include <stdarg.h>
9
10 #ifdef HAVE_UNISTD_H
11 #include <unistd.h>
e5080217
AM
12@@ -423,7 +446,7 @@
13 cursor += elen + TAG_HDR_SIZE;
14 plen += elen + TAG_HDR_SIZE;
15 }
16-
17+
18 /* Copy cookie and relay-ID if needed */
19 if (conn->cookie.type) {
20 CHECK_ROOM(cursor, packet.payload,
21@@ -451,6 +474,31 @@
22 syslog(LOG_INFO,"Sent PADT");
23 }
24
25+/***********************************************************************
26+*%FUNCTION: sendPADTf
27+*%ARGUMENTS:
28+* conn -- PPPoE connection
29+* msg -- printf-style format string
30+* args -- arguments for msg
31+*%RETURNS:
32+* Nothing
33+*%DESCRIPTION:
34+* Sends a PADT packet with a formatted message
35+***********************************************************************/
36+void
37+sendPADTf(PPPoEConnection *conn, char const *fmt, ...)
38+{
39+ char msg[512];
40+ va_list ap;
41+
42+ va_start(ap, fmt);
43+ vsnprintf(msg, sizeof(msg), fmt, ap);
44+ va_end(ap);
45+ msg[511] = 0;
46+
47+ sendPADT(conn, msg);
48+}
49+
50 /**********************************************************************
51 *%FUNCTION: parseLogErrs
52 *%ARGUMENTS:
53@@ -482,4 +530,3 @@
54 break;
55 }
56 }
57-
9c7e6b64
AM
58diff -urN ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/config.h ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/config.h
59--- ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/config.h Sun Sep 1 20:54:50 2002
60+++ ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/config.h Sun Sep 1 20:55:21 2002
e5080217
AM
61@@ -1,5 +1,6 @@
62-/* config.h. Generated automatically by configure. */
63+/* config.h. Generated by configure. */
64 /* config.h.in. Generated automatically from configure.in by autoheader. */
65+/* LIC: GPL */
66
67 /* Define to empty if the keyword does not work. */
68 /* #undef const */
69@@ -133,3 +134,8 @@
70
71 /* Define if bitfields are packed in reverse order */
72 #define PACK_BITFIELDS_REVERSED 1
73+
74+/* Solaris moans if we don't do this... */
75+#ifdef __sun
76+#define __EXTENSIONS__ 1
77+#endif
9c7e6b64
AM
78diff -urN ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/debug.c ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/debug.c
79--- ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/debug.c Sun Sep 1 20:54:50 2002
80+++ ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/debug.c Sun Sep 1 20:55:21 2002
e5080217
AM
81@@ -11,10 +11,12 @@
82 * This program may be distributed according to the terms of the GNU
83 * General Public License, version 2 or (at your option) any later version.
84 *
85+* LIC: GPL
86+*
87 ***********************************************************************/
88
89 static char const RCSID[] =
90-"$Id$";
91+"$Id$";
92
93 #include "pppoe.h"
94 #include <sys/time.h>
95@@ -116,6 +118,8 @@
96 case CODE_PADR: fprintf(fp, "PADR "); break;
97 case CODE_PADS: fprintf(fp, "PADS "); break;
98 case CODE_PADT: fprintf(fp, "PADT "); break;
99+ case CODE_PADM: fprintf(fp, "PADM "); break;
100+ case CODE_PADN: fprintf(fp, "PADN "); break;
101 case CODE_SESS: fprintf(fp, "SESS "); break;
102 }
103
9c7e6b64
AM
104diff -urN ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/discovery.c ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/discovery.c
105--- ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/discovery.c Sun Sep 1 20:54:50 2002
106+++ ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/discovery.c Sun Sep 1 20:55:21 2002
e5080217
AM
107@@ -322,12 +324,12 @@
108 pc.serviceNameOK = (conn->serviceName) ? 0 : 1;
109 pc.seenACName = 0;
110 pc.seenServiceName = 0;
111-
112+
113 do {
114 if (BPF_BUFFER_IS_EMPTY) {
115 tv.tv_sec = timeout;
116 tv.tv_usec = 0;
117-
118+
119 FD_ZERO(&readable);
120 FD_SET(conn->discoverySocket, &readable);
121
122@@ -340,7 +342,7 @@
123 }
124 if (r == 0) return; /* Timed out */
125 }
126-
127+
128 /* Get the packet */
129 receivePacket(conn->discoverySocket, &packet, &len);
130
131@@ -379,19 +381,17 @@
132 continue;
133 }
134 conn->numPADOs++;
135- if (conn->printACNames) {
136- printf("--------------------------------------------------\n");
137- }
138 if (pc.acNameOK && pc.serviceNameOK) {
139 memcpy(conn->peerEth, packet.ethHdr.h_source, ETH_ALEN);
140 if (conn->printACNames) {
141 printf("AC-Ethernet-Address: %02x:%02x:%02x:%02x:%02x:%02x\n",
142- (unsigned) conn->peerEth[0],
143+ (unsigned) conn->peerEth[0],
144 (unsigned) conn->peerEth[1],
145 (unsigned) conn->peerEth[2],
146 (unsigned) conn->peerEth[3],
147 (unsigned) conn->peerEth[4],
148 (unsigned) conn->peerEth[5]);
149+ printf("--------------------------------------------------\n");
150 continue;
151 }
152 conn->discoveryState = STATE_RECEIVED_PADO;
153@@ -504,10 +504,10 @@
154 if (BPF_BUFFER_IS_EMPTY) {
155 tv.tv_sec = timeout;
156 tv.tv_usec = 0;
157-
158+
159 FD_ZERO(&readable);
160 FD_SET(conn->discoverySocket, &readable);
161-
162+
163 while(1) {
164 r = select(conn->discoverySocket+1, &readable, NULL, NULL, &tv);
165 if (r >= 0 || errno != EINTR) break;
166@@ -621,7 +621,6 @@
167
168 /* If we're only printing access concentrator names, we're done */
169 if (conn->printACNames) {
170- printf("--------------------------------------------------\n");
171 exit(0);
172 }
173
174@@ -641,4 +640,3 @@
175 conn->discoveryState = STATE_SESSION;
176 return;
177 }
178-
9c7e6b64
AM
179diff -urN ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/if.c ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/if.c
180--- ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/if.c Sun Sep 1 20:54:50 2002
181+++ ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/if.c Sun Sep 1 20:55:21 2002
e5080217
AM
182@@ -11,10 +11,12 @@
183 * This program may be distributed according to the terms of the GNU
184 * General Public License, version 2 or (at your option) any later version.
185 *
186+* LIC: GPL
187+*
188 ***********************************************************************/
189
190 static char const RCSID[] =
191-"$Id$";
192+"$Id$";
193
194 #include "pppoe.h"
195
196@@ -87,7 +89,7 @@
197
198 static int dl_abssaplen;
199 static int dl_saplen;
200-static int dl_addrlen;
201+static int dl_addrlen;
202
203 #endif
204
205@@ -169,7 +171,7 @@
206 if (ifr->ifr_addr.sa_family == AF_LINK) {
207 sdl = (const struct sockaddr_dl *) &ifr->ifr_addr;
208 if ((sdl->sdl_type == IFT_ETHER) &&
209- (sdl->sdl_alen == ETH_ALEN) &&
210+ (sdl->sdl_alen == ETH_ALEN) &&
211 !strncmp(ifname, ifr->ifr_name, sizeof(ifr->ifr_name))) {
212 if (found) {
213 char buffer[256];
214@@ -177,14 +179,14 @@
215 rp_fatal(buffer);
216 } else {
217 found = 1;
218- memcpy(hwaddr, LLADDR(sdl), ETH_ALEN);
219+ memcpy(hwaddr, LLADDR(sdl), ETH_ALEN);
220 }
221 }
222 }
223 }
224 if (!found) {
225 char buffer[256];
226- sprintf(buffer, "interface %.16s has no ethernet address", ifname);
227+ sprintf(buffer, "interface %.16s has no ethernet address", ifname);
228 rp_fatal(buffer);
229 }
230 }
231@@ -207,23 +209,23 @@
232 * Note that the ethernet type names come from "pppoe.h" and are
233 * used here to maintain consistency with the rest of this file. */
234 static struct bpf_insn bpfRun[] = { /* run PPPoE */
235- BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12), /* ethernet type */
236- BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ETH_PPPOE_SESSION, 5, 0),
237- BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ETH_PPPOE_DISCOVERY, 0, 9),
238- BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0), /* first word of dest. addr */
239+ BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12), /* ethernet type */
240+ BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ETH_PPPOE_SESSION, 5, 0),
241+ BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ETH_PPPOE_DISCOVERY, 0, 9),
242+ BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0), /* first word of dest. addr */
243 #define PPPOE_BCAST_CMPW 4 /* offset of word compare */
244- BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 2),
245- BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 4), /* next 1/2 word of dest. */
246+ BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 2),
247+ BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 4), /* next 1/2 word of dest. */
248 #define PPPOE_BCAST_CMPH 6 /* offset of 1/2 word compare */
249- BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 4, 0),
250- BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0), /* first word of dest. addr */
251+ BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 4, 0),
252+ BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0), /* first word of dest. addr */
253 #define PPPOE_FILTER_CMPW 8 /* offset of word compare */
254- BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 3),
255- BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 4), /* next 1/2 word of dest. */
256+ BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 3),
257+ BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 4), /* next 1/2 word of dest. */
258 #define PPPOE_FILTER_CMPH 10 /* offset of 1/rd compare */
259- BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 1),
260- BPF_STMT(BPF_RET+BPF_K, (u_int) -1), /* keep packet */
261- BPF_STMT(BPF_RET+BPF_K, 0), /* drop packet */
262+ BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 1),
263+ BPF_STMT(BPF_RET+BPF_K, (u_int) -1), /* keep packet */
264+ BPF_STMT(BPF_RET+BPF_K, 0), /* drop packet */
265 };
266
267 /* Fix the potentially varying parts */
268@@ -242,14 +244,14 @@
269 struct bpf_program bpfProgram;
270 memcpy(bpfInsn, bpfRun, sizeof(bpfRun));
271 bpfInsn[PPPOE_BCAST_CMPW].k = ((0xff << 24) | (0xff << 16) |
272- (0xff << 8) | 0xff);
273+ (0xff << 8) | 0xff);
274 bpfInsn[PPPOE_BCAST_CMPH].k = ((0xff << 8) | 0xff);
275 bpfInsn[PPPOE_FILTER_CMPW].k = ((hwaddr[0] << 24) | (hwaddr[1] << 16) |
276 (hwaddr[2] << 8) | hwaddr[3]);
277 bpfInsn[PPPOE_FILTER_CMPH].k = ((hwaddr[4] << 8) | hwaddr[5]);
278 bpfProgram.bf_len = (sizeof(bpfInsn) / sizeof(bpfInsn[0]));
279 bpfProgram.bf_insns = &bpfInsn[0];
280-
281+
282 /* Apply the filter */
283 if (ioctl(fd, BIOCSETF, &bpfProgram) < 0) {
284 fatalSys("ioctl(BIOCSETF)");
285@@ -362,9 +364,9 @@
286 fatalSys("ioctl(BIOCVERSION)");
287 }
288 if ((bpf_ver.bv_major != BPF_MAJOR_VERSION) ||
289- (bpf_ver.bv_minor < BPF_MINOR_VERSION)) {
290+ (bpf_ver.bv_minor < BPF_MINOR_VERSION)) {
291 char buffer[256];
292- sprintf(buffer, "Unsupported BPF version: %d.%d (kernel: %d.%d)",
293+ sprintf(buffer, "Unsupported BPF version: %d.%d (kernel: %d.%d)",
294 BPF_MAJOR_VERSION, BPF_MINOR_VERSION,
295 bpf_ver.bv_major, bpf_ver.bv_minor);
296 rp_fatal(buffer);
297@@ -394,7 +396,7 @@
298 }
299
300 syslog(LOG_INFO, "Interface=%.16s HWaddr=%02X:%02X:%02X:%02X:%02X:%02X Device=%.32s Buffer size=%d",
301- ifname,
302+ ifname,
303 hwaddr[0], hwaddr[1], hwaddr[2],
304 hwaddr[3], hwaddr[4], hwaddr[5],
305 bpfName, bpfLength);
306@@ -548,12 +550,12 @@
307
308 short tmp_sap;
309
310- tmp_sap = htons(pkt->ethHdr.h_proto);
311- data_size = size - sizeof(struct ethhdr);
312+ tmp_sap = htons(pkt->ethHdr.h_proto);
313+ data_size = size - sizeof(struct ethhdr);
314
315 memcpy((char *)phys, (char *)pkt->ethHdr.h_dest, ETHERADDRL);
316 memcpy((char *)sap, (char *)&tmp_sap, sizeof(ushort_t));
317- memcpy((char *)xmitbuf, (char *)pkt + sizeof(struct ethhdr), data_size);
318+ memcpy((char *)xmitbuf, (char *)pkt + sizeof(struct ethhdr), data_size);
319
320 if (dl_saplen > 0) { /* order is sap+phys */
321 (void) memcpy((char*)addr, (char*)&sap, dl_abssaplen);
322@@ -564,7 +566,7 @@
323 }
324
325 #ifdef DL_DEBUG
326- printf("%02x:%02x:%02x:%02x:%02x:%02x %02x:%02x\n",
327+ printf("%02x:%02x:%02x:%02x:%02x:%02x %02x:%02x\n",
328 addr[0],addr[1],addr[2],addr[3],addr[4],addr[5],
329 addr[6],addr[7]);
330 #endif
331@@ -667,20 +669,20 @@
332 }
333 #else
334 #ifdef USE_DLPI
335- struct strbuf data;
336- int flags = 0;
337- int retval;
338-
339- data.buf = (char *) pkt;
340- data.maxlen = MAXDLBUF;
341- data.len = 0;
342-
343+ struct strbuf data;
344+ int flags = 0;
345+ int retval;
346+
347+ data.buf = (char *) pkt;
348+ data.maxlen = MAXDLBUF;
349+ data.len = 0;
350+
351 if ((retval = getmsg(sock, NULL, &data, &flags)) < 0) {
352 sysErr("read (receivePacket)");
353 return -1;
354 }
355
356- *size = data.len;
357+ *size = data.len;
358
359 #else
360 if ((*size = recv(sock, pkt, sizeof(PPPoEPacket), 0)) < 0) {
361@@ -708,34 +710,50 @@
362 openInterface(char const *ifname, UINT16_t type, unsigned char *hwaddr)
363 {
364 int fd;
365- long buf[MAXDLBUF];
366+ long buf[MAXDLBUF];
367
368 union DL_primitives *dlp;
369
370- char base_dev[PATH_MAX];
371- int ppa;
372+ char base_dev[PATH_MAX];
373+ int ppa;
374
375 if(strlen(ifname) > PATH_MAX) {
376- rp_fatal("socket: string to long");
377+ rp_fatal("socket: Interface name too long");
378+ }
379+
380+ if (strlen(ifname) < 2) {
381+ rp_fatal("socket: Interface name too short");
382 }
383
384 ppa = atoi(&ifname[strlen(ifname)-1]);
385- strncpy(base_dev, ifname, PATH_MAX);
386- base_dev[strlen(base_dev)-1] = '\0';
387+ strncpy(base_dev, ifname, PATH_MAX);
388+ base_dev[strlen(base_dev)-1] = '\0';
389
390 /* rearranged order of DLPI code - delphys 20010803 */
391 dlp = (union DL_primitives*) buf;
392
393- if (( fd = open(base_dev, O_RDWR)) < 0) {
394+ if ( (fd = open(base_dev, O_RDWR)) < 0) {
395 /* Give a more helpful message for the common error case */
396 if (errno == EPERM) {
397 rp_fatal("Cannot create raw socket -- pppoe must be run as root.");
398 }
399+ /* Common error is to omit /dev/ */
400+ if (errno == ENOENT) {
401+ char ifname[512];
402+ snprintf(ifname, sizeof(ifname), "/dev/%s", base_dev);
403+ if ((fd = open(ifname, O_RDWR)) < 0) {
404+ if (errno == EPERM) {
405+ rp_fatal("Cannot create raw socket -- pppoe must be run as root.");
406+ }
407+ }
408+ }
409+ }
410+ if (fd < 0) {
411 fatalSys("socket");
412 }
413
414 /* rearranged order of DLPI code - delphys 20010803 */
415- dlattachreq(fd, ppa);
416+ dlattachreq(fd, ppa);
417 dlokack(fd, (char *)buf);
418
419 dlbindreq(fd, type, 0, DL_CLDLS, 0, 0);
420@@ -753,8 +771,8 @@
421 /* ethernet address retrieved as part of DL_INFO_ACK - delphys 20010803 */
422 memcpy(hwaddr, (u_char*)((char*)(dlp) + (int)(dlp->info_ack.dl_addr_offset)), ETHERADDRL);
423
424- if ( strioctl(fd, DLIOCRAW, -1, 0, NULL) < 0 ) {
425- fatalSys("DLIOCRAW");
426+ if ( strioctl(fd, DLIOCRAW, -1, 0, NULL) < 0 ) {
427+ fatalSys("DLIOCRAW");
428 }
429
430 if (ioctl(fd, I_FLUSH, FLUSHR) < 0) fatalSys("I_FLUSH");
431@@ -766,332 +784,332 @@
432
433 void dlpromisconreq(int fd, u_long level)
434 {
435- dl_promiscon_req_t promiscon_req;
436- struct strbuf ctl;
437- int flags;
438+ dl_promiscon_req_t promiscon_req;
439+ struct strbuf ctl;
440+ int flags;
441
442- promiscon_req.dl_primitive = DL_PROMISCON_REQ;
443- promiscon_req.dl_level = level;
444+ promiscon_req.dl_primitive = DL_PROMISCON_REQ;
445+ promiscon_req.dl_level = level;
446
447- ctl.maxlen = 0;
448- ctl.len = sizeof (promiscon_req);
449- ctl.buf = (char *) &promiscon_req;
450+ ctl.maxlen = 0;
451+ ctl.len = sizeof (promiscon_req);
452+ ctl.buf = (char *) &promiscon_req;
453
454- flags = 0;
455+ flags = 0;
456
457- if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
458- fatalSys("dlpromiscon: putmsg");
459+ if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
460+ fatalSys("dlpromiscon: putmsg");
461
462 }
463
464 void dlinforeq(int fd)
465 {
466- dl_info_req_t info_req;
467- struct strbuf ctl;
468- int flags;
469+ dl_info_req_t info_req;
470+ struct strbuf ctl;
471+ int flags;
472
473- info_req.dl_primitive = DL_INFO_REQ;
474+ info_req.dl_primitive = DL_INFO_REQ;
475
476- ctl.maxlen = 0;
477- ctl.len = sizeof (info_req);
478- ctl.buf = (char *) &info_req;
479+ ctl.maxlen = 0;
480+ ctl.len = sizeof (info_req);
481+ ctl.buf = (char *) &info_req;
482
483- flags = RS_HIPRI;
484+ flags = RS_HIPRI;
485
486- if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
487- fatalSys("dlinforeq: putmsg");
488+ if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
489+ fatalSys("dlinforeq: putmsg");
490 }
491
492 void dlunitdatareq(int fd, u_char *addrp, int addrlen, u_long minpri, u_long maxpri, u_char *datap, int datalen)
493 {
494- long buf[MAXDLBUF];
495- union DL_primitives *dlp;
496- struct strbuf data, ctl;
497-
498- dlp = (union DL_primitives*) buf;
499-
500- dlp->unitdata_req.dl_primitive = DL_UNITDATA_REQ;
501- dlp->unitdata_req.dl_dest_addr_length = addrlen;
502- dlp->unitdata_req.dl_dest_addr_offset = sizeof (dl_unitdata_req_t);
503- dlp->unitdata_req.dl_priority.dl_min = minpri;
504- dlp->unitdata_req.dl_priority.dl_max = maxpri;
505-
506- (void) memcpy(OFFADDR(dlp, sizeof (dl_unitdata_req_t)), addrp, addrlen);
507-
508- ctl.maxlen = 0;
509- ctl.len = sizeof (dl_unitdata_req_t) + addrlen;
510- ctl.buf = (char *) buf;
511-
512- data.maxlen = 0;
513- data.len = datalen;
514- data.buf = (char *) datap;
515+ long buf[MAXDLBUF];
516+ union DL_primitives *dlp;
517+ struct strbuf data, ctl;
518+
519+ dlp = (union DL_primitives*) buf;
520+
521+ dlp->unitdata_req.dl_primitive = DL_UNITDATA_REQ;
522+ dlp->unitdata_req.dl_dest_addr_length = addrlen;
523+ dlp->unitdata_req.dl_dest_addr_offset = sizeof (dl_unitdata_req_t);
524+ dlp->unitdata_req.dl_priority.dl_min = minpri;
525+ dlp->unitdata_req.dl_priority.dl_max = maxpri;
526+
527+ (void) memcpy(OFFADDR(dlp, sizeof (dl_unitdata_req_t)), addrp, addrlen);
528
529- if (putmsg(fd, &ctl, &data, 0) < 0)
530- fatalSys("dlunitdatareq: putmsg");
531+ ctl.maxlen = 0;
532+ ctl.len = sizeof (dl_unitdata_req_t) + addrlen;
533+ ctl.buf = (char *) buf;
534+
535+ data.maxlen = 0;
536+ data.len = datalen;
537+ data.buf = (char *) datap;
538+
539+ if (putmsg(fd, &ctl, &data, 0) < 0)
540+ fatalSys("dlunitdatareq: putmsg");
541 }
542
543 void dlinfoack(int fd, char *bufp)
544 {
545- union DL_primitives *dlp;
546- struct strbuf ctl;
547- int flags;
548+ union DL_primitives *dlp;
549+ struct strbuf ctl;
550+ int flags;
551
552- ctl.maxlen = MAXDLBUF;
553- ctl.len = 0;
554- ctl.buf = bufp;
555+ ctl.maxlen = MAXDLBUF;
556+ ctl.len = 0;
557+ ctl.buf = bufp;
558
559- strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlinfoack");
560+ strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlinfoack");
561
562- dlp = (union DL_primitives *) ctl.buf;
563+ dlp = (union DL_primitives *) ctl.buf;
564
565- expecting(DL_INFO_ACK, dlp);
566+ expecting(DL_INFO_ACK, dlp);
567
568- if (ctl.len < sizeof (dl_info_ack_t)) {
569+ if (ctl.len < sizeof (dl_info_ack_t)) {
570 char buffer[256];
571- sprintf(buffer, "dlinfoack: response ctl.len too short: %d", ctl.len);
572- rp_fatal(buffer);
573+ sprintf(buffer, "dlinfoack: response ctl.len too short: %d", ctl.len);
574+ rp_fatal(buffer);
575 }
576
577- if (flags != RS_HIPRI)
578- rp_fatal("dlinfoack: DL_INFO_ACK was not M_PCPROTO");
579+ if (flags != RS_HIPRI)
580+ rp_fatal("dlinfoack: DL_INFO_ACK was not M_PCPROTO");
581
582- if (ctl.len < sizeof (dl_info_ack_t)) {
583+ if (ctl.len < sizeof (dl_info_ack_t)) {
584 char buffer[256];
585- sprintf(buffer, "dlinfoack: short response ctl.len: %d", ctl.len);
586- rp_fatal(buffer);
587+ sprintf(buffer, "dlinfoack: short response ctl.len: %d", ctl.len);
588+ rp_fatal(buffer);
589 }
590 }
591
592 void dlbindreq(int fd, u_long sap, u_long max_conind, u_long service_mode, u_long conn_mgmt, u_long xidtest)
593 {
594- dl_bind_req_t bind_req;
595- struct strbuf ctl;
596- int flags;
597-
598- bind_req.dl_primitive = DL_BIND_REQ;
599- bind_req.dl_sap = sap;
600- bind_req.dl_max_conind = max_conind;
601- bind_req.dl_service_mode = service_mode;
602- bind_req.dl_conn_mgmt = conn_mgmt;
603- bind_req.dl_xidtest_flg = xidtest;
604-
605- ctl.maxlen = 0;
606- ctl.len = sizeof (bind_req);
607- ctl.buf = (char *) &bind_req;
608+ dl_bind_req_t bind_req;
609+ struct strbuf ctl;
610+ int flags;
611+
612+ bind_req.dl_primitive = DL_BIND_REQ;
613+ bind_req.dl_sap = sap;
614+ bind_req.dl_max_conind = max_conind;
615+ bind_req.dl_service_mode = service_mode;
616+ bind_req.dl_conn_mgmt = conn_mgmt;
617+ bind_req.dl_xidtest_flg = xidtest;
618+
619+ ctl.maxlen = 0;
620+ ctl.len = sizeof (bind_req);
621+ ctl.buf = (char *) &bind_req;
622
623- flags = 0;
624+ flags = 0;
625
626- if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
627- fatalSys("dlbindreq: putmsg");
628+ if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
629+ fatalSys("dlbindreq: putmsg");
630 }
631
632 void dlattachreq(int fd, u_long ppa)
633 {
634- dl_attach_req_t attach_req;
635- struct strbuf ctl;
636- int flags;
637+ dl_attach_req_t attach_req;
638+ struct strbuf ctl;
639+ int flags;
640
641- attach_req.dl_primitive = DL_ATTACH_REQ;
642- attach_req.dl_ppa = ppa;
643+ attach_req.dl_primitive = DL_ATTACH_REQ;
644+ attach_req.dl_ppa = ppa;
645
646- ctl.maxlen = 0;
647- ctl.len = sizeof (attach_req);
648- ctl.buf = (char *) &attach_req;
649+ ctl.maxlen = 0;
650+ ctl.len = sizeof (attach_req);
651+ ctl.buf = (char *) &attach_req;
652
653- flags = 0;
654+ flags = 0;
655
656- if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
657- fatalSys("dlattachreq: putmsg");
658+ if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
659+ fatalSys("dlattachreq: putmsg");
660 }
661
662 void dlokack(int fd, char *bufp)
663 {
664- union DL_primitives *dlp;
665- struct strbuf ctl;
666- int flags;
667+ union DL_primitives *dlp;
668+ struct strbuf ctl;
669+ int flags;
670
671- ctl.maxlen = MAXDLBUF;
672- ctl.len = 0;
673- ctl.buf = bufp;
674+ ctl.maxlen = MAXDLBUF;
675+ ctl.len = 0;
676+ ctl.buf = bufp;
677
678- strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlokack");
679+ strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlokack");
680
681- dlp = (union DL_primitives *) ctl.buf;
682+ dlp = (union DL_primitives *) ctl.buf;
683
684- expecting(DL_OK_ACK, dlp);
685+ expecting(DL_OK_ACK, dlp);
686
687- if (ctl.len < sizeof (dl_ok_ack_t)) {
688+ if (ctl.len < sizeof (dl_ok_ack_t)) {
689 char buffer[256];
690 sprintf(buffer, "dlokack: response ctl.len too short: %d", ctl.len);
691- rp_fatal(buffer);
692+ rp_fatal(buffer);
693 }
694
695- if (flags != RS_HIPRI)
696- rp_fatal("dlokack: DL_OK_ACK was not M_PCPROTO");
697+ if (flags != RS_HIPRI)
698+ rp_fatal("dlokack: DL_OK_ACK was not M_PCPROTO");
699
700- if (ctl.len < sizeof (dl_ok_ack_t)) {
701- char buffer[256];
702+ if (ctl.len < sizeof (dl_ok_ack_t)) {
703+ char buffer[256];
704 sprintf(buffer, "dlokack: short response ctl.len: %d", ctl.len);
705- rp_fatal(buffer);
706+ rp_fatal(buffer);
707 }
708 }
709
710 void dlbindack(int fd, char *bufp)
711 {
712- union DL_primitives *dlp;
713- struct strbuf ctl;
714- int flags;
715+ union DL_primitives *dlp;
716+ struct strbuf ctl;
717+ int flags;
718
719- ctl.maxlen = MAXDLBUF;
720- ctl.len = 0;
721- ctl.buf = bufp;
722+ ctl.maxlen = MAXDLBUF;
723+ ctl.len = 0;
724+ ctl.buf = bufp;
725
726- strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlbindack");
727+ strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlbindack");
728
729- dlp = (union DL_primitives *) ctl.buf;
730+ dlp = (union DL_primitives *) ctl.buf;
731
732- expecting(DL_BIND_ACK, dlp);
733+ expecting(DL_BIND_ACK, dlp);
734
735- if (flags != RS_HIPRI)
736- rp_fatal("dlbindack: DL_OK_ACK was not M_PCPROTO");
737+ if (flags != RS_HIPRI)
738+ rp_fatal("dlbindack: DL_OK_ACK was not M_PCPROTO");
739
740- if (ctl.len < sizeof (dl_bind_ack_t)) {
741+ if (ctl.len < sizeof (dl_bind_ack_t)) {
742 char buffer[256];
743 sprintf(buffer, "dlbindack: short response ctl.len: %d", ctl.len);
744- rp_fatal(buffer);
745+ rp_fatal(buffer);
746 }
747 }
748
749 int strioctl(int fd, int cmd, int timout, int len, char *dp)
750 {
751- struct strioctl sioc;
752- int rc;
753+ struct strioctl sioc;
754+ int rc;
755
756- sioc.ic_cmd = cmd;
757- sioc.ic_timout = timout;
758- sioc.ic_len = len;
759- sioc.ic_dp = dp;
760- rc = ioctl(fd, I_STR, &sioc);
761-
762- if (rc < 0)
763- return (rc);
764- else
765- return (sioc.ic_len);
766+ sioc.ic_cmd = cmd;
767+ sioc.ic_timout = timout;
768+ sioc.ic_len = len;
769+ sioc.ic_dp = dp;
770+ rc = ioctl(fd, I_STR, &sioc);
771+
772+ if (rc < 0)
773+ return (rc);
774+ else
775+ return (sioc.ic_len);
776 }
777
778 void strgetmsg(int fd, struct strbuf *ctlp, struct strbuf *datap, int *flagsp, char *caller)
779 {
780- int rc;
781- static char errmsg[80];
782+ int rc;
783+ static char errmsg[80];
784
785- /*
786- * Start timer.
787- */
788- (void) signal(SIGALRM, sigalrm);
789- if (alarm(MAXWAIT) < 0) {
790- (void) sprintf(errmsg, "%s: alarm", caller);
791- fatalSys(errmsg);
792- }
793-
794- /*
795- * Set flags argument and issue getmsg().
796- */
797- *flagsp = 0;
798- if ((rc = getmsg(fd, ctlp, datap, flagsp)) < 0) {
799- (void) sprintf(errmsg, "%s: getmsg", caller);
800- fatalSys(errmsg);
801- }
802-
803- /*
804- * Stop timer.
805- */
806- if (alarm(0) < 0) {
807- (void) sprintf(errmsg, "%s: alarm", caller);
808- fatalSys(errmsg);
809- }
810-
811- /*
812- * Check for MOREDATA and/or MORECTL.
813- */
814- if ((rc & (MORECTL | MOREDATA)) == (MORECTL | MOREDATA)) {
815- char buffer[256];
816+ /*
817+ * Start timer.
818+ */
819+ (void) signal(SIGALRM, sigalrm);
820+ if (alarm(MAXWAIT) < 0) {
821+ (void) sprintf(errmsg, "%s: alarm", caller);
822+ fatalSys(errmsg);
823+ }
824+
825+ /*
826+ * Set flags argument and issue getmsg().
827+ */
828+ *flagsp = 0;
829+ if ((rc = getmsg(fd, ctlp, datap, flagsp)) < 0) {
830+ (void) sprintf(errmsg, "%s: getmsg", caller);
831+ fatalSys(errmsg);
832+ }
833+
834+ /*
835+ * Stop timer.
836+ */
837+ if (alarm(0) < 0) {
838+ (void) sprintf(errmsg, "%s: alarm", caller);
839+ fatalSys(errmsg);
840+ }
841+
842+ /*
843+ * Check for MOREDATA and/or MORECTL.
844+ */
845+ if ((rc & (MORECTL | MOREDATA)) == (MORECTL | MOREDATA)) {
846+ char buffer[256];
847 sprintf(buffer, "%s: MORECTL|MOREDATA", caller);
848 rp_fatal(buffer);
849 }
850-
851- if (rc & MORECTL) {
852+
853+ if (rc & MORECTL) {
854 char buffer[256];
855 sprintf(buffer, "%s: MORECTL", caller);
856- rp_fatal(buffer);
857+ rp_fatal(buffer);
858 }
859-
860- if (rc & MOREDATA) {
861- char buffer[256];
862+
863+ if (rc & MOREDATA) {
864+ char buffer[256];
865 sprintf(buffer, "%s: MOREDATA", caller);
866 rp_fatal(buffer);
867 }
868
869- /*
870- * Check for at least sizeof (long) control data portion.
871- */
872- if (ctlp->len < sizeof (long)) {
873- char buffer[256];
874+ /*
875+ * Check for at least sizeof (long) control data portion.
876+ */
877+ if (ctlp->len < sizeof (long)) {
878+ char buffer[256];
879 sprintf(buffer, "getmsg: control portion length < sizeof (long): %d", ctlp->len);
880- rp_fatal(buffer);
881+ rp_fatal(buffer);
882 }
883 }
884
885 void sigalrm(int sig)
886 {
887- (void) rp_fatal("sigalrm: TIMEOUT");
888+ (void) rp_fatal("sigalrm: TIMEOUT");
889 }
890
891 void expecting(int prim, union DL_primitives *dlp)
892 {
893- if (dlp->dl_primitive != (u_long)prim) {
894- char buffer[256];
895+ if (dlp->dl_primitive != (u_long)prim) {
896+ char buffer[256];
897 sprintf(buffer, "expected %s got %s", dlprim(prim), dlprim(dlp->dl_primitive));
898- rp_fatal(buffer);
899- exit(1);
900+ rp_fatal(buffer);
901+ exit(1);
902 }
903 }
904
905 char *dlprim(u_long prim)
906 {
907- static char primbuf[80];
908+ static char primbuf[80];
909
910- switch ((int)prim) {
911- CASERET(DL_INFO_REQ);
912- CASERET(DL_INFO_ACK);
913- CASERET(DL_ATTACH_REQ);
914- CASERET(DL_DETACH_REQ);
915- CASERET(DL_BIND_REQ);
916- CASERET(DL_BIND_ACK);
917- CASERET(DL_UNBIND_REQ);
918- CASERET(DL_OK_ACK);
919- CASERET(DL_ERROR_ACK);
920- CASERET(DL_SUBS_BIND_REQ);
921- CASERET(DL_SUBS_BIND_ACK);
922- CASERET(DL_UNITDATA_REQ);
923- CASERET(DL_UNITDATA_IND);
924- CASERET(DL_UDERROR_IND);
925- CASERET(DL_UDQOS_REQ);
926- CASERET(DL_CONNECT_REQ);
927- CASERET(DL_CONNECT_IND);
928- CASERET(DL_CONNECT_RES);
929- CASERET(DL_CONNECT_CON);
930- CASERET(DL_TOKEN_REQ);
931- CASERET(DL_TOKEN_ACK);
932- CASERET(DL_DISCONNECT_REQ);
933- CASERET(DL_DISCONNECT_IND);
934- CASERET(DL_RESET_REQ);
935- CASERET(DL_RESET_IND);
936- CASERET(DL_RESET_RES);
937- CASERET(DL_RESET_CON);
938- default:
939- (void) sprintf(primbuf, "unknown primitive 0x%lx", prim);
940- return (primbuf);
941- }
942+ switch ((int)prim) {
943+ CASERET(DL_INFO_REQ);
944+ CASERET(DL_INFO_ACK);
945+ CASERET(DL_ATTACH_REQ);
946+ CASERET(DL_DETACH_REQ);
947+ CASERET(DL_BIND_REQ);
948+ CASERET(DL_BIND_ACK);
949+ CASERET(DL_UNBIND_REQ);
950+ CASERET(DL_OK_ACK);
951+ CASERET(DL_ERROR_ACK);
952+ CASERET(DL_SUBS_BIND_REQ);
953+ CASERET(DL_SUBS_BIND_ACK);
954+ CASERET(DL_UNITDATA_REQ);
955+ CASERET(DL_UNITDATA_IND);
956+ CASERET(DL_UDERROR_IND);
957+ CASERET(DL_UDQOS_REQ);
958+ CASERET(DL_CONNECT_REQ);
959+ CASERET(DL_CONNECT_IND);
960+ CASERET(DL_CONNECT_RES);
961+ CASERET(DL_CONNECT_CON);
962+ CASERET(DL_TOKEN_REQ);
963+ CASERET(DL_TOKEN_ACK);
964+ CASERET(DL_DISCONNECT_REQ);
965+ CASERET(DL_DISCONNECT_IND);
966+ CASERET(DL_RESET_REQ);
967+ CASERET(DL_RESET_IND);
968+ CASERET(DL_RESET_RES);
969+ CASERET(DL_RESET_CON);
970+ default:
971+ (void) sprintf(primbuf, "unknown primitive 0x%lx", prim);
972+ return (primbuf);
973+ }
974 }
975
976 #endif /* USE_DLPI */
9c7e6b64
AM
977diff -urN ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/plugin.c ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/plugin.c
978--- ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/plugin.c Sun Sep 1 20:54:50 2002
979+++ ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/plugin.c Sun Sep 1 20:55:21 2002
e5080217
AM
980@@ -48,9 +51,9 @@
981 #include <signal.h>
982 #include <net/ethernet.h>
983 #include <net/if_arp.h>
984-#include "ppp_defs.h"
985-#include "if_ppp.h"
986-#include "if_pppox.h"
987+#include <linux/ppp_defs.h>
988+#include <linux/if_ppp.h>
989+#include <linux/if_pppox.h>
990
991 #define _PATH_ETHOPT _ROOT_PATH "/etc/ppp/options."
992
e5080217
AM
993@@ -399,12 +398,11 @@
994 void
995 rp_fatal(char const *str)
996 {
997- char buf[1024];
998 printErr(str);
999- sprintf(buf, "RP-PPPoE: %.256s", str);
1000- sendPADT(conn, buf);
1001+ sendPADTf(conn, "RP-PPPoE: %.256s", str);
1002 exit(1);
1003 }
1004+
1005 /**********************************************************************
1006 *%FUNCTION: sysErr
1007 *%ARGUMENTS:
9c7e6b64
AM
1008diff -urN ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/pppoe.h ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/pppoe.h
1009--- ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/pppoe.h Sun Sep 1 20:54:50 2002
1010+++ ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/pppoe.h Sun Sep 1 20:55:21 2002
e5080217
AM
1011@@ -9,14 +9,12 @@
1012 * This program may be distributed according to the terms of the GNU
1013 * General Public License, version 2 or (at your option) any later version.
1014 *
1015-* $Id$
1016+* LIC: GPL
1017+*
1018+* $Id$
1019 *
1020 ***********************************************************************/
1021
1022-#ifdef __sun__
1023-#define __EXTENSIONS__
1024-#endif
1025-
1026 #include "config.h"
1027
1028 #if defined(HAVE_NETPACKET_PACKET_H) || defined(HAVE_LINUX_IF_PACKET_H)
1029@@ -160,6 +158,12 @@
1030 #define CODE_PADR 0x19
1031 #define CODE_PADS 0x65
1032 #define CODE_PADT 0xA7
1033+
1034+/* Extensions from draft-carrel-info-pppoe-ext-00 */
1035+/* I do NOT like PADM or PADN, but they are here for completeness */
1036+#define CODE_PADM 0xD3
1037+#define CODE_PADN 0xD4
1038+
1039 #define CODE_SESS 0x00
1040
1041 /* PPPoE Tags */
1042@@ -174,6 +178,12 @@
1043 #define TAG_AC_SYSTEM_ERROR 0x0202
1044 #define TAG_GENERIC_ERROR 0x0203
1045
1046+/* Extensions from draft-carrel-info-pppoe-ext-00 */
1047+/* I do NOT like these tags one little bit */
1048+#define TAG_HURL 0x111
1049+#define TAG_MOTM 0x112
1050+#define TAG_IP_ROUTE_ADD 0x121
1051+
1052 /* Discovery phase states */
1053 #define STATE_SENT_PADI 0
1054 #define STATE_RECEIVED_PADO 1
1055@@ -298,6 +308,8 @@
1056 void syncReadFromEth(PPPoEConnection *conn, int sock, int clampMss);
1057 char *strDup(char const *str);
1058 void sendPADT(PPPoEConnection *conn, char const *msg);
1059+void sendPADTf(PPPoEConnection *conn, char const *fmt, ...);
1060+
1061 void sendSessionPacket(PPPoEConnection *conn,
1062 PPPoEPacket *packet, int len);
1063 void initPPP(void);
This page took 2.048607 seconds and 4 git commands to generate.