Detect PPPoE vs. DHCP

Andre Garzia soapdog at mac.com
Mon Nov 8 18:19:49 CST 2004


Some research brought this to my attention:

PPPoE Configuration in MacOS X and Darwin
http://www.opendarwin.org/en/articles/network_config/ar01s04.html

Network Configuration in MacOS X and Darwin
http://www.opendarwin.org/en/articles/network_config/ar01s02.html


Then I found lots of configuration info inside the plists that reside  
at /Library/Preferences/SystemConfiguration

And there's a Kicker.bundle inside the  
/System/Library/SystemConfiguration/Kicker.bundle/Contents that it  
responsible (it appears) to start the network, inside it's plist it  
shows ne instructions to start the networking... it's there somewhere.  
You should see a bash script called "enable-network" that restart the  
network if configuration is changed. There's also some nice "library"  
/etc/rc.common that shows some funcs like checkNetwork() (which in our  
case is useless)

The folder /Library/Preferences/SystemConfiguration got a file called  
NetworkInterfaces.plist, there it holds the Network Adapter info, I  
think PPPoE info might be stored there too, but since I don't use PPPoE  
I cannot prove it. Also, When turning on PPPoE here just to see if  
somefile changed, my computer locked, and network was "disabled" (I  
should have thought of that).

After that I was felling dizzy, and went to Apple Developer Connection  
documentation and found this System Configuration Tool thing:  
http://developer.apple.com/documentation/Networking/Conceptual/ 
SystemConfigFrameworks/index.html

This text is very relevant to you, look at this blurb I copy & pasted  
from it:

Who Should Read This Document?

The audience for this document comprises two main groups:
	▪ 	
  Developers of network configuration or dialer software.
	▪ 	
Developers of applications that need to request and use network  
connections.

If you are developing an application that defines network services,  
initiates IP networking or creates a PPP connection, you should  
concentrate on the network preferences and configuration APIs. If  
you’re developing an application that needs to know if a remote host is  
reachable or initiate a PPP connection, you should focus on the  
reachability and connection APIs.

---- end of blurb ---

See, it's exactly what you're looking I think. In this document we  
learn that we can "listen" to notifications from the Notitfyd/Configd  
daemons, and that they are responsible for logging the use of the files  
mentioned above, for example, one can register to receive a  
notification when a successifull PPPoE connection is established. The  
problem, is, Revolution does not have access to the Cocoa nor the  
Carbon API collections, unless, someone make an external. Then looking  
further, I discovered a command line utility called "scutil" that is an  
interface for configd, you can read and write to it using open process  
or shell (open process is better since it uses interactive prompts).  
You start it by typing scutil, first command should be "open", Then,  
you should acquire a list of available serviceIDs by querying the "show  
Setup:/Network/Global/IPv4" This will list the IDs, if you query the  
IDs with "show Setup:/Network/Service/<insert the id>/Interface" you  
receive all kinds of info on each interface. I'll glue a session below.

--- begin paste ---
[soapdog:/Library/Preferences/SystemConfiguration] andregar% scutil
 > open
 > show Setup:/Network/Global/IPv4
<dictionary> {
   ServiceOrder : <array> {
     0 : 1348DBC7-2685-11D8-9878-0003936D012E
     1 : 1348BE96-2685-11D8-9878-0003936D012E
     2 : 13489648-2685-11D8-9878-0003936D012E
   }
   PPPOverridePrimary : 0
}
 > show  
Setup:/Network/Service/1348DBC7-2685-11D8-9878-0003936D012E/Interface
<dictionary> {
   UserDefinedName : Built-in Ethernet
   DeviceName : en0
   Type : Ethernet
   Hardware : Ethernet
}
 > show  
Setup:/Network/Service/1348BE96-2685-11D8-9878-0003936D012E/Interface
<dictionary> {
   UserDefinedName : usbserial
   SubType : PPPSerial
   DeviceName : usbserial
   Type : PPP
   Hardware : Modem
}

----- end paste -----

See, if you had a valid PPPoE connection, one of the services would  
show a SubType: PPPoE.

That will tell you if you have a PPPoE connection.... :D Just learned  
this as I researched, lot's of cool stuff can be done with scutil, you  
can for example, load it thru open process, register for a notification  
and keep looping the buffer, if the notification arrives, you'll be  
warned. but fiddling with this you can remote control all macos x  
networking stuff and be called back when it works... I think scutil has  
access to system wide configuration and events, you can learn much from  
it.

Hope this answer your questions, I'll now drink some tea....

Cheers Rob
Andre






On Nov 8, 2004, at 6:04 PM, RGould8 at aol.com wrote:

> Can anyone tell me if there's a way in Mac OS X to determine whether  
> the user
> is currently connected via DHCP vs. PPPoE?   Some sort of unix shell  
> command
> perhaps?   I've looked at the "ifconfig" command, and it spits back a  
> lot if
> interesting info, but nothing jumps out at me to denote "DHCP" vs.  
> "PPPoE".
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
-- 
Andre Alves Garzia  2004  BRAZIL
http://studio.soapdog.org



More information about the use-livecode mailing list