Date: Thu, 5 Mar 1998 08:58:57 +0000 From: dmlb@ragnet.demon.co.uk To: Peter van Heusden <pvh@leftside.wcape.school.za> Cc: dmlb@ragnet.demon.co.uk, freebsd-hackers@FreeBSD.ORG Subject: Re: Detecting state of PPP Message-ID: <9803050902.AA18200@symbionics.co.uk> In-Reply-To: <Pine.BSF.3.95.980305071307.15655F-100000@leftside.wcape.school.za>
next in thread | previous in thread | raw e-mail | index | archive | help
> Date: Thu, 5 Mar 1998 07:16:09 +0200 (SAT) > From: Peter van Heusden <pvh@leftside.wcape.school.za> > To: freebsd-hackers@FreeBSD.ORG > Subject: Detecting state of PPP > Hi > > How does one go about writing a program to check if a PPP link is up or > down? I'm running PPP in -auto mode, and I'd like to be able to tell > whether the PPP link is actually up (i.e. the modem connection is in > place) at any particular time. Unfortunately, the flags on tun0 stay the > same (0x8051 on my system) whether the modem is connected or not. What > should I be looking at? > > Thanks, > Peter The generic way is to either use pppctl(8) or connect to the listening socket and detect the state of the ppp prompt. ppp ON computer> --- ppp is down PPP ON computer> --- ppp is up. Something I did in tcl was the follwoing (from memory) #!/usr/local/bin/tclsh7.6 set s [socket localhost 3000] gets $s gets $s gets $s if {[read $s 3] == "PPP"} { puts "ppp is up" } else { puts "ppp is down" } close $s The three gets read the initial banner from pp; the read reads the first 3 bytes of the prompt. The socket number 3000 is talked about in the manual basically ppp will open 3000+tunnel number. You may also need to set a password in /etc/ppp.secrets. Note that the new way of talking is via a unix domain socket (a socket addressable by a file name). But tcl can't open unix domain sockets, so I did it the old way. I am using this with TkDesk to give a little phone up/down icon. Comments Brian? Duncan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9803050902.AA18200>