From 6910d50e9b1e80fe758b259149012e7e062eecd0 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Mon, 6 Jun 2016 10:14:12 +0200 Subject: net: make networking code re-entrant - The network instance is now in struct network and does not use any local/static data - A new top-level struct in baresip.c owns the single instance of struct network it is a long-term goal to remove all local/static data from libbaresip and make it fully re-entrant. --- include/baresip.h | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/baresip.h b/include/baresip.h index d60b0a5..f7f3c70 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -200,6 +200,8 @@ struct config_avt { /* Network */ struct config_net { char ifname[16]; /**< Bind to interface (optional) */ + struct sa nsv[4]; /**< DNS nameservers */ + size_t nsc; /**< Number of DNS nameservers */ }; #ifdef USE_VIDEO @@ -459,18 +461,21 @@ const struct menc *menc_find(const char *id); * Net - Networking */ +struct network; + typedef void (net_change_h)(void *arg); -int net_init(const struct config_net *cfg, int af); -void net_close(void); -int net_dnssrv_add(const struct sa *sa); -void net_change(uint32_t interval, net_change_h *ch, void *arg); -bool net_check(void); -int net_af(void); -int net_debug(struct re_printf *pf, void *unused); -const struct sa *net_laddr_af(int af); -const char *net_domain(void); -struct dnsc *net_dnsc(void); +int net_alloc(struct network **netp, const struct config_net *cfg, int af); +int net_use_nameserver(struct network *net, const struct sa *ns); +void net_change(struct network *net, uint32_t interval, + net_change_h *ch, void *arg); +void net_force_change(struct network *net); +bool net_check(struct network *net); +int net_af(const struct network *net); +int net_debug(struct re_printf *pf, const struct network *net); +const struct sa *net_laddr_af(const struct network *net, int af); +const char *net_domain(const struct network *net); +struct dnsc *net_dnsc(const struct network *net); /* @@ -1050,6 +1055,15 @@ double mos_calculate(double *r_factor, double rtt, double jitter, uint32_t num_packets_lost); +/* + * Baresip instance + */ + +int baresip_init(struct config *cfg, bool prefer_ipv6); +void baresip_close(void); +struct network *baresip_network(void); + + #ifdef __cplusplus } #endif -- cgit v1.2.3