1 /* HERCIFC.H (c) Copyright Roger Bowler, 2000-2012 */ 2 /* (c) Copyright James A. Pierson, 2002-2009 */ 3 /* Hercules Interface Control Program */ 4 5 #if defined(NEED_HERCIFC_H) 6 7 #ifndef __HERCIFC_H_ 8 #define __HERCIFC_H_ 9 10 #if ( (!defined(WIN32) && \ 11 !(defined(HAVE_LINUX_IF_TUN_H) || defined(HAVE_NET_IF_H)) ) || \ 12 (defined(WIN32) && !defined(HAVE_NET_IF_H)) ) 13 14 struct ifreq 15 { 16 union 17 { 18 char ifrn_name[IFNAMSIZ]; // (interface name) 19 } 20 ifr_ifrn; 21 22 union 23 { 24 struct sockaddr ifru_addr; // (IP address) 25 struct sockaddr ifru_netmask; // (network mask) 26 struct sockaddr ifru_hwaddr; // (MAC address) 27 short int ifru_flags; // (flags) 28 int ifru_mtu; // (maximum transmission unit) 29 } 30 ifr_ifru; 31 }; 32 33 #define ifr_name ifr_ifrn.ifrn_name 34 #define ifr_hwaddr ifr_ifru.ifru_hwaddr 35 #define ifr_addr ifr_ifru.ifru_addr 36 #define ifr_netmask ifr_ifru.ifru_netmask 37 #define ifr_flags ifr_ifru.ifru_flags 38 #define ifr_mtu ifr_ifru.ifru_mtu 39 40 #endif 41 42 #if ( !defined(WIN32) && !defined(HAVE_LINUX_IF_TUN_H) ) || \ 43 ( defined(OPTION_W32_CTCI) ) 44 45 /* Ioctl defines */ 46 #define TUNSETNOCSUM _IOW('T', 200, int) 47 #define TUNSETDEBUG _IOW('T', 201, int) 48 #define TUNSETIFF _IOW('T', 202, int) 49 #define TUNSETPERSIST _IOW('T', 203, int) 50 #define TUNSETOWNER _IOW('T', 204, int) 51 52 /* TUNSETIFF ifr flags */ 53 #define IFF_TUN 0x0001 54 #define IFF_TAP 0x0002 55 #define IFF_NO_PI 0x1000 56 #define IFF_ONE_QUEUE 0x2000 57 58 #endif 59 60 #if !defined(HAVE_NET_IF_H) 61 /* Standard interface flags. */ 62 #define IFF_UP 0x1 /* interface is up */ 63 #define IFF_BROADCAST 0x2 /* broadcast address valid */ 64 #define IFF_LOOPBACK 0x8 /* is a loopback net */ 65 #define IFF_NOTRAILERS 0x20 /* avoid use of trailers */ 66 #define IFF_RUNNING 0x40 /* resources allocated */ 67 #define IFF_PROMISC 0x100 /* receive all packets */ 68 #define IFF_MULTICAST 0x1000 /* Supports multicast */ 69 #endif 70 71 // -------------------------------------------------------------------- 72 // Definition of the control request structure 73 // -------------------------------------------------------------------- 74 75 #define HERCIFC_CMD "hercifc" // Interface config command 76 #if defined(__FreeBSD__) 77 #define HERCTUN_DEV "/dev/tun" // Default TUN control dev 78 #else 79 #define HERCTUN_DEV "/dev/net/tun" // Default TUN/TAP char dev 80 #endif 81 82 typedef struct _CTLREQ 83 { 84 long iType; 85 int iProcID; 86 unsigned long int iCtlOp; 87 char szIFName[IFNAMSIZ]; 88 union 89 { 90 struct ifreq ifreq; 91 #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__SOLARIS__) 92 struct rtentry rtentry; 93 #endif 94 } 95 iru; 96 } 97 CTLREQ, *PCTLREQ; 98 99 #define CTLREQ_SIZE sizeof( CTLREQ ) 100 #define CTLREQ_OP_DONE 0 101 102 #endif // __HERCIFC_H_ 103 104 #endif // #if defined(NEED_HERCIFC_H) 105