From owner-freebsd-hackers Thu Mar 5 01:09:05 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA08469 for freebsd-hackers-outgoing; Thu, 5 Mar 1998 01:09:05 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from symbionics.co.uk (symsun3.symbionics.co.uk [194.32.100.60]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id BAA08315 for ; Thu, 5 Mar 1998 01:07:08 -0800 (PST) (envelope-from dmlb@ragnet.demon.co.uk) From: dmlb@ragnet.demon.co.uk Received: from sympc287.symbionics.co.uk by symbionics.co.uk (4.1/SMI-4.1) id AA18200; Thu, 5 Mar 98 09:02:25 GMT Message-Id: <9803050902.AA18200@symbionics.co.uk> Comments: Authenticated sender is To: Peter van Heusden Date: Thu, 5 Mar 1998 08:58:57 +0000 Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Subject: Re: Detecting state of PPP Reply-To: dmlb@ragnet.demon.co.uk Cc: dmlb@ragnet.demon.co.uk, freebsd-hackers@FreeBSD.ORG In-Reply-To: X-Mailer: Pegasus Mail for Win32 (v2.53/R1) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > Date: Thu, 5 Mar 1998 07:16:09 +0200 (SAT) > From: Peter van Heusden > 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