b.liu | d440f9f | 2025-04-18 10:44:31 +0800 | [diff] [blame^] | 1 | #ifndef __QL_NET_COMMON_H__ |
| 2 | #define __QL_NET_COMMON_H__ |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | /** Maximum length of the APN name. */ |
| 6 | #define QL_NET_MAX_APN_NAME_LEN 150 |
| 7 | |
| 8 | /** Maximum length of the APN user name. */ |
| 9 | #define QL_NET_MAX_APN_USERNAME_LEN 127 |
| 10 | |
| 11 | /** Maximum length of the password. */ |
| 12 | #define QL_NET_MAX_APN_PASSWORD_LEN 127 |
| 13 | |
| 14 | /** Maximum address length. */ |
| 15 | #define QL_NET_MAX_ADDR_LEN 46 |
| 16 | |
| 17 | // 1 - 7 (ASR 1806) |
| 18 | #define QL_NET_MAX_DATA_CALL_NUM 7 |
| 19 | |
| 20 | /** Maximum lenth of the device name. */ |
| 21 | #define QL_NET_MAX_NAME_LEN 32 |
| 22 | #define QL_NET_MAX_RECONNECT_INTERVAL_LEN 20 |
| 23 | #define QL_NET_MAX_APN_ID QL_NET_MAX_DATA_CALL_NUM |
| 24 | #define QL_NET_USB_DEV_MAX_NUM QL_NET_MAX_DATA_CALL_NUM |
| 25 | |
| 26 | #define QL_NET_MAX_LANHOST_NUM 18 |
| 27 | #define QL_NET_MAX_LANHOST_NAME_LEN 64 |
| 28 | |
| 29 | typedef enum { |
| 30 | QL_NET_DATA_CALL_STATUS_MIN = -1, |
| 31 | QL_NET_DATA_CALL_STATUS_NONE = 0x0, /**< Call state is NONE */ |
| 32 | QL_NET_DATA_CALL_STATUS_CREATED = 0x1, /**< Call state was created */ |
| 33 | QL_NET_DATA_CALL_STATUS_IDLE = 0x2, /**< Call state is IDLE. */ |
| 34 | QL_NET_DATA_CALL_STATUS_CONNECTING = 0x3, /**< Call is connecting. */ |
| 35 | QL_NET_DATA_CALL_STATUS_PARTIAL_V4_CONNECTED = 0x4, /**< V4V6 mode, V4 is connected. */ |
| 36 | QL_NET_DATA_CALL_STATUS_PARTIAL_V6_CONNECTED = 0x5, /**< V4V6 mode, V6 is connected. */ |
| 37 | QL_NET_DATA_CALL_STATUS_CONNECTED = 0x6, /**< Call is connected. */ |
| 38 | QL_NET_DATA_CALL_STATUS_DISCONNECTED = 0x7, /**< Call is disconnected. */ |
| 39 | QL_NET_DATA_CALL_STATUS_ERROR = 0x8, /**< Error ocurred */ |
| 40 | QL_NET_DATA_CALL_STATUS_DELETED = 0x9, /**< Data Call was deleted */ |
| 41 | QL_NET_DATA_CALL_STATUS_MAX |
| 42 | } QL_NET_DATA_CALL_STATUS_E; |
| 43 | |
| 44 | #define IS_QL_NET_DATA_CALL_STATUS_VALID(status) \ |
| 45 | ((status)>QL_NET_DATA_CALL_STATUS_MIN && (status)<QL_NET_DATA_CALL_STATUS_MAX) |
| 46 | |
| 47 | typedef enum { |
| 48 | QL_NET_DATA_CALL_RECONNECT_MODE_MIN = -1, |
| 49 | QL_NET_DATA_CALL_RECONNECT_DISABLE = 0x0, |
| 50 | QL_NET_DATA_CALL_RECONNECT_NORMAL = 0x1, /**< Normal mode, interval defined by reconnect_interval[0] in sec */ |
| 51 | QL_NET_DATA_CALL_RECONNECT_MODE_1 = 0x2, /**< Mode 1, time interval list defined by reconnect_interval in sec, |
| 52 | if the time interval list is T1,T2,T3...Tn, the reconnection interval is T1,T2,T3...Tn,Tn,Tn...Tn */ |
| 53 | QL_NET_DATA_CALL_RECONNECT_MODE_2 = 0x3, /**< Mode 2, time interval list defined by reconnect_interval in sec, |
| 54 | if the time interval list is T1,T2,T3...Tn, the reconnection interval is T1,T2,T3..Tn,T1,T2,T3..Tn,T1.. */ |
| 55 | QL_NET_DATA_CALL_RECONONECT_MODE_MAX |
| 56 | } QL_NET_DATA_CALL_RECONNECT_MODE_E; |
| 57 | |
| 58 | #define IS_QL_NET_DATA_CALL_RECONNECT_MODE_VALID(mode) \ |
| 59 | ((mode)>QL_NET_DATA_CALL_RECONNECT_MODE_MIN && (mode)<QL_NET_DATA_CALL_RECONONECT_MODE_MAX) |
| 60 | |
| 61 | typedef enum { |
| 62 | QL_NET_IP_VER_MIN = -0, |
| 63 | QL_NET_IP_VER_V4 = 0x1, |
| 64 | QL_NET_IP_VER_V6 = 0x2, |
| 65 | QL_NET_IP_VER_V4V6 = 0x3, |
| 66 | QL_NET_IP_VER_MAX |
| 67 | } QL_NET_IP_VER_E; |
| 68 | |
| 69 | #define IS_QL_NET_IP_VER_VALID(ver) \ |
| 70 | ((ver)>QL_NET_IP_VER_MIN && (ver)<QL_NET_IP_VER_MAX) |
| 71 | |
| 72 | typedef enum { |
| 73 | QL_NET_AUTH_PREF_MIN = -1, |
| 74 | QL_NET_AUTH_PREF_PAP_CHAP_NOT_ALLOWED = 0, |
| 75 | QL_NET_AUTH_PREF_PAP_ONLY_ALLOWED = 1, |
| 76 | QL_NET_AUTH_PREF_CHAP_ONLY_ALLOWED = 2, |
| 77 | QL_NET_AUTH_PREF_PAP_CHAP_BOTH_ALLOWED = 3, |
| 78 | QL_NET_AUTH_PREF_MAX |
| 79 | } QL_NET_AUTH_PREF_E; |
| 80 | |
| 81 | #define IS_QL_NET_AUTH_PREF_VALID(pref) \ |
| 82 | ((pref)>QL_NET_AUTH_PREF_MIN && (pref)<QL_NET_AUTH_PREF_MAX) |
| 83 | |
| 84 | typedef enum { |
| 85 | QL_NET_USB_DEV_TYPE_MIN = 0, |
| 86 | QL_NET_USB_DEV_TYPE_ECM = 1, |
| 87 | QL_NET_USB_DEV_TYPE_NCM = 2, |
| 88 | QL_NET_USB_DEV_TYPE_RNDIS = 3, |
| 89 | QL_NET_USB_DEV_TYPE_MBIM = 4, |
| 90 | QL_NET_USB_DEV_TYPE_MAX |
| 91 | } QL_NET_USB_DEV_TYPE_E; |
| 92 | |
| 93 | typedef enum { |
| 94 | QL_NET_USB_DEV_STATUS_MIN = -1, |
| 95 | QL_NET_USB_DEV_STATUS_NONE = 0, |
| 96 | QL_NET_USB_DEV_STATUS_LINKDOWN = 1, |
| 97 | QL_NET_USB_DEV_STATUS_LINKUP = 2, |
| 98 | QL_NET_USB_DEV_STATUS_MAX |
| 99 | } QL_NET_USB_DEV_STATUS_E; |
| 100 | |
| 101 | typedef enum { |
| 102 | QL_NET_NF_CMD_FORMAT_MIN = -1, |
| 103 | QL_NET_NF_CMD_FORMAT_COMMON = 0, |
| 104 | QL_NET_NF_CMD_FORMAT_JSON = 1, |
| 105 | QL_NET_NF_CMD_FORMAT_MAX |
| 106 | } QL_NET_NF_CMD_FORMAT_E; |
| 107 | |
| 108 | typedef enum { |
| 109 | QL_LANHOST_EVENT_ADD = 0, |
| 110 | QL_LANHOST_EVENT_DEL, |
| 111 | QL_LANHOST_EVENT_UPDATE, |
| 112 | } QL_LANHOST_EVENT_TYPE_E; |
| 113 | |
| 114 | typedef struct { |
| 115 | char device[QL_NET_MAX_NAME_LEN]; |
| 116 | QL_NET_USB_DEV_TYPE_E type; |
| 117 | QL_NET_USB_DEV_STATUS_E status; |
| 118 | int8_t inst_id; |
| 119 | } ql_net_usb_dev_t; |
| 120 | |
| 121 | typedef struct { |
| 122 | char addr[QL_NET_MAX_ADDR_LEN]; /**< IPV4 address format string */ |
| 123 | char netmask[QL_NET_MAX_ADDR_LEN]; /**< Subnet mask, format */ |
| 124 | uint8_t subnet_bits; /**< Subnet mask bit number, exp: |
| 125 | 255.255.255.0 is 24, 255.255.0.0 is 16 */ |
| 126 | char gateway[QL_NET_MAX_ADDR_LEN]; /**< Gateway, IPV4 address*/ |
| 127 | char dnsp[QL_NET_MAX_ADDR_LEN]; /**< Primary DNS server address. */ |
| 128 | char dnss[QL_NET_MAX_ADDR_LEN]; /**< Secondary DNS server address. */ |
| 129 | } ql_net_addr_t; |
| 130 | |
| 131 | typedef struct |
| 132 | { |
| 133 | char addr[QL_NET_MAX_ADDR_LEN]; /**< IPV6 address format string */ |
| 134 | char prefix[QL_NET_MAX_ADDR_LEN]; |
| 135 | int32_t prefix_bits; |
| 136 | char gateway[QL_NET_MAX_ADDR_LEN]; /**< Gateway address. */ |
| 137 | char dnsp[QL_NET_MAX_ADDR_LEN]; /**< Primary DNS server address. */ |
| 138 | char dnss[QL_NET_MAX_ADDR_LEN]; /**< Secondary DNS server address. */ |
| 139 | } ql_net_addr6_t; |
| 140 | |
| 141 | typedef struct |
| 142 | { |
| 143 | char addr[QL_NET_MAX_ADDR_LEN]; /**< IPV4 address format string */ |
| 144 | char macaddr[18]; /**< MAC address, format: XX:XX:XX:XX:XX:XX */ |
| 145 | char name[QL_NET_MAX_LANHOST_NAME_LEN]; /**< hostname */ |
| 146 | char ifname[QL_NET_MAX_NAME_LEN]; /**< device name */ |
| 147 | int uptime; /**< online time in sec */ |
| 148 | } ql_lanhost_t; |
| 149 | |
| 150 | #endif |
| 151 | |