| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "conf-parser-forward.h" |
| 5 |
#include "in-addr-util.h" |
| 6 |
#include "network-util.h" |
| 7 |
#include "networkd-wwan-bus.h" |
| 8 |
|
| 9 |
typedef struct Modem Modem; |
| 10 |
|
| 11 |
typedef struct Bearer { |
| 12 |
Modem *modem; |
| 13 |
|
| 14 |
sd_bus_slot *slot_getall; /* for GetAll method */ |
| 15 |
|
| 16 |
char *path; /* DBus path e.g /org/freedesktop/ModemManager/Bearer/0 */ |
| 17 |
char *name; /* Interface property, e.g. wwan0 */ |
| 18 |
char *apn; /* "apn" field in Properties */ |
| 19 |
AddressFamily ip_type; /* "ip-type" field in Properties */ |
| 20 |
|
| 21 |
/* Ip4Config or IP6Config property */ |
| 22 |
MMBearerIpMethod ip4_method; |
| 23 |
MMBearerIpMethod ip6_method; |
| 24 |
unsigned ip4_prefixlen; |
| 25 |
unsigned ip6_prefixlen; |
| 26 |
union in_addr_union ip4_address; |
| 27 |
union in_addr_union ip6_address; |
| 28 |
union in_addr_union ip4_gateway; |
| 29 |
union in_addr_union ip6_gateway; |
| 30 |
struct in_addr_full **dns; |
| 31 |
size_t n_dns; |
| 32 |
uint32_t ip4_mtu; |
| 33 |
uint32_t ip6_mtu; |
| 34 |
|
| 35 |
bool connected; /* Connected property */ |
| 36 |
} Bearer; |
| 37 |
|
| 38 |
typedef struct Modem { |
| 39 |
Manager *manager; |
| 40 |
|
| 41 |
sd_bus_slot *slot_propertieschanged; |
| 42 |
sd_bus_slot *slot_statechanged; |
| 43 |
sd_bus_slot *slot_connect; |
| 44 |
|
| 45 |
char *path; /* DBus path e.g /org/freedesktop/ModemManager/Modem/0 */ |
| 46 |
char *manufacturer; /* The "Manufacturer" property */ |
| 47 |
char *model; /* The "Model" property */ |
| 48 |
char *port_name; /* MM_MODEM_PORT_TYPE_NET of Ports property */ |
| 49 |
|
| 50 |
Hashmap *bearers_by_path; |
| 51 |
Hashmap *bearers_by_name; |
| 52 |
|
| 53 |
MMModemState state; |
| 54 |
MMModemStateFailedReason state_fail_reason; |
| 55 |
ModemReconnectState reconnect_state; |
| 56 |
} Modem; |
| 57 |
|
| 58 |
int bearer_new(Modem *modem, const char *path, Bearer **ret); |
| 59 |
Bearer* bearer_free(Bearer *b); |
| 60 |
DEFINE_TRIVIAL_CLEANUP_FUNC(Bearer*, bearer_free); |
| 61 |
|
| 62 |
int bearer_set_name(Bearer *b, const char *name); |
| 63 |
|
| 64 |
int bearer_get_by_path(Manager *manager, const char *path, Modem **ret_modem, Bearer **ret_bearer); |
| 65 |
int link_get_bearer(Link *link, Bearer **ret); |
| 66 |
|
| 67 |
int link_dhcp_enabled_by_bearer(Link *link, int family); |
| 68 |
|
| 69 |
int link_apply_bearer(Link *link); |
| 70 |
int bearer_update_link(Bearer *b); |
| 71 |
void bearer_drop(Bearer *b); |
| 72 |
|
| 73 |
int modem_new(Manager *m, const char *path, Modem **ret); |
| 74 |
Modem* modem_free(Modem *modem); |
| 75 |
DEFINE_TRIVIAL_CLEANUP_FUNC(Modem*, modem_free); |
| 76 |
|
| 77 |
int modem_get_by_path(Manager *m, const char *path, Modem **ret); |
| 78 |
int link_get_modem(Link *link, Modem **ret); |
| 79 |
|
| 80 |
CONFIG_PARSER_PROTOTYPE(config_parse_mm_allowed_auth); |
| 81 |
CONFIG_PARSER_PROTOTYPE(config_parse_mm_ip_family); |
| 82 |
CONFIG_PARSER_PROTOTYPE(config_parse_mm_route_metric); |