b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame^] | 1 | #include <stdint.h> |
| 2 | //gsw include |
| 3 | |
| 4 | |
| 5 | #define GSW_HAL_SUCCESS 0 |
| 6 | #define GSW_HAL_FAIL -1 |
| 7 | #define GSW_HAL_MEM_INVAILD -2 |
| 8 | #define GSW_NW_OPERATION_NAME_LEN 128 |
| 9 | #define GSW_NW_PLMN_LEN 6 |
| 10 | #define GSW_NW_MCC_LEN 3 |
| 11 | #define GSW_NW_MNC_LEN 3 |
| 12 | #define GSW_NW_PARA_MAX_LEN 128 |
| 13 | #define GSW_MCC_MAX_LEN 16 |
| 14 | #define GSW_MNC_MAX_LEN 16 |
| 15 | #define GSW_APN_CHANNEL_MAX 10 |
| 16 | #define GSW_POXY_ADDR_MAX_LEN 64 |
| 17 | #define GSW_PDP_TYPE_MAX_LEN 16 |
| 18 | #define GSW_APN_MAX_LEN 65 |
| 19 | #define GSW_APN_ID_MAX_LEN 32 |
| 20 | #define GSW_APN_TYPE_MAX_LEN 50 |
| 21 | #define GSW_USR_MAX_LEN 16 |
| 22 | #define GSW_PWD_MAX_LEN 16 |
| 23 | #define GSW_AUTH_TYPE_MAX_LEN 50 |
| 24 | #define GSW_PROTOCO_MAX_LEN 64 |
| 25 | #define GSW_CARRIER_ID_MAX_LEN 64 |
| 26 | #define GSW_IFACE_NAME_MAX_LEN 50 |
| 27 | #define GSW_PDP_ADDR_MAX_LEN 64 |
| 28 | #define GSW_DNS_ADDR_MAX_LEN 64 |
| 29 | #define GSW_GETWAYS_ADDR_MAX_LEN 64 |
| 30 | #define GSW_RSP_MAX_LEN 256 |
| 31 | |
| 32 | typedef struct { |
| 33 | int handle; /**< data connection handle*/ |
| 34 | int cid; /**< data connection cid*/ |
| 35 | int state; /**< data connection state*/ |
| 36 | int fail_cause; /**< data connection fail cause*/ |
| 37 | char *type; /**< data connection type*/ |
| 38 | char *ifname; /**< ifname*/ |
| 39 | |
| 40 | char *v4_ip; /**< ipv4 address*/ |
| 41 | char *v4_pdns; /**< ipv4 pdns address*/ |
| 42 | char *v4_sdns; /**< ipv4 sdns address*/ |
| 43 | char *v4_gw; /**< ipv4 gateway address*/ |
| 44 | |
| 45 | char *v6_ip; /**< ipv6 address*/ |
| 46 | char *v6_pdns; /**< ipv6 gateway address*/ |
| 47 | char *v6_sdns; /**< ipv6 gateway address*/ |
| 48 | }Wan_State_ind_s; |
| 49 | |
| 50 | typedef struct { |
| 51 | char ip[GSW_PDP_ADDR_MAX_LEN]; /**< ip address */ |
| 52 | char pdns[GSW_DNS_ADDR_MAX_LEN]; /**< pdns address*/ |
| 53 | char sdns[GSW_DNS_ADDR_MAX_LEN]; /**< sdns address*/ |
| 54 | char gw[GSW_GETWAYS_ADDR_MAX_LEN]; /**< gate way address*/ |
| 55 | }V4_Addr_s; |
| 56 | |
| 57 | typedef struct { |
| 58 | char ip[GSW_PDP_ADDR_MAX_LEN]; /**< ip address*/ |
| 59 | char pdns[GSW_DNS_ADDR_MAX_LEN]; /**< pdns address*/ |
| 60 | char sdns[GSW_DNS_ADDR_MAX_LEN]; /**< sdns address*/ |
| 61 | }V6_Addr_s; |
| 62 | |
| 63 | typedef struct { |
| 64 | int handle; /**< data connection handle*/ |
| 65 | |
| 66 | /* req info */ |
| 67 | char mcc[GSW_MCC_MAX_LEN]; /**< apn mcc value*/ |
| 68 | char mnc[GSW_MNC_MAX_LEN]; /**< apn mnc value*/ |
| 69 | char apnid[GSW_APN_ID_MAX_LEN]; /**< apn id*/ |
| 70 | char apn[GSW_APN_MAX_LEN]; /**< apn name*/ |
| 71 | char apnType[GSW_APN_TYPE_MAX_LEN]; /**< apn type ipv4 ipv4v6 ipv6*/ |
| 72 | char usr[GSW_USR_MAX_LEN]; /**< apn usr name*/ |
| 73 | char pwd[GSW_PWD_MAX_LEN]; /**< apn password*/ |
| 74 | char authType[GSW_AUTH_TYPE_MAX_LEN]; /**< apn auth type*/ |
| 75 | char normalProtocol[GSW_PROTOCO_MAX_LEN]; /**< apn auth protoco*/ |
| 76 | char roamingProtocol[GSW_PROTOCO_MAX_LEN]; /**< apn auth protoco roaming*/ |
| 77 | char carrier[GSW_CARRIER_ID_MAX_LEN]; /**< carrier id*/ |
| 78 | |
| 79 | /* rsp */ |
| 80 | int cid; /**< data connection cid for mdm sdk*/ |
| 81 | int active; /**< pdn context active state: 2,actived; other,not active */ |
| 82 | char ifname[GSW_IFACE_NAME_MAX_LEN]; /**< if name of current datalink */ |
| 83 | int type; /**< data connection type*/ |
| 84 | V4_Addr_s v4; /**< ipv4 addr*/ |
| 85 | V6_Addr_s v6; /**< ipv6 addr*/ |
| 86 | int mtu; /**< mtu value*/ |
| 87 | |
| 88 | char out[GSW_RSP_MAX_LEN]; /**< sdk return value*/ |
| 89 | }Link_Info_s; |
| 90 | |
| 91 | typedef struct |
| 92 | { |
| 93 | uint64_t tx_pkts; /* the number of packet sent*/ |
| 94 | uint64_t tx_bytes; /* the number of packet sent bytes */ |
| 95 | uint64_t tx_dropped_pkts; /* the number of packet dropped by sent*/ |
| 96 | uint64_t rx_pkts; /* the number of packet received*/ |
| 97 | uint64_t rx_bytes; /* the number of packet receivedbytes */ |
| 98 | uint64_t rx_dropped_pkts; /* the number of packet dropped by received*/ |
| 99 | }gsw_data_pkt_stats; |
| 100 | |
| 101 | |
| 102 | typedef void (*gsw_data_call_evt_cb_t)(Wan_State_ind_s *linkState); |
| 103 | |
| 104 | /** |
| 105 | * @brief datacall sdk init |
| 106 | * @param [in] evt_cb callback function for data connection state change event |
| 107 | * call back; |
| 108 | * @retval 0: success |
| 109 | * @retval other: fail |
| 110 | */ |
| 111 | int gsw_data_call_init(gsw_data_call_evt_cb_t evt_cb); |
| 112 | |
| 113 | |
| 114 | /** |
| 115 | * @brief data_call sdk deinit |
| 116 | * @param |
| 117 | * @retval 0: success |
| 118 | * @retval other: fail |
| 119 | */ |
| 120 | int gsw_data_call_deinit(void); |
| 121 | |
| 122 | /** |
| 123 | * @brief set apn parameters for data call |
| 124 | * @param [in/out] LinkInf apn info for pub or private datacall |
| 125 | * inlcude apn name mcc mnc, passwork apnid type cid etc |
| 126 | * @retval 0: success |
| 127 | * @retval other: fail |
| 128 | */ |
| 129 | int gsw_data_call_set_apn(Link_Info_s *LinkInf); |
| 130 | |
| 131 | |
| 132 | /** |
| 133 | * @brief set apn parameters for data call |
| 134 | * @param [in] linkid data connetion link number |
| 135 | * @param [in/out] LinkInf link info req: apn info for pub or private datacall |
| 136 | * inlcude apn name mcc mnc, passwork apnid etc |
| 137 | * resp: data call link state ipaddress type etc |
| 138 | * @retval 0: success |
| 139 | * @retval other: fail |
| 140 | */ |
| 141 | int gsw_data_call_connect(int linkid, Link_Info_s *LinkInf); |
| 142 | |
| 143 | |
| 144 | /** |
| 145 | * @brief set apn parameters for data call |
| 146 | * @param [in] linkid |
| 147 | * @param [in/out] LinkInf link info req: apn info for pub or private datacall |
| 148 | * inlcude apn name mcc mnc, passwork apnid etc |
| 149 | * resp: data call link state ipaddress type etc |
| 150 | * @retval 0: success |
| 151 | * @retval other: fail |
| 152 | */ |
| 153 | int gsw_data_call_disconnect(int linkid, Link_Info_s *LinkInf); |
| 154 | |
| 155 | |
| 156 | |
| 157 | /* |
| 158 | * @brief get mobile operator name |
| 159 | @param [in] linkid apn id |
| 160 | @param [out] data_pkt obtian actual data call network card data traffic |
| 161 | @retval 0: success |
| 162 | @retval 0: other: fail |
| 163 | */ |
| 164 | int gsw_get_data_call_pkt_stats(int linkid, gsw_data_pkt_stats *data_pkt); |
| 165 | |
| 166 | |
| 167 | |