blob: f86bd7d80a53319f80cefb44a3c2eb7be36ac368 [file] [log] [blame]
/******************************************************************************
*(C) Copyright 2015 Marvell International Ltd.
* All Rights Reserved
******************************************************************************/
#ifndef __CHL_DB__
#define __CHL_DB__
#include <libubox/list.h>
#include <stdbool.h>
#include <cm.h>
#include "chl.h"
#include "chl_util.h"
#define CHL_PDP_DNS4P 0x000000001
#define CHL_PDP_DNS4S 0x000000002
#define CHL_PDP_DNS6P 0x000000004
#define CHL_PDP_DNS6S 0x000000008
#define IPV4_STR "IP"
#define IPV6_STR "IPv6"
#define IPV4V6_STR "IPv4v6"
#define MAX_IPV4_STR 16
#define MAX_IPV6_STR 64
#define MAX_APN_STR 32
#define MAX_CLIENT_STR 16
#define MAX_IFNAME_STR 16
#define MAX_EXT_PARAM_LEN 32
#define CHL_DFLT_MASK "255.255.255.255"
#define CHL_IPV6_DFLT_PREF 64
#define EXTP_RADIO 0x00000001
#define EXTP_PROF 0x00000002
#define EXTP_UNAME 0x00000004
#define EXTP_PWD 0x00000008
#define EXTP_AUTH 0x00000010
enum chl_ipv6_state {
CHL_IPV6_IDLE,
CHL_IPV6_SEARCHING,
CHL_IPV6_FOUND,
};
struct extra_param {
char data_profile[MAX_EXT_PARAM_LEN];
char username[MAX_EXT_PARAM_LEN];
char password[MAX_EXT_PARAM_LEN];
unsigned int auth_type;
unsigned int radio_tech;
unsigned int flags;
};
struct reg_param {
char *name;
char *apn;
int ip_type;
bool internet;
struct extra_param *ext;
};
struct chl_pdp {
int id;
int rt_idx;
struct list_head clients;
struct list_head list;
char apn[MAX_APN_STR];
struct extra_param extra;
char ipv4[MAX_IPV4_STR];
char dns4p[MAX_IPV4_STR];
char dns4s[MAX_IPV4_STR];
char netmask[MAX_IPV4_STR];
char ipv6[MAX_IPV6_STR];
char dns6p[MAX_IPV6_STR];
char dns6s[MAX_IPV6_STR];
unsigned int prefix_len;
char gw[MAX_IPV6_STR];
char gb6addr[MAX_IPV6_STR];
unsigned int cid;
unsigned int type;
unsigned int dns;
unsigned int open_count;
unsigned int client_count;
bool untracked;
bool autoconf_pdp;
bool req_gw;
enum chl_nw_status nw_status;
enum chl_ipv6_state ipv6_state;
RIL_DataCallFailCause last_ril_status;
};
struct chl_client {
char name[MAX_CLIENT_STR];
int id;
unsigned int type;
bool req_open;
bool req_gw;
struct list_head list;
struct chl_pdp *pdp;
int rt_idx;
};
unsigned int pdp_match_ext_param(struct reg_param *rp, struct chl_pdp *pdp);
struct chl_pdp *chl_db_add_pdp(struct reg_param *rp);
struct chl_pdp *chl_db_get_pdp_by_id(int id);
struct chl_pdp *chl_db_get_pdp_by_cid(int cid);
struct chl_client *chl_db_add_client(struct reg_param *rp, struct chl_pdp *pdp);
struct chl_client *chl_db_get_client_by_id(int id);
struct chl_pdp *chl_db_get_autoconf_pdp(struct chl_pdp *except);
struct chl_pdp *chl_db_get_pdp_by_apn(char *apn);
bool chl_db_pdp_has_clients(struct chl_pdp *pdp);
void chl_db_del_client(struct chl_client *cl);
void chl_db_clear_pdp(struct chl_pdp *pdp, int nw_status);
void chl_db_del_pdp(struct chl_pdp *pdp);
void chl_db_status(void);
void chl_db_take_over_pdp(struct chl_pdp *pdp);
void chl_db_update_pdp(Ubus_Data_Call_Response *rsp, struct chl_pdp *pdp,
enum chl_nw_status nw_status);
struct list_head *chl_db_get_list(void);
char *cl_type_to_str(int type);
char *ipv6_state_to_str(int state);
#endif