summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-07-26 17:31:53 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-08-09 13:54:44 +0200
commita212398f7c39ab0e919e0c9efde8a1c8a37678bb (patch)
tree430e5452e4cb7308b74789082b875fed05f3b8f3
parentb352ca030d8870930493f36e2b3702760ff4b44a (diff)
consistency: use OSMO_SS7_PC_INVALID for osmo_sccp_user
A previous patch added ss7_instance primary_pc validity checks by means of OSMO_SS7_PC_INVALID. To be consistent, also adjust sccp_user accordingly. (see I7f0f0c89b7335d9da24161bfac8234be214ca00c) Remove the osmo_sccp_user's pc_valid field, replaced by pc=OSMO_SS7_PC_INVALID. Adjust all code paths. Simplify some log printing, using the fact that osmo_ss7_pointcode_print() now outputs "(no PC)" for unset point codes. Change-Id: I8684c9b559712072c772012890bbf7efa7c8eb35
-rw-r--r--src/sccp_internal.h1
-rw-r--r--src/sccp_scoc.c2
-rw-r--r--src/sccp_user.c32
-rw-r--r--src/sccp_vty.c2
4 files changed, 16 insertions, 21 deletions
diff --git a/src/sccp_internal.h b/src/sccp_internal.h
index 17dda13..66d768d 100644
--- a/src/sccp_internal.h
+++ b/src/sccp_internal.h
@@ -34,7 +34,6 @@ struct osmo_sccp_user {
/*! \brief SSN and/or point code to which we are bound */
uint16_t ssn;
uint32_t pc;
- bool pc_valid;
/* set if we are a server */
struct llist_head links;
diff --git a/src/sccp_scoc.c b/src/sccp_scoc.c
index 9820c40..74fb0e7 100644
--- a/src/sccp_scoc.c
+++ b/src/sccp_scoc.c
@@ -1672,7 +1672,7 @@ static void vty_show_connection(struct vty *vty, struct sccp_connection *conn)
struct osmo_sccp_addr *remote_addr;
uint32_t local_pc = OSMO_SS7_PC_INVALID;
- if (conn->user->pc_valid)
+ if (osmo_ss7_pc_is_valid(conn->user->pc))
local_pc = conn->user->pc;
else if (osmo_ss7_pc_is_valid(s7i->cfg.primary_pc))
local_pc = s7i->cfg.primary_pc;
diff --git a/src/sccp_user.c b/src/sccp_user.c
index d49da29..1414572 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -48,13 +48,13 @@ sccp_user_find(struct osmo_sccp_instance *inst, uint16_t ssn, uint32_t pc)
/* First try to find match for PC + SSN */
llist_for_each_entry(scu, &inst->users, list) {
- if (scu->pc_valid && scu->pc == pc && scu->ssn == ssn)
+ if (osmo_ss7_pc_is_valid(scu->pc) && scu->pc == pc && scu->ssn == ssn)
return scu;
}
/* Then try to match on SSN only */
llist_for_each_entry(scu, &inst->users, list) {
- if (!scu->pc_valid && scu->ssn == ssn)
+ if (!osmo_ss7_pc_is_valid(scu->pc) && scu->ssn == ssn)
return scu;
}
@@ -65,28 +65,25 @@ sccp_user_find(struct osmo_sccp_instance *inst, uint16_t ssn, uint32_t pc)
* \param[in] inst SCCP Instance
* \param[in] name human-readable name
* \param[in] ssn Sub-System Number to bind to
- * \param[in] pc Point Code to bind to (if any)
- * \param[in] pc_valid Whether or not \ref pc is valid/used
+ * \param[in] pc Point Code to bind to, or OSMO_SS7_PC_INVALID if none.
* \returns Callee-allocated SCCP User on success; negative otherwise */
static struct osmo_sccp_user *
sccp_user_bind_pc(struct osmo_sccp_instance *inst, const char *name,
- osmo_prim_cb prim_cb, uint16_t ssn, uint32_t pc, bool pc_valid)
+ osmo_prim_cb prim_cb, uint16_t ssn, uint32_t pc)
{
struct osmo_sccp_user *scu;
- if (!pc_valid)
- pc = 0;
scu = sccp_user_find(inst, ssn, pc);
if (scu) {
LOGP(DLSCCP, LOGL_ERROR,
- "Cannot bind user '%s' to SSN=%u PC=%u=%s (pc_valid=%u), this SSN and PC"
+ "Cannot bind user '%s' to SSN=%u PC=%s, this SSN and PC"
" is already bound by '%s'\n",
- name, ssn, pc, osmo_ss7_pointcode_print(inst->ss7, pc), pc_valid, scu->name);
+ name, ssn, osmo_ss7_pointcode_print(inst->ss7, pc), scu->name);
return NULL;
}
- LOGP(DLSCCP, LOGL_INFO, "Binding user '%s' to SSN=%u PC=%u=%s (pc_valid=%u)\n",
- name, ssn, pc, osmo_ss7_pointcode_print(inst->ss7, pc), pc_valid);
+ LOGP(DLSCCP, LOGL_INFO, "Binding user '%s' to SSN=%u PC=%s\n",
+ name, ssn, osmo_ss7_pointcode_print(inst->ss7, pc));
scu = talloc_zero(inst, struct osmo_sccp_user);
scu->name = talloc_strdup(scu, name);
@@ -94,7 +91,6 @@ sccp_user_bind_pc(struct osmo_sccp_instance *inst, const char *name,
scu->prim_cb = prim_cb;
scu->ssn = ssn;
scu->pc = pc;
- scu->pc_valid = pc_valid;
llist_add_tail(&scu->list, &inst->users);
return scu;
@@ -104,13 +100,13 @@ sccp_user_bind_pc(struct osmo_sccp_instance *inst, const char *name,
* \param[in] inst SCCP Instance
* \param[in] name human-readable name
* \param[in] ssn Sub-System Number to bind to
- * \param[in] pc Point Code to bind to (if any)
+ * \param[in] pc Point Code to bind to
* \returns Callee-allocated SCCP User on success; negative otherwise */
struct osmo_sccp_user *
osmo_sccp_user_bind_pc(struct osmo_sccp_instance *inst, const char *name,
osmo_prim_cb prim_cb, uint16_t ssn, uint32_t pc)
{
- return sccp_user_bind_pc(inst, name, prim_cb, ssn, pc, true);
+ return sccp_user_bind_pc(inst, name, prim_cb, ssn, pc);
}
/*! \brief Bind a given SCCP User to a given SSN (at any PC)
@@ -122,7 +118,7 @@ struct osmo_sccp_user *
osmo_sccp_user_bind(struct osmo_sccp_instance *inst, const char *name,
osmo_prim_cb prim_cb, uint16_t ssn)
{
- return sccp_user_bind_pc(inst, name, prim_cb, ssn, 0, false);
+ return sccp_user_bind_pc(inst, name, prim_cb, ssn, OSMO_SS7_PC_INVALID);
}
/*! \brief Unbind a given SCCP user
@@ -130,9 +126,9 @@ osmo_sccp_user_bind(struct osmo_sccp_instance *inst, const char *name,
* at the time this function returns. */
void osmo_sccp_user_unbind(struct osmo_sccp_user *scu)
{
- LOGP(DLSCCP, LOGL_INFO, "Unbinding user '%s' from SSN=%u PC=%u "
- "(pc_valid=%u)\n", scu->name, scu->ssn, scu->pc,
- scu->pc_valid);
+ LOGP(DLSCCP, LOGL_INFO, "Unbinding user '%s' from SSN=%u PC=%s\n",
+ scu->name, scu->ssn,
+ osmo_ss7_pointcode_print(scu->inst->ss7, scu->pc));
/* FIXME: free/release all connections held by this user? */
llist_del(&scu->list);
talloc_free(scu);
diff --git a/src/sccp_vty.c b/src/sccp_vty.c
index 626fefb..7f0a0de 100644
--- a/src/sccp_vty.c
+++ b/src/sccp_vty.c
@@ -42,7 +42,7 @@ static void show_user(struct vty *vty, struct osmo_sccp_user *user)
{
struct osmo_sccp_instance *sccp = user->inst;
- if (user->pc_valid)
+ if (osmo_ss7_pc_is_valid(user->pc))
vty_out(vty, "SSN %3u %7s : %s%s", user->ssn,
osmo_ss7_pointcode_print(sccp->ss7, user->pc),
user->name, VTY_NEWLINE);