X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=net.h;h=f3caf02450e9224b2a4fdc3d7272d27ab9078406;hb=HEAD;hp=0bb9d2d9565f716c734e45cbfbb43ba4c7fbf391;hpb=a063cda5cff1e3ec56dabddd8ddcd42060a57fd4;p=mtetherd diff --git a/net.h b/net.h index 0bb9d2d..f3caf02 100644 --- a/net.h +++ b/net.h @@ -22,6 +22,7 @@ #define _MTETHERD_NET_H #include +#include G_BEGIN_DECLS @@ -47,6 +48,50 @@ struct _MTetherDDevice { GType mtetherd_device_get_type(); +// Allocates a new device object +// This object doesn't have addresses assigned yet +// Add it to a device list or use mtetherd_device_set_index to construct them +MTetherDDevice *mtetherd_device_new(const gchar *interface, const gchar *udi); +// Constructs IP address and DHCP ranges from the given index +// 192.168.255.0/24 is the supernet for all devices, +// each gets a /30 from that range, depending on the index +// Example: index = 32 -> subnet = 192.168.255.200/30 +// The host address is always 1, and the DHCP range goes from 1 to 2 +void mtetherd_device_set_index(MTetherDDevice *self, guint index); +// Returns the interface name +const gchar *mtetherd_device_get_interface(MTetherDDevice *self); +// Returns the host address +// Free when done +gchar *mtetherd_device_get_addr(MTetherDDevice *self); +// Returns the netmask +// Free when done +gchar *mtetherd_device_get_netmask(MTetherDDevice *self); +// Returns the DHCP range start address +// Free when done +gchar *mtetherd_device_get_dhcp_start(MTetherDDevice *self); +// Returns the DHCP range end address +// Free when done +gchar *mtetherd_device_get_dhcp_end(MTetherDDevice *self); + +// Device list functions +// The list is constrained to 64 entries +gpointer mtetherd_device_list_new(); +// Unrefs all devices contained within and frees the list +void mtetherd_device_list_free(gpointer list); +// Scans the list for an udi and returns the first device found +MTetherDDevice *mtetherd_device_list_find(gpointer list, const gchar *udi); +// Adds a device to the next free position +// This transfers ownership of the object to the list +// Returns FALSE if the list is already full +gboolean mtetherd_device_list_add(gpointer list, MTetherDDevice *device); +// Removes and deallocates the first device with the given UDI from the list +// Returns FALSE if the UDI is not found +gboolean mtetherd_device_list_remove(gpointer list, const gchar *udi); + +// Returns true if the device is acceptable for tethering +// Currently checks if the interface name starts with usb or bnep +gboolean mtetherd_device_ok(const gchar *interface); + G_END_DECLS #endif //_MTETHERD_NET_H