Question

So I'm running PPP under linux with a cellular modem. The program I'm writing needs to know if the link is active before sending any data.

What are my options to check

  • if the link is available
  • if it routes to a server I control (it doesn't go to the internet as I said earlier)

Also, what is the best way to restart it - I'd like to have program control over when it starts and stops, so I assume an init.d isn't appropriate. Using system() doesn't seem to give a PID, are there other options besides fork() and the gaggle of exec??() calls?

C on Linux on ARM (custom distribution using buildroot).

Was it helpful?

Solution

You can use the ip-up script functionality of pppd to have it execute a program when the IP interface is up and ready. Details are in the pppd(8) man page - search for "ip-up".

To restart pppd, use the linkname parameter to set a known pidfile name (/var/run/ppp-name.pid). Also use the persist option. When you want to restart pppd, send the SIGHUP signal. Again, this is described in the man page.

OTHER TIPS

You could parse /proc/net/route.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top