1 #ifndef LIBRARIES_IFCONFIG_H 2 #define LIBRARIES_IFCONFIG_H 3 4 /* 5 ifconfig.library include (V50) 6 7 Copyright © 2003 The MorphOS Development Team, All Rights Reserved. 8 */ 9 10 #ifndef EXEC_TYPES_H 11 #include <exec/types.h> 12 #endif 13 14 #ifndef EXEC_LISTS_H 15 #include <exec/lists.h> 16 #endif 17 18 #ifndef DOS_RDARGS_H 19 #include <dos/rdargs.h> 20 #endif 21 22 #ifndef UTILITY_TAGITEM_H 23 #include <utility/tagitem.h> 24 #endif 25 26 #pragma pack(2) 27 28 29 /* 30 * Name and version of the library described by this header 31 */ 32 #define IFCONFIGNAME "ifconfig.library" 33 #define IFCONFIGVERSION 51 34 35 /* 36 * Interface type definitions. Note that these are BIT positions, and only 37 * one of the bits is set in ifc_type field of if_config. 38 */ 39 #define IFCT_SANA 1 40 #define IFCT_SLIP 2 41 #define IFCT_PPP 4 42 #define IFCT_PPTP 8 43 #define IFCT_LOOPBACK 16 44 45 /* 46 * Information on each configuration item. This is used internally by the 47 * library, and returned by the IfConfigGetTagInfo(). 48 * Note that this structure is READ ONLY when returned by IfConfigGetTagInfo(), 49 * and it may grow in future (in such vase the library version number will 50 * grow, too). 51 */ 52 struct ifc_confitem { 53 const char * ci_Names; 54 const char * ci_CanonicalName;/* canonical form of the name */ 55 Tag ci_TagValue; /* data type is encoded into the tag value */ 56 UWORD ci_TypesAllowed; /* mask of allowed interface types */ 57 UWORD ci_Flags; /* misc flags, defined below */ 58 }; 59 60 61 /* 62 * ci_Flags definitions 63 */ 64 #define CIF_REQUIRED (1<<0) 65 #define CIF_NOT (1<<1) /* switch defaults to 1, turn to 0 */ 66 67 /* 68 * Tag item values for the interface configuration information 69 * 70 * Note that the name and type are parsed separately, and they do not 71 * have corresponding tag values. 72 */ 73 74 /* 75 * data type number bits 16 - 23 76 */ 77 #define IFTB_TYPE 16 /* starts from 16th bit */ 78 /* 79 * argument passing convention (bit 8 WITHIN type) 80 */ 81 #define IFTF_REF 0x80 /* not set == by value */ 82 #define IFTM_REF(tag) (((tag) >> IFTB_TYPE) & IFTF_REF) 83 #define IFTS_TYPE 0x7F /* mask after shift by IFTB_TYPE */ 84 #define IFTM_TYPE(tag) (((tag) >> IFTB_TYPE) & IFTS_TYPE) 85 #define IFTM_REFTYPE(tag) (((tag) >> IFTB_TYPE) & (IFTF_REF | IFTS_TYPE)) 86 /* 87 * Code (bits 0 - 15) 88 */ 89 #define IFTS_CODE 0xFFFF 90 #define IFTM_CODE(tag) ((tag) & SBTS_CODE) 91 92 /* 93 * Defined data types (tag value type on comments) 94 */ 95 96 #define CI_TYPE_TYPE 0 /* XXX - internal only */ 97 #define CI_TYPE_STRING (IFTF_REF | 1) /* null terminated string */ 98 #define CI_TYPE_LONG 2 /* long integer */ 99 #define CI_TYPE_SWITCH 3 /* boolean */ 100 #define CI_TYPE_HEXSTRING (IFTF_REF | 4) /* byte length + data */ 101 #define CI_TYPE_DOTNOT (IFTF_REF | 5) /* struct sockaddr_in */ 102 #define CI_LAST_TYPE 5 /* last type value */ 103 /* 104 * Macros to define the actual tag codes - one for each type 105 */ 106 #define IFTM_STRING(code) (TAG_USER | (CI_TYPE_STRING << IFTB_TYPE) | (code)) 107 #define IFTM_LONG(code) (TAG_USER | (CI_TYPE_LONG << IFTB_TYPE) | (code)) 108 #define IFTM_SWITCH(code) (TAG_USER | (CI_TYPE_SWITCH << IFTB_TYPE) | (code)) 109 #define IFTM_HEXSTRING(code) (TAG_USER | (CI_TYPE_HEXSTRING << IFTB_TYPE) | (code)) 110 #define IFTM_DOTNOT(code) (TAG_USER | (CI_TYPE_DOTNOT << IFTB_TYPE) | (code)) 111 112 /* 113 * The actual tag codes 114 */ 115 #define IF_Device IFTM_STRING( 1) /* Exec device name */ 116 #define IF_Unit IFTM_LONG( 2) /* Exec device unit */ 117 #define IF_HWAddress IFTM_HEXSTRING( 3) /* Sana-II HW-address */ 118 #define IF_IPType IFTM_LONG( 4) /* IP protocol type */ 119 #define IF_MTU IFTM_LONG( 5) /* (Transmit) MTU */ 120 #define IF_SerBaud IFTM_LONG( 6) /* Serial baud rate */ 121 #define IF_SerBufLen IFTM_LONG( 7) /* Serial read buffer length */ 122 #define IF_CD IFTM_SWITCH( 8) /* Serial flag: Carrier Detect */ 123 #define IF_7Wire IFTM_SWITCH( 9) /* Serial flag: CTS/RTS handshake */ 124 #define IF_EOFMode IFTM_SWITCH( 10) /* Serial flag: EOF-mode */ 125 #define IF_Shared IFTM_SWITCH( 11) /* Serial flag: Shared mode */ 126 #define IF_UseODU IFTM_SWITCH( 12) /* Serial flag: Use OwnDevUnit */ 127 #define IF_ARPType IFTM_LONG( 13) /* ARP protocol type */ 128 #define IF_IPReq IFTM_LONG( 14) /* # of IP read requests */ 129 #define IF_ARPReq IFTM_LONG( 15) /* # of ARP read requests */ 130 #define IF_WriteReq IFTM_LONG( 16) /* # of write requests */ 131 #define IF_Tracking IFTM_SWITCH( 17) /* Sana2: Type tracking */ 132 #define IF_QuickIO IFTM_SWITCH( 18) /* Sana2: QuickIO */ 133 #define IF_Filter IFTM_SWITCH( 19) /* Sana2: Use Filter Hook */ 134 #define IF_NoARP IFTM_SWITCH( 20) /* Flag: No ARP */ 135 #define IF_ARPHdr IFTM_LONG( 21) /* ?? */ 136 #define IF_P2P IFTM_SWITCH( 22) /* Flag: Point-to-point interface */ 137 #define IF_Simplex IFTM_SWITCH( 23) /* Flag: iface receives own bcasts */ 138 #define IF_Loopback IFTM_SWITCH( 24) /* Flag: iface is of loopback type */ 139 #define IF_Compress IFTM_SWITCH( 25) /* Slip flag: Compress headers */ 140 #define IF_NoICMP IFTM_SWITCH( 26) /* Slip flag: No ICMP traffic */ 141 #define IF_AutoComp IFTM_SWITCH( 27) /* Slip flag: Compress detection */ 142 #define IF_OnlineScript IFTM_STRING( 28) /* Serial: Dialing script */ 143 #define IF_OfflineScript IFTM_STRING( 29) /* Serial: Hangup script */ 144 #define IF_ReconnectScript IFTM_STRING( 30) /* Serial: Reconnect script */ 145 #define IF_IP IFTM_DOTNOT( 31) /* IP address of the interface */ 146 #define IF_Netmask IFTM_DOTNOT( 32) /* Netmask of the interface */ 147 #define IF_DestIP IFTM_DOTNOT( 33) /* Dest. IP addr of the iface */ 148 #define IF_Gateway IFTM_DOTNOT( 34) /* Def. gateway for this interface */ 149 #define IF_UseBootP IFTM_SWITCH( 35) /* Use BootP to configure iface */ 150 #define IF_AutoConfig IFTM_SWITCH( 36) /* Configure this iface on startup */ 151 #define IF_ConfigFileName IFTM_STRING( 37) /* Sana2 configuration file name */ 152 #define IF_ConfigFileContents IFTM_STRING( 38) /* Sana2 configuration contents */ 153 #define IF_DoOnline IFTM_SWITCH( 39) /* AmiTCP: put device online at start */ 154 #define IF_DoOffline IFTM_SWITCH( 40) /* AmiTCP: put device offline at end */ 155 #define IF_UseDHCP IFTM_SWITCH( 41) /* Use DHCP to configure iface */ 156 #define IF_DriverArgs IFTM_STRING( 42) /* Exec device flags used as a string */ 157 #define IF_MAXTAGS 42 /* # of defined tag codes */ 158 159 /* 160 * The interface configuration structure returned by the ifconfig_find(), 161 * if entry for the searched interface was found. 162 */ 163 struct ifconfig { 164 struct Node ifc_node; /* read only */ 165 char ifc_name[16]; /* IFNAMSIZ */ 166 LONG ifc_type; /* IFCT_SANA, IFCT_LOOPBACK, IFCT_SLIP, IFCT_PPP, IFCT_PPTP */ 167 struct TagItem * ifc_taglist; 168 UBYTE ifc_databuf[0]; /* private */ 169 }; 170 171 172 /* 173 * The ifconfig.library functions return dos error codes + some 174 * extended error codes. 175 * IfConfigStrError() should be used to convert these codes to 176 * english language text strings. 177 * 178 * The normal error code is in the lower word of the returned error code 179 * Upper half contains private information about the error. 180 * When comparing the error code to the defined values, the upper half must 181 * be masked away with the following macro 182 */ 183 184 #define IFCONFIG_ERROR(x) ((unsigned short)x) 185 186 /* extended IoErr codes */ 187 #define ERROR_IFCONFIG_BASE 1024 188 #define ERROR_TYPE_MUST_BE_FIRST 1024 189 #define ERROR_TYPE_NOT_KNOWN 1025 190 #define ERROR_OPTION_NOT_ALLOWED_FOR_TYPE 1026 191 #define ERROR_OPTION_NOT_KNOWN 1027 192 #define ERROR_IFCONFIG_MAX 1027 193 194 195 #pragma pack() 196 197 #endif /* !LIBRARIES_IFCONFIG_H */