b.liu | 5fa9e77 | 2023-11-23 18:00:55 +0800 | [diff] [blame] | 1 | /* |
| 2 | * qser_data_call.h |
| 3 | * |
| 4 | * QSER data call header file. |
| 5 | * |
| 6 | * Author : lb |
| 7 | * Date : 2023/11/23 13:32:37 |
| 8 | */ |
| 9 | #ifndef _QSER_DATA_CALL_H |
| 10 | #define _QSER_DATA_CALL_H |
| 11 | #include "mbtk_type.h" |
| 12 | |
| 13 | #define QSER_APN_MAX_LIST 8 |
| 14 | #define QSER_APN_NAME_SIZE 150 |
| 15 | #define QSER_APN_USERNAME_SIZE 127 |
| 16 | #define QSER_APN_PASSWORD_SIZE 127 |
| 17 | |
| 18 | typedef enum { |
| 19 | QSER_DATA_CALL_ERROR_NONE = 0, |
| 20 | QSER_DATA_CALL_ERROR_INVALID_PARAMS, |
| 21 | } qser_data_call_error_e; |
| 22 | |
| 23 | typedef enum { |
| 24 | QSER_DATA_CALL_TYPE_IPV4 = 0, /*!< IPv4 call. */ |
| 25 | QSER_DATA_CALL_TYPE_IPV6, /*!< IPv6 call. */ |
| 26 | QSER_DATA_CALL_TYPE_IPV4V6, /*!< IPv4 and IPv6 call (Only used call start or stop). */ |
| 27 | } qser_data_call_ip_family_e; |
| 28 | |
| 29 | typedef enum { |
| 30 | QSER_APN_PDP_TYPE_IPV4 = 0, |
| 31 | QSER_APN_PDP_TYPE_PPP, |
| 32 | QSER_APN_PDP_TYPE_IPV6, |
| 33 | QSER_APN_PDP_TYPE_IPV4V6, |
| 34 | } qser_apn_pdp_type_e; |
| 35 | |
| 36 | typedef enum { |
| 37 | QSER_APN_AUTH_PROTO_DEFAULT = 0, |
| 38 | QSER_APN_AUTH_PROTO_NONE, |
| 39 | QSER_APN_AUTH_PROTO_PAP, |
| 40 | QSER_APN_AUTH_PROTO_CHAP, |
| 41 | QSER_APN_AUTH_PROTO_PAP_CHAP, |
| 42 | } qser_apn_auth_proto_e; |
| 43 | |
| 44 | typedef struct { |
| 45 | char profile_idx; /*!< UMTS/CMDA profile ID. */ |
| 46 | bool reconnect; /*!< Whether to re-dial after disconnecting the network.*/ |
| 47 | qser_data_call_ip_family_e ip_family; /*!< IP version. */ |
| 48 | char cdma_username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */ |
| 49 | char cdma_password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */ |
| 50 | } qser_data_call_s; |
| 51 | |
| 52 | struct v4_info { |
| 53 | char name[16]; /*!< Interface Name. */ |
| 54 | qser_data_call_state_e state; /*!< The dial status. */ |
| 55 | bool reconnect; /*!< re-dial flag. */ |
| 56 | struct v4_address_status addr; /*!< IPv4 IP Address information. */ |
| 57 | struct pkt_stats stats; /*!< IPv4 statics */ |
| 58 | }; |
| 59 | |
| 60 | struct v6_info { |
| 61 | char name[16]; /*!< Interface Name. */ |
| 62 | qser_data_call_state_e state; /*!< The dial status. */ |
| 63 | bool reconnect; /*!< re-dial flag. */ |
| 64 | struct v6_address_status addr; /*!< IPv6 IP Address information. */ |
| 65 | struct pkt_stats stats; /*!< IPv6 statics */ |
| 66 | }; |
| 67 | |
| 68 | typedef struct { |
| 69 | char profile_idx; /*!< UMTS/CDMA profile ID. */ |
| 70 | qser_data_call_ip_family_e ip_family; /*!< IP version. */ |
| 71 | struct v4_info v4; /*!< IPv4 information */ |
| 72 | struct v6_info v6; /*!< IPv6 information */ |
| 73 | } qser_data_call_info_s; |
| 74 | |
| 75 | typedef struct { |
| 76 | unsigned char profile_idx; /*!< UMTS/CDMA profile ID. */ |
| 77 | qser_apn_pdp_type_e pdp_type; /*!< Packet Data Protocol (PDP) type specifies the type of data payload exchanged over the airlink when the packet data session is established with this profile. */ |
| 78 | qser_apn_auth_proto_e auth_proto; /*!< Authentication Protocol. */ |
| 79 | char apn_name[QSER_APN_NAME_SIZE]; /*!< A string parameter that is a logical name used to select the GGSN and external packet data network. */ |
| 80 | char username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */ |
| 81 | char password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */ |
| 82 | char apn_type[QSER_APN_NAME_SIZE]; /*The primary key of the apn table, cannot insert two apn information with the same apn_type*/ |
| 83 | } qser_apn_info_s; |
| 84 | |
| 85 | typedef struct { |
| 86 | qser_apn_pdp_type_e pdp_type; /*!< Packet Data Protocol (PDP) type specifies the type of data payload exchanged over the airlink when the packet data session is established with this profile. */ |
| 87 | qser_apn_auth_proto_e auth_proto; /*!< Authentication Protocol. */ |
| 88 | char apn_name[QSER_APN_NAME_SIZE]; /*!< A string parameter that is a logical name used to select the GGSN and external packet data network. */ |
| 89 | char username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */ |
| 90 | char password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */ |
| 91 | char apn_type[QSER_APN_NAME_SIZE]; /*The primary key of the apn table, cannot insert two apn information with the same apn_type*/ |
| 92 | } qser_apn_add_s; |
| 93 | |
| 94 | typedef struct { |
| 95 | int cnt; /*apn[] 数组中有效 apn 的数目 */ |
| 96 | qser_apn_info_s apn[QSER_APN_MAX_LIST]; |
| 97 | } qser_apn_info_list_s; |
| 98 | |
| 99 | typedef void (*qser_data_call_evt_cb_t)(qser_data_call_state_s *state); |
| 100 | |
| 101 | int qser_data_call_init(qser_data_call_evt_cb_t evt_cb); |
| 102 | |
| 103 | void qser_data_call_destroy(void); |
| 104 | |
| 105 | int qser_data_call_start(qser_data_call_s *data_call, qser_data_call_error_e *err); |
| 106 | |
| 107 | int qser_data_call_stop(char profile_idx, qser_data_call_ip_family_e ip_family, qser_data_call_error_e *err); |
| 108 | |
| 109 | int qser_data_call_info_get(char profile_idx,qser_data_call_ip_family_e ip_family,qser_data_call_info_s *info,qser_data_call_error_e *err); |
| 110 | |
| 111 | int qser_apn_set(qser_apn_info_s *apn); |
| 112 | |
| 113 | int qser_apn_get(unsigned char profile_idx, qser_apn_info_s *apn); |
| 114 | |
| 115 | int qser_apn_add(qser_apn_add_s *apn, unsigned char *profile_idx); |
| 116 | |
| 117 | int qser_apn_del(unsigned char profile_idx); |
| 118 | |
| 119 | int qser_apn_get_list(qser_apn_info_list_s *apn_list); |
| 120 | |
| 121 | #endif /* _QSER_DATA_CALL_H */ |