blob: afe3fc4773bb369c56d75abaf712d625a7f215fe [file] [log] [blame]
/*------------------------------------------------------------
(C) Copyright [2006-2014] Marvell International Ltd.
All Rights Reserved
------------------------------------------------------------*/
#ifndef __DIALER_TASK_H__
#define __DIALER_TASK_H__
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
#include <assert.h>
#include <stdbool.h>
#include <linux/if.h>
#include <linux/sockios.h>
#include <sys/ioctl.h>
// for nezha3
#include <libubox/blob.h>
#include <libubox/blobmsg.h>
#include <libubox/ustream.h>
#include <libubus.h>
#include <ubusmsg.h>
#include <uci.h>
#include <rilutil.h>
#include <telephony/ril.h>
#include <telephony/cm.h>
#include "cm_def.h"
#include "cm_service.h"
#include "cm_func.h"
//////////////////////////////////////////////////////////////////////
// Structs
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// Global definitions
//////////////////////////////////////////////////////////////////////
#define UCI_CFG_FILE "wan" /* /etc/config/ */
#define MAX_TRY_NUM_ESM_FALSE 5
typedef RIL_Data_Call_Response_v11 RIL_Data_Call_Response;
typedef int *FILE_ID;
#define MAX_RETRY_TIME_COMMON 1
#define MAX_RETRY_TIME_23G 1
#define MAX_RETRY_TIME_LTE 1
#define MAX_CID_LIMITATION 16
#define PDP_FAIL_GET_GLOBALIP (0xffff-1)
#define PDP_FAIL_BACKOFF_TIME 0x010d
#define PDP_DIAL_STATUS_OK 0
#define CCINET_IOCTL_AQUIRE SIOCDEVPRIVATE
#define CCINET_IOCTL_RELEASE (SIOCDEVPRIVATE+1)
#define CCINET_IOCTL_SET_V6_CID (SIOCDEVPRIVATE+2)
#define CCINET_IOCTL_SET_V4_CID (SIOCDEVPRIVATE+6)
#define CCINET_IOCTL_IF_LAN_ENABLE (SIOCDEVPRIVATE+7)
#define CCINET_IOCTL_IF_LAN_DISABLE (SIOCDEVPRIVATE+8)
#define PDP_FAIL_NO_CCINET (-10)
#define PDP_FAIL_DHCP_SERVER_ERR_PIPE (-11)
typedef enum {
DOWN = 0,
UP = 1,
FORCEUP = 2,
} if_command;
typedef enum {
IPV4V6 = 0,
IPV4 = 1,
IPV6 = 2,
TYPE_ETH = 3,
} pdp_type;
typedef struct {
uint32_t network_interface_id; //wan interface store IPV4 IP/DNS/GW and IPV6 local link IP, wan6 interface is for DHCP6v and RA for IPV6
uint32_t network_id;
uint32_t ril_id;
uint32_t cm_id;
uint32_t sim_id;
uint32_t odhcpd_id;
} cm_ubus_ctx_id;
typedef struct {
int datalen;
void * data;
} cm_query_datalist;
struct vzw_extra_info
{
int apn_class;
int max_conn_time;
int max_conn;
int wait_time;
};
//////////////////////////////////////////////////////////////////////
// Prototypes
//////////////////////////////////////////////////////////////////////
int dialer_init();
void showPFInfo(PacketFilterInfo * PF_info);
void showConContext(CM_Connection_Context * Pdp);
void showDataCallResponse(Data_Call_Response_List * DcRsp);
void FreeDataCallRsponseList(Data_Call_Response_List * pList);
void CreateDataCallResponseList(CM_Connection_Context *setupCtx, Ubus_Data_Call_Response * SrcData, int SrcDataLen, int cid);
unsigned char setUnknownPpdCause(unsigned char setVaue);
unsigned char getUnknownPpdCause(void);
void clearUnknownPpdCause(void);
bool getErrorIndFlag();
void clearErrorIndFlag();
void GetIMSI_complete_cb();
void GetIMSI_data_cb(struct ubus_request *req, int type, struct blob_attr *msg);
void GetIMSI();
Data_Call_Response *StartDialer(CM_Connection_Context * ConInfo);
void dialer_MT_function_data_cb(struct ubus_request *req, int type, struct blob_attr *msg);
void dialer_MT_function(CM_Connection_Context * ConInfo);
Data_Call_Response *StartMTDialer(CM_Connection_Context * ConInfo);
void StopDialer_data_cb(struct ubus_request *req, int type, struct blob_attr *msg);
void StopDialer(int cid);
void DialerUpdateTFT_data_cb(struct ubus_request *req, int type, struct blob_attr *msg);
void DialerUpdateTFT(PacketFilterInfo * PF_info);
void dialer_function(CM_Connection_Context * ConInfo);
void SetupDataCall_data_cb(struct ubus_request *req, int type, struct blob_attr *msg);
void SetInitialAttachAPN_data_cb(struct ubus_request *req, int type, struct blob_attr *msg);
void SetInitialAttachAPN(Apn_Info * apninfo, bool saveNVM);
void SetupDataCall(CM_Connection_Context * ConInfo);
void SetupDedicatedDataCall(CM_Connection_Context * ConInfo);
void ConfigIPInfo(int sync);
void DeleteIPInfo(int cid, pdp_type protocol);
void QueryDataCall_data_cb(struct ubus_request *req, int type, struct blob_attr *msg);
void QueryDataCall(CM_Connection_Context *ctx);
void QueryDataCall_Indnotify();
void QuerySimStatus_cb(struct ubus_request *req, int type, struct blob_attr *msg);
int QuerySimStatus();
int SetCPPowerInd(int value);
void dialer_query_defaultdatacall();
int send_if_command(int cid, if_command cmd, pdp_type protocol);
int up_down_br_lan(if_command cmd, char* name, int sync);
int reload_network(int sync);
int reload_odhcpd();
int WaitForSimReady(void);
int RilIdReady(void);
int init_apn_list(void);
int reinit_apn_list(void);
const char * RilRequestToString(int request);
void configure_pdp_para(Ubus_Data_Call_Response *src, Data_Call_Response_List *dst, char *item);
void QueryDataCall_Indnotify_complete_cb(struct ubus_request *req, int ret);
bool is_vzw_sim(char *imsi);
void fill_data_profile_by_class(int apn_class, RIL_DataProfileInfo *data_profile);
int config_vzw_apn_list(void);
void send_disconnect_2host(int cid, pdp_type ip_type);
bool address_v6_null(int v6_address[]);
int get_imsi(int sync, int switch_sim_done);
Mnc_Apn *get_mnc_apn_info();
int cm_get_current_cid(void);
bool ccinet_ipv6_global_ready(int cid, int query_seconds);
Data_Call_Response_List *get_data_call_response_list(void);
int get_current_cid(void);
bool dialer_pdp_cause_new_apn(void);
int getInterfaceAddr6(const char *ifname, char *ipaddress, size_t ipsize);
void set_ipv4_only_allowed(int flag);
int get_ipv4_only_allowed();
void set_ipv6_only_allowed(int flag);
int get_ipv6_only_allowed();
bool is_ctcc_sim(char *imsi);
bool is_telcel_sim(char *imsi);
void start_2hours_redial_timer(void);
void stop_2hours_redial_timer(void);
#endif