On Tue, 2005-03-22 at 12:42 -0500, Dan Williams wrote: > On Tue, 2005-03-22 at 18:06 +0100, Nils Philippsen wrote: > > On Tue, 2005-03-22 at 10:56 -0500, Dan Williams wrote: > > > > > 3) Full access to DHCP options. NetworkManager provides a DBUS API for > > > applications to access DHCP options returned by the server. For > > > example, ntpd could listen to NetworkManager events and then restart > > > itself with the new server address without ever having to read a config > > > file. xchat could listen to events and find out the corporate IRC > > > server to connect to without ever needing user intervention. There's a > > > wealth of information passed along in DHCP options that applications can > > > use. I'm unaware of any method that "dhclient" has that could provide > > > this information to NetworkManager. > > > > Again, I currently use FC3 stuff, so I'm not sure how this applies here, > > but when I last looked at it, only few information where passed to the > > NMTester.py script in the examples directory. Maybe I got things wrong > > (perhaps the app has to ask for DHCP specific stuff -- I'm a complete > > Yes, the app must ask for the dhcp options itself. This should be > fairly easy from Python. In pseudo code: > > object_path = "/org/freedesktop/NetworkManager/DhcpOptions" > interface = "org.freedesktop.NetworkManager.DhcpOptions" > > type = dbus_call(object_path, interface, "getType", "NTP Servers") > if type == DBUS_TYPE_ARRAY > ip_ary = dbus_call(object_path, interface, "getIntegerv", "NTP > Servers") > ip = ip_ary[0] > else > ip = dbus_call(object_path, interface, "getInteger", "NTP Servers") Hmm, I couldn't make much heads or tails out of it, mostly because I don't know what's pseudo in there and what not ;-), anyway: "dbus_call" isn't wrapped in python. I tried to access the DHCP options like this: --- 8< --- import dbus service = 'org.freedesktop.NetworkManager' object_path = "/org/freedesktop/NetworkManager/DhcpOptions" interface = "org.freedesktop.NetworkManager.DhcpOptions" bus = dbus.Bus (dbus.Bus.TYPE_SYSTEM) NWM_service = bus.get_service (service) dhcpOptions = NWM_service.get_object (object_path, interface) --- >8 --- but the resulting dhcpOptions options doesn't have many methods to begin with: dhcpOptions: ['__doc__', '__getattr__', '__init__', '__module__', '_interface', '_object_path', '_service', 'connect_to_signal'] Any clues for me here? > and now "ip" contains the uint32 representation of an IP address for the > first ntp server returned by the DHCP server, if any. Remember that the > server can return an arbitrary # of servers. > > In the future, the DHCP options API from NetworkManager will always > return an array, even for options that can only have 1 item. That > greatly simplifies bindings and code. > > > neophyte when it comes to dbus e.a.), but I didn't see any information > > related to DHCP there. Furthermore: AFAIK DHCP options get only > > transmitted from the server when the client asks for them, so how would > > I go about "custom" DHCP options I wanted to evaluate? > > The client can request DHCP options from the server, but the server > doesn't necessarily have to provide them. The server is also free to > provide more options than the client asked for I believe. I found that you don't e.g. get the interface-mtu unless you ask for it. It would be good if people could set it somewhere, even more so for non- standard custom options that you want to be able to ask from NWM later on in some python script (assuming you get it working of course). Nils -- Nils Philippsen / Red Hat / nphilipp@xxxxxxxxxx "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -- B. Franklin, 1759 PGP fingerprint: C4A8 9474 5C4C ADE3 2B8F 656D 47D8 9B65 6951 3011