[PATCH] libosmo-sccp[master]: sccp: add addressbook functionality for sccp addresses

2017-06-21 Thread dexter
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2924

to look at the new patch set (#9).

sccp: add addressbook functionality for sccp addresses

SCCP addresses are defined through a number of compoinents, not
just an IP-Address, there is also point code, ssn and more. To
simplify and unify the handling of such objects, this patch
introduces an addressbook functionality. The user can set up
multiple addresses per ss7 instance and give them names. Later
that name can be used to reference the address at a later point
in the config. This means that the usage of sccp-addresses from
the programmers point of view boils down to a VTY function that
reads the string name of a previously defined address. The
programmer can then use the API to get a pointer to the SCCP
address struct and use it normally.

For this feature, two additional VTY nodes are necessary,
this commit depends libosmocore change:
Change-Id I42aa29c097f284b85801c5329b015b189640

Change-Id: I068ed7f7d113dab88424a9d47bab7fc703bb7942
---
M include/osmocom/sigtran/osmo_ss7.h
M include/osmocom/sigtran/sccp_sap.h
M src/osmo_ss7.c
M src/osmo_ss7_vty.c
4 files changed, 587 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/24/2924/9

diff --git a/include/osmocom/sigtran/osmo_ss7.h 
b/include/osmocom/sigtran/osmo_ss7.h
index 7b0a607..741a7e3 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -89,6 +89,7 @@
uint8_t network_indicator;
struct osmo_ss7_pc_fmt pc_fmt;
bool permit_dyn_rkm_alloc;
+   struct llist_head sccp_address_book;
} cfg;
 };
 
diff --git a/include/osmocom/sigtran/sccp_sap.h 
b/include/osmocom/sigtran/sccp_sap.h
index f378e5c..2258b0d 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -247,3 +247,9 @@
osmo_prim_cb prim_cb, uint16_t ssn);
 
 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr 
*oph);
+
+struct osmo_sccp_addr *
+osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7);
+
+char * osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr,
+ const struct osmo_ss7_instance *ss7);
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index d952ecd..78b22a7 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -352,6 +352,8 @@
 
llist_add(&inst->list, &osmo_ss7_instances);
 
+   INIT_LLIST_HEAD(&inst->cfg.sccp_address_book);
+
return inst;
 }
 
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 97b5cf0..8e40474 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -36,6 +36,7 @@
 #include 
 
 #include "xua_internal.h"
+#include 
 
 #define XUA_VAR_STR"(sua|m3ua|ipa)"
 
@@ -891,6 +892,537 @@
return CMD_SUCCESS;
 }
 
+/***
+ * SCCP addressbook handling
+ ***/
+
+/* SCCP addressbook */
+struct osmo_sccp_addr_entry {
+   struct llist_head list;
+   struct osmo_ss7_instance *inst;
+   char name[512];
+   struct osmo_sccp_addr addr;
+};
+
+static struct cmd_node sccpaddr_node = {
+   L_CS7_SCCPADDR_NODE,
+   "%s(config-cs7-sccpaddr)# ",
+   1,
+};
+
+static struct cmd_node sccpaddr_gt_node = {
+   L_CS7_SCCPADDR_GT_NODE,
+   "%s(config-cs7-sccpaddr-gt)# ",
+   1,
+};
+
+/* Pick an SCCP address entry from the addressbook by its name */
+struct osmo_sccp_addr_entry *addr_entry_by_name(const char *name,
+   const struct osmo_ss7_instance
+   *inst)
+{
+   struct osmo_sccp_addr_entry *entry;
+   llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+   if (strcmp(entry->name, name) == 0)
+   return entry;
+   }
+   return NULL;
+}
+
+/*! \brief Lookup an SCCP address from the addressbook by its name.
+ *  \param[in] lookup-name of the address to lookup
+ *  \param[in] ss7 instance
+ *  \returns SCCP address; NULL on error */
+struct osmo_sccp_addr *osmo_sccp_addr_by_name(const char *name,
+ const struct osmo_ss7_instance
+ *ss7)
+{
+   struct osmo_sccp_addr_entry *entry;
+
+   entry = addr_entry_by_name(name, ss7);
+   if (entry)
+   return &entry->addr;
+
+   return NULL;
+}
+
+/*! \brief Reverse lookup the lookup-name of a specified SCCP address.
+ *  \param[in] name of the address to lookup
+ *  \param[in] ss7 instance
+ *  \returns char pointer to the lookup-name; NULL on error */
+char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr,
+const struct osmo_ss7_instance *ss7)

[PATCH] libosmo-sccp[master]: sccp: add addressbook functionality for sccp addresses

2017-06-21 Thread dexter
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2924

to look at the new patch set (#8).

sccp: add addressbook functionality for sccp addresses

SCCP addresses are defined through a number of compoinents, not
just an IP-Address, there is also point code, ssn and more. To
simplify and unify the handling of such objects, this patch
introduces an addressbook functionality. The user can set up
multiple addresses per ss7 instance and give them names. Later
that name can be used to reference the address at a later point
in the config. This means that the usage of sccp-addresses from
the programmers point of view boils down to a VTY function that
reads the string name of a previously defined address. The
programmer can then use the API to get a pointer to the SCCP
address struct and use it normally.

For this feature, two additional VTY nodes are necessary,
this commit depends libosmocore change:
Change-Id I42aa29c097f284b85801c5329b015b189640

Change-Id: I068ed7f7d113dab88424a9d47bab7fc703bb7942
---
M include/osmocom/sigtran/osmo_ss7.h
M include/osmocom/sigtran/sccp_sap.h
M src/osmo_ss7.c
M src/osmo_ss7_vty.c
4 files changed, 584 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/24/2924/8

diff --git a/include/osmocom/sigtran/osmo_ss7.h 
b/include/osmocom/sigtran/osmo_ss7.h
index 7b0a607..741a7e3 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -89,6 +89,7 @@
uint8_t network_indicator;
struct osmo_ss7_pc_fmt pc_fmt;
bool permit_dyn_rkm_alloc;
+   struct llist_head sccp_address_book;
} cfg;
 };
 
diff --git a/include/osmocom/sigtran/sccp_sap.h 
b/include/osmocom/sigtran/sccp_sap.h
index f378e5c..2258b0d 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -247,3 +247,9 @@
osmo_prim_cb prim_cb, uint16_t ssn);
 
 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr 
*oph);
+
+struct osmo_sccp_addr *
+osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7);
+
+char * osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr,
+ const struct osmo_ss7_instance *ss7);
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index d952ecd..78b22a7 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -352,6 +352,8 @@
 
llist_add(&inst->list, &osmo_ss7_instances);
 
+   INIT_LLIST_HEAD(&inst->cfg.sccp_address_book);
+
return inst;
 }
 
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 97b5cf0..75b2431 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -36,6 +36,7 @@
 #include 
 
 #include "xua_internal.h"
+#include 
 
 #define XUA_VAR_STR"(sua|m3ua|ipa)"
 
@@ -891,6 +892,534 @@
return CMD_SUCCESS;
 }
 
+/***
+ * SCCP addressbook handling
+ ***/
+
+/* SCCP addressbook */
+struct osmo_sccp_addr_entry {
+   struct llist_head list;
+   struct osmo_ss7_instance *inst;
+   char name[512];
+   struct osmo_sccp_addr addr;
+};
+
+static struct cmd_node sccpaddr_node = {
+   L_CS7_SCCPADDR_NODE,
+   "%s(config-cs7-sccpaddr)# ",
+   1,
+};
+
+static struct cmd_node sccpaddr_gt_node = {
+   L_CS7_SCCPADDR_GT_NODE,
+   "%s(config-cs7-sccpaddr-gt)# ",
+   1,
+};
+
+/* Pick an SCCP address entry from the addressbook by its name */
+struct osmo_sccp_addr_entry *
+addr_entry_by_name(const char *name, const struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_entry *entry;
+   llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+   if (strcmp(entry->name, name) == 0)
+   return entry;
+   }
+   return NULL;
+}
+
+/*! \brief Lookup an SCCP address from the addressbook by its name.
+ *  \param[in] lookup-name of the address to lookup
+ *  \param[in] ss7 instance
+ *  \returns SCCP address; NULL on error */
+struct osmo_sccp_addr *
+osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7)
+{
+   struct osmo_sccp_addr_entry *entry;
+
+   entry = addr_entry_by_name(name, ss7);
+   if(entry)
+   return &entry->addr;
+
+   return NULL;
+}
+
+/*! \brief Reverse lookup the lookup-name of a specified SCCP address.
+ *  \param[in] name of the address to lookup
+ *  \param[in] ss7 instance
+ *  \returns char pointer to the lookup-name; NULL on error */
+char * osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr,
+ const struct osmo_ss7_instance *ss7)
+{
+   struct osmo_sccp_addr_entry *entry;
+   llist_for_each_entry(entry, &ss7->cfg.sccp_address_book, list) {
+   if (memcmp(&entry->addr, addr, sizeof(*addr)) =

[PATCH] libosmo-sccp[master]: sccp: add addressbook functionality for sccp addresses

2017-06-20 Thread dexter
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2924

to look at the new patch set (#7).

sccp: add addressbook functionality for sccp addresses

SCCP addresses are defined through a number of compoinents, not
just an IP-Address, there is also point code, ssn and more. To
simplify and unify the handling of such objects, this patch
introduces an addressbook functionality. The user can set up
multiple addresses per ss7 instance and give them names. Later
that name can be used to reference the address at a later point
in the config. This means that the usage of sccp-addresses from
the programmers point of view boils down to a VTY function that
reads the string name of a previously defined address. The
programmer can then use the API to get a pointer to the SCCP
address struct and use it normally.

For this feature, two additional VTY nodes are necessary,
this commit depends libosmocore change:
Change-Id I42aa29c097f284b85801c5329b015b189640

Change-Id: I068ed7f7d113dab88424a9d47bab7fc703bb7942
---
M include/osmocom/sigtran/osmo_ss7.h
M include/osmocom/sigtran/sccp_sap.h
M src/osmo_ss7.c
M src/osmo_ss7_vty.c
4 files changed, 562 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/24/2924/7

diff --git a/include/osmocom/sigtran/osmo_ss7.h 
b/include/osmocom/sigtran/osmo_ss7.h
index 7b0a607..741a7e3 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -89,6 +89,7 @@
uint8_t network_indicator;
struct osmo_ss7_pc_fmt pc_fmt;
bool permit_dyn_rkm_alloc;
+   struct llist_head sccp_address_book;
} cfg;
 };
 
diff --git a/include/osmocom/sigtran/sccp_sap.h 
b/include/osmocom/sigtran/sccp_sap.h
index f378e5c..35d522b 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -247,3 +247,6 @@
osmo_prim_cb prim_cb, uint16_t ssn);
 
 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr 
*oph);
+
+struct osmo_sccp_addr *
+osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7);
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index d952ecd..78b22a7 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -352,6 +352,8 @@
 
llist_add(&inst->list, &osmo_ss7_instances);
 
+   INIT_LLIST_HEAD(&inst->cfg.sccp_address_book);
+
return inst;
 }
 
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 97b5cf0..ce47667 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -36,6 +36,7 @@
 #include 
 
 #include "xua_internal.h"
+#include 
 
 #define XUA_VAR_STR"(sua|m3ua|ipa)"
 
@@ -891,6 +892,515 @@
return CMD_SUCCESS;
 }
 
+/***
+ * SCCP addressbook handling
+ ***/
+
+/* SCCP addressbook */
+struct osmo_sccp_addr_entry {
+   struct llist_head list;
+   struct osmo_ss7_instance *inst;
+   char name[512];
+   struct osmo_sccp_addr addr;
+};
+
+static struct cmd_node sccpaddr_node = {
+   L_CS7_SCCPADDR_NODE,
+   "%s(config-cs7-sccpaddr)# ",
+   1,
+};
+
+static struct cmd_node sccpaddr_gt_node = {
+   L_CS7_SCCPADDR_GT_NODE,
+   "%s(config-cs7-sccpaddr-gt)# ",
+   1,
+};
+
+/* Pick an SCCP address entry from the addressbook by its name */
+struct osmo_sccp_addr_entry *
+addr_entry_by_name(const char *name, const struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_entry *entry;
+   llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+   if (strcmp(entry->name, name) == 0)
+   return entry;
+   }
+   return NULL;
+}
+
+/*! \brief Pick an SCCP address from the addressbook by its name */
+struct osmo_sccp_addr *
+osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7)
+{
+   struct osmo_sccp_addr_entry *entry;
+
+   entry = addr_entry_by_name(name, ss7);
+   if(entry)
+   return &entry->addr;
+
+   return NULL;
+}
+
+/* Generate VTY configuration file snippet */
+static void write_sccp_addressbook(struct vty *vty,
+  const struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_entry *entry;
+
+   if (llist_empty(&inst->cfg.sccp_address_book))
+   return;
+
+   /* FIXME: Add code to write IP-Addresses */
+
+   llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+   vty_out(vty, " sccp-address %s%s", entry->name, VTY_NEWLINE);
+   switch (entry->addr.ri) {
+   case OSMO_SCCP_RI_GT:
+   vty_out(vty, "  routing-indicator GT%s", VTY_NEWLINE);
+   break;
+   case OSMO_SCCP_RI_SSN_PC:
+   vty_out(vty, "  routing-i

[PATCH] libosmo-sccp[master]: sccp: add addressbook functionality for sccp addresses

2017-06-20 Thread dexter
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2924

to look at the new patch set (#6).

sccp: add addressbook functionality for sccp addresses

SCCP addresses are defined through a number of compoinents, not
just an IP-Address, there is also point code, ssn and more. To
simplify and unify the handling of such objects, this patch
introduces an addressbook functionality. The user can set up
multiple addresses per ss7 instance and give them names. Later
that name can be used to reference the address at a later point
in the config. This means that the usage of sccp-addresses from
the programmers point of view boils down to a VTY function that
reads the string name of a previously defined address. The
programmer can then use the API to get a pointer to the SCCP
address struct and use it normally.

For this feature, two additional VTY nodes are necessary,
this commit depends libosmocore change:
Change-Id I42aa29c097f284b85801c5329b015b189640

Change-Id: I068ed7f7d113dab88424a9d47bab7fc703bb7942
---
M include/osmocom/sigtran/osmo_ss7.h
M include/osmocom/sigtran/sccp_sap.h
M src/osmo_ss7.c
M src/osmo_ss7_vty.c
4 files changed, 549 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/24/2924/6

diff --git a/include/osmocom/sigtran/osmo_ss7.h 
b/include/osmocom/sigtran/osmo_ss7.h
index 7b0a607..741a7e3 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -89,6 +89,7 @@
uint8_t network_indicator;
struct osmo_ss7_pc_fmt pc_fmt;
bool permit_dyn_rkm_alloc;
+   struct llist_head sccp_address_book;
} cfg;
 };
 
diff --git a/include/osmocom/sigtran/sccp_sap.h 
b/include/osmocom/sigtran/sccp_sap.h
index f378e5c..35d522b 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -247,3 +247,6 @@
osmo_prim_cb prim_cb, uint16_t ssn);
 
 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr 
*oph);
+
+struct osmo_sccp_addr *
+osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7);
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index d952ecd..78b22a7 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -352,6 +352,8 @@
 
llist_add(&inst->list, &osmo_ss7_instances);
 
+   INIT_LLIST_HEAD(&inst->cfg.sccp_address_book);
+
return inst;
 }
 
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 97b5cf0..60aec9a 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -36,6 +36,7 @@
 #include 
 
 #include "xua_internal.h"
+#include 
 
 #define XUA_VAR_STR"(sua|m3ua|ipa)"
 
@@ -891,6 +892,502 @@
return CMD_SUCCESS;
 }
 
+/***
+ * SCCP addressbook handling
+ ***/
+
+/* SCCP addressbook */
+struct osmo_sccp_addr_entry {
+   struct llist_head list;
+   struct osmo_ss7_instance *inst;
+   char name[512];
+   struct osmo_sccp_addr addr;
+};
+
+static struct cmd_node sccpaddr_node = {
+   L_CS7_SCCPADDR_NODE,
+   "%s(config-cs7-sccpaddr)# ",
+   1,
+};
+
+static struct cmd_node sccpaddr_gt_node = {
+   L_CS7_SCCPADDR_GT_NODE,
+   "%s(config-cs7-sccpaddr-gt)# ",
+   1,
+};
+
+/* Pick an SCCP address entry from the addressbook by its name */
+struct osmo_sccp_addr_entry *
+addr_entry_by_name(const char *name, const struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_entry *entry;
+   llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+   if (strcmp(entry->name, name) == 0)
+   return entry;
+   }
+   return NULL;
+}
+
+/*! \brief Pick an SCCP address from the addressbook by its name */
+struct osmo_sccp_addr *
+osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7)
+{
+   struct osmo_sccp_addr_entry *entry;
+
+   entry = addr_entry_by_name(name, ss7);
+   if(entry)
+   return &entry->addr;
+
+   return NULL;
+}
+
+/* Generate VTY configuration file snippet */
+static void write_sccp_addressbook(struct vty *vty,
+  const struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_entry *entry;
+
+   if (llist_empty(&inst->cfg.sccp_address_book))
+   return;
+
+   /* FIXME: Add code to write IP-Addresses */
+
+   llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+   vty_out(vty, " sccp-address %s%s", entry->name, VTY_NEWLINE);
+   switch (entry->addr.ri) {
+   case OSMO_SCCP_RI_GT:
+   vty_out(vty, "  routing-indicator GT%s", VTY_NEWLINE);
+   break;
+   case OSMO_SCCP_RI_SSN_PC:
+   vty_out(vty, "  routing-i

[PATCH] libosmo-sccp[master]: sccp: add addressbook functionality for sccp addresses

2017-06-19 Thread dexter
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2924

to look at the new patch set (#5).

sccp: add addressbook functionality for sccp addresses

SCCP addresses are defined through a number of compoinents, not
just an IP-Address, there is also point code, ssn and more. To
simplify and unify the handling of such objects, this patch
introduces an addressbook functionality. The user can set up
multiple addresses per ss7 instance and give them names. Later
that name can be used to reference the address at a later point
in the config. This means that the usage of sccp-addresses from
the programmers point of view boils down to a VTY function that
reads the string name of a previously defined address. The
programmer can then use the API to get a pointer to the SCCP
address struct and use it normally.

For this feature, two additional VTY nodes are necessary,
this commit depends libosmocore change:
Change-Id I42aa29c097f284b85801c5329b015b189640

Change-Id: I068ed7f7d113dab88424a9d47bab7fc703bb7942
---
M include/osmocom/sigtran/osmo_ss7.h
M include/osmocom/sigtran/sccp_sap.h
M src/osmo_ss7.c
M src/osmo_ss7_vty.c
4 files changed, 549 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/24/2924/5

diff --git a/include/osmocom/sigtran/osmo_ss7.h 
b/include/osmocom/sigtran/osmo_ss7.h
index 7b0a607..741a7e3 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -89,6 +89,7 @@
uint8_t network_indicator;
struct osmo_ss7_pc_fmt pc_fmt;
bool permit_dyn_rkm_alloc;
+   struct llist_head sccp_address_book;
} cfg;
 };
 
diff --git a/include/osmocom/sigtran/sccp_sap.h 
b/include/osmocom/sigtran/sccp_sap.h
index f378e5c..17d5009 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -247,3 +247,6 @@
osmo_prim_cb prim_cb, uint16_t ssn);
 
 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr 
*oph);
+
+struct osmo_sccp_addr
+*osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7);
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index d952ecd..78b22a7 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -352,6 +352,8 @@
 
llist_add(&inst->list, &osmo_ss7_instances);
 
+   INIT_LLIST_HEAD(&inst->cfg.sccp_address_book);
+
return inst;
 }
 
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 97b5cf0..40431e4 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -36,6 +36,7 @@
 #include 
 
 #include "xua_internal.h"
+#include 
 
 #define XUA_VAR_STR"(sua|m3ua|ipa)"
 
@@ -891,6 +892,502 @@
return CMD_SUCCESS;
 }
 
+/***
+ * SCCP addressbook handling
+ ***/
+
+/* SCCP addressbook */
+struct osmo_sccp_addr_entry {
+   struct llist_head list;
+   struct osmo_ss7_instance *inst;
+   char name[512];
+   struct osmo_sccp_addr addr;
+};
+
+static struct cmd_node sccpaddr_node = {
+   L_CS7_SCCPADDR_NODE,
+   "%s(config-cs7-sccpaddr)# ",
+   1,
+};
+
+static struct cmd_node sccpaddr_gt_node = {
+   L_CS7_SCCPADDR_GT_NODE,
+   "%s(config-cs7-sccpaddr-gt)# ",
+   1,
+};
+
+/* Pick an SCCP address entry from the addressbook by its name */
+struct osmo_sccp_addr_entry *
+addr_entry_by_name(const char *name, const struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_entry *entry;
+   llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+   if (strcmp(entry->name, name) == 0)
+   return entry;
+   }
+   return NULL;
+}
+
+/*! \brief Pick an SCCP address from the addressbook by its name */
+struct osmo_sccp_addr
+*osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7)
+{
+   struct osmo_sccp_addr_entry *entry;
+
+   entry = addr_entry_by_name(name, ss7);
+   if(entry)
+   return &entry->addr;
+
+   return NULL;
+}
+
+/* Generate VTY configuration file snippet */
+static void write_sccp_addressbook(struct vty *vty,
+  const struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_entry *entry;
+
+   if (llist_empty(&inst->cfg.sccp_address_book))
+   return;
+
+   /* FIXME: Add code to write IP-Addresses */
+
+   llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+   vty_out(vty, " sccp-address %s%s", entry->name, VTY_NEWLINE);
+   switch (entry->addr.ri) {
+   case OSMO_SCCP_RI_GT:
+   vty_out(vty, "  routing-indicator GT%s", VTY_NEWLINE);
+   break;
+   case OSMO_SCCP_RI_SSN_PC:
+   vty_out(vty, "  routing-ind

[PATCH] libosmo-sccp[master]: sccp: add addressbook functionality for sccp addresses

2017-06-19 Thread dexter
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2924

to look at the new patch set (#4).

sccp: add addressbook functionality for sccp addresses

SCCP addresses are defined through a number of compoinents, not
just an IP-Address, there is also point code, ssn and more. To
simplify and unify the handling of such objects, this patch
introduces an addressbook functionality. The user can set up
multiple addresses per ss7 instance and give them names. Later
that name can be used to reference the address at a later point
in the config. This means that the usage of sccp-addresses from
the programmers point of view boils down to a VTY function that
reads the string name of a previously defined address. The
programmer can then use the API to get a pointer to the SCCP
address struct and use it normally.

For this feature, two additional VTY nodes are necessary,
this commit depends libosmocore change:
Change-Id I42aa29c097f284b85801c5329b015b189640

Change-Id: I068ed7f7d113dab88424a9d47bab7fc703bb7942
---
M include/osmocom/sigtran/osmo_ss7.h
M include/osmocom/sigtran/sccp_sap.h
M src/osmo_ss7.c
M src/osmo_ss7_vty.c
4 files changed, 549 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/24/2924/4

diff --git a/include/osmocom/sigtran/osmo_ss7.h 
b/include/osmocom/sigtran/osmo_ss7.h
index 7b0a607..741a7e3 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -89,6 +89,7 @@
uint8_t network_indicator;
struct osmo_ss7_pc_fmt pc_fmt;
bool permit_dyn_rkm_alloc;
+   struct llist_head sccp_address_book;
} cfg;
 };
 
diff --git a/include/osmocom/sigtran/sccp_sap.h 
b/include/osmocom/sigtran/sccp_sap.h
index f378e5c..17d5009 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -247,3 +247,6 @@
osmo_prim_cb prim_cb, uint16_t ssn);
 
 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr 
*oph);
+
+struct osmo_sccp_addr
+*osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7);
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index d952ecd..78b22a7 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -352,6 +352,8 @@
 
llist_add(&inst->list, &osmo_ss7_instances);
 
+   INIT_LLIST_HEAD(&inst->cfg.sccp_address_book);
+
return inst;
 }
 
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 97b5cf0..c06cf6a 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -36,6 +36,7 @@
 #include 
 
 #include "xua_internal.h"
+#include 
 
 #define XUA_VAR_STR"(sua|m3ua|ipa)"
 
@@ -891,6 +892,502 @@
return CMD_SUCCESS;
 }
 
+/***
+ * SCCP addressbook handling
+ ***/
+
+/* SCCP addressbook */
+struct osmo_sccp_addr_entry {
+   struct llist_head list;
+   struct osmo_ss7_instance *inst;
+   char name[512];
+   struct osmo_sccp_addr addr;
+};
+
+static struct cmd_node sccpaddr_node = {
+   L_CS7_SCCPADDR_NODE,
+   "%s(config-cs7-sccpaddr)# ",
+   1,
+};
+
+static struct cmd_node sccpaddr_gt_node = {
+   L_CS7_SCCPADDR_GT_NODE,
+   "%s(config-cs7-sccpaddr-gt)# ",
+   1,
+};
+
+/* Pick an SCCP address entry from the addressbook by its name */
+struct osmo_sccp_addr_entry *
+addr_entry_by_name(const char *name, const struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_entry *entry;
+   llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+   if (strcmp(entry->name, name) == 0)
+   return entry;
+   }
+   return NULL;
+}
+
+/*! \brief Pick an SCCP address from the addressbook by its name */
+struct osmo_sccp_addr
+*osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7)
+{
+   struct osmo_sccp_addr_entry *entry;
+
+   entry = addr_entry_by_name(name, ss7);
+   if(entry)
+   return &entry->addr;
+
+   return NULL;
+}
+
+/* Generate VTY configuration file snippet */
+static void write_sccp_addressbook(struct vty *vty,
+  const struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_entry *entry;
+
+   if (llist_empty(&inst->cfg.sccp_address_book))
+   return;
+
+   /* FIXME: Add code to write IP-Addresses */
+
+   llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+   vty_out(vty, " sccp-address %s%s", entry->name, VTY_NEWLINE);
+   switch (entry->addr.ri) {
+   case OSMO_SCCP_RI_GT:
+   vty_out(vty, "  routing-indicator GT%s", VTY_NEWLINE);
+   break;
+   case OSMO_SCCP_RI_SSN_PC:
+   vty_out(vty, "  routing-ind

[PATCH] libosmo-sccp[master]: sccp: add addressbook functionality for sccp addresses

2017-06-19 Thread dexter
Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2924

to look at the new patch set (#3).

sccp: add addressbook functionality for sccp addresses

SCCP addresses are defined through a number of compoinents, not
just an IP-Address, there is also point code, ssn and more. To
simplify and unify the handling of such objects, this patch
introduces an addressbook functionality. The user can set up
multiple addresses per ss7 instance and give them names. Later
that name can be used to reference the address at a later point
in the config. This means that the usage of sccp-addresses from
the programmers point of view boils down to a VTX function that
reads the string name of a previously defined address. The
programmer can then use the API to get a pointer to the SCCP
address struct and use it normally.

Change-Id: I068ed7f7d113dab88424a9d47bab7fc703bb7942
---
M include/osmocom/sigtran/osmo_ss7.h
M include/osmocom/sigtran/sccp_sap.h
M src/osmo_ss7.c
M src/osmo_ss7_vty.c
4 files changed, 549 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/24/2924/3

diff --git a/include/osmocom/sigtran/osmo_ss7.h 
b/include/osmocom/sigtran/osmo_ss7.h
index 7b0a607..741a7e3 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -89,6 +89,7 @@
uint8_t network_indicator;
struct osmo_ss7_pc_fmt pc_fmt;
bool permit_dyn_rkm_alloc;
+   struct llist_head sccp_address_book;
} cfg;
 };
 
diff --git a/include/osmocom/sigtran/sccp_sap.h 
b/include/osmocom/sigtran/sccp_sap.h
index f378e5c..17d5009 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -247,3 +247,6 @@
osmo_prim_cb prim_cb, uint16_t ssn);
 
 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr 
*oph);
+
+struct osmo_sccp_addr
+*osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7);
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index d952ecd..78b22a7 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -352,6 +352,8 @@
 
llist_add(&inst->list, &osmo_ss7_instances);
 
+   INIT_LLIST_HEAD(&inst->cfg.sccp_address_book);
+
return inst;
 }
 
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 97b5cf0..c06cf6a 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -36,6 +36,7 @@
 #include 
 
 #include "xua_internal.h"
+#include 
 
 #define XUA_VAR_STR"(sua|m3ua|ipa)"
 
@@ -891,6 +892,502 @@
return CMD_SUCCESS;
 }
 
+/***
+ * SCCP addressbook handling
+ ***/
+
+/* SCCP addressbook */
+struct osmo_sccp_addr_entry {
+   struct llist_head list;
+   struct osmo_ss7_instance *inst;
+   char name[512];
+   struct osmo_sccp_addr addr;
+};
+
+static struct cmd_node sccpaddr_node = {
+   L_CS7_SCCPADDR_NODE,
+   "%s(config-cs7-sccpaddr)# ",
+   1,
+};
+
+static struct cmd_node sccpaddr_gt_node = {
+   L_CS7_SCCPADDR_GT_NODE,
+   "%s(config-cs7-sccpaddr-gt)# ",
+   1,
+};
+
+/* Pick an SCCP address entry from the addressbook by its name */
+struct osmo_sccp_addr_entry *
+addr_entry_by_name(const char *name, const struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_entry *entry;
+   llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+   if (strcmp(entry->name, name) == 0)
+   return entry;
+   }
+   return NULL;
+}
+
+/*! \brief Pick an SCCP address from the addressbook by its name */
+struct osmo_sccp_addr
+*osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7)
+{
+   struct osmo_sccp_addr_entry *entry;
+
+   entry = addr_entry_by_name(name, ss7);
+   if(entry)
+   return &entry->addr;
+
+   return NULL;
+}
+
+/* Generate VTY configuration file snippet */
+static void write_sccp_addressbook(struct vty *vty,
+  const struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_entry *entry;
+
+   if (llist_empty(&inst->cfg.sccp_address_book))
+   return;
+
+   /* FIXME: Add code to write IP-Addresses */
+
+   llist_for_each_entry(entry, &inst->cfg.sccp_address_book, list) {
+   vty_out(vty, " sccp-address %s%s", entry->name, VTY_NEWLINE);
+   switch (entry->addr.ri) {
+   case OSMO_SCCP_RI_GT:
+   vty_out(vty, "  routing-indicator GT%s", VTY_NEWLINE);
+   break;
+   case OSMO_SCCP_RI_SSN_PC:
+   vty_out(vty, "  routing-indicator PC%s", VTY_NEWLINE);
+   break;
+   case OSMO_SCCP_RI_SSN_IP:
+   vty_out(vty, "  routing-in

[PATCH] libosmo-sccp[master]: sccp: add addressbook functionality for sccp addresses

2017-06-16 Thread dexter
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/2924

to look at the new patch set (#2).

sccp: add addressbook functionality for sccp addresses

SCCP addresses are defined through a number of compoinents, not
just an IP-Address, there is also point code, ssn and more. To
simplify and unify the handling of such objects, this patch
introduces an addressbook functionality. The user can set up
multiple addresses per ss7 instance and give them names. Later
that name can be used to reference the address at a later point
in the config. This means that the usage of sccp-addresses from
the programmers point of view boils down to a VTX function that
reads the string name of a previously defined address. The
programmer can then use the API to get a pointer to the SCCP
address struct and use it normally.

Change-Id: I068ed7f7d113dab88424a9d47bab7fc703bb7942
---
M include/osmocom/sigtran/osmo_ss7.h
M include/osmocom/sigtran/sccp_sap.h
M src/osmo_ss7.c
M src/osmo_ss7_vty.c
4 files changed, 533 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/24/2924/2

diff --git a/include/osmocom/sigtran/osmo_ss7.h 
b/include/osmocom/sigtran/osmo_ss7.h
index 7b0a607..741a7e3 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -89,6 +89,7 @@
uint8_t network_indicator;
struct osmo_ss7_pc_fmt pc_fmt;
bool permit_dyn_rkm_alloc;
+   struct llist_head sccp_address_book;
} cfg;
 };
 
diff --git a/include/osmocom/sigtran/sccp_sap.h 
b/include/osmocom/sigtran/sccp_sap.h
index f378e5c..ccadba7 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -247,3 +247,7 @@
osmo_prim_cb prim_cb, uint16_t ssn);
 
 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr 
*oph);
+
+/*! \brief Pick an SCCP address from the addressbook by its name */
+struct osmo_sccp_addr_list *
+osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7);
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index d952ecd..78b22a7 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -352,6 +352,8 @@
 
llist_add(&inst->list, &osmo_ss7_instances);
 
+   INIT_LLIST_HEAD(&inst->cfg.sccp_address_book);
+
return inst;
 }
 
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 97b5cf0..6e48828 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -36,6 +36,7 @@
 #include 
 
 #include "xua_internal.h"
+#include 
 
 #define XUA_VAR_STR"(sua|m3ua|ipa)"
 
@@ -891,6 +892,485 @@
return CMD_SUCCESS;
 }
 
+/***
+ * SCCP addressbook handling
+ ***/
+
+/* SCCP addressbook */
+struct osmo_sccp_addr_list {
+   struct llist_head list;
+   struct osmo_ss7_instance *inst;
+   char *name;
+   struct osmo_sccp_addr *addr;
+};
+
+static struct cmd_node sccpaddr_node = {
+   L_CS7_SCCPADDR_NODE,
+   "%s(config-cs7-sccpaddr)# ",
+   1,
+};
+
+static struct cmd_node sccpaddr_gt_node = {
+   L_CS7_SCCPADDR_GT_NODE,
+   "%s(config-cs7-sccpaddr-gt)# ",
+   1,
+};
+
+/*! \brief Pick an SCCP address from the addressbook by its name */
+struct osmo_sccp_addr_list *
+osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7)
+{
+   struct osmo_sccp_addr_list *addr;
+   llist_for_each_entry(addr, &ss7->cfg.sccp_address_book, list) {
+   if (strcmp(addr->name, name) == 0)
+   return addr;
+   }
+   return NULL;
+}
+
+/* Generate VTY configuration file snippet */
+static void write_sccp_addressbook(struct vty *vty,
+  const struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_list *addr;
+
+   if (llist_empty(&inst->cfg.sccp_address_book))
+   return;
+
+   /* FIXME: Add code to write IP-Addresses */
+
+   llist_for_each_entry(addr, &inst->cfg.sccp_address_book, list) {
+   vty_out(vty, " sccp-address %s%s", addr->name, VTY_NEWLINE);
+   switch (addr->addr->ri) {
+   case OSMO_SCCP_RI_GT:
+   vty_out(vty, "  routing-indicator GT%s", VTY_NEWLINE);
+   break;
+   case OSMO_SCCP_RI_SSN_PC:
+   vty_out(vty, "  routing-indicator PC%s", VTY_NEWLINE);
+   break;
+   case OSMO_SCCP_RI_SSN_IP:
+   vty_out(vty, "  routing-indicator IP%s", VTY_NEWLINE);
+   break;
+   }
+   if (addr->addr->presence & OSMO_SCCP_ADDR_T_PC)
+   vty_out(vty, "  point-code %s%s",
+   osmo_ss7_pointcode_print(addr->inst,
+   

[PATCH] libosmo-sccp[master]: sccp: add addressbook functionality for sccp addresses

2017-06-15 Thread dexter

Review at  https://gerrit.osmocom.org/2924

sccp: add addressbook functionality for sccp addresses

SCCP addresses are defined through a number of compoinents, not
just an IP-Address, there is also point code, ssn and more. To
simplify and unify the handling of such objects, this patch
introduces an addressbook functionality. The user can set up
multiple addresses per ss7 instance and give them names. Later
that name can be used to reference the address at a later point
in the config. This means that the usage of sccp-addresses from
the programmers point of view boils down to a VTX function that
reads the string name of a previously defined address. The
programmer can then use the API to get a pointer to the SCCP
address struct and use it normally.

Change-Id: I068ed7f7d113dab88424a9d47bab7fc703bb7942
---
M include/osmocom/sigtran/osmo_ss7.h
M include/osmocom/sigtran/sccp_sap.h
M src/osmo_ss7.c
M src/osmo_ss7_vty.c
4 files changed, 535 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/24/2924/1

diff --git a/include/osmocom/sigtran/osmo_ss7.h 
b/include/osmocom/sigtran/osmo_ss7.h
index 7b0a607..741a7e3 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -89,6 +89,7 @@
uint8_t network_indicator;
struct osmo_ss7_pc_fmt pc_fmt;
bool permit_dyn_rkm_alloc;
+   struct llist_head sccp_address_book;
} cfg;
 };
 
diff --git a/include/osmocom/sigtran/sccp_sap.h 
b/include/osmocom/sigtran/sccp_sap.h
index f378e5c..f948727 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -247,3 +247,8 @@
osmo_prim_cb prim_cb, uint16_t ssn);
 
 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr 
*oph);
+
+/*! \brief Pick an SCCP address from the addressbook by its name */
+struct osmo_sccp_addr_list *osmo_sccp_addr_by_name(const char *name,
+  struct osmo_ss7_instance
+  *ss7);
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index d952ecd..78b22a7 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -352,6 +352,8 @@
 
llist_add(&inst->list, &osmo_ss7_instances);
 
+   INIT_LLIST_HEAD(&inst->cfg.sccp_address_book);
+
return inst;
 }
 
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 97b5cf0..d584a44 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -36,6 +36,7 @@
 #include 
 
 #include "xua_internal.h"
+#include 
 
 #define XUA_VAR_STR"(sua|m3ua|ipa)"
 
@@ -891,6 +892,486 @@
return CMD_SUCCESS;
 }
 
+/***
+ * SCCP addressbook handling
+ ***/
+
+/* SCCP addressbook */
+struct osmo_sccp_addr_list {
+   struct llist_head list;
+   struct osmo_ss7_instance *inst;
+   char *name;
+   struct osmo_sccp_addr *addr;
+};
+
+static struct cmd_node sccpaddr_node = {
+   L_CS7_SCCPADDR_NODE,
+   "%s(config-cs7-sccpaddr)# ",
+   1,
+};
+
+static struct cmd_node sccpaddr_gt_node = {
+   L_CS7_SCCPADDR_GT_NODE,
+   "%s(config-cs7-sccpaddr-gt)# ",
+   1,
+};
+
+/* Pick an SCCP address from the addressbook by its name */
+struct osmo_sccp_addr_list *osmo_sccp_addr_by_name(const char *name,
+  struct osmo_ss7_instance
+  *ss7)
+{
+   struct osmo_sccp_addr_list *addr;
+   llist_for_each_entry(addr, &ss7->cfg.sccp_address_book, list) {
+   if (strcmp(addr->name, name) == 0)
+   return addr;
+   }
+   return NULL;
+}
+
+/* Generate VTY configuration file snippet */
+static void write_sccp_addressbook(struct vty *vty,
+  struct osmo_ss7_instance *inst)
+{
+   struct osmo_sccp_addr_list *addr;
+
+   if (llist_empty(&inst->cfg.sccp_address_book))
+   return;
+
+   /* FIXME: Add code to write IP-Addresses */
+
+   llist_for_each_entry(addr, &inst->cfg.sccp_address_book, list) {
+   vty_out(vty, " sccp-address %s%s", addr->name, VTY_NEWLINE);
+   switch (addr->addr->ri) {
+   case OSMO_SCCP_RI_GT:
+   vty_out(vty, "  routing-indicator GT%s", VTY_NEWLINE);
+   break;
+   case OSMO_SCCP_RI_SSN_PC:
+   vty_out(vty, "  routing-indicator PC%s", VTY_NEWLINE);
+   break;
+   case OSMO_SCCP_RI_SSN_IP:
+   vty_out(vty, "  routing-indicator IP%s", VTY_NEWLINE);
+   break;
+   }
+   if (addr->addr->presence & OSMO_SCCP_ADDR_T_PC)
+   vty_out(vty, "  point-code %s%s",
+