blob: c85637e85637f298b45dd88d3eb1950b151b0536 [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"
19#include "mbtk_device.h"
20#include "mbtk_queue.h"
b.liu15f456b2024-10-31 20:16:06 +080021#include "mbtk_ril.h"
b.liu87afc4c2024-08-14 17:33:45 +080022
23#define SOCK_CLIENT_MAX 100
24#define EPOLL_LISTEN_MAX 100
b.liu87afc4c2024-08-14 17:33:45 +080025
b.liu10a34102024-08-20 20:36:24 +080026#if 0
b.liu87afc4c2024-08-14 17:33:45 +080027#define MBTK_APN_PROP "persist.mbtk.apn"
b.liu10a34102024-08-20 20:36:24 +080028#else
29#define MBTK_APN_PROP "/etc/mbtk/apn"
30#endif
31
b.liu87afc4c2024-08-14 17:33:45 +080032#define MBTK_DEF_ROUTE_CID "persist.mbtk.def_route_cid"
b.liubcf86c92024-08-19 19:48:28 +080033#define MBTK_DEF_DNS_CID "persist.mbtk.def_dns_cid"
b.liu87afc4c2024-08-14 17:33:45 +080034
35typedef struct
36{
37 int fd;
b.liu7ca612c2025-04-25 09:23:36 +080038 mbtk_sim_type_enum sim_id;
b.liub171c9a2024-11-12 19:23:29 +080039 ATPortType_enum port;
b.liu87afc4c2024-08-14 17:33:45 +080040
41 uint32 ind_num;
42 uint16 ind_register[IND_REGISTER_MAX];
43} sock_cli_info_t;
44
45typedef struct
46{
47 sock_cli_info_t *cli_info;
48 void* pack; // Refro to : ril_msg_pack_info_t
49} ril_msg_queue_info_t;
50
51typedef struct {
b.liu7ca612c2025-04-25 09:23:36 +080052 mbtk_sim_type_enum cur_sim_id;
53 mbtk_radio_state_enum radio_state[MBTK_SIM_NUM];
54 mbtk_sim_state_enum sim_state[MBTK_SIM_NUM];
55 mbtk_sim_card_type_enum sim_type[MBTK_SIM_NUM];
b.liu87afc4c2024-08-14 17:33:45 +080056 int sock_listen_fd;
57 int epoll_fd;
b.liub171c9a2024-11-12 19:23:29 +080058 bool at_process[ATPORTTYPE_NUM];
b.liu87afc4c2024-08-14 17:33:45 +080059
60 list_node_t *sock_client_list; // Refor to : sock_cli_info_t
b.liub171c9a2024-11-12 19:23:29 +080061 mbtk_queue_node_t msg_queue[ATPORTTYPE_NUM]; // Refor to : ril_msg_queue_info_t
62 pthread_cond_t msg_cond[ATPORTTYPE_NUM];
63 pthread_mutex_t msg_mutex[ATPORTTYPE_NUM];
b.liu87afc4c2024-08-14 17:33:45 +080064} ril_info_t;
65
66typedef struct {
67 bool band_set_success;
b.liu61ad9172025-01-09 14:33:55 +080068 uint32 net_support; // MBTK_NET_SUPPORT_2G / MBTK_NET_SUPPORT_3G / MBTK_NET_SUPPORT_4G / MBTK_NET_SUPPORT_5G
b.liu87afc4c2024-08-14 17:33:45 +080069 mbtk_modem_band_area_enum band_area;
70 mbtk_band_info_t band_support;
71} ril_band_info_t;
72
b.liu87afc4c2024-08-14 17:33:45 +080073/*
740: unknown
751: available
762: current
773: forbidden
78*/
79typedef enum
80{
81 MBTK_NET_AVIL_STATE_UNKNOWN = 0,
82 MBTK_NET_AVIL_STATE_AVAILABLE,
83 MBTK_NET_AVIL_STATE_CURRENT,
84 MBTK_NET_AVIL_STATE_FORBIDDEN
85} mbtk_net_avil_state_enum;
86
87typedef enum {
88 RIL_DATA_CALL_STATE_STOP,
89 RIL_DATA_CALL_STATE_STARTED,
90 RIL_DATA_CALL_STATE_STARTING, // Data dialing in progress
91 RIL_DATA_CALL_STATE_STOPPING // Ending data dialing
92} ril_data_call_state_enum;
93
94typedef struct {
b.liu15f456b2024-10-31 20:16:06 +080095 ril_msg_id_enum msg;
b.liu87afc4c2024-08-14 17:33:45 +080096
97 void *data;
98 int data_len;
99} ril_urc_msg_info_t;
100
b.liubcf86c92024-08-19 19:48:28 +0800101typedef struct
102{
103 int cid;
104 bool act;
105 bool waitting;
106} ril_cgact_wait_t;
107
b.liu15f456b2024-10-31 20:16:06 +0800108typedef enum {
109 RIL_ACT_STATE_DISCONNECTED = 0,
110 RIL_ACT_STATE_CONNECTING,
111 RIL_ACT_STATE_CONNECTED,
112 RIL_ACT_STATE_CONNECTED_RETRY, // Network disconnection, retry after network recovery.
113 RIL_ACT_STATE_DISCONNECTING
114} ril_act_state_enum;
115
116typedef struct {
b.liuafdf2c62024-11-12 11:10:44 +0800117 bool valid;
118
b.liub1d9b1c2024-12-31 13:38:18 +0800119 bool manual_call;
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.liu7ca612c2025-04-25 09:23:36 +0800127mbtk_radio_state_enum ril_radio_state_get(mbtk_sim_type_enum sim_id, ATPortType_enum port);
128mbtk_ril_err_enum ril_radio_state_set(mbtk_sim_type_enum sim_id, ATPortType_enum port, mbtk_radio_state_enum state, bool reset);
b.liu87afc4c2024-08-14 17:33:45 +0800129
b.liu7ca612c2025-04-25 09:23:36 +0800130mbtk_sim_state_enum ril_sim_state_get(mbtk_sim_type_enum sim_id, ATPortType_enum port);
b.liu87afc4c2024-08-14 17:33:45 +0800131
b.liu7ca612c2025-04-25 09:23:36 +0800132void apn_auto_conf_from_prop(mbtk_sim_type_enum sim_id, ATPortType_enum port);
b.liu87afc4c2024-08-14 17:33:45 +0800133
134bool is_ipv4(const char *ip);
135
yq.wang5682ba92025-05-15 09:44:18 +0800136int net_ifc_config(mbtk_sim_type_enum sim_id, mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info);
b.liubcf86c92024-08-19 19:48:28 +0800137
yq.wang5682ba92025-05-15 09:44:18 +0800138int net_ifc_reconfig(mbtk_sim_type_enum sim_id, mbtk_ril_cid_enum cid, bool def_route, bool as_dns, mbtk_ip_info_t *ip_info);
b.liubcf86c92024-08-19 19:48:28 +0800139
b.liu87afc4c2024-08-14 17:33:45 +0800140#endif /* _RIL_INFO_H */