blob: fbeddad224d8df858e609c4c01af7d9c9b9d1cc3 [file] [log] [blame]
/*
* qser_data_call.h
*
* QSER data call header file.
*
* Author : lb
* Date : 2023/11/23 13:32:37
*/
#ifndef _QSER_DATA_CALL_H
#define _QSER_DATA_CALL_H
#include "mbtk_type.h"
#define QSER_APN_MAX_LIST 8
#define QSER_APN_NAME_SIZE 150
#define QSER_APN_USERNAME_SIZE 127
#define QSER_APN_PASSWORD_SIZE 127
typedef enum {
QSER_DATA_CALL_ERROR_NONE = 0,
QSER_DATA_CALL_ERROR_INVALID_PARAMS,
} qser_data_call_error_e;
typedef enum {
QSER_DATA_CALL_TYPE_IPV4 = 0, /*!< IPv4 call. */
QSER_DATA_CALL_TYPE_IPV6, /*!< IPv6 call. */
QSER_DATA_CALL_TYPE_IPV4V6, /*!< IPv4 and IPv6 call (Only used call start or stop). */
} qser_data_call_ip_family_e;
typedef enum {
QSER_APN_PDP_TYPE_IPV4 = 0,
QSER_APN_PDP_TYPE_PPP,
QSER_APN_PDP_TYPE_IPV6,
QSER_APN_PDP_TYPE_IPV4V6,
} qser_apn_pdp_type_e;
typedef enum {
QSER_APN_AUTH_PROTO_DEFAULT = 0,
QSER_APN_AUTH_PROTO_NONE,
QSER_APN_AUTH_PROTO_PAP,
QSER_APN_AUTH_PROTO_CHAP,
QSER_APN_AUTH_PROTO_PAP_CHAP,
} qser_apn_auth_proto_e;
typedef struct {
char profile_idx; /*!< UMTS/CMDA profile ID. */
bool reconnect; /*!< Whether to re-dial after disconnecting the network.*/
qser_data_call_ip_family_e ip_family; /*!< IP version. */
char cdma_username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
char cdma_password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
} qser_data_call_s;
struct v4_info {
char name[16]; /*!< Interface Name. */
qser_data_call_state_e state; /*!< The dial status. */
bool reconnect; /*!< re-dial flag. */
struct v4_address_status addr; /*!< IPv4 IP Address information. */
struct pkt_stats stats; /*!< IPv4 statics */
};
struct v6_info {
char name[16]; /*!< Interface Name. */
qser_data_call_state_e state; /*!< The dial status. */
bool reconnect; /*!< re-dial flag. */
struct v6_address_status addr; /*!< IPv6 IP Address information. */
struct pkt_stats stats; /*!< IPv6 statics */
};
typedef struct {
char profile_idx; /*!< UMTS/CDMA profile ID. */
qser_data_call_ip_family_e ip_family; /*!< IP version. */
struct v4_info v4; /*!< IPv4 information */
struct v6_info v6; /*!< IPv6 information */
} qser_data_call_info_s;
typedef struct {
unsigned char profile_idx; /*!< UMTS/CDMA profile ID. */
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. */
qser_apn_auth_proto_e auth_proto; /*!< Authentication Protocol. */
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. */
char username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
char password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
char apn_type[QSER_APN_NAME_SIZE]; /*The primary key of the apn table, cannot insert two apn information with the same apn_type*/
} qser_apn_info_s;
typedef struct {
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. */
qser_apn_auth_proto_e auth_proto; /*!< Authentication Protocol. */
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. */
char username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
char password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
char apn_type[QSER_APN_NAME_SIZE]; /*The primary key of the apn table, cannot insert two apn information with the same apn_type*/
} qser_apn_add_s;
typedef struct {
int cnt; /*apn[] 数组中有效 apn 的数目 */
qser_apn_info_s apn[QSER_APN_MAX_LIST];
} qser_apn_info_list_s;
typedef void (*qser_data_call_evt_cb_t)(qser_data_call_state_s *state);
int qser_data_call_init(qser_data_call_evt_cb_t evt_cb);
void qser_data_call_destroy(void);
int qser_data_call_start(qser_data_call_s *data_call, qser_data_call_error_e *err);
int qser_data_call_stop(char profile_idx, qser_data_call_ip_family_e ip_family, qser_data_call_error_e *err);
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);
int qser_apn_set(qser_apn_info_s *apn);
int qser_apn_get(unsigned char profile_idx, qser_apn_info_s *apn);
int qser_apn_add(qser_apn_add_s *apn, unsigned char *profile_idx);
int qser_apn_del(unsigned char profile_idx);
int qser_apn_get_list(qser_apn_info_list_s *apn_list);
#endif /* _QSER_DATA_CALL_H */