1 diff -ruNp ppp-2.4.3.orig/pppd/plugins/rp-pppoe/common.c ppp-2.4.3/pppd/plugins/rp-pppoe/common.c
2 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/common.c 2004-02-02 04:36:46.000000000 +0100
3 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/common.c 2005-03-11 02:09:19.000000000 +0100
4 @@ -18,10 +18,6 @@ static char const RCSID[] =
15 @@ -50,17 +46,17 @@ parsePacket(PPPoEPacket *packet, ParseFu
16 UINT16_t tagType, tagLen;
18 if (packet->ver != 1) {
19 - syslog(LOG_ERR, "Invalid PPPoE version (%d)", (int) packet->ver);
20 + error("Invalid PPPoE version (%u)", packet->ver);
23 if (packet->type != 1) {
24 - syslog(LOG_ERR, "Invalid PPPoE type (%d)", (int) packet->type);
25 + error("Invalid PPPoE type (%u)", packet->type);
29 /* Do some sanity checks on packet */
30 if (len > ETH_DATA_LEN - 6) { /* 6-byte overhead for PPPoE header */
31 - syslog(LOG_ERR, "Invalid PPPoE packet length (%u)", len);
32 + error("Invalid PPPoE packet length (%u)", len);
36 @@ -76,7 +72,7 @@ parsePacket(PPPoEPacket *packet, ParseFu
39 if ((curTag - packet->payload) + tagLen + TAG_HDR_SIZE > len) {
40 - syslog(LOG_ERR, "Invalid PPPoE tag length (%u)", tagLen);
41 + error("Invalid PPPoE tag length (%u)", tagLen);
44 func(tagType, tagLen, curTag+TAG_HDR_SIZE, extra);
45 @@ -105,17 +101,17 @@ findTag(PPPoEPacket *packet, UINT16_t ty
46 UINT16_t tagType, tagLen;
48 if (packet->ver != 1) {
49 - syslog(LOG_ERR, "Invalid PPPoE version (%d)", (int) packet->ver);
50 + error("Invalid PPPoE version (%u)", packet->ver);
53 if (packet->type != 1) {
54 - syslog(LOG_ERR, "Invalid PPPoE type (%d)", (int) packet->type);
55 + error("Invalid PPPoE type (%u)", packet->type);
59 /* Do some sanity checks on packet */
60 if (len > ETH_DATA_LEN - 6) { /* 6-byte overhead for PPPoE header */
61 - syslog(LOG_ERR, "Invalid PPPoE packet length (%u)", len);
62 + error("Invalid PPPoE packet length (%u)", len);
66 @@ -131,7 +127,7 @@ findTag(PPPoEPacket *packet, UINT16_t ty
69 if ((curTag - packet->payload) + tagLen + TAG_HDR_SIZE > len) {
70 - syslog(LOG_ERR, "Invalid PPPoE tag length (%u)", tagLen);
71 + error("Invalid PPPoE tag length (%u)", tagLen);
74 if (tagType == type) {
75 @@ -143,6 +139,7 @@ findTag(PPPoEPacket *packet, UINT16_t ty
80 /**********************************************************************
83 @@ -158,6 +155,7 @@ printErr(char const *str)
84 fprintf(stderr, "pppoe: %s\n", str);
85 syslog(LOG_ERR, "%s", str);
90 /**********************************************************************
91 @@ -172,7 +170,7 @@ strDup(char const *str)
93 char *copy = malloc(strlen(str)+1);
95 - rp_fatal("strdup failed");
96 + fatal("strdup failed");
100 @@ -467,9 +465,10 @@ sendPADT(PPPoEConnection *conn, char con
101 fprintf(conn->debugFile, "\n");
102 fflush(conn->debugFile);
104 - syslog(LOG_INFO,"Sent PADT");
109 /**********************************************************************
110 *%FUNCTION: parseLogErrs
112 @@ -501,4 +500,5 @@ parseLogErrs(UINT16_t type, UINT16_t len
118 diff -ruNp ppp-2.4.3.orig/pppd/plugins/rp-pppoe/discovery.c ppp-2.4.3/pppd/plugins/rp-pppoe/discovery.c
119 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/discovery.c 2005-03-11 02:12:52.000000000 +0100
120 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/discovery.c 2005-03-10 12:24:19.000000000 +0100
121 @@ -13,10 +13,6 @@ static char const RCSID[] =
125 -#ifdef HAVE_SYSLOG_H
132 @@ -167,24 +163,21 @@ parsePADOTags(UINT16_t type, UINT16_t le
133 if (conn->printACNames) {
134 printf("Got a Service-Name-Error tag: %.*s\n", (int) len, data);
136 - syslog(LOG_ERR, "PADO: Service-Name-Error: %.*s", (int) len, data);
138 + fatal("PADO: Service-Name-Error: %.*s", (int) len, data);
141 case TAG_AC_SYSTEM_ERROR:
142 if (conn->printACNames) {
143 printf("Got a System-Error tag: %.*s\n", (int) len, data);
145 - syslog(LOG_ERR, "PADO: System-Error: %.*s", (int) len, data);
147 + fatal("PADO: System-Error: %.*s", (int) len, data);
150 case TAG_GENERIC_ERROR:
151 if (conn->printACNames) {
152 printf("Got a Generic-Error tag: %.*s\n", (int) len, data);
154 - syslog(LOG_ERR, "PADO: Generic-Error: %.*s", (int) len, data);
156 + fatal("PADO: Generic-Error: %.*s", (int) len, data);
160 @@ -209,20 +202,14 @@ parsePADSTags(UINT16_t type, UINT16_t le
161 PPPoEConnection *conn = (PPPoEConnection *) extra;
163 case TAG_SERVICE_NAME:
164 - syslog(LOG_DEBUG, "PADS: Service-Name: '%.*s'", (int) len, data);
165 + dbglog("PADS: Service-Name: '%.*s'", (int) len, data);
167 case TAG_SERVICE_NAME_ERROR:
168 - syslog(LOG_ERR, "PADS: Service-Name-Error: %.*s", (int) len, data);
169 - fprintf(stderr, "PADS: Service-Name-Error: %.*s\n", (int) len, data);
171 + fatal("PADS: Service-Name-Error: %.*s", (int) len, data);
172 case TAG_AC_SYSTEM_ERROR:
173 - syslog(LOG_ERR, "PADS: System-Error: %.*s", (int) len, data);
174 - fprintf(stderr, "PADS: System-Error: %.*s\n", (int) len, data);
176 + fatal("PADS: System-Error: %.*s", (int) len, data);
177 case TAG_GENERIC_ERROR:
178 - syslog(LOG_ERR, "PADS: Generic-Error: %.*s", (int) len, data);
179 - fprintf(stderr, "PADS: Generic-Error: %.*s\n", (int) len, data);
181 + fatal("PADS: Generic-Error: %.*s", (int) len, data);
182 case TAG_RELAY_SESSION_ID:
183 conn->relayId.type = htons(type);
184 conn->relayId.length = htons(len);
185 @@ -336,7 +323,7 @@ waitForPADO(PPPoEConnection *conn, int t
186 if (r >= 0 || errno != EINTR) break;
189 - fatalSys("select (waitForPADO)");
190 + fatal("waitForPADO: select: %m");
192 if (r == 0) return; /* Timed out */
194 @@ -346,8 +333,7 @@ waitForPADO(PPPoEConnection *conn, int t
197 if (ntohs(packet.length) + HDR_SIZE > len) {
198 - syslog(LOG_ERR, "Bogus PPPoE length field (%u)",
199 - (unsigned int) ntohs(packet.length));
200 + error("Bogus PPPoE length field (%u)", ntohs(packet.length));
204 @@ -366,16 +352,16 @@ waitForPADO(PPPoEConnection *conn, int t
206 if (packet.code == CODE_PADO) {
207 if (BROADCAST(packet.ethHdr.h_source)) {
208 - printErr("Ignoring PADO packet from broadcast MAC address");
209 + error("Ignoring PADO packet from broadcast MAC address");
212 parsePacket(&packet, parsePADOTags, &pc);
213 if (!pc.seenACName) {
214 - printErr("Ignoring PADO packet with no AC-Name tag");
215 + error("Ignoring PADO packet with no AC-Name tag");
218 if (!pc.seenServiceName) {
219 - printErr("Ignoring PADO packet with no Service-Name tag");
220 + error("Ignoring PADO packet with no Service-Name tag");
224 @@ -513,7 +499,7 @@ waitForPADS(PPPoEConnection *conn, int t
225 if (r >= 0 || errno != EINTR) break;
228 - fatalSys("select (waitForPADS)");
229 + fatal("waitForPADS: select: %m");
233 @@ -523,8 +509,7 @@ waitForPADS(PPPoEConnection *conn, int t
236 if (ntohs(packet.length) + HDR_SIZE > len) {
237 - syslog(LOG_ERR, "Bogus PPPoE length field (%u)",
238 - (unsigned int) ntohs(packet.length));
239 + error("Bogus PPPoE length field (%u)", ntohs(packet.length));
243 @@ -556,11 +541,12 @@ waitForPADS(PPPoEConnection *conn, int t
244 /* Don't bother with ntohs; we'll just end up converting it back... */
245 conn->session = packet.session;
247 - syslog(LOG_INFO, "PPP session is %d", (int) ntohs(conn->session));
248 + info("PPP session is %d", ntohs(conn->session));
250 /* RFC 2516 says session id MUST NOT be zero or 0xFFFF */
251 if (ntohs(conn->session) == 0 || ntohs(conn->session) == 0xFFFF) {
252 - syslog(LOG_ERR, "Access concentrator used a session value of %x -- the AC is violating RFC 2516", (unsigned int) ntohs(conn->session));
253 + error("Access concentrator used a session value of 0x%x"
254 + " -- the AC is violating RFC 2516", ntohs(conn->session));
258 @@ -620,7 +606,7 @@ discovery(PPPoEConnection *conn)
260 /* If we're only printing access concentrator names, we're done */
261 if (conn->printACNames) {
266 timeout = PADI_TIMEOUT;
267 diff -ruNp ppp-2.4.3.orig/pppd/plugins/rp-pppoe/if.c ppp-2.4.3/pppd/plugins/rp-pppoe/if.c
268 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/if.c 2001-12-14 03:55:20.000000000 +0100
269 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/if.c 2005-03-10 13:32:43.000000000 +0100
270 @@ -40,10 +40,6 @@ static char const RCSID[] =
271 #include <sys/ioctl.h>
274 -#ifdef HAVE_SYSLOG_H
281 @@ -127,7 +123,7 @@ etherType(PPPoEPacket *packet)
283 UINT16_t type = (UINT16_t) ntohs(packet->ethHdr.h_proto);
284 if (type != Eth_PPPOE_Discovery && type != Eth_PPPOE_Session) {
285 - syslog(LOG_ERR, "Invalid ether type 0x%x", type);
286 + error("Invalid ethernet type 0x%x", type);
290 @@ -156,7 +152,7 @@ getHWaddr(int sock, char const *ifname,
291 ifc.ifc_len = sizeof(inbuf);
293 if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) {
294 - fatalSys("SIOCGIFCONF");
295 + fatal("SIOCGIFCONF: %m");
298 ifreq.ifr_name[0] = '\0';
299 @@ -172,9 +168,7 @@ getHWaddr(int sock, char const *ifname,
300 (sdl->sdl_alen == ETH_ALEN) &&
301 !strncmp(ifname, ifr->ifr_name, sizeof(ifr->ifr_name))) {
304 - sprintf(buffer, "interface %.16s has more than one ethernet address", ifname);
306 + fatal("interface %s has more than one ethernet address", ifname);
309 memcpy(hwaddr, LLADDR(sdl), ETH_ALEN);
310 @@ -183,9 +177,7 @@ getHWaddr(int sock, char const *ifname,
315 - sprintf(buffer, "interface %.16s has no ethernet address", ifname);
317 + fatal("interface %s has no ethernet address", ifname);
321 @@ -252,7 +244,7 @@ initFilter(int fd, UINT16_t type, unsign
323 /* Apply the filter */
324 if (ioctl(fd, BIOCSETF, &bpfProgram) < 0) {
325 - fatalSys("ioctl(BIOCSETF)");
326 + fatal("ioctl(BIOCSETF): %m");
330 @@ -298,42 +290,36 @@ openInterface(char const *ifname, UINT16
333 case EACCES: /* permission denied */
336 - sprintf(buffer, "Cannot open %.32s -- pppoe must be run as root.", bpfName);
339 + fatal("Cannot open %s -- pppoe must be run as root.", bpfName);
342 case ENOENT: /* no such file */
344 - rp_fatal("No /dev/bpf* devices (check your kernel configuration for BPF support)");
345 + fatal("No /dev/bpf* devices (check your kernel configuration for BPF support)");
347 - rp_fatal("All /dev/bpf* devices are in use");
348 + fatal("All /dev/bpf* devices are in use");
353 + fatal("%s: %m", bpfName);
356 if ((sock = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) {
357 - fatalSys("socket");
358 + fatal("socket: %m");
361 /* Check that the interface is up */
362 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
363 if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) {
364 - fatalSys("ioctl(SIOCGIFFLAGS)");
365 + fatal("ioctl(SIOCGIFFLAGS): %m");
367 if ((ifr.ifr_flags & IFF_UP) == 0) {
369 - sprintf(buffer, "Interface %.16s is not up\n", ifname);
371 + fatal("Interface %s is not up", ifname);
374 /* Fill in hardware address and initialize the packet filter rules */
375 if (hwaddr == NULL) {
376 - rp_fatal("openInterface: no hwaddr arg.");
377 + fatal("openInterface: no hwaddr arg.");
379 getHWaddr(sock, ifname, hwaddr);
380 initFilter(fd, type, hwaddr);
381 @@ -342,58 +328,52 @@ openInterface(char const *ifname, UINT16
382 #if !defined(__OpenBSD__)
383 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
384 if (ioctl(sock, SIOCGIFMTU, &ifr) < 0) {
385 - fatalSys("ioctl(SIOCGIFMTU)");
386 + fatal("ioctl(SIOCGIFMTU): %m");
388 if (ifr.ifr_mtu < ETH_DATA_LEN) {
390 - sprintf(buffer, "Interface %.16s has MTU of %d -- should be %d. You may have serious connection problems.",
391 + error("Interface %s has MTU of %d -- should be %d."
392 + " You may have serious connection problems.",
393 ifname, ifr.ifr_mtu, ETH_DATA_LEN);
398 /* done with the socket */
399 if (close(sock) < 0) {
401 + fatal("close: %m");
404 /* Check the BPF version number */
405 if (ioctl(fd, BIOCVERSION, &bpf_ver) < 0) {
406 - fatalSys("ioctl(BIOCVERSION)");
407 + fatal("ioctl(BIOCVERSION): %m");
409 if ((bpf_ver.bv_major != BPF_MAJOR_VERSION) ||
410 (bpf_ver.bv_minor < BPF_MINOR_VERSION)) {
412 - sprintf(buffer, "Unsupported BPF version: %d.%d (kernel: %d.%d)",
413 + fatal("Unsupported BPF version: %d.%d (kernel: %d.%d)",
414 BPF_MAJOR_VERSION, BPF_MINOR_VERSION,
415 bpf_ver.bv_major, bpf_ver.bv_minor);
419 /* allocate a receive packet buffer */
420 if (ioctl(fd, BIOCGBLEN, &bpfLength) < 0) {
421 - fatalSys("ioctl(BIOCGBLEN)");
422 + fatal("ioctl(BIOCGBLEN): %m");
424 if (!(bpfBuffer = (unsigned char *) malloc(bpfLength))) {
425 - rp_fatal("malloc");
429 /* reads should return as soon as there is a packet available */
431 if (ioctl(fd, BIOCIMMEDIATE, &optval) < 0) {
432 - fatalSys("ioctl(BIOCIMMEDIATE)");
433 + fatal("ioctl(BIOCIMMEDIATE): %m");
436 /* Bind the interface to the filter */
437 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
438 if (ioctl(fd, BIOCSETIF, &ifr) < 0) {
440 - sprintf(buffer, "ioctl(BIOCSETIF) can't select interface %.16s",
443 + fatal("ioctl(BIOCSETIF) can't select interface %s: %m", ifname);
446 - syslog(LOG_INFO, "Interface=%.16s HWaddr=%02X:%02X:%02X:%02X:%02X:%02X Device=%.32s Buffer size=%d",
447 + info("Interface=%s HWaddr=%02X:%02X:%02X:%02X:%02X:%02X Device=%s Buffer size=%d",
449 hwaddr[0], hwaddr[1], hwaddr[2],
450 hwaddr[3], hwaddr[4], hwaddr[5],
451 @@ -442,48 +422,41 @@ openInterface(char const *ifname, UINT16
452 if ((fd = socket(domain, stype, htons(type))) < 0) {
453 /* Give a more helpful message for the common error case */
454 if (errno == EPERM) {
455 - rp_fatal("Cannot create raw socket -- pppoe must be run as root.");
456 + fatal("Cannot create raw socket -- pppoe must be run as root.");
458 - fatalSys("socket");
459 + fatal("cannot create the raw socket: %m");
462 if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) < 0) {
463 - fatalSys("setsockopt");
464 + fatal("setsockopt(SOL_SOCKET, SO_BROADCAST): %m");
467 /* Fill in hardware address */
469 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
470 - if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) {
471 - fatalSys("ioctl(SIOCGIFHWADDR)");
473 + if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0)
474 + fatal("ioctl(SIOCGIFHWADDR): %m");
475 memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
477 if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
479 - sprintf(buffer, "Interface %.16s is not Ethernet", ifname);
481 + fatal("Interface %s is not Ethernet", ifname);
484 if (NOT_UNICAST(hwaddr)) {
487 - "Interface %.16s has broadcast/multicast MAC address??",
488 + fatal("Interface %s has broadcast/multicast MAC address",
494 /* Sanity check on MTU */
495 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
496 if (ioctl(fd, SIOCGIFMTU, &ifr) < 0) {
497 - fatalSys("ioctl(SIOCGIFMTU)");
498 + fatal("ioctl(SIOCGIFMTU): %m");
500 if (ifr.ifr_mtu < ETH_DATA_LEN) {
502 - sprintf(buffer, "Interface %.16s has MTU of %d -- should be %d. You may have serious connection problems.",
503 + error("Interface %s has MTU of %d -- should be %d."
504 + " You may have serious connection problems.",
505 ifname, ifr.ifr_mtu, ETH_DATA_LEN);
509 #ifdef HAVE_STRUCT_SOCKADDR_LL
510 @@ -493,7 +466,7 @@ openInterface(char const *ifname, UINT16
512 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
513 if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) {
514 - fatalSys("ioctl(SIOCFIGINDEX): Could not get interface index");
515 + fatal("ioctl(SIOCFIGINDEX): Could not get interface index: %m");
517 sa.sll_ifindex = ifr.ifr_ifindex;
519 @@ -503,7 +476,7 @@ openInterface(char const *ifname, UINT16
521 /* We're only interested in packets on specified interface */
522 if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
528 @@ -527,13 +500,11 @@ sendPacket(PPPoEConnection *conn, int so
531 if (write(sock, pkt, size) < 0) {
532 - sysErr("write (sendPacket)");
534 + fatal("sendPacket: write: %m");
536 #elif defined(HAVE_STRUCT_SOCKADDR_LL)
537 if (send(sock, pkt, size, 0) < 0) {
538 - sysErr("send (sendPacket)");
540 + fatal("sendPacket: send: %m");
544 @@ -577,12 +548,11 @@ sendPacket(PPPoEConnection *conn, int so
548 - rp_fatal("relay and server not supported on Linux 2.0 kernels");
549 + fatal("relay and server not supported on Linux 2.0 kernels");
551 strcpy(sa.sa_data, conn->ifName);
552 if (sendto(sock, pkt, size, 0, &sa, sizeof(sa)) < 0) {
553 - sysErr("sendto (sendPacket)");
555 + fatal("sendPacket: sendto: %m");
559 @@ -632,26 +602,24 @@ receivePacket(int sock, PPPoEPacket *pkt
562 if ((bpfSize = read(sock, bpfBuffer, bpfLength)) < 0) {
563 - sysErr("read (receivePacket)");
565 + fatal("receivePacket: read: %m");
568 if (bpfSize < sizeof(hdr)) {
569 - syslog(LOG_ERR, "Truncated bpf packet header: len=%d", bpfSize);
570 + error("Truncated bpf packet header: len=%d", bpfSize);
571 clearPacketHeader(pkt); /* resets bpfSize and bpfOffset */
574 memcpy(&hdr, bpfBuffer + bpfOffset, sizeof(hdr));
575 if (hdr.bh_caplen != hdr.bh_datalen) {
576 - syslog(LOG_ERR, "Truncated bpf packet: caplen=%d, datalen=%d",
577 + error("Truncated bpf packet: caplen=%d, datalen=%d",
578 hdr.bh_caplen, hdr.bh_datalen);
579 clearPacketHeader(pkt); /* resets bpfSize and bpfOffset */
582 seglen = hdr.bh_hdrlen + hdr.bh_caplen;
583 if (seglen > bpfSize) {
584 - syslog(LOG_ERR, "Truncated bpf packet: seglen=%d, bpfSize=%d",
586 + error("Truncated bpf packet: seglen=%d, bpfSize=%d", seglen, bpfSize);
587 clearPacketHeader(pkt); /* resets bpfSize and bpfOffset */
590 @@ -676,16 +644,14 @@ receivePacket(int sock, PPPoEPacket *pkt
593 if ((retval = getmsg(sock, NULL, &data, &flags)) < 0) {
594 - sysErr("read (receivePacket)");
596 + fatal("receivePacket: getmsg: %m");
602 if ((*size = recv(sock, pkt, sizeof(PPPoEPacket), 0)) < 0) {
603 - sysErr("recv (receivePacket)");
605 + fatal("receivePacket: recv: %m");
609 @@ -716,7 +682,7 @@ openInterface(char const *ifname, UINT16
612 if(strlen(ifname) > PATH_MAX) {
613 - rp_fatal("socket: string to long");
614 + fatal("openInterface: interface name too long");
617 ppa = atoi(&ifname[strlen(ifname)-1]);
618 @@ -729,9 +695,9 @@ openInterface(char const *ifname, UINT16
619 if (( fd = open(base_dev, O_RDWR)) < 0) {
620 /* Give a more helpful message for the common error case */
621 if (errno == EPERM) {
622 - rp_fatal("Cannot create raw socket -- pppoe must be run as root.");
623 + fatal("Cannot create raw socket -- pppoe must be run as root.");
625 - fatalSys("socket");
626 + fatal("open(%s): %m", base_dev);
629 /* rearranged order of DLPI code - delphys 20010803 */
630 @@ -747,17 +713,18 @@ openInterface(char const *ifname, UINT16
631 dl_abssaplen = ABS(dlp->info_ack.dl_sap_length);
632 dl_saplen = dlp->info_ack.dl_sap_length;
633 if (ETHERADDRL != (dlp->info_ack.dl_addr_length - dl_abssaplen))
634 - fatalSys("invalid destination physical address length");
635 + fatal("invalid destination physical address length");
636 dl_addrlen = dl_abssaplen + ETHERADDRL;
638 /* ethernet address retrieved as part of DL_INFO_ACK - delphys 20010803 */
639 memcpy(hwaddr, (u_char*)((char*)(dlp) + (int)(dlp->info_ack.dl_addr_offset)), ETHERADDRL);
641 if ( strioctl(fd, DLIOCRAW, -1, 0, NULL) < 0 ) {
642 - fatalSys("DLIOCRAW");
643 + fatal("DLIOCRAW: %m");
646 - if (ioctl(fd, I_FLUSH, FLUSHR) < 0) fatalSys("I_FLUSH");
647 + if (ioctl(fd, I_FLUSH, FLUSHR) < 0)
648 + fatal("I_FLUSH: %m");
652 @@ -780,7 +747,7 @@ void dlpromisconreq(int fd, u_long level
655 if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
656 - fatalSys("dlpromiscon: putmsg");
657 + fatal("dlpromiscon: putmsg: %m");
661 @@ -799,7 +766,7 @@ void dlinforeq(int fd)
664 if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
665 - fatalSys("dlinforeq: putmsg");
666 + fatal("dlinforeq: putmsg: %m");
669 void dlunitdatareq(int fd, u_char *addrp, int addrlen, u_long minpri, u_long maxpri, u_char *datap, int datalen)
670 @@ -827,7 +794,7 @@ void dlunitdatareq(int fd, u_char *addrp
671 data.buf = (char *) datap;
673 if (putmsg(fd, &ctl, &data, 0) < 0)
674 - fatalSys("dlunitdatareq: putmsg");
675 + fatal("dlunitdatareq: putmsg: %m");
678 void dlinfoack(int fd, char *bufp)
679 @@ -847,18 +814,14 @@ void dlinfoack(int fd, char *bufp)
680 expecting(DL_INFO_ACK, dlp);
682 if (ctl.len < sizeof (dl_info_ack_t)) {
684 - sprintf(buffer, "dlinfoack: response ctl.len too short: %d", ctl.len);
686 + fatal("dlinfoack: response ctl.len too short: %d", ctl.len);
689 if (flags != RS_HIPRI)
690 - rp_fatal("dlinfoack: DL_INFO_ACK was not M_PCPROTO");
691 + fatal("dlinfoack: DL_INFO_ACK was not M_PCPROTO");
693 if (ctl.len < sizeof (dl_info_ack_t)) {
695 - sprintf(buffer, "dlinfoack: short response ctl.len: %d", ctl.len);
697 + fatal("dlinfoack: short response ctl.len: %d", ctl.len);
701 @@ -882,7 +845,7 @@ void dlbindreq(int fd, u_long sap, u_lon
704 if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
705 - fatalSys("dlbindreq: putmsg");
706 + fatal("dlbindreq: putmsg: %m");
709 void dlattachreq(int fd, u_long ppa)
710 @@ -901,7 +864,7 @@ void dlattachreq(int fd, u_long ppa)
713 if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
714 - fatalSys("dlattachreq: putmsg");
715 + fatal("dlattachreq: putmsg: %m");
718 void dlokack(int fd, char *bufp)
719 @@ -921,18 +884,14 @@ void dlokack(int fd, char *bufp)
720 expecting(DL_OK_ACK, dlp);
722 if (ctl.len < sizeof (dl_ok_ack_t)) {
724 - sprintf(buffer, "dlokack: response ctl.len too short: %d", ctl.len);
726 + fatal("dlokack: response ctl.len too short: %d", ctl.len);
729 if (flags != RS_HIPRI)
730 - rp_fatal("dlokack: DL_OK_ACK was not M_PCPROTO");
731 + fatal("dlokack: DL_OK_ACK was not M_PCPROTO");
733 if (ctl.len < sizeof (dl_ok_ack_t)) {
735 - sprintf(buffer, "dlokack: short response ctl.len: %d", ctl.len);
737 + fatal("dlokack: short response ctl.len: %d", ctl.len);
741 @@ -953,12 +912,10 @@ void dlbindack(int fd, char *bufp)
742 expecting(DL_BIND_ACK, dlp);
744 if (flags != RS_HIPRI)
745 - rp_fatal("dlbindack: DL_OK_ACK was not M_PCPROTO");
746 + fatal("dlbindack: DL_OK_ACK was not M_PCPROTO");
748 if (ctl.len < sizeof (dl_bind_ack_t)) {
750 - sprintf(buffer, "dlbindack: short response ctl.len: %d", ctl.len);
752 + fatal("dlbindack: short response ctl.len: %d", ctl.len);
756 @@ -989,8 +946,7 @@ void strgetmsg(int fd, struct strbuf *ct
758 (void) signal(SIGALRM, sigalrm);
759 if (alarm(MAXWAIT) < 0) {
760 - (void) sprintf(errmsg, "%s: alarm", caller);
762 + fatal("%s: alarm", caller);
766 @@ -998,61 +954,48 @@ void strgetmsg(int fd, struct strbuf *ct
769 if ((rc = getmsg(fd, ctlp, datap, flagsp)) < 0) {
770 - (void) sprintf(errmsg, "%s: getmsg", caller);
772 + fatal(errmsg, "%s: getmsg: %m", caller);
779 - (void) sprintf(errmsg, "%s: alarm", caller);
781 + fatal("%s: alarm", caller);
785 * Check for MOREDATA and/or MORECTL.
787 if ((rc & (MORECTL | MOREDATA)) == (MORECTL | MOREDATA)) {
789 - sprintf(buffer, "%s: MORECTL|MOREDATA", caller);
791 + fatal("%s: MORECTL|MOREDATA", caller);
796 - sprintf(buffer, "%s: MORECTL", caller);
798 + fatal("%s: MORECTL", caller);
803 - sprintf(buffer, "%s: MOREDATA", caller);
805 + fatal("%s: MOREDATA", caller);
809 * Check for at least sizeof (long) control data portion.
811 if (ctlp->len < sizeof (long)) {
813 - sprintf(buffer, "getmsg: control portion length < sizeof (long): %d", ctlp->len);
815 + fatal("getmsg: control portion length < sizeof (long): %d", ctlp->len);
819 void sigalrm(int sig)
821 - (void) rp_fatal("sigalrm: TIMEOUT");
822 + fatal("sigalrm: TIMEOUT");
825 void expecting(int prim, union DL_primitives *dlp)
827 if (dlp->dl_primitive != (u_long)prim) {
829 - sprintf(buffer, "expected %s got %s", dlprim(prim), dlprim(dlp->dl_primitive));
832 + fatal("expected %s got %s", dlprim(prim), dlprim(dlp->dl_primitive));
836 diff -ruNp ppp-2.4.3.orig/pppd/plugins/rp-pppoe/Makefile.linux ppp-2.4.3/pppd/plugins/rp-pppoe/Makefile.linux
837 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/Makefile.linux 2004-11-14 08:58:37.000000000 +0100
838 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/Makefile.linux 2005-03-11 01:48:27.000000000 +0100
839 @@ -28,8 +28,8 @@ COPTS=-O2 -g
840 CFLAGS=$(COPTS) -I../../../include/linux
841 all: rp-pppoe.so pppoe-discovery
843 -pppoe-discovery: libplugin.a pppoe-discovery.o
844 - $(CC) -o pppoe-discovery pppoe-discovery.o libplugin.a
845 +pppoe-discovery: pppoe-discovery.o utils.o libplugin.a
846 + $(CC) -o pppoe-discovery pppoe-discovery.o utils.o libplugin.a
848 pppoe-discovery.o: pppoe-discovery.c
849 $(CC) $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o pppoe-discovery.o pppoe-discovery.c
850 diff -ruNp ppp-2.4.3.orig/pppd/plugins/rp-pppoe/plugin.c ppp-2.4.3/pppd/plugins/rp-pppoe/plugin.c
851 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/plugin.c 2004-11-04 11:07:37.000000000 +0100
852 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/plugin.c 2005-03-11 02:12:39.000000000 +0100
853 @@ -35,7 +35,6 @@ static char const RCSID[] =
854 #include "pppd/pathnames.h"
856 #include <linux/types.h>
858 #include <sys/ioctl.h>
859 #include <sys/types.h>
860 #include <sys/socket.h>
861 @@ -173,10 +172,8 @@ PPPOEConnectDevice(void)
862 (unsigned) conn->peerEth[5]);
864 if (connect(conn->sessionSocket, (struct sockaddr *) &sp,
865 - sizeof(struct sockaddr_pppox)) < 0) {
866 + sizeof(struct sockaddr_pppox)) < 0)
867 fatal("Failed to connect PPPoE socket: %d %m", errno);
871 return conn->sessionSocket;
873 @@ -365,11 +362,9 @@ plugin_init(void)
876 add_options(Options);
878 - info("RP-PPPoE plugin version %s compiled against pppd %s",
879 - RP_VERSION, VERSION);
883 /**********************************************************************
886 @@ -423,6 +418,7 @@ sysErr(char const *str)
893 struct channel pppoe_channel = {
894 diff -ruNp ppp-2.4.3.orig/pppd/plugins/rp-pppoe/pppoe-discovery.c ppp-2.4.3/pppd/plugins/rp-pppoe/pppoe-discovery.c
895 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/pppoe-discovery.c 2004-11-13 13:12:05.000000000 +0100
896 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/pppoe-discovery.c 2005-03-11 02:06:13.000000000 +0100
901 -char *xstrdup(const char *s);
904 -void die(int status)
909 int main(int argc, char *argv[])
912 @@ -32,17 +26,17 @@ int main(int argc, char *argv[])
914 conn = malloc(sizeof(PPPoEConnection));
916 - fatalSys("malloc");
919 memset(conn, 0, sizeof(PPPoEConnection));
921 while ((opt = getopt(argc, argv, "I:D:VUAS:C:h")) > 0) {
924 - conn->serviceName = xstrdup(optarg);
925 + conn->serviceName = strDup(optarg);
928 - conn->acName = xstrdup(optarg);
929 + conn->acName = strDup(optarg);
932 conn->useHostUniq = 1;
933 @@ -57,7 +51,7 @@ int main(int argc, char *argv[])
934 fprintf(conn->debugFile, "pppoe-discovery %s\n", VERSION);
937 - conn->ifName = xstrdup(optarg);
938 + conn->ifName = strDup(optarg);
941 /* this is the default */
942 @@ -74,7 +68,7 @@ int main(int argc, char *argv[])
944 /* default interface name */
946 - conn->ifName = strdup("eth0");
947 + conn->ifName = strDup("eth0");
949 conn->discoverySocket = -1;
950 conn->sessionSocket = -1;
951 @@ -84,39 +78,6 @@ int main(int argc, char *argv[])
955 -void rp_fatal(char const *str)
960 - sprintf(buf, "pppoe-discovery: %.256s", str);
964 -void fatalSys(char const *str)
969 - sprintf(buf, "%.256s: %.256s", str, strerror(i));
971 - sprintf(buf, "pppoe-discovery: %.256s: %.256s", str, strerror(i));
975 -void sysErr(char const *str)
980 -char *xstrdup(const char *s)
982 - register char *ret = strdup(s);
990 fprintf(stderr, "Usage: pppoe-discovery [options]\n");
991 diff -ruNp ppp-2.4.3.orig/pppd/plugins/rp-pppoe/pppoe.h ppp-2.4.3/pppd/plugins/rp-pppoe/pppoe.h
992 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/pppoe.h 2004-11-04 11:07:37.000000000 +0100
993 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/pppoe.h 2005-03-11 02:08:00.000000000 +0100
994 @@ -307,12 +307,18 @@ void discovery(PPPoEConnection *conn);
995 unsigned char *findTag(PPPoEPacket *packet, UINT16_t tagType,
998 +void dbglog(char *, ...); /* log a debug message */
999 +void info(char *, ...); /* log an informational message */
1000 +void warn(char *, ...); /* log a warning message */
1001 +void error(char *, ...); /* log an error message */
1002 +void fatal(char *, ...); /* log an error message and die(1) */
1004 #define SET_STRING(var, val) do { if (var) free(var); var = strDup(val); } while(0);
1006 #define CHECK_ROOM(cursor, start, len) \
1008 if (((cursor)-(start))+(len) > MAX_PPPOE_PAYLOAD) { \
1009 - syslog(LOG_ERR, "Would create too-long packet"); \
1010 + error("Would create too-long packet"); \
1014 diff -ruNp ppp-2.4.3.orig/pppd/plugins/rp-pppoe/utils.c ppp-2.4.3/pppd/plugins/rp-pppoe/utils.c
1015 --- ppp-2.4.3.orig/pppd/plugins/rp-pppoe/utils.c 1970-01-01 01:00:00.000000000 +0100
1016 +++ ppp-2.4.3/pppd/plugins/rp-pppoe/utils.c 2005-03-11 02:07:57.000000000 +0100
1019 +#include <stdlib.h>
1020 +#include <unistd.h>
1021 +#include <stdarg.h>
1022 +#include <syslog.h>
1024 +void dbglog(const char *fmt, ...)
1028 + va_start(ap, fmt);
1029 + vsyslog(LOG_DEBUG, fmt, ap);
1030 + vfprintf(stderr, fmt, ap);
1031 + fputs("\n", stderr);
1035 +void info(const char *fmt, ...)
1039 + va_start(ap, fmt);
1040 + vsyslog(LOG_INFO, fmt, ap);
1041 + vfprintf(stderr, fmt, ap);
1042 + fputs("\n", stderr);
1046 +void warn(const char *fmt, ...)
1050 + va_start(ap, fmt);
1051 + vsyslog(LOG_WARNING, fmt, ap);
1052 + vfprintf(stderr, fmt, ap);
1053 + fputs("\n", stderr);
1057 +void error(const char *fmt, ...)
1061 + va_start(ap, fmt);
1062 + vsyslog(LOG_ERR, fmt, ap);
1063 + vfprintf(stderr, fmt, ap);
1064 + fputs("\n", stderr);
1068 +void fatal(const char *fmt, ...)
1072 + va_start(ap, fmt);
1073 + vsyslog(LOG_ERR, fmt, ap);
1074 + vfprintf(stderr, fmt, ap);
1075 + fputs("\n", stderr);