Check network status and control PPP in the program

So, I am running PPP under Linux using a cellular modem. The program that I am writing should know if the link is active before sending any data.

What are my verification options

  • if the link is available
  • if it is redirected to the server that I control (it does not go to the Internet, as I said earlier)

Also, what is the best way to restart it - I would like to have programmatic control when it starts and stops, so I assume init.d is not suitable. Using system()does not seem to give a PID, are there any other options besides fork(), and calling t2> calls?

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

+3
source share
2

pppd ip-up script, , IP- . pppd (8) - "ip-up".

pppd, linkname, pidfile (/var/run/ppp-name.pid). persist. pppd, SIGHUP. , .

+6

/proc/net/route.

+3

Source: https://habr.com/ru/post/1696745/


All Articles