Hello,
I merged the experimental patch for pppoe support in pppoa3. At the
moment the code is for linux only as i don't have *BSD box.
I would like people who needs or can use PPPoE to try this patch.
Usage :
1 - install and configure rp-pppoe
2 - tell rp-pppoe to use tap0
3 - before starting pppd with rp-pppoe, launch pppoa3 in bridging mode
$ pppoa3 -b -c -m 1 -vpi ... -vci ...
4 - run pppoe
If all runs fine, pppoa3 should run in background and transmit pppoe
packets through usb.
I'll try to set up my connection in pppoe mode but i never did that
before so if someone already used the experimental patch could test
this one, it would be great.
I post 2 patches :
- one against cvs head
- one against 1.1 release
--
Edouard Gomez
-- Attached file included as plaintext by Listar --
Index: src/pppoa3.c
===================================================================
RCS file: /cvsroot/speedtouch/speedtouch/src/pppoa3.c,v
retrieving revision 1.25
diff -r1.25 pppoa3.c
60a61,65
> #ifdef __linux__
> #include <linux/if_tun.h>
> #include <linux/if.h>
> #endif
>
123a129,131
> #ifdef __linux__
> static int tap_open();
> #endif
238a247,251
> /* Standard PPPoA or Bridged PPPoE */
> #ifdef __linux__
> static int bridging;
> #endif
>
276c289
< #define BRIDGING1483_HEADER 12
---
> #define BRIDGING1483_HEADER 10
315,316c328
< fdin = STDIN_FILENO;
< fdout = STDOUT_FILENO;
---
> bridging = 0;
342a355,379
> /* Open pty file descriptors */
> #ifdef __linux__
> if(!bridging) {
> #endif
> fdin = STDIN_FILENO;
> fdout = STDOUT_FILENO;
> #ifdef __linux__
> } else {
> fdin = fdout = tap_open();
> close(STDIN_FILENO);
> close(STDOUT_FILENO);
> close(STDERR_FILENO);
>
> switch(fork()) {
> case -1: /* Error */
> report(0, REPORT_ERROR, "fork() failed. Quitting\n");
> return(-1);
> case 0: /* Child part */
> break;
> default: /* Parent part - Quit and let child leave its life */
> return(0);
> }
> }
> #endif
>
367c404,407
< report(2, REPORT_INFO, "Using %s HDLC mode\n", (syncHDLC == 0)?"ASync":"Sync");
---
> report(2, REPORT_INFO, "Using %s HDLC mode\n", (syncHDLC)?"Sync":"ASync");
> report(2, REPORT_INFO, "Using %s mode\n", (bridging)?"Bridged PPPoE":"PPPoA");
> report(2, REPORT_INFO, "Control pipe %sabled\n", (use_pipe)?"en":"dis");
> report(2, REPORT_INFO, "Previous instance cleaning %sabled\n",
>(clean_previous_instance)?"en":"dis");
370,373c410
< if(use_pipe)
< report(2, REPORT_INFO, "Control pipe enabled\n");
< if(clean_previous_instance)
< report(2, REPORT_INFO, "Previous instance cleaning enabled\n");
---
>
773c810,817
< aal5_send_buf = source_buf + HDLC_HEADER_SIZE;
---
>
> #ifdef __linux__
> if(bridging)
> aal5_send_buf = source_buf;
> else
> #endif
> aal5_send_buf = source_buf + HDLC_HEADER_SIZE;
>
861,864c905,918
< destination_buf = buffer;
< destination_buf[0] = FRAME_ADDR;
< destination_buf[1] = FRAME_CTRL;
< aal5_recv_buf = destination_buf + HDLC_HEADER_SIZE;
---
> #ifdef __linux__
> if(bridging) {
> destination_buf = buffer + BRIDGING1483_HEADER;
> aal5_recv_buf = buffer;
> } else {
> #endif
> destination_buf = buffer;
> destination_buf[0] = FRAME_ADDR;
> destination_buf[1] = FRAME_CTRL;
> aal5_recv_buf = destination_buf + HDLC_HEADER_SIZE;
> #ifdef __linux__
> }
> #endif
>
915a970,972
> #ifdef __linux__
> if(write_dest(fdout, destination_buf, n +
>(bridging)?-BRIDGING1483_HEADER:HDLC_HEADER_SIZE) > 0)
> #else
916a974
> #endif
1152c1210
< static int read_source(int fd, unsigned char *buffer, int size)
---
> static int read_source(int fd, unsigned char *dst_buffer, int size)
1155,1158c1213,1218
< /*
< * we must handle HDLC framing, since this is what pppd
< * sends to us. We use some code from rp-pppoe
< */
---
> unsigned char *buffer = dst_buffer;
>
> /*
> * we must handle HDLC framing, since this is what pppd
> * sends to us. We use some code from rp-pppoe
> */
1166a1227,1247
> #ifdef __linux__
> if(bridging) {
> /*
> * When bridging aal5 frames will never use more than 1500
>bytes
> * because max I802.2 frames are 15000 bytes long, so there is
>no
> * buffer overflow possible here even if we use 12 bytes more
> */
> buffer[0]=0xaa;
> buffer[1]=0xaa;
> buffer[2]=0x03;
> buffer[3]=0x00;
> buffer[4]=0x80;
> buffer[5]=0xc2;
> buffer[6]=0x00;
> buffer[7]=0x07;
> buffer[8]=0x00;
> buffer[9]=0x00;
> buffer += BRIDGING1483_HEADER;
> }
> #endif
>
1193a1275,1277
> #ifdef __linux__
> return(r + (bridging)?BRIDGING1483_HEADER:-HDLC_HEADER_SIZE);
> #else
1194a1279
> #endif
1249c1334
< if (PPPPacketSize < 2) {
---
> if (PPPPacketSize < HDLC_HEADER_SIZE) {
1253c1338
< return PPPPacketSize - 2;
---
> return PPPPacketSize - HDLC_HEADER_SIZE;
1403a1489,1518
> * Function : tap_open
> * Arguments :
> * none
> * Return value : a file descriptor
> * Description : Updates the PPP FCS
> *
> */
>
> #ifdef __linux__
> static int tap_open()
> {
> struct ifreq ifr;
> int fd, err;
>
> if( (fd = open("/dev/net/tun", O_RDWR | O_SYNC)) < 0 )
> return -1;
>
> memset(&ifr, 0, sizeof(ifr));
> ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
>
> if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){
> close(fd);
> return err;
> }
>
> return fd;
> }
> #endif
>
> /*
1743a1859,1863
> #ifdef __linux__
> else if(strcmp(argv[i], "--bridging") == 0 || strcmp(argv[i], "-b") ==
>0) {
> bridging = 1;
> }
> #endif
1780a1901,1907
> /*
> * If using RFC 1483 Bridging, use syncHDLC part of the code, but of
> * course this is not HDLC anymore.
> */
> if(bridging)
> syncHDLC = 1;
>
1802a1930,1933
> #ifdef __linux__
> fprintf(stderr, " -b | --bridging\n");
> fprintf(stderr, " Bridging 1483 mode (PPPoE support)\n");
> #endif
-- Attached file included as plaintext by Listar --
Index: src/pppoa3.c
===================================================================
RCS file: /cvsroot/speedtouch/speedtouch/src/pppoa3.c,v
retrieving revision 1.24
diff -r1.24 pppoa3.c
23c23
< * $Id: pppoa3.c,v 1.24 2002/05/18 19:54:46 edgomez Exp $
---
> * $Id: pppoa3.c,v 1.25 2002/10/13 20:42:12 edgomez Exp $
60a61,65
> #ifdef __linux__
> #include <linux/if_tun.h>
> #include <linux/if.h>
> #endif
>
106,107c111,112
< static void *read_from_ppp_thread(void*);
< static void *write_to_ppp_thread(void*);
---
> static void *read_from_usb_thread(void*);
> static void *write_to_usb_thread(void*);
121,123c126,131
< /* ppp(d) I/O */
< static int ppp_read (int fd, unsigned char *buffer, int size);
< static int ppp_write(int fd, unsigned char *buffer, int size);
---
> /* I/O */
> static int read_source(int fd, unsigned char *buffer, int size);
> static int write_dest(int fd, unsigned char *buffer, int size);
> #ifdef __linux__
> static int tap_open();
> #endif
155a164,167
> /* Input/output device descriptors */
> static int fdin;
> static int fdout;
>
183,184c195,196
< #define THREAD_READ_FROM_PPP 0
< #define THREAD_WRITE_TO_PPP 1
---
> #define THREAD_READ_FROM_USB 0
> #define THREAD_WRITE_TO_USB 1
200c212
< THREAD_READ_FROM_PPP,
---
> THREAD_WRITE_TO_USB,
203,204c215,216
< read_from_ppp_thread,
< "Read from ppp"
---
> write_to_usb_thread,
> "Read from usb"
207c219
< THREAD_WRITE_TO_PPP,
---
> THREAD_READ_FROM_USB,
210,211c222,223
< write_to_ppp_thread,
< "Write to ppp"
---
> read_from_usb_thread,
> "Write to usb"
234a247,251
> /* Standard PPPoA or Bridged PPPoE */
> #ifdef __linux__
> static int bridging;
> #endif
>
271,277c288,292
< #define BUFFER_SIZE (64*1024)
< #define HDLC_HEADER_SIZE 2
<
< static unsigned char ppp_read_buf[HDLC_HEADER_SIZE + 1367*ATM_CELL_TOTAL_SIZE];
< static unsigned char ppp_write_buf[HDLC_HEADER_SIZE + 1367*ATM_CELL_TOTAL_SIZE];
< static unsigned char *aal5_send_buf = &ppp_read_buf[HDLC_HEADER_SIZE];
< static unsigned char *aal5_recv_buf = &ppp_write_buf[HDLC_HEADER_SIZE];
---
> #define HDLC_HEADER_SIZE 2
> #define BRIDGING1483_HEADER 10
> #define AAL5_MAX_SIZE 64*1024
> #define BUFFER_SIZE HDLC_HEADER_SIZE + BRIDGING1483_HEADER + \
> 1367*ATM_CELL_TOTAL_SIZE
298a314
> char tmp[128];
311a328
> bridging = 0;
337a355,379
> /* Open pty file descriptors */
> #ifdef __linux__
> if(!bridging) {
> #endif
> fdin = STDIN_FILENO;
> fdout = STDOUT_FILENO;
> #ifdef __linux__
> } else {
> fdin = fdout = tap_open();
> close(STDIN_FILENO);
> close(STDOUT_FILENO);
> close(STDERR_FILENO);
>
> switch(fork()) {
> case -1: /* Error */
> report(0, REPORT_ERROR, "fork() failed. Quitting\n");
> return(-1);
> case 0: /* Child part */
> break;
> default: /* Parent part - Quit and let child leave its life */
> return(0);
> }
> }
> #endif
>
362c404,407
< report(2, REPORT_INFO, "Using %s HDLC mode\n", (syncHDLC == 0)?"ASync":"Sync");
---
> report(2, REPORT_INFO, "Using %s HDLC mode\n", (syncHDLC)?"Sync":"ASync");
> report(2, REPORT_INFO, "Using %s mode\n", (bridging)?"Bridged PPPoE":"PPPoA");
> report(2, REPORT_INFO, "Control pipe %sabled\n", (use_pipe)?"en":"dis");
> report(2, REPORT_INFO, "Previous instance cleaning %sabled\n",
>(clean_previous_instance)?"en":"dis");
365,368c410
< if(use_pipe)
< report(2, REPORT_INFO, "Control pipe enabled\n");
< if(clean_previous_instance)
< report(2, REPORT_INFO, "Previous instance cleaning enabled\n");
---
>
377c419
< snprintf(ppp_read_buf, 127, PPPOA3_PID_FILE_FORMAT, modem_id);
---
> snprintf(tmp, 127, PPPOA3_PID_FILE_FORMAT, modem_id);
388,389c430,431
< if((i = open(ppp_read_buf, O_RDONLY)) < 0) {
< report(0, REPORT_INFO, "No previous instance found\n",
ppp_read_buf);
---
> if((i = open(tmp, O_RDONLY)) < 0) {
> report(0, REPORT_INFO, "No previous instance found\n",
>tmp);
486c528
< if((i = open(ppp_read_buf, O_CREAT|O_WRONLY, 0600)) < 0) {
---
> if((i = open(tmp, O_CREAT|O_WRONLY, 0600)) < 0) {
514c556
< STDIN_FILENO, STDOUT_FILENO);
---
> fdin, fdout);
521c563
< if(getsockopt(STDIN_FILENO, SOL_SOCKET, SO_SNDBUF, &sbuf, &ss) == 0) {
---
> if(getsockopt(fdin, SOL_SOCKET, SO_SNDBUF, &sbuf, &ss) == 0) {
527c569
< if(setsockopt(STDIN_FILENO, SOL_SOCKET, SO_SNDBUF, &sbuf, ss)
< 0)
---
> if(setsockopt(fdin, SOL_SOCKET, SO_SNDBUF, &sbuf, ss) < 0)
532c574
< if(getsockopt(STDIN_FILENO, SOL_SOCKET, SO_RCVBUF, &sbuf, &ss) == 0) {
---
> if(getsockopt(fdin, SOL_SOCKET, SO_RCVBUF, &sbuf, &ss) == 0) {
538c580
< if(setsockopt(STDIN_FILENO, SOL_SOCKET, SO_RCVBUF, &sbuf, ss)
< 0)
---
> if(setsockopt(fdin, SOL_SOCKET, SO_RCVBUF, &sbuf, ss) < 0)
551c593
< if(isatty(STDIN_FILENO) && syncHDLC) {
---
> if(isatty(fdin) && syncHDLC) {
555c597
< if(ioctl(STDIN_FILENO, TIOCSETD, &disc) < 0) {
---
> if(ioctl(fdin, TIOCSETD, &disc) < 0) {
563c605
< if(ioctl(STDIN_FILENO, TIOCSETD, &disc) < 0) {
---
> if(ioctl(fdin, TIOCSETD, &disc) < 0) {
625c667
< if(thread_start(THREAD_READ_FROM_PPP) < 0) {
---
> if(thread_start(THREAD_WRITE_TO_USB) < 0) {
627c669
< thread_array[thread_getindex(THREAD_READ_FROM_PPP)].name);
---
> thread_array[thread_getindex(THREAD_WRITE_TO_USB)].name);
631c673
< if(thread_start(THREAD_WRITE_TO_PPP) < 0) {
---
> if(thread_start(THREAD_READ_FROM_USB) < 0) {
633c675
< thread_array[thread_getindex(THREAD_WRITE_TO_PPP)].name);
---
> thread_array[thread_getindex(THREAD_READ_FROM_USB)].name);
695,696c737,738
< snprintf(ppp_read_buf, 127, PPPOA3_PID_FILE_FORMAT, modem_id);
< unlink(ppp_read_buf);
---
> snprintf(tmp, 127, PPPOA3_PID_FILE_FORMAT, modem_id);
> unlink(tmp);
735c777
< * Function : read_from_ppp_thread
---
> * Function : write_to_usb_thread
741c783
< static void *read_from_ppp_thread(void* arg)
---
> static void *write_to_usb_thread(void* arg)
744a787,789
> unsigned char *buffer;
> unsigned char *source_buf;
> unsigned char *aal5_send_buf;
753a799,802
> /* Allocate buffer memory */
> if((buffer = malloc(BUFFER_SIZE)) == NULL)
> goto local_end;
>
755c804
< pthread_cleanup_push(cleanup_iothread,
&thread_array[thread_getindex(THREAD_READ_FROM_PPP)].m_id);
---
> pthread_cleanup_push(cleanup_iothread,
>&thread_array[thread_getindex(THREAD_WRITE_TO_USB)].m_id);
759a809,818
> source_buf = buffer;
>
> #ifdef __linux__
> if(bridging)
> aal5_send_buf = source_buf;
> else
> #endif
> aal5_send_buf = source_buf + HDLC_HEADER_SIZE;
>
>
766c825
< n = ppp_read(STDIN_FILENO, ppp_read_buf, BUFFER_SIZE);
---
> n = read_source(fdin, source_buf, AAL5_MAX_SIZE);
798a858,860
> free(buffer);
>
> local_end:
810c872
< * Function : write_to_ppp_thread
---
> * Function : read_from_usb_thread
815c877
< static void *write_to_ppp_thread(void* arg)
---
> static void *read_from_usb_thread(void* arg)
819a882,884
> unsigned char *buffer;
> unsigned char *aal5_recv_buf;
> unsigned char *destination_buf;
830c895
< pthread_cleanup_push(cleanup_iothread,
&thread_array[thread_getindex(THREAD_WRITE_TO_PPP)].m_id);
---
> pthread_cleanup_push(cleanup_iothread,
>&thread_array[thread_getindex(THREAD_READ_FROM_USB)].m_id);
834a900,903
> /* Allocate buffer memory */
> if((buffer = malloc(BUFFER_SIZE)) == NULL)
> goto local_end;
>
836,837c905,918
< ppp_write_buf[0] = 0xff;
< ppp_write_buf[1] = 0x03;
---
> #ifdef __linux__
> if(bridging) {
> destination_buf = buffer + BRIDGING1483_HEADER;
> aal5_recv_buf = buffer;
> } else {
> #endif
> destination_buf = buffer;
> destination_buf[0] = FRAME_ADDR;
> destination_buf[1] = FRAME_CTRL;
> aal5_recv_buf = destination_buf + HDLC_HEADER_SIZE;
> #ifdef __linux__
> }
> #endif
>
889c970,974
< if(ppp_write(STDOUT_FILENO, ppp_write_buf, n +
HDLC_HEADER_SIZE) > 0)
---
> #ifdef __linux__
> if(write_dest(fdout, destination_buf, n +
>(bridging)?-BRIDGING1483_HEADER:HDLC_HEADER_SIZE) > 0)
> #else
> if(write_dest(fdout, destination_buf, n +
>HDLC_HEADER_SIZE) > 0)
> #endif
915a1001,1003
> free(buffer);
>
> local_end:
1064c1152
< pthread_getschedparam(
thread_array[thread_getindex(THREAD_READ_FROM_PPP)].t_id,
---
> pthread_getschedparam(
>thread_array[thread_getindex(THREAD_READ_FROM_USB)].t_id,
1067c1155
< pthread_setschedparam(
thread_array[thread_getindex(THREAD_READ_FROM_PPP)].t_id,
---
> pthread_setschedparam(
>thread_array[thread_getindex(THREAD_READ_FROM_USB)].t_id,
1071c1159
< pthread_getschedparam(
thread_array[thread_getindex(THREAD_WRITE_TO_PPP)].t_id,
---
> pthread_getschedparam(
>thread_array[thread_getindex(THREAD_WRITE_TO_USB)].t_id,
1074c1162
< pthread_setschedparam(
thread_array[thread_getindex(THREAD_WRITE_TO_PPP)].t_id,
---
> pthread_setschedparam(
>thread_array[thread_getindex(THREAD_WRITE_TO_USB)].t_id,
1116c1204
< * Function : ppp_read
---
> * Function : read_source
1122c1210
< static int ppp_read(int fd, unsigned char *buffer, int size)
---
> static int read_source(int fd, unsigned char *dst_buffer, int size)
1125,1128c1213,1218
< /*
< * we must handle HDLC framing, since this is what pppd
< * sends to us. We use some code from rp-pppoe
< */
---
> unsigned char *buffer = dst_buffer;
>
> /*
> * we must handle HDLC framing, since this is what pppd
> * sends to us. We use some code from rp-pppoe
> */
1130c1220
< if(size > BUFFER_SIZE) {
---
> if(size > AAL5_MAX_SIZE) {
1136a1227,1247
> #ifdef __linux__
> if(bridging) {
> /*
> * When bridging aal5 frames will never use more than 1500
>bytes
> * because max I802.2 frames are 15000 bytes long, so there is
>no
> * buffer overflow possible here even if we use 12 bytes more
> */
> buffer[0]=0xaa;
> buffer[1]=0xaa;
> buffer[2]=0x03;
> buffer[3]=0x00;
> buffer[4]=0x80;
> buffer[5]=0xc2;
> buffer[6]=0x00;
> buffer[7]=0x07;
> buffer[8]=0x00;
> buffer[9]=0x00;
> buffer += BRIDGING1483_HEADER;
> }
> #endif
>
1163a1275,1277
> #ifdef __linux__
> return(r + (bridging)?BRIDGING1483_HEADER:-HDLC_HEADER_SIZE);
> #else
1164a1279
> #endif
1219c1334
< if (PPPPacketSize < 2) {
---
> if (PPPPacketSize < HDLC_HEADER_SIZE) {
1223c1338
< return PPPPacketSize-2;
---
> return PPPPacketSize - HDLC_HEADER_SIZE;
1244c1359
< * Function : ppp_write
---
> * Function : write_dest
1250c1365
< static int ppp_write(int fd, unsigned char *buffer, int n)
---
> static int write_dest(int fd, unsigned char *buffer, int n)
1373a1489,1518
> * Function : tap_open
> * Arguments :
> * none
> * Return value : a file descriptor
> * Description : Updates the PPP FCS
> *
> */
>
> #ifdef __linux__
> static int tap_open()
> {
> struct ifreq ifr;
> int fd, err;
>
> if( (fd = open("/dev/net/tun", O_RDWR | O_SYNC)) < 0 )
> return -1;
>
> memset(&ifr, 0, sizeof(ifr));
> ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
>
> if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){
> close(fd);
> return err;
> }
>
> return fd;
> }
> #endif
>
> /*
1437,1438c1582,1583
< if( id == THREAD_READ_FROM_PPP ||
< id == THREAD_WRITE_TO_PPP) {
---
> if( id == THREAD_READ_FROM_USB ||
> id == THREAD_WRITE_TO_USB) {
1713a1859,1863
> #ifdef __linux__
> else if(strcmp(argv[i], "--bridging") == 0 || strcmp(argv[i], "-b") ==
>0) {
> bridging = 1;
> }
> #endif
1750a1901,1907
> /*
> * If using RFC 1483 Bridging, use syncHDLC part of the code, but of
> * course this is not HDLC anymore.
> */
> if(bridging)
> syncHDLC = 1;
>
1772a1930,1933
> #ifdef __linux__
> fprintf(stderr, " -b | --bridging\n");
> fprintf(stderr, " Bridging 1483 mode (PPPoE support)\n");
> #endif
Liste de diffusion modem ALCATEL SpeedTouch USB
Pour se d�sinscrire : mailto:speedtouch-request@;ml.free.fr?subject=unsubscribe