PPPoE Interface

 

PPPoE (PPP Over Ethernet) is widely used in the DSL world for users to connect to Internet. To enable this feature:

 

*          Program file - /flash/bin/pppd is required

*          Connection mode must be set to always-on or manual.

*          User / password / service fields must be set to the ones specified by your ISP

 

If the connection is successful, the PPPoE IP address and connection time will be shown in the status page.

 

 

 

 

Connection Modes

 

Always-on.

 

The system keeps the PPPoE in connection state automatically after power-on. If the connection fails, the system will always try to make a new connection.

 

Manual

 

The connection is controlled by software signals.

SIGUSR1 (value = 10) - start connection

SIGUSR2 (value = 12) - stop connection

 

Manual Control by Commands:

 

First, we need to know the pppd's PID (Process ID) which is stored in the file /var/run/ppp0.pid.

 

/> cat /var/run/ppp0.pid

22

 

In this example, the pppd's PID is 22. Then, we use:

"kill -10 22" to start PPPoE connection

"kill -12 22" to stop PPPoE connection

 

Manual Control by Program:

 

In programs, we are doing exactly the same way:

 

 FILE *fpid;

 int pid;

 

 // get pppd's pid

 fpid=fopen("/var/run/ppp0.pid","rt");

 if(!fpid) return 0;

 if(fscanf(fpid,"%d",&pid)!=1) return 0;

 fclose(fpid);

 // start connection

 kill(pid,SIGUSR1);

 // idle 30 seconds

 sleep(30);

 // stop connection

 kill(pid,SIGUSR2);

 

Connection Status

 

Connection status can be checked with ioctl() system call to get the IP address of "ppp0" device. If the IP address can be retrieved, the connection is ok, otherwise, it is not connected.

 

Connection time is calculated with the starting time which is stored in the file "/var/run/ppp.time".

 

Practical program examples can be found in app/cgi/cgi.c and app/cgi/cgilib.c.