1 Index: ppp-2.4.3/pppd/plugins/rp-pppoe/common.c
2 ===================================================================
3 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/common.c 2007-06-04 13:22:08.391579568 +0200
4 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/common.c 2007-06-04 13:22:09.414424072 +0200
17 UINT16_t tagType, tagLen;
19 if (packet->ver != 1) {
20 - syslog(LOG_ERR, "Invalid PPPoE version (%d)", (int) packet->ver);
21 + error("Invalid PPPoE version (%u)", packet->ver);
24 if (packet->type != 1) {
25 - syslog(LOG_ERR, "Invalid PPPoE type (%d)", (int) packet->type);
26 + error("Invalid PPPoE type (%u)", packet->type);
30 /* Do some sanity checks on packet */
31 if (len > ETH_DATA_LEN - 6) { /* 6-byte overhead for PPPoE header */
32 - syslog(LOG_ERR, "Invalid PPPoE packet length (%u)", len);
33 + error("Invalid PPPoE packet length (%u)", len);
40 if ((curTag - packet->payload) + tagLen + TAG_HDR_SIZE > len) {
41 - syslog(LOG_ERR, "Invalid PPPoE tag length (%u)", tagLen);
42 + error("Invalid PPPoE tag length (%u)", tagLen);
45 func(tagType, tagLen, curTag+TAG_HDR_SIZE, extra);
47 UINT16_t tagType, tagLen;
49 if (packet->ver != 1) {
50 - syslog(LOG_ERR, "Invalid PPPoE version (%d)", (int) packet->ver);
51 + error("Invalid PPPoE version (%u)", packet->ver);
54 if (packet->type != 1) {
55 - syslog(LOG_ERR, "Invalid PPPoE type (%d)", (int) packet->type);
56 + error("Invalid PPPoE type (%u)", packet->type);
60 /* Do some sanity checks on packet */
61 if (len > ETH_DATA_LEN - 6) { /* 6-byte overhead for PPPoE header */
62 - syslog(LOG_ERR, "Invalid PPPoE packet length (%u)", len);
63 + error("Invalid PPPoE packet length (%u)", len);
70 if ((curTag - packet->payload) + tagLen + TAG_HDR_SIZE > len) {
71 - syslog(LOG_ERR, "Invalid PPPoE tag length (%u)", tagLen);
72 + error("Invalid PPPoE tag length (%u)", tagLen);
75 if (tagType == type) {
81 /**********************************************************************
85 fprintf(stderr, "pppoe: %s\n", str);
86 syslog(LOG_ERR, "%s", str);
91 /**********************************************************************
94 char *copy = malloc(strlen(str)+1);
96 - rp_fatal("strdup failed");
97 + fatal("strdup failed");
102 fprintf(conn->debugFile, "\n");
103 fflush(conn->debugFile);
105 - syslog(LOG_INFO,"Sent PADT");
110 /**********************************************************************
111 *%FUNCTION: parseLogErrs
119 Index: ppp-2.4.3/pppd/plugins/rp-pppoe/discovery.c
120 ===================================================================
121 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/discovery.c 2007-06-04 13:22:09.225452800 +0200
122 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/discovery.c 2007-06-04 13:22:09.414424072 +0200
127 -#ifdef HAVE_SYSLOG_H
134 @@ -167,24 +163,21 @@
135 if (conn->printACNames) {
136 printf("Got a Service-Name-Error tag: %.*s\n", (int) len, data);
138 - syslog(LOG_ERR, "PADO: Service-Name-Error: %.*s", (int) len, data);
140 + fatal("PADO: Service-Name-Error: %.*s", (int) len, data);
143 case TAG_AC_SYSTEM_ERROR:
144 if (conn->printACNames) {
145 printf("Got a System-Error tag: %.*s\n", (int) len, data);
147 - syslog(LOG_ERR, "PADO: System-Error: %.*s", (int) len, data);
149 + fatal("PADO: System-Error: %.*s", (int) len, data);
152 case TAG_GENERIC_ERROR:
153 if (conn->printACNames) {
154 printf("Got a Generic-Error tag: %.*s\n", (int) len, data);
156 - syslog(LOG_ERR, "PADO: Generic-Error: %.*s", (int) len, data);
158 + fatal("PADO: Generic-Error: %.*s", (int) len, data);
162 @@ -209,20 +202,14 @@
163 PPPoEConnection *conn = (PPPoEConnection *) extra;
165 case TAG_SERVICE_NAME:
166 - syslog(LOG_DEBUG, "PADS: Service-Name: '%.*s'", (int) len, data);
167 + dbglog("PADS: Service-Name: '%.*s'", (int) len, data);
169 case TAG_SERVICE_NAME_ERROR:
170 - syslog(LOG_ERR, "PADS: Service-Name-Error: %.*s", (int) len, data);
171 - fprintf(stderr, "PADS: Service-Name-Error: %.*s\n", (int) len, data);
173 + fatal("PADS: Service-Name-Error: %.*s", (int) len, data);
174 case TAG_AC_SYSTEM_ERROR:
175 - syslog(LOG_ERR, "PADS: System-Error: %.*s", (int) len, data);
176 - fprintf(stderr, "PADS: System-Error: %.*s\n", (int) len, data);
178 + fatal("PADS: System-Error: %.*s", (int) len, data);
179 case TAG_GENERIC_ERROR:
180 - syslog(LOG_ERR, "PADS: Generic-Error: %.*s", (int) len, data);
181 - fprintf(stderr, "PADS: Generic-Error: %.*s\n", (int) len, data);
183 + fatal("PADS: Generic-Error: %.*s", (int) len, data);
184 case TAG_RELAY_SESSION_ID:
185 conn->relayId.type = htons(type);
186 conn->relayId.length = htons(len);
188 if (r >= 0 || errno != EINTR) break;
191 - fatalSys("select (waitForPADO)");
192 + fatal("waitForPADO: select: %m");
194 if (r == 0) return; /* Timed out */
199 if (ntohs(packet.length) + HDR_SIZE > len) {
200 - syslog(LOG_ERR, "Bogus PPPoE length field (%u)",
201 - (unsigned int) ntohs(packet.length));
202 + error("Bogus PPPoE length field (%u)", ntohs(packet.length));
206 @@ -366,16 +352,16 @@
208 if (packet.code == CODE_PADO) {
209 if (BROADCAST(packet.ethHdr.h_source)) {
210 - printErr("Ignoring PADO packet from broadcast MAC address");
211 + error("Ignoring PADO packet from broadcast MAC address");
214 parsePacket(&packet, parsePADOTags, &pc);
215 if (!pc.seenACName) {
216 - printErr("Ignoring PADO packet with no AC-Name tag");
217 + error("Ignoring PADO packet with no AC-Name tag");
220 if (!pc.seenServiceName) {
221 - printErr("Ignoring PADO packet with no Service-Name tag");
222 + error("Ignoring PADO packet with no Service-Name tag");
227 if (r >= 0 || errno != EINTR) break;
230 - fatalSys("select (waitForPADS)");
231 + fatal("waitForPADS: select: %m");
238 if (ntohs(packet.length) + HDR_SIZE > len) {
239 - syslog(LOG_ERR, "Bogus PPPoE length field (%u)",
240 - (unsigned int) ntohs(packet.length));
241 + error("Bogus PPPoE length field (%u)", ntohs(packet.length));
245 @@ -556,11 +541,12 @@
246 /* Don't bother with ntohs; we'll just end up converting it back... */
247 conn->session = packet.session;
249 - syslog(LOG_INFO, "PPP session is %d", (int) ntohs(conn->session));
250 + info("PPP session is %d", ntohs(conn->session));
252 /* RFC 2516 says session id MUST NOT be zero or 0xFFFF */
253 if (ntohs(conn->session) == 0 || ntohs(conn->session) == 0xFFFF) {
254 - syslog(LOG_ERR, "Access concentrator used a session value of %x -- the AC is violating RFC 2516", (unsigned int) ntohs(conn->session));
255 + error("Access concentrator used a session value of 0x%x"
256 + " -- the AC is violating RFC 2516", ntohs(conn->session));
262 /* If we're only printing access concentrator names, we're done */
263 if (conn->printACNames) {
268 timeout = PADI_TIMEOUT;
269 Index: ppp-2.4.3/pppd/plugins/rp-pppoe/if.c
270 ===================================================================
271 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/if.c 2007-06-04 13:22:08.402577896 +0200
272 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/if.c 2007-06-04 13:22:09.416423768 +0200
274 #include <sys/ioctl.h>
277 -#ifdef HAVE_SYSLOG_H
286 UINT16_t type = (UINT16_t) ntohs(packet->ethHdr.h_proto);
287 if (type != Eth_PPPOE_Discovery && type != Eth_PPPOE_Session) {
288 - syslog(LOG_ERR, "Invalid ether type 0x%x", type);
289 + error("Invalid ethernet type 0x%x", type);
294 ifc.ifc_len = sizeof(inbuf);
296 if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) {
297 - fatalSys("SIOCGIFCONF");
298 + fatal("SIOCGIFCONF: %m");
301 ifreq.ifr_name[0] = '\0';
303 (sdl->sdl_alen == ETH_ALEN) &&
304 !strncmp(ifname, ifr->ifr_name, sizeof(ifr->ifr_name))) {
307 - sprintf(buffer, "interface %.16s has more than one ethernet address", ifname);
309 + fatal("interface %s has more than one ethernet address", ifname);
312 memcpy(hwaddr, LLADDR(sdl), ETH_ALEN);
318 - sprintf(buffer, "interface %.16s has no ethernet address", ifname);
320 + fatal("interface %s has no ethernet address", ifname);
326 /* Apply the filter */
327 if (ioctl(fd, BIOCSETF, &bpfProgram) < 0) {
328 - fatalSys("ioctl(BIOCSETF)");
329 + fatal("ioctl(BIOCSETF): %m");
333 @@ -298,42 +290,36 @@
336 case EACCES: /* permission denied */
339 - sprintf(buffer, "Cannot open %.32s -- pppoe must be run as root.", bpfName);
342 + fatal("Cannot open %s -- pppoe must be run as root.", bpfName);
345 case ENOENT: /* no such file */
347 - rp_fatal("No /dev/bpf* devices (check your kernel configuration for BPF support)");
348 + fatal("No /dev/bpf* devices (check your kernel configuration for BPF support)");
350 - rp_fatal("All /dev/bpf* devices are in use");
351 + fatal("All /dev/bpf* devices are in use");
356 + fatal("%s: %m", bpfName);
359 if ((sock = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) {
360 - fatalSys("socket");
361 + fatal("socket: %m");
364 /* Check that the interface is up */
365 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
366 if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) {
367 - fatalSys("ioctl(SIOCGIFFLAGS)");
368 + fatal("ioctl(SIOCGIFFLAGS): %m");
370 if ((ifr.ifr_flags & IFF_UP) == 0) {
372 - sprintf(buffer, "Interface %.16s is not up\n", ifname);
374 + fatal("Interface %s is not up", ifname);
377 /* Fill in hardware address and initialize the packet filter rules */
378 if (hwaddr == NULL) {
379 - rp_fatal("openInterface: no hwaddr arg.");
380 + fatal("openInterface: no hwaddr arg.");
382 getHWaddr(sock, ifname, hwaddr);
383 initFilter(fd, type, hwaddr);
384 @@ -342,58 +328,52 @@
385 #if !defined(__OpenBSD__)
386 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
387 if (ioctl(sock, SIOCGIFMTU, &ifr) < 0) {
388 - fatalSys("ioctl(SIOCGIFMTU)");
389 + fatal("ioctl(SIOCGIFMTU): %m");
391 if (ifr.ifr_mtu < ETH_DATA_LEN) {
393 - sprintf(buffer, "Interface %.16s has MTU of %d -- should be %d. You may have serious connection problems.",
394 + error("Interface %s has MTU of %d -- should be %d."
395 + " You may have serious connection problems.",
396 ifname, ifr.ifr_mtu, ETH_DATA_LEN);
401 /* done with the socket */
402 if (close(sock) < 0) {
404 + fatal("close: %m");
407 /* Check the BPF version number */
408 if (ioctl(fd, BIOCVERSION, &bpf_ver) < 0) {
409 - fatalSys("ioctl(BIOCVERSION)");
410 + fatal("ioctl(BIOCVERSION): %m");
412 if ((bpf_ver.bv_major != BPF_MAJOR_VERSION) ||
413 (bpf_ver.bv_minor < BPF_MINOR_VERSION)) {
415 - sprintf(buffer, "Unsupported BPF version: %d.%d (kernel: %d.%d)",
416 + fatal("Unsupported BPF version: %d.%d (kernel: %d.%d)",
417 BPF_MAJOR_VERSION, BPF_MINOR_VERSION,
418 bpf_ver.bv_major, bpf_ver.bv_minor);
422 /* allocate a receive packet buffer */
423 if (ioctl(fd, BIOCGBLEN, &bpfLength) < 0) {
424 - fatalSys("ioctl(BIOCGBLEN)");
425 + fatal("ioctl(BIOCGBLEN): %m");
427 if (!(bpfBuffer = (unsigned char *) malloc(bpfLength))) {
428 - rp_fatal("malloc");
432 /* reads should return as soon as there is a packet available */
434 if (ioctl(fd, BIOCIMMEDIATE, &optval) < 0) {
435 - fatalSys("ioctl(BIOCIMMEDIATE)");
436 + fatal("ioctl(BIOCIMMEDIATE): %m");
439 /* Bind the interface to the filter */
440 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
441 if (ioctl(fd, BIOCSETIF, &ifr) < 0) {
443 - sprintf(buffer, "ioctl(BIOCSETIF) can't select interface %.16s",
446 + fatal("ioctl(BIOCSETIF) can't select interface %s: %m", ifname);
449 - syslog(LOG_INFO, "Interface=%.16s HWaddr=%02X:%02X:%02X:%02X:%02X:%02X Device=%.32s Buffer size=%d",
450 + info("Interface=%s HWaddr=%02X:%02X:%02X:%02X:%02X:%02X Device=%s Buffer size=%d",
452 hwaddr[0], hwaddr[1], hwaddr[2],
453 hwaddr[3], hwaddr[4], hwaddr[5],
454 @@ -442,48 +422,41 @@
455 if ((fd = socket(domain, stype, htons(type))) < 0) {
456 /* Give a more helpful message for the common error case */
457 if (errno == EPERM) {
458 - rp_fatal("Cannot create raw socket -- pppoe must be run as root.");
459 + fatal("Cannot create raw socket -- pppoe must be run as root.");
461 - fatalSys("socket");
462 + fatal("cannot create the raw socket: %m");
465 if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) < 0) {
466 - fatalSys("setsockopt");
467 + fatal("setsockopt(SOL_SOCKET, SO_BROADCAST): %m");
470 /* Fill in hardware address */
472 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
473 - if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) {
474 - fatalSys("ioctl(SIOCGIFHWADDR)");
476 + if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0)
477 + fatal("ioctl(SIOCGIFHWADDR): %m");
478 memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
480 if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
482 - sprintf(buffer, "Interface %.16s is not Ethernet", ifname);
484 + fatal("Interface %s is not Ethernet", ifname);
487 if (NOT_UNICAST(hwaddr)) {
490 - "Interface %.16s has broadcast/multicast MAC address??",
491 + fatal("Interface %s has broadcast/multicast MAC address",
497 /* Sanity check on MTU */
498 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
499 if (ioctl(fd, SIOCGIFMTU, &ifr) < 0) {
500 - fatalSys("ioctl(SIOCGIFMTU)");
501 + fatal("ioctl(SIOCGIFMTU): %m");
503 if (ifr.ifr_mtu < ETH_DATA_LEN) {
505 - sprintf(buffer, "Interface %.16s has MTU of %d -- should be %d. You may have serious connection problems.",
506 + error("Interface %s has MTU of %d -- should be %d."
507 + " You may have serious connection problems.",
508 ifname, ifr.ifr_mtu, ETH_DATA_LEN);
512 #ifdef HAVE_STRUCT_SOCKADDR_LL
515 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
516 if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) {
517 - fatalSys("ioctl(SIOCFIGINDEX): Could not get interface index");
518 + fatal("ioctl(SIOCFIGINDEX): Could not get interface index: %m");
520 sa.sll_ifindex = ifr.ifr_ifindex;
524 /* We're only interested in packets on specified interface */
525 if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
531 @@ -527,13 +500,11 @@
534 if (write(sock, pkt, size) < 0) {
535 - sysErr("write (sendPacket)");
537 + fatal("sendPacket: write: %m");
539 #elif defined(HAVE_STRUCT_SOCKADDR_LL)
540 if (send(sock, pkt, size, 0) < 0) {
541 - sysErr("send (sendPacket)");
543 + fatal("sendPacket: send: %m");
547 @@ -577,12 +548,11 @@
551 - rp_fatal("relay and server not supported on Linux 2.0 kernels");
552 + fatal("relay and server not supported on Linux 2.0 kernels");
554 strcpy(sa.sa_data, conn->ifName);
555 if (sendto(sock, pkt, size, 0, &sa, sizeof(sa)) < 0) {
556 - sysErr("sendto (sendPacket)");
558 + fatal("sendPacket: sendto: %m");
562 @@ -632,26 +602,24 @@
565 if ((bpfSize = read(sock, bpfBuffer, bpfLength)) < 0) {
566 - sysErr("read (receivePacket)");
568 + fatal("receivePacket: read: %m");
571 if (bpfSize < sizeof(hdr)) {
572 - syslog(LOG_ERR, "Truncated bpf packet header: len=%d", bpfSize);
573 + error("Truncated bpf packet header: len=%d", bpfSize);
574 clearPacketHeader(pkt); /* resets bpfSize and bpfOffset */
577 memcpy(&hdr, bpfBuffer + bpfOffset, sizeof(hdr));
578 if (hdr.bh_caplen != hdr.bh_datalen) {
579 - syslog(LOG_ERR, "Truncated bpf packet: caplen=%d, datalen=%d",
580 + error("Truncated bpf packet: caplen=%d, datalen=%d",
581 hdr.bh_caplen, hdr.bh_datalen);
582 clearPacketHeader(pkt); /* resets bpfSize and bpfOffset */
585 seglen = hdr.bh_hdrlen + hdr.bh_caplen;
586 if (seglen > bpfSize) {
587 - syslog(LOG_ERR, "Truncated bpf packet: seglen=%d, bpfSize=%d",
589 + error("Truncated bpf packet: seglen=%d, bpfSize=%d", seglen, bpfSize);
590 clearPacketHeader(pkt); /* resets bpfSize and bpfOffset */
593 @@ -676,16 +644,14 @@
596 if ((retval = getmsg(sock, NULL, &data, &flags)) < 0) {
597 - sysErr("read (receivePacket)");
599 + fatal("receivePacket: getmsg: %m");
605 if ((*size = recv(sock, pkt, sizeof(PPPoEPacket), 0)) < 0) {
606 - sysErr("recv (receivePacket)");
608 + fatal("receivePacket: recv: %m");
615 if(strlen(ifname) > PATH_MAX) {
616 - rp_fatal("socket: string to long");
617 + fatal("openInterface: interface name too long");
620 ppa = atoi(&ifname[strlen(ifname)-1]);
622 if (( fd = open(base_dev, O_RDWR)) < 0) {
623 /* Give a more helpful message for the common error case */
624 if (errno == EPERM) {
625 - rp_fatal("Cannot create raw socket -- pppoe must be run as root.");
626 + fatal("Cannot create raw socket -- pppoe must be run as root.");
628 - fatalSys("socket");
629 + fatal("open(%s): %m", base_dev);
632 /* rearranged order of DLPI code - delphys 20010803 */
633 @@ -747,17 +713,18 @@
634 dl_abssaplen = ABS(dlp->info_ack.dl_sap_length);
635 dl_saplen = dlp->info_ack.dl_sap_length;
636 if (ETHERADDRL != (dlp->info_ack.dl_addr_length - dl_abssaplen))
637 - fatalSys("invalid destination physical address length");
638 + fatal("invalid destination physical address length");
639 dl_addrlen = dl_abssaplen + ETHERADDRL;
641 /* ethernet address retrieved as part of DL_INFO_ACK - delphys 20010803 */
642 memcpy(hwaddr, (u_char*)((char*)(dlp) + (int)(dlp->info_ack.dl_addr_offset)), ETHERADDRL);
644 if ( strioctl(fd, DLIOCRAW, -1, 0, NULL) < 0 ) {
645 - fatalSys("DLIOCRAW");
646 + fatal("DLIOCRAW: %m");
649 - if (ioctl(fd, I_FLUSH, FLUSHR) < 0) fatalSys("I_FLUSH");
650 + if (ioctl(fd, I_FLUSH, FLUSHR) < 0)
651 + fatal("I_FLUSH: %m");
658 if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
659 - fatalSys("dlpromiscon: putmsg");
660 + fatal("dlpromiscon: putmsg: %m");
667 if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
668 - fatalSys("dlinforeq: putmsg");
669 + fatal("dlinforeq: putmsg: %m");
672 void dlunitdatareq(int fd, u_char *addrp, int addrlen, u_long minpri, u_long maxpri, u_char *datap, int datalen)
674 data.buf = (char *) datap;
676 if (putmsg(fd, &ctl, &data, 0) < 0)
677 - fatalSys("dlunitdatareq: putmsg");
678 + fatal("dlunitdatareq: putmsg: %m");
681 void dlinfoack(int fd, char *bufp)
682 @@ -847,18 +814,14 @@
683 expecting(DL_INFO_ACK, dlp);
685 if (ctl.len < sizeof (dl_info_ack_t)) {
687 - sprintf(buffer, "dlinfoack: response ctl.len too short: %d", ctl.len);
689 + fatal("dlinfoack: response ctl.len too short: %d", ctl.len);
692 if (flags != RS_HIPRI)
693 - rp_fatal("dlinfoack: DL_INFO_ACK was not M_PCPROTO");
694 + fatal("dlinfoack: DL_INFO_ACK was not M_PCPROTO");
696 if (ctl.len < sizeof (dl_info_ack_t)) {
698 - sprintf(buffer, "dlinfoack: short response ctl.len: %d", ctl.len);
700 + fatal("dlinfoack: short response ctl.len: %d", ctl.len);
707 if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
708 - fatalSys("dlbindreq: putmsg");
709 + fatal("dlbindreq: putmsg: %m");
712 void dlattachreq(int fd, u_long ppa)
716 if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
717 - fatalSys("dlattachreq: putmsg");
718 + fatal("dlattachreq: putmsg: %m");
721 void dlokack(int fd, char *bufp)
722 @@ -921,18 +884,14 @@
723 expecting(DL_OK_ACK, dlp);
725 if (ctl.len < sizeof (dl_ok_ack_t)) {
727 - sprintf(buffer, "dlokack: response ctl.len too short: %d", ctl.len);
729 + fatal("dlokack: response ctl.len too short: %d", ctl.len);
732 if (flags != RS_HIPRI)
733 - rp_fatal("dlokack: DL_OK_ACK was not M_PCPROTO");
734 + fatal("dlokack: DL_OK_ACK was not M_PCPROTO");
736 if (ctl.len < sizeof (dl_ok_ack_t)) {
738 - sprintf(buffer, "dlokack: short response ctl.len: %d", ctl.len);
740 + fatal("dlokack: short response ctl.len: %d", ctl.len);
744 @@ -953,12 +912,10 @@
745 expecting(DL_BIND_ACK, dlp);
747 if (flags != RS_HIPRI)
748 - rp_fatal("dlbindack: DL_OK_ACK was not M_PCPROTO");
749 + fatal("dlbindack: DL_OK_ACK was not M_PCPROTO");
751 if (ctl.len < sizeof (dl_bind_ack_t)) {
753 - sprintf(buffer, "dlbindack: short response ctl.len: %d", ctl.len);
755 + fatal("dlbindack: short response ctl.len: %d", ctl.len);
761 (void) signal(SIGALRM, sigalrm);
762 if (alarm(MAXWAIT) < 0) {
763 - (void) sprintf(errmsg, "%s: alarm", caller);
765 + fatal("%s: alarm", caller);
769 @@ -998,61 +954,48 @@
772 if ((rc = getmsg(fd, ctlp, datap, flagsp)) < 0) {
773 - (void) sprintf(errmsg, "%s: getmsg", caller);
775 + fatal(errmsg, "%s: getmsg: %m", caller);
782 - (void) sprintf(errmsg, "%s: alarm", caller);
784 + fatal("%s: alarm", caller);
788 * Check for MOREDATA and/or MORECTL.
790 if ((rc & (MORECTL | MOREDATA)) == (MORECTL | MOREDATA)) {
792 - sprintf(buffer, "%s: MORECTL|MOREDATA", caller);
794 + fatal("%s: MORECTL|MOREDATA", caller);
799 - sprintf(buffer, "%s: MORECTL", caller);
801 + fatal("%s: MORECTL", caller);
806 - sprintf(buffer, "%s: MOREDATA", caller);
808 + fatal("%s: MOREDATA", caller);
812 * Check for at least sizeof (long) control data portion.
814 if (ctlp->len < sizeof (long)) {
816 - sprintf(buffer, "getmsg: control portion length < sizeof (long): %d", ctlp->len);
818 + fatal("getmsg: control portion length < sizeof (long): %d", ctlp->len);
822 void sigalrm(int sig)
824 - (void) rp_fatal("sigalrm: TIMEOUT");
825 + fatal("sigalrm: TIMEOUT");
828 void expecting(int prim, union DL_primitives *dlp)
830 if (dlp->dl_primitive != (u_long)prim) {
832 - sprintf(buffer, "expected %s got %s", dlprim(prim), dlprim(dlp->dl_primitive));
835 + fatal("expected %s got %s", dlprim(prim), dlprim(dlp->dl_primitive));
839 Index: ppp-2.4.3/pppd/plugins/rp-pppoe/Makefile.linux
840 ===================================================================
841 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/Makefile.linux 2007-06-04 13:22:08.408576984 +0200
842 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/Makefile.linux 2007-06-04 13:22:09.416423768 +0200
844 CFLAGS=$(COPTS) -I../../../include/linux
845 all: rp-pppoe.so pppoe-discovery
847 -pppoe-discovery: libplugin.a pppoe-discovery.o
848 - $(CC) -o pppoe-discovery pppoe-discovery.o libplugin.a
849 +pppoe-discovery: pppoe-discovery.o utils.o libplugin.a
850 + $(CC) -o pppoe-discovery pppoe-discovery.o utils.o libplugin.a
852 pppoe-discovery.o: pppoe-discovery.c
853 $(CC) $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o pppoe-discovery.o pppoe-discovery.c
854 Index: ppp-2.4.3/pppd/plugins/rp-pppoe/plugin.c
855 ===================================================================
856 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/plugin.c 2007-06-04 13:22:08.414576072 +0200
857 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/plugin.c 2007-06-04 13:22:09.417423616 +0200
859 #include "pppd/pathnames.h"
861 #include <linux/types.h>
863 #include <sys/ioctl.h>
864 #include <sys/types.h>
865 #include <sys/socket.h>
867 (unsigned) conn->peerEth[5]);
869 if (connect(conn->sessionSocket, (struct sockaddr *) &sp,
870 - sizeof(struct sockaddr_pppox)) < 0) {
871 + sizeof(struct sockaddr_pppox)) < 0)
872 fatal("Failed to connect PPPoE socket: %d %m", errno);
876 return conn->sessionSocket;
881 add_options(Options);
883 - info("RP-PPPoE plugin version %s compiled against pppd %s",
884 - RP_VERSION, VERSION);
888 /**********************************************************************
898 struct channel pppoe_channel = {
899 Index: ppp-2.4.3/pppd/plugins/rp-pppoe/pppoe-discovery.c
900 ===================================================================
901 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/pppoe-discovery.c 2007-06-04 13:22:08.420575160 +0200
902 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/pppoe-discovery.c 2007-06-04 13:22:09.417423616 +0200
907 -char *xstrdup(const char *s);
910 -void die(int status)
915 int main(int argc, char *argv[])
920 conn = malloc(sizeof(PPPoEConnection));
922 - fatalSys("malloc");
925 memset(conn, 0, sizeof(PPPoEConnection));
927 while ((opt = getopt(argc, argv, "I:D:VUAS:C:h")) > 0) {
930 - conn->serviceName = xstrdup(optarg);
931 + conn->serviceName = strDup(optarg);
934 - conn->acName = xstrdup(optarg);
935 + conn->acName = strDup(optarg);
938 conn->useHostUniq = 1;
940 fprintf(conn->debugFile, "pppoe-discovery %s\n", VERSION);
943 - conn->ifName = xstrdup(optarg);
944 + conn->ifName = strDup(optarg);
947 /* this is the default */
950 /* default interface name */
952 - conn->ifName = strdup("eth0");
953 + conn->ifName = strDup("eth0");
955 conn->discoverySocket = -1;
956 conn->sessionSocket = -1;
961 -void rp_fatal(char const *str)
966 - sprintf(buf, "pppoe-discovery: %.256s", str);
970 -void fatalSys(char const *str)
975 - sprintf(buf, "%.256s: %.256s", str, strerror(i));
977 - sprintf(buf, "pppoe-discovery: %.256s: %.256s", str, strerror(i));
981 -void sysErr(char const *str)
986 -char *xstrdup(const char *s)
988 - register char *ret = strdup(s);
996 fprintf(stderr, "Usage: pppoe-discovery [options]\n");
997 Index: ppp-2.4.3/pppd/plugins/rp-pppoe/pppoe.h
998 ===================================================================
999 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/pppoe.h 2007-06-04 13:22:08.426574248 +0200
1000 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/pppoe.h 2007-06-04 13:22:09.418423464 +0200
1001 @@ -307,12 +307,18 @@
1002 unsigned char *findTag(PPPoEPacket *packet, UINT16_t tagType,
1005 +void dbglog(char *, ...); /* log a debug message */
1006 +void info(char *, ...); /* log an informational message */
1007 +void warn(char *, ...); /* log a warning message */
1008 +void error(char *, ...); /* log an error message */
1009 +void fatal(char *, ...); /* log an error message and die(1) */
1011 #define SET_STRING(var, val) do { if (var) free(var); var = strDup(val); } while(0);
1013 #define CHECK_ROOM(cursor, start, len) \
1015 if (((cursor)-(start))+(len) > MAX_PPPOE_PAYLOAD) { \
1016 - syslog(LOG_ERR, "Would create too-long packet"); \
1017 + error("Would create too-long packet"); \
1021 Index: ppp-2.4.3/pppd/plugins/rp-pppoe/utils.c
1022 ===================================================================
1023 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1024 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/utils.c 2007-06-04 13:22:09.418423464 +0200
1027 +#include <stdlib.h>
1028 +#include <unistd.h>
1029 +#include <stdarg.h>
1030 +#include <syslog.h>
1032 +void dbglog(const char *fmt, ...)
1036 + va_start(ap, fmt);
1037 + vsyslog(LOG_DEBUG, fmt, ap);
1038 + vfprintf(stderr, fmt, ap);
1039 + fputs("\n", stderr);
1043 +void info(const char *fmt, ...)
1047 + va_start(ap, fmt);
1048 + vsyslog(LOG_INFO, fmt, ap);
1049 + vfprintf(stderr, fmt, ap);
1050 + fputs("\n", stderr);
1054 +void warn(const char *fmt, ...)
1058 + va_start(ap, fmt);
1059 + vsyslog(LOG_WARNING, fmt, ap);
1060 + vfprintf(stderr, fmt, ap);
1061 + fputs("\n", stderr);
1065 +void error(const char *fmt, ...)
1069 + va_start(ap, fmt);
1070 + vsyslog(LOG_ERR, fmt, ap);
1071 + vfprintf(stderr, fmt, ap);
1072 + fputs("\n", stderr);
1076 +void fatal(const char *fmt, ...)
1080 + va_start(ap, fmt);
1081 + vsyslog(LOG_ERR, fmt, ap);
1082 + vfprintf(stderr, fmt, ap);
1083 + fputs("\n", stderr);