blob: 6dcf807ac619e8907cd6f63e78fe64b6475a282b [file] [log] [blame]
b.liu87afc4c2024-08-14 17:33:45 +08001/*
2* ril_info.h
3*
4* MBTK Ril information header.
5*
6* Author : lb
7* Date : 2024/8/6 10:53:08
8*/
9#ifndef _RIL_INFO_H
10#define _RIL_INFO_H
11#include <stdio.h>
12
13#include "mbtk_type.h"
14#include "mbtk_ril_api.h"
15#include "mbtk_log.h"
16#include "atchannel.h"
17#include "at_tok.h"
18#include "mbtk_list.h"
b.liu472cfaf2024-12-19 19:08:19 +080019#ifdef MBTK_DEV_INFO_VERSION_2
20#include "mbtk_device_v2.h"
21#else
b.liu87afc4c2024-08-14 17:33:45 +080022#include "mbtk_device.h"
b.liu472cfaf2024-12-19 19:08:19 +080023#endif
b.liu87afc4c2024-08-14 17:33:45 +080024#include "mbtk_queue.h"
b.liu15f456b2024-10-31 20:16:06 +080025#include "mbtk_ril.h"
b.liu87afc4c2024-08-14 17:33:45 +080026
27#define SOCK_CLIENT_MAX 100
28#define EPOLL_LISTEN_MAX 100
b.liu87afc4c2024-08-14 17:33:45 +080029
b.liu10a34102024-08-20 20:36:24 +080030#if 0
b.liu87afc4c2024-08-14 17:33:45 +080031#define MBTK_APN_PROP "persist.mbtk.apn"
b.liu10a34102024-08-20 20:36:24 +080032#else
33#define MBTK_APN_PROP "/etc/mbtk/apn"
34#endif
35
b.liu87afc4c2024-08-14 17:33:45 +080036#define MBTK_DEF_ROUTE_CID "persist.mbtk.def_route_cid"
b.liubcf86c92024-08-19 19:48:28 +080037#define MBTK_DEF_DNS_CID "persist.mbtk.def_dns_cid"
b.liu87afc4c2024-08-14 17:33:45 +080038
39typedef struct
40{
41 int fd;
b.liub171c9a2024-11-12 19:23:29 +080042 ATPortType_enum port;
b.liu87afc4c2024-08-14 17:33:45 +080043
44 uint32 ind_num;
45 uint16 ind_register[IND_REGISTER_MAX];
46} sock_cli_info_t;
47
48typedef struct
49{
50 sock_cli_info_t *cli_info;
51 void* pack; // Refro to : ril_msg_pack_info_t
52} ril_msg_queue_info_t;
53
54typedef struct {
55 mbtk_radio_state_enum radio_state;
56 mbtk_sim_state_enum sim_state;
b.liu15f456b2024-10-31 20:16:06 +080057 mbtk_sim_card_type_enum sim_type;
b.liu87afc4c2024-08-14 17:33:45 +080058 int sock_listen_fd;
59 int epoll_fd;
b.liub171c9a2024-11-12 19:23:29 +080060 bool at_process[ATPORTTYPE_NUM];
b.liu87afc4c2024-08-14 17:33:45 +080061
62 list_node_t *sock_client_list; // Refor to : sock_cli_info_t
b.liub171c9a2024-11-12 19:23:29 +080063 mbtk_queue_node_t msg_queue[ATPORTTYPE_NUM]; // Refor to : ril_msg_queue_info_t
64 pthread_cond_t msg_cond[ATPORTTYPE_NUM];
65 pthread_mutex_t msg_mutex[ATPORTTYPE_NUM];
b.liu87afc4c2024-08-14 17:33:45 +080066} ril_info_t;
67
68typedef struct {
69 bool band_set_success;
70 mbtk_modem_band_area_enum band_area;
71 mbtk_band_info_t band_support;
72} ril_band_info_t;
73
b.liu87afc4c2024-08-14 17:33:45 +080074/*
750: unknown
761: available
772: current
783: forbidden
79*/
80typedef enum
81{
82 MBTK_NET_AVIL_STATE_UNKNOWN = 0,
83 MBTK_NET_AVIL_STATE_AVAILABLE,
84 MBTK_NET_AVIL_STATE_CURRENT,
85 MBTK_NET_AVIL_STATE_FORBIDDEN
86} mbtk_net_avil_state_enum;
87
88typedef enum {
89 RIL_DATA_CALL_STATE_STOP,
90 RIL_DATA_CALL_STATE_STARTED,
91 RIL_DATA_CALL_STATE_STARTING, // Data dialing in progress
92 RIL_DATA_CALL_STATE_STOPPING // Ending data dialing
93} ril_data_call_state_enum;
94
95typedef struct {
b.liu15f456b2024-10-31 20:16:06 +080096 ril_msg_id_enum msg;
b.liu87afc4c2024-08-14 17:33:45 +080097
98 void *data;
99 int data_len;
100} ril_urc_msg_info_t;
101
b.liubcf86c92024-08-19 19:48:28 +0800102typedef struct
103{
104 int cid;
105 bool act;
106 bool waitting;
107} ril_cgact_wait_t;
108
b.liu15f456b2024-10-31 20:16:06 +0800109typedef enum {
110 RIL_ACT_STATE_DISCONNECTED = 0,
111 RIL_ACT_STATE_CONNECTING,
112 RIL_ACT_STATE_CONNECTED,
113 RIL_ACT_STATE_CONNECTED_RETRY, // Network disconnection, retry after network recovery.
114 RIL_ACT_STATE_DISCONNECTING
115} ril_act_state_enum;
116
117typedef struct {
b.liuafdf2c62024-11-12 11:10:44 +0800118 bool valid;
119
b.liu15f456b2024-10-31 20:16:06 +0800120 mbtk_apn_info_t apn_info;
121 ril_act_state_enum act_state;
122} ril_data_call_info_t;
123
b.liu87afc4c2024-08-14 17:33:45 +0800124extern ril_info_t ril_info;
125
126
b.liub171c9a2024-11-12 19:23:29 +0800127mbtk_radio_state_enum ril_radio_state_get(ATPortType_enum port);
128mbtk_ril_err_enum ril_radio_state_set(ATPortType_enum port, mbtk_radio_state_enum state, bool reset);
b.liu87afc4c2024-08-14 17:33:45 +0800129
b.liub171c9a2024-11-12 19:23:29 +0800130mbtk_sim_state_enum ril_sim_state_get(ATPortType_enum port);
b.liu87afc4c2024-08-14 17:33:45 +0800131
b.liub171c9a2024-11-12 19:23:29 +0800132void apn_auto_conf_from_prop(ATPortType_enum port);
b.liu87afc4c2024-08-14 17:33:45 +0800133
134bool is_ipv4(const char *ip);
135
b.liubcf86c92024-08-19 19:48:28 +0800136int net_ifc_config(mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info);
137
138int net_ifc_reconfig(mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info);
139
b.liu87afc4c2024-08-14 17:33:45 +0800140#endif /* _RIL_INFO_H */