1 diff -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
13 cursor += elen + TAG_HDR_SIZE;
14 plen += elen + TAG_HDR_SIZE;
18 /* Copy cookie and relay-ID if needed */
19 if (conn->cookie.type) {
20 CHECK_ROOM(cursor, packet.payload,
22 syslog(LOG_INFO,"Sent PADT");
25 +/***********************************************************************
26 +*%FUNCTION: sendPADTf
28 +* conn -- PPPoE connection
29 +* msg -- printf-style format string
30 +* args -- arguments for msg
34 +* Sends a PADT packet with a formatted message
35 +***********************************************************************/
37 +sendPADTf(PPPoEConnection *conn, char const *fmt, ...)
43 + vsnprintf(msg, sizeof(msg), fmt, ap);
47 + sendPADT(conn, msg);
50 /**********************************************************************
51 *%FUNCTION: parseLogErrs
58 diff -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
62 -/* config.h. Generated automatically by configure. */
63 +/* config.h. Generated by configure. */
64 /* config.h.in. Generated automatically from configure.in by autoheader. */
67 /* Define to empty if the keyword does not work. */
71 /* Define if bitfields are packed in reverse order */
72 #define PACK_BITFIELDS_REVERSED 1
74 +/* Solaris moans if we don't do this... */
76 +#define __EXTENSIONS__ 1
78 diff -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
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.
87 ***********************************************************************/
89 static char const RCSID[] =
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;
104 diff -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
107 @@ -322,12 +324,12 @@
108 pc.serviceNameOK = (conn->serviceName) ? 0 : 1;
110 pc.seenServiceName = 0;
114 if (BPF_BUFFER_IS_EMPTY) {
120 FD_SET(conn->discoverySocket, &readable);
124 if (r == 0) return; /* Timed out */
129 receivePacket(conn->discoverySocket, &packet, &len);
131 @@ -379,19 +381,17 @@
135 - if (conn->printACNames) {
136 - printf("--------------------------------------------------\n");
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");
152 conn->discoveryState = STATE_RECEIVED_PADO;
153 @@ -504,10 +504,10 @@
154 if (BPF_BUFFER_IS_EMPTY) {
160 FD_SET(conn->discoverySocket, &readable);
164 r = select(conn->discoverySocket+1, &readable, NULL, NULL, &tv);
165 if (r >= 0 || errno != EINTR) break;
167 conn->discoveryState = STATE_SESSION;
171 diff -urN ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/if.c ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/if.c
172 --- ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/if.c Sun Sep 1 20:54:50 2002
173 +++ ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/if.c Sun Sep 1 20:55:21 2002
175 * This program may be distributed according to the terms of the GNU
176 * General Public License, version 2 or (at your option) any later version.
180 ***********************************************************************/
182 static char const RCSID[] =
190 static int dl_abssaplen;
191 static int dl_saplen;
192 -static int dl_addrlen;
193 +static int dl_addrlen;
198 if (ifr->ifr_addr.sa_family == AF_LINK) {
199 sdl = (const struct sockaddr_dl *) &ifr->ifr_addr;
200 if ((sdl->sdl_type == IFT_ETHER) &&
201 - (sdl->sdl_alen == ETH_ALEN) &&
202 + (sdl->sdl_alen == ETH_ALEN) &&
203 !strncmp(ifname, ifr->ifr_name, sizeof(ifr->ifr_name))) {
206 @@ -177,14 +179,14 @@
210 - memcpy(hwaddr, LLADDR(sdl), ETH_ALEN);
211 + memcpy(hwaddr, LLADDR(sdl), ETH_ALEN);
218 - sprintf(buffer, "interface %.16s has no ethernet address", ifname);
219 + sprintf(buffer, "interface %.16s has no ethernet address", ifname);
223 @@ -207,23 +209,23 @@
224 * Note that the ethernet type names come from "pppoe.h" and are
225 * used here to maintain consistency with the rest of this file. */
226 static struct bpf_insn bpfRun[] = { /* run PPPoE */
227 - BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12), /* ethernet type */
228 - BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ETH_PPPOE_SESSION, 5, 0),
229 - BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ETH_PPPOE_DISCOVERY, 0, 9),
230 - BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0), /* first word of dest. addr */
231 + BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 12), /* ethernet type */
232 + BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ETH_PPPOE_SESSION, 5, 0),
233 + BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ETH_PPPOE_DISCOVERY, 0, 9),
234 + BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0), /* first word of dest. addr */
235 #define PPPOE_BCAST_CMPW 4 /* offset of word compare */
236 - BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 2),
237 - BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 4), /* next 1/2 word of dest. */
238 + BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 2),
239 + BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 4), /* next 1/2 word of dest. */
240 #define PPPOE_BCAST_CMPH 6 /* offset of 1/2 word compare */
241 - BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 4, 0),
242 - BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0), /* first word of dest. addr */
243 + BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 4, 0),
244 + BPF_STMT(BPF_LD+BPF_W+BPF_ABS, 0), /* first word of dest. addr */
245 #define PPPOE_FILTER_CMPW 8 /* offset of word compare */
246 - BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 3),
247 - BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 4), /* next 1/2 word of dest. */
248 + BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 3),
249 + BPF_STMT(BPF_LD+BPF_H+BPF_ABS, 4), /* next 1/2 word of dest. */
250 #define PPPOE_FILTER_CMPH 10 /* offset of 1/rd compare */
251 - BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 1),
252 - BPF_STMT(BPF_RET+BPF_K, (u_int) -1), /* keep packet */
253 - BPF_STMT(BPF_RET+BPF_K, 0), /* drop packet */
254 + BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0, 0, 1),
255 + BPF_STMT(BPF_RET+BPF_K, (u_int) -1), /* keep packet */
256 + BPF_STMT(BPF_RET+BPF_K, 0), /* drop packet */
259 /* Fix the potentially varying parts */
260 @@ -242,14 +244,14 @@
261 struct bpf_program bpfProgram;
262 memcpy(bpfInsn, bpfRun, sizeof(bpfRun));
263 bpfInsn[PPPOE_BCAST_CMPW].k = ((0xff << 24) | (0xff << 16) |
264 - (0xff << 8) | 0xff);
265 + (0xff << 8) | 0xff);
266 bpfInsn[PPPOE_BCAST_CMPH].k = ((0xff << 8) | 0xff);
267 bpfInsn[PPPOE_FILTER_CMPW].k = ((hwaddr[0] << 24) | (hwaddr[1] << 16) |
268 (hwaddr[2] << 8) | hwaddr[3]);
269 bpfInsn[PPPOE_FILTER_CMPH].k = ((hwaddr[4] << 8) | hwaddr[5]);
270 bpfProgram.bf_len = (sizeof(bpfInsn) / sizeof(bpfInsn[0]));
271 bpfProgram.bf_insns = &bpfInsn[0];
274 /* Apply the filter */
275 if (ioctl(fd, BIOCSETF, &bpfProgram) < 0) {
276 fatalSys("ioctl(BIOCSETF)");
278 fatalSys("ioctl(BIOCVERSION)");
280 if ((bpf_ver.bv_major != BPF_MAJOR_VERSION) ||
281 - (bpf_ver.bv_minor < BPF_MINOR_VERSION)) {
282 + (bpf_ver.bv_minor < BPF_MINOR_VERSION)) {
284 - sprintf(buffer, "Unsupported BPF version: %d.%d (kernel: %d.%d)",
285 + sprintf(buffer, "Unsupported BPF version: %d.%d (kernel: %d.%d)",
286 BPF_MAJOR_VERSION, BPF_MINOR_VERSION,
287 bpf_ver.bv_major, bpf_ver.bv_minor);
292 syslog(LOG_INFO, "Interface=%.16s HWaddr=%02X:%02X:%02X:%02X:%02X:%02X Device=%.32s Buffer size=%d",
295 hwaddr[0], hwaddr[1], hwaddr[2],
296 hwaddr[3], hwaddr[4], hwaddr[5],
298 @@ -548,12 +550,12 @@
302 - tmp_sap = htons(pkt->ethHdr.h_proto);
303 - data_size = size - sizeof(struct ethhdr);
304 + tmp_sap = htons(pkt->ethHdr.h_proto);
305 + data_size = size - sizeof(struct ethhdr);
307 memcpy((char *)phys, (char *)pkt->ethHdr.h_dest, ETHERADDRL);
308 memcpy((char *)sap, (char *)&tmp_sap, sizeof(ushort_t));
309 - memcpy((char *)xmitbuf, (char *)pkt + sizeof(struct ethhdr), data_size);
310 + memcpy((char *)xmitbuf, (char *)pkt + sizeof(struct ethhdr), data_size);
312 if (dl_saplen > 0) { /* order is sap+phys */
313 (void) memcpy((char*)addr, (char*)&sap, dl_abssaplen);
318 - printf("%02x:%02x:%02x:%02x:%02x:%02x %02x:%02x\n",
319 + printf("%02x:%02x:%02x:%02x:%02x:%02x %02x:%02x\n",
320 addr[0],addr[1],addr[2],addr[3],addr[4],addr[5],
323 @@ -667,20 +669,20 @@
327 - struct strbuf data;
331 - data.buf = (char *) pkt;
332 - data.maxlen = MAXDLBUF;
335 + struct strbuf data;
339 + data.buf = (char *) pkt;
340 + data.maxlen = MAXDLBUF;
343 if ((retval = getmsg(sock, NULL, &data, &flags)) < 0) {
344 sysErr("read (receivePacket)");
352 if ((*size = recv(sock, pkt, sizeof(PPPoEPacket), 0)) < 0) {
353 @@ -708,34 +710,50 @@
354 openInterface(char const *ifname, UINT16_t type, unsigned char *hwaddr)
357 - long buf[MAXDLBUF];
358 + long buf[MAXDLBUF];
360 union DL_primitives *dlp;
362 - char base_dev[PATH_MAX];
364 + char base_dev[PATH_MAX];
367 if(strlen(ifname) > PATH_MAX) {
368 - rp_fatal("socket: string to long");
369 + rp_fatal("socket: Interface name too long");
372 + if (strlen(ifname) < 2) {
373 + rp_fatal("socket: Interface name too short");
376 ppa = atoi(&ifname[strlen(ifname)-1]);
377 - strncpy(base_dev, ifname, PATH_MAX);
378 - base_dev[strlen(base_dev)-1] = '\0';
379 + strncpy(base_dev, ifname, PATH_MAX);
380 + base_dev[strlen(base_dev)-1] = '\0';
382 /* rearranged order of DLPI code - delphys 20010803 */
383 dlp = (union DL_primitives*) buf;
385 - if (( fd = open(base_dev, O_RDWR)) < 0) {
386 + if ( (fd = open(base_dev, O_RDWR)) < 0) {
387 /* Give a more helpful message for the common error case */
388 if (errno == EPERM) {
389 rp_fatal("Cannot create raw socket -- pppoe must be run as root.");
391 + /* Common error is to omit /dev/ */
392 + if (errno == ENOENT) {
394 + snprintf(ifname, sizeof(ifname), "/dev/%s", base_dev);
395 + if ((fd = open(ifname, O_RDWR)) < 0) {
396 + if (errno == EPERM) {
397 + rp_fatal("Cannot create raw socket -- pppoe must be run as root.");
406 /* rearranged order of DLPI code - delphys 20010803 */
407 - dlattachreq(fd, ppa);
408 + dlattachreq(fd, ppa);
409 dlokack(fd, (char *)buf);
411 dlbindreq(fd, type, 0, DL_CLDLS, 0, 0);
413 /* ethernet address retrieved as part of DL_INFO_ACK - delphys 20010803 */
414 memcpy(hwaddr, (u_char*)((char*)(dlp) + (int)(dlp->info_ack.dl_addr_offset)), ETHERADDRL);
416 - if ( strioctl(fd, DLIOCRAW, -1, 0, NULL) < 0 ) {
417 - fatalSys("DLIOCRAW");
418 + if ( strioctl(fd, DLIOCRAW, -1, 0, NULL) < 0 ) {
419 + fatalSys("DLIOCRAW");
422 if (ioctl(fd, I_FLUSH, FLUSHR) < 0) fatalSys("I_FLUSH");
423 @@ -766,332 +784,332 @@
425 void dlpromisconreq(int fd, u_long level)
427 - dl_promiscon_req_t promiscon_req;
430 + dl_promiscon_req_t promiscon_req;
434 - promiscon_req.dl_primitive = DL_PROMISCON_REQ;
435 - promiscon_req.dl_level = level;
436 + promiscon_req.dl_primitive = DL_PROMISCON_REQ;
437 + promiscon_req.dl_level = level;
440 - ctl.len = sizeof (promiscon_req);
441 - ctl.buf = (char *) &promiscon_req;
443 + ctl.len = sizeof (promiscon_req);
444 + ctl.buf = (char *) &promiscon_req;
449 - if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
450 - fatalSys("dlpromiscon: putmsg");
451 + if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
452 + fatalSys("dlpromiscon: putmsg");
456 void dlinforeq(int fd)
458 - dl_info_req_t info_req;
461 + dl_info_req_t info_req;
465 - info_req.dl_primitive = DL_INFO_REQ;
466 + info_req.dl_primitive = DL_INFO_REQ;
469 - ctl.len = sizeof (info_req);
470 - ctl.buf = (char *) &info_req;
472 + ctl.len = sizeof (info_req);
473 + ctl.buf = (char *) &info_req;
478 - if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
479 - fatalSys("dlinforeq: putmsg");
480 + if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
481 + fatalSys("dlinforeq: putmsg");
484 void dlunitdatareq(int fd, u_char *addrp, int addrlen, u_long minpri, u_long maxpri, u_char *datap, int datalen)
486 - long buf[MAXDLBUF];
487 - union DL_primitives *dlp;
488 - struct strbuf data, ctl;
490 - dlp = (union DL_primitives*) buf;
492 - dlp->unitdata_req.dl_primitive = DL_UNITDATA_REQ;
493 - dlp->unitdata_req.dl_dest_addr_length = addrlen;
494 - dlp->unitdata_req.dl_dest_addr_offset = sizeof (dl_unitdata_req_t);
495 - dlp->unitdata_req.dl_priority.dl_min = minpri;
496 - dlp->unitdata_req.dl_priority.dl_max = maxpri;
498 - (void) memcpy(OFFADDR(dlp, sizeof (dl_unitdata_req_t)), addrp, addrlen);
501 - ctl.len = sizeof (dl_unitdata_req_t) + addrlen;
502 - ctl.buf = (char *) buf;
505 - data.len = datalen;
506 - data.buf = (char *) datap;
507 + long buf[MAXDLBUF];
508 + union DL_primitives *dlp;
509 + struct strbuf data, ctl;
511 + dlp = (union DL_primitives*) buf;
513 + dlp->unitdata_req.dl_primitive = DL_UNITDATA_REQ;
514 + dlp->unitdata_req.dl_dest_addr_length = addrlen;
515 + dlp->unitdata_req.dl_dest_addr_offset = sizeof (dl_unitdata_req_t);
516 + dlp->unitdata_req.dl_priority.dl_min = minpri;
517 + dlp->unitdata_req.dl_priority.dl_max = maxpri;
519 + (void) memcpy(OFFADDR(dlp, sizeof (dl_unitdata_req_t)), addrp, addrlen);
521 - if (putmsg(fd, &ctl, &data, 0) < 0)
522 - fatalSys("dlunitdatareq: putmsg");
524 + ctl.len = sizeof (dl_unitdata_req_t) + addrlen;
525 + ctl.buf = (char *) buf;
528 + data.len = datalen;
529 + data.buf = (char *) datap;
531 + if (putmsg(fd, &ctl, &data, 0) < 0)
532 + fatalSys("dlunitdatareq: putmsg");
535 void dlinfoack(int fd, char *bufp)
537 - union DL_primitives *dlp;
540 + union DL_primitives *dlp;
544 - ctl.maxlen = MAXDLBUF;
547 + ctl.maxlen = MAXDLBUF;
551 - strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlinfoack");
552 + strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlinfoack");
554 - dlp = (union DL_primitives *) ctl.buf;
555 + dlp = (union DL_primitives *) ctl.buf;
557 - expecting(DL_INFO_ACK, dlp);
558 + expecting(DL_INFO_ACK, dlp);
560 - if (ctl.len < sizeof (dl_info_ack_t)) {
561 + if (ctl.len < sizeof (dl_info_ack_t)) {
563 - sprintf(buffer, "dlinfoack: response ctl.len too short: %d", ctl.len);
565 + sprintf(buffer, "dlinfoack: response ctl.len too short: %d", ctl.len);
569 - if (flags != RS_HIPRI)
570 - rp_fatal("dlinfoack: DL_INFO_ACK was not M_PCPROTO");
571 + if (flags != RS_HIPRI)
572 + rp_fatal("dlinfoack: DL_INFO_ACK was not M_PCPROTO");
574 - if (ctl.len < sizeof (dl_info_ack_t)) {
575 + if (ctl.len < sizeof (dl_info_ack_t)) {
577 - sprintf(buffer, "dlinfoack: short response ctl.len: %d", ctl.len);
579 + sprintf(buffer, "dlinfoack: short response ctl.len: %d", ctl.len);
584 void dlbindreq(int fd, u_long sap, u_long max_conind, u_long service_mode, u_long conn_mgmt, u_long xidtest)
586 - dl_bind_req_t bind_req;
590 - bind_req.dl_primitive = DL_BIND_REQ;
591 - bind_req.dl_sap = sap;
592 - bind_req.dl_max_conind = max_conind;
593 - bind_req.dl_service_mode = service_mode;
594 - bind_req.dl_conn_mgmt = conn_mgmt;
595 - bind_req.dl_xidtest_flg = xidtest;
598 - ctl.len = sizeof (bind_req);
599 - ctl.buf = (char *) &bind_req;
600 + dl_bind_req_t bind_req;
604 + bind_req.dl_primitive = DL_BIND_REQ;
605 + bind_req.dl_sap = sap;
606 + bind_req.dl_max_conind = max_conind;
607 + bind_req.dl_service_mode = service_mode;
608 + bind_req.dl_conn_mgmt = conn_mgmt;
609 + bind_req.dl_xidtest_flg = xidtest;
612 + ctl.len = sizeof (bind_req);
613 + ctl.buf = (char *) &bind_req;
618 - if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
619 - fatalSys("dlbindreq: putmsg");
620 + if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
621 + fatalSys("dlbindreq: putmsg");
624 void dlattachreq(int fd, u_long ppa)
626 - dl_attach_req_t attach_req;
629 + dl_attach_req_t attach_req;
633 - attach_req.dl_primitive = DL_ATTACH_REQ;
634 - attach_req.dl_ppa = ppa;
635 + attach_req.dl_primitive = DL_ATTACH_REQ;
636 + attach_req.dl_ppa = ppa;
639 - ctl.len = sizeof (attach_req);
640 - ctl.buf = (char *) &attach_req;
642 + ctl.len = sizeof (attach_req);
643 + ctl.buf = (char *) &attach_req;
648 - if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
649 - fatalSys("dlattachreq: putmsg");
650 + if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
651 + fatalSys("dlattachreq: putmsg");
654 void dlokack(int fd, char *bufp)
656 - union DL_primitives *dlp;
659 + union DL_primitives *dlp;
663 - ctl.maxlen = MAXDLBUF;
666 + ctl.maxlen = MAXDLBUF;
670 - strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlokack");
671 + strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlokack");
673 - dlp = (union DL_primitives *) ctl.buf;
674 + dlp = (union DL_primitives *) ctl.buf;
676 - expecting(DL_OK_ACK, dlp);
677 + expecting(DL_OK_ACK, dlp);
679 - if (ctl.len < sizeof (dl_ok_ack_t)) {
680 + if (ctl.len < sizeof (dl_ok_ack_t)) {
682 sprintf(buffer, "dlokack: response ctl.len too short: %d", ctl.len);
687 - if (flags != RS_HIPRI)
688 - rp_fatal("dlokack: DL_OK_ACK was not M_PCPROTO");
689 + if (flags != RS_HIPRI)
690 + rp_fatal("dlokack: DL_OK_ACK was not M_PCPROTO");
692 - if (ctl.len < sizeof (dl_ok_ack_t)) {
694 + if (ctl.len < sizeof (dl_ok_ack_t)) {
696 sprintf(buffer, "dlokack: short response ctl.len: %d", ctl.len);
702 void dlbindack(int fd, char *bufp)
704 - union DL_primitives *dlp;
707 + union DL_primitives *dlp;
711 - ctl.maxlen = MAXDLBUF;
714 + ctl.maxlen = MAXDLBUF;
718 - strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlbindack");
719 + strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlbindack");
721 - dlp = (union DL_primitives *) ctl.buf;
722 + dlp = (union DL_primitives *) ctl.buf;
724 - expecting(DL_BIND_ACK, dlp);
725 + expecting(DL_BIND_ACK, dlp);
727 - if (flags != RS_HIPRI)
728 - rp_fatal("dlbindack: DL_OK_ACK was not M_PCPROTO");
729 + if (flags != RS_HIPRI)
730 + rp_fatal("dlbindack: DL_OK_ACK was not M_PCPROTO");
732 - if (ctl.len < sizeof (dl_bind_ack_t)) {
733 + if (ctl.len < sizeof (dl_bind_ack_t)) {
735 sprintf(buffer, "dlbindack: short response ctl.len: %d", ctl.len);
741 int strioctl(int fd, int cmd, int timout, int len, char *dp)
743 - struct strioctl sioc;
745 + struct strioctl sioc;
749 - sioc.ic_timout = timout;
752 - rc = ioctl(fd, I_STR, &sioc);
757 - return (sioc.ic_len);
759 + sioc.ic_timout = timout;
762 + rc = ioctl(fd, I_STR, &sioc);
767 + return (sioc.ic_len);
770 void strgetmsg(int fd, struct strbuf *ctlp, struct strbuf *datap, int *flagsp, char *caller)
773 - static char errmsg[80];
775 + static char errmsg[80];
780 - (void) signal(SIGALRM, sigalrm);
781 - if (alarm(MAXWAIT) < 0) {
782 - (void) sprintf(errmsg, "%s: alarm", caller);
787 - * Set flags argument and issue getmsg().
790 - if ((rc = getmsg(fd, ctlp, datap, flagsp)) < 0) {
791 - (void) sprintf(errmsg, "%s: getmsg", caller);
798 - if (alarm(0) < 0) {
799 - (void) sprintf(errmsg, "%s: alarm", caller);
804 - * Check for MOREDATA and/or MORECTL.
806 - if ((rc & (MORECTL | MOREDATA)) == (MORECTL | MOREDATA)) {
811 + (void) signal(SIGALRM, sigalrm);
812 + if (alarm(MAXWAIT) < 0) {
813 + (void) sprintf(errmsg, "%s: alarm", caller);
818 + * Set flags argument and issue getmsg().
821 + if ((rc = getmsg(fd, ctlp, datap, flagsp)) < 0) {
822 + (void) sprintf(errmsg, "%s: getmsg", caller);
829 + if (alarm(0) < 0) {
830 + (void) sprintf(errmsg, "%s: alarm", caller);
835 + * Check for MOREDATA and/or MORECTL.
837 + if ((rc & (MORECTL | MOREDATA)) == (MORECTL | MOREDATA)) {
839 sprintf(buffer, "%s: MORECTL|MOREDATA", caller);
843 - if (rc & MORECTL) {
845 + if (rc & MORECTL) {
847 sprintf(buffer, "%s: MORECTL", caller);
852 - if (rc & MOREDATA) {
855 + if (rc & MOREDATA) {
857 sprintf(buffer, "%s: MOREDATA", caller);
862 - * Check for at least sizeof (long) control data portion.
864 - if (ctlp->len < sizeof (long)) {
867 + * Check for at least sizeof (long) control data portion.
869 + if (ctlp->len < sizeof (long)) {
871 sprintf(buffer, "getmsg: control portion length < sizeof (long): %d", ctlp->len);
877 void sigalrm(int sig)
879 - (void) rp_fatal("sigalrm: TIMEOUT");
880 + (void) rp_fatal("sigalrm: TIMEOUT");
883 void expecting(int prim, union DL_primitives *dlp)
885 - if (dlp->dl_primitive != (u_long)prim) {
887 + if (dlp->dl_primitive != (u_long)prim) {
889 sprintf(buffer, "expected %s got %s", dlprim(prim), dlprim(dlp->dl_primitive));
897 char *dlprim(u_long prim)
899 - static char primbuf[80];
900 + static char primbuf[80];
902 - switch ((int)prim) {
903 - CASERET(DL_INFO_REQ);
904 - CASERET(DL_INFO_ACK);
905 - CASERET(DL_ATTACH_REQ);
906 - CASERET(DL_DETACH_REQ);
907 - CASERET(DL_BIND_REQ);
908 - CASERET(DL_BIND_ACK);
909 - CASERET(DL_UNBIND_REQ);
910 - CASERET(DL_OK_ACK);
911 - CASERET(DL_ERROR_ACK);
912 - CASERET(DL_SUBS_BIND_REQ);
913 - CASERET(DL_SUBS_BIND_ACK);
914 - CASERET(DL_UNITDATA_REQ);
915 - CASERET(DL_UNITDATA_IND);
916 - CASERET(DL_UDERROR_IND);
917 - CASERET(DL_UDQOS_REQ);
918 - CASERET(DL_CONNECT_REQ);
919 - CASERET(DL_CONNECT_IND);
920 - CASERET(DL_CONNECT_RES);
921 - CASERET(DL_CONNECT_CON);
922 - CASERET(DL_TOKEN_REQ);
923 - CASERET(DL_TOKEN_ACK);
924 - CASERET(DL_DISCONNECT_REQ);
925 - CASERET(DL_DISCONNECT_IND);
926 - CASERET(DL_RESET_REQ);
927 - CASERET(DL_RESET_IND);
928 - CASERET(DL_RESET_RES);
929 - CASERET(DL_RESET_CON);
931 - (void) sprintf(primbuf, "unknown primitive 0x%lx", prim);
934 + switch ((int)prim) {
935 + CASERET(DL_INFO_REQ);
936 + CASERET(DL_INFO_ACK);
937 + CASERET(DL_ATTACH_REQ);
938 + CASERET(DL_DETACH_REQ);
939 + CASERET(DL_BIND_REQ);
940 + CASERET(DL_BIND_ACK);
941 + CASERET(DL_UNBIND_REQ);
942 + CASERET(DL_OK_ACK);
943 + CASERET(DL_ERROR_ACK);
944 + CASERET(DL_SUBS_BIND_REQ);
945 + CASERET(DL_SUBS_BIND_ACK);
946 + CASERET(DL_UNITDATA_REQ);
947 + CASERET(DL_UNITDATA_IND);
948 + CASERET(DL_UDERROR_IND);
949 + CASERET(DL_UDQOS_REQ);
950 + CASERET(DL_CONNECT_REQ);
951 + CASERET(DL_CONNECT_IND);
952 + CASERET(DL_CONNECT_RES);
953 + CASERET(DL_CONNECT_CON);
954 + CASERET(DL_TOKEN_REQ);
955 + CASERET(DL_TOKEN_ACK);
956 + CASERET(DL_DISCONNECT_REQ);
957 + CASERET(DL_DISCONNECT_IND);
958 + CASERET(DL_RESET_REQ);
959 + CASERET(DL_RESET_IND);
960 + CASERET(DL_RESET_RES);
961 + CASERET(DL_RESET_CON);
963 + (void) sprintf(primbuf, "unknown primitive 0x%lx", prim);
968 #endif /* USE_DLPI */
969 diff -urN ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/plugin.c ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/plugin.c
970 --- ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/plugin.c Sun Sep 1 20:54:50 2002
971 +++ ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/plugin.c Sun Sep 1 20:55:21 2002
974 #include <net/ethernet.h>
975 #include <net/if_arp.h>
976 -#include "ppp_defs.h"
978 -#include "if_pppox.h"
979 +#include <linux/ppp_defs.h>
980 +#include <linux/if_ppp.h>
981 +#include <linux/if_pppox.h>
983 #define _PATH_ETHOPT _ROOT_PATH "/etc/ppp/options."
985 @@ -399,12 +398,11 @@
987 rp_fatal(char const *str)
991 - sprintf(buf, "RP-PPPoE: %.256s", str);
992 - sendPADT(conn, buf);
993 + sendPADTf(conn, "RP-PPPoE: %.256s", str);
997 /**********************************************************************
1000 diff -urN ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/pppoe.h ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/pppoe.h
1001 --- ppp-2.4.2-20020901.org/pppd/plugins/rp-pppoe/pppoe.h Sun Sep 1 20:54:50 2002
1002 +++ ppp-2.4.2-20020901/pppd/plugins/rp-pppoe/pppoe.h Sun Sep 1 20:55:21 2002
1003 @@ -160,6 +158,12 @@
1004 #define CODE_PADR 0x19
1005 #define CODE_PADS 0x65
1006 #define CODE_PADT 0xA7
1008 +/* Extensions from draft-carrel-info-pppoe-ext-00 */
1009 +/* I do NOT like PADM or PADN, but they are here for completeness */
1010 +#define CODE_PADM 0xD3
1011 +#define CODE_PADN 0xD4
1013 #define CODE_SESS 0x00
1016 @@ -174,6 +178,12 @@
1017 #define TAG_AC_SYSTEM_ERROR 0x0202
1018 #define TAG_GENERIC_ERROR 0x0203
1020 +/* Extensions from draft-carrel-info-pppoe-ext-00 */
1021 +/* I do NOT like these tags one little bit */
1022 +#define TAG_HURL 0x111
1023 +#define TAG_MOTM 0x112
1024 +#define TAG_IP_ROUTE_ADD 0x121
1026 /* Discovery phase states */
1027 #define STATE_SENT_PADI 0
1028 #define STATE_RECEIVED_PADO 1
1030 void syncReadFromEth(PPPoEConnection *conn, int sock, int clampMss);
1031 char *strDup(char const *str);
1032 void sendPADT(PPPoEConnection *conn, char const *msg);
1033 +void sendPADTf(PPPoEConnection *conn, char const *fmt, ...);
1035 void sendSessionPacket(PPPoEConnection *conn,
1036 PPPoEPacket *packet, int len);