aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2020-10-11 20:48:04 +0200
committerlaforge <laforge@osmocom.org>2020-10-12 13:08:42 +0000
commit9a4cf275b2d2ae03702bd344291332f7e898da51 (patch)
treeca1fe9e1d9ac2ece53be9241c3aac525d518be47
parent4b6c8afcb2e0c7c366bf0a98138d659055860af3 (diff)
gprs_ns2: const the return value of gprs_ns2_ip_vc_sockaddr / gprs_ns2_ip_bind_sockaddr
The sockaddr should not be changed. free and create the bind/nsvc if the address should be changed. Change-Id: I371ac2361b569e36722b02fc9cd82ec8da2fa9e3
-rw-r--r--include/osmocom/gprs/gprs_ns2.h4
-rw-r--r--src/gb/gprs_ns2.c6
-rw-r--r--src/gb/gprs_ns2_sns.c8
-rw-r--r--src/gb/gprs_ns2_udp.c6
-rw-r--r--src/gb/gprs_ns2_vty.c2
5 files changed, 14 insertions, 12 deletions
diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h
index 75315308..a3edc638 100644
--- a/include/osmocom/gprs/gprs_ns2.h
+++ b/include/osmocom/gprs/gprs_ns2.h
@@ -139,8 +139,8 @@ int gprs_ns2_ip_connect_sns(struct gprs_ns2_vc_bind *bind,
const struct osmo_sockaddr *remote,
uint16_t nsei);
-struct osmo_sockaddr *gprs_ns2_ip_vc_sockaddr(struct gprs_ns2_vc *nsvc);
-struct osmo_sockaddr *gprs_ns2_ip_bind_sockaddr(struct gprs_ns2_vc_bind *bind);
+const struct osmo_sockaddr *gprs_ns2_ip_vc_sockaddr(struct gprs_ns2_vc *nsvc);
+const struct osmo_sockaddr *gprs_ns2_ip_bind_sockaddr(struct gprs_ns2_vc_bind *bind);
int gprs_ns2_is_ip_bind(struct gprs_ns2_vc_bind *bind);
int gprs_ns2_ip_bind_set_dscp(struct gprs_ns2_vc_bind *bind, int dscp);
struct gprs_ns2_vc *gprs_ns2_nsvc_by_sockaddr_bind(
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 50acf99a..43a3d770 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -210,8 +210,8 @@ static const struct osmo_stat_item_group_desc nsvc_statg_desc = {
* \return pointer to buf on success; NULL on error */
char *gprs_ns2_ll_str_buf(char *buf, size_t buf_len, struct gprs_ns2_vc *nsvc)
{
- struct osmo_sockaddr *local;
- struct osmo_sockaddr *remote;
+ const struct osmo_sockaddr *local;
+ const struct osmo_sockaddr *remote;
struct osmo_sockaddr_str local_str;
struct osmo_sockaddr_str remote_str;
@@ -847,7 +847,7 @@ struct gprs_ns2_vc *gprs_ns2_nsvc_by_sockaddr_nse(struct gprs_ns2_nse *nse,
const struct osmo_sockaddr *sockaddr)
{
struct gprs_ns2_vc *nsvc;
- struct osmo_sockaddr *remote;
+ const struct osmo_sockaddr *remote;
OSMO_ASSERT(nse);
OSMO_ASSERT(sockaddr);
diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c
index fabc134a..27562269 100644
--- a/src/gb/gprs_ns2_sns.c
+++ b/src/gb/gprs_ns2_sns.c
@@ -473,7 +473,7 @@ static int do_sns_change_weight(struct osmo_fsm_inst *fi, const struct gprs_ns_i
struct gprs_ns2_nse *nse = nse_inst_from_fi(fi);
struct gprs_ns2_vc *nsvc;
struct osmo_sockaddr sa = {};
- struct osmo_sockaddr *remote;
+ const struct osmo_sockaddr *remote;
uint8_t new_signal;
uint8_t new_data;
@@ -533,7 +533,7 @@ static int do_sns_delete(struct osmo_fsm_inst *fi,
struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv;
struct gprs_ns2_nse *nse = nse_inst_from_fi(fi);
struct gprs_ns2_vc *nsvc, *tmp;
- struct osmo_sockaddr *remote;
+ const struct osmo_sockaddr *remote;
struct osmo_sockaddr sa = {};
if (ip4) {
@@ -1239,7 +1239,9 @@ int ns2_sns_bss_fsm_start(struct gprs_ns2_nse *nse, struct gprs_ns2_vc *nsvc,
struct gprs_ns_ie_ip6_elem *ip6_elems;
struct gprs_ns2_vc_bind *bind;
struct gprs_ns2_inst *nsi = nse->nsi;
- struct osmo_sockaddr *sa, local;
+ const struct osmo_sockaddr *sa;
+ struct osmo_sockaddr local;
+
gss->ip = remote->u.sa.sa_family == AF_INET ? IPv4 : IPv6;
gss->initial = *remote;
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c
index 7ead71a1..9aca80b2 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -274,7 +274,7 @@ struct gprs_ns2_vc_bind *gprs_ns2_ip_bind_by_sockaddr(struct gprs_ns2_inst *nsi,
const struct osmo_sockaddr *sockaddr)
{
struct gprs_ns2_vc_bind *bind;
- struct osmo_sockaddr *local;
+ const struct osmo_sockaddr *local;
OSMO_ASSERT(nsi);
OSMO_ASSERT(sockaddr);
@@ -396,7 +396,7 @@ struct gprs_ns2_vc *gprs_ns2_ip_bind_connect(struct gprs_ns2_vc_bind *bind,
/*! Return the socket address of the remote peer of a NS-VC.
* \param[in] nsvc NS-VC whose remote peer we want to know
* \return address of the remote peer; NULL in case of error */
-struct osmo_sockaddr *gprs_ns2_ip_vc_sockaddr(struct gprs_ns2_vc *nsvc)
+const struct osmo_sockaddr *gprs_ns2_ip_vc_sockaddr(struct gprs_ns2_vc *nsvc)
{
struct priv_vc *priv;
@@ -410,7 +410,7 @@ struct osmo_sockaddr *gprs_ns2_ip_vc_sockaddr(struct gprs_ns2_vc *nsvc)
/*! Return the locally bound socket address of the bind.
* \param[in] bind The bind whose local address we want to know
* \return address of the local bind */
-struct osmo_sockaddr *gprs_ns2_ip_bind_sockaddr(struct gprs_ns2_vc_bind *bind)
+const struct osmo_sockaddr *gprs_ns2_ip_bind_sockaddr(struct gprs_ns2_vc_bind *bind)
{
struct priv_bind *priv;
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 55e87ae1..92c00958 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -247,7 +247,7 @@ static void dump_nsvc(struct vty *vty, struct gprs_ns2_vc *nsvc, bool stats)
{
struct osmo_sockaddr_str remote;
struct osmo_sockaddr_str local;
- struct osmo_sockaddr *sockaddr;
+ const struct osmo_sockaddr *sockaddr;
switch (nsvc->ll) {
case GPRS_NS_LL_UDP: {