├── .build-info └── post-config ├── gui ├── ja.msg ├── html │ ├── mainwin.png │ ├── props-basic.png │ ├── props-nic.png │ ├── mainwin-busy.png │ ├── props-options.png │ ├── mainwin-nonroot.png │ ├── props-advanced.png │ └── tkpppoe.html ├── tkpppoe.1 ├── pppoe-wrapper.1 ├── Makefile.in ├── wrapper.c └── en.msg ├── doc ├── PROBLEMS ├── KERNEL-MODE-PPPOE └── HOW-TO-CONNECT ├── configs ├── pppoe-server-options ├── pap-secrets ├── firewall-standalone ├── firewall-masq └── pppoe.conf ├── SERVPOET ├── man ├── pppoe-stop.8 ├── pppoe-setup.8 ├── pppoe-status.8 ├── pppoe-start.8 ├── pppoe-connect.8 ├── pppoe-sniff.8 ├── pppoe-relay.8 ├── pppoe.conf.5 ├── pppoe-server.8 └── pppoe.8 ├── src ├── md5.h ├── libevent │ ├── Makefile.in │ ├── hash.h │ ├── eventpriv.h │ ├── event_tcp.h │ ├── event.h │ ├── hash.c │ └── event_sig.c ├── relay.h ├── config.h.in ├── debug.c ├── pppoe-server.h ├── install-sh ├── pppoe-sniff.c ├── ppp.c └── md5.c ├── go ├── scripts ├── pppoe-init-turbolinux.in ├── pppoe-init.in ├── pppoe-init-suse.in ├── pppoe-status ├── pppoe-stop.in ├── pppoe-start.in ├── pppoe-connect.in └── pppoe-setup.in ├── README ├── go-gui └── rp-pppoe.spec /.build-info/post-config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir ../src/plugin 4 | -------------------------------------------------------------------------------- /gui/ja.msg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Distrotech/rp-pppoe/HEAD/gui/ja.msg -------------------------------------------------------------------------------- /doc/PROBLEMS: -------------------------------------------------------------------------------- 1 | # LIC: GPL 2 | 3 | Problems? 4 | 5 | See the last section of HOW-TO-CONNECT. 6 | -------------------------------------------------------------------------------- /gui/html/mainwin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Distrotech/rp-pppoe/HEAD/gui/html/mainwin.png -------------------------------------------------------------------------------- /gui/html/props-basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Distrotech/rp-pppoe/HEAD/gui/html/props-basic.png -------------------------------------------------------------------------------- /gui/html/props-nic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Distrotech/rp-pppoe/HEAD/gui/html/props-nic.png -------------------------------------------------------------------------------- /gui/html/mainwin-busy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Distrotech/rp-pppoe/HEAD/gui/html/mainwin-busy.png -------------------------------------------------------------------------------- /gui/html/props-options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Distrotech/rp-pppoe/HEAD/gui/html/props-options.png -------------------------------------------------------------------------------- /gui/html/mainwin-nonroot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Distrotech/rp-pppoe/HEAD/gui/html/mainwin-nonroot.png -------------------------------------------------------------------------------- /gui/html/props-advanced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Distrotech/rp-pppoe/HEAD/gui/html/props-advanced.png -------------------------------------------------------------------------------- /configs/pppoe-server-options: -------------------------------------------------------------------------------- 1 | # PPP options for the PPPoE server 2 | # LIC: GPL 3 | require-pap 4 | login 5 | lcp-echo-interval 10 6 | lcp-echo-failure 2 7 | -------------------------------------------------------------------------------- /configs/pap-secrets: -------------------------------------------------------------------------------- 1 | # LIC: GPL 2 | # Edit this file and place it in /etc/ppp/pap-secrets 3 | 4 | #User #Server #Password #IP 5 | bxxxxx@sympatico.ca * my_password * 6 | 7 | # Replace bxxxxx@sympatico.ca with your Sympatico user-ID 8 | # Replace my_password with your Sympatico password 9 | 10 | # For Magma, use xxyyzz@magma.ca 11 | -------------------------------------------------------------------------------- /SERVPOET: -------------------------------------------------------------------------------- 1 | # LIC: GPL 2 | 3 | ServPoET 4 | -------- 5 | 6 | ServPoET is a commercial version of the PPPoE server. While everything 7 | you received in this package is licensed under the GNU General Public 8 | License, ServPoET is not free software and is licensed under a traditional 9 | commercial license. 10 | 11 | ServPoET features RADIUS support, support for different realms, 12 | real-time server status reporting and a friendly curses-based GUI for 13 | administration. For information on ServPoET: 14 | 15 | Contact Fine Point Technologies, Inc. (http://www.finepoint.com/) 16 | 17 | -- 18 | David F. Skoll 19 | -------------------------------------------------------------------------------- /man/pppoe-stop.8: -------------------------------------------------------------------------------- 1 | .\" LIC: GPL 2 | .TH PPPOE-STOP 8 "21 February 2000" 3 | .UC 4 4 | .SH NAME 5 | pppoe-stop \- Shell script to shut down a PPPoE link 6 | .SH SYNOPSIS 7 | .B pppoe-stop \fR[\fIconfig_file\fR] 8 | 9 | .SH DESCRIPTION 10 | \fBpppoe-stop\fR is a shell script which stops the Roaring Penguin 11 | user-space PPPoE client. If you omit \fIconfig_file\fR, the default 12 | file \fB/etc/ppp/pppoe.conf\fR is used. 13 | 14 | .SH AUTHOR 15 | \fBpppoe-stop\fR was written by David F. Skoll . 16 | 17 | The \fBpppoe\fR home page is \fIhttp://www.roaringpenguin.com/pppoe/\fR. 18 | 19 | .SH SEE ALSO 20 | pppoe(8), pppoe-start(8), pppoe-connect(8), pppd(8), pppoe.conf(5), pppoe-setup(8), pppoe-status(8), pppoe-sniff(8), pppoe-relay(8), pppoe-server(8) 21 | 22 | -------------------------------------------------------------------------------- /man/pppoe-setup.8: -------------------------------------------------------------------------------- 1 | .\" LIC: GPL 2 | .TH PPPOE-SETUP 8 "21 February 2000" 3 | .UC 4 4 | .SH NAME 5 | pppoe-setup \- Shell script to configure Roaring Penguin PPPoE client 6 | .SH SYNOPSIS 7 | .B pppoe-setup 8 | 9 | .SH DESCRIPTION 10 | \fBpppoe-setup\fR is a shell script which prompts you for various pieces 11 | of information and sets up an /etc/ppp/pppoe.conf configuration script 12 | for the \fBpppoe-start\fR, \fBpppoe-stop\fR and \fBpppoe-connect\fR scripts. 13 | 14 | .SH AUTHOR 15 | \fBpppoe-setup\fR was written by David F. Skoll . 16 | 17 | The \fBpppoe\fR home page is \fIhttp://www.roaringpenguin.com/pppoe/\fR. 18 | 19 | .SH SEE ALSO 20 | pppoe(8), pppoe-start(8), pppoe-stop(8), pppoe-connect(8), pppd(8), 21 | pppoe.conf(5), pppoe-status(8), pppoe-sniff(8), pppoe-relay(8), 22 | pppoe-server(8) 23 | 24 | -------------------------------------------------------------------------------- /man/pppoe-status.8: -------------------------------------------------------------------------------- 1 | .\" LIC: GPL 2 | .TH PPPOE-STATUS 8 "16 March 2000" 3 | .UC 4 4 | .SH NAME 5 | pppoe-status \- Shell script to report on status of PPPoE link 6 | .SH SYNOPSIS 7 | .B pppoe-status \fR[\fIconfig_file\fR] 8 | 9 | .SH DESCRIPTION 10 | \fBpppoe-status\fR is a shell script which checks the status of the 11 | PPPoE link established by the Roaring Penguin user-space PPPoE client. 12 | If you omit \fIconfig_file\fR, the default file 13 | \fB/etc/ppp/pppoe.conf\fR is used. 14 | 15 | .SH AUTHOR 16 | \fBpppoe-status\fR was written by David F. Skoll . 17 | 18 | The \fBpppoe\fR home page is \fIhttp://www.roaringpenguin.com/pppoe/\fR. 19 | 20 | .SH SEE ALSO 21 | pppoe(8), pppoe-start(8), pppoe-connect(8), pppd(8), pppoe.conf(5), 22 | pppoe-setup(8), pppoe-stop(8), pppoe-sniff(8), pppoe-relay(8), 23 | pppoe-server(8) 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/md5.h: -------------------------------------------------------------------------------- 1 | #ifndef MD5_H 2 | #define MD5_H 3 | /* 4 | * LIC: GPL 5 | */ 6 | 7 | #include "config.h" 8 | 9 | #if SIZEOF_UNSIGNED_INT == 4 10 | typedef unsigned int uint32; 11 | #elif SIZEOF_UNSIGNED_LONG == 4 12 | typedef unsigned long uint32; 13 | #else 14 | # error Could not find a 32-bit integer type 15 | #endif 16 | 17 | struct MD5Context { 18 | uint32 buf[4]; 19 | uint32 bits[2]; 20 | unsigned char in[64]; 21 | }; 22 | 23 | void MD5Init(struct MD5Context *context); 24 | void MD5Update(struct MD5Context *context, unsigned char const *buf, 25 | unsigned len); 26 | void MD5Final(unsigned char digest[16], struct MD5Context *context); 27 | void MD5Transform(uint32 buf[4], uint32 const in[16]); 28 | 29 | /* 30 | * This is needed to make RSAREF happy on some MS-DOS compilers. 31 | */ 32 | typedef struct MD5Context MD5_CTX; 33 | 34 | #endif /* !MD5_H */ 35 | -------------------------------------------------------------------------------- /man/pppoe-start.8: -------------------------------------------------------------------------------- 1 | .\" LIC: GPL 2 | .TH PPPOE-START 8 "21 February 2000" 3 | .UC 4 4 | .SH NAME 5 | pppoe-start \- Shell script to bring up a PPPoE link 6 | .SH SYNOPSIS 7 | .B pppoe-start \fR[\fIconfig_file\fR] 8 | .P 9 | .B pppoe-start \fR\fIinterface user\fR [\fIconfig_file\fR] 10 | 11 | .SH DESCRIPTION 12 | \fBpppoe-start\fR is a shell script which starts the Roaring Penguin 13 | user-space PPPoE client. If you omit \fIconfig_file\fR, the default 14 | file \fB/etc/ppp/pppoe.conf\fR is used. If you supply 15 | \fIinterface\fR and \fIuser\fR, then they override the Ethernet interface 16 | and user-name settings in the configuration file. 17 | 18 | .SH AUTHOR 19 | \fBpppoe-start\fR was written by David F. Skoll . 20 | 21 | The \fBpppoe\fR home page is \fIhttp://www.roaringpenguin.com/pppoe/\fR. 22 | 23 | .SH SEE ALSO 24 | pppoe(8), pppoe-stop(8), pppoe-connect(8), pppd(8), pppoe.conf(5), 25 | pppoe-setup(8), pppoe-status(8), pppoe-sniff(8), pppoe-relay(8), 26 | pppoe-server(8) 27 | 28 | -------------------------------------------------------------------------------- /go: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # LIC: GPL 3 | #*********************************************************************** 4 | # 5 | # go 6 | # 7 | # Quick-start shell script to set up PPPoE 8 | # 9 | # Copyright (C) 2000 Roaring Penguin Software Inc. 10 | # 11 | # $Id$ 12 | #*********************************************************************** 13 | 14 | # Figure out directory of script 15 | MYDIR=`dirname $0` 16 | cd $MYDIR/src 17 | 18 | echo "Running ./configure..." 19 | ./configure 20 | if [ "$?" != 0 ] ; then 21 | echo "Oops! It looks like ./configure failed." 22 | exit 1 23 | fi 24 | 25 | echo "Running make..." 26 | make 27 | if [ "$?" != 0 ] ; then 28 | echo "Oops! It looks like make failed." 29 | exit 1 30 | fi 31 | 32 | echo "Running make install..." 33 | make install 34 | 35 | if [ "$?" != 0 ] ; then 36 | echo "Oops! It looks like make install failed." 37 | exit 1 38 | fi 39 | 40 | for i in a a a a a a a a a a a a a a a a a a a a a a a a a a a a ; do 41 | echo "" 42 | done 43 | 44 | sh ../scripts/pppoe-setup 45 | -------------------------------------------------------------------------------- /src/libevent/Makefile.in: -------------------------------------------------------------------------------- 1 | # Generated automatically from Makefile.in by configure. 2 | # $Id$ 3 | # 4 | # Makefile for event-handling library 5 | # 6 | # Copyright 2002 Roaring Penguin Software Inc. 7 | # 8 | # This software may be distributed according to the terms of the GNU 9 | # General Public License, version 2 or (at your option) any later version. 10 | # LIC: GPL 11 | 12 | OBJS=event.o event_tcp.o hash.o event_sig.o 13 | SRCS=$(OBJS:.o=.c) 14 | HDRS=event.h event_tcp.h eventpriv.h hash.h 15 | CFLAGS=@CFLAGS@ -I.. $(DEFINES) 16 | AR=ar 17 | 18 | all: libevent.a 19 | 20 | libevent.a: $(OBJS) 21 | rm -f libevent.a 22 | $(AR) -cq libevent.a $(OBJS) 23 | @RANLIB@ libevent.a 24 | 25 | event.o: event.c $(HDRS) 26 | @CC@ $(CFLAGS) -c -o $@ $< 27 | 28 | hash.o: hash.c $(HDRS) 29 | @CC@ $(CFLAGS) -c -o $@ $< 30 | 31 | event_sig.o: event_sig.c $(HDRS) 32 | @CC@ $(CFLAGS) -c -o $@ $< 33 | 34 | event_tcp.o: event_tcp.c $(HDRS) 35 | @CC@ $(CFLAGS) -c -o $@ $< 36 | 37 | clean: FORCE 38 | rm -f *.a *.o *~ 39 | 40 | FORCE: 41 | 42 | .phony: FORCE 43 | -------------------------------------------------------------------------------- /gui/tkpppoe.1: -------------------------------------------------------------------------------- 1 | .\" $Id$ 2 | .\" LIC: GPL 3 | .TH TKPPPOE 1 "26 February 2001" 4 | .UC 4 5 | .SH NAME 6 | tkpppoe \- Graphical interface for controlling rp-pppoe 7 | .SH SYNOPSIS 8 | .B tkpppoe 9 | 10 | .SH DESCRIPTION 11 | \fBtkpppoe\fR is a graphical program for controlling PPPoE links. 12 | It works with the RP-PPPoE package and has its own HTML manual. 13 | 14 | .SH FILES 15 | 16 | .TP 17 | .B /etc/ppp/rp-pppoe-gui/connection-info 18 | Contains connection information. This file is not human-editable. 19 | 20 | .TP 21 | .B /etc/ppp/rp-pppoe-gui/passwd 22 | Contains passwords for each connection. This file is not human-editable. 23 | 24 | .TP 25 | .B /etc/ppp/rp-pppoe-gui/conf.* 26 | These configuration files are used by \fBpppoe-start\fR. They are 27 | generated anew by \fBtkpppoe\fR each time a change is made to a 28 | connection's properties. 29 | 30 | .SH AUTHOR 31 | \fBtkpppoe\fR was written by David F. Skoll . 32 | 33 | The \fBpppoe\fR home page is \fIhttp://www.roaringpenguin.com/pppoe/\fR. 34 | 35 | .SH SEE ALSO 36 | pppoe-start(8), pppoe-stop(8), pppoe-wrapper(8). 37 | 38 | -------------------------------------------------------------------------------- /configs/firewall-standalone: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # firewall-standalone This script sets up firewall rules for a standalone 4 | # machine 5 | # 6 | # Copyright (C) 2005 Roaring Penguin Software Inc. This software may 7 | # be distributed under the terms of the GNU General Public License, version 8 | # 2 or any later version. 9 | # LIC: GPL 10 | 11 | # Interface to Internet 12 | EXTIF=ppp+ 13 | 14 | iptables -P INPUT ACCEPT 15 | iptables -P OUTPUT ACCEPT 16 | iptables -P FORWARD DROP 17 | 18 | iptables -F FORWARD 19 | iptables -F INPUT 20 | iptables -F OUTPUT 21 | 22 | # Deny TCP and UDP packets to privileged ports 23 | iptables -A INPUT -p udp -i $EXTIF --dport 0:1023 -j LOG 24 | iptables -A INPUT -p tcp -i $EXTIF --dport 0:1023 -j LOG 25 | iptables -A INPUT -p udp -i $EXTIF --dport 0:1023 -j DROP 26 | iptables -A INPUT -p tcp -i $EXTIF --dport 0:1023 -j DROP 27 | 28 | # Deny TCP connection attempts 29 | iptables -A INPUT -i $EXTIF -p tcp --syn -j LOG 30 | iptables -A INPUT -i $EXTIF -p tcp --syn -j DROP 31 | 32 | # Deny ICMP echo-requests 33 | iptables -A INPUT -i $EXTIF -p icmp --icmp-type echo-request -j DROP 34 | 35 | -------------------------------------------------------------------------------- /gui/pppoe-wrapper.1: -------------------------------------------------------------------------------- 1 | .\" LIC: GPL 2 | .TH PPPOE-WRAPPER 1 "26 February 2001" 3 | .UC 4 4 | .SH NAME 5 | pppoe-wrapper \- SUID wrapper for starting and stopping PPPoE connections. 6 | .SH SYNOPSIS 7 | .B pppoe-wrapper start linkname 8 | .P 9 | .B pppoe-wrapper stop linkname 10 | .P 11 | .B pppoe-wrapper status linkname 12 | 13 | .SH DESCRIPTION 14 | \fBpppoe-wrapper\fR is a small SUID program which allows non-root users 15 | to start and stop PPPoE links. It operates as follows: 16 | 17 | .TP 18 | .B o 19 | First, \fIlinkname\fR is sanity-checked. Too-long names and names containing 20 | illegal characters are rejected. 21 | 22 | .TP 23 | .B o 24 | Second, \fBpppoe-wrapper\fR opens the file \fB/etc/ppp/rp-pppoe-gui/conf.\fR\fIlinkname\fR for reading. If that file does not contain the line: 25 | .nf 26 | 27 | NONROOT=OK 28 | 29 | .fi 30 | then \fBpppoe-wrapper\fR fails. 31 | 32 | .TP 33 | .B o 34 | Otherwise, \fBpppoe-wrapper\fR runs \fBpppoe-start\fR, \fBpppoe-stop\fR or 35 | \fBpppoe-status\fR with the above filename as its single argument. 36 | 37 | .SH AUTHOR 38 | \fBpppoe-wrapper\fR was written by David F. Skoll . 39 | 40 | The \fBpppoe\fR home page is \fIhttp://www.roaringpenguin.com/pppoe/\fR. 41 | 42 | .SH SEE ALSO 43 | pppoe-start(8), pppoe-stop(8), pppoe-status(8), tkpppoe(1) 44 | 45 | 46 | -------------------------------------------------------------------------------- /scripts/pppoe-init-turbolinux.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # pppoe This script starts or stops a PPPoE connection 4 | # 5 | # chkconfig: 2345 99 01 6 | # description: Connects to PPPoE provider 7 | # 8 | # LIC: GPL 9 | # 10 | # Copyright (C) 2000 Roaring Penguin Software Inc. This software may 11 | # be distributed under the terms of the GNU General Public License, version 12 | # 2 or any later version. 13 | 14 | # Source function library if it exists 15 | test -r /etc/rc.d/init.d/functions && . /etc/rc.d/init.d/functions 16 | 17 | # From AUTOCONF 18 | prefix=@prefix@ 19 | exec_prefix=@exec_prefix@ 20 | 21 | # Paths to programs 22 | START=@sbindir@/pppoe-start 23 | STOP=@sbindir@/pppoe-stop 24 | STATUS=@sbindir@/pppoe-status 25 | case "$1" in 26 | start) 27 | echo -n "Bringing up PPPoE link: " 28 | 29 | $START 30 | if [ $? = 0 ] ; then 31 | echo success 32 | touch /var/lock/subsys/pppoe 33 | else 34 | echo failure 35 | fi 36 | ;; 37 | 38 | stop) 39 | echo -n "Shutting down PPPoE link: " 40 | 41 | $STOP > /dev/null 2>&1 42 | if [ $? = 0 ] ; then 43 | echo success 44 | rm -f /var/lock/subsys/pppoe 45 | else 46 | echo failure 47 | fi 48 | ;; 49 | 50 | restart) 51 | $0 stop 52 | $0 start 53 | ;; 54 | 55 | status) 56 | $STATUS 57 | ;; 58 | 59 | *) 60 | echo "Usage: pppoe {start|stop|restart|status}" 61 | exit 1 62 | esac 63 | 64 | exit 0 65 | -------------------------------------------------------------------------------- /scripts/pppoe-init.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # pppoe This script starts or stops a PPPoE connection 4 | # 5 | # chkconfig: 2345 99 01 6 | # description: Connects to PPPoE provider 7 | # 8 | # LIC: GPL 9 | # 10 | # Copyright (C) 2000 Roaring Penguin Software Inc. This software may 11 | # be distributed under the terms of the GNU General Public License, version 12 | # 2 or any later version. 13 | 14 | # Source function library if it exists 15 | test -r /etc/rc.d/init.d/functions && . /etc/rc.d/init.d/functions 16 | 17 | # From AUTOCONF 18 | prefix=@prefix@ 19 | exec_prefix=@exec_prefix@ 20 | 21 | # Paths to programs 22 | START=@sbindir@/pppoe-start 23 | STOP=@sbindir@/pppoe-stop 24 | STATUS=@sbindir@/pppoe-status 25 | case "$1" in 26 | start) 27 | echo -n "Bringing up PPPoE link" 28 | 29 | $START 30 | if [ $? = 0 ] ; then 31 | touch /var/lock/subsys/pppoe 32 | echo_success 33 | else 34 | echo_failure 35 | fi 36 | echo "" 37 | ;; 38 | 39 | stop) 40 | echo -n "Shutting down PPPoE link" 41 | 42 | $STOP > /dev/null 2>&1 43 | if [ $? = 0 ] ; then 44 | rm -f /var/lock/subsys/pppoe 45 | echo_success 46 | else 47 | echo_failure 48 | fi 49 | echo "" 50 | ;; 51 | 52 | restart) 53 | $0 stop 54 | $0 start 55 | ;; 56 | 57 | status) 58 | $STATUS 59 | ;; 60 | 61 | *) 62 | echo "Usage: pppoe {start|stop|restart|status}" 63 | exit 1 64 | esac 65 | 66 | exit 0 67 | -------------------------------------------------------------------------------- /src/libevent/hash.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * hash.h 4 | * 5 | * Hash table utilities 6 | * 7 | * Copyright (C) 2002 Roaring Penguin Software Inc. 8 | * 9 | * LIC: GPL 10 | * 11 | ***********************************************************************/ 12 | 13 | #ifndef HASH_H 14 | #define HASH_H 15 | 16 | #include 17 | /* Fixed-size hash tables for now */ 18 | #define HASHTAB_SIZE 67 19 | 20 | /* A hash bucket */ 21 | typedef struct hash_bucket_t { 22 | struct hash_bucket_t *next; 23 | struct hash_bucket_t *prev; 24 | unsigned int hashval; 25 | } hash_bucket; 26 | 27 | /* A hash table */ 28 | typedef struct hash_table_t { 29 | hash_bucket *buckets[HASHTAB_SIZE]; 30 | size_t hash_offset; 31 | unsigned int (*compute_hash)(void *data); 32 | int (*compare)(void *item1, void *item2); 33 | size_t num_entries; 34 | } hash_table; 35 | 36 | /* Functions */ 37 | void hash_init(hash_table *tab, 38 | size_t hash_offset, 39 | unsigned int (*compute)(void *data), 40 | int (*compare)(void *item1, void *item2)); 41 | void hash_insert(hash_table *tab, void *item); 42 | void hash_remove(hash_table *tab, void *item); 43 | void *hash_find(hash_table *tab, void *item); 44 | void *hash_find_next(hash_table *tab, void *item); 45 | size_t hash_num_entries(hash_table *tab); 46 | 47 | /* Iteration functions */ 48 | void *hash_start(hash_table *tab, void **cursor); 49 | void *hash_next(hash_table *tab, void **cursor); 50 | 51 | /* Utility function: hashpjw for strings */ 52 | unsigned int hash_pjw(char const *str); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /scripts/pppoe-init-suse.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # pppoe This script starts or stops a PPPoE connection 4 | # 5 | # chkconfig: 2345 99 01 6 | # description: Connects to PPPoE provider 7 | # 8 | # LIC: GPL 9 | # 10 | # Copyright (C) 2000 Roaring Penguin Software Inc. This software may 11 | # be distributed under the terms of the GNU General Public License, version 12 | # 2 or any later version. 13 | # Modifed to work with SuSE 6.4 linux by Gary Cameron. 14 | # 15 | # Source function library. 16 | #. /etc/rc.d/init.d/functions # For red hat? 17 | . /etc/rc.config # For SuSE, enables setting from /etc/rc.config 18 | 19 | #Tweak this 20 | restart_time=120 21 | 22 | # From AUTOCONF 23 | prefix=@prefix@ 24 | exec_prefix=@exec_prefix@ 25 | 26 | # Paths to programs 27 | START=@sbindir@/pppoe-start 28 | STOP=@sbindir@/pppoe-stop 29 | STATUS=@sbindir@/pppoe-status 30 | 31 | test "$PPPoE_START" = "yes" || exit 0 32 | 33 | # The echo return value for success (defined in /etc/rc.config). 34 | return=$rc_done 35 | case "$1" in 36 | start) 37 | echo -n "Bringing up PPPoE link" 38 | $START > /dev/null 2>&1 || return=$rc_failed 39 | echo -e "$return" 40 | ;; 41 | 42 | stop) 43 | echo -n "Shutting down PPPoE link" 44 | $STOP > /dev/null 2>&1 || return=$rc_failed 45 | echo -e "$return" 46 | ;; 47 | 48 | restart) 49 | $0 stop 50 | echo "Waiting" $restart_time "seconds for the host to reset itself" 51 | sleep $restart_time #Note: Need time for host to reset itself 52 | $0 start 53 | ;; 54 | 55 | status) 56 | $STATUS 57 | ;; 58 | 59 | *) 60 | echo "Usage: pppoe {start|stop|restart|status}" 61 | exit 1 62 | esac 63 | 64 | exit 0 65 | -------------------------------------------------------------------------------- /src/libevent/eventpriv.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * eventpriv.h 4 | * 5 | * Abstraction of select call into "event-handling" to make programming 6 | * easier. This header includes "private" definitions which users 7 | * of the event-handling code should not care about. 8 | * 9 | * Copyright (C) 2001 Roaring Penguin Software Inc. 10 | * 11 | * This program may be distributed according to the terms of the GNU 12 | * General Public License, version 2 or (at your option) any later version. 13 | * 14 | * $Id$ 15 | * 16 | * LIC: GPL 17 | * 18 | ***********************************************************************/ 19 | 20 | #ifndef INCLUDE_EVENTPRIV_H 21 | #define INCLUDE_EVENTPRIV_H 1 22 | #include 23 | #include 24 | #include 25 | 26 | /* Handler structure */ 27 | typedef struct EventHandler_t { 28 | struct EventHandler_t *next; /* Link in list */ 29 | int fd; /* File descriptor for select */ 30 | unsigned int flags; /* Select on read or write; enable timeout */ 31 | struct timeval tmout; /* Absolute time for timeout */ 32 | EventCallbackFunc fn; /* Callback function */ 33 | void *data; /* Extra data to pass to callback */ 34 | } EventHandler; 35 | 36 | /* Selector structure */ 37 | typedef struct EventSelector_t { 38 | EventHandler *handlers; /* Linked list of EventHandlers */ 39 | int nestLevel; /* Event-handling nesting level */ 40 | int opsPending; /* True if operations are pending */ 41 | int destroyPending; /* If true, a destroy is pending */ 42 | } EventSelector; 43 | 44 | /* Private flags */ 45 | #define EVENT_FLAG_DELETED 256 46 | #endif 47 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | # LIC: GPL 2 | 3 | pppoe: a PPP-over-Ethernet redirector for pppd 4 | Copyright (C) 2001-2012 Roaring Penguin Software Inc. 5 | 6 | Some inspiration from an earlier client by Luke Stras. 7 | 8 | The MSS clamping was inspired by mssclampfw by Marc Boucher 9 | with acknowledgements to Rebel.com (http://www.rebel.com). However, the 10 | actual MSS clamping code is original and is licensed under the GPL, unlike 11 | the original mssclampfw. 12 | 13 | Introduction 14 | ============ 15 | 16 | pppoe is a user-space redirector which permits the use of PPPoE 17 | (Point-to-Point Over Ethernet) with Linux. PPPoE is used by many 18 | DSL service providers. 19 | 20 | Installation 21 | ============ 22 | 23 | Requirements 24 | ------------ 25 | 26 | 1) Linux 2.2.9 or later on Intel, Sparc or PowerPC. It may work on 27 | Alpha, too -- anyone care to let me know? 28 | 29 | OR 30 | 31 | Linux 2.0.36 or later. 32 | 33 | OR 34 | 35 | FreeBSD, NetBSD or OpenBSD with BPF support, though this is old, 36 | unmaintained, and may no longer work. 37 | 38 | 39 | 2) pppd 2.3.10 or later. Versions 2.3.7 and later work unless you use 40 | demand-dialling. For demand dialling, you *must* use 2.3.10 or later. 41 | 42 | QUICKSTART 43 | ---------- 44 | 45 | If you're lucky, the "quickstart" method will work. After unpacking 46 | the archive, become root and type: 47 | 48 | ./go 49 | 50 | This should configure, compile and install the software and set up your 51 | DSL connection. You'll have to answer a few questions along the way. 52 | 53 | If you want the GUI wrapper, type: 54 | 55 | ./go-gui 56 | 57 | If ./go and ./go-gui didn't work, read the rest of this README. 58 | 59 | Compiling 60 | --------- 61 | 62 | Compile and install pppd if you don't already have it. Then: 63 | 64 | 1) Unpack: 65 | 66 | $ tar xzvf rp-pppoe-xxx.tar.gz 67 | 68 | 2) Change to source directory: 69 | 70 | $ cd src 71 | 72 | 3) Configure: 73 | 74 | $ ./configure 75 | 76 | 4) Compile: 77 | 78 | $ make 79 | 80 | 4) Install (this step must be done as root) 81 | 82 | # make install 83 | 84 | 5) Now read doc/HOW-TO-CONNECT 85 | 86 | -- 87 | David F. Skoll | Roaring Penguin Software Inc. 88 | http://www.roaringpenguin.com 89 | -------------------------------------------------------------------------------- /gui/Makefile.in: -------------------------------------------------------------------------------- 1 | # @configure_input@ 2 | #*********************************************************************** 3 | # 4 | # Makefile 5 | # 6 | # Makefile for GUI for Roaring Penguin's Linux user-space PPPoE client. 7 | # 8 | # Copyright (C) 2001 Roaring Penguin Software Inc. 9 | # 10 | # This program may be distributed according to the terms of the GNU 11 | # General Public License, version 2 or (at your option) any later version. 12 | # 13 | # LIC: GPL 14 | # 15 | # $Id$ 16 | #*********************************************************************** 17 | DEFINES= 18 | prefix=@prefix@ 19 | exec_prefix=@exec_prefix@ 20 | mandir=@mandir@ 21 | install=@INSTALL@ 22 | install_dir=@INSTALL@ -d 23 | sbindir=@sbindir@ 24 | bindir=@bindir@ 25 | datadir=@datadir@ 26 | 27 | PPPOE_START_PATH=@sbindir@/pppoe-start 28 | PPPOE_STOP_PATH=@sbindir@/pppoe-stop 29 | PPPOE_STATUS_PATH=@sbindir@/pppoe-status 30 | 31 | PATHS='-DPPPOE_START_PATH="$(PPPOE_START_PATH)"' '-DPPPOE_STOP_PATH="$(PPPOE_STOP_PATH)"' '-DPPPOE_STATUS_PATH="$(PPPOE_STATUS_PATH)"' 32 | 33 | CFLAGS= @CFLAGS@ $(DEFINES) $(PATHS) 34 | 35 | all: pppoe-wrapper 36 | @echo "" 37 | @echo "Type 'make install' as root to install the software." 38 | 39 | pppoe-wrapper: wrapper.o 40 | @CC@ -o pppoe-wrapper wrapper.o 41 | 42 | wrapper.o: wrapper.c 43 | @CC@ $(CFLAGS) -c -o wrapper.o wrapper.c 44 | 45 | install: all 46 | -mkdir -p $(DESTDIR)$(sbindir) 47 | -mkdir -p $(DESTDIR)$(bindir) 48 | -mkdir -p $(DESTDIR)/etc/ppp/rp-pppoe-gui 49 | $(install) -m 4755 -s pppoe-wrapper $(DESTDIR)$(sbindir) 50 | $(install) -m 755 tkpppoe $(DESTDIR)$(bindir) 51 | -mkdir -p $(DESTDIR)$(mandir)/man1 52 | $(install) -m 644 pppoe-wrapper.1 $(DESTDIR)$(mandir)/man1 53 | $(install) -m 644 tkpppoe.1 $(DESTDIR)$(mandir)/man1 54 | -mkdir -p $(DESTDIR)$(datadir)/tkpppoe 55 | for i in tkpppoe.html mainwin-busy.png mainwin-nonroot.png mainwin.png props-advanced.png props-basic.png props-nic.png props-options.png; do \ 56 | $(install) -m 644 html/$$i $(DESTDIR)$(datadir)/tkpppoe; \ 57 | done 58 | for i in en.msg ja.msg; do \ 59 | $(install) -m 644 $$i $(DESTDIR)$(datadir)/tkpppoe; \ 60 | done 61 | 62 | clean: 63 | rm -f *.o *~ pppoe-wrapper 64 | 65 | distclean: clean 66 | rm -f Makefile tkpppoe 67 | 68 | .PHONY: clean 69 | 70 | .PHONY: distclean 71 | -------------------------------------------------------------------------------- /go-gui: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # LIC: GPL 3 | #*********************************************************************** 4 | # 5 | # go-gui 6 | # 7 | # Quick-start shell script to set up PPPoE and GUI wrapper 8 | # 9 | # Copyright (C) 2000 Roaring Penguin Software Inc. 10 | # 11 | # $Id$ 12 | #*********************************************************************** 13 | 14 | # GUI only works on Linux 15 | if test "`uname`" != "Linux" ; then 16 | echo "Sorry, the GUI only works on Linux." 17 | exit 1 18 | fi 19 | 20 | # Figure out directory of script 21 | MYDIR=`dirname $0` 22 | cd $MYDIR/src 23 | 24 | echo "Running ./configure..." 25 | ./configure 26 | if [ "$?" != 0 ] ; then 27 | echo "Oops! It looks like ./configure failed." 28 | exit 1 29 | fi 30 | 31 | echo "Running make..." 32 | make 33 | if [ "$?" != 0 ] ; then 34 | echo "Oops! It looks like make failed." 35 | exit 1 36 | fi 37 | 38 | echo "Running make install..." 39 | make install 40 | 41 | if [ "$?" != 0 ] ; then 42 | echo "Oops! It looks like make install failed." 43 | exit 1 44 | fi 45 | 46 | echo "Building GUI wrapper..." 47 | cd ../gui 48 | make 49 | if [ "$?" != 0 ] ; then 50 | echo "Oops! It looks like make failed." 51 | exit 1 52 | fi 53 | 54 | echo "Installing GUI..." 55 | make install 56 | 57 | if [ "$?" != 0 ] ; then 58 | echo "Oops! It looks like make install failed." 59 | exit 1 60 | fi 61 | 62 | # Install entry in KDE menu 63 | if test -n "$KDEDIR" ; then 64 | echo "Installing KDE menu entry Internet : TkPPPoE..." 65 | mkdir -p "$KDEDIR/share/applnk/Internet" 66 | cat < "$KDEDIR/share/applnk/Internet/tkpppoe.kdelnk" 67 | # KDE Config File 68 | [KDE Desktop Entry] 69 | Name=TkPPPoE 70 | Comment=Start/Stop PPPoE connections 71 | Exec=tkpppoe 72 | Terminal=0 73 | Type=Application 74 | EOF 75 | fi 76 | 77 | # Install entry in GNOME menus 78 | GNOMEDIR=`gnome-config --datadir 2>/dev/null` 79 | if test -n "$GNOMEDIR" ; then 80 | echo "Installing GNOME menu entry Internet : TkPPPoE..." 81 | mkdir -p "$GNOMEDIR/gnome/apps/Internet" 82 | cat < "$GNOMEDIR/gnome/apps/Internet/tkpppoe.desktop" 83 | [Desktop Entry] 84 | Name=TkPPPoE 85 | Comment=Start/Stop PPPoE connections 86 | Exec=tkpppoe 87 | Terminal=0 88 | Type=Application 89 | EOF 90 | fi 91 | echo "Running GUI configuration tool..." 92 | tkpppoe & 93 | exit 0 94 | -------------------------------------------------------------------------------- /src/libevent/event_tcp.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * event-tcp.h 4 | * 5 | * Event-driven TCP functions to allow for single-threaded "concurrent" 6 | * server. 7 | * 8 | * Copyright (C) 2001 Roaring Penguin Software Inc. 9 | * 10 | * $Id$ 11 | * 12 | * This program may be distributed according to the terms of the GNU 13 | * General Public License, version 2 or (at your option) any later version. 14 | * 15 | * LIC: GPL 16 | * 17 | ***********************************************************************/ 18 | 19 | #ifndef INCLUDE_EVENT_TCP_H 20 | #define INCLUDE_EVENT_TCP_H 1 21 | 22 | #include "event.h" 23 | #include 24 | 25 | typedef void (*EventTcpAcceptFunc)(EventSelector *es, 26 | int fd); 27 | 28 | typedef void (*EventTcpConnectFunc)(EventSelector *es, 29 | int fd, 30 | int flag, 31 | void *data); 32 | 33 | typedef void (*EventTcpIOFinishedFunc)(EventSelector *es, 34 | int fd, 35 | char *buf, 36 | int len, 37 | int flag, 38 | void *data); 39 | 40 | #define EVENT_TCP_FLAG_COMPLETE 0 41 | #define EVENT_TCP_FLAG_IOERROR 1 42 | #define EVENT_TCP_FLAG_EOF 2 43 | #define EVENT_TCP_FLAG_TIMEOUT 3 44 | 45 | typedef struct EventTcpState_t { 46 | int socket; 47 | char *buf; 48 | char *cur; 49 | int len; 50 | int delim; 51 | EventTcpIOFinishedFunc f; 52 | EventSelector *es; 53 | EventHandler *eh; 54 | void *data; 55 | } EventTcpState; 56 | 57 | extern EventHandler *EventTcp_CreateAcceptor(EventSelector *es, 58 | int socket, 59 | EventTcpAcceptFunc f); 60 | 61 | extern void EventTcp_Connect(EventSelector *es, 62 | int fd, 63 | struct sockaddr const *addr, 64 | socklen_t addrlen, 65 | EventTcpConnectFunc f, 66 | int timeout, 67 | void *data); 68 | 69 | extern EventTcpState *EventTcp_ReadBuf(EventSelector *es, 70 | int socket, 71 | int len, 72 | int delim, 73 | EventTcpIOFinishedFunc f, 74 | int timeout, 75 | void *data); 76 | 77 | extern EventTcpState *EventTcp_WriteBuf(EventSelector *es, 78 | int socket, 79 | char *buf, 80 | int len, 81 | EventTcpIOFinishedFunc f, 82 | int timeout, 83 | void *data); 84 | 85 | extern void EventTcp_CancelPending(EventTcpState *s); 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /scripts/pppoe-status: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #*********************************************************************** 3 | # 4 | # pppoe-status 5 | # 6 | # Shell script to report on status of PPPoE connection 7 | # 8 | # Copyright (C) 2000-2001 Roaring Penguin Software Inc. 9 | # 10 | # $Id$ 11 | # 12 | # This file may be distributed under the terms of the GNU General 13 | # Public License. 14 | # 15 | # LIC: GPL 16 | # 17 | # Usage: pppoe-status [config_file] 18 | # If config_file is omitted, defaults to /etc/ppp/pppoe.conf 19 | # 20 | #*********************************************************************** 21 | 22 | # Defaults 23 | CONFIG=/etc/ppp/pppoe.conf 24 | 25 | case "$#" in 26 | 1) 27 | CONFIG="$1" 28 | ;; 29 | esac 30 | 31 | if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then 32 | echo "$0: Cannot read configuration file '$CONFIG'" >& 2 33 | exit 1 34 | fi 35 | 36 | . $CONFIG 37 | 38 | PPPOE_PIDFILE="$PIDFILE.pppoe" 39 | PPPD_PIDFILE="$PIDFILE.pppd" 40 | 41 | if [ "$DEMAND" != "no" ] ; then 42 | echo "Note: You have enabled demand-connection; pppoe-status may be inaccurate." 43 | fi 44 | 45 | # If no PPPOE_PIDFILE, connection is down, unless we're using the Linux plugin 46 | if [ "$LINUX_PLUGIN" = "" ] ; then 47 | if [ ! -r "$PPPOE_PIDFILE" ] ; then 48 | echo "pppoe-status: Link is down (can't read pppoe PID file $PPPOE_PIDFILE)" 49 | exit 1 50 | fi 51 | fi 52 | 53 | # If no PPPD_PIDFILE, something fishy! 54 | if [ ! -r "$PPPD_PIDFILE" ] ; then 55 | echo "pppoe-status: Link is down (can't read pppd PID file $PPPD_PIDFILE)" 56 | exit 1 57 | fi 58 | 59 | PPPD_PID=`cat "$PPPD_PIDFILE"` 60 | 61 | # Sigh. Some versions of pppd put PID files in /var/run; others put them 62 | # in /etc/ppp. Since it's too messy to figure out what pppd does, we 63 | # try both locations. 64 | for i in /etc/ppp/ppp*.pid /var/run/ppp*.pid ; do 65 | if [ -r $i ] ; then 66 | PID=`cat $i` 67 | if [ "$PID" = "$PPPD_PID" ] ; then 68 | IF=`basename $i .pid` 69 | netstat -rn | grep " ${IF}\$" > /dev/null 70 | # /sbin/ifconfig $IF | grep "UP.*POINTOPOINT" > /dev/null 71 | if [ "$?" != "0" ] ; then 72 | echo "pppoe-status: Link is attached to $IF, but $IF is down" 73 | exit 1 74 | fi 75 | echo "pppoe-status: Link is up and running on interface $IF" 76 | /sbin/ifconfig $IF 77 | exit 0 78 | fi 79 | fi 80 | done 81 | 82 | echo "pppoe-status: Link is down -- could not find interface corresponding to" 83 | echo "pppd pid $PPPD_PID" 84 | exit 1 -------------------------------------------------------------------------------- /configs/firewall-masq: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # firewall-masq This script sets up firewall rules for a machine 4 | # acting as a masquerading gateway 5 | # 6 | # Copyright (C) 2000 Roaring Penguin Software Inc. This software may 7 | # be distributed under the terms of the GNU General Public License, version 8 | # 2 or any later version. 9 | # LIC: GPL 10 | 11 | # Interface to Internet 12 | EXTIF=ppp+ 13 | 14 | # NAT-Tables are different, so we can use ACCEPT everywhere (?) 15 | iptables -t nat -P PREROUTING ACCEPT 16 | iptables -t nat -P OUTPUT ACCEPT 17 | iptables -t nat -P POSTROUTING ACCEPT 18 | 19 | # Flush the NAT-Table 20 | iptables -t nat -F 21 | 22 | iptables -t filter -P INPUT DROP 23 | iptables -t filter -F 24 | 25 | # Allow incoming SSH 26 | #iptables -t filter -A INPUT -i $EXTIF -p tcp --dport 22 -j ACCEPT 27 | 28 | # Log & Deny the rest of the privileged ports 29 | iptables -t filter -A INPUT -i $EXTIF -p tcp --dport 0:1023 -j LOG 30 | iptables -t filter -A INPUT -i $EXTIF -p udp --dport 0:1023 -j LOG 31 | iptables -t filter -A INPUT -i $EXTIF -p tcp --dport 0:1023 -j DROP 32 | iptables -t filter -A INPUT -i $EXTIF -p udp --dport 0:1023 -j DROP 33 | 34 | # Log & Deny NFS 35 | iptables -t filter -A INPUT -i $EXTIF -p udp --dport 2049 -j LOG 36 | iptables -t filter -A INPUT -i $EXTIF -p tcp --dport 2049 -j LOG 37 | iptables -t filter -A INPUT -i $EXTIF -p udp --dport 2049 -j DROP 38 | iptables -t filter -A INPUT -i $EXTIF -p tcp --dport 2049 -j DROP 39 | 40 | # Log & Deny X11 41 | iptables -t filter -A INPUT -i $EXTIF -p tcp --dport 6000:6063 -j LOG 42 | iptables -t filter -A INPUT -i $EXTIF -p tcp --dport 6000:6063 -j DROP 43 | 44 | # Log & Deny XFS 45 | iptables -t filter -A INPUT -i $EXTIF -p tcp --dport 7100 -j LOG 46 | iptables -t filter -A INPUT -i $EXTIF -p tcp --dport 7100 -j DROP 47 | 48 | # Deny TCP connection attempts 49 | iptables -t filter -A INPUT -i $EXTIF -p tcp --syn -j LOG 50 | iptables -t filter -A INPUT -i $EXTIF -p tcp --syn -j DROP 51 | 52 | # Deny ICMP echo-requests 53 | iptables -t filter -A INPUT -i $EXTIF -p icmp --icmp-type echo-request -j DROP 54 | 55 | # Do masquerading 56 | iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE 57 | 58 | # Enable forwarding 59 | echo 1 > /proc/sys/net/ipv4/ip_forward 60 | 61 | # no IP spoofing 62 | if [ -e /proc/sys/net/ipv4/conf/all/rp_filter ] ; then 63 | for i in /proc/sys/net/ipv4/conf/*/rp_filter; do 64 | echo 1 > $i 65 | done 66 | fi 67 | 68 | # Disable Source Routed Packets 69 | for i in /proc/sys/net/ipv4/conf/*/accept_source_route; do 70 | echo 0 > $i 71 | done 72 | -------------------------------------------------------------------------------- /man/pppoe-connect.8: -------------------------------------------------------------------------------- 1 | .\" LIC: GPL 2 | .TH PPPOE-CONNECT 8 "21 February 2000" 3 | .UC 4 4 | .SH NAME 5 | pppoe-connect \- Shell script to manage a PPPoE link 6 | 7 | .SH SYNOPSIS 8 | .B pppoe-connect \fR[\fIconfig_file\fR] 9 | .P 10 | .B pppoe-connect \fR\fIinterface user\fR [\fIconfig_file\fR] 11 | 12 | 13 | .SH DESCRIPTION 14 | \fBpppoe-connect\fR is a shell script which manages a PPPoE connection 15 | using the Roaring Penguin user-space PPPoE client. If you omit 16 | \fIconfig_file\fR, the default file \fB/etc/ppp/pppoe.conf\fR is used. 17 | If you supply \fIinterface\fR and \fIuser\fR, then they override the 18 | Ethernet interface and user-name settings in the configuration file. 19 | .P 20 | Note that normally, you should \fInot\fR invoke \fBpppoe-connect\fR 21 | directly. Instead, use \fBpppoe-start\fR to bring up the PPPoE connection. 22 | .P 23 | \fBpppoe-connect\fR first reads a configuration file. It then brings 24 | up a PPPoE connection. If the connection ever drops, a message is logged 25 | to syslog, and \fBpppoe-connect\fR re-establishes the connection. In addition, 26 | each time the connection is dropped or cannot be established, 27 | \fBpppoe-connect\fR executes the script \fB/etc/ppp/pppoe-lost\fR if it 28 | exists and is executable. 29 | 30 | .P 31 | The shell script \fBpppoe-stop\fR causes \fBpppoe-connect\fR to break out 32 | of its loop, bring the connection down, and exit. 33 | 34 | .SH TECHNICAL DETAILS 35 | \fBpppoe-connect\fR uses the following shell variables from the 36 | configuration file: 37 | 38 | .TP 39 | .B ETH 40 | The Ethernet interface connected to the DSL modem (for example, eth0). 41 | 42 | .TP 43 | .B USER 44 | The PPPoE user-id (for example, b1xxnxnx@sympatico.ca). 45 | 46 | .TP 47 | .B PIDFILE 48 | A file in which to write the process-ID of the pppoe-connect process 49 | (for example, \fB/var/run/pppoe.pid\fR). Two additional files 50 | ($PIDFILE.pppd and $PIDFILE.pppoe) hold the process-ID's of the 51 | \fBpppd\fR and \fBpppoe\fR processes, respectively. 52 | 53 | .P 54 | By using different configuration files with different PIDFILE 55 | settings, you can manage multiple PPPoE connections. Just specify the 56 | configuration file as an argument to \fBpppoe-start\fR and 57 | \fBpppoe-stop\fR. 58 | 59 | .SH AUTHOR 60 | \fBpppoe-connect\fR was written by David F. Skoll . 61 | 62 | The \fBpppoe\fR home page is \fIhttp://www.roaringpenguin.com/pppoe/\fR. 63 | 64 | .SH SEE ALSO 65 | pppoe(8), pppoe-start(8), pppoe-stop(8), pppd(8), pppoe.conf(5), pppoe-setup(8), pppoe-status(8), pppoe-sniff(8), pppoe-server(8), pppoe-relay(8) 66 | 67 | -------------------------------------------------------------------------------- /scripts/pppoe-stop.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # @configure_input@ 3 | #*********************************************************************** 4 | # 5 | # pppoe-stop 6 | # 7 | # Shell script to bring down a PPPoE connection 8 | # 9 | # Copyright (C) 2000 Roaring Penguin Software Inc. 10 | # 11 | # $Id$ 12 | # 13 | # This file may be distributed under the terms of the GNU General 14 | # Public License. 15 | # 16 | # LIC: GPL 17 | # 18 | # Usage: pppoe-stop [config_file] 19 | # If config_file is omitted, defaults to /etc/ppp/pppoe.conf 20 | # 21 | #*********************************************************************** 22 | 23 | # Set to "C" locale so we can parse messages from commands 24 | LANG=C 25 | export LANG 26 | 27 | ME="`basename $0`" 28 | LOGGER="/usr/bin/logger -t $ME" 29 | CONFIG="$1" 30 | if [ "$CONFIG" = "" ] ; then 31 | CONFIG=/etc/ppp/pppoe.conf 32 | fi 33 | 34 | if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then 35 | echo "$ME: Cannot read configuration file '$CONFIG'" >& 2 36 | exit 1 37 | fi 38 | export CONFIG 39 | . $CONFIG 40 | 41 | PPPOE_PIDFILE="$PIDFILE.pppoe" 42 | PPPD_PIDFILE="$PIDFILE.pppd" 43 | STARTPID="$PIDFILE.start" 44 | 45 | # Backward config file compatibility 46 | if test "$DEMAND" = "" ; then 47 | DEMAND=no 48 | fi 49 | 50 | # Ignore SIGTERM 51 | trap "" 15 52 | 53 | # Check for pidfile 54 | if [ -r "$PIDFILE" ] ; then 55 | PID=`cat $PIDFILE` 56 | 57 | # Check if still running 58 | kill -0 $PID > /dev/null 2>&1 59 | if [ $? != 0 ] ; then 60 | echo "$ME: The pppoe-connect script (PID $PID) appears to have died" >& 2 61 | fi 62 | 63 | # Kill pppd, which should in turn kill pppoe 64 | if [ -r "$PPPD_PIDFILE" ] ; then 65 | PPPD_PID=`cat "$PPPD_PIDFILE"` 66 | $LOGGER -p daemon.notice "Killing pppd" 67 | echo "Killing pppd ($PPPD_PID)" 68 | kill $PPPD_PID > /dev/null 2>&1 || exit 1 69 | fi 70 | 71 | # Kill pppoe-start 72 | PIDS=`cat $STARTPID` 73 | kill -0 $PIDS > /dev/null 2>&1 74 | if [ $? = 0 ] ; then 75 | $LOGGER -p daemon.notice "Killing pppoe-connect" 76 | kill $PIDS > /dev/null 2>&1 77 | fi 78 | 79 | # Kill pppoe-connect 80 | $LOGGER -p daemon.notice "Killing pppoe-connect" 81 | echo "Killing pppoe-connect ($PID)" 82 | kill -9 $PID > /dev/null 2>&1 83 | 84 | # Kill pppd again, in case it's still hanging around 85 | if [ -r "$PPPD_PIDFILE" ] ; then 86 | PPPD_PID=`cat "$PPPD_PIDFILE"` 87 | kill -9 $PPPD_PID > /dev/null 2>&1 || exit 1 88 | fi 89 | 90 | rm -f "$PIDFILE" "$PPPD_PIDFILE" "$PPPOE_PIDFILE" "$STARTPID" 91 | else 92 | echo "$ME: No PPPoE connection appears to be running" >&2 93 | exit 1 94 | fi 95 | 96 | exit 0 97 | -------------------------------------------------------------------------------- /man/pppoe-sniff.8: -------------------------------------------------------------------------------- 1 | .\" LIC: GPL 2 | .TH PPPOE-SNIFF 8 "3 July 2000" 3 | .\"" 4 | .UC 4 5 | .SH NAME 6 | pppoe-sniff \- examine network for non-standard PPPoE frames 7 | .SH SYNOPSIS 8 | .B pppoe-sniff \fR[\fIoptions\fR] 9 | 10 | .SH DESCRIPTION 11 | \fBpppoe-sniff\fR listens for likely-looking PPPoE PADR and session frames 12 | and deduces extra options required for \fBpppoe(8)\fR to work. 13 | 14 | Some DSL providers seem to use non-standard frame types for PPPoE frames, 15 | and/or require a certain value in the Service-Name field. It is often 16 | easier to sniff those values from a machine which can successfully connect 17 | rather than try to pry them out of the DSL provider. 18 | 19 | To use \fBpppoe-sniff\fR, you need two computers, a DSL modem and 20 | an Ethernet hub (\fInot\fR an Ethernet switch.) 21 | 22 | If the DSL modem normally connects directly to your computer's 23 | Ethernet card, connect it to the "uplink" port on the Ethernet hub. 24 | Plug two computers into normal ports on the hub. On one computer, run 25 | whatever software the DSL provider gave you on whatever operating 26 | system the DSL provider supports. On the other computer, run Linux and 27 | log in as root. 28 | 29 | On the Linux machine, put the Ethernet interface into promiscuous mode 30 | and start \fBpppoe-sniff\fR. If the ethernet interface is \fIeth0\fR, 31 | for example, type these commands: 32 | 33 | .nf 34 | ifconfig eth0 promisc 35 | pppoe-sniff -I eth0 36 | .fi 37 | 38 | On the other machine, start your DSL connection as usual. After a short 39 | time, \fBpppoe-sniff\fR should print recommendations for the value 40 | of \fBPPPOE_EXTRA\fR. Set this value in \fB/etc/ppp/pppoe.conf\fR. 41 | If \fBpppoe-sniff\fR indicates that something special is required in 42 | \fBPPPOE_EXTRA\fR, please e-mail this to \fBpppoe@roaringpenguin.com\fR 43 | along with the name of your ISP and the manufacturer and model number of 44 | your DSL modem. This information will be collated and provided on the 45 | PPPoE web page for users who do not have two computers. 46 | 47 | After \fBpppoe-sniff\fR finishes (or you stop it if it seems hung), 48 | remember to turn off promiscuous mode: 49 | 50 | .nf 51 | ifconfig eth0 -promisc 52 | .fi 53 | 54 | .SH OPTIONS 55 | .TP 56 | .B \-I \fIinterface\fR 57 | The \fB\-I\fR option specifies the Ethernet interface to use. Under Linux, 58 | it is typically \fIeth0\fR or \fIeth1\fR. The interface should be "up" 59 | and in promiscuous mode before you start \fBpppoe-sniff\fR. 60 | 61 | .TP 62 | .B \-V 63 | The \fB\-V\fR option causes \fBpppoe-sniff\fR to print its version number and 64 | exit. 65 | 66 | .SH BUGS 67 | \fBpppoe-sniff\fR only works on Linux. 68 | 69 | .SH AUTHORS 70 | \fBpppoe-sniff\fR was written by David F. Skoll . 71 | 72 | The \fBpppoe\fR home page is \fIhttp://www.roaringpenguin.com/pppoe/\fR. 73 | 74 | .SH SEE ALSO 75 | pppoe-start(8), pppoe-stop(8), pppoe-connect(8), pppd(8), pppoe.conf(5), 76 | pppoe(8), pppoe-setup(8), pppoe-status(8), pppoe-server(8), pppoe-relay(8) 77 | 78 | -------------------------------------------------------------------------------- /src/libevent/event.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * event.h 4 | * 5 | * Abstraction of select call into "event-handling" to make programming 6 | * easier. 7 | * 8 | * Copyright (C) 2001 Roaring Penguin Software Inc. 9 | * 10 | * This program may be distributed according to the terms of the GNU 11 | * General Public License, version 2 or (at your option) any later version. 12 | * 13 | * $Id$ 14 | * 15 | * LIC: GPL 16 | * 17 | ***********************************************************************/ 18 | 19 | #define DEBUG_EVENT 20 | 21 | #ifndef INCLUDE_EVENT_H 22 | #define INCLUDE_EVENT_H 1 23 | 24 | /* Solaris moans if we don't do this... */ 25 | #ifdef __sun 26 | #define __EXTENSIONS__ 1 27 | #endif 28 | 29 | struct EventSelector_t; 30 | 31 | /* Callback function */ 32 | typedef void (*EventCallbackFunc)(struct EventSelector_t *es, 33 | int fd, unsigned int flags, 34 | void *data); 35 | 36 | #include "eventpriv.h" 37 | 38 | /* Create an event selector */ 39 | extern EventSelector *Event_CreateSelector(void); 40 | 41 | /* Destroy the event selector */ 42 | extern void Event_DestroySelector(EventSelector *es); 43 | 44 | /* Handle one event */ 45 | extern int Event_HandleEvent(EventSelector *es); 46 | 47 | /* Add a handler for a ready file descriptor */ 48 | extern EventHandler *Event_AddHandler(EventSelector *es, 49 | int fd, 50 | unsigned int flags, 51 | EventCallbackFunc fn, void *data); 52 | 53 | /* Add a handler for a ready file descriptor with associated timeout*/ 54 | extern EventHandler *Event_AddHandlerWithTimeout(EventSelector *es, 55 | int fd, 56 | unsigned int flags, 57 | struct timeval t, 58 | EventCallbackFunc fn, 59 | void *data); 60 | 61 | 62 | /* Add a timer handler */ 63 | extern EventHandler *Event_AddTimerHandler(EventSelector *es, 64 | struct timeval t, 65 | EventCallbackFunc fn, 66 | void *data); 67 | 68 | /* Change the timeout of a timer handler */ 69 | void Event_ChangeTimeout(EventHandler *handler, struct timeval t); 70 | 71 | /* Delete a handler */ 72 | extern int Event_DelHandler(EventSelector *es, 73 | EventHandler *eh); 74 | 75 | /* Retrieve callback function from a handler */ 76 | extern EventCallbackFunc Event_GetCallback(EventHandler *eh); 77 | 78 | /* Retrieve data field from a handler */ 79 | extern void *Event_GetData(EventHandler *eh); 80 | 81 | /* Set callback and data to new values */ 82 | extern void Event_SetCallbackAndData(EventHandler *eh, 83 | EventCallbackFunc fn, 84 | void *data); 85 | 86 | /* Handle a signal synchronously in event loop */ 87 | int Event_HandleSignal(EventSelector *es, int sig, void (*handler)(int sig)); 88 | 89 | /* Reap children synchronously in event loop */ 90 | int Event_HandleChildExit(EventSelector *es, pid_t pid, 91 | void (*handler)(pid_t, int, void *), void *data); 92 | 93 | extern int Event_EnableDebugging(char const *fname); 94 | 95 | #ifdef DEBUG_EVENT 96 | extern void Event_DebugMsg(char const *fmt, ...); 97 | #define EVENT_DEBUG(x) Event_DebugMsg x 98 | #else 99 | #define EVENT_DEBUG(x) ((void) 0) 100 | #endif 101 | 102 | /* Flags */ 103 | #define EVENT_FLAG_READABLE 1 104 | #define EVENT_FLAG_WRITEABLE 2 105 | #define EVENT_FLAG_WRITABLE EVENT_FLAG_WRITEABLE 106 | 107 | /* This is strictly a timer event */ 108 | #define EVENT_FLAG_TIMER 4 109 | 110 | /* This is a read or write event with an associated timeout */ 111 | #define EVENT_FLAG_TIMEOUT 8 112 | 113 | #define EVENT_TIMER_BITS (EVENT_FLAG_TIMER | EVENT_FLAG_TIMEOUT) 114 | #endif 115 | -------------------------------------------------------------------------------- /doc/KERNEL-MODE-PPPOE: -------------------------------------------------------------------------------- 1 | # LIC: GPL 2 | 3 | RP-PPPoE now supports kernel-mode PPPoE on Linux kernels 2.4 or newer. 4 | However, the default "./go" build procedure does not make kernel-mode 5 | support. 6 | 7 | Here's what you need to do: 8 | 9 | 0) Make sure you are running kernel 2.4 or newer on the machine you 10 | will build rp-pppoe on. You must have the following kernel 11 | configuration settings: 12 | 13 | CONFIG_PPP=m or CONFIG_PPP=y 14 | CONFIG_PPP_ASYNC=m or CONFIG_PPP_ASYNC=y 15 | CONFIG_PPP_SYNC_TTY=m or CONFIG_PPP_SYNC_TTY=y 16 | CONFIG_PPP_DEFLATE=m or CONFIG_PPP_DEFLATE=y 17 | CONFIG_PPP_BSDCOMP=m or CONFIG_PPP_BSDCOMP=y 18 | CONFIG_PPPOE=m or CONFIG_PPPOE=y 19 | CONFIG_N_HDLC=m or CONFIG_N_HDLC=y 20 | CONFIG_UNIX98_PTYS=y 21 | 22 | You also need a /dev/ppp file: 23 | 24 | mknod --mode=664 /dev/ppp c 108 0 25 | 26 | You might want to add these lines to /etc/modules.conf: 27 | 28 | alias char-major-108 ppp_generic 29 | alias tty-ldisc-3 ppp_async 30 | alias tty-ldisc-13 n_hdlc 31 | alias tty-ldisc-14 ppp_synctty 32 | alias net-pf-24 pppoe 33 | 34 | 1) If you are running pppd older than 2.4.0, check out the latest 35 | version of the PPP software from the CVS repository at cvs.samba.org. 36 | Here's how to do this: 37 | 38 | cvs -d :pserver:cvs@pserver.samba.org:/cvsroot login 39 | # When prompted for a password, type "cvs" 40 | 41 | # Change to the directory in which you want to store the PPP source 42 | # code. 43 | cd /path/to/checked/out/sources 44 | 45 | # Check out the source 46 | cvs -z5 -d :pserver:cvs@pserver.samba.org:/cvsroot co ppp 47 | 48 | If you are running pppd 2.4.0 or newer, and have the pppd development 49 | headers installed, you can skip steps 1 and 2. 50 | 51 | 2) The source gets checked out into a subdirectory called ppp. If 52 | the source ends up in /path/to/checked/out/sources/ppp, then call 53 | that path $PPPDIR. 54 | 55 | Build and install the checked-out ppp code according to its instructions. 56 | 57 | 3) Unpack rp-pppoe. 58 | 59 | 4) In the rp-pppoe directory, change to src/ and type: 60 | 61 | ./configure --enable-plugin=$PPPDIR 62 | 63 | where $PPPDIR, of course, refers to the checked-out "ppp" directory 64 | from cvs.samba.org. 65 | 66 | If you didn't check out the PPP software from cvs.samba.org, use: 67 | 68 | ./configure --enable-plugin 69 | 70 | This will work if the header pppd/pppd.h is located in /usr/include 71 | or /usr/local/include. 72 | 73 | 4) Type make; make install 74 | 75 | 5) Edit /etc/ppp/pppoe.conf to include this line: 76 | 77 | LINUX_PLUGIN=/etc/ppp/plugins/rp-pppoe.so 78 | 79 | After that, pppoe-start should use kernel-mode PPPoE. 80 | 81 | The rp-pppoe.so plugin adds the following command-line options to pppd: 82 | 83 | ethXXX -- Use interface ethXXX as Ethernet interface 84 | brXXX -- Use interface brXXX as Ethernet interface 85 | nic-XXXX -- Use interface XXXX as the Ethernet interface 86 | 87 | rp_pppoe_service SERVICE_NAME -- Specify desired service name 88 | rp_pppoe_ac NAME -- Specify desired access concentrator name 89 | rp_pppoe_verbose 0|1 -- Print names of access concentrators 90 | 91 | rp_pppoe_sess nnnn:aa:bb:cc:dd:ee:ff -- Attach to existing session 'nnnn' 92 | on AC with Ethernet address aa:bb:cc:dd:ee:ff 93 | This skips the discovery phase. 94 | 95 | rp_pppoe_mac aa:bb:cc:dd:ee:ff -- only accept PADOs from specified MAC address 96 | 97 | The kernel-mode PPPoE plugin permits an MTU of up to 1500 on the PPP 98 | interface providing that the MTU on the underlying Ethernet interface 99 | is at least 1508. In /etc/ppp/pppoe.conf, set MTU=1500 and MRU=1500 to 100 | enable the larger PPP MTU. The larger PPP MTU is negotiated according 101 | to RFC 4638. 102 | 103 | -- 104 | David F. Skoll 105 | 106 | -------------------------------------------------------------------------------- /src/relay.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * relay.h 4 | * 5 | * Definitions for PPPoE relay 6 | * 7 | * Copyright (C) 2001-2006 Roaring Penguin Software Inc. 8 | * 9 | * This program may be distributed according to the terms of the GNU 10 | * General Public License, version 2 or (at your option) any later version. 11 | * 12 | * LIC: GPL 13 | * 14 | * $Id$ 15 | * 16 | ***********************************************************************/ 17 | 18 | #include "pppoe.h" 19 | 20 | /* Description for each active Ethernet interface */ 21 | typedef struct InterfaceStruct { 22 | char name[IFNAMSIZ+1]; /* Interface name */ 23 | int discoverySock; /* Socket for discovery frames */ 24 | int sessionSock; /* Socket for session frames */ 25 | int clientOK; /* Client requests allowed (PADI, PADR) */ 26 | int acOK; /* AC replies allowed (PADO, PADS) */ 27 | unsigned char mac[ETH_ALEN]; /* MAC address */ 28 | } PPPoEInterface; 29 | 30 | /* Session state for relay */ 31 | struct SessionHashStruct; 32 | typedef struct SessionStruct { 33 | struct SessionStruct *next; /* Free list link */ 34 | struct SessionStruct *prev; /* Free list link */ 35 | struct SessionHashStruct *acHash; /* Hash bucket for AC MAC/Session */ 36 | struct SessionHashStruct *clientHash; /* Hash bucket for client MAC/Session */ 37 | unsigned int epoch; /* Epoch when last activity was seen */ 38 | UINT16_t sesNum; /* Session number assigned by relay */ 39 | } PPPoESession; 40 | 41 | /* Hash table entry to find sessions */ 42 | typedef struct SessionHashStruct { 43 | struct SessionHashStruct *next; /* Link in hash chain */ 44 | struct SessionHashStruct *prev; /* Link in hash chain */ 45 | struct SessionHashStruct *peer; /* Peer for this session */ 46 | PPPoEInterface const *interface; /* Interface */ 47 | unsigned char peerMac[ETH_ALEN]; /* Peer's MAC address */ 48 | UINT16_t sesNum; /* Session number */ 49 | PPPoESession *ses; /* Session data */ 50 | } SessionHash; 51 | 52 | /* Function prototypes */ 53 | 54 | void relayGotSessionPacket(PPPoEInterface const *i); 55 | void relayGotDiscoveryPacket(PPPoEInterface const *i); 56 | PPPoEInterface *findInterface(int sock); 57 | unsigned int hash(unsigned char const *mac, UINT16_t sesNum); 58 | SessionHash *findSession(unsigned char const *mac, UINT16_t sesNum); 59 | void deleteHash(SessionHash *hash); 60 | PPPoESession *createSession(PPPoEInterface const *ac, 61 | PPPoEInterface const *cli, 62 | unsigned char const *acMac, 63 | unsigned char const *cliMac, 64 | UINT16_t acSes); 65 | void freeSession(PPPoESession *ses, char const *msg); 66 | void addInterface(char const *ifname, int clientOK, int acOK); 67 | void usage(char const *progname); 68 | void initRelay(int nsess); 69 | void relayLoop(void); 70 | void addHash(SessionHash *sh); 71 | void unhash(SessionHash *sh); 72 | 73 | void relayHandlePADT(PPPoEInterface const *iface, PPPoEPacket *packet, int size); 74 | void relayHandlePADI(PPPoEInterface const *iface, PPPoEPacket *packet, int size); 75 | void relayHandlePADO(PPPoEInterface const *iface, PPPoEPacket *packet, int size); 76 | void relayHandlePADR(PPPoEInterface const *iface, PPPoEPacket *packet, int size); 77 | void relayHandlePADS(PPPoEInterface const *iface, PPPoEPacket *packet, int size); 78 | 79 | int addTag(PPPoEPacket *packet, PPPoETag const *tag); 80 | int insertBytes(PPPoEPacket *packet, unsigned char *loc, 81 | void const *bytes, int length); 82 | int removeBytes(PPPoEPacket *packet, unsigned char *loc, 83 | int length); 84 | void relaySendError(unsigned char code, 85 | UINT16_t session, 86 | PPPoEInterface const *iface, 87 | unsigned char const *mac, 88 | PPPoETag const *hostUniq, 89 | char const *errMsg); 90 | 91 | void alarmHandler(int sig); 92 | void cleanSessions(void); 93 | 94 | #define MAX_INTERFACES 8 95 | #define DEFAULT_SESSIONS 5000 96 | 97 | /* Hash table size -- a prime number; gives load factor of around 6 98 | for 65534 sessions */ 99 | #define HASHTAB_SIZE 18917 100 | -------------------------------------------------------------------------------- /src/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated automatically from configure.in by autoheader. */ 2 | /* LIC: GPL */ 3 | 4 | /* Define to empty if the keyword does not work. */ 5 | #undef const 6 | 7 | /* Define if you have that is POSIX.1 compatible. */ 8 | #undef HAVE_SYS_WAIT_H 9 | 10 | /* Define to `int' if doesn't define. */ 11 | #undef pid_t 12 | 13 | /* Define as the return type of signal handlers (int or void). */ 14 | #undef RETSIGTYPE 15 | 16 | /* Define if the setvbuf function takes the buffering type as its second 17 | argument and the buffer pointer as the third, as on System V 18 | before release 3. */ 19 | #undef SETVBUF_REVERSED 20 | 21 | /* Define if you have the ANSI C header files. */ 22 | #undef STDC_HEADERS 23 | 24 | /* Define if you can safely include both and . */ 25 | #undef TIME_WITH_SYS_TIME 26 | 27 | /* Define if your declares struct tm. */ 28 | #undef TM_IN_SYS_TIME 29 | 30 | #undef HAVE_STRUCT_SOCKADDR_LL 31 | 32 | /* The number of bytes in a unsigned int. */ 33 | #undef SIZEOF_UNSIGNED_INT 34 | 35 | /* The number of bytes in a unsigned long. */ 36 | #undef SIZEOF_UNSIGNED_LONG 37 | 38 | /* The number of bytes in a unsigned short. */ 39 | #undef SIZEOF_UNSIGNED_SHORT 40 | 41 | /* Define if you have the select function. */ 42 | #undef HAVE_SELECT 43 | 44 | /* Define if you have the socket function. */ 45 | #undef HAVE_SOCKET 46 | 47 | /* Define if you have the strerror function. */ 48 | #undef HAVE_STRERROR 49 | 50 | /* Define if you have the strtol function. */ 51 | #undef HAVE_STRTOL 52 | 53 | /* Define if you have the header file. */ 54 | #undef HAVE_ASM_TYPES_H 55 | 56 | /* Define if you have the header file. */ 57 | #undef HAVE_FCNTL_H 58 | 59 | /* Define if you have the header file. */ 60 | #undef HAVE_GETOPT_H 61 | 62 | /* Define if you have the header file. */ 63 | #undef HAVE_LINUX_IF_ETHER_H 64 | 65 | /* Define if you have kernel-mode PPPoE in Linux file. */ 66 | #undef HAVE_LINUX_KERNEL_PPPOE 67 | 68 | /* Define if you have the header file. */ 69 | #undef HAVE_LINUX_IF_PACKET_H 70 | 71 | /* Define if you have the header file. */ 72 | #undef HAVE_LINUX_IF_PPPOX_H 73 | 74 | /* Define if you have the header file. */ 75 | #undef HAVE_NET_BPF_H 76 | 77 | /* Define if you have the header file. */ 78 | #undef HAVE_NET_IF_ARP_H 79 | 80 | /* Define if you have the header file. */ 81 | #undef HAVE_NET_ETHERNET_H 82 | 83 | /* Define if you have the header file. */ 84 | #undef HAVE_NET_IF_H 85 | 86 | /* Define if you have the header file. */ 87 | #undef HAVE_LINUX_IF_H 88 | 89 | /* Define if you have the header file. */ 90 | #undef HAVE_NET_IF_DL_H 91 | 92 | /* Define if you have the header file. */ 93 | #undef HAVE_NET_IF_ETHER_H 94 | 95 | /* Define if you have the header file. */ 96 | #undef HAVE_NET_IF_TYPES_H 97 | 98 | /* Define if you have the header file. */ 99 | #undef HAVE_NETINET_IF_ETHER_H 100 | 101 | /* Define if you have the header file. */ 102 | #undef HAVE_NETPACKET_PACKET_H 103 | 104 | /* Define if you have the header file. */ 105 | #undef HAVE_SYS_CDEFS_H 106 | 107 | /* Define if you have the header file. */ 108 | #undef HAVE_SYS_DLPI_H 109 | 110 | /* Define if you have the header file. */ 111 | #undef HAVE_SYS_IOCTL_H 112 | 113 | /* Define if you have the header file. */ 114 | #undef HAVE_SYS_PARAM_H 115 | 116 | /* Define if you have the header file. */ 117 | #undef HAVE_SYS_SOCKET_H 118 | 119 | /* Define if you have the header file. */ 120 | #undef HAVE_SYS_TIME_H 121 | 122 | /* Define if you have the header file. */ 123 | #undef HAVE_SYS_UIO_H 124 | 125 | /* Define if you have the header file. */ 126 | #undef HAVE_SYSLOG_H 127 | 128 | /* Define if you have the header file. */ 129 | #undef HAVE_UNISTD_H 130 | 131 | /* Define if you have the N_HDLC line discipline in linux/termios.h */ 132 | #undef HAVE_N_HDLC 133 | 134 | /* Define if bitfields are packed in reverse order */ 135 | #undef PACK_BITFIELDS_REVERSED 136 | 137 | /* Define to include debugging code */ 138 | #undef DEBUGGING_ENABLED 139 | 140 | /* Solaris moans if we don't do this... */ 141 | #ifdef __sun 142 | #define __EXTENSIONS__ 1 143 | #endif 144 | -------------------------------------------------------------------------------- /src/debug.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * debug.c 4 | * 5 | * Implementation of user-space PPPoE redirector for Linux. 6 | * 7 | * Functions for printing debugging information 8 | * 9 | * Copyright (C) 2000 by Roaring Penguin Software Inc. 10 | * 11 | * This program may be distributed according to the terms of the GNU 12 | * General Public License, version 2 or (at your option) any later version. 13 | * 14 | * LIC: GPL 15 | * 16 | ***********************************************************************/ 17 | 18 | static char const RCSID[] = 19 | "$Id$"; 20 | 21 | #include "pppoe.h" 22 | 23 | #ifdef DEBUGGING_ENABLED 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | /********************************************************************** 31 | *%FUNCTION: dumpHex 32 | *%ARGUMENTS: 33 | * fp -- file to dump to 34 | * buf -- buffer to dump 35 | * len -- length of data 36 | *%RETURNS: 37 | * Nothing 38 | *%DESCRIPTION: 39 | * Dumps buffer to fp in an easy-to-read format 40 | ***********************************************************************/ 41 | void 42 | dumpHex(FILE *fp, unsigned char const *buf, int len) 43 | { 44 | int i; 45 | int base; 46 | 47 | if (!fp) return; 48 | 49 | /* do NOT dump PAP packets */ 50 | if (len >= 2 && buf[0] == 0xC0 && buf[1] == 0x23) { 51 | fprintf(fp, "(PAP Authentication Frame -- Contents not dumped)\n"); 52 | return; 53 | } 54 | 55 | for (base=0; baselength); 94 | 95 | /* Sheesh... printing times is a pain... */ 96 | struct timeval tv; 97 | time_t now; 98 | int millisec; 99 | struct tm *lt; 100 | char timebuf[256]; 101 | 102 | UINT16_t type = etherType(packet); 103 | if (!fp) return; 104 | gettimeofday(&tv, NULL); 105 | now = (time_t) tv.tv_sec; 106 | millisec = tv.tv_usec / 1000; 107 | lt = localtime(&now); 108 | strftime(timebuf, 256, "%H:%M:%S", lt); 109 | fprintf(fp, "%s.%03d %s PPPoE ", timebuf, millisec, dir); 110 | if (type == Eth_PPPOE_Discovery) { 111 | fprintf(fp, "Discovery (%x) ", (unsigned) type); 112 | } else if (type == Eth_PPPOE_Session) { 113 | fprintf(fp, "Session (%x) ", (unsigned) type); 114 | } else { 115 | fprintf(fp, "Unknown (%x) ", (unsigned) type); 116 | } 117 | 118 | switch(packet->code) { 119 | case CODE_PADI: fprintf(fp, "PADI "); break; 120 | case CODE_PADO: fprintf(fp, "PADO "); break; 121 | case CODE_PADR: fprintf(fp, "PADR "); break; 122 | case CODE_PADS: fprintf(fp, "PADS "); break; 123 | case CODE_PADT: fprintf(fp, "PADT "); break; 124 | case CODE_PADM: fprintf(fp, "PADM "); break; 125 | case CODE_PADN: fprintf(fp, "PADN "); break; 126 | case CODE_SESS: fprintf(fp, "SESS "); break; 127 | } 128 | 129 | fprintf(fp, "sess-id %d length %d\n", 130 | (int) ntohs(packet->session), 131 | len); 132 | 133 | /* Ugly... I apologize... */ 134 | fprintf(fp, 135 | "SourceAddr %02x:%02x:%02x:%02x:%02x:%02x " 136 | "DestAddr %02x:%02x:%02x:%02x:%02x:%02x\n", 137 | (unsigned) packet->ethHdr.h_source[0], 138 | (unsigned) packet->ethHdr.h_source[1], 139 | (unsigned) packet->ethHdr.h_source[2], 140 | (unsigned) packet->ethHdr.h_source[3], 141 | (unsigned) packet->ethHdr.h_source[4], 142 | (unsigned) packet->ethHdr.h_source[5], 143 | (unsigned) packet->ethHdr.h_dest[0], 144 | (unsigned) packet->ethHdr.h_dest[1], 145 | (unsigned) packet->ethHdr.h_dest[2], 146 | (unsigned) packet->ethHdr.h_dest[3], 147 | (unsigned) packet->ethHdr.h_dest[4], 148 | (unsigned) packet->ethHdr.h_dest[5]); 149 | dumpHex(fp, packet->payload, ntohs(packet->length)); 150 | } 151 | 152 | #endif /* DEBUGGING_ENABLED */ 153 | -------------------------------------------------------------------------------- /rp-pppoe.spec: -------------------------------------------------------------------------------- 1 | Summary: PPP Over Ethernet (xDSL support) 2 | Name: rp-pppoe 3 | Version: 3.11 4 | %if %(%{expand:test %{_vendor} != mandrake ; echo $?}) 5 | Release: 1mdk 6 | %else 7 | Release: 1 8 | %endif 9 | License: GPL 10 | Group: System Environment/Daemons 11 | Source: http://www.roaringpenguin.com/penguin/pppoe/rp-pppoe-3.10.tar.gz 12 | Url: http://www.roaringpenguin.com/pppoe/ 13 | Packager: David F. Skoll 14 | BuildRoot: /tmp/pppoe-build 15 | Vendor: Roaring Penguin Software Inc. 16 | Requires: ppp >= 2.3.7 17 | 18 | # LIC: GPL 19 | %description 20 | PPPoE (Point-to-Point Protocol over Ethernet) is a protocol used by 21 | many DSL Internet Service Providers. Roaring Penguin has a free 22 | client for Linux systems to connect to PPPoE service providers. 23 | 24 | The client is a user-mode program and does not require any kernel 25 | modifications. It is fully compliant with RFC 2516, the official PPPoE 26 | specification. 27 | 28 | %prep 29 | %setup 30 | cd src 31 | ./configure --mandir=%{_mandir} 32 | 33 | %build 34 | cd src 35 | make 36 | cd ../gui 37 | make 38 | 39 | %install 40 | umask 022 41 | cd src 42 | make install DESTDIR=$RPM_BUILD_ROOT 43 | mkdir -p $RPM_BUILD_ROOT/etc/init.d 44 | test -f $RPM_BUILD_ROOT/etc/init.d/pppoe || cp ../scripts/pppoe-init $RPM_BUILD_ROOT/etc/init.d/pppoe 45 | chmod 755 $RPM_BUILD_ROOT/etc/init.d/pppoe 46 | cd ../gui 47 | make install DESTDIR=$RPM_BUILD_ROOT 48 | rm -f $RPM_BUILD_ROOT/etc/ppp/pppoe.conf-3.10 49 | rm -f $RPM_BUILD_ROOT/etc/ppp/firewall-masq-3.10 50 | rm -f $RPM_BUILD_ROOT/etc/ppp/firewall-standalone-3.10 51 | rm -f $RPM_BUILD_ROOT/etc/ppp/pppoe-server-options-example 52 | 53 | %clean 54 | rm -rf $RPM_BUILD_ROOT 55 | 56 | %files 57 | %defattr(-,root,root) 58 | %doc doc/CHANGES doc/HOW-TO-CONNECT doc/LICENSE doc/KERNEL-MODE-PPPOE README SERVPOET 59 | %config(noreplace) /etc/ppp/pppoe.conf 60 | %config(noreplace) /etc/ppp/pppoe-server-options 61 | %config(noreplace) /etc/ppp/firewall-masq 62 | %config(noreplace) /etc/ppp/firewall-standalone 63 | /etc/ppp/plugins/* 64 | /usr/sbin/pppoe 65 | /usr/sbin/pppoe-server 66 | /usr/sbin/pppoe-sniff 67 | /usr/sbin/pppoe-relay 68 | /usr/sbin/pppoe-connect 69 | /usr/sbin/pppoe-start 70 | /usr/sbin/pppoe-stop 71 | /usr/sbin/pppoe-setup 72 | /usr/sbin/pppoe-status 73 | %{_mandir}/man5/pppoe.conf.5* 74 | %{_mandir}/man8/pppoe.8* 75 | %{_mandir}/man8/pppoe-server.8* 76 | %{_mandir}/man8/pppoe-relay.8* 77 | %{_mandir}/man8/pppoe-sniff.8* 78 | %{_mandir}/man8/pppoe-connect.8* 79 | %{_mandir}/man8/pppoe-start.8* 80 | %{_mandir}/man8/pppoe-stop.8* 81 | %{_mandir}/man8/pppoe-status.8* 82 | %{_mandir}/man8/pppoe-setup.8* 83 | /etc/init.d/pppoe 84 | %package gui 85 | Summary: Tk PPP Over Ethernet Client (xDSL support) 86 | Group: System Environment/Daemons 87 | Requires: rp-pppoe 88 | Requires: tk 89 | 90 | %description gui 91 | This is a graphical wrapper around the rp-pppoe PPPoE client. PPPoE is 92 | a protocol used by many DSL Internet Service Providers. 93 | 94 | %post gui 95 | # Install entry in KDE menu 96 | if test -n "$KDEDIR" ; then 97 | mkdir -p "$KDEDIR/share/applnk/Internet" 98 | cat < "$KDEDIR/share/applnk/Internet/tkpppoe.kdelnk" 99 | # KDE Config File 100 | [KDE Desktop Entry] 101 | Name=TkPPPoE 102 | Comment=Start/Stop PPPoE connections 103 | Exec=tkpppoe 104 | Terminal=0 105 | Type=Application 106 | EOF 107 | fi 108 | 109 | # Install entry in GNOME menus 110 | GNOMEDIR=`gnome-config --datadir 2>/dev/null` 111 | if test -n "$GNOMEDIR" ; then 112 | mkdir -p "$GNOMEDIR/gnome/apps/Internet" 113 | cat < "$GNOMEDIR/gnome/apps/Internet/tkpppoe.desktop" 114 | [Desktop Entry] 115 | Name=TkPPPoE 116 | Comment=Start/Stop PPPoE connections 117 | Exec=tkpppoe 118 | Terminal=0 119 | Type=Application 120 | EOF 121 | fi 122 | 123 | %postun gui 124 | # Remove KDE menu entry 125 | if test -n "$KDEDIR" ; then 126 | rm -f "$KDEDIR/share/applnk/Internet/tkpppoe.kdelnk" 127 | fi 128 | 129 | # Remove GNOME menu entry 130 | GNOMEDIR=`gnome-config --datadir 2>/dev/null` 131 | if test -n "$GNOMEDIR" ; then 132 | rm -f "$GNOMEDIR/gnome/apps/Internet/tkpppoe.desktop" 133 | fi 134 | 135 | %files gui 136 | %defattr(-,root,root) 137 | %dir /etc/ppp/rp-pppoe-gui 138 | /usr/sbin/pppoe-wrapper 139 | /usr/bin/tkpppoe 140 | %{_mandir}/man1/tkpppoe.1* 141 | %{_mandir}/man1/pppoe-wrapper.1* 142 | /usr/share/tkpppoe/tkpppoe.html 143 | /usr/share/tkpppoe/mainwin-busy.png 144 | /usr/share/tkpppoe/mainwin-nonroot.png 145 | /usr/share/tkpppoe/mainwin.png 146 | /usr/share/tkpppoe/props-advanced.png 147 | /usr/share/tkpppoe/props-basic.png 148 | /usr/share/tkpppoe/props-nic.png 149 | /usr/share/tkpppoe/props-options.png 150 | /usr/share/tkpppoe/en.msg 151 | /usr/share/tkpppoe/ja.msg 152 | 153 | %changelog 154 | * Thu Jul 21 2001 Shigechika AIKAWA 155 | - merged rp-pppoe.spec and rp-pppoe-gui.spec 156 | -------------------------------------------------------------------------------- /man/pppoe-relay.8: -------------------------------------------------------------------------------- 1 | .\" LIC: GPL 2 | .TH PPPOE-RELAY 8 "26 January 2001" 3 | .\"" 4 | .UC 4 5 | .SH NAME 6 | pppoe-relay \- user-space PPPoE relay agent. 7 | .SH SYNOPSIS 8 | .B pppoe-relay \fR[\fIoptions\fR] 9 | 10 | .SH DESCRIPTION 11 | \fBpppoe-relay\fR is a user-space relay agent for PPPoE 12 | (Point-to-Point Protocol over Ethernet) for Linux. \fBpppoe-relay\fR 13 | works in concert with the \fBpppoe\fR client and \fBpppoe-server\fR 14 | server. See the OPERATION section later in this manual for 15 | details on how \fBpppoe-relay\fR works. 16 | 17 | .SH OPTIONS 18 | .TP 19 | .B \-S \fIinterface\fR 20 | Adds the Ethernet interface \fIinterface\fR to the list of interfaces 21 | managed by \fBpppoe-relay\fR. Only PPPoE servers may be connected to 22 | this interface. 23 | 24 | .TP 25 | .B \-C \fIinterface\fR 26 | Adds the Ethernet interface \fIinterface\fR to the list of interfaces 27 | managed by \fBpppoe-relay\fR. Only PPPoE clients may be connected to 28 | this interface. 29 | 30 | .TP 31 | .B \-B \fIinterface\fR 32 | Adds the Ethernet interface \fIinterface\fR to the list of interfaces 33 | managed by \fBpppoe-relay\fR. Both PPPoE clients and servers may be 34 | connected to this interface. 35 | 36 | .TP 37 | .B \-n \fInum\fR 38 | Allows at most \fInum\fR concurrent PPPoE sessions. If not specified, 39 | the default is 5000. \fInum\fR can range from 1 to 65534. 40 | 41 | .TP 42 | .B \-i \fItimeout\fR 43 | Specifies the session idle timeout. If both peers in a session are idle 44 | for more than \fItimeout\fR seconds, the session is terminated. 45 | If \fItimeout\fR is specified as zero, sessions will never be terminated 46 | because of idleness. 47 | 48 | Note that the idle-session expiry routine is never run more frequently than 49 | every 30 seconds, so the timeout is approximate. The default value for 50 | \fItimeout\fR is 600 seconds (10 minutes.) 51 | 52 | .TP 53 | .B \-F 54 | The \fB\-F\fR option causes \fBpppoe-relay\fR \fInot\fR to fork into the 55 | background; instead, it remains in the foreground. 56 | 57 | .TP 58 | .B \-h 59 | The \fB\-h\fR option prints a brief usage message and exits. 60 | 61 | .SH OPERATION 62 | 63 | \fBpppoe-relay\fR listens for incoming PPPoE PADI frames on all interfaces 64 | specified with \fB-B\fR or \fB-C\fR options. When a PADI frame appears, 65 | \fBpppoe-relay\fR adds a Relay-Session-ID tag and broadcasts the PADI 66 | on all interfaces specified with \fB-B\fR or \fB-S\fR options (except the 67 | interface on which the frame arrived.) 68 | 69 | Any PADO frames received are relayed back to the client which sent the 70 | PADI (assuming they contain valid Relay-Session-ID tags.) Likewise, 71 | PADR frames from clients are relayed back to the matching access 72 | concentrator. 73 | 74 | When a PADS frame is received, \fBpppoe-relay\fR enters the two peers' 75 | MAC addresses and session-ID's into a hash table. (The session-ID seen 76 | by the access concentrator may be different from that seen by the client; 77 | \fBpppoe-relay\fR must renumber sessions to avoid the possibility of duplicate 78 | session-ID's.) Whenever either peer sends a session frame, \fBpppoe-relay\fR 79 | looks up the session entry in the hash table and relays the frame to 80 | the correct peer. 81 | 82 | When a PADT frame is received, \fBpppoe-relay\fR relays it to the peer 83 | and deletes the session entry from its hash table. 84 | 85 | If a client and server crash (or frames are lost), PADT frames may never 86 | be sent, and \fBpppoe-relay\fR's hash table can fill up with stale sessions. 87 | Therefore, a session-cleaning routine runs periodically, and removes old 88 | sessions from the hash table. A session is considered "old" if no traffic 89 | has been seen within \fItimeout\fR seconds. When a session is deleted because 90 | of a timeout, a PADT frame is sent to each peer to make certain that they 91 | are aware the session has been killed. 92 | 93 | .SH EXAMPLE INVOCATIONS 94 | 95 | .nf 96 | pppoe-relay -C eth0 -S eth1 97 | .fi 98 | 99 | The example above relays frames between PPPoE clients on the eth0 network 100 | and PPPoE servers on the eth1 network. 101 | 102 | .nf 103 | pppoe-relay -B eth0 -B eth1 104 | .fi 105 | 106 | This example is a transparent relay -- frames are relayed between any mix 107 | of clients and servers on the eth0 and eth1 networks. 108 | 109 | .nf 110 | pppoe-relay -S eth0 -C eth1 -C eth2 -C eth3 111 | .fi 112 | 113 | This example relays frames between servers on the eth0 network and 114 | clients on the eth1, eth2 and eth3 networks. 115 | 116 | .SH AUTHORS 117 | \fBpppoe-relay\fR was written by David F. Skoll . 118 | 119 | The \fBpppoe\fR home page is \fIhttp://www.roaringpenguin.com/pppoe/\fR. 120 | 121 | .SH SEE ALSO 122 | pppoe-start(8), pppoe-stop(8), pppoe-connect(8), pppd(8), pppoe.conf(5), 123 | pppoe(8), pppoe-setup(8), pppoe-status(8), pppoe-sniff(8), pppoe-server(8) 124 | 125 | -------------------------------------------------------------------------------- /configs/pppoe.conf: -------------------------------------------------------------------------------- 1 | #*********************************************************************** 2 | # 3 | # pppoe.conf 4 | # 5 | # Configuration file for rp-pppoe. Edit as appropriate and install in 6 | # /etc/ppp/pppoe.conf 7 | # 8 | # NOTE: This file is used by the pppoe-start, pppoe-stop, pppoe-connect and 9 | # pppoe-status shell scripts. It is *not* used in any way by the 10 | # "pppoe" executable. 11 | # 12 | # Copyright (C) 2000 Roaring Penguin Software Inc. 13 | # 14 | # This file may be distributed under the terms of the GNU General 15 | # Public License. 16 | # 17 | # LIC: GPL 18 | # $Id$ 19 | #*********************************************************************** 20 | 21 | # When you configure a variable, DO NOT leave spaces around the "=" sign. 22 | 23 | # Ethernet card connected to DSL modem 24 | ETH=eth1 25 | 26 | # PPPoE user name. You may have to supply "@provider.com" Sympatico 27 | # users in Canada do need to include "@sympatico.ca" 28 | # Sympatico uses PAP authentication. Make sure /etc/ppp/pap-secrets 29 | # contains the right username/password combination. 30 | # For Magma, use xxyyzz@magma.ca 31 | USER=bxxxnxnx@sympatico.ca 32 | 33 | # Bring link up on demand? Default is to leave link up all the time. 34 | # If you want the link to come up on demand, set DEMAND to a number indicating 35 | # the idle time after which the link is brought down. 36 | DEMAND=no 37 | #DEMAND=300 38 | 39 | # DNS type: SERVER=obtain from server; SPECIFY=use DNS1 and DNS2; 40 | # NOCHANGE=do not adjust. 41 | DNSTYPE=SERVER 42 | 43 | # Obtain DNS server addresses from the peer (recent versions of pppd only) 44 | # In old config files, this used to be called USEPEERDNS. Changed to 45 | # PEERDNS for better Red Hat compatibility 46 | PEERDNS=yes 47 | 48 | DNS1= 49 | DNS2= 50 | 51 | # Make the PPPoE connection your default route. Set to 52 | # DEFAULTROUTE=no if you don't want this. 53 | DEFAULTROUTE=yes 54 | 55 | ### ONLY TOUCH THE FOLLOWING SETTINGS IF YOU'RE AN EXPERT 56 | 57 | # How long pppoe-start waits for a new PPP interface to appear before 58 | # concluding something went wrong. If you use 0, then pppoe-start 59 | # exits immediately with a successful status and does not wait for the 60 | # link to come up. Time is in seconds. 61 | # 62 | # WARNING WARNING WARNING: 63 | # 64 | # If you are using rp-pppoe on a physically-inaccessible host, set 65 | # CONNECT_TIMEOUT to 0. This makes SURE that the machine keeps trying 66 | # to connect forever after pppoe-start is called. Otherwise, it will 67 | # give out after CONNECT_TIMEOUT seconds and will not attempt to 68 | # connect again, making it impossible to reach. 69 | CONNECT_TIMEOUT=30 70 | 71 | # How often in seconds pppoe-start polls to check if link is up 72 | CONNECT_POLL=2 73 | 74 | # Specific desired AC Name 75 | ACNAME= 76 | 77 | # Specific desired service name 78 | SERVICENAME= 79 | 80 | # Character to echo at each poll. Use PING="" if you don't want 81 | # anything echoed 82 | PING="." 83 | 84 | # File where the pppoe-connect script writes its process-ID. 85 | # Three files are actually used: 86 | # $PIDFILE contains PID of pppoe-connect script 87 | # $PIDFILE.pppoe contains PID of pppoe process 88 | # $PIDFILE.pppd contains PID of pppd process 89 | CF_BASE=`basename $CONFIG` 90 | PIDFILE="/var/run/$CF_BASE-pppoe.pid" 91 | 92 | # Do you want to use synchronous PPP? "yes" or "no". "yes" is much 93 | # easier on CPU usage, but may not work for you. It is safer to use 94 | # "no", but you may want to experiment with "yes". "yes" is generally 95 | # safe on Linux machines with the n_hdlc line discipline; unsafe on others. 96 | SYNCHRONOUS=no 97 | 98 | # Do you want to clamp the MSS? Here's how to decide: 99 | # - If you have only a SINGLE computer connected to the DSL modem, choose 100 | # "no". 101 | # - If you have a computer acting as a gateway for a LAN, choose "1412". 102 | # The setting of 1412 is safe for either setup, but uses slightly more 103 | # CPU power. 104 | CLAMPMSS=1412 105 | #CLAMPMSS=no 106 | 107 | # LCP echo interval and failure count. 108 | LCP_INTERVAL=20 109 | LCP_FAILURE=3 110 | 111 | # PPPOE_TIMEOUT should be about 4*LCP_INTERVAL 112 | PPPOE_TIMEOUT=80 113 | 114 | # Firewalling: One of NONE, STANDALONE or MASQUERADE 115 | FIREWALL=NONE 116 | 117 | # Linux kernel-mode plugin for pppd. If you want to try the kernel-mode 118 | # plugin, use LINUX_PLUGIN=/etc/ppp/plugins/rp-pppoe.so 119 | LINUX_PLUGIN= 120 | 121 | # Any extra arguments to pass to pppoe. Normally, use a blank string 122 | # like this: 123 | PPPOE_EXTRA="" 124 | 125 | # Rumour has it that "Citizen's Communications" with a 3Com 126 | # HomeConnect DSL Modem DualLink requires these extra options: 127 | # PPPOE_EXTRA="-f 3c12:3c13 -S ISP" 128 | 129 | # Any extra arguments to pass to pppd. Normally, use a blank string 130 | # like this: 131 | PPPD_EXTRA="" 132 | 133 | 134 | ########## DON'T CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING 135 | # If you wish to COMPLETELY overrride the pppd invocation: 136 | # Example: 137 | # OVERRIDE_PPPD_COMMAND="pppd call dsl" 138 | 139 | # If you want pppoe-connect to exit when connection drops: 140 | # RETRY_ON_FAILURE=no 141 | -------------------------------------------------------------------------------- /src/pppoe-server.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * pppoe-server.h 4 | * 5 | * Definitions for PPPoE server 6 | * 7 | * Copyright (C) 2001-2012 Roaring Penguin Software Inc. 8 | * 9 | * This program may be distributed according to the terms of the GNU 10 | * General Public License, version 2 or (at your option) any later version. 11 | * 12 | * LIC: GPL 13 | * 14 | * $Id$ 15 | * 16 | ***********************************************************************/ 17 | 18 | #include "pppoe.h" 19 | #include "event.h" 20 | 21 | #ifdef HAVE_L2TP 22 | #include "l2tp/l2tp.h" 23 | #endif 24 | 25 | #define MAX_USERNAME_LEN 31 26 | /* An Ethernet interface */ 27 | typedef struct { 28 | char name[IFNAMSIZ+1]; /* Interface name */ 29 | int sock; /* Socket for discovery frames */ 30 | unsigned char mac[ETH_ALEN]; /* MAC address */ 31 | EventHandler *eh; /* Event handler for this interface */ 32 | UINT16_t mtu; /* MTU of interface */ 33 | 34 | /* Next fields are used only if we're an L2TP LAC */ 35 | #ifdef HAVE_L2TP 36 | int session_sock; /* Session socket */ 37 | EventHandler *lac_eh; /* LAC's event-handler */ 38 | #endif 39 | } Interface; 40 | 41 | #define FLAG_RECVD_PADT 1 42 | #define FLAG_USER_SET 2 43 | #define FLAG_IP_SET 4 44 | #define FLAG_SENT_PADT 8 45 | 46 | /* Only used if we are an L2TP LAC or LNS */ 47 | #define FLAG_ACT_AS_LAC 256 48 | #define FLAG_ACT_AS_LNS 512 49 | 50 | /* Forward declaration */ 51 | struct ClientSessionStruct; 52 | 53 | /* Dispatch table for session-related functions. We call different 54 | functions for L2TP-terminated sessions than for locally-terminated 55 | sessions. */ 56 | typedef struct PppoeSessionFunctionTable_t { 57 | /* Stop the session */ 58 | void (*stop)(struct ClientSessionStruct *ses, char const *reason); 59 | 60 | /* Return 1 if session is active, 0 otherwise */ 61 | int (*isActive)(struct ClientSessionStruct *ses); 62 | 63 | /* Describe a session in human-readable form */ 64 | char const * (*describe)(struct ClientSessionStruct *ses); 65 | } PppoeSessionFunctionTable; 66 | 67 | extern PppoeSessionFunctionTable DefaultSessionFunctionTable; 68 | 69 | /* A client session */ 70 | typedef struct ClientSessionStruct { 71 | struct ClientSessionStruct *next; /* In list of free or active sessions */ 72 | PppoeSessionFunctionTable *funcs; /* Function table */ 73 | pid_t pid; /* PID of child handling session */ 74 | Interface *ethif; /* Ethernet interface */ 75 | unsigned char myip[IPV4ALEN]; /* Local IP address */ 76 | unsigned char peerip[IPV4ALEN]; /* Desired IP address of peer */ 77 | UINT16_t sess; /* Session number */ 78 | unsigned char eth[ETH_ALEN]; /* Peer's Ethernet address */ 79 | unsigned int flags; /* Various flags */ 80 | time_t startTime; /* When session started */ 81 | char const *serviceName; /* Service name */ 82 | UINT16_t requested_mtu; /* Requested PPP_MAX_PAYLOAD per RFC 4638 */ 83 | #ifdef HAVE_LICENSE 84 | char user[MAX_USERNAME_LEN+1]; /* Authenticated user-name */ 85 | char realm[MAX_USERNAME_LEN+1]; /* Realm */ 86 | unsigned char realpeerip[IPV4ALEN]; /* Actual IP address -- may be assigned 87 | by RADIUS server */ 88 | int maxSessionsPerUser; /* Max sessions for this user */ 89 | #endif 90 | #ifdef HAVE_L2TP 91 | l2tp_session *l2tp_ses; /* L2TP session */ 92 | struct sockaddr_in tunnel_endpoint; /* L2TP endpoint */ 93 | #endif 94 | } ClientSession; 95 | 96 | /* Hack for daemonizing */ 97 | #define CLOSEFD 64 98 | 99 | /* Max. number of interfaces to listen on */ 100 | #define MAX_INTERFACES 64 101 | 102 | /* Max. 64 sessions by default */ 103 | #define DEFAULT_MAX_SESSIONS 64 104 | 105 | /* An array of client sessions */ 106 | extern ClientSession *Sessions; 107 | 108 | /* Interfaces we're listening on */ 109 | extern Interface interfaces[MAX_INTERFACES]; 110 | extern int NumInterfaces; 111 | 112 | /* The number of session slots */ 113 | extern size_t NumSessionSlots; 114 | 115 | /* The number of active sessions */ 116 | extern size_t NumActiveSessions; 117 | 118 | /* Offset of first session */ 119 | extern size_t SessOffset; 120 | 121 | /* Access concentrator name */ 122 | extern char *ACName; 123 | 124 | extern unsigned char LocalIP[IPV4ALEN]; 125 | extern unsigned char RemoteIP[IPV4ALEN]; 126 | 127 | /* Do not create new sessions if free RAM < 10MB (on Linux only!) */ 128 | #define MIN_FREE_MEMORY 10000 129 | 130 | /* Do we increment local IP for each connection? */ 131 | extern int IncrLocalIP; 132 | 133 | /* Free sessions */ 134 | extern ClientSession *FreeSessions; 135 | 136 | /* When a session is freed, it is added to the end of the free list */ 137 | extern ClientSession *LastFreeSession; 138 | 139 | /* Busy sessions */ 140 | extern ClientSession *BusySessions; 141 | 142 | extern EventSelector *event_selector; 143 | extern int GotAlarm; 144 | 145 | extern void setAlarm(unsigned int secs); 146 | extern void killAllSessions(void); 147 | extern void serverProcessPacket(Interface *i); 148 | extern void processPADT(Interface *ethif, PPPoEPacket *packet, int len); 149 | extern void processPADR(Interface *ethif, PPPoEPacket *packet, int len); 150 | extern void processPADI(Interface *ethif, PPPoEPacket *packet, int len); 151 | extern void usage(char const *msg); 152 | extern ClientSession *pppoe_alloc_session(void); 153 | extern int pppoe_free_session(ClientSession *ses); 154 | extern void sendHURLorMOTM(PPPoEConnection *conn, char const *url, UINT16_t tag); 155 | 156 | #ifdef HAVE_LICENSE 157 | extern int getFreeMem(void); 158 | #endif 159 | -------------------------------------------------------------------------------- /src/install-sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # install - install a program, script, or datafile 4 | # This comes from X11R5. 5 | # 6 | # Calling this script install-sh is preferred over install.sh, to prevent 7 | # `make' implicit rules from creating a file called install from it 8 | # when there is no Makefile. 9 | # 10 | # This script is compatible with the BSD install script, but was written 11 | # from scratch. 12 | # 13 | 14 | 15 | # set DOITPROG to echo to test this script 16 | 17 | # Don't use :- since 4.3BSD and earlier shells don't like it. 18 | doit="${DOITPROG-}" 19 | 20 | 21 | # put in absolute paths if you don't have them in your path; or use env. vars. 22 | 23 | mvprog="${MVPROG-mv}" 24 | cpprog="${CPPROG-cp}" 25 | chmodprog="${CHMODPROG-chmod}" 26 | chownprog="${CHOWNPROG-chown}" 27 | chgrpprog="${CHGRPPROG-chgrp}" 28 | stripprog="${STRIPPROG-strip}" 29 | rmprog="${RMPROG-rm}" 30 | mkdirprog="${MKDIRPROG-mkdir}" 31 | 32 | transformbasename="" 33 | transform_arg="" 34 | instcmd="$mvprog" 35 | chmodcmd="$chmodprog 0755" 36 | chowncmd="" 37 | chgrpcmd="" 38 | stripcmd="" 39 | rmcmd="$rmprog -f" 40 | mvcmd="$mvprog" 41 | src="" 42 | dst="" 43 | dir_arg="" 44 | 45 | while [ x"$1" != x ]; do 46 | case $1 in 47 | -c) instcmd="$cpprog" 48 | shift 49 | continue;; 50 | 51 | -d) dir_arg=true 52 | shift 53 | continue;; 54 | 55 | -m) chmodcmd="$chmodprog $2" 56 | shift 57 | shift 58 | continue;; 59 | 60 | -o) chowncmd="$chownprog $2" 61 | shift 62 | shift 63 | continue;; 64 | 65 | -g) chgrpcmd="$chgrpprog $2" 66 | shift 67 | shift 68 | continue;; 69 | 70 | -s) stripcmd="$stripprog" 71 | shift 72 | continue;; 73 | 74 | -t=*) transformarg=`echo $1 | sed 's/-t=//'` 75 | shift 76 | continue;; 77 | 78 | -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 79 | shift 80 | continue;; 81 | 82 | *) if [ x"$src" = x ] 83 | then 84 | src=$1 85 | else 86 | # this colon is to work around a 386BSD /bin/sh bug 87 | : 88 | dst=$1 89 | fi 90 | shift 91 | continue;; 92 | esac 93 | done 94 | 95 | if [ x"$src" = x ] 96 | then 97 | echo "install: no input file specified" 98 | exit 1 99 | else 100 | true 101 | fi 102 | 103 | if [ x"$dir_arg" != x ]; then 104 | dst=$src 105 | src="" 106 | 107 | if [ -d $dst ]; then 108 | instcmd=: 109 | else 110 | instcmd=mkdir 111 | fi 112 | else 113 | 114 | # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 115 | # might cause directories to be created, which would be especially bad 116 | # if $src (and thus $dsttmp) contains '*'. 117 | 118 | if [ -f $src -o -d $src ] 119 | then 120 | true 121 | else 122 | echo "install: $src does not exist" 123 | exit 1 124 | fi 125 | 126 | if [ x"$dst" = x ] 127 | then 128 | echo "install: no destination specified" 129 | exit 1 130 | else 131 | true 132 | fi 133 | 134 | # If destination is a directory, append the input filename; if your system 135 | # does not like double slashes in filenames, you may need to add some logic 136 | 137 | if [ -d $dst ] 138 | then 139 | dst="$dst"/`basename $src` 140 | else 141 | true 142 | fi 143 | fi 144 | 145 | ## this sed command emulates the dirname command 146 | dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 147 | 148 | # Make sure that the destination directory exists. 149 | # this part is taken from Noah Friedman's mkinstalldirs script 150 | 151 | # Skip lots of stat calls in the usual case. 152 | if [ ! -d "$dstdir" ]; then 153 | defaultIFS=' 154 | ' 155 | IFS="${IFS-${defaultIFS}}" 156 | 157 | oIFS="${IFS}" 158 | # Some sh's can't handle IFS=/ for some reason. 159 | IFS='%' 160 | set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` 161 | IFS="${oIFS}" 162 | 163 | pathcomp='' 164 | 165 | while [ $# -ne 0 ] ; do 166 | pathcomp="${pathcomp}${1}" 167 | shift 168 | 169 | if [ ! -d "${pathcomp}" ] ; 170 | then 171 | $mkdirprog "${pathcomp}" 172 | else 173 | true 174 | fi 175 | 176 | pathcomp="${pathcomp}/" 177 | done 178 | fi 179 | 180 | if [ x"$dir_arg" != x ] 181 | then 182 | $doit $instcmd $dst && 183 | 184 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 185 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 186 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 187 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 188 | else 189 | 190 | # If we're going to rename the final executable, determine the name now. 191 | 192 | if [ x"$transformarg" = x ] 193 | then 194 | dstfile=`basename $dst` 195 | else 196 | dstfile=`basename $dst $transformbasename | 197 | sed $transformarg`$transformbasename 198 | fi 199 | 200 | # don't allow the sed command to completely eliminate the filename 201 | 202 | if [ x"$dstfile" = x ] 203 | then 204 | dstfile=`basename $dst` 205 | else 206 | true 207 | fi 208 | 209 | # Make a temp file name in the proper directory. 210 | 211 | dsttmp=$dstdir/#inst.$$# 212 | 213 | # Move or copy the file name to the temp name 214 | 215 | $doit $instcmd $src $dsttmp && 216 | 217 | trap "rm -f ${dsttmp}" 0 && 218 | 219 | # and set any options; do chmod last to preserve setuid bits 220 | 221 | # If any of these fail, we abort the whole thing. If we want to 222 | # ignore errors from any of these, just make sure not to ignore 223 | # errors from the above "$doit $instcmd $src $dsttmp" command. 224 | 225 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 226 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 227 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 228 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 229 | 230 | # Now rename the file to the real destination. 231 | 232 | $doit $rmcmd -f $dstdir/$dstfile && 233 | $doit $mvcmd $dsttmp $dstdir/$dstfile 234 | 235 | fi && 236 | 237 | 238 | exit 0 239 | -------------------------------------------------------------------------------- /scripts/pppoe-start.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # @configure_input@ 3 | #*********************************************************************** 4 | # 5 | # pppoe-start 6 | # 7 | # Shell script to bring up a PPPoE connection 8 | # 9 | # Copyright (C) 2000 Roaring Penguin Software Inc. 10 | # 11 | # $Id$ 12 | # 13 | # This file may be distributed under the terms of the GNU General 14 | # Public License. 15 | # 16 | # LIC: GPL 17 | # 18 | # Usage: pppoe-start [config_file] 19 | # pppoe-start interface user [config_file] 20 | # Second form overrides USER and ETH from config file. 21 | # If config_file is omitted, defaults to /etc/ppp/pppoe.conf 22 | # 23 | #*********************************************************************** 24 | 25 | # From AUTOCONF 26 | prefix=@prefix@ 27 | exec_prefix=@exec_prefix@ 28 | 29 | # Paths to programs 30 | CONNECT=@sbindir@/pppoe-connect 31 | ECHO=@ECHO@ 32 | IFCONFIG=/sbin/ifconfig 33 | 34 | # Set to "C" locale so we can parse messages from commands 35 | LANG=C 36 | export LANG 37 | 38 | # Defaults 39 | CONFIG=/etc/ppp/pppoe.conf 40 | USER="" 41 | ETH="" 42 | ME=`basename $0` 43 | # Must be root 44 | if [ "`@ID@ -u`" != 0 ] ; then 45 | $ECHO "$ME: You must be root to run this script" >& 2 46 | exit 1 47 | fi 48 | 49 | # Debugging 50 | if [ "$DEBUG" = "1" ] ; then 51 | $ECHO "*** Running in debug mode... please be patient..." 52 | DEBUG=/tmp/pppoe-debug-$$ 53 | export DEBUG 54 | mkdir $DEBUG 55 | if [ "$?" != 0 ] ; then 56 | $ECHO "Could not create directory $DEBUG... exiting" 57 | exit 1 58 | fi 59 | DEBUG=$DEBUG/pppoe-debug.txt 60 | 61 | # Initial debug output 62 | $ECHO "---------------------------------------------" > $DEBUG 63 | $ECHO "* The following section contains information about your system" >> $DEBUG 64 | date >> $DEBUG 65 | $ECHO "Output of uname -a" >> $DEBUG 66 | uname -a >> $DEBUG 67 | $ECHO "---------------------------------------------" >> $DEBUG 68 | $ECHO "* The following section contains information about your network" >> $DEBUG 69 | $ECHO "* interfaces. The one you chose for PPPoE should contain the words:" >> $DEBUG 70 | $ECHO "* 'UP' and 'RUNNING'. If it does not, you probably have an Ethernet" >> $DEBUG 71 | $ECHO "* driver problem." >> $DEBUG 72 | $ECHO "Output of ifconfig -a" >> $DEBUG 73 | $IFCONFIG -a >> $DEBUG 74 | $ECHO "---------------------------------------------" >> $DEBUG 75 | if [ "`uname -s`" = "Linux" ] ; then 76 | $ECHO "* The following section contains information about kernel modules" >> $DEBUG 77 | $ECHO "* If the module for your Ethernet card is 'tulip', you might" >> $DEBUG 78 | $ECHO "* want to look for an updated version at http://www.scyld.com" >> $DEBUG 79 | $ECHO "Output of lsmod" >> $DEBUG 80 | lsmod >> $DEBUG 81 | $ECHO "---------------------------------------------" >> $DEBUG 82 | fi 83 | $ECHO "* The following section lists your routing table." >> $DEBUG 84 | $ECHO "* If you have an entry which starts with '0.0.0.0', you probably" >> $DEBUG 85 | $ECHO "* have defined a default route and gateway, and pppd will" >> $DEBUG 86 | $ECHO "* not create a default route using your ISP. Try getting" >> $DEBUG 87 | $ECHO "* rid of this route." >> $DEBUG 88 | $ECHO "Output of netstat -n -r" >> $DEBUG 89 | netstat -n -r >> $DEBUG 90 | $ECHO "---------------------------------------------" >> $DEBUG 91 | $ECHO "Contents of /etc/resolv.conf" >> $DEBUG 92 | $ECHO "* The following section lists DNS setup." >> $DEBUG 93 | $ECHO "* If you can browse by IP address, but not name, suspect" >> $DEBUG 94 | $ECHO "* a DNS problem." >> $DEBUG 95 | cat /etc/resolv.conf >> $DEBUG 96 | $ECHO "---------------------------------------------" >> $DEBUG 97 | $ECHO "* The following section lists /etc/ppp/options." >> $DEBUG 98 | $ECHO "* You should have NOTHING in that file." >> $DEBUG 99 | $ECHO "Contents of /etc/ppp/options" >> $DEBUG 100 | cat /etc/ppp/options >> $DEBUG 2>/dev/null 101 | $ECHO "---------------------------------------------" >> $DEBUG 102 | else 103 | DEBUG="" 104 | fi 105 | 106 | # Sort out command-line arguments 107 | case "$#" in 108 | 1) 109 | CONFIG="$1" 110 | ;; 111 | 3) 112 | CONFIG="$3" 113 | ;; 114 | esac 115 | 116 | if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then 117 | $ECHO "$ME: Cannot read configuration file '$CONFIG'" >& 2 118 | exit 1 119 | fi 120 | export CONFIG 121 | . $CONFIG 122 | 123 | # Check for command-line overriding of ETH and USER 124 | case "$#" in 125 | 2|3) 126 | ETH="$1" 127 | USER="$2" 128 | ;; 129 | esac 130 | 131 | # Check for pidfile 132 | if [ -r "$PIDFILE" ] ; then 133 | PID=`cat "$PIDFILE"` 134 | # Check if still running 135 | kill -0 $PID > /dev/null 2>&1 136 | if [ $? = 0 ] ; then 137 | $ECHO "$ME: There already seems to be a PPPoE connection up (PID $PID)" >& 2 138 | exit 1 139 | fi 140 | # Delete bogus PIDFILE 141 | rm -f "$PIDFILE" "$PIDFILE.pppd" "$PIDFILE.pppoe" "$PIDFILE.start" 142 | fi 143 | 144 | echo $$ > $PIDFILE.start 145 | 146 | # Start the connection in the background unless we're debugging 147 | if [ "$DEBUG" != "" ] ; then 148 | $CONNECT "$@" 149 | exit 0 150 | fi 151 | 152 | $CONNECT "$@" > /dev/null 2>&1 & 153 | CONNECT_PID=$! 154 | 155 | if [ "$CONNECT_TIMEOUT" = "" -o "$CONNECT_TIMEOUT" = 0 ] ; then 156 | exit 0 157 | fi 158 | 159 | # Don't monitor connection if dial-on-demand 160 | if [ "$DEMAND" != "" -a "$DEMAND" != "no" ] ; then 161 | exit 0 162 | fi 163 | 164 | # Monitor connection 165 | TIME=0 166 | while [ true ] ; do 167 | @sbindir@/pppoe-status $CONFIG > /dev/null 2>&1 168 | 169 | # Looks like the interface came up 170 | if [ $? = 0 ] ; then 171 | # Print newline if standard input is a TTY 172 | tty -s && $ECHO " Connected!" 173 | exit 0 174 | fi 175 | 176 | if test -n "$FORCEPING" ; then 177 | printf "%s" "$FORCEPING" 178 | else 179 | tty -s && printf "%s" "$PING" 180 | fi 181 | sleep $CONNECT_POLL 182 | TIME=`expr $TIME + $CONNECT_POLL` 183 | if [ $TIME -gt $CONNECT_TIMEOUT ] ; then 184 | break 185 | fi 186 | done 187 | 188 | $ECHO "TIMED OUT" >& 2 189 | # Timed out! Kill the pppoe-connect process and quit 190 | kill $CONNECT_PID > /dev/null 2>&1 191 | 192 | # Clean up PIDFILE(s) 193 | rm -f "$PIDFILE" "$PIDFILE.pppd" "$PIDFILE.pppoe" "$PIDFILE.start" 194 | 195 | exit 1 196 | 197 | -------------------------------------------------------------------------------- /man/pppoe.conf.5: -------------------------------------------------------------------------------- 1 | .\" LIC: GPL 2 | .TH PPPOE.CONF 5 "21 February 2000" 3 | .UC 4 4 | .SH NAME 5 | pppoe.conf \- Configuration file used by \fBpppoe-start\fR(8), 6 | \fBpppoe-stop\fR(8), \fBpppoe-status(8)\fR and \fBpppoe-connect\fR(8). 7 | 8 | .SH DESCRIPTION 9 | \fB/etc/ppp/pppoe.conf\fR is a shell script which contains configuration 10 | information for Roaring Penguin's PPPoE scripts. Note that \fBpppoe.conf\fR 11 | is used only by the various pppoe-* shell scripts, not by \fBpppoe\fR 12 | itself. 13 | 14 | \fBpppoe.conf\fR consists of a sequence of shell variable assignments. 15 | The variables and their meanings are: 16 | 17 | .TP 18 | .B ETH 19 | The Ethernet interface connected to the DSL modem (for example, eth0). 20 | 21 | .TP 22 | .B USER 23 | The PPPoE user-id (for example, b1xxnxnx@sympatico.ca). 24 | 25 | .TP 26 | .B SERVICENAME 27 | If this is not blank, then it is passed with the \fB\-S\fR option to 28 | \fBpppoe\fR. It specifies a service name to ask for. Usually, you 29 | should leave it blank. 30 | 31 | .TP 32 | .B ACNAME 33 | If this is not blank, then it is passed with the \fB\-C\fR option to 34 | \fBpppoe\fR. It specifies the name of the access concentrator to connect 35 | to. Usually, you should leave it blank. 36 | 37 | .TP 38 | .B DEMAND 39 | If set to a number, the link is activated on demand and brought down 40 | after after \fBDEMAND\fR seconds. If set to \fBno\fR, the link is kept 41 | up all the time rather than being activated on demand. 42 | 43 | .TP 44 | .B DNSTYPE 45 | One of \fBNOCHANGE\fR, \fBSPECIFY\fR or \fBSERVER\fR. If 46 | set to NOCHANGE, \fBpppoe-connect\fR will not adjust the DNS setup in 47 | any way. If set to SPECIFY, it will re-write /etc/resolv.conf with 48 | the values of DNS1 and DNS2. If set to \fBSERVER\fR, it will 49 | supply the \fIusepeerdns\fR option to \fBpppd\fR, and make a symlink 50 | from /etc/resolv.conf to /etc/ppp/resolv.conf. 51 | 52 | .TP 53 | .B DNS1, DNS2 54 | IP addresses of DNS servers if you use DNSTYPE=SPECIFY. 55 | 56 | .TP 57 | .B NONROOT 58 | If the line \fBNONROOT=OK\fR (exactly like that; no whitespace or comments) 59 | appears in the configuration file, then \fBpppoe-wrapper\fR will allow 60 | non-root users to bring the conneciton up or down. The wrapper is installed 61 | only if you installed the rp-pppoe-gui package. 62 | 63 | .TP 64 | .B USEPEERDNS 65 | If set to "yes", then \fBpppoe-connect\fR will supply the \fIusepeerdns\fR 66 | option to \fBpppd\fR, which causes it to obtain DNS server addresses 67 | from the peer and create a new \fB/etc/resolv.conf\fR file. Otherwise, 68 | \fBpppoe-connect\fR will not supply this option, and \fBpppd\fR will not 69 | modify \fB/etc/resolv.conf\fR. 70 | 71 | .TP 72 | .B CONNECT_POLL 73 | How often (in seconds) \fBpppoe-start\fR should check to see if a new PPP 74 | interface has come up. If this is set to 0, the \fBpppoe-start\fR simply 75 | initiates the PPP session, but does not wait to see if it comes up 76 | successfully. 77 | 78 | .TP 79 | .B CONNECT_TIMEOUT 80 | How long (in seconds) \fBpppoe-start\fR should wait for a new PPP interface 81 | to come up before concluding that \fBpppoe-connect\fR has failed and killing 82 | the session. 83 | 84 | .TP 85 | .B PING 86 | A character which is echoed every \fBCONNECT_POLL\fR seconds while 87 | \fBpppoe-start\fR is waiting for the PPP interface to come up. 88 | 89 | .TP 90 | .B FORCEPING 91 | A character which is echoed every \fBCONNECT_POLL\fR seconds while 92 | \fBpppoe-start\fR is waiting for the PPP interface to come up. Similar 93 | to \fBPING\fR, but the character is echoed even if \fBpppoe-start\fR's 94 | standard output is not a tty. 95 | 96 | .TP 97 | .B PIDFILE 98 | A file in which to write the process-ID of the pppoe-connect process 99 | (for example, \fB/var/run/pppoe.pid\fR). Two additional files 100 | ($PIDFILE.pppd and $PIDFILE.pppoe) hold the process-ID's of the 101 | \fBpppd\fR and \fBpppoe\fR processes, respectively. 102 | 103 | .TP 104 | .B SYNCHRONOUS 105 | An indication of whether or not to use synchronous PPP (\fByes\fR or 106 | \fBno\fR). Synchronous PPP is safe on Linux machines with the n_hdlc 107 | line discipline. (If you have a file called "n_hdlc.o" in your 108 | modules directory, you have the line discipline.) It is \fInot 109 | recommended\fR on other machines or on Linux machines without the 110 | n_hdlc line discipline due to some known and unsolveable race 111 | conditions in a user-mode client. 112 | 113 | .TP 114 | .B CLAMPMSS 115 | The value at which to "clamp" the advertised MSS for TCP sessions. The 116 | default of 1412 should be fine. 117 | 118 | .TP 119 | .B LCP_INTERVAL 120 | How often (in seconds) \fBpppd\fR sends out LCP echo-request packets. 121 | 122 | .TP 123 | .B LCP_FAILURE 124 | How many unanswered LCP echo-requests must occur before \fBpppd\fR 125 | concludes the link is dead. 126 | 127 | .TP 128 | .B PPPOE_TIMEOUT 129 | If this many seconds elapse without any activity seen by \fBpppoe\fR, 130 | then \fBpppoe\fR exits. 131 | 132 | .TP 133 | .B FIREWALL 134 | One of NONE, STANDALONE or MASQUERADE. If NONE, then \fBpppoe-connect\fR does 135 | not add any firewall rules. If STANDALONE, then it clears existing firewall 136 | rules and sets up basic rules for a standalone machine. If MASQUERADE, then 137 | it clears existing firewall rules and sets up basic rules for an Internet 138 | gateway. If you run services on your machine, these simple firewall scripts 139 | are inadequate; you'll have to make your own firewall rules and set FIREWALL 140 | to NONE. 141 | 142 | .TP 143 | .B PPPOE_EXTRA 144 | Any extra arguments to pass to \fBpppoe\fR 145 | 146 | .TP 147 | .B PPPD_EXTRA 148 | Any extra arguments to pass to \fBpppd\fR 149 | 150 | .TP 151 | .B LINUX_PLUGIN 152 | If non-blank, the full path of the Linux kernel-mode PPPoE plugin 153 | (typically \fB/etc/ppp/plugins/rp-pppoe.so\fR.) This forces 154 | \fBpppoe-connect\fR to use kernel-mode PPPoE on Linux 2.4.x systems. 155 | This code is experimental and unsupported. Use of the plugin causes 156 | \fBpppoe-connect\fR to ignore CLAMPMSS, PPPOE_EXTRA, SYNCHRONOUS and 157 | PPPOE_TIMEOUT. 158 | 159 | .P 160 | By using different configuration files with different PIDFILE 161 | settings, you can manage multiple PPPoE connections. Just specify the 162 | configuration file as an argument to \fBpppoe-start\fR and \fBpppoe-stop\fR. 163 | 164 | .SH SEE ALSO 165 | pppoe(8), pppoe-connect(8), pppoe-start(8), pppoe-stop(8), pppd(8), pppoe-setup(8), 166 | pppoe-wrapper(8) 167 | 168 | -------------------------------------------------------------------------------- /gui/wrapper.c: -------------------------------------------------------------------------------- 1 | /* -*-Mode: C;-*- */ 2 | 3 | /*********************************************************************** 4 | * 5 | * wrapper.c 6 | * 7 | * C wrapper designed to run SUID root for controlling PPPoE connections. 8 | * 9 | * Copyright (C) 2005 by Roaring Penguin Software Inc. 10 | * 11 | * LIC: GPL 12 | * 13 | * This program may be distributed under the terms of the GNU General 14 | * Public License, Version 2, or (at your option) any later version. 15 | ***********************************************************************/ 16 | 17 | #define _SVID_SOURCE 1 /* For putenv */ 18 | #define _POSIX_SOURCE 1 /* For fileno */ 19 | #define _BSD_SOURCE 1 /* For setreuid */ 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #define CONN_NAME_LEN 64 28 | #define LINELEN 512 29 | 30 | static char const *pppoe_start = PPPOE_START_PATH; 31 | static char const *pppoe_stop = PPPOE_STOP_PATH; 32 | static char const *pppoe_status = PPPOE_STATUS_PATH; 33 | 34 | /********************************************************************** 35 | *%FUNCTION: PathOK 36 | *%ARGUMENTS: 37 | * fname -- a file name. 38 | *%RETURNS: 39 | * 1 if path to fname is secure; 0 otherwise. 40 | *%DESCRIPTION: 41 | * Makes sure ownership/permissions of file and parent directories 42 | * are safe. 43 | **********************************************************************/ 44 | static int 45 | PathOK(char const *fname) 46 | { 47 | char path[LINELEN]; 48 | struct stat buf; 49 | char const *slash; 50 | 51 | if (strlen(fname) > LINELEN) { 52 | fprintf(stderr, "Pathname '%s' too long\n", fname); 53 | return 0; 54 | } 55 | 56 | /* Must be absolute path */ 57 | if (*fname != '/') { 58 | fprintf(stderr, "Unsafe path '%s' not absolute\n", fname); 59 | return 0; 60 | } 61 | 62 | /* Check root directory */ 63 | if (stat("/", &buf) < 0) { 64 | perror("stat"); 65 | return 0; 66 | } 67 | if (buf.st_uid) { 68 | fprintf(stderr, "SECURITY ALERT: Root directory (/) not owned by root\n"); 69 | return 0; 70 | } 71 | if (buf.st_mode & (S_IWGRP | S_IWOTH)) { 72 | fprintf(stderr, "SECURITY ALERT: Root directory (/) writable by group or other\n"); 73 | return 0; 74 | } 75 | 76 | /* Check each component */ 77 | slash = fname; 78 | 79 | while(*slash) { 80 | slash = strchr(slash+1, '/'); 81 | if (!slash) { 82 | slash = fname + strlen(fname); 83 | } 84 | memcpy(path, fname, slash-fname); 85 | path[slash-fname] = 0; 86 | if (stat(path, &buf) < 0) { 87 | perror("stat"); 88 | return 0; 89 | } 90 | if (buf.st_uid) { 91 | fprintf(stderr, "SECURITY ALERT: '%s' not owned by root\n", path); 92 | return 0; 93 | } 94 | 95 | if (buf.st_mode & (S_IWGRP | S_IWOTH)) { 96 | fprintf(stderr, "SECURITY ALERT: '%s' writable by group or other\n", 97 | path); 98 | return 0; 99 | } 100 | } 101 | return 1; 102 | } 103 | 104 | /********************************************************************** 105 | *%FUNCTION: CleanEnvironment 106 | *%ARGUMENTS: 107 | * envp -- environment passed to main 108 | *%RETURNS: 109 | * Nothing 110 | *%DESCRIPTION: 111 | * Deletes all environment variables; makes safe environment 112 | **********************************************************************/ 113 | static void 114 | CleanEnvironment(char *envp[]) 115 | { 116 | envp[0] = NULL; 117 | putenv("PATH=/bin:/usr/bin:/sbin:/usr/sbin"); 118 | } 119 | 120 | /********************************************************************** 121 | *%FUNCTION: main 122 | *%ARGUMENTS: 123 | * argc, argv -- usual suspects 124 | * Usage: pppoe-wrapper {start|stop|status} {connection_name} 125 | *%RETURNS: 126 | * Whatever pppoe-start, pppoe-stop or pppoe-status returns. 127 | *%DESCRIPTION: 128 | * Runs pppoe-start, pppoe-stop or pppoe-status on given connection if 129 | * non-root users are allowed to do it. 130 | **********************************************************************/ 131 | int 132 | main(int argc, char *argv[]) 133 | { 134 | int amRoot; 135 | char *cp; 136 | char fname[64+CONN_NAME_LEN]; 137 | char line[LINELEN+1]; 138 | int allowed = 0; 139 | 140 | FILE *fp; 141 | 142 | extern char **environ; 143 | 144 | /* Clean out environment */ 145 | CleanEnvironment(environ); 146 | 147 | /* Are we root? */ 148 | amRoot = (getuid() == 0); 149 | 150 | /* Validate arguments */ 151 | if (argc != 3) { 152 | fprintf(stderr, "Usage: %s {start|stop|status} connection_name\n", 153 | argv[0]); 154 | exit(1); 155 | } 156 | 157 | if (strcmp(argv[1], "start") && 158 | strcmp(argv[1], "stop") && 159 | strcmp(argv[1], "status")) { 160 | fprintf(stderr, "Usage: %s {start|stop|status} connection_name\n", 161 | argv[0]); 162 | exit(1); 163 | } 164 | 165 | /* Connection name can be at most CONN_NAME_LEN chars; alpha, num, underscore */ 166 | if (strlen(argv[2]) > CONN_NAME_LEN) { 167 | fprintf(stderr, "%s: Connection name '%s' too long.\n", 168 | argv[0], argv[2]); 169 | exit(1); 170 | } 171 | 172 | for (cp = argv[2]; *cp; cp++) { 173 | if (!strchr("abcdefghijklmnopqrstuvwxyz" 174 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 175 | "0123456789_-", *cp)) { 176 | fprintf(stderr, "%s: Connection name '%s' contains illegal character '%c'\n", argv[0], argv[2], *cp); 177 | exit(1); 178 | } 179 | } 180 | 181 | /* Open the connection file */ 182 | sprintf(fname, "/etc/ppp/rp-pppoe-gui/conf.%s", argv[2]); 183 | /* Check path sanity */ 184 | if (!PathOK(fname)) { 185 | exit(1); 186 | } 187 | 188 | fp = fopen(fname, "r"); 189 | if (!fp) { 190 | fprintf(stderr, "%s: Could not open '%s': %s\n", 191 | argv[0], fname, strerror(errno)); 192 | exit(1); 193 | } 194 | 195 | /* Check if non-root users can control it */ 196 | if (amRoot) { 197 | allowed = 1; 198 | } else { 199 | while (!feof(fp)) { 200 | if (!fgets(line, LINELEN, fp)) { 201 | break; 202 | } 203 | if (!strcmp(line, "NONROOT=OK\n")) { 204 | allowed = 1; 205 | break; 206 | } 207 | } 208 | } 209 | fclose(fp); 210 | 211 | if (!allowed) { 212 | fprintf(stderr, "%s: Non-root users are not permitted to control connection '%s'\n", argv[0], argv[2]); 213 | exit(1); 214 | } 215 | 216 | /* Become root with setuid() to defeat is-root checks in shell scripts */ 217 | if (setreuid(0, 0) < 0) { 218 | perror("setreuid"); 219 | exit(1); 220 | } 221 | 222 | /* It's OK -- do it. */ 223 | if (!strcmp(argv[1], "start")) { 224 | if (!PathOK(pppoe_start)) exit(1); 225 | execl(pppoe_start, "pppoe-start", fname, NULL); 226 | } else if (!strcmp(argv[1], "stop")) { 227 | if (!PathOK(pppoe_stop)) exit(1); 228 | execl(pppoe_stop, "pppoe-stop", fname, NULL); 229 | } else { 230 | if (!PathOK(pppoe_status)) exit(1); 231 | execl(pppoe_status, "pppoe-status", fname, NULL); 232 | } 233 | fprintf(stderr, "%s: execl: %s\n", argv[0], strerror(errno)); 234 | exit(1); 235 | } 236 | -------------------------------------------------------------------------------- /man/pppoe-server.8: -------------------------------------------------------------------------------- 1 | .\" LIC: GPL 2 | .TH PPPOE-SERVER 8 "21 June 2008" 3 | .\"" 4 | .UC 4 5 | .SH NAME 6 | pppoe-server \- user-space PPPoE server 7 | .SH SYNOPSIS 8 | .B pppoe-server \fR[\fIoptions\fR] 9 | 10 | .SH DESCRIPTION 11 | \fBpppoe-server\fR is a user-space server for PPPoE (Point-to-Point Protocol 12 | over Ethernet) for Linux and other UNIX systems. \fBpppoe-server\fR works in 13 | concert with the \fBpppoe\fR client to respond to PPPoE discovery packets 14 | and set up PPPoE sessions. 15 | 16 | .SH OPTIONS 17 | .TP 18 | .B \-F 19 | The \fB\-F\fR option causes \fBpppoe-server\fR not to fork and become a 20 | daemon. The default is to fork and become a daemon. 21 | 22 | .TP 23 | .B \-I \fIinterface\fR 24 | The \fB\-I\fR option specifies the Ethernet interface to use. Under 25 | Linux, it is typically \fIeth0\fR or \fIeth1\fR. The interface should 26 | be "up" before you start \fBpppoe-server\fR, but need not have an IP 27 | address. You can supply multiple \fB\-I\fR options if you want the 28 | server to respond on more than one interface. 29 | 30 | .TP 31 | .B \-X \fIpidfile\fR 32 | This option causes \fBpppoe-server\fR to write its process ID to 33 | \fIpidfile\fR. Additionally, it keeps the file locked so that only 34 | a single process may be started for a given \fIpidfile\fR. 35 | 36 | .TP 37 | .B \-q \fI/path/to/pppd\fR 38 | Specifies the full path to the \fBpppd\fR program. The default is determined 39 | at compile time. One use of this option is to supply a wrapper program that 40 | modifies the arguments passed to pppd. This lets you do things not directly 41 | supported by the server (for example, specify IPv6 addresses.) 42 | 43 | .TP 44 | .B \-Q \fI/path/to/pppoe\fR 45 | Specifies the full path to the \fBpppoe\fR program. The default is determined 46 | at compile time. This option is only relevant if you are \fInot\fR 47 | using kernel-mode PPPoE. 48 | 49 | .TP 50 | .B \-T \fItimeout\fR 51 | This option is passed directly to \fBpppoe\fR; see \fBpppoe\fR(8) for 52 | details. If you are using kernel-mode PPPoE, this option has \fIno effect\fR. 53 | 54 | .TP 55 | .B \-C \fIac_name\fR 56 | Specifies which name to report as the access concentrator name. If not 57 | supplied, the host name is used. 58 | 59 | .TP 60 | .B \-S \fIname\fR 61 | Offer a service named \fIname\fR. Multiple \fB\-S\fR options may 62 | be specified; each one causes the named service to be advertised 63 | in a Service-Name tag in the PADO frame. The first \fB\-S\fR option 64 | specifies the default service, and is used if the PPPoE client 65 | requests a Service-Name of length zero. 66 | 67 | .TP 68 | .B \-m \fIMSS\fR 69 | This option is passed directly to \fBpppoe\fR; see \fBpppoe\fR(8) for 70 | details. If you are using kernel-mode PPPoE, this option has \fIno effect\fR. 71 | 72 | .TP 73 | .B \-x \fIn\fR 74 | Limit the number of sessions per peer MAC address to \fIn\fR. If a given 75 | MAC address attempts to create more than \fIn\fR sessions, then its 76 | PADI and PADR packets are ignored. If you set \fIn\fR to 0 (the default), 77 | then no limit is imposed on the number of sessions per peer MAC address. 78 | 79 | .TP 80 | .B \-s 81 | This option is passed directly to \fBpppoe\fR; see \fBpppoe\fR(8) for 82 | details. In addition, it causes \fBpppd\fR to be invoked with the 83 | \fIsync\fR option. 84 | 85 | .TP 86 | .B \-L \fIip\fR 87 | Sets the local IP address. This is passed to spawned \fBpppd\fR processes. 88 | If not specified, the default is 10.0.0.1. 89 | 90 | .TP 91 | .B \-R \fIip\fR 92 | Sets the starting remote IP address. As sessions are established, 93 | IP addresses are assigned starting from \fIip\fR. \fBpppoe-server\fR 94 | automatically keeps track of the pool of addresses and passes a 95 | valid remote IP address to \fBpppd\fR. If not specified, a starting address 96 | of 10.67.15.1 is used. 97 | 98 | .TP 99 | .B \-N \fInum\fR 100 | Allows at most \fInum\fR concurrent PPPoE sessions. If not specified, 101 | the default is 64. 102 | 103 | .TP 104 | .B \-O \fIfname\fR 105 | This option causes \fBpppoe-server\fR to tell \fBpppd\fR to use the option 106 | file \fIfname\fR instead of the default \fI/etc/ppp/pppoe-server-options\fR. 107 | 108 | .TP 109 | .B \-p \fIfname\fR 110 | Reads the specified file \fIfname\fR which is a text file consisting of 111 | one IP address per line. These IP addresses will be assigned to clients. 112 | The number of sessions allowed will equal the number of addresses found 113 | in the file. The \fB\-p\fR option overrides both \fB\-R\fR and \fB\-N\fR. 114 | 115 | In addition to containing IP addresses, the pool file can contain lines 116 | of the form: 117 | 118 | .nf 119 | a.b.c.d-e 120 | .fi 121 | 122 | which includes all IP addresses from a.b.c.d to a.b.c.e. For example, 123 | the line: 124 | 125 | .nf 126 | 1.2.3.4-7 127 | .fi 128 | 129 | is equivalent to: 130 | 131 | .nf 132 | 1.2.3.4 133 | 1.2.3.5 134 | 1.2.3.6 135 | 1.2.3.7 136 | .fi 137 | 138 | .TP 139 | .B \-r 140 | Tells the PPPoE server to randomly permute session numbers. Instead of 141 | handing out sessions in order, the session numbers are assigned in an 142 | unpredictable order. 143 | 144 | .TP 145 | .B \-u 146 | Tells the server to invoke \fBpppd\fR with the \fIunit\fR option. Note 147 | that this option only works for \fBpppd\fR version 2.4.0 or newer. 148 | 149 | .TP 150 | .B \-o \fIoffset\fR 151 | Instead of numbering PPPoE sessions starting at 1, they will be numbered 152 | starting at \fIoffset\fR+1. This allows you to run multiple servers on 153 | a given machine; just make sure that their session numbers do not 154 | overlap. 155 | 156 | .TP 157 | .B \-f disc:sess 158 | The \fB\-f\fR option sets the Ethernet frame types for PPPoE discovery 159 | and session frames. The types are specified as hexadecimal numbers 160 | separated by a colon. Standard PPPoE uses frame types 8863:8864. 161 | \fIYou should not use this option\fR unless you are absolutely sure 162 | the peer you are dealing with uses non-standard frame types. 163 | 164 | .TP 165 | .B \-k 166 | The \fB\-k\fR option tells the server to use kernel-mode PPPoE on Linux. 167 | This option is available only on Linux kernels 2.4.0 and later, and 168 | only if the server was built with kernel-mode support. 169 | 170 | .TP 171 | .B \-i 172 | The \fB\-i\fR option tells the server to completely ignore PADI frames 173 | if there are no free session slots. 174 | 175 | .TP 176 | .B \-h 177 | The \fB\-h\fR option prints a brief usage message and exits. 178 | 179 | .SH OPERATION 180 | 181 | \fBpppoe-server\fR listens for incoming PPPoE discovery packets. When 182 | a session is established, it spawns a \fBpppd\fR process. The following 183 | options are passed to \fBpppd\fR: 184 | 185 | .nf 186 | nodetach noaccomp nobsdcom nodeflate nopcomp novj novjccomp 187 | default-asyncmap 188 | .fi 189 | 190 | In addition, the local and remote IP address are set based on the 191 | \fB\-L\fR and \fB\-R\fR options. The \fBpty\fR option is supplied along 192 | with a \fBpppoe\fR command to initiate the PPPoE session. Finally, 193 | additional \fBpppd\fR options can be placed in the file 194 | \fB/etc/ppp/pppoe-server-options\fR (which must exist, even if it is just 195 | empty!) 196 | 197 | Note that \fBpppoe-server\fR is meant mainly for testing PPPoE clients. 198 | It is \fInot\fR a high-performance server meant for production use. 199 | 200 | .SH AUTHORS 201 | \fBpppoe-server\fR was written by David F. Skoll . 202 | 203 | The \fBpppoe\fR home page is \fIhttp://www.roaringpenguin.com/pppoe/\fR. 204 | 205 | .SH SEE ALSO 206 | pppoe-start(8), pppoe-stop(8), pppoe-connect(8), pppd(8), pppoe.conf(5), 207 | pppoe(8), pppoe-setup(8), pppoe-status(8), pppoe-sniff(8), pppoe-relay(8) 208 | 209 | -------------------------------------------------------------------------------- /gui/html/tkpppoe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | TkPPPoE Manual 8 | 9 | 10 | 11 |
12 |

tkpppoe - A GUI for managing PPPoE Connections

13 |
14 | 15 |

Introduction

16 | 17 | TkPPPoE is a graphical user interface for managing PPPoE connections. It 18 | performs two different functions: 19 |
    20 |
  • TkPPPoE lets you define connection properties. This step must 21 | be done as root. 22 |
  • TkPPPoE lets you start and stop PPPoE connections. This step 23 | may be done as a normal user, depending on how you configured the connection. 24 |
25 | 26 |

Defining Connections

27 | 28 | To define connections, start TkPPPoE as root. You can do this from 29 | a terminal by typing tkpppoe, or from the KDE or GNOME menus 30 | by selecting Internet : TkPPPoE. The following window pops up: 31 | 32 |

33 |

Main Window 34 |
35 | 36 |

37 | Because you have not yet defined any connections, the connection property 38 | window also pops up: 39 | 40 |

41 |

Connection Properties - Basic 42 |
43 | 44 | You can pop up the connection property window at any time by clicking 45 | New Connection... You can edit the properties of an existing 46 | connection by selecting the connection's name and clicking 47 | Properties... 48 |

Basic Information

49 | 50 | Let's fill in the basic information: 51 |
    52 |
  • For Connection Name, enter a unique name for this connection. It 53 | can be anything you like, but must contain only letters, numbers, underscores 54 | or dashes. In particular, it can't contain spaces. If you have only one 55 | PPPoE connection, a good name is Default. 56 |
  • For User Name, enter the user name supplied by your ISP. Enter 57 | only the user name; do not enter an "@isp.com" part. 58 |
  • For Network, you may have to enter your ISP's domain name. 59 | (For example, isp.com.) Some DSL providers add this to your user 60 | name; others do not. You may have to experiment a bit. The two most likely 61 | choices are your ISP's domain name, or blank. Try both. 62 |
  • For Password, enter the password your ISP provided you with. 63 |
64 | 65 |

NIC and DNS

66 | Click on the NIC and DNS tab: 67 | 68 |

69 |

Connection Properties - NIC and DNS
70 |

71 |

    72 |
  • For Ethernet Interface, enter the Ethernet interface connected 73 | to the DSL modem. It is something like eth0 or eth1. Click 74 | on ... to browse a list of detected Ethernet interfaces. 75 |
  • For DNS Setup, you have three options: 76 |
      77 |
    1. From Server means that the system will obtain DNS information from 78 | the PPPoE server. This is the correct choice for most ISPs. 79 |
    2. Specify means that you will enter the IP addresses of your DNS 80 | servers manually. In this case, enter the addresses in the Primary DNS 81 | and Secondary DNS entries. 82 |
    3. Do not Adjust means that you want RP-PPPoE to leave your 83 | DNS setup alone. Use this if you are running your own caching DNS server 84 | or know that you don't want the DNS setup touched. 85 |
    86 |
87 | 88 |

Options

89 | Click on the Options tab: 90 | 91 |

92 |

Connection Properties - Options
93 |

94 |

    95 |
  • If you want ordinary users to be able to start and stop this connection, 96 | enable Allow use by non-root users. If you do not enable this, 97 | non-root users will be able to monitor the connection, but not control it. 98 |
  • If you want to use synchronous PPP, enable Use synchronous PPP. 99 | This is recommended as it conserves CPU usage, but may not work on some 100 | (misconfigured) Linux kernels. 101 |
  • For Firewalling, you have three options: 102 |
      103 |
    1. Stand-Alone installs a simple firewall ruleset for stand-alone 104 | machines. Use this if you have only a single computer connected to the DSL 105 | modem. 106 |
    2. Masquerading installs a simple firewall ruleset for using 107 | your Linux computer as an Internet sharing device. If you have two Ethernet 108 | cards, you can connect one card to the DSL modem and the other to an 109 | internal LAN. The masquerading firewall ruleset lets internal machines 110 | share the DSL connection. 111 |
    3. None. If you already have your own firewall rules, or you wish 112 | to run servers on your machine, select None. This is not recommended 113 | unless you take steps to secure your machine, and know what you are doing. 114 |
    115 |
116 | 117 |

Advanced

118 | Click on the Advanced tab: 119 | 120 |

121 |

Connection Properties - Advanced
122 |

123 | 124 | In most cases, you can leave AC-Name and Service-Name blank. 125 | In some cases, your ISP may require you to enter information in these fields; 126 | contact your ISP for more information. 127 | 128 |

Controlling Connections

129 | For these examples, run tkpppoe as a normal user (not root). 130 | The main window appears like this: 131 | 132 |

133 |

Main Window - Non-root 134 |
135 |

136 |

    137 |
  • To start a connection, press Start. The two LEDs flash red 138 | and grey. If the connection is established, they turn green. 139 |
  • To stop a connection, press Stop. 140 |
141 | 142 |

The two rectangles to the right of the connection name are the 143 | status LEDs. The top LED corresponds to transmitted data and 144 | the bottom to received. The LEDs are colored as follows: 145 |

    146 |
  • Grey -- connection is not established. 147 |
  • Flashing red/grey -- connection is being started. 148 |
  • Green -- connection is up, but idle. 149 |
  • Yellow -- connection is up and data is being sent or received. 150 |
  • Red -- connection has been lost, but the system is trying to reestablish it. 151 |
152 | 153 |

154 | When a connection is established, two graphs appear: 155 | 156 |

157 |

Main Window - Established Connection 158 |
159 |

160 | 161 | The left (red) graph shows transmitted packets and the average 162 | transmission speed (in bits per second) over the sample time. The 163 | right (green) graph shows received packets. 164 | 165 |

Miscellaneous Information

166 |
    167 |
  • The connection menu has an entry called User's Manual which 168 | will pop up this user manual (if you have Netscape installed.) 169 |
  • You can define multiple PPPoE connections, but you should not use 170 | more than one simultaneuously unless you feel comfortable editing scripts 171 | and setting up routing tables. By default, TkPPPoE tries to add a default 172 | route for connections. This does not work well with multiple simultaneous 173 | connections. 174 |
  • If you exit from TkPPPoE, connections which are up remain up. You 175 | have to explicitly stop connections if you want them terminated. 176 |
177 |
178 | TkPPPoE is Copyright 2001 by Roaring Penguin Software Inc and 179 | is licensed under the GNU General Public License. 180 |

Screenshots show TkPPPoE running under the XFCE desktop, a lightweight UNIX and Linux desktop. 181 | 182 | 183 | -------------------------------------------------------------------------------- /src/pppoe-sniff.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * pppoe-sniff.c 4 | * 5 | * Sniff a network for likely-looking PPPoE frames and deduce the value 6 | * to supply to PPPOE_EXTRA in /etc/ppp/pppoe.conf. USE AT YOUR OWN RISK. 7 | * 8 | * Copyright (C) 2000 by Roaring Penguin Software Inc. 9 | * 10 | * This program may be distributed according to the terms of the GNU 11 | * General Public License, version 2 or (at your option) any later version. 12 | * 13 | * LIC: GPL 14 | * 15 | ***********************************************************************/ 16 | 17 | static char const RCSID[] = 18 | "$Id$"; 19 | 20 | #include "pppoe.h" 21 | 22 | #ifdef HAVE_GETOPT_H 23 | #include 24 | #endif 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #ifdef USE_DLPI 32 | #include 33 | /* function declarations */ 34 | void dlpromisconreq( int fd, u_long level); 35 | void dlokack(int fd, char *bufp); 36 | #endif 37 | 38 | /* Default interface if no -I option given */ 39 | #define DEFAULT_IF "eth0" 40 | 41 | /* Global vars */ 42 | int SeenPADR = 0; 43 | int SeenSess = 0; 44 | UINT16_t SessType, DiscType; 45 | 46 | char *IfName = NULL; /* Interface name */ 47 | char *ServiceName = NULL; /* Service name */ 48 | 49 | /********************************************************************** 50 | *%FUNCTION: parsePADRTags 51 | *%ARGUMENTS: 52 | * type -- tag type 53 | * len -- tag length 54 | * data -- tag data 55 | * extra -- extra user data. 56 | *%RETURNS: 57 | * Nothing 58 | *%DESCRIPTION: 59 | * Picks interesting tags out of a PADR packet 60 | ***********************************************************************/ 61 | void 62 | parsePADRTags(UINT16_t type, UINT16_t len, unsigned char *data, 63 | void *extra) 64 | { 65 | switch(type) { 66 | case TAG_SERVICE_NAME: 67 | ServiceName = malloc(len+1); 68 | if (ServiceName) { 69 | memcpy(ServiceName, data, len); 70 | ServiceName[len] = 0; 71 | } 72 | break; 73 | } 74 | } 75 | 76 | /********************************************************************** 77 | *%FUNCTION: fatalSys 78 | *%ARGUMENTS: 79 | * str -- error message 80 | *%RETURNS: 81 | * Nothing 82 | *%DESCRIPTION: 83 | * Prints a message plus the errno value to stderr and exits. 84 | ***********************************************************************/ 85 | void 86 | fatalSys(char const *str) 87 | { 88 | char buf[1024]; 89 | sprintf(buf, "%.256s: %.256s", str, strerror(errno)); 90 | printErr(buf); 91 | exit(1); 92 | } 93 | 94 | /********************************************************************** 95 | *%FUNCTION: rp_fatal 96 | *%ARGUMENTS: 97 | * str -- error message 98 | *%RETURNS: 99 | * Nothing 100 | *%DESCRIPTION: 101 | * Prints a message to stderr and syslog and exits. 102 | ***********************************************************************/ 103 | void 104 | rp_fatal(char const *str) 105 | { 106 | printErr(str); 107 | exit(1); 108 | } 109 | 110 | /********************************************************************** 111 | *%FUNCTION: usage 112 | *%ARGUMENTS: 113 | * argv0 -- program name 114 | *%RETURNS: 115 | * Nothing 116 | *%DESCRIPTION: 117 | * Prints usage information and exits. 118 | ***********************************************************************/ 119 | void 120 | usage(char const *argv0) 121 | { 122 | fprintf(stderr, "Usage: %s [options]\n", argv0); 123 | fprintf(stderr, "Options:\n"); 124 | fprintf(stderr, " -I if_name -- Specify interface (default %s.)\n", 125 | DEFAULT_IF); 126 | fprintf(stderr, " -V -- Print version and exit.\n"); 127 | fprintf(stderr, "\nPPPoE Version %s, Copyright (C) 2000 Roaring Penguin Software Inc.\n", VERSION); 128 | fprintf(stderr, "PPPoE comes with ABSOLUTELY NO WARRANTY.\n"); 129 | fprintf(stderr, "This is free software, and you are welcome to redistribute it under the terms\n"); 130 | fprintf(stderr, "of the GNU General Public License, version 2 or any later version.\n"); 131 | fprintf(stderr, "http://www.roaringpenguin.com\n"); 132 | exit(0); 133 | } 134 | 135 | #if !defined(USE_LINUX_PACKET) && !defined(USE_DLPI) 136 | 137 | int 138 | main() 139 | { 140 | fprintf(stderr, "Sorry, pppoe-sniff works only on Linux.\n"); 141 | return 1; 142 | } 143 | 144 | #else 145 | 146 | /********************************************************************** 147 | *%FUNCTION: main 148 | *%ARGUMENTS: 149 | * argc, argv -- count and values of command-line arguments 150 | *%RETURNS: 151 | * Nothing 152 | *%DESCRIPTION: 153 | * Main program 154 | ***********************************************************************/ 155 | int 156 | main(int argc, char *argv[]) 157 | { 158 | int opt; 159 | int sock; 160 | PPPoEPacket pkt; 161 | int size; 162 | #ifdef USE_DLPI 163 | long buf[MAXDLBUF]; 164 | #endif 165 | 166 | if (getuid() != geteuid() || 167 | getgid() != getegid()) { 168 | fprintf(stderr, "SECURITY WARNING: pppoe-sniff will NOT run suid or sgid. Fix your installation.\n"); 169 | exit(1); 170 | } 171 | 172 | while((opt = getopt(argc, argv, "I:V")) != -1) { 173 | switch(opt) { 174 | case 'I': 175 | SET_STRING(IfName, optarg); 176 | break; 177 | case 'V': 178 | printf("pppoe-sniff: Roaring Penguin PPPoE Version %s\n", VERSION); 179 | exit(0); 180 | default: 181 | usage(argv[0]); 182 | } 183 | } 184 | 185 | /* Pick a default interface name */ 186 | if (!IfName) { 187 | IfName = DEFAULT_IF; 188 | } 189 | 190 | /* Open the interface */ 191 | #ifdef USE_DLPI 192 | sock = openInterface(IfName, Eth_PPPOE_Discovery, NULL); 193 | dlpromisconreq(sock, DL_PROMISC_PHYS); 194 | dlokack(sock, (char *)buf); 195 | dlpromisconreq(sock, DL_PROMISC_SAP); 196 | dlokack(sock, (char *)buf); 197 | #else 198 | 199 | sock = openInterface(IfName, ETH_P_ALL, NULL, NULL); 200 | 201 | #endif 202 | 203 | /* We assume interface is in promiscuous mode -- use ifconfig to 204 | ensure this */ 205 | fprintf(stderr, "Sniffing for PADR. Start your connection on another machine...\n"); 206 | while (!SeenPADR) { 207 | if (receivePacket(sock, &pkt, &size) < 0) continue; 208 | if (ntohs(pkt.length) + HDR_SIZE > size) continue; 209 | if (pkt.ver != 1 || pkt.type != 1) continue; 210 | if (pkt.code != CODE_PADR) continue; 211 | 212 | /* Looks promising... parse it */ 213 | if (parsePacket(&pkt, parsePADRTags, NULL) < 0) { 214 | continue; 215 | } 216 | DiscType = ntohs(pkt.ethHdr.h_proto); 217 | fprintf(stderr, "\nExcellent! Sniffed a likely-looking PADR.\n"); 218 | break; 219 | } 220 | 221 | while (!SeenSess) { 222 | if (receivePacket(sock, &pkt, &size) < 0) continue; 223 | if (ntohs(pkt.length) + HDR_SIZE > size) continue; 224 | if (pkt.ver != 1 || pkt.type != 1) continue; 225 | if (pkt.code != CODE_SESS) continue; 226 | 227 | /* Cool! */ 228 | SessType = ntohs(pkt.ethHdr.h_proto); 229 | break; 230 | } 231 | 232 | fprintf(stderr, "Wonderful! Sniffed a likely-looking session packet.\n"); 233 | if ((ServiceName == NULL || *ServiceName == 0) && 234 | DiscType == ETH_PPPOE_DISCOVERY && 235 | SessType == ETH_PPPOE_SESSION) { 236 | fprintf(stderr, "\nGreat! It looks like a standard PPPoE service.\nYou should not need anything special in the configuration file.\n"); 237 | return 0; 238 | } 239 | 240 | fprintf(stderr, "\nOK, looks like you need something special in the configuration file.\nTry this:\n\n"); 241 | if (ServiceName != NULL && *ServiceName != 0) { 242 | fprintf(stderr, "SERVICENAME='%s'\n", ServiceName); 243 | } 244 | if (DiscType != ETH_PPPOE_DISCOVERY || SessType != ETH_PPPOE_SESSION) { 245 | fprintf(stderr, " PPPOE_EXTRA='-f %x:%x'\n", DiscType, SessType); 246 | } 247 | return 0; 248 | } 249 | 250 | #endif 251 | /********************************************************************** 252 | *%FUNCTION: sysErr 253 | *%ARGUMENTS: 254 | * str -- error message 255 | *%RETURNS: 256 | * Nothing 257 | *%DESCRIPTION: 258 | * Prints a message plus the errno value to syslog. 259 | ***********************************************************************/ 260 | void 261 | sysErr(char const *str) 262 | { 263 | char buf[1024]; 264 | sprintf(buf, "%.256s: %.256s", str, strerror(errno)); 265 | printErr(buf); 266 | } 267 | -------------------------------------------------------------------------------- /src/libevent/hash.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * hash.c 4 | * 5 | * Implementation of hash tables. Each item inserted must include 6 | * a hash_bucket member. 7 | * 8 | * Copyright (C) 2002 Roaring Penguin Software Inc. 9 | * 10 | * This software may be distributed under the terms of the GNU General 11 | * Public License, Version 2 or (at your option) any later version. 12 | * 13 | * LIC: GPL 14 | * 15 | ***********************************************************************/ 16 | 17 | static char const RCSID[] = 18 | "$Id$"; 19 | 20 | #include "hash.h" 21 | 22 | #include 23 | #define BITS_IN_int ( sizeof(int) * CHAR_BIT ) 24 | #define THREE_QUARTERS ((int) ((BITS_IN_int * 3) / 4)) 25 | #define ONE_EIGHTH ((int) (BITS_IN_int / 8)) 26 | #define HIGH_BITS ( ~((unsigned int)(~0) >> ONE_EIGHTH )) 27 | 28 | #define GET_BUCKET(tab, data) ((hash_bucket *) ((char *) (data) + (tab)->hash_offset)) 29 | 30 | #define GET_ITEM(tab, bucket) ((void *) (((char *) (void *) bucket) - (tab)->hash_offset)) 31 | 32 | static void *hash_next_cursor(hash_table *tab, hash_bucket *b); 33 | 34 | /********************************************************************** 35 | * %FUNCTION: hash_init 36 | * %ARGUMENTS: 37 | * tab -- hash table 38 | * hash_offset -- offset of hash_bucket data member in inserted items 39 | * compute -- pointer to function to compute hash value 40 | * compare -- pointer to comparison function. Returns 0 if items are equal, 41 | * non-zero otherwise. 42 | * %RETURNS: 43 | * Nothing 44 | * %DESCRIPTION: 45 | * Initializes a hash table. 46 | ***********************************************************************/ 47 | void 48 | hash_init(hash_table *tab, 49 | size_t hash_offset, 50 | unsigned int (*compute)(void *data), 51 | int (*compare)(void *item1, void *item2)) 52 | { 53 | size_t i; 54 | 55 | tab->hash_offset = hash_offset; 56 | tab->compute_hash = compute; 57 | tab->compare = compare; 58 | for (i=0; ibuckets[i] = NULL; 60 | } 61 | tab->num_entries = 0; 62 | } 63 | 64 | /********************************************************************** 65 | * %FUNCTION: hash_insert 66 | * %ARGUMENTS: 67 | * tab -- hash table to insert into 68 | * item -- the item we're inserting 69 | * %RETURNS: 70 | * Nothing 71 | * %DESCRIPTION: 72 | * Inserts an item into the hash table. It must not currently be in any 73 | * hash table. 74 | ***********************************************************************/ 75 | void 76 | hash_insert(hash_table *tab, 77 | void *item) 78 | { 79 | hash_bucket *b = GET_BUCKET(tab, item); 80 | unsigned int val = tab->compute_hash(item); 81 | b->hashval = val; 82 | val %= HASHTAB_SIZE; 83 | b->prev = NULL; 84 | b->next = tab->buckets[val]; 85 | if (b->next) { 86 | b->next->prev = b; 87 | } 88 | tab->buckets[val] = b; 89 | tab->num_entries++; 90 | } 91 | 92 | /********************************************************************** 93 | * %FUNCTION: hash_remove 94 | * %ARGUMENTS: 95 | * tab -- hash table 96 | * item -- item in hash table 97 | * %RETURNS: 98 | * Nothing 99 | * %DESCRIPTION: 100 | * Removes item from hash table 101 | ***********************************************************************/ 102 | void 103 | hash_remove(hash_table *tab, 104 | void *item) 105 | { 106 | hash_bucket *b = GET_BUCKET(tab, item); 107 | unsigned int val = b->hashval % HASHTAB_SIZE; 108 | 109 | if (b->prev) { 110 | b->prev->next = b->next; 111 | } else { 112 | tab->buckets[val] = b->next; 113 | } 114 | if (b->next) { 115 | b->next->prev = b->prev; 116 | } 117 | tab->num_entries--; 118 | } 119 | 120 | /********************************************************************** 121 | * %FUNCTION: hash_find 122 | * %ARGUMENTS: 123 | * tab -- hash table 124 | * item -- item equal to one we're seeking (in the compare-function sense) 125 | * %RETURNS: 126 | * A pointer to the item in the hash table, or NULL if no such item 127 | * %DESCRIPTION: 128 | * Searches hash table for item. 129 | ***********************************************************************/ 130 | void * 131 | hash_find(hash_table *tab, 132 | void *item) 133 | { 134 | unsigned int val = tab->compute_hash(item) % HASHTAB_SIZE; 135 | hash_bucket *b; 136 | for (b = tab->buckets[val]; b; b = b->next) { 137 | void *item2 = GET_ITEM(tab, b); 138 | if (!tab->compare(item, item2)) return item2; 139 | } 140 | return NULL; 141 | } 142 | 143 | /********************************************************************** 144 | * %FUNCTION: hash_find_next 145 | * %ARGUMENTS: 146 | * tab -- hash table 147 | * item -- an item returned by hash_find or hash_find_next 148 | * %RETURNS: 149 | * A pointer to the next equal item in the hash table, or NULL if no such item 150 | * %DESCRIPTION: 151 | * Searches hash table for anoter item equivalent to this one. Search 152 | * starts from item. 153 | ***********************************************************************/ 154 | void * 155 | hash_find_next(hash_table *tab, 156 | void *item) 157 | { 158 | hash_bucket *b = GET_BUCKET(tab, item); 159 | for (b = b->next; b; b = b->next) { 160 | void *item2 = GET_ITEM(tab, b); 161 | if (!tab->compare(item, item2)) return item2; 162 | } 163 | return NULL; 164 | } 165 | /********************************************************************** 166 | * %FUNCTION: hash_start 167 | * %ARGUMENTS: 168 | * tab -- hash table 169 | * cursor -- a void pointer to keep track of location 170 | * %RETURNS: 171 | * "first" entry in hash table, or NULL if table is empty 172 | * %DESCRIPTION: 173 | * Starts an iterator -- sets cursor so hash_next will return next entry. 174 | ***********************************************************************/ 175 | void * 176 | hash_start(hash_table *tab, void **cursor) 177 | { 178 | int i; 179 | for (i=0; ibuckets[i]) { 181 | /* Point cursor to NEXT item so it is valid 182 | even if current item is free'd */ 183 | *cursor = hash_next_cursor(tab, tab->buckets[i]); 184 | return GET_ITEM(tab, tab->buckets[i]); 185 | } 186 | } 187 | *cursor = NULL; 188 | return NULL; 189 | } 190 | 191 | /********************************************************************** 192 | * %FUNCTION: hash_next 193 | * %ARGUMENTS: 194 | * tab -- hash table 195 | * cursor -- cursor into hash table 196 | * %RETURNS: 197 | * Next item in table, or NULL. 198 | * %DESCRIPTION: 199 | * Steps cursor to next item in table. 200 | ***********************************************************************/ 201 | void * 202 | hash_next(hash_table *tab, void **cursor) 203 | { 204 | hash_bucket *b; 205 | 206 | if (!*cursor) return NULL; 207 | 208 | b = (hash_bucket *) *cursor; 209 | *cursor = hash_next_cursor(tab, b); 210 | return GET_ITEM(tab, b); 211 | } 212 | 213 | /********************************************************************** 214 | * %FUNCTION: hash_next_cursor 215 | * %ARGUMENTS: 216 | * tab -- a hash table 217 | * b -- a hash bucket 218 | * %RETURNS: 219 | * Cursor value for bucket following b in hash table. 220 | ***********************************************************************/ 221 | static void * 222 | hash_next_cursor(hash_table *tab, hash_bucket *b) 223 | { 224 | unsigned int i; 225 | if (!b) return NULL; 226 | if (b->next) return b->next; 227 | 228 | i = b->hashval % HASHTAB_SIZE; 229 | for (++i; ibuckets[i]) return tab->buckets[i]; 231 | } 232 | return NULL; 233 | } 234 | 235 | size_t 236 | hash_num_entries(hash_table *tab) 237 | { 238 | return tab->num_entries; 239 | } 240 | 241 | /********************************************************************** 242 | * %FUNCTION: hash_pjw 243 | * %ARGUMENTS: 244 | * str -- a zero-terminated string 245 | * %RETURNS: 246 | * A hash value using the hashpjw algorithm 247 | * %DESCRIPTION: 248 | * An adaptation of Peter Weinberger's (PJW) generic hashing 249 | * algorithm based on Allen Holub's version. Accepts a pointer 250 | * to a datum to be hashed and returns an unsigned integer. 251 | ***********************************************************************/ 252 | unsigned int 253 | hash_pjw(char const * str) 254 | { 255 | unsigned int hash_value, i; 256 | 257 | for (hash_value = 0; *str; ++str) { 258 | hash_value = ( hash_value << ONE_EIGHTH ) + *str; 259 | if (( i = hash_value & HIGH_BITS ) != 0 ) { 260 | hash_value = 261 | ( hash_value ^ ( i >> THREE_QUARTERS )) & 262 | ~HIGH_BITS; 263 | } 264 | } 265 | return hash_value; 266 | } 267 | -------------------------------------------------------------------------------- /gui/en.msg: -------------------------------------------------------------------------------- 1 | # LIC: GPL 2 | 3 | ::msgcat::mcset en "AC-Name:" "AC-Name:" 4 | ::msgcat::mcset en "Advanced" "Advanced" 5 | ::msgcat::mcset en "Allow use by non-root users" "Allow use by non-root users" 6 | ::msgcat::mcset en "Are you sure you wish to delete the connection" "Are you sure you wish to delete the connection" 7 | ::msgcat::mcset en "Basic" "Basic" 8 | ::msgcat::mcset en "Browse detected Ethernet interface names." "Browse detected Ethernet interface names." 9 | ::msgcat::mcset en "Cancel" "Cancel" 10 | ::msgcat::mcset en "Confirm Deletion - RP-PPPoE" "Confirm Deletion - RP-PPPoE" 11 | ::msgcat::mcset en "Connection aborted by user" "Connection aborted by user" 12 | ::msgcat::mcset en "Connection Exists" "Connection Exists" 13 | ::msgcat::mcset en "Connection Name:" "Connection Name:" 14 | ::msgcat::mcset en "Connection name must be non-blank and contain only letters, digits, `_' and `-'" "Connection name must be non-blank and contain only letters, digits, `_' and `-'" 15 | ::msgcat::mcset en "Delete" "Delete" 16 | ::msgcat::mcset en "DNS server options:\n'From Server' - Let PPPoE server specify DNS servers\n'Specify' - Enter IP addresses of DNS servers yourself\n'Do not Adjust' - Leave your DNS setup alone." "DNS server options:\n'From Server' - Let PPPoE server specify DNS servers\n'Specify' - Enter IP addresses of DNS servers yourself\n'Do not Adjust' - Leave your DNS setup alone." 17 | ::msgcat::mcset en "DNS server options:\n'From Server' - Let PPPoE server specify DNS servers\n'Specify' - Enter IP addresses of DNS servers yourself\n'Do not Adjust' - Leave your DNS setup alone." "DNS server options:\n'From Server' - Let PPPoE server specify DNS servers\n'Specify' - Enter IP addresses of DNS servers yourself\n'Do not Adjust' - Leave your DNS setup alone." 18 | ::msgcat::mcset en "DNS Setup:" "DNS Setup:" 19 | ::msgcat::mcset en "Do not Adjust" "Do not Adjust" 20 | ::msgcat::mcset en "Edit Connection" "Edit Connection" 21 | ::msgcat::mcset en "Edit Connection" "Edit Connection" 22 | ::msgcat::mcset en "Enter access concentrator name if required. Most ISPs do not require this; try leaving it blank." "Enter access concentrator name if required. Most ISPs do not require this; try leaving it blank." 23 | ::msgcat::mcset en "Enter access concentrator name if required. Most ISPs do not require this; try leaving it blank." "Enter access concentrator name if required. Most ISPs do not require this; try leaving it blank." 24 | ::msgcat::mcset en "Enter a name for this connection. It can contain letters, numbers, undescores and the minus-sign." "Enter a name for this connection. It can contain letters, numbers, undescores and the minus-sign." 25 | ::msgcat::mcset en "Enter a name for this connection. It can contain letters, numbers, undescores and the minus-sign." "Enter a name for this connection. It can contain letters, numbers, undescores and the minus-sign." 26 | ::msgcat::mcset en "Enter Ethernet interface to which DSL modem is attached." "Enter Ethernet interface to which DSL modem is attached." 27 | ::msgcat::mcset en "Enter Ethernet interface to which DSL modem is attached." "Enter Ethernet interface to which DSL modem is attached." 28 | ::msgcat::mcset en "Enter service name if required. Most ISPs do not require this; try leaving it blank." "Enter service name if required. Most ISPs do not require this; try leaving it blank." 29 | ::msgcat::mcset en "Enter service name if required. Most ISPs do not require this; try leaving it blank." "Enter service name if required. Most ISPs do not require this; try leaving it blank." 30 | ::msgcat::mcset en "Enter the IP address of the primary DNS server." "Enter the IP address of the primary DNS server." 31 | ::msgcat::mcset en "Enter the IP address of the primary DNS server." "Enter the IP address of the primary DNS server." 32 | ::msgcat::mcset en "Enter the IP address of the secondary DNS server." "Enter the IP address of the secondary DNS server." 33 | ::msgcat::mcset en "Enter the IP address of the secondary DNS server." "Enter the IP address of the secondary DNS server." 34 | ::msgcat::mcset en "Enter your password." "Enter your password." 35 | ::msgcat::mcset en "Enter your password." "Enter your password." 36 | ::msgcat::mcset en "Enter your user name. Do not add a domain-name after the user name." "Enter your user name. Do not add a domain-name after the user name." 37 | ::msgcat::mcset en "Enter your user name. Do not add a domain-name after the user name." "Enter your user name. Do not add a domain-name after the user name." 38 | ::msgcat::mcset en "Error" "Error" 39 | ::msgcat::mcset en "Error loading configuration file:" "Error loading configuration file:" 40 | ::msgcat::mcset en "Error starting connection:" "Error starting connection:" 41 | ::msgcat::mcset en "Error stopping connection:" "Error stopping connection:" 42 | ::msgcat::mcset en "Ethernet Interface:" "Ethernet Interface:" 43 | ::msgcat::mcset en "Exit" "Exit" 44 | ::msgcat::mcset en "failed" "failed" 45 | ::msgcat::mcset en "failed" "failed" 46 | ::msgcat::mcset en "Firewalling:" "Firewalling:" 47 | ::msgcat::mcset en "Firewalling options:\nStand-Alone - A stand-alone machine.\nMasquerading - A gateway machine used for Internet sharing.\nNone - Use if you already have your own firewall rules or want to run servers." "Firewalling options:\nStand-Alone - A stand-alone machine.\nMasquerading - A gateway machine used for Internet sharing.\nNone - Use if you already have your own firewall rules or want to run servers." 48 | ::msgcat::mcset en "Firewalling options:\nStand-Alone - A stand-alone machine.\nMasquerading - A gateway machine used for Internet sharing.\nNone - Use if you already have your own firewall rules or want to run servers." "Firewalling options:\nStand-Alone - A stand-alone machine.\nMasquerading - A gateway machine used for Internet sharing.\nNone - Use if you already have your own firewall rules or want to run servers." 49 | ::msgcat::mcset en "From Server" "From Server" 50 | ::msgcat::mcset en "From Server" "From Server" 51 | ::msgcat::mcset en "From Server" "From Server" 52 | ::msgcat::mcset en "From Server" "From Server" 53 | ::msgcat::mcset en "Help file is not installed" "Help file is not installed" 54 | ::msgcat::mcset en "If enabled, ordinary users can start and stop this connection." "If enabled, ordinary users can start and stop this connection." 55 | ::msgcat::mcset en "Masquerading" "Masquerading" 56 | ::msgcat::mcset en "Masquerading" "Masquerading" 57 | ::msgcat::mcset en "Masquerading" "Masquerading" 58 | ::msgcat::mcset en "Network:" "Network:" 59 | ::msgcat::mcset en "New Connection..." "New Connection..." 60 | ::msgcat::mcset en "New Connection" "New Connection" 61 | ::msgcat::mcset en "New Connection" "New Connection" 62 | ::msgcat::mcset en "NIC and DNS" "NIC and DNS" 63 | ::msgcat::mcset en "None" "None" 64 | ::msgcat::mcset en "None" "None" 65 | ::msgcat::mcset en "Note" "Note" 66 | ::msgcat::mcset en "Note: There are no connections defined. You must run this program as root to define connections" "Note: There are no connections defined. You must run this program as root to define connections" 67 | ::msgcat::mcset en "OK" "OK" 68 | ::msgcat::mcset en "Options" "Options" 69 | ::msgcat::mcset en "Password:" "Password:" 70 | ::msgcat::mcset en "Primary DNS entry must consist of four dot-separated decimal numbers" "Primary DNS entry must consist of four dot-separated decimal numbers" 71 | ::msgcat::mcset en "Primary DNS:" "Primary DNS:" 72 | ::msgcat::mcset en "Properties..." "Properties..." 73 | ::msgcat::mcset en "Secondary DNS entry must consist of four dot-separated decimal numbers" "Secondary DNS entry must consist of four dot-separated decimal numbers" 74 | ::msgcat::mcset en "Secondary DNS:" "Secondary DNS:" 75 | ::msgcat::mcset en "Service-Name:" "Service-Name:" 76 | ::msgcat::mcset en "Some ISP's require you to enter their domain-name here (e.g. " "Some ISP's require you to enter their domain-name here (e.g. " 77 | ::msgcat::mcset en "Some ISP's require you to enter their domain-name here (e.g. " "Some ISP's require you to enter their domain-name here (e.g. " 78 | ::msgcat::mcset en "Specify" "Specify" 79 | ::msgcat::mcset en "Specify" "Specify" 80 | ::msgcat::mcset en "Specify" "Specify" 81 | ::msgcat::mcset en "Stand-Alone" "Stand-Alone" 82 | ::msgcat::mcset en "Stand-Alone" "Stand-Alone" 83 | ::msgcat::mcset en "Start" "Start" 84 | ::msgcat::mcset en "Stop" "Stop" 85 | ::msgcat::mcset en "succeeded" "succeeded" 86 | ::msgcat::mcset en "The connection already exists. Pick another name." "The connection already exists. Pick another name." 87 | ::msgcat::mcset en "User Name:" "User Name:" 88 | ::msgcat::mcset en "Use synchronous PPP (recommended -- easier on the CPU.)" "Use synchronous PPP (recommended -- easier on the CPU.)" 89 | ::msgcat::mcset en "Use synchronous PPP" "Use synchronous PPP" 90 | ::msgcat::mcset en "Welcome to RP-PPPoE" "Welcome to RP-PPPoE" 91 | -------------------------------------------------------------------------------- /src/ppp.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * ppp.c 4 | * 5 | * Implementation of user-space PPPoE redirector for Linux. 6 | * 7 | * Functions for talking to PPP daemon 8 | * 9 | * Copyright (C) 2000-2012 by Roaring Penguin Software Inc. 10 | * 11 | * This program may be distributed according to the terms of the GNU 12 | * General Public License, version 2 or (at your option) any later version. 13 | * 14 | * LIC: GPL 15 | * 16 | ***********************************************************************/ 17 | 18 | static char const RCSID[] = 19 | "$Id$"; 20 | 21 | #include "pppoe.h" 22 | 23 | #ifdef HAVE_SYSLOG_H 24 | #include 25 | #endif 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #ifdef HAVE_SYS_UIO_H 32 | #include 33 | #endif 34 | 35 | #ifdef HAVE_UNISTD_H 36 | #include 37 | #endif 38 | 39 | #ifdef HAVE_N_HDLC 40 | #ifndef N_HDLC 41 | #include 42 | #endif 43 | #endif 44 | 45 | static int PPPState; 46 | static int PPPPacketSize; 47 | static unsigned char PPPXorValue; 48 | 49 | static UINT16_t const fcstab[256] = { 50 | 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 51 | 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 52 | 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 53 | 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 54 | 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 55 | 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 56 | 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 57 | 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 58 | 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 59 | 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 60 | 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 61 | 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 62 | 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 63 | 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 64 | 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 65 | 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 66 | 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 67 | 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 68 | 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 69 | 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 70 | 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 71 | 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 72 | 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 73 | 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 74 | 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 75 | 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 76 | 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 77 | 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 78 | 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 79 | 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 80 | 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 81 | 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 82 | }; 83 | 84 | /********************************************************************** 85 | *%FUNCTION: syncReadFromPPP 86 | *%ARGUMENTS: 87 | * conn -- PPPoEConnection structure 88 | * packet -- buffer in which to place PPPoE packet 89 | *%RETURNS: 90 | * Nothing 91 | *%DESCRIPTION: 92 | * Reads from a synchronous PPP device and builds and transmits a PPPoE 93 | * packet 94 | ***********************************************************************/ 95 | void 96 | syncReadFromPPP(PPPoEConnection *conn, PPPoEPacket *packet) 97 | { 98 | int r; 99 | #ifndef HAVE_N_HDLC 100 | struct iovec vec[2]; 101 | unsigned char dummy[2]; 102 | vec[0].iov_base = (void *) dummy; 103 | vec[0].iov_len = 2; 104 | vec[1].iov_base = (void *) packet->payload; 105 | vec[1].iov_len = ETH_JUMBO_LEN - PPPOE_OVERHEAD; 106 | 107 | /* Use scatter-read to throw away the PPP frame address bytes */ 108 | r = readv(0, vec, 2); 109 | #else 110 | /* Bloody hell... readv doesn't work with N_HDLC line discipline... GRR! */ 111 | unsigned char buf[ETH_JUMBO_LEN - PPPOE_OVERHEAD + 2]; 112 | r = read(0, buf, ETH_JUMBO_LEN - PPPOE_OVERHEAD + 2); 113 | if (r >= 2) { 114 | memcpy(packet->payload, buf+2, r-2); 115 | } 116 | #endif 117 | if (r < 0) { 118 | /* Catch the Linux "select" bug */ 119 | if (errno == EAGAIN) { 120 | rp_fatal("Linux select bug hit! This message is harmless, but please ask the Linux kernel developers to fix it."); 121 | } 122 | fatalSys("read (syncReadFromPPP)"); 123 | } 124 | if (r == 0) { 125 | syslog(LOG_INFO, "end-of-file in syncReadFromPPP"); 126 | sendPADT(conn, "RP-PPPoE: EOF in syncReadFromPPP"); 127 | exit(0); 128 | } 129 | 130 | if (r < 2) { 131 | rp_fatal("too few characters read from PPP (syncReadFromPPP)"); 132 | } 133 | 134 | sendSessionPacket(conn, packet, r-2); 135 | } 136 | 137 | /********************************************************************** 138 | *%FUNCTION: initPPP 139 | *%ARGUMENTS: 140 | * None 141 | *%RETURNS: 142 | * Nothing 143 | *%DESCRIPTION: 144 | * Initializes the PPP state machine 145 | ***********************************************************************/ 146 | void 147 | initPPP(void) 148 | { 149 | PPPState = STATE_WAITFOR_FRAME_ADDR; 150 | PPPPacketSize = 0; 151 | PPPXorValue = 0; 152 | 153 | } 154 | /********************************************************************** 155 | *%FUNCTION: asyncReadFromPPP 156 | *%ARGUMENTS: 157 | * conn -- PPPoEConnection structure 158 | * packet -- buffer in which to place PPPoE packet 159 | *%RETURNS: 160 | * Nothing 161 | *%DESCRIPTION: 162 | * Reads from an async PPP device and builds a PPPoE packet to transmit 163 | ***********************************************************************/ 164 | void 165 | asyncReadFromPPP(PPPoEConnection *conn, PPPoEPacket *packet) 166 | { 167 | unsigned char buf[READ_CHUNK]; 168 | unsigned char *ptr = buf; 169 | unsigned char c; 170 | 171 | int r; 172 | 173 | r = read(0, buf, READ_CHUNK); 174 | if (r < 0) { 175 | fatalSys("read (asyncReadFromPPP)"); 176 | } 177 | 178 | if (r == 0) { 179 | syslog(LOG_INFO, "end-of-file in asyncReadFromPPP"); 180 | sendPADT(conn, "RP-PPPoE: EOF in asyncReadFromPPP"); 181 | exit(0); 182 | } 183 | 184 | while(r) { 185 | if (PPPState == STATE_WAITFOR_FRAME_ADDR) { 186 | while(r) { 187 | --r; 188 | if (*ptr++ == FRAME_ADDR) { 189 | PPPState = STATE_DROP_PROTO; 190 | break; 191 | } 192 | } 193 | } 194 | 195 | /* Still waiting... */ 196 | if (PPPState == STATE_WAITFOR_FRAME_ADDR) return; 197 | 198 | while(r && PPPState == STATE_DROP_PROTO) { 199 | --r; 200 | if (*ptr++ == (FRAME_CTRL ^ FRAME_ENC)) { 201 | PPPState = STATE_BUILDING_PACKET; 202 | } 203 | } 204 | 205 | if (PPPState == STATE_DROP_PROTO) return; 206 | 207 | /* Start building frame */ 208 | while(r && PPPState == STATE_BUILDING_PACKET) { 209 | --r; 210 | c = *ptr++; 211 | switch(c) { 212 | case FRAME_ESC: 213 | PPPXorValue = FRAME_ENC; 214 | break; 215 | case FRAME_FLAG: 216 | if (PPPPacketSize < 2) { 217 | rp_fatal("Packet too short from PPP (asyncReadFromPPP)"); 218 | } 219 | sendSessionPacket(conn, packet, PPPPacketSize-2); 220 | PPPPacketSize = 0; 221 | PPPXorValue = 0; 222 | PPPState = STATE_WAITFOR_FRAME_ADDR; 223 | break; 224 | default: 225 | if (PPPPacketSize >= ETH_JUMBO_LEN - 4) { 226 | syslog(LOG_ERR, "Packet too big! Check MTU on PPP interface"); 227 | PPPPacketSize = 0; 228 | PPPXorValue = 0; 229 | PPPState = STATE_WAITFOR_FRAME_ADDR; 230 | } else { 231 | packet->payload[PPPPacketSize++] = c ^ PPPXorValue; 232 | PPPXorValue = 0; 233 | } 234 | } 235 | } 236 | } 237 | } 238 | 239 | /********************************************************************** 240 | *%FUNCTION: pppFCS16 241 | *%ARGUMENTS: 242 | * fcs -- current fcs 243 | * cp -- a buffer's worth of data 244 | * len -- length of buffer "cp" 245 | *%RETURNS: 246 | * A new FCS 247 | *%DESCRIPTION: 248 | * Updates the PPP FCS. 249 | ***********************************************************************/ 250 | UINT16_t 251 | pppFCS16(UINT16_t fcs, 252 | unsigned char * cp, 253 | int len) 254 | { 255 | while (len--) 256 | fcs = (fcs >> 8) ^ fcstab[(fcs ^ *cp++) & 0xff]; 257 | 258 | return (fcs); 259 | } 260 | -------------------------------------------------------------------------------- /src/md5.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code implements the MD5 message-digest algorithm. 3 | * The algorithm is due to Ron Rivest. This code was 4 | * written by Colin Plumb in 1993, no copyright is claimed. 5 | * This code is in the public domain; do with it what you wish. 6 | * 7 | * Equivalent code is available from RSA Data Security, Inc. 8 | * This code has been tested against that, and is equivalent, 9 | * except that you don't need to include two pages of legalese 10 | * with every copy. 11 | * 12 | * LIC: GPL 13 | * 14 | * To compute the message digest of a chunk of bytes, declare an 15 | * MD5Context structure, pass it to MD5Init, call MD5Update as 16 | * needed on buffers full of bytes, and then call MD5Final, which 17 | * will fill a supplied 16-byte array with the digest. 18 | */ 19 | #include /* for memcpy() */ 20 | #include "md5.h" 21 | 22 | static void byteReverse(unsigned char *buf, unsigned longs); 23 | 24 | /* 25 | * Note: this code is harmless on little-endian machines. 26 | */ 27 | static void 28 | byteReverse(unsigned char *buf, unsigned longs) 29 | { 30 | uint32 t; 31 | do { 32 | t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | 33 | ((unsigned) buf[1] << 8 | buf[0]); 34 | *(uint32 *) buf = t; 35 | buf += 4; 36 | } while (--longs); 37 | } 38 | 39 | /* 40 | * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious 41 | * initialization constants. 42 | */ 43 | void MD5Init(struct MD5Context *ctx) 44 | { 45 | ctx->buf[0] = 0x67452301; 46 | ctx->buf[1] = 0xefcdab89; 47 | ctx->buf[2] = 0x98badcfe; 48 | ctx->buf[3] = 0x10325476; 49 | 50 | ctx->bits[0] = 0; 51 | ctx->bits[1] = 0; 52 | } 53 | 54 | /* 55 | * Update context to reflect the concatenation of another buffer full 56 | * of bytes. 57 | */ 58 | void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) 59 | { 60 | uint32 t; 61 | 62 | /* Update bitcount */ 63 | 64 | t = ctx->bits[0]; 65 | if ((ctx->bits[0] = t + ((uint32) len << 3)) < t) 66 | ctx->bits[1]++; /* Carry from low to high */ 67 | ctx->bits[1] += len >> 29; 68 | 69 | t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ 70 | 71 | /* Handle any leading odd-sized chunks */ 72 | 73 | if (t) { 74 | unsigned char *p = (unsigned char *) ctx->in + t; 75 | 76 | t = 64 - t; 77 | if (len < t) { 78 | memcpy(p, buf, len); 79 | return; 80 | } 81 | memcpy(p, buf, t); 82 | byteReverse(ctx->in, 16); 83 | MD5Transform(ctx->buf, (uint32 *) ctx->in); 84 | buf += t; 85 | len -= t; 86 | } 87 | /* Process data in 64-byte chunks */ 88 | 89 | while (len >= 64) { 90 | memcpy(ctx->in, buf, 64); 91 | byteReverse(ctx->in, 16); 92 | MD5Transform(ctx->buf, (uint32 *) ctx->in); 93 | buf += 64; 94 | len -= 64; 95 | } 96 | 97 | /* Handle any remaining bytes of data. */ 98 | 99 | memcpy(ctx->in, buf, len); 100 | } 101 | 102 | /* 103 | * Final wrapup - pad to 64-byte boundary with the bit pattern 104 | * 1 0* (64-bit count of bits processed, MSB-first) 105 | */ 106 | void MD5Final(unsigned char digest[16], struct MD5Context *ctx) 107 | { 108 | unsigned count; 109 | unsigned char *p; 110 | 111 | /* Compute number of bytes mod 64 */ 112 | count = (ctx->bits[0] >> 3) & 0x3F; 113 | 114 | /* Set the first char of padding to 0x80. This is safe since there is 115 | always at least one byte free */ 116 | p = ctx->in + count; 117 | *p++ = 0x80; 118 | 119 | /* Bytes of padding needed to make 64 bytes */ 120 | count = 64 - 1 - count; 121 | 122 | /* Pad out to 56 mod 64 */ 123 | if (count < 8) { 124 | /* Two lots of padding: Pad the first block to 64 bytes */ 125 | memset(p, 0, count); 126 | byteReverse(ctx->in, 16); 127 | MD5Transform(ctx->buf, (uint32 *) ctx->in); 128 | 129 | /* Now fill the next block with 56 bytes */ 130 | memset(ctx->in, 0, 56); 131 | } else { 132 | /* Pad block to 56 bytes */ 133 | memset(p, 0, count - 8); 134 | } 135 | byteReverse(ctx->in, 14); 136 | 137 | /* Append length in bits and transform */ 138 | ((uint32 *) ctx->in)[14] = ctx->bits[0]; 139 | ((uint32 *) ctx->in)[15] = ctx->bits[1]; 140 | 141 | MD5Transform(ctx->buf, (uint32 *) ctx->in); 142 | byteReverse((unsigned char *) ctx->buf, 4); 143 | memcpy(digest, ctx->buf, 16); 144 | memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ 145 | } 146 | 147 | #ifndef ASM_MD5 148 | 149 | /* The four core functions - F1 is optimized somewhat */ 150 | 151 | /* #define F1(x, y, z) (x & y | ~x & z) */ 152 | #define F1(x, y, z) (z ^ (x & (y ^ z))) 153 | #define F2(x, y, z) F1(z, x, y) 154 | #define F3(x, y, z) (x ^ y ^ z) 155 | #define F4(x, y, z) (y ^ (x | ~z)) 156 | 157 | /* This is the central step in the MD5 algorithm. */ 158 | #define MD5STEP(f, w, x, y, z, data, s) \ 159 | ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) 160 | 161 | /* 162 | * The core of the MD5 algorithm, this alters an existing MD5 hash to 163 | * reflect the addition of 16 longwords of new data. MD5Update blocks 164 | * the data and converts bytes into longwords for this routine. 165 | */ 166 | void MD5Transform(uint32 buf[4], uint32 const in[16]) 167 | { 168 | register uint32 a, b, c, d; 169 | 170 | a = buf[0]; 171 | b = buf[1]; 172 | c = buf[2]; 173 | d = buf[3]; 174 | 175 | MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); 176 | MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); 177 | MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); 178 | MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); 179 | MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); 180 | MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); 181 | MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); 182 | MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); 183 | MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); 184 | MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); 185 | MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); 186 | MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); 187 | MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); 188 | MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); 189 | MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); 190 | MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); 191 | 192 | MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); 193 | MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); 194 | MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); 195 | MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); 196 | MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); 197 | MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); 198 | MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); 199 | MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); 200 | MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); 201 | MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); 202 | MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); 203 | MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); 204 | MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); 205 | MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); 206 | MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); 207 | MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); 208 | 209 | MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); 210 | MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); 211 | MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); 212 | MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); 213 | MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); 214 | MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); 215 | MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); 216 | MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); 217 | MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); 218 | MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); 219 | MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); 220 | MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); 221 | MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); 222 | MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); 223 | MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); 224 | MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); 225 | 226 | MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); 227 | MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); 228 | MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); 229 | MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); 230 | MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); 231 | MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); 232 | MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); 233 | MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); 234 | MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); 235 | MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); 236 | MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); 237 | MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); 238 | MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); 239 | MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); 240 | MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); 241 | MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); 242 | 243 | buf[0] += a; 244 | buf[1] += b; 245 | buf[2] += c; 246 | buf[3] += d; 247 | } 248 | 249 | #endif 250 | -------------------------------------------------------------------------------- /src/libevent/event_sig.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * event_sig.c 4 | * 5 | * Code for handling signals nicely (synchronously) and for dealing 6 | * with reaping child processes. 7 | * 8 | * Copyright (C) 2002 by Roaring Penguin Software Inc. 9 | * 10 | * This software may be distributed under the terms of the GNU General 11 | * Public License, Version 2, or (at your option) any later version. 12 | * 13 | * LIC: GPL 14 | * 15 | ***********************************************************************/ 16 | 17 | static char const RCSID[] = 18 | "$Id$"; 19 | 20 | #define _POSIX_SOURCE 1 /* For sigaction defines */ 21 | #define _BSD_SOURCE 1 /* For SA_RESTART */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "event.h" 31 | #include "hash.h" 32 | 33 | /* Kludge for figuring out NSIG */ 34 | #ifdef NSIG 35 | #define MAX_SIGNALS NSIG 36 | #elif defined(_NSIG) 37 | #define MAX_SIGNALS _NSIG 38 | #else 39 | #define MAX_SIGNALS 256 /* Should be safe... */ 40 | #endif 41 | 42 | /* A structure for a "synchronous" signal handler */ 43 | struct SynchronousSignalHandler { 44 | int fired; /* Have we received this signal? */ 45 | void (*handler)(int sig); /* Handler function */ 46 | }; 47 | 48 | /* A structure for calling back when a child dies */ 49 | struct ChildEntry { 50 | hash_bucket hash; 51 | void (*handler)(pid_t pid, int status, void *data); 52 | pid_t pid; 53 | void *data; 54 | }; 55 | 56 | static struct SynchronousSignalHandler SignalHandlers[MAX_SIGNALS]; 57 | static int Pipe[2] = {-1, -1}; 58 | static pid_t MyPid = (pid_t) -1; 59 | 60 | static EventHandler *PipeHandler = NULL; 61 | static hash_table child_process_table; 62 | 63 | static unsigned int child_hash(void *data) 64 | { 65 | return (unsigned int) ((struct ChildEntry *) data)->pid; 66 | } 67 | 68 | static int child_compare(void *d1, void *d2) 69 | { 70 | return ((struct ChildEntry *)d1)->pid != ((struct ChildEntry *)d2)->pid; 71 | } 72 | 73 | /********************************************************************** 74 | * %FUNCTION: DoPipe 75 | * %ARGUMENTS: 76 | * es -- event selector 77 | * fd -- readable file descriptor 78 | * flags -- flags from event system 79 | * data -- ignored 80 | * %RETURNS: 81 | * Nothing 82 | * %DESCRIPTION: 83 | * Called when an async signal handler wants attention. This function 84 | * fires all "synchronous" signal handlers. 85 | ***********************************************************************/ 86 | static void 87 | DoPipe(EventSelector *es, 88 | int fd, 89 | unsigned int flags, 90 | void *data) 91 | { 92 | char buf[64]; 93 | int i; 94 | sigset_t set; 95 | 96 | /* Clear pipe */ 97 | while (read(fd, buf, 64) == 64) { 98 | ; 99 | } 100 | 101 | /* Fire handlers */ 102 | for (i=0; i MAX_SIGNALS) { 134 | /* Ooops... */ 135 | return; 136 | } 137 | if (getpid() != MyPid) { 138 | /* Spuriously-caught signal caught in child! */ 139 | return; 140 | } 141 | 142 | /* If there's no handler, ignore it */ 143 | if (!SignalHandlers[sig].handler) { 144 | return; 145 | } 146 | 147 | SignalHandlers[sig].fired = 1; 148 | int errno_save = errno; 149 | write(Pipe[1], &sig, 1); 150 | errno = errno_save; 151 | } 152 | 153 | /********************************************************************** 154 | * %FUNCTION: child_handler 155 | * %ARGUMENTS: 156 | * sig -- signal number (whoop-dee-doo) 157 | * %RETURNS: 158 | * Nothing 159 | * %DESCRIPTION: 160 | * Called *SYNCHRONOUSLY* to reap dead children. SIGCHLD is blocked 161 | * during the execution of this function. 162 | ***********************************************************************/ 163 | static void 164 | child_handler(int sig) 165 | { 166 | int status; 167 | int pid; 168 | struct ChildEntry *ce; 169 | struct ChildEntry candidate; 170 | 171 | while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { 172 | candidate.pid = (pid_t) pid; 173 | 174 | ce = hash_find(&child_process_table, &candidate); 175 | if (ce) { 176 | hash_remove(&child_process_table, ce); 177 | if (ce->handler) { 178 | ce->handler(pid, status, ce->data); 179 | } 180 | free(ce); 181 | } 182 | } 183 | } 184 | 185 | /********************************************************************** 186 | * %FUNCTION: SetupPipes (static) 187 | * %ARGUMENTS: 188 | * es -- event selector 189 | * %RETURNS: 190 | * 0 on success; -1 on failure 191 | * %DESCRIPTION: 192 | * Sets up pipes with an event handler to handle IPC from a signal handler 193 | ***********************************************************************/ 194 | static int 195 | SetupPipes(EventSelector *es) 196 | { 197 | int flags; 198 | int i; 199 | 200 | /* If already done, do nothing */ 201 | if (PipeHandler) return 0; 202 | 203 | MyPid = getpid(); 204 | 205 | /* Initialize the child-process hash table */ 206 | hash_init(&child_process_table, 207 | offsetof(struct ChildEntry, hash), 208 | child_hash, 209 | child_compare); 210 | 211 | /* Open pipe to self */ 212 | if (pipe(Pipe) < 0) { 213 | return -1; 214 | } 215 | 216 | /* Make pipes non-blocking */ 217 | for (i=0; i<=1; i++) { 218 | flags = fcntl(Pipe[i], F_GETFL, 0); 219 | if (flags != -1) { 220 | flags = fcntl(Pipe[i], F_SETFL, flags | O_NONBLOCK); 221 | } 222 | if (flags == -1) { 223 | close(Pipe[0]); 224 | close(Pipe[1]); 225 | return -1; 226 | } 227 | } 228 | 229 | PipeHandler = Event_AddHandler(es, Pipe[0], 230 | EVENT_FLAG_READABLE, DoPipe, NULL); 231 | if (!PipeHandler) { 232 | int old_errno = errno; 233 | close(Pipe[0]); 234 | close(Pipe[1]); 235 | errno = old_errno; 236 | return -1; 237 | } 238 | return 0; 239 | } 240 | 241 | /********************************************************************** 242 | * %FUNCTION: Event_HandleSignal 243 | * %ARGUMENTS: 244 | * es -- event selector 245 | * sig -- signal number 246 | * handler -- handler to call when signal is raised. Handler is called 247 | * "synchronously" as events are processed by event loop. 248 | * %RETURNS: 249 | * 0 on success, -1 on error. 250 | * %DESCRIPTION: 251 | * Sets up a "synchronous" signal handler. 252 | ***********************************************************************/ 253 | int 254 | Event_HandleSignal(EventSelector *es, 255 | int sig, 256 | void (*handler)(int sig)) 257 | { 258 | struct sigaction act; 259 | 260 | if (SetupPipes(es) < 0) return -1; 261 | 262 | act.sa_handler = sig_handler; 263 | sigemptyset(&act.sa_mask); 264 | act.sa_flags = 0; 265 | #ifdef SA_RESTART 266 | act.sa_flags |= SA_RESTART; 267 | #endif 268 | if (sig == SIGCHLD) { 269 | act.sa_flags |= SA_NOCLDSTOP; 270 | } 271 | if (sigaction(sig, &act, NULL) < 0) return -1; 272 | 273 | SignalHandlers[sig].handler = handler; 274 | 275 | return 0; 276 | } 277 | 278 | /********************************************************************** 279 | * %FUNCTION: Event_HandleChildExit 280 | * %ARGUMENTS: 281 | * es -- event selector 282 | * pid -- process-ID of child to wait for 283 | * handler -- function to call when child exits 284 | * data -- data to pass to handler when child exits 285 | * %RETURNS: 286 | * 0 on success, -1 on failure. 287 | * %DESCRIPTION: 288 | * Sets things up so that when a child exits, handler() will be called 289 | * with the pid of the child and "data" as arguments. The call will 290 | * be synchronous (part of the normal event loop on es). 291 | ***********************************************************************/ 292 | int 293 | Event_HandleChildExit(EventSelector *es, 294 | pid_t pid, 295 | void (*handler)(pid_t, int, void *), 296 | void *data) 297 | { 298 | struct ChildEntry *ce; 299 | sigset_t set; 300 | 301 | if (Event_HandleSignal(es, SIGCHLD, child_handler) < 0) return -1; 302 | ce = malloc(sizeof(struct ChildEntry)); 303 | if (!ce) return -1; 304 | ce->pid = pid; 305 | ce->data = data; 306 | ce->handler = handler; 307 | 308 | /* Critical section: Don't let SIGCHLD mess hash_insert */ 309 | sigemptyset(&set); 310 | sigaddset(&set, SIGCHLD); 311 | sigprocmask(SIG_BLOCK, &set, NULL); 312 | 313 | hash_insert(&child_process_table, ce); 314 | 315 | sigprocmask(SIG_UNBLOCK, &set, NULL); 316 | 317 | return 0; 318 | } 319 | -------------------------------------------------------------------------------- /man/pppoe.8: -------------------------------------------------------------------------------- 1 | .\" LIC: GPL 2 | .TH PPPOE 8 "3 July 2000" 3 | .UC 4 4 | .SH NAME 5 | pppoe \- user-space PPPoE client. 6 | .SH SYNOPSIS 7 | .B pppd pty 'pppoe \fR[\fIpppoe_options\fR]\fB' \fR[\fIpppd_options\fR] 8 | .P 9 | .B pppoe -A \fR[\fIpppoe_options\fR] 10 | .SH DESCRIPTION 11 | \fBpppoe\fR is a user-space client for PPPoE (Point-to-Point Protocol 12 | over Ethernet) for Linux and other UNIX systems. \fBpppoe\fR works in 13 | concert with the \fBpppd\fR PPP daemon to provide a PPP connection 14 | over Ethernet, as is used by many DSL service providers. 15 | 16 | .SH OPTIONS 17 | .TP 18 | .B \-I \fIinterface\fR 19 | The \fB\-I\fR option specifies the Ethernet interface to use. Under Linux, 20 | it is typically \fIeth0\fR or \fIeth1\fR. The interface should be "up" 21 | before you start \fBpppoe\fR, but should \fInot\fR be configured to have 22 | an IP address. 23 | 24 | .TP 25 | .B \-T \fItimeout\fR 26 | The \fB\-T\fR option causes \fBpppoe\fR to exit if no session traffic 27 | is detected for \fItimeout\fR seconds. I recommend that you use this 28 | option as an extra safety measure, but if you do, you should make sure 29 | that PPP generates enough traffic so the timeout will normally not be 30 | triggered. The best way to do this is to use the 31 | \fIlcp-echo-interval\fR option to \fBpppd\fR. You should set the 32 | PPPoE timeout to be about four times the LCP echo interval. 33 | 34 | .TP 35 | .B \-D \fIfile_name\fR 36 | The \fB\-D\fR option causes every packet to be dumped to the specified 37 | \fIfile_name\fR. This is intended for debugging only; it produces huge 38 | amounts of output and greatly reduces performance. 39 | 40 | .TP 41 | .B \-V 42 | The \fB\-V\fR option causes \fBpppoe\fR to print its version number and 43 | exit. 44 | 45 | .TP 46 | .B \-A 47 | The \fB\-A\fR option causes \fBpppoe\fR to send a PADI packet and then print 48 | the names of access concentrators in each PADO packet it receives. Do not 49 | use this option in conjunction with \fBpppd\fR; the \fB\-A\fR option is 50 | meant to be used interactively to give interesting information about the 51 | access concentrator. 52 | 53 | .TP 54 | .B \-S \fIservice_name\fR 55 | Specifies the desired service name. \fBpppoe\fR will only initiate sessions 56 | with access concentrators which can provide the specified service. In 57 | most cases, you should \fInot\fR specify this option. Use it only if you 58 | know that there are multiple access concentrators or know that you need a 59 | specific service name. 60 | 61 | .TP 62 | .B \-C \fIac_name\fR 63 | Specifies the desired access concentrator name. \fBpppoe\fR will only 64 | initiate sessions with the specified access concentrator. In 65 | most cases, you should \fInot\fR specify this option. Use it only if you 66 | know that there are multiple access concentrators. If both the 67 | \fB\-S\fR and \fB\-C\fR options are specified, they must \fIboth\fR match 68 | for \fBpppoe\fR to initiate a session. 69 | 70 | .TP 71 | .B \-U 72 | Causes \fBpppoe\fR to use the Host-Uniq tag in its discovery packets. This 73 | lets you run multiple \fBpppoe\fR daemons without having their discovery 74 | packets interfere with one another. You must supply this option to 75 | \fIall\fR \fBpppoe\fR daemons if you intend to run multiple daemons 76 | simultaneously. 77 | 78 | .TP 79 | .B \-s 80 | Causes \fBpppoe\fR to use \fIsynchronous\fR PPP encapsulation. If you 81 | use this option, then you \fImust\fR use the \fBsync\fR option with 82 | \fBpppd\fR. You are encouraged to use this option if it works, because 83 | it greatly reduces the CPU overhead of \fBpppoe\fR. However, it 84 | MAY be unreliable on slow machines -- there is a race condition between 85 | pppd writing data and pppoe reading it. For this reason, the default 86 | setting is asynchronous. If you encounter bugs or crashes with Synchronous 87 | PPP, turn it off -- don't e-mail me for support! 88 | 89 | .TP 90 | .B \-m \fIMSS\fR 91 | Causes \fBpppoe\fR to \fIclamp\fR the TCP maximum segment size at the specified 92 | value. Because of PPPoE overhead, the maximum segment size for PPPoE is 93 | smaller than for normal Ethernet encapsulation. This could cause problems 94 | for machines on a LAN behind a gateway using PPPoE. If you have a LAN 95 | behind a gateway, and the gateway connects to the Internet using PPPoE, 96 | you are strongly recommended to use a \fB\-m 1412\fR option. This avoids 97 | having to set the MTU on all the hosts on the LAN. 98 | 99 | .TP 100 | .B \-p \fIfile\fR 101 | Causes \fBpppoe\fR to write its process-ID to the specified file. This 102 | can be used to locate and kill \fBpppoe\fR processes. 103 | 104 | .TP 105 | .B \-e \fIsess:mac\fR 106 | Causes \fBpppoe\fR to skip the discovery phase and move directly to the 107 | session phase. The session is given by \fIsess\fR and the MAC address of 108 | the peer by \fImac\fR. This mode is \fInot\fR meant for normal use; it 109 | is designed only for \fBpppoe-server\fR(8). 110 | 111 | .TP 112 | .B \-n 113 | Causes \fBpppoe\fR not to open a discovery socket. This mode is 114 | \fInot\fR meant for normal use; it is designed only for 115 | \fBpppoe-server\fR(8). 116 | 117 | .TP 118 | .B \-k 119 | Causes \fBpppoe\fR to terminate an existing session by sending a PADT frame, 120 | and then exit. You must use the \fB\-e\fR option in conjunction with this 121 | option to specify the session to kill. This may be useful for killing 122 | sessions when a buggy peer does not realize the session has ended. 123 | 124 | .TP 125 | .B \-d 126 | Causes \fBpppoe\fR to perform discovery and then exit, after printing 127 | session information to standard output. The session information is printed 128 | in exactly the format expected by the \fB\-e\fR option. This option lets 129 | you initiate a PPPoE discovery, perform some other work, and then start 130 | the actual PPP session. \fIBe careful\fR; if you use this option in a loop, 131 | you can create many sessions, which may annoy your peer. 132 | 133 | .TP 134 | .B \-f disc:sess 135 | The \fB\-f\fR option sets the Ethernet frame types for PPPoE discovery 136 | and session frames. The types are specified as hexadecimal numbers 137 | separated by a colon. Standard PPPoE uses frame types 8863:8864. 138 | \fIYou should not use this option\fR unless you are absolutely sure 139 | the peer you are dealing with uses non-standard frame types. If your 140 | ISP uses non-standard frame types, complain! 141 | 142 | .TP 143 | .B \-h 144 | The \fB\-h\fR option causes \fBpppoe\fR to print usage information and 145 | exit. 146 | 147 | .SH PPPOE BACKGROUND 148 | 149 | PPPoE (Point-to-Point Protocol over Ethernet) is described in RFC 2516 150 | and is a protocol which allows the session abstraction to be maintained 151 | over bridged Ethernet networks. 152 | 153 | PPPoE works by encapsulating PPP frames in Ethernet frames. The protocol 154 | has two distinct stages: The \fIdiscovery\fR and the \fIsession\fR stage. 155 | 156 | In the discovery stage, the host broadcasts a special PADI (PPPoE 157 | Active Discovery Initiation) frame to discover any \fIaccess 158 | concentrators\fR. The access concentrators (typically, only one 159 | access concentrator) reply with PADO (PPPoE Active Discovery Offer) 160 | packets, announcing their presence and the services they offer. The 161 | host picks one of the access concentrators and transmits a PADR (PPPoE 162 | Active Discovery Request) packet, asking for a session. The access 163 | concentrator replies with a PADS (PPPoE Active Discovery 164 | Session-Confirmation) packet. The protocol then moves to the session stage. 165 | 166 | In the session stage, the host and access concentrator exchange PPP frames 167 | embedded in Ethernet frames. The normal Ethernet MTU is 1500 bytes, but 168 | the PPPoE overhead plus two bytes of overhead for the encapsulated PPP 169 | frame mean that the MTU of the PPP interface is at most 1492 bytes. 170 | This causes \fIall kinds of problems\fR if you are using a Linux machine 171 | as a firewall and interfaces behind the firewall have an MTU greater than 172 | 1492. In fact, to be safe, I recommend setting the MTU of machines 173 | behind the firewall to 1412, to allow for worst-case TCP and IP options 174 | in their respective headers. 175 | 176 | Normally, PPP uses the Link Control Protocol (LCP) to shut down a PPP 177 | link. However, the PPPoE specification allows the link to be shut down 178 | with a special PADT (PPPoE Active Discovery Terminate) packet. This client 179 | recognizes this packet and will correctly terminate if a terminate request 180 | is received for the PPP session. 181 | 182 | .SH DESIGN GOALS 183 | 184 | My design goals for this PPPoE client were as follows, in descending order 185 | of importance: 186 | 187 | .TP 188 | .B o 189 | It must work. 190 | 191 | .TP 192 | .B o 193 | It must be a user-space program and not a kernel patch. 194 | 195 | .TP 196 | .B o 197 | The code must be easy to read and maintain. 198 | 199 | .TP 200 | .B o 201 | It must be fully compliant with RFC 2516, the proposed PPPoE standard. 202 | 203 | .TP 204 | .B o 205 | It must never hang up forever -- if the connection is broken, it must 206 | detect this and exit, allowing a wrapper script to restart the connection. 207 | 208 | .TP 209 | .B o 210 | It must be fairly efficient. 211 | 212 | .P 213 | I believe I have achieved all of these goals, but (of course) am open 214 | to suggestions, patches and ideas. See my home page, 215 | http://www.roaringpenguin.com, for contact information. 216 | 217 | .SH NOTES 218 | 219 | For best results, you must give \fBpppd\fR an mtu option of 220 | 1492. I have observed problems with excessively-large frames 221 | unless I set this option. Also, if \fBpppoe\fR is running on a firewall 222 | machine, all machines behind the firewall should have MTU's of 1412. 223 | 224 | If you have problems, check your system logs. \fBpppoe\fR logs interesting 225 | things to syslog. You may have to turn on logging of \fIdebug\fR-level 226 | messages for complete diagnosis. 227 | 228 | .SH AUTHORS 229 | \fBpppoe\fR was written by David F. Skoll , 230 | with much inspiration from an earlier version by Luke Stras. 231 | 232 | The \fBpppoe\fR home page is \fIhttp://www.roaringpenguin.com/pppoe/\fR. 233 | 234 | .SH SEE ALSO 235 | pppoe-start(8), pppoe-stop(8), pppoe-connect(8), pppd(8), pppoe.conf(5), pppoe-setup(8), pppoe-status(8), pppoe-sniff(8), pppoe-server(8), pppoe-relay(8) 236 | 237 | -------------------------------------------------------------------------------- /scripts/pppoe-connect.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # @configure_input@ 3 | #*********************************************************************** 4 | # 5 | # pppoe-connect 6 | # 7 | # Shell script to connect to a PPPoE provider 8 | # 9 | # Copyright (C) 2000 Roaring Penguin Software Inc. 10 | # 11 | # $Id$ 12 | # 13 | # This file may be distributed under the terms of the GNU General 14 | # Public License. 15 | # 16 | # LIC: GPL 17 | # 18 | # Usage: pppoe-connect [config_file] 19 | # pppoe-connect interface user [config_file] 20 | # Second form overrides USER and ETH from config file. 21 | # If config_file is omitted, defaults to /etc//ppp/pppoe.conf 22 | # 23 | #*********************************************************************** 24 | 25 | # From AUTOCONF 26 | prefix=@prefix@ 27 | exec_prefix=@exec_prefix@ 28 | localstatedir=/var 29 | 30 | # Paths to programs 31 | IFCONFIG=/sbin/ifconfig 32 | PPPD=@PPPD@ 33 | SETSID=@SETSID@ 34 | PPPOE=@sbindir@/pppoe 35 | LOGGER="/usr/bin/logger -t `basename $0`" 36 | 37 | # Set to "C" locale so we can parse messages from commands 38 | LANG=C 39 | export LANG 40 | 41 | # Must be root 42 | if test "`@ID@ -u`" != 0 ; then 43 | echo "$0: You must be root to run this script" >& 2 44 | exit 1 45 | fi 46 | 47 | if test "$SETSID" != "" -a ! -x "$SETSID"; then 48 | SETSID="" 49 | fi 50 | 51 | CONFIG=/etc//ppp/pppoe.conf 52 | USER="" 53 | ETH="" 54 | 55 | # Sort out command-line arguments 56 | case "$#" in 57 | 1) 58 | CONFIG="$1" 59 | ;; 60 | 3) 61 | CONFIG="$3" 62 | ;; 63 | esac 64 | 65 | if test ! -f "$CONFIG" -o ! -r "$CONFIG" ; then 66 | echo "$0: Cannot read configuration file '$CONFIG'" >& 2 67 | exit 1 68 | fi 69 | export CONFIG 70 | . $CONFIG 71 | 72 | PPPOE_PIDFILE="$PIDFILE.pppoe" 73 | PPPD_PIDFILE="$PIDFILE.pppd" 74 | 75 | # Check for command-line overriding of ETH and USER 76 | case "$#" in 77 | 2|3) 78 | ETH="$1" 79 | USER="$2" 80 | ;; 81 | esac 82 | 83 | # Check that config file is sane 84 | if test "$USER" = "" ; then 85 | echo "$0: Check '$CONFIG' -- no setting for USER" >& 2 86 | exit 1 87 | fi 88 | if test "$ETH" = "" ; then 89 | echo "$0: Check '$CONFIG' -- no setting for ETH" >& 2 90 | exit 1 91 | fi 92 | 93 | PPPD_PID=0 94 | 95 | # Catch common error 96 | if test "$DEBUG" = "1" ; then 97 | echo "*** If you want to use DEBUG, invoke pppoe-start, not pppoe-connect." 98 | exit 1 99 | fi 100 | 101 | if test "$DEBUG" != "" ; then 102 | if test "$LINUX_PLUGIN" != "" ; then 103 | echo "Cannot use DEBUG mode and LINUX_PLUGIN at the same time." 104 | echo "Kernel-mode PPPoE is experimental and unsupported." 105 | exit 1 106 | fi 107 | echo "* The following section identifies your Ethernet interface" >> $DEBUG 108 | echo "* and user name. Some ISP's need 'username'; others" >> $DEBUG 109 | echo "* need 'username@isp.com'. Try both" >> $DEBUG 110 | echo "ETH=$ETH; USER=$USER" >> $DEBUG 111 | echo "---------------------------------------------" >> $DEBUG 112 | fi 113 | 114 | # MTU of Ethernet card attached to modem MUST be 1500. This apparently 115 | # fails on some *BSD's, so we'll only do it under Linux 116 | 117 | if test `uname -s` = Linux ; then 118 | $IFCONFIG $ETH up 119 | EXISTING_MTU=`$IFCONFIG $ETH 2> /dev/null | grep MTU: | sed -e 's/.*MTU://' | sed -e 's/[^0-9].*//'` 120 | if test "$EXISTING_MTU" = "" -o "$EXISTING_MTU" -lt 1500 ; then 121 | $IFCONFIG $ETH mtu 1500 122 | fi 123 | 124 | # For 2.4 kernels. Will fail on 2.2.x, but who cares? 125 | modprobe ppp_generic > /dev/null 2>&1 126 | modprobe ppp_async > /dev/null 2>&1 127 | modprobe ppp_synctty > /dev/null 2>&1 128 | if test -n "$LINUX_PLUGIN" ; then 129 | modprobe pppox > /dev/null 2>&1 130 | modprobe pppoe > /dev/null 2>&1 131 | fi 132 | fi 133 | 134 | if test "$SYNCHRONOUS" = "yes" ; then 135 | PPPOE_SYNC=-s 136 | PPPD_SYNC=sync 137 | # Increase the chances of it working on Linux... 138 | if test `uname -s` = Linux ; then 139 | modprobe n_hdlc > /dev/null 2>&1 140 | fi 141 | else 142 | PPPOE_SYNC="" 143 | PPPD_SYNC="" 144 | fi 145 | 146 | if test -n "$ACNAME" ; then 147 | ACNAME="-C $ACNAME" 148 | fi 149 | 150 | if test -n "$SERVICENAME" ; then 151 | SERVICENAMEOPT="-S $SERVICENAME" 152 | else 153 | SERVICENAMEOPT="" 154 | fi 155 | 156 | if test "$CLAMPMSS" = "no" ; then 157 | CLAMPMSS="" 158 | else 159 | CLAMPMSS="-m $CLAMPMSS" 160 | fi 161 | 162 | # If DNSTYPE is SERVER, we must use "usepeerdns" option to pppd. 163 | if test "$DNSTYPE" = "SERVER" ; then 164 | PEERDNS=yes 165 | USEPEERDNS=yes 166 | fi 167 | 168 | if test "$PEERDNS" = "yes" ; then 169 | PEERDNS="usepeerdns" 170 | else 171 | PEERDNS="" 172 | fi 173 | 174 | # Backward config file compatibility -- PEERDNS used to be USEPEERDNS 175 | if test "$USEPEERDNS" = "yes" ; then 176 | PEERDNS="usepeerdns" 177 | fi 178 | if test "$USEPEERDNS" = "no" ; then 179 | PEERDNS="" 180 | fi 181 | 182 | 183 | # Backward config file compatibility 184 | if test "$DEMAND" = "" ; then 185 | DEMAND=no 186 | fi 187 | 188 | if test "$DEMAND" = "no" ; then 189 | DEMAND="" 190 | else 191 | DEMAND="demand persist idle $DEMAND 10.112.112.112:10.112.112.113 ipcp-accept-remote ipcp-accept-local connect true noipdefault ktune" 192 | fi 193 | 194 | case "$FIREWALL" in 195 | STANDALONE) 196 | . /etc/ppp/firewall-standalone 197 | ;; 198 | MASQUERADE) 199 | . /etc/ppp/firewall-masq 200 | ;; 201 | esac 202 | 203 | # If we're using kernel-mode PPPoE on Linux... 204 | if test "$LINUX_PLUGIN" != "" ; then 205 | PLUGIN_OPTS="plugin $LINUX_PLUGIN nic-$ETH" 206 | if test -n "$SERVICENAME" ; then 207 | PLUGIN_OPTS="$PLUGIN_OPTS rp_pppoe_service $SERVICENAME" 208 | fi 209 | modprobe pppoe > /dev/null 2>&1 210 | fi 211 | 212 | if test "$DEFAULTROUTE" != "no" ; then 213 | DEFAULTROUTE="defaultroute" 214 | else 215 | DEFAULTROUTE="" 216 | fi 217 | 218 | if test -n "$UNIT" ; then 219 | DOUNIT="unit $UNIT" 220 | else 221 | DOUNIT="" 222 | fi 223 | 224 | if test "$MTU" = "" ; then 225 | MTU=1492 226 | fi 227 | if test "$MRU" = "" ; then 228 | MRU=1492 229 | fi 230 | 231 | # Standard PPP options we always use 232 | PPP_STD_OPTIONS="$PLUGIN_OPTS $DOUNIT noipdefault noauth default-asyncmap $DEFAULTROUTE hide-password nodetach $PEERDNS mtu $MTU mru $MRU noaccomp nodeflate nopcomp novj novjccomp user $USER lcp-echo-interval $LCP_INTERVAL lcp-echo-failure $LCP_FAILURE $PPPD_EXTRA" 233 | 234 | # Jigger DNS if required... 235 | if test "$DNSTYPE" = "SERVER" ; then 236 | # Sorry, dude... 237 | rm -f /etc/resolv.conf 238 | ln -s /etc/ppp/resolv.conf /etc/resolv.conf 239 | elif test "$DNSTYPE" = "SPECIFY" ; then 240 | # Sorry, dude... 241 | rm -f /etc/resolv.conf 242 | echo "nameserver $DNS1" > /etc/resolv.conf 243 | if test -n "$DNS2" ; then 244 | echo "nameserver $DNS2" >> /etc/resolv.conf 245 | fi 246 | fi 247 | 248 | # PPPoE invocation 249 | PPPOE_CMD="$PPPOE -p $PPPOE_PIDFILE -I $ETH -T $PPPOE_TIMEOUT -U $PPPOE_SYNC $CLAMPMSS $ACNAME $SERVICENAMEOPT $PPPOE_EXTRA" 250 | if test "$DEBUG" != "" ; then 251 | if test "$DEMAND" != "" ; then 252 | echo "(Turning off DEMAND for debugging purposes)" 253 | DEMAND="" 254 | fi 255 | echo "* The following section shows the pppd command we will invoke" >> $DEBUG 256 | echo "pppd invocation" >> $DEBUG 257 | echo "$SETSID $PPPD pty '$PPPOE_CMD' $PPP_STD_OPTIONS $PPPD_SYNC debug" >> $DEBUG 258 | echo "---------------------------------------------" >> $DEBUG 259 | $SETSID $PPPD pty "$PPPOE_CMD -D $DEBUG-0" \ 260 | $PPP_STD_OPTIONS \ 261 | $PPPD_SYNC \ 262 | debug >> $DEBUG 2>&1 263 | echo "---------------------------------------------" >> $DEBUG 264 | echo "* The following section is an extract from your log." >> $DEBUG 265 | echo "* Look for error messages from pppd, such as" >> $DEBUG 266 | echo "* a lack of kernel support for PPP, authentication failure" >> $DEBUG 267 | echo "* etc." >> $DEBUG 268 | if test -f "/var/log/messages" ; then 269 | echo "Extract from /var/log/messages" >> $DEBUG 270 | grep 'ppp' /var/log/messages | tail -150 >> $DEBUG 271 | elif test -f "/var/adm/messages"; then 272 | echo "Extract from /var/adm/messages" >> $DEBUG 273 | grep 'ppp' /var/adm/messages | tail -150 >> $DEBUG 274 | else 275 | echo "Can't find messages file (looked for /var/{log,adm}/messages" >> $DEBUG 276 | fi 277 | date >> $DEBUG 278 | echo "---------------------------------------------" >> $DEBUG 279 | echo "* The following section is a dump of the packets" >> $DEBUG 280 | echo "* sent and received by rp-pppoe. If you don't see" >> $DEBUG 281 | echo "* any output, it's an Ethernet driver problem. If you only" >> $DEBUG 282 | echo "* see three PADI packets and nothing else, check your cables" >> $DEBUG 283 | echo "* and modem. Make sure the modem lights flash when you try" >> $DEBUG 284 | echo "* to connect. Check that your Ethernet card is in" >> $DEBUG 285 | echo "* half-duplex, 10Mb/s mode. If all else fails," >> $DEBUG 286 | echo "* try using pppoe-sniff." >> $DEBUG 287 | echo "rp-pppoe debugging dump" >> $DEBUG 288 | cat $DEBUG-0 >> $DEBUG 289 | rm -f $DEBUG-0 290 | for i in 1 2 3 4 5 6 7 8 9 10 ; do 291 | echo "" 292 | echo "" 293 | echo "" 294 | done 295 | echo "*** Finished debugging run. Please review the file" 296 | echo "*** '$DEBUG' and try to" 297 | echo "*** figure out what is going on." 298 | echo "***" 299 | echo "*** Unfortunately, we can NO LONGER accept debugging" 300 | echo "*** output for analysis. Please do not send this to" 301 | echo "*** Roaring Penguin; it is too time-consuming for" 302 | echo "*** us to deal with all the analyses we have been sent." 303 | exit 0 304 | fi 305 | 306 | echo $$ > $PIDFILE 307 | 308 | while [ true ] ; do 309 | if test "$OVERRIDE_PPPD_COMMAND" != "" ; then 310 | $SETSID $OVERRIDE_PPPD_COMMAND & 311 | echo "$!" > $PPPD_PIDFILE 312 | elif test "$LINUX_PLUGIN" != "" ; then 313 | $SETSID $PPPD $PPP_STD_OPTIONS $DEMAND & 314 | echo "$!" > $PPPD_PIDFILE 315 | else 316 | $SETSID $PPPD pty "$PPPOE_CMD" \ 317 | $PPP_STD_OPTIONS \ 318 | $DEMAND \ 319 | $PPPD_SYNC & 320 | echo "$!" > $PPPD_PIDFILE 321 | fi 322 | wait 323 | 324 | if test "$RETRY_ON_FAILURE" = "no" ; then 325 | exit 326 | fi 327 | 328 | # Run /etc/ppp/pppoe-lost if it exists 329 | test -x /etc/ppp/pppoe-lost && /etc/ppp/pppoe-lost 330 | 331 | # Re-establish the connection 332 | $LOGGER -p daemon.notice \ 333 | "PPPoE connection lost; attempting re-connection." 334 | 335 | # Wait a bit in case a problem causes tons of log messages :-) 336 | sleep 5 337 | done 338 | -------------------------------------------------------------------------------- /doc/HOW-TO-CONNECT: -------------------------------------------------------------------------------- 1 | # LIC: GPL 2 | 3 | $Id$ 4 | 5 | This package lets you connect a Linux machine to an ISP that uses PPPoE. 6 | PPPoE is used by many DSL providers and some wireless providers. 7 | 8 | Follow these steps and you should have your PPPoE service up and running. 9 | 10 | 0. Install the rp-pppoe-software 11 | -------------------------------- 12 | 13 | You should have already done this by the time you're reading this. If not, 14 | go back and read README. 15 | 16 | 1. Set up your Ethernet hardware 17 | -------------------------------- 18 | 19 | First, make sure the Ethernet card you intend to use with the modem is 20 | visible to the Linux kernel. Just how to do this is beyond the scope 21 | of this document. However, if the card is the only Ethernet card in 22 | the system, executing: 23 | 24 | ifconfig eth0 25 | 26 | should display something like this: 27 | 28 | eth0 Link encap:Ethernet HWaddr 00:60:67:62:31:D4 29 | 30 | plust some more lines. Your HWaddr will be different. As long as you see 31 | the HWaddr line, your card should be working. 32 | 33 | DO NOT assign an IP address to the Ethernet card. DO NOT configure the 34 | card to come up at boot time. 35 | 36 | 2. Configure various files 37 | -------------------------- 38 | 39 | Several files need editing. The easiest way to do this is to run 40 | the following command as root: 41 | 42 | pppoe-setup 43 | 44 | Answer the questions and you should be all set. If you want to know what 45 | goes on behind the scenes, continue reading this document. If you don't 46 | care and your connection works, stop reading. :-) 47 | 48 | 3. Edit pap-secrets 49 | ------------------- 50 | 51 | Edit the "pap-secrets" file, inserting your proper user-ID and password. 52 | Install the file (or copy the relevant lines) to /etc/ppp/pap-secrets. 53 | Your ISP may use CHAP authentication. In this case, add the line to 54 | /etc/ppp/chap-secrets. 55 | 56 | 4. Edit /etc/ppp/pppoe.conf 57 | ----------------------------- 58 | 59 | The file /etc/ppp/pppoe.conf contains configuration information for the 60 | DSL connection. You need to edit the following items: 61 | 62 | - Change ETH=eth1 to the correct Ethernet device for your modem. 63 | - Change USER=bxxxnxnx@sympatico.ca to your proper DSL user-ID. 64 | 65 | Don't edit any of the other settings unless you're an expert. 66 | 67 | 5. Set up DNS 68 | ------------- 69 | 70 | If you are using DNS servers supplied by your ISP, edit the file 71 | /etc/resolv.conf to contain these lines: 72 | 73 | nameserver ip_addr_of_first_dns_server 74 | nameserver ip_addr_of_second_dns_server 75 | 76 | For example: 77 | 78 | nameserver 204.101.251.1 79 | nameserver 204.101.251.2 80 | 81 | 82 | 6. Firewall your machine 83 | ------------------------ 84 | 85 | MAKE SURE YOU FIREWALL YOUR MACHINE. A sample firewall script is given 86 | in the shell script "firewall" To install the script: 87 | 88 | a) Copy it to /etc/rc.d/init.d/firewall 89 | b) Type: chkconfig firewall on 90 | c) Start the firewall: sh /etc/rc.d/init.d/firewall start 91 | 92 | (The above procedure works ONLY on Red Hat-like systems.) 93 | 94 | You may want to tweak the script somewhat. 95 | 96 | 7. Bring up the connection at boot time 97 | --------------------------------------- 98 | 99 | On a Red Hat system, the installation procedure should have installed 100 | a script called /etc/rc.d/init.d/pppoe. To bring up the connection 101 | at boot time, just type this command as root: 102 | 103 | chkconfig --add pppoe 104 | 105 | On non-Red-Hat systems, add this line to the end 106 | of /etc/rc.d/rc.local: 107 | 108 | /usr/sbin/pppoe-start 109 | 110 | 8. Configure LAN Hosts 111 | ---------------------- 112 | 113 | If you have a LAN behind the firewall, you have to lower the TCP 114 | maximum segment size from the normal 1460 to 1452 (or better, 1412.) 115 | You have two options: Either set the MTU of all the interfaces on 116 | other hosts on the LAN to 1452, or use the "-m 1412" option to pppoe. 117 | The "-m" option for pppoe is far simpler and makes it easier to add 118 | hosts to the LAN, but consumes some extra CPU time. 119 | 120 | If you want to manually configure the LAN hosts, here's how: 121 | 122 | In Linux, use: "ifconfig eth0 mtu 1452". For best results, put this 123 | in an /etc/rc.d/rc.local script. 124 | 125 | For Windows, machines, see http://lan.cns.ksu.edu/OS/WIN95/slip95.htm. 126 | Set the MaxMTU to 1452. 127 | 128 | 9. Commands to control the PPPoE link 129 | ------------------------------------- 130 | 131 | As root, bring up the link by typing: pppoe-start 132 | As root, bring down the link by typing: pppoe-stop 133 | 134 | That's it! 135 | 136 | -- 137 | David F. Skoll | Roaring Penguin Software Inc. 138 | http://www.roaringpenguin.com | 139 | 140 | PROBLEMS! DAVE, IT DOESN'T WORK! 141 | --------------------------------- 142 | 143 | Here are some problems PPPoE users have encountered. 144 | 145 | ----------------------------------------------------------------------------- 146 | A) Can't see the Ethernet interface 147 | 148 | Well, I can't really help you here. To use these instructions, you must 149 | have Linux working to the point where it recognizes your Ethernet card. 150 | If you type "ifconfig ethx" and you get back a HWAddr value, your Ethernet 151 | card is probably OK. But I really can't help with hardware configuration 152 | issues. 153 | 154 | ----------------------------------------------------------------------------- 155 | B) Connection seems to come up, but I can't browse the web or ping anything 156 | 157 | You probably don't have DNS set up. See step 6. 158 | 159 | ----------------------------------------------------------------------------- 160 | C) Can't compile PPPoE 161 | 162 | Make sure you have "make", the C compiler and all development header 163 | files installed. I only test rp-pppoe on Linux. It might not work on 164 | *BSD and probably won't work on any other version of UNIX. 165 | 166 | ----------------------------------------------------------------------------- 167 | D) pppd complains about (i) "unknown option pty" or (ii) "pty option precludes 168 | specifying device name" 169 | 170 | (i) Your pppd is too old. You need at least 2.3.7. 171 | (ii) Your /etc/ppp/options file is not empty. Empty it! 172 | 173 | ----------------------------------------------------------------------------- 174 | E) pppoe dies with the log message "Message too long" 175 | 176 | You set the MTU of the Ethernet interface connected to the DSL modem 177 | to less than 1500. Don't do that. 178 | 179 | ----------------------------------------------------------------------------- 180 | F) Internal hosts can't see the Internet 181 | 182 | Do you have masquerading set up? I can't help you in great detail, but 183 | see the IPCHAINS-HOWTO and the IP-Masquerade mini-HOWTO. 184 | 185 | ----------------------------------------------------------------------------- 186 | G) Authentication fails 187 | 188 | Make sure you have the right secret in /etc/ppp/pap-secrets. Your ISP 189 | may be using CHAP; it won't hurt to copy the line to /etc/ppp/chap-secrets. 190 | 191 | Also, MAKE SURE that /etc/ppp/options is EMPTY. The "pppoe-connect" script 192 | supplies all required options on the command line; additional options 193 | in /etc/ppp/options may mess things up. 194 | 195 | ----------------------------------------------------------------------------- 196 | H) VPN software does not work 197 | 198 | If you are using VPN software on a Windows or Linux machine with another 199 | Linux machine running PPPoE as the gateway, you MUST NOT use the "-m" option 200 | to pppoe. This alters IP packets, which will break any VPN which uses IPSec. 201 | In /etc/ppp/pppoe.conf, set CLAMPMSS to "no". You'll also have to reduce 202 | the MTU on the hosts behind the gateway to 1452. 203 | 204 | ----------------------------------------------------------------------------- 205 | I) I can browse some web sites just fine, but others stall forever. 206 | 207 | There is probably a buggy router or firewall between you and the Web server. 208 | One possible workaround: In /etc/ppp/pppoe.conf, find the line which reads: 209 | 210 | CLAMPMSS=1412 211 | 212 | Try lowering the 1412 until it works (go down in steps of 100 or so.) Each 213 | time you lower the value, you have to restart your connection like this: 214 | 215 | pppoe-stop; pppoe-start 216 | 217 | This should work around buggy routers which do not support Path MTU discovery. 218 | 219 | ----------------------------------------------------------------------------- 220 | J) Whenever I connect using DSL, my internal LAN no longer sees the gateway 221 | 222 | You are more than likely running a 2.0.X Linux kernel. To solve this 223 | problem, give the Ethernet card connected to the DSL modem a fake IP 224 | address. For example, if eth0 is your internal LAN card and eth1 goes to 225 | the DSL modem, do something like this: 226 | 227 | ifconfig eth1 10.0.0.1 netmask 255.255.255.0 228 | 229 | (You may have to choose a different IP address; experiment.) 230 | ----------------------------------------------------------------------------- 231 | K) How can I run a script every time I connect and get a new IP address? 232 | 233 | Put the script in /etc/ppp/ip-up. See the pppd(8) man page. 234 | ----------------------------------------------------------------------------- 235 | L) Nothing works! 236 | 237 | You may need to put your Ethernet card in half-duplex, 10Mb/s mode to 238 | work with the DSL modem. You may have to run a DOS program to do this, 239 | or pass special parameters to the Linux driver. 240 | 241 | Some providers object to attempts to set the MRU or MTU. Try removing 242 | "mtu 1492 mru 1492" from PPP_STD_OPTIONS in the pppoe-connect script. 243 | This problem has been seen with an ISP in Hong Kong. 244 | 245 | Your DSL provider may be using non-standard PPPoE frames or require 246 | something special in the Service-Name field. If you have two computers, 247 | you can try sniffing out these values with the "pppoe-sniff" program. 248 | Type "man pppoe-sniff" for details. If you don't have two computers, 249 | you'll have to ask your DSL provider if it uses non-standard PPPoE frames 250 | or special Service-Name fields. Good luck getting an answer... 251 | 252 | If pppoe-sniff indicates that nothing is amiss, make sure the Ethernet 253 | card associated with the DSL modem does NOT have a valid IP address. 254 | (NOTE: For 2.0 kernels, you may have to give it a fake IP address 255 | which is not on your internal subnet. Something like 192.168.42.42 256 | might work if you are not using 192.168.42.*) 257 | 258 | If you are using synchronous PPP on a slow machine, try switching to 259 | asynchronous PPP. 260 | 261 | Make sure no entries in the routing table go through the Ethernet card 262 | connected to the DSL modem. You might want to add these lines in 263 | pppoe-connect: 264 | 265 | ifconfig ethx down 266 | ifconfig ethx up mtu 1500 267 | 268 | which should reset things to sane values. 269 | -------------------------------------------------------------------------------- /scripts/pppoe-setup.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #*********************************************************************** 3 | # 4 | # pppoe-setup 5 | # 6 | # All-purpose slicing/dicing shell script to configure rp-pppoe. 7 | # 8 | # LIC: GPL 9 | # 10 | # Copyright (C) 2000 Roaring Penguin Software Inc. 11 | # 12 | # $Id$ 13 | #*********************************************************************** 14 | 15 | # From AUTOCONF 16 | prefix=@prefix@ 17 | exec_prefix=@exec_prefix@ 18 | 19 | # Paths to programs 20 | IFCONFIG=/sbin/ifconfig 21 | PPPD=@PPPD@ 22 | PPPOE=@sbindir@/pppoe 23 | ECHO=@ECHO@ 24 | LOGGER="/usr/bin/logger -t `basename $0`" 25 | 26 | # Set to "C" locale so we can parse messages from commands 27 | LANG=C 28 | export LANG 29 | 30 | CONFIG=/etc/ppp/pppoe.conf 31 | 32 | # Protect created files 33 | umask 077 34 | 35 | copy() { 36 | cp $1 $2 37 | if [ "$?" != 0 ] ; then 38 | $ECHO "*** Error copying $1 to $2" 39 | $ECHO "*** Quitting." 40 | exit 1 41 | fi 42 | } 43 | 44 | $ECHO "Welcome to the Roaring Penguin PPPoE client setup. First, I will run" 45 | $ECHO "some checks on your system to make sure the PPPoE client is installed" 46 | $ECHO "properly..." 47 | $ECHO "" 48 | 49 | # Must be root 50 | if [ "`@ID@ -u`" != 0 ] ; then 51 | $ECHO "$0: Sorry, you must be root to run this script" 52 | exit 1 53 | fi 54 | 55 | # Prototype config file must exist 56 | if [ ! -r "$CONFIG" ] ; then 57 | $ECHO "Oh, dear, I don't see the file '$CONFIG' anywhere. Please" 58 | $ECHO "re-install the PPPoE client." 59 | exit 1 60 | fi 61 | 62 | # Must have pppd 63 | if [ ! -x $PPPD ] ; then 64 | $ECHO "Oops, I can't execute the program '$PPPD'. You" 65 | $ECHO "must install the PPP software suite, version 2.3.10 or later." 66 | exit 1 67 | fi 68 | export CONFIG 69 | . $CONFIG 70 | 71 | if [ "$DEMAND" = "" ] ; then 72 | DEMAND=no 73 | fi 74 | 75 | # pppoe must exist 76 | if [ ! -x "$PPPOE" ] ; then 77 | $ECHO "Oh, dear, I can't execute the program '$PPPOE'. Please" 78 | $ECHO "re-install the rp-pppoe client." 79 | exit 1 80 | fi 81 | 82 | $ECHO "Looks good! Now, please enter some information:" 83 | 84 | while [ true ] ; do 85 | $ECHO "" 86 | $ECHO "USER NAME" 87 | $ECHO "" 88 | printf "%s" ">>> Enter your PPPoE user name (default $USER): " 89 | read U 90 | 91 | if [ "$U" = "" ] ; then 92 | U="$USER" 93 | fi 94 | 95 | # Under Linux, "fix" the default interface if eth1 is not available 96 | if test `uname -s` = "Linux" ; then 97 | $IFCONFIG $ETH > /dev/null 2>&1 || ETH=eth0 98 | fi 99 | $ECHO "" 100 | $ECHO "INTERFACE" 101 | $ECHO "" 102 | $ECHO ">>> Enter the Ethernet interface connected to the DSL modem" 103 | $ECHO "For Solaris, this is likely to be something like /dev/hme0." 104 | $ECHO "For Linux, it will be ethn, where 'n' is a number." 105 | printf "%s" "(default $ETH): " 106 | read E 107 | 108 | if [ "$E" = "" ] ; then 109 | E="$ETH" 110 | fi 111 | 112 | $ECHO "" 113 | $ECHO "Do you want the link to come up on demand, or stay up continuously?" 114 | $ECHO "If you want it to come up on demand, enter the idle time in seconds" 115 | $ECHO "after which the link should be dropped. If you want the link to" 116 | $ECHO "stay up permanently, enter 'no' (two letters, lower-case.)" 117 | $ECHO "NOTE: Demand-activated links do not interact well with dynamic IP" 118 | $ECHO "addresses. You may have some problems with demand-activated links." 119 | printf "%s" ">>> Enter the demand value (default $DEMAND): " 120 | read D 121 | if [ "$D" = "" ] ; then 122 | D=$DEMAND 123 | fi 124 | 125 | $ECHO "" 126 | $ECHO "DNS" 127 | $ECHO "" 128 | $ECHO "Please enter the IP address of your ISP's primary DNS server." 129 | $ECHO "If your ISP claims that 'the server will provide DNS addresses'," 130 | $ECHO "enter 'server' (all lower-case) here." 131 | $ECHO "If you just press enter, I will assume you know what you are" 132 | $ECHO "doing and not modify your DNS setup." 133 | printf "%s" ">>> Enter the DNS information here: " 134 | 135 | read DNS1 136 | 137 | 138 | if [ "$DNS1" != "" ] ; then 139 | if [ "$DNS1" != "server" ] ; then 140 | $ECHO "Please enter the IP address of your ISP's secondary DNS server." 141 | $ECHO "If you just press enter, I will assume there is only one DNS server." 142 | printf "%s" ">>> Enter the secondary DNS server address here: " 143 | read DNS2 144 | fi 145 | fi 146 | 147 | while [ true ] ; do 148 | $ECHO "" 149 | $ECHO "PASSWORD" 150 | $ECHO "" 151 | stty -echo 152 | printf "%s" ">>> Please enter your PPPoE password: " 153 | read PWD1 154 | $ECHO "" 155 | printf "%s" ">>> Please re-enter your PPPoE password: " 156 | read PWD2 157 | $ECHO "" 158 | stty echo 159 | if [ "$PWD1" = "$PWD2" ] ; then 160 | break 161 | fi 162 | 163 | printf "%s" ">>> Sorry, the passwords do not match. Try again? (y/n)" 164 | read ANS 165 | case "$ANS" in 166 | N|No|NO|Non|n|no|non) 167 | $ECHO "OK, quitting. Bye." 168 | exit 1 169 | esac 170 | done 171 | 172 | # Firewalling 173 | $ECHO "" 174 | $ECHO "FIREWALLING" 175 | $ECHO "" 176 | if test `uname -s` != "Linux" ; then 177 | $ECHO "Sorry, firewalling is only supported under Linux. Consult" 178 | $ECHO "your operating system manuals for details on setting up" 179 | $ECHO "packet filters for your system." 180 | FIREWALL=NONE 181 | else 182 | $ECHO "Please choose the firewall rules to use. Note that these rules are" 183 | $ECHO "very basic. You are strongly encouraged to use a more sophisticated" 184 | $ECHO "firewall setup; however, these will provide basic security. If you" 185 | $ECHO "are running any servers on your machine, you must choose 'NONE' and" 186 | $ECHO "set up firewalling yourself. Otherwise, the firewall rules will deny" 187 | $ECHO "access to all standard servers like Web, e-mail, ftp, etc. If you" 188 | $ECHO "are using SSH, the rules will block outgoing SSH connections which" 189 | $ECHO "allocate a privileged source port." 190 | $ECHO "" 191 | while [ true ] ; do 192 | $ECHO "The firewall choices are:" 193 | $ECHO "0 - NONE: This script will not set any firewall rules. You are responsible" 194 | $ECHO " for ensuring the security of your machine. You are STRONGLY" 195 | $ECHO " recommended to use some kind of firewall rules." 196 | $ECHO "1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation" 197 | $ECHO "2 - MASQUERADE: Appropriate for a machine acting as an Internet gateway" 198 | $ECHO " for a LAN" 199 | printf "%s" ">>> Choose a type of firewall (0-2): " 200 | read a 201 | if [ "$a" = 0 -o "$a" = 1 -o "$a" = 2 ] ; then 202 | break 203 | fi 204 | $ECHO "Please enter a number from 0 to 2" 205 | done 206 | 207 | case "$a" in 208 | 0) 209 | FIREWALL=NONE 210 | ;; 211 | 1) 212 | FIREWALL=STANDALONE 213 | ;; 214 | 2) 215 | FIREWALL=MASQUERADE 216 | ;; 217 | esac 218 | fi 219 | 220 | $ECHO "" 221 | $ECHO "** Summary of what you entered **" 222 | $ECHO "" 223 | $ECHO "Ethernet Interface: $E" 224 | $ECHO "User name: $U" 225 | if [ "$D" = "no" ] ; then 226 | $ECHO "Activate-on-demand: No" 227 | else 228 | $ECHO "Activate-on-demand: Yes; idle timeout = $D seconds" 229 | fi 230 | 231 | if [ "$DNS1" != "" ] ; then 232 | if [ "$DNS1" = "server" ] ; then 233 | $ECHO "DNS addresses: Supplied by ISP's server" 234 | else 235 | $ECHO "Primary DNS: $DNS1" 236 | if [ "$DNS2" != "" ] ; then 237 | $ECHO "Secondary DNS: $DNS2" 238 | fi 239 | fi 240 | else 241 | $ECHO "DNS: Do not adjust" 242 | fi 243 | $ECHO "Firewalling: $FIREWALL" 244 | $ECHO "" 245 | while [ true ] ; do 246 | printf "%s" '>>> Accept these settings and adjust configuration files (y/n)? ' 247 | read ANS 248 | case "ANS" in 249 | Y|y|yes|Yes|oui|Oui) 250 | ANS=y 251 | ;; 252 | N|n|no|No|non|Non) 253 | ANS=n 254 | ;; 255 | esac 256 | if [ "$ANS" = "y" -o "$ANS" = "n" ] ; then 257 | break 258 | fi 259 | done 260 | if [ "$ANS" = "y" ] ; then 261 | break 262 | fi 263 | done 264 | 265 | # Adjust configuration files. First to $CONFIG 266 | 267 | $ECHO "Adjusting $CONFIG" 268 | 269 | copy $CONFIG $CONFIG-bak 270 | if [ "$DNS1" = "server" ] ; then 271 | DNSTYPE=SERVER 272 | DNS1="" 273 | PEERDNS=yes 274 | else 275 | PEERDNS=no 276 | if [ "$DNS1" = "" ] ; then 277 | DNSTYPE=NOCHANGE 278 | else 279 | DNSTYPE=SPECIFY 280 | fi 281 | fi 282 | 283 | # Where is pppd likely to put its pid? 284 | if [ -d /var/run ] ; then 285 | VARRUN=/var/run 286 | else 287 | VARRUN=/etc/ppp 288 | fi 289 | 290 | # Some #$(*& ISP's use a slash in the user name... 291 | sed -e "s&^USER=.*&USER='$U'&" \ 292 | -e "s&^ETH=.*Ð='$E'&" \ 293 | -e "s&^PIDFILE=.*&PIDFILE=\"$VARRUN/\$CF_BASE-pppoe.pid\"&" \ 294 | -e "s/^FIREWALL=.*/FIREWALL=$FIREWALL/" \ 295 | -e "s/^DEMAND=.*/DEMAND=$D/" \ 296 | -e "s/^DNSTYPE=.*/DNSTYPE=$DNSTYPE/" \ 297 | -e "s/^DNS1=.*/DNS1=$DNS1/" \ 298 | -e "s/^DNS2=.*/DNS2=$DNS2/" \ 299 | -e "s/^PEERDNS=.*/PEERDNS=$PEERDNS/" \ 300 | < $CONFIG-bak > $CONFIG 301 | 302 | if [ $? != 0 ] ; then 303 | $ECHO "** Error modifying $CONFIG" 304 | $ECHO "** Quitting" 305 | exit 1 306 | fi 307 | 308 | if [ "$DNS1" != "" ] ; then 309 | if [ "$DNS1" != "server" ] ; then 310 | $ECHO "Adjusting /etc/resolv.conf" 311 | if [ -r /etc/resolv.conf ] ; then 312 | grep -s "MADE-BY-RP-PPPOE" /etc/resolv.conf > /dev/null 2>&1 313 | if [ "$?" != 0 ] ; then 314 | $ECHO " (But first backing it up to /etc/resolv.conf-bak)" 315 | copy /etc/resolv.conf /etc/resolv.conf-bak 316 | fi 317 | fi 318 | $ECHO "# MADE-BY-RP-PPPOE" > /etc/resolv.conf 319 | $ECHO "nameserver $DNS1" >> /etc/resolv.conf 320 | if [ "$DNS2" != "" ] ; then 321 | $ECHO "nameserver $DNS2" >> /etc/resolv.conf 322 | fi 323 | fi 324 | fi 325 | 326 | $ECHO "Adjusting /etc/ppp/pap-secrets and /etc/ppp/chap-secrets" 327 | if [ -r /etc/ppp/pap-secrets ] ; then 328 | $ECHO " (But first backing it up to /etc/ppp/pap-secrets-bak)" 329 | copy /etc/ppp/pap-secrets /etc/ppp/pap-secrets-bak 330 | else 331 | cp /dev/null /etc/ppp/pap-secrets-bak 332 | fi 333 | if [ -r /etc/ppp/chap-secrets ] ; then 334 | $ECHO " (But first backing it up to /etc/ppp/chap-secrets-bak)" 335 | copy /etc/ppp/chap-secrets /etc/ppp/chap-secrets-bak 336 | else 337 | cp /dev/null /etc/ppp/chap-secrets-bak 338 | fi 339 | 340 | egrep -v "^$U|^\"$U\"" /etc/ppp/pap-secrets-bak > /etc/ppp/pap-secrets 341 | $ECHO "\"$U\" * \"$PWD1\"" >> /etc/ppp/pap-secrets 342 | egrep -v "^$U|^\"$U\"" /etc/ppp/chap-secrets-bak > /etc/ppp/chap-secrets 343 | $ECHO "\"$U\" * \"$PWD1\"" >> /etc/ppp/chap-secrets 344 | 345 | $ECHO "" 346 | $ECHO "" 347 | $ECHO "" 348 | $ECHO "Congratulations, it should be all set up!" 349 | $ECHO "" 350 | $ECHO "Type 'pppoe-start' to bring up your PPPoE link and 'pppoe-stop' to bring" 351 | $ECHO "it down. Type 'pppoe-status' to see the link status." 352 | exit 0 353 | --------------------------------------------------------------------------------