• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/uqmi/uqmid/modem.h

  1 /*
  2  * uqmi -- tiny QMI support implementation
  3  *
  4  * Copyright (C) 2023 Alexander Couzens <lynxis@fe80.eu>
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the
 18  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 19  * Boston, MA 02110-1301 USA.
 20  */
 21 
 22 #ifndef __UQMID_MODEM_H
 23 #define __UQMID_MODEM_H
 24 
 25 #include "sim.h"
 26 #include <libubus.h>
 27 #include <netinet/in.h>
 28 
 29 #define PATH_LEN 128
 30 
 31 // try to get osmocom fsm into here?
 32 struct modem_config {
 33         bool configured;
 34         char *apn;
 35         char *username;
 36         char *password;
 37         char *pin;
 38         char *puk;
 39         bool roaming;
 40         uint8_t pdp_type;
 41 };
 42 
 43 struct wwan_conf {
 44         bool raw_ip;
 45         bool pass_through;
 46 };
 47 
 48 
 49 struct modem {
 50         char *name;
 51         /*! path to the device. /dev/cdc-wdm */
 52         char *device;
 53         /*! IMEI including LUN check digit */
 54         char *imei;
 55         /*! 2 digit software version */
 56         char *imeisv;
 57         /*! CDMA MEID id - hopefully we never need this */
 58         char *meid;
 59         char path[PATH_LEN];
 60 
 61         /* Either usb or usbmisc of cdc-wdm0 */
 62         char *subsystem_name;
 63         struct {
 64                 /* network device name. e.g. wwan0 */
 65                 char *dev;
 66                 char *sysfs;
 67                 struct wwan_conf config;
 68 
 69                 /* uqmid won't do any sysfs/kernel configuration */
 70                 bool skip_configuration;
 71         } wwan;
 72 
 73         char *manuf;
 74         char *model;
 75         char *rev;
 76 
 77         /* unsure if iccid should be here */
 78         char *iccid; /* FIXME: iccid length is? */
 79         char imsi[16];
 80 
 81         struct modem_config config;
 82         struct {
 83                 /* Radio Access Technology */
 84                 int rat;
 85                 /* Mobile Country Code */
 86                 int mcc;
 87                 /* Mobile Network Code */
 88                 int mnc;
 89                 /* len can be 2 or 3 */
 90                 int mnc_len;
 91                 /* Operator name, can be from Sim or network. */
 92                 char *operator_name;
 93                 /* attached to Circuit Switch/Voice */
 94                 bool cs;
 95                 /* attached to Packet Switch/Data */
 96                 bool ps;
 97                 /* if an error happened and the modem should stay off */
 98                 char *error;
 99         } state;
100 
101         /* TODO: add multiple bearer support later */
102         struct {
103                 /* The QMI internal handle */
104                 uint32_t packet_data_handle;
105                 /* either ipv4, ipv6, ipv46 */
106                 int pdp_type;
107                 /* valid v4_addr and ipv46 */
108                 struct sockaddr_in v4_addr;
109                 struct sockaddr_in v4_netmask;
110                 struct sockaddr_in v4_gateway;
111                 /* valid v6 and ipv46 */
112                 struct sockaddr_in6 v6;
113                 struct sockaddr_storage dns1;
114                 struct sockaddr_storage dns2;
115         } brearer;
116 
117         struct {
118                 /*! sim_fsm instance */
119                 struct osmo_fsm_inst *fi;
120                 /* Do we found a valid simcard */
121                 bool init;
122                 /* Certain modems (and maybe simcards) support either unlocking the sim via pin1 or upin. */
123                 enum uqmi_sim_state state;
124                 bool use_upin;
125                 bool use_uim;
126                 bool requires_unlock;
127                 /* when we tried the configured pin once */
128                 bool pin_tried;
129                 bool puk_tried;
130                 int pin_retries;
131                 int puk_retries;
132         } sim;
133 
134         struct qmi_dev *qmi;
135 
136         struct list_head list;
137         struct ubus_object ubus;
138 
139         /*! modem_fsm instance */
140         struct osmo_fsm_inst *fi;
141 };
142 
143 int uqmid_modem_add(const char *name, const char *device, bool qmi_over_mbim);
144 int uqmid_modem_remove(struct modem *modem);
145 int uqmid_modem_start(struct modem *modem);
146 int uqmid_modem_configured(struct modem *modem);
147 void uqmid_modem_set_error(struct modem *modem, const char *error);
148 
149 typedef void (*uqmid_modem_get_opmode_cb)(void *data, int opmode_err, int opmode);
150 int uqmid_modem_get_opmode(struct modem *modem, uqmid_modem_get_opmode_cb cb, void *cb_data);
151 int uqmid_modem_networkstatus(struct modem *modem);
152 struct modem *uqmid_modem_find_by_device(const char *device);
153 struct modem *uqmid_modem_find_by_name(const char *name);
154 
155 #endif /* __UQMID_MODEM_H */
156 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt