1/* 2 * Routines for managing persistent storage of port mappings, etc. 3 * 4 * Copyright (C) 2014, Broadcom Corporation. All Rights Reserved. 5 * 6 * Permission to use, copy, modify, and/or distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 * 18 * $Id: nvparse.h 465779 2014-03-28 09:48:53Z $ 19 */ 20 21#ifndef _nvparse_h_ 22#define _nvparse_h_ 23 24/* 256 entries per list */ 25#ifndef MAX_NVPARSE 26#define MAX_NVPARSE 16 27#endif 28 29/* Maximum number of Traffic Management rules */ 30#define MAX_NUM_TRF_MGMT_RULES 10 31 32/* 802.11u venue name */ 33#define VENUE_LANGUAGE_CODE_SIZE 3 34#define VENUE_NAME_SIZE 255 35 36 37#define BCM_DECODE_ANQP_MCC_LENGTH 3 38#define BCM_DECODE_ANQP_MNC_LENGTH 3 39 40#define BCM_DECODE_ANQP_MAX_OI_LENGTH 15 41#define BCM_DECODE_ANQP_MAX_URL_LENGTH 128 42 43/* WAN info - link status */ 44#define HSPOT_WAN_LINK_STATUS_SHIFT 0 45#define HSPOT_WAN_LINK_STATUS_MASK (0x03 << HSPOT_WAN_LINK_STATUS_SHIFT) 46#define HSPOT_WAN_LINK_UP 0x01 47#define HSPOT_WAN_LINK_DOWN 0x02 48#define HSPOT_WAN_LINK_TEST 0x03 49 50/* WAN info - symmetric link */ 51#define HSPOT_WAN_SYMMETRIC_LINK_SHIFT 2 52#define HSPOT_WAN_SYMMETRIC_LINK_MASK (0x01 << HSPOT_WAN_SYMMETRIC_LINK_SHIFT) 53#define HSPOT_WAN_SYMMETRIC_LINK 0x01 54#define HSPOT_WAN_NOT_SYMMETRIC_LINK 0x00 55 56/* WAN info - at capacity */ 57#define HSPOT_WAN_AT_CAPACITY_SHIFT 3 58#define HSPOT_WAN_AT_CAPACITY_MASK (0x01 << HSPOT_WAN_AT_CAPACITY_SHIFT) 59#define HSPOT_WAN_AT_CAPACITY 0x01 60#define HSPOT_WAN_NOT_AT_CAPACITY 0x00 61 62/* Passpoint release numbers */ 63#define HSPOT_RELEASE_1 0 64#define HSPOT_RELEASE_2 1 65 66/* OSU method */ 67#define HSPOT_OSU_METHOD_OMA_DM 0 68#define HSPOT_OSU_METHOD_SOAP_XML 1 69 70#define BCM_DECODE_HSPOT_ANQP_MAX_OPERATOR_NAME 4 71 72#define NVRAM_MAX_VAL_LEN (2 * 1024) 73 74#define ICONPATH "/bin/" 75#define LANG_ZXX "zxx" 76#define ENGLISH "eng" 77 78typedef struct { 79 uint8 langLen; 80 char lang[VENUE_LANGUAGE_CODE_SIZE + 1]; /* null terminated */ 81 uint8 nameLen; 82 char name[VENUE_NAME_SIZE + 1]; /* null terminated */ 83} oper_name_t; 84 85typedef struct { 86 uint8 encoding; 87 uint8 nameLen; 88 char name[VENUE_NAME_SIZE + 1]; /* null terminated */ 89} nai_home_realm_t; 90 91typedef struct 92{ 93 uint8 langLen; 94 char lang[VENUE_LANGUAGE_CODE_SIZE + 1]; /* null terminated */ 95 uint8 nameLen; 96 char name[VENUE_NAME_SIZE + 1]; /* null terminated */ 97} venue_name_t; 98 99typedef struct 100{ 101 char mcc[BCM_DECODE_ANQP_MCC_LENGTH + 1]; 102 char mnc[BCM_DECODE_ANQP_MNC_LENGTH + 1]; 103} plmn_name_t; 104 105typedef struct 106{ 107 uint8 oiLen; 108 uint8 oi[BCM_DECODE_ANQP_MAX_OI_LENGTH]; 109} oui_name_t; 110 111typedef struct 112{ 113 uint8 type; 114 uint16 urlLen; 115 uint8 url[BCM_DECODE_ANQP_MAX_URL_LENGTH + 1]; /* null terminated */ 116} net_auth_t; 117 118typedef struct { 119 uint8 linkStatus; 120 uint8 symmetricLink; 121 uint8 atCapacity; 122 uint32 dlinkSpeed; 123 uint32 ulinkSpeed; 124 uint8 dlinkLoad; 125 uint8 ulinkLoad; 126 uint16 lmd; 127 uint32 dlinkAvailable; 128 uint32 ulinkAvailable; 129} wan_metrics_t; 130 131#define BCM_DECODE_AUTH_PARAM_TYPE_UNKNOWN -1 132#define BCM_DECODE_AUTH_PARAM_TYPE_1 1 133#define BCM_DECODE_AUTH_PARAM_TYPE_2 2 134#define BCM_DECODE_AUTH_PARAM_TYPE_3 3 135 136#define BCM_DECODE_ANQP_MAX_AUTH_PARAM 16 137typedef struct 138{ 139 uint8 id; 140 uint8 len; 141 uint8 value[BCM_DECODE_ANQP_MAX_AUTH_PARAM]; 142} bcm_decode_anqp_auth_t; 143 144#define BCM_DECODE_ANQP_MAX_AUTH 4 145typedef struct 146{ 147 uint8 eapMethod; 148 uint8 authCount; 149 bcm_decode_anqp_auth_t auth[BCM_DECODE_ANQP_MAX_AUTH]; 150} bcm_decode_anqp_eap_method_t; 151 152#define REALM_INFO_LENGTH 1024 153#define BCM_DECODE_ANQP_MAX_REALM_LENGTH 255 154#define BCM_DECODE_ANQP_MAX_EAP_METHOD 4 155typedef struct 156{ 157 uint8 encoding; 158 uint8 realmLen; 159 uint8 realm[BCM_DECODE_ANQP_MAX_REALM_LENGTH + 1]; /* null terminated */ 160 uint8 eapCount; 161 uint8 realmInfoLen; 162 uint8 realmInfo[REALM_INFO_LENGTH + 1]; /* null terminated */ 163 uint8 eapInfo[BCM_DECODE_ANQP_MAX_REALM_LENGTH + 1]; 164 bcm_decode_anqp_eap_method_t eap[BCM_DECODE_ANQP_MAX_EAP_METHOD]; 165} bcm_decode_anqp_nai_realm_data_t; 166 167#define BCM_DECODE_ANQP_MAX_REALM 16 168typedef struct 169{ 170 int isDecodeValid; 171 uint16 realmCount; 172 bcm_decode_anqp_nai_realm_data_t realm[BCM_DECODE_ANQP_MAX_REALM]; 173} realm_list_t; 174 175typedef struct { 176 uint8 langLen; 177 char lang[VENUE_LANGUAGE_CODE_SIZE + 1]; /* null terminated */ 178 uint8 nameLen; 179 char name[VENUE_NAME_SIZE + 1]; /* null terminated */ 180} bcm_decode_hspot_anqp_name_duple_t; 181 182#define BCM_DECODE_HSPOT_ANQP_MAX_OPERATOR_NAME 4 183typedef struct { 184 int isDecodeValid; 185 int numName; 186 bcm_decode_hspot_anqp_name_duple_t duple[BCM_DECODE_HSPOT_ANQP_MAX_OPERATOR_NAME]; 187} bcm_decode_hspot_anqp_operator_friendly_name_t; 188 189#define BCM_DECODE_HSPOT_ANQP_MAX_ICON_TYPE_LENGTH 128 190#define BCM_DECODE_HSPOT_ANQP_MAX_ICON_FILENAME_LENGTH 128 191typedef struct 192{ 193 uint16 width; 194 uint16 height; 195 char lang[VENUE_LANGUAGE_CODE_SIZE + 1]; /* null terminated */ 196 uint8 typeLength; 197 uint8 type[BCM_DECODE_HSPOT_ANQP_MAX_ICON_TYPE_LENGTH + 1]; /* null terminated */ 198 uint8 filenameLength; 199 char filename[BCM_DECODE_HSPOT_ANQP_MAX_ICON_FILENAME_LENGTH + 1]; 200} bcm_decode_hspot_anqp_icon_metadata_t; 201 202#define BCM_DECODE_HSPOT_ANQP_MAX_NAI_LENGTH 128 203#define BCM_DECODE_HSPOT_ANQP_MAX_METHOD_LENGTH 2 204#define BCM_DECODE_HSPOT_ANQP_MAX_ICON_METADATA_LENGTH 8 205#define BCM_DECODE_HSPOT_ANQP_MAX_URI_LENGTH 128 206#define FRIENDLY_NAME_INFO_LENGTH 2048 207typedef struct 208{ 209 bcm_decode_hspot_anqp_operator_friendly_name_t name; 210 uint8 uriLength; 211 uint8 uri[BCM_DECODE_HSPOT_ANQP_MAX_URI_LENGTH + 1]; /* null terminated */ 212 uint8 methodLength; 213 uint8 method[BCM_DECODE_HSPOT_ANQP_MAX_METHOD_LENGTH]; 214 int iconMetadataCount; 215 bcm_decode_hspot_anqp_icon_metadata_t iconMetadata[ 216 BCM_DECODE_HSPOT_ANQP_MAX_ICON_METADATA_LENGTH]; 217 uint8 naiLength; 218 uint8 nai[BCM_DECODE_HSPOT_ANQP_MAX_NAI_LENGTH + 1]; /* null terminated */ 219 bcm_decode_hspot_anqp_operator_friendly_name_t desc; 220 char nameInfo[FRIENDLY_NAME_INFO_LENGTH + 1]; 221 char descInfo[FRIENDLY_NAME_INFO_LENGTH + 1]; 222 char iconInfo[FRIENDLY_NAME_INFO_LENGTH + 1]; 223} bcm_decode_hspot_anqp_osu_provider_t; 224 225#define BCM_DECODE_HSPOT_ANQP_MAX_OSU_SSID_LENGTH 255 226#define BCM_DECODE_HSPOT_ANQP_MAX_OSU_PROVIDER 16 227typedef struct 228{ 229 int isDecodeValid; 230 uint8 osuSsidLength; 231 uint8 osuSsid[BCM_DECODE_HSPOT_ANQP_MAX_OSU_SSID_LENGTH + 1]; /* null terminated */ 232 uint8 osuProviderCount; 233 bcm_decode_hspot_anqp_osu_provider_t osuProvider[BCM_DECODE_HSPOT_ANQP_MAX_OSU_PROVIDER]; 234} osu_provider_list_t; 235 236/* 20 DSCP + 0x0 default */ 237#define MAX_NUM_TRF_MGMT_DWM_RULES 21 238 239#if !defined(AUTOFW_PORT_DEPRECATED) 240/* 241 * Automatic (application specific) port forwards are described by a 242 * netconf_app_t structure. A specific outbound connection triggers 243 * the expectation of one or more inbound connections which may be 244 * optionally remapped to a different port range. 245 */ 246extern bool valid_autofw_port(const netconf_app_t *app); 247extern bool get_autofw_port(int which, netconf_app_t *app); 248extern bool set_autofw_port(int which, const netconf_app_t *app); 249extern bool del_autofw_port(int which); 250#endif /* !AUTOFW_PORT_DEPRECATED */ 251 252/* 253 * Persistent (static) port forwards are described by a netconf_nat_t 254 * structure. On Linux, a netconf_filter_t that matches the target 255 * parameters of the netconf_nat_t should also be added to the INPUT 256 * and FORWARD tables to ACCEPT the forwarded connection. 257 */ 258extern bool valid_forward_port(const netconf_nat_t *nat); 259extern bool get_forward_port(int which, netconf_nat_t *nat); 260extern bool set_forward_port(int which, const netconf_nat_t *nat); 261extern bool del_forward_port(int which); 262 263/* 264 * Client filters are described by two netconf_filter_t structures that 265 * differ in match.src.ipaddr alone (to support IP address ranges) 266 */ 267extern bool valid_filter_client(const netconf_filter_t *start, const netconf_filter_t *end); 268extern bool get_filter_client(int which, netconf_filter_t *start, netconf_filter_t *end); 269extern bool set_filter_client(int which, const netconf_filter_t *start, 270 const netconf_filter_t *end); 271extern bool del_filter_client(int which); 272 273#ifdef __CONFIG_URLFILTER__ 274/* 275 * URL filters are described by two netconf_urlfilter_t structures that 276 * differ in match.src.ipaddr alone (to support IP address ranges) 277 */ 278extern bool valid_filter_url(const netconf_urlfilter_t *start, const netconf_urlfilter_t *end); 279extern bool get_filter_url(int which, netconf_urlfilter_t *start, netconf_urlfilter_t *end); 280extern bool set_filter_url(int which, const netconf_urlfilter_t *start, 281 const netconf_urlfilter_t *end); 282extern bool del_filter_url(int which); 283#endif /* __CONFIG_URLFILTER__ */ 284 285extern bool valid_trf_mgmt_port(const netconf_trmgmt_t *trmgmt); 286extern bool set_trf_mgmt_port(char *prefix, int which, const netconf_trmgmt_t *trmgmt); 287extern bool get_trf_mgmt_port(char *prefix, int which, netconf_trmgmt_t *trmgmt); 288extern bool del_trf_mgmt_port(char *prefix, int which); 289 290extern bool set_trf_mgmt_dwm(char *prefix, int which, const netconf_trmgmt_t *trmgmt); 291extern bool get_trf_mgmt_dwm(char *prefix, int which, netconf_trmgmt_t *trmgmt); 292extern bool del_trf_mgmt_dwm(char *prefix, int which); 293 294/* 295* WPA/WDS per link configuration. Parameters after 'auth' are 296* authentication algorithm dependant: 297* 298* When auth is "psk", the parameter list is: 299* 300* bool get_wds_wsec(int unit, int which, char *mac, char *role, 301* char *crypto, char *auth, char *ssid, char *passphrase); 302*/ 303extern bool get_wds_wsec(int unit, int which, char *mac, char *role, 304 char *crypto, char *auth, ...); 305extern bool set_wds_wsec(int unit, int which, char *mac, char *role, 306 char *crypto, char *auth, ...); 307extern bool del_wds_wsec(int unit, int which); 308 309/* Conversion routine for deprecated variables */ 310extern void convert_deprecated(void); 311 312#endif /* _nvparse_h_ */ 313