1 /* 2 GSK - a library to write servers 3 Copyright (C) 1999-2000 Dave Benson 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 Contact: 20 daveb@ffem.org <Dave Benson> 21 */ 22 23 /* GskNetworkInterface: find information about network devices on this host. */ 24 25 #ifndef __GSK_NETWORK_INTERFACES_H_ 26 #define __GSK_NETWORK_INTERFACES_H_ 27 28 #include "gsksocketaddress.h" 29 30 G_BEGIN_DECLS 31 32 typedef struct _GskNetworkInterface GskNetworkInterface; 33 typedef struct _GskNetworkInterfaceSet GskNetworkInterfaceSet; 34 35 typedef enum 36 { 37 GSK_NETWORK_INTERFACE_UP = (1<<0), 38 GSK_NETWORK_INTERFACE_LOOPBACK = (1<<1), 39 GSK_NETWORK_INTERFACE_NON_LOOPBACK = (1<<2), 40 GSK_NETWORK_INTERFACE_HAS_BROADCAST = (1<<3), 41 GSK_NETWORK_INTERFACE_HAS_MULTICAST = (1<<4) 42 } GskNetworkInterfaceFlags; 43 44 struct _GskNetworkInterface 45 { 46 const char *ifname; 47 48 /* whether this interface is "virtual" -- just connects back to this host */ 49 unsigned is_loopback : 1; 50 51 /* whether this interface supports broadcasting. */ 52 unsigned supports_multicast : 1; 53 54 /* whether this interface is receiving packets not intended for it. */ 55 unsigned is_promiscuous : 1; 56 57 /* ip-address if the interface is up. */ 58 GskSocketAddress *address; 59 60 /* if !is_loopback, this is the device's MAC address. */ 61 GskSocketAddress *hw_address; 62 63 /* if is_point_to_point, this is the address of the other end of 64 * the connection. 65 */ 66 GskSocketAddress *p2p_address; 67 68 /* if supports_broadcast, this is the broadcast address. */ 69 GskSocketAddress *broadcast; 70 }; 71 72 struct _GskNetworkInterfaceSet 73 { 74 guint num_interfaces; 75 GskNetworkInterface *interfaces; 76 }; 77 78 GskNetworkInterfaceSet * 79 gsk_network_interface_set_new (GskNetworkInterfaceFlags flags); 80 void gsk_network_interface_set_destroy(GskNetworkInterfaceSet *set); 81 82 G_END_DECLS 83 84 #endif 85