1 /*------------------------------------------------------------------------------ 2 * Project: NC 3 * File: nc_types.h 4 * Description: Network Configuration library header file 5 * 6 * Copyright (C) Nintendo. All rights reserved. 7 * These coded instructions, statements, and computer programs contain 8 * proprietary information of Nintendo of America Inc. and/or Nintendo 9 * Company Ltd., and are protected by Federal copyright law. They may 10 * not be disclosed to third parties or copied or duplicated in any form, 11 * in whole or in part, without the prior written consent of Nintendo. 12 * 13 *------------------------------------------------------------------------------ 14 */ 15 #ifndef __NC_TYPES_H__ 16 #define __NC_TYPES_H__ 17 18 #include <types.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /*---------------------------------------------------------------------------* 25 * 26 * Constants defined for this file 27 * -- #Defines -- 28 * 29 *---------------------------------------------------------------------------*/ 30 /* Default startup profile ID */ 31 #define NETCONF_DEFAULT_PROFILE 0 32 33 /* Number of profiles */ 34 #define NETCONF_PROFILE_COUNT 6 35 36 /* Values for startup profile ID */ 37 #define NETCONF_PROFILE0 0 38 #define NETCONF_PROFILE1 1 39 #define NETCONF_PROFILE2 2 40 #define NETCONF_PROFILE3 3 41 #define NETCONF_PROFILE4 4 42 #define NETCONF_PROFILE5 5 43 44 /* Values for state */ 45 #define NETCONF_ADMIN_STATE_UNUSED 0 46 #define NETCONF_ADMIN_STATE_UP 1 47 #define NETCONF_ADMIN_STATE_DOWN 2 48 #define NETCONF_LINK_STATE_UP 1 49 #define NETCONF_LINK_STATE_DOWN 2 50 #define NETCONF_LINK_STATE_NEGOTIATE 3 51 #define NETCONF_OPER_STATE_UP 1 52 #define NETCONF_OPER_STATE_DOWN 2 53 54 /* Value for network interface */ 55 #define NETCONF_NIC_WIFI 0 56 #define NETCONF_NIC_ETH 1 57 58 /* Error */ 59 #define NETCONF_ERROR_OK (0) 60 #define NETCONF_ERROR_NG (-1) /* generic */ 61 #define NETCONF_ERROR_INVALID (-2) 62 #define NETCONF_ERROR_UNKNOWN (-3) 63 #define NETCONF_ERROR_RETRY (-4) 64 #define NETCONF_ERROR_NEEDINIT (-5) 65 #define NETCONF_ERROR_ADDR (-6) 66 #define NETCONF_ERROR_NETMASK (-7) 67 #define NETCONF_ERROR_NEXTHOP (-8) 68 #define NETCONF_ERROR_IF_STATE (-9) 69 #define NETCONF_ERROR_CONFIG_METHOD (-10) 70 #define NETCONF_ERROR_SSID_LEN (-11) 71 #define NETCONF_ERROR_KEYLEN (-12) 72 #define NETCONF_ERROR_KEYID (-13) 73 #define NETCONF_ERROR_PRIVACY_MODE (-14) 74 #define NETCONF_ERROR_CONFIG_FILE (-15) 75 #define NETCONF_ERROR_CONFIG_FORMAT_INVALID (-16) 76 #define NETCONF_ERROR_MCP (-17) 77 #define NETCONF_ERROR_NAMESERVER (-18) 78 #define NETCONF_ERROR_IF_INDEX (-19) 79 #define NETCONF_ERROR_SPEED (-20) 80 #define NETCONF_ERROR_DUPLEX (-21) 81 #define NETCONF_ERROR_NEGOTIATION (-22) 82 #define NETCONF_ERROR_PROFILE_NUMBER (-23) 83 #define NETCONF_ERROR_MTU (-24) 84 #define NETCONF_ERROR_VALID_FLAG (-25) 85 #define NETCONF_ERROR_PROXY_STATE (-26) 86 #define NETCONF_ERROR_PROXY_HOST (-27) 87 #define NETCONF_ERROR_PROXY_PORT (-28) 88 #define NETCONF_ERROR_USBETH_NOT_FOUND (-29) 89 #define NETCONF_ERROR_PROXY_AUTH_TYPE (-30) 90 #define NETCONF_ERROR_SSID_STRING (-31) 91 #define NETCONF_ERROR_PROXY_NO_HOSTS (-32) 92 #define NETCONF_ERROR_PROXY_USERNAME (-33) 93 #define NETCONF_ERROR_PROXY_PASSWORD (-34) 94 95 96 /* Wi-Fi configuration methods */ 97 #define NETCONF_METHOD_MANUAL (0) 98 #define NETCONF_METHOD_WPS (1) 99 #define NETCONF_METHOD_USBAP (2) /* Not supported */ 100 #define NETCONF_METHOD_AOSS (3) 101 #define NETCONF_METHOD_RAKURAKU (4) 102 103 /* Privacy-related Definitions */ 104 #define NETCONF_PRIVACY_MODE_NONE (0x0000) /* No encryption */ 105 #define NETCONF_PRIVACY_MODE_WEP40 (0x0001) /* WEP ( RC4 40bit ) encryption */ 106 #define NETCONF_PRIVACY_MODE_WEP104 (0x0002) /* WEP ( RC4 104bit ) encryption */ 107 #define NETCONF_PRIVACY_MODE_WPA2_PSK_TKIP (0x0003) /* WPA2-PSK ( TKIP ) encryption */ 108 #define NETCONF_PRIVACY_MODE_WPA_PSK_TKIP (0x0004) /* WPA-PSK ( TKIP ) encryption */ 109 #define NETCONF_PRIVACY_MODE_WPA2_PSK_AES (0x0005) /* WPA2-PSK ( AES ) encryption */ 110 #define NETCONF_PRIVACY_MODE_WPA_PSK_AES (0x0006) /* WPA-PSK ( AES ) encryption */ 111 #define NETCONF_PRIVACY_MODE_STATIC_AES (0x0007) /* UDS mode only */ 112 #define NETCONF_PRIVACY_MODE_WEP (0x0008) /* WEP encryption */ 113 114 /* SSID length */ 115 #define NETCONF_SSID_SIZE 32 116 117 /* USB-Ethernet dongle links speed */ 118 #define NETCONF_ETH_LINK_SPEED_10M 10 119 #define NETCONF_ETH_LINK_SPEED_100M 100 120 121 /* USB-Ethernet dongle duplex mode */ 122 #define NETCONF_ETH_LINK_HALF_DUPLEX 1 123 #define NETCONF_ETH_LINK_FULL_DUPLEX 2 124 125 /* USB-Ethernet dongle negotiation mode */ 126 #define NETCONF_ETH_AUTO_NEGOTIATION_OFF 1 127 #define NETCONF_ETH_AUTO_NEGOTIATION_ON 2 128 129 /* Default MTU */ 130 #define NETCONF_DEFAULT_INTERFACE_MTU 1400 131 #define NETCONF_MAX_MTU 1500 132 #define NETCONF_MIN_MTU 576 133 134 /* Proxy */ 135 #define NETCONF_DEFAULT_PROXY_PORT 80 136 #define NETCONF_MAX_PROXY_PORT_NUMBER 65535 137 #define NETCONF_MIN_PROXY_PORT_NUMBER 1 138 #define NETCONF_MAX_PROXY_HOST_LEN 128 139 #define NETCONF_MAX_NO_PROXY_HOSTS_LEN 128 140 #define NETCONF_MAX_PROXY_USERNAME_LEN 128 141 #define NETCONF_MAX_PROXY_PASSWORD_LEN 64 142 143 #define NETCONF_PROXY_STATE_DISABLE 0 /* Disable proxy */ 144 #define NETCONF_PROXY_STATE_ENABLE 1 /* Enable proxy */ 145 146 /*---------------------------------------------------------------------------* 147 * 148 * Data types defined for this file 149 * -- Structs, Typedefs, Enums -- 150 * 151 *---------------------------------------------------------------------------*/ 152 /* Common primitives */ 153 typedef s32 NETCONF_ERROR; 154 typedef s32 NETCONF_PROFILE; 155 typedef u16 NETCONF_NIC; 156 typedef u16 NETCONF_IFSTATE; 157 typedef u16 NETCONF_PROXY_STATE; 158 159 /* Configuration method to obtain address */ 160 typedef enum { 161 NETCONF_ADDR_DHCP, 162 NETCONF_ADDR_STICKY, 163 NETCONF_ADDR_MANUAL 164 } netconf_addr_method_t; 165 166 /* Profile state */ 167 typedef enum { 168 NETCONF_PROFILE_STATE_DEFAULT, /* Profile is not configured */ 169 NETCONF_PROFILE_STATE_CONFIGURED /* Profile is configured */ 170 } NETCONF_PROFILE_STATE; 171 172 /* Valid flag state */ 173 typedef enum { 174 NETCONF_PROFILE_VALID_FLAG_INVALID, /* Valid flag is invalid state */ 175 NETCONF_PROFILE_VALID_FLAG_VALID /* Valid flag is valid state */ 176 } NETCONF_PROFILE_VALID_FLAG; 177 178 /* Last link error reason */ 179 typedef enum { 180 NETCONF_LAST_WIFI_LINK_ERROR_OK, /* No error */ 181 NETCONF_LAST_WIFI_LINK_ERROR_ASSOC_FAILED, /* Credentials were invalid or air link trouble */ 182 NETCONF_LAST_WIFI_LINK_ERROR_REASSOC_DENIED, /* !!This error is not used anymore!! */ 183 NETCONF_LAST_WIFI_LINK_ERROR_KEY_INVALID, /* Disassociated by the AP due to the wrong passphrase for WPA */ 184 NETCONF_LAST_WIFI_LINK_ERROR_SELF_DISCONNECT, /* Internally the unit asked to be disconnected */ 185 NETCONF_LAST_WIFI_LINK_ERROR_INVALID_WD_MODE, /* Cannot process the request because WD is in the UDS mode */ 186 NETCONF_LAST_WIFI_LINK_ERROR_LOST_AP_SIGNAL, /* Lost AP signal for some reason */ 187 NETCONF_LAST_WIFI_LINK_ERROR_UNKNOWN /* Unknown error */ 188 } NETCONF_LAST_WIFI_LINK_ERROR; 189 190 /* Proxy authentication type */ 191 typedef enum { 192 NETCONF_PROXY_AUTH_TYPE_NONE = 0x00, /* Nothing */ 193 NETCONF_PROXY_AUTH_TYPE_BASIC = 0x01, /* Basic */ 194 NETCONF_PROXY_AUTH_TYPE_DIGEST = 0x02, /* Digest */ 195 NETCONF_PROXY_AUTH_TYPE_NTLM = 0x08, /* NTLM */ 196 NETCONF_PROXY_AUTH_TYPE_ANY = (NETCONF_PROXY_AUTH_TYPE_BASIC | /* All fine types set */ 197 NETCONF_PROXY_AUTH_TYPE_DIGEST | 198 NETCONF_PROXY_AUTH_TYPE_NTLM) 199 } NETCONF_PROXY_AUTH_TYPE; 200 201 /*---------------------------------------------------------------------------* 202 structure 203 *---------------------------------------------------------------------------*/ 204 PACKED_STRUCT_BEGIN 205 206 /* Proxy settings structure */ 207 typedef struct proxy_cfg_ 208 { 209 u16 use_proxy; 210 u16 port; 211 NETCONF_PROXY_AUTH_TYPE auth_type; 212 u8 host[NETCONF_MAX_PROXY_HOST_LEN]; 213 u8 username[NETCONF_MAX_PROXY_USERNAME_LEN]; 214 u8 password[NETCONF_MAX_PROXY_PASSWORD_LEN]; 215 u8 noproxy_hosts[NETCONF_MAX_NO_PROXY_HOSTS_LEN]; 216 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) proxy_cfg_t; 217 218 /* WiFi privacy structure */ 219 typedef struct wifi_privacy_ 220 { 221 u16 mode; 222 u8 reserved[ 2 ]; 223 union { 224 struct { 225 u16 key_id; 226 u8 key[4][5]; 227 u8 reserved[2]; 228 } wep40; 229 struct { 230 u16 key_id; 231 u8 key[4][13]; 232 u8 reserved[2]; 233 } wep104; 234 struct { 235 u16 key_len; 236 u8 key[64]; 237 u8 reserved[2]; 238 } tkip; 239 struct { 240 u16 key_len; 241 u8 key[64]; 242 u8 reserved[2]; 243 } aes; 244 } s; 245 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) wifi_privacy_t; 246 247 /* Access point config structure */ 248 typedef struct wifi_AP_cfg_ 249 { 250 u8 ssid[NETCONF_SSID_SIZE]; 251 u16 ssidlength; 252 u8 reserved[2]; 253 wifi_privacy_t privacy; 254 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) wifi_AP_cfg_t; 255 256 /* WiFi config structure */ 257 typedef struct wifi_cfg_ 258 { 259 u16 config_method; 260 u8 reserved[2]; 261 union { 262 /* Only manual method is supported today */ 263 wifi_AP_cfg_t manual; 264 wifi_AP_cfg_t wps; 265 } config; 266 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) wifi_cfg_t; 267 268 /* Ethernet config structure */ 269 typedef struct eth_cfg_ 270 { 271 u16 speed; 272 u16 duplex; 273 u16 negotiation; 274 u8 reserved[2]; 275 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) eth_cfg_t; 276 277 /* Per interface IPv4 configuration */ 278 typedef struct ipv4_info_ 279 { 280 u32 mode; /* disable | manual | DHCP | DHCP sticky */ 281 /* 'disable' has meaning only when we have IPv6 */ 282 u32 addr; /* IP address of device */ 283 u32 netmask; /* Subnet mask */ 284 u32 nexthop; /* Default gateway */ 285 u32 ns1, ns2; /* DNS servers */ 286 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) ipv4_info_t; 287 288 /* Per interface configuration */ 289 typedef struct ifconfig_ 290 { 291 u16 if_index; /* Network interface index */ 292 u16 if_state; /* Same as admin state */ 293 u32 if_mtu; /* MTU value for the interface */ 294 ipv4_info_t ipv4_info; 295 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) ifconfig_t; 296 297 /* Network configuration profile */ 298 typedef struct netconf_profile_ 299 { 300 ifconfig_t wl0; /* for the wireless interface */ 301 wifi_cfg_t wifi; /* config for wl0 interface */ 302 303 ifconfig_t eth0; /* for the ethernet interface */ 304 eth_cfg_t eth_cfg; /* config for eth0 interface */ 305 306 proxy_cfg_t proxy_cfg; /* config for http proxy */ 307 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) netconf_profile_t; 308 309 /* Structure of network monitoring */ 310 typedef struct netconf_ifstate_ 311 { 312 u16 if_state; /* ifAdminStatus */ 313 u16 link_state; /* link state */ 314 u16 oper_state; /* ifOperStatus */ 315 u8 reserved[2]; 316 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) netconf_ifstate_t; 317 318 /* Structure of profile states */ 319 typedef struct netconf_profile_states_ 320 { 321 NETCONF_PROFILE_STATE profile_state[NETCONF_PROFILE5+1]; 322 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) netconf_profile_states_t; 323 324 /* Structures of valid flags */ 325 typedef struct netconf_valid_flags_ 326 { 327 NETCONF_PROFILE_VALID_FLAG valid_flag[NETCONF_PROFILE5+1]; 328 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) netconf_valid_flags_t; 329 330 /* AOSS config structure */ 331 typedef struct aoss_config_ 332 { 333 wifi_AP_cfg_t config[4]; 334 } PACKED_STRUCT_ATTRIBUTE ATTRIB_STRUCT_ALIGN(4) aoss_cfg_t; 335 336 PACKED_STRUCT_END 337 338 /* Definitions for the compatibility. do not use it, these definitions will be removed. */ 339 #define NETCOND_MAX_MTU NETCONF_MAX_MTU 340 #define NETOONF_MAX_PROXY_PASSWORD_LEN NETCONF_MAX_PROXY_PASSWORD_LEN 341 #define NETCONF_LAST_WIFI_LINK_ERROR_UNKOWN NETCONF_LAST_WIFI_LINK_ERROR_UNKNOWN 342 #define NETCONF_PROXY_AUTH_TPYE_ANY NETCONF_PROXY_AUTH_TYPE_ANY 343 344 #ifdef __cplusplus 345 } 346 #endif 347 348 #endif // __NC_H__ 349