]> git.pld-linux.org Git - packages/ppp.git/blob - ppp-rp-pppoe-update.patch
- obsolete
[packages/ppp.git] / ppp-rp-pppoe-update.patch
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
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>
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 -
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
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
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
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  
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;
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 @@ -641,4 +640,3 @@
167      conn->discoveryState = STATE_SESSION;
168      return;
169  }
170 -
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
174 @@ -11,10 +11,12 @@
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.
177  *
178 +* LIC: GPL
179 +*
180  ***********************************************************************/
181  
182  static char const RCSID[] =
183 -"$Id$";
184 +"$Id$";
185  
186  #include "pppoe.h"
187  
188 @@ -87,7 +89,7 @@
189  
190  static int     dl_abssaplen;
191  static int     dl_saplen;
192 -static int     dl_addrlen;
193 +static int     dl_addrlen;
194  
195  #endif
196  
197 @@ -169,7 +171,7 @@
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))) {
204                 if (found) {
205                     char buffer[256];
206 @@ -177,14 +179,14 @@
207                     rp_fatal(buffer);
208                 } else {
209                     found = 1;
210 -                   memcpy(hwaddr, LLADDR(sdl), ETH_ALEN);
211 +                   memcpy(hwaddr, LLADDR(sdl), ETH_ALEN);
212                 }
213             }
214         }
215      }
216      if (!found) {
217         char buffer[256];
218 -        sprintf(buffer, "interface %.16s has no ethernet address", ifname);
219 +       sprintf(buffer, "interface %.16s has no ethernet address", ifname);
220         rp_fatal(buffer);
221      }
222  }
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 */
257      };
258  
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];
272 -      
273 +
274        /* Apply the filter */
275        if (ioctl(fd, BIOCSETF, &bpfProgram) < 0) {
276         fatalSys("ioctl(BIOCSETF)");
277 @@ -362,9 +364,9 @@
278         fatalSys("ioctl(BIOCVERSION)");
279      }
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)) {
283         char buffer[256];
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);
288         rp_fatal(buffer);
289 @@ -394,7 +396,7 @@
290      }
291  
292      syslog(LOG_INFO, "Interface=%.16s HWaddr=%02X:%02X:%02X:%02X:%02X:%02X Device=%.32s Buffer size=%d",
293 -          ifname, 
294 +          ifname,
295            hwaddr[0], hwaddr[1], hwaddr[2],
296            hwaddr[3], hwaddr[4], hwaddr[5],
297            bpfName, bpfLength);
298 @@ -548,12 +550,12 @@
299  
300         short   tmp_sap;
301  
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);
306  
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);
311  
312         if (dl_saplen > 0) {  /* order is sap+phys */
313                 (void) memcpy((char*)addr, (char*)&sap, dl_abssaplen);
314 @@ -564,7 +566,7 @@
315         }
316  
317  #ifdef DL_DEBUG
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],
321                 addr[6],addr[7]);
322  #endif
323 @@ -667,20 +669,20 @@
324      }
325  #else
326  #ifdef USE_DLPI
327 -       struct strbuf data; 
328 -       int flags = 0;  
329 -       int retval; 
330 -
331 -       data.buf = (char *) pkt; 
332 -       data.maxlen = MAXDLBUF; 
333 -       data.len = 0; 
334 -       
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         if ((retval = getmsg(sock, NULL, &data, &flags)) < 0) {
344             sysErr("read (receivePacket)");
345             return -1;
346         }
347  
348 -       *size = data.len; 
349 +       *size = data.len;
350  
351  #else
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)
355  {
356      int fd;
357 -    long buf[MAXDLBUF]; 
358 +    long buf[MAXDLBUF];
359  
360         union   DL_primitives   *dlp;
361  
362 -    char base_dev[PATH_MAX]; 
363 -    int ppa; 
364 +    char base_dev[PATH_MAX];
365 +    int ppa;
366  
367      if(strlen(ifname) > PATH_MAX) {
368 -       rp_fatal("socket: string to long"); 
369 +       rp_fatal("socket: Interface name too long");
370 +    }
371 +
372 +    if (strlen(ifname) < 2) {
373 +       rp_fatal("socket: Interface name too short");
374      }
375  
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';
381  
382  /* rearranged order of DLPI code - delphys 20010803 */
383      dlp = (union DL_primitives*) buf;
384  
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.");
390         }
391 +       /* Common error is to omit /dev/ */
392 +       if (errno == ENOENT) {
393 +           char ifname[512];
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.");
398 +               }
399 +           }
400 +       }
401 +    }
402 +    if (fd < 0) {
403         fatalSys("socket");
404      }
405  
406  /* rearranged order of DLPI code - delphys 20010803 */
407 -    dlattachreq(fd, ppa); 
408 +    dlattachreq(fd, ppa);
409      dlokack(fd, (char *)buf);
410  
411      dlbindreq(fd, type, 0, DL_CLDLS, 0, 0);
412 @@ -753,8 +771,8 @@
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);
415  
416 -    if ( strioctl(fd, DLIOCRAW, -1, 0, NULL) < 0 ) { 
417 -       fatalSys("DLIOCRAW"); 
418 +    if ( strioctl(fd, DLIOCRAW, -1, 0, NULL) < 0 ) {
419 +       fatalSys("DLIOCRAW");
420      }
421  
422      if (ioctl(fd, I_FLUSH, FLUSHR) < 0) fatalSys("I_FLUSH");
423 @@ -766,332 +784,332 @@
424  
425  void dlpromisconreq(int fd, u_long level)
426  {
427 -        dl_promiscon_req_t      promiscon_req;
428 -        struct  strbuf  ctl;
429 -        int     flags;
430 +       dl_promiscon_req_t      promiscon_req;
431 +       struct  strbuf  ctl;
432 +       int     flags;
433  
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;
438  
439 -        ctl.maxlen = 0;
440 -        ctl.len = sizeof (promiscon_req);
441 -        ctl.buf = (char *) &promiscon_req;
442 +       ctl.maxlen = 0;
443 +       ctl.len = sizeof (promiscon_req);
444 +       ctl.buf = (char *) &promiscon_req;
445  
446 -        flags = 0;
447 +       flags = 0;
448  
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");
453  
454  }
455  
456  void dlinforeq(int fd)
457  {
458 -        dl_info_req_t   info_req;
459 -        struct  strbuf  ctl;
460 -        int     flags;
461 +       dl_info_req_t   info_req;
462 +       struct  strbuf  ctl;
463 +       int     flags;
464  
465 -        info_req.dl_primitive = DL_INFO_REQ;
466 +       info_req.dl_primitive = DL_INFO_REQ;
467  
468 -        ctl.maxlen = 0;
469 -        ctl.len = sizeof (info_req);
470 -        ctl.buf = (char *) &info_req;
471 +       ctl.maxlen = 0;
472 +       ctl.len = sizeof (info_req);
473 +       ctl.buf = (char *) &info_req;
474  
475 -        flags = RS_HIPRI;
476 +       flags = RS_HIPRI;
477  
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");
482  }
483  
484  void dlunitdatareq(int fd, u_char *addrp, int addrlen, u_long minpri, u_long maxpri, u_char *datap, int datalen)
485  {
486 -        long    buf[MAXDLBUF];
487 -        union   DL_primitives   *dlp;
488 -        struct  strbuf  data, ctl;
489 -
490 -        dlp = (union DL_primitives*) buf;
491 -
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;
497 -
498 -        (void) memcpy(OFFADDR(dlp, sizeof (dl_unitdata_req_t)), addrp, addrlen);
499 -
500 -        ctl.maxlen = 0;
501 -        ctl.len = sizeof (dl_unitdata_req_t) + addrlen;
502 -        ctl.buf = (char *) buf;
503 -
504 -        data.maxlen = 0;
505 -        data.len = datalen;
506 -        data.buf = (char *) datap;
507 +       long    buf[MAXDLBUF];
508 +       union   DL_primitives   *dlp;
509 +       struct  strbuf  data, ctl;
510 +
511 +       dlp = (union DL_primitives*) buf;
512 +
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;
518 +
519 +       (void) memcpy(OFFADDR(dlp, sizeof (dl_unitdata_req_t)), addrp, addrlen);
520  
521 -        if (putmsg(fd, &ctl, &data, 0) < 0)
522 -                fatalSys("dlunitdatareq:  putmsg");
523 +       ctl.maxlen = 0;
524 +       ctl.len = sizeof (dl_unitdata_req_t) + addrlen;
525 +       ctl.buf = (char *) buf;
526 +
527 +       data.maxlen = 0;
528 +       data.len = datalen;
529 +       data.buf = (char *) datap;
530 +
531 +       if (putmsg(fd, &ctl, &data, 0) < 0)
532 +               fatalSys("dlunitdatareq:  putmsg");
533  }
534  
535  void dlinfoack(int fd, char *bufp)
536  {
537 -        union   DL_primitives   *dlp;
538 -        struct  strbuf  ctl;
539 -        int     flags;
540 +       union   DL_primitives   *dlp;
541 +       struct  strbuf  ctl;
542 +       int     flags;
543  
544 -        ctl.maxlen = MAXDLBUF;
545 -        ctl.len = 0;
546 -        ctl.buf = bufp;
547 +       ctl.maxlen = MAXDLBUF;
548 +       ctl.len = 0;
549 +       ctl.buf = bufp;
550  
551 -        strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlinfoack");
552 +       strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlinfoack");
553  
554 -        dlp = (union DL_primitives *) ctl.buf;
555 +       dlp = (union DL_primitives *) ctl.buf;
556  
557 -        expecting(DL_INFO_ACK, dlp);
558 +       expecting(DL_INFO_ACK, dlp);
559  
560 -        if (ctl.len < sizeof (dl_info_ack_t)) {
561 +       if (ctl.len < sizeof (dl_info_ack_t)) {
562                 char buffer[256];
563 -               sprintf(buffer, "dlinfoack:  response ctl.len too short:  %d", ctl.len); 
564 -                rp_fatal(buffer); 
565 +               sprintf(buffer, "dlinfoack:  response ctl.len too short:  %d", ctl.len);
566 +               rp_fatal(buffer);
567         }
568  
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");
573  
574 -        if (ctl.len < sizeof (dl_info_ack_t)) {
575 +       if (ctl.len < sizeof (dl_info_ack_t)) {
576                 char buffer[256];
577 -               sprintf(buffer, "dlinfoack:  short response ctl.len:  %d", ctl.len); 
578 -               rp_fatal(buffer); 
579 +               sprintf(buffer, "dlinfoack:  short response ctl.len:  %d", ctl.len);
580 +               rp_fatal(buffer);
581         }
582  }
583  
584  void dlbindreq(int fd, u_long sap, u_long max_conind, u_long service_mode, u_long conn_mgmt, u_long xidtest)
585  {
586 -        dl_bind_req_t   bind_req;
587 -        struct  strbuf  ctl;
588 -        int     flags;
589 -
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;
596 -
597 -        ctl.maxlen = 0;
598 -        ctl.len = sizeof (bind_req);
599 -        ctl.buf = (char *) &bind_req;
600 +       dl_bind_req_t   bind_req;
601 +       struct  strbuf  ctl;
602 +       int     flags;
603 +
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;
610 +
611 +       ctl.maxlen = 0;
612 +       ctl.len = sizeof (bind_req);
613 +       ctl.buf = (char *) &bind_req;
614  
615 -        flags = 0;
616 +       flags = 0;
617  
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");
622  }
623  
624  void dlattachreq(int fd, u_long ppa)
625  {
626 -        dl_attach_req_t attach_req;
627 -        struct  strbuf  ctl;
628 -        int     flags;
629 +       dl_attach_req_t attach_req;
630 +       struct  strbuf  ctl;
631 +       int     flags;
632  
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;
637  
638 -        ctl.maxlen = 0;
639 -        ctl.len = sizeof (attach_req);
640 -        ctl.buf = (char *) &attach_req;
641 +       ctl.maxlen = 0;
642 +       ctl.len = sizeof (attach_req);
643 +       ctl.buf = (char *) &attach_req;
644  
645 -        flags = 0;
646 +       flags = 0;
647  
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");
652  }
653  
654  void dlokack(int fd, char *bufp)
655  {
656 -        union   DL_primitives   *dlp;
657 -        struct  strbuf  ctl;
658 -        int     flags;
659 +       union   DL_primitives   *dlp;
660 +       struct  strbuf  ctl;
661 +       int     flags;
662  
663 -        ctl.maxlen = MAXDLBUF;
664 -        ctl.len = 0;
665 -        ctl.buf = bufp;
666 +       ctl.maxlen = MAXDLBUF;
667 +       ctl.len = 0;
668 +       ctl.buf = bufp;
669  
670 -        strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlokack");
671 +       strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlokack");
672  
673 -        dlp = (union DL_primitives *) ctl.buf;
674 +       dlp = (union DL_primitives *) ctl.buf;
675  
676 -        expecting(DL_OK_ACK, dlp);
677 +       expecting(DL_OK_ACK, dlp);
678  
679 -        if (ctl.len < sizeof (dl_ok_ack_t)) { 
680 +       if (ctl.len < sizeof (dl_ok_ack_t)) {
681                 char buffer[256];
682                 sprintf(buffer, "dlokack:  response ctl.len too short:  %d", ctl.len);
683 -               rp_fatal(buffer); 
684 +               rp_fatal(buffer);
685         }
686  
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");
691  
692 -        if (ctl.len < sizeof (dl_ok_ack_t)) {
693 -               char buffer[256]; 
694 +       if (ctl.len < sizeof (dl_ok_ack_t)) {
695 +               char buffer[256];
696                 sprintf(buffer, "dlokack:  short response ctl.len:  %d", ctl.len);
697 -               rp_fatal(buffer); 
698 +               rp_fatal(buffer);
699         }
700  }
701  
702  void dlbindack(int fd, char *bufp)
703  {
704 -        union   DL_primitives   *dlp;
705 -        struct  strbuf  ctl;
706 -        int     flags;
707 +       union   DL_primitives   *dlp;
708 +       struct  strbuf  ctl;
709 +       int     flags;
710  
711 -        ctl.maxlen = MAXDLBUF;
712 -        ctl.len = 0;
713 -        ctl.buf = bufp;
714 +       ctl.maxlen = MAXDLBUF;
715 +       ctl.len = 0;
716 +       ctl.buf = bufp;
717  
718 -        strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlbindack");
719 +       strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlbindack");
720  
721 -        dlp = (union DL_primitives *) ctl.buf;
722 +       dlp = (union DL_primitives *) ctl.buf;
723  
724 -        expecting(DL_BIND_ACK, dlp);
725 +       expecting(DL_BIND_ACK, dlp);
726  
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");
731  
732 -        if (ctl.len < sizeof (dl_bind_ack_t)) {
733 +       if (ctl.len < sizeof (dl_bind_ack_t)) {
734                 char buffer[256];
735                 sprintf(buffer, "dlbindack:  short response ctl.len:  %d", ctl.len);
736 -               rp_fatal(buffer); 
737 +               rp_fatal(buffer);
738         }
739  }
740  
741  int strioctl(int fd, int cmd, int timout, int len, char *dp)
742  {
743 -        struct  strioctl        sioc;
744 -        int     rc;
745 +       struct  strioctl        sioc;
746 +       int     rc;
747  
748 -        sioc.ic_cmd = cmd;
749 -        sioc.ic_timout = timout;
750 -        sioc.ic_len = len;
751 -        sioc.ic_dp = dp;
752 -        rc = ioctl(fd, I_STR, &sioc);
753 -
754 -        if (rc < 0)
755 -                return (rc);
756 -        else
757 -                return (sioc.ic_len);
758 +       sioc.ic_cmd = cmd;
759 +       sioc.ic_timout = timout;
760 +       sioc.ic_len = len;
761 +       sioc.ic_dp = dp;
762 +       rc = ioctl(fd, I_STR, &sioc);
763 +
764 +       if (rc < 0)
765 +               return (rc);
766 +       else
767 +               return (sioc.ic_len);
768  }
769  
770  void strgetmsg(int fd, struct strbuf *ctlp, struct strbuf *datap, int *flagsp, char *caller)
771  {
772 -        int     rc;
773 -        static  char    errmsg[80];
774 +       int     rc;
775 +       static  char    errmsg[80];
776  
777 -        /*
778 -         * Start timer.
779 -         */
780 -        (void) signal(SIGALRM, sigalrm);
781 -        if (alarm(MAXWAIT) < 0) {
782 -                (void) sprintf(errmsg, "%s:  alarm", caller);
783 -                fatalSys(errmsg);
784 -        }
785 -
786 -        /*
787 -         * Set flags argument and issue getmsg().
788 -         */
789 -        *flagsp = 0;
790 -        if ((rc = getmsg(fd, ctlp, datap, flagsp)) < 0) {
791 -                (void) sprintf(errmsg, "%s:  getmsg", caller);
792 -                fatalSys(errmsg);
793 -        }
794 -
795 -        /*
796 -         * Stop timer.
797 -         */
798 -        if (alarm(0) < 0) {
799 -                (void) sprintf(errmsg, "%s:  alarm", caller);
800 -                fatalSys(errmsg);
801 -        }
802 -
803 -        /*
804 -         * Check for MOREDATA and/or MORECTL.
805 -         */
806 -        if ((rc & (MORECTL | MOREDATA)) == (MORECTL | MOREDATA)) {
807 -               char buffer[256]; 
808 +       /*
809 +        * Start timer.
810 +        */
811 +       (void) signal(SIGALRM, sigalrm);
812 +       if (alarm(MAXWAIT) < 0) {
813 +               (void) sprintf(errmsg, "%s:  alarm", caller);
814 +               fatalSys(errmsg);
815 +       }
816 +
817 +       /*
818 +        * Set flags argument and issue getmsg().
819 +        */
820 +       *flagsp = 0;
821 +       if ((rc = getmsg(fd, ctlp, datap, flagsp)) < 0) {
822 +               (void) sprintf(errmsg, "%s:  getmsg", caller);
823 +               fatalSys(errmsg);
824 +       }
825 +
826 +       /*
827 +        * Stop timer.
828 +        */
829 +       if (alarm(0) < 0) {
830 +               (void) sprintf(errmsg, "%s:  alarm", caller);
831 +               fatalSys(errmsg);
832 +       }
833 +
834 +       /*
835 +        * Check for MOREDATA and/or MORECTL.
836 +        */
837 +       if ((rc & (MORECTL | MOREDATA)) == (MORECTL | MOREDATA)) {
838 +               char buffer[256];
839                 sprintf(buffer, "%s:  MORECTL|MOREDATA", caller);
840                 rp_fatal(buffer);
841         }
842 -                
843 -        if (rc & MORECTL) {
844 +
845 +       if (rc & MORECTL) {
846                 char buffer[256];
847                 sprintf(buffer, "%s:  MORECTL", caller);
848 -               rp_fatal(buffer); 
849 +               rp_fatal(buffer);
850         }
851 -        
852 -        if (rc & MOREDATA) {
853 -               char buffer[256]; 
854 +
855 +       if (rc & MOREDATA) {
856 +               char buffer[256];
857                 sprintf(buffer, "%s:  MOREDATA", caller);
858                 rp_fatal(buffer);
859         }
860  
861 -        /*
862 -         * Check for at least sizeof (long) control data portion.
863 -         */
864 -        if (ctlp->len < sizeof (long)) {
865 -               char buffer[256]; 
866 +       /*
867 +        * Check for at least sizeof (long) control data portion.
868 +        */
869 +       if (ctlp->len < sizeof (long)) {
870 +               char buffer[256];
871                 sprintf(buffer, "getmsg:  control portion length < sizeof (long):  %d", ctlp->len);
872 -               rp_fatal(buffer); 
873 +               rp_fatal(buffer);
874         }
875  }
876  
877  void sigalrm(int sig)
878  {
879 -        (void) rp_fatal("sigalrm:  TIMEOUT");
880 +       (void) rp_fatal("sigalrm:  TIMEOUT");
881  }
882  
883  void expecting(int prim, union DL_primitives *dlp)
884  {
885 -        if (dlp->dl_primitive != (u_long)prim) {
886 -               char buffer[256]; 
887 +       if (dlp->dl_primitive != (u_long)prim) {
888 +               char buffer[256];
889                 sprintf(buffer, "expected %s got %s", dlprim(prim), dlprim(dlp->dl_primitive));
890 -               rp_fatal(buffer); 
891 -               exit(1); 
892 +               rp_fatal(buffer);
893 +               exit(1);
894         }
895  }
896  
897  char *dlprim(u_long prim)
898  {
899 -        static  char    primbuf[80];
900 +       static  char    primbuf[80];
901  
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);
930 -                default:
931 -                        (void) sprintf(primbuf, "unknown primitive 0x%lx", prim);
932 -                        return (primbuf);
933 -        }
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);
962 +               default:
963 +                       (void) sprintf(primbuf, "unknown primitive 0x%lx", prim);
964 +                       return (primbuf);
965 +       }
966  }
967  
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
972 @@ -48,9 +51,9 @@
973  #include <signal.h>
974  #include <net/ethernet.h>
975  #include <net/if_arp.h>
976 -#include "ppp_defs.h"
977 -#include "if_ppp.h"
978 -#include "if_pppox.h"
979 +#include <linux/ppp_defs.h>
980 +#include <linux/if_ppp.h>
981 +#include <linux/if_pppox.h>
982  
983  #define _PATH_ETHOPT         _ROOT_PATH "/etc/ppp/options."
984  
985 @@ -399,12 +398,11 @@
986  void
987  rp_fatal(char const *str)
988  {
989 -    char buf[1024];
990      printErr(str);
991 -    sprintf(buf, "RP-PPPoE: %.256s", str);
992 -    sendPADT(conn, buf);
993 +    sendPADTf(conn, "RP-PPPoE: %.256s", str);
994      exit(1);
995  }
996 +
997  /**********************************************************************
998  *%FUNCTION: sysErr
999  *%ARGUMENTS:
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
1007 +
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
1012 +
1013  #define CODE_SESS           0x00
1014  
1015  /* PPPoE Tags */
1016 @@ -174,6 +178,12 @@
1017  #define TAG_AC_SYSTEM_ERROR    0x0202
1018  #define TAG_GENERIC_ERROR      0x0203
1019  
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
1025 +
1026  /* Discovery phase states */
1027  #define STATE_SENT_PADI     0
1028  #define STATE_RECEIVED_PADO 1
1029 @@ -298,6 +308,8 @@
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, ...);
1034 +
1035  void sendSessionPacket(PPPoEConnection *conn,
1036                        PPPoEPacket *packet, int len);
1037  void initPPP(void);
This page took 0.157688 seconds and 3 git commands to generate.