GSK Reference Manual | ||||
---|---|---|---|---|
GskNetworkInterface; GskNetworkInterfaceSet; enum GskNetworkInterfaceFlags; GskNetworkInterfaceSet* gsk_network_interface_set_new (GskNetworkInterfaceFlags flags); void gsk_network_interface_set_destroy (GskNetworkInterfaceSet *set);
These methods allow you to obtain information about the local network interfaces.
A network interface is abstract jargon for an ethernet card, that is, it's a device that transmits and receives packets. Or, it can be a virtual interface, like the loopback interface is. One other possibility is that the interface is an alias: this sort of trick is done to make a computer listen on two IP addresses.
The information returned by this function is a name for each interface (the same name as returned by ifconfig) and addresses, mostly the address used to connect to this device, ie your IP address (with port set to 0).
typedef struct { const char *ifname; /* whether this interface is "virtual" -- just connects back to this host */ unsigned is_loopback : 1; /* whether this interface supports broadcasting. */ unsigned supports_multicast : 1; /* whether this interface is receiving packets not intended for it. */ unsigned is_promiscuous : 1; /* ip-address if the interface is up. */ GskSocketAddress *address; /* if !is_loopback, this is the device's MAC address. */ GskSocketAddress *hw_address; /* if is_point_to_point, this is the address of the other end of * the connection. */ GskSocketAddress *p2p_address; /* if supports_broadcast, this is the broadcast address. */ GskSocketAddress *broadcast; } GskNetworkInterface;
Information about a single network interface.
const char *ifname ; |
the name of the interface. |
GskSocketAddress *address ; |
the IP address of the interface (with port set to 0). |
GskSocketAddress *hw_address ; |
the ethernet address of the interface. |
GskSocketAddress *p2p_address ; |
the remote IP address of a point-to-point connection. |
GskSocketAddress *broadcast ; |
the broadcast IP address. |
typedef struct { guint num_interfaces; GskNetworkInterface *interfaces; } GskNetworkInterfaceSet;
Information about a number of network interfaces.
guint num_interfaces ; |
the number of interfaces. |
GskNetworkInterface *interfaces ; |
the interfaces. |
typedef enum { GSK_NETWORK_INTERFACE_UP = (1<<0), GSK_NETWORK_INTERFACE_LOOPBACK = (1<<1), GSK_NETWORK_INTERFACE_NON_LOOPBACK = (1<<2), GSK_NETWORK_INTERFACE_HAS_BROADCAST = (1<<3), GSK_NETWORK_INTERFACE_HAS_MULTICAST = (1<<4) } GskNetworkInterfaceFlags;
Constraints governing which interfaces to return.
GskNetworkInterfaceSet* gsk_network_interface_set_new (GskNetworkInterfaceFlags flags);
Create a new list of interfaces, subject to the constraints given.
Note that the constraints must all be satified, so using GSK_NETWORK_INTERFACE_NO_LOOKBACK and GSK_NETWORK_INTERFACE_LOOKBACK will always return an empty set.
flags : |
constraints on the interfaces to return. All the constraints must be satisfied. |
Returns : | a newly allocated list of interfaces that
must be freed with gsk_network_interface_set_destroy() .
|
void gsk_network_interface_set_destroy (GskNetworkInterfaceSet *set);
Free the memory used by the list of interfaces.
set : |
the list of interfaces to destroy. |