diff options
author | Daniel Willmann <daniel@totalueberwachung.de> | 2011-07-22 17:55:42 +0200 |
---|---|---|
committer | Daniel Willmann <daniel@totalueberwachung.de> | 2011-07-28 19:40:26 +0200 |
commit | 81671d54b0141b2db57df386ebf8dd7131131a24 (patch) | |
tree | 2880fc007e8f99f42649acf2e573d5326dd2f2eb /openbsc | |
parent | 145c58df93e0388ba012b55fc4b70123fb706601 (diff) |
libctrl: Change controlif_setup so it returns the ctrl handle
nat: Catch up with controlif_setup API change
We now save a control handle reference in the nat
osmo-bsc: Catch up with controlif_setup API change
We now save a control handle reference in the gsm network
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/include/openbsc/bsc_nat.h | 3 | ||||
-rw-r--r-- | openbsc/include/openbsc/control_cmd.h | 10 | ||||
-rw-r--r-- | openbsc/include/openbsc/gsm_data.h | 3 | ||||
-rw-r--r-- | openbsc/src/libctrl/control_if.c | 22 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_main.c | 3 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_nat.c | 2 |
6 files changed, 26 insertions, 17 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 97c0a1cb4..5423ed278 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -310,6 +310,9 @@ struct bsc_nat { /* statistics */ struct bsc_nat_statistics stats; + + /* control interface */ + struct ctrl_handle *ctrl; }; struct bsc_nat_ussd_con { diff --git a/openbsc/include/openbsc/control_cmd.h b/openbsc/include/openbsc/control_cmd.h index 82252cb6a..a41a710ea 100644 --- a/openbsc/include/openbsc/control_cmd.h +++ b/openbsc/include/openbsc/control_cmd.h @@ -29,6 +29,14 @@ enum ctrl_type { CTRL_TYPE_ERROR }; +struct ctrl_handle { + struct osmo_fd listen_fd; + struct gsm_network *gsmnet; + + /* List of control connections */ + struct llist_head ccon_list; +}; + struct ctrl_connection { struct llist_head list_entry; @@ -149,6 +157,6 @@ struct ctrl_cmd_element cmd_##cmdname = { \ } struct gsm_network; -int controlif_setup(struct gsm_network *gsmnet, uint16_t port); +struct ctrl_handle *controlif_setup(struct gsm_network *gsmnet, uint16_t port); #endif /* _CONTROL_CMD_H */ diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 715ff1bdd..a5244da81 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -288,6 +288,9 @@ struct gsm_network { /* subscriber related features */ int keep_subscr; struct gsm_sms_queue *sms_queue; + + /* control interface */ + struct ctrl_handle *ctrl; }; #define SMS_HDR_SIZE 128 diff --git a/openbsc/src/libctrl/control_if.c b/openbsc/src/libctrl/control_if.c index 4ab3f3a6c..fc28bb69d 100644 --- a/openbsc/src/libctrl/control_if.c +++ b/openbsc/src/libctrl/control_if.c @@ -60,14 +60,6 @@ #include <osmocom/vty/command.h> #include <osmocom/vty/vector.h> -struct ctrl_handle { - struct osmo_fd listen_fd; - struct gsm_network *gsmnet; - - /* List of control connections */ - struct llist_head ccon_list; -}; - vector ctrl_node_vec; int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd) @@ -606,33 +598,35 @@ int verify_counter(struct ctrl_cmd *cmd, const char *value, void *data) return 0; } -int controlif_setup(struct gsm_network *gsmnet, uint16_t port) +struct ctrl_handle *controlif_setup(struct gsm_network *gsmnet, uint16_t port) { int ret; struct ctrl_handle *ctrl; ctrl = talloc_zero(tall_bsc_ctx, struct ctrl_handle); if (!ctrl) - return -ENOMEM; + return NULL; INIT_LLIST_HEAD(&ctrl->ccon_list); ctrl->gsmnet = gsmnet; ctrl_node_vec = vector_init(5); - if (!ctrl_node_vec) - return -ENOMEM; + if (!ctrl_node_vec) { + talloc_free(ctrl); + return NULL; + } /* Listen for control connections */ ret = make_sock(&ctrl->listen_fd, IPPROTO_TCP, 0, port, 0, listen_fd_cb, ctrl); if (ret < 0) { talloc_free(ctrl); - return ret; + return NULL; } ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_rate_ctr); ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_counter); - return ret; + return ctrl; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index 7d376ef0e..fa0bd0724 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -422,7 +422,8 @@ int main(int argc, char **argv) } bsc_api_init(bsc_gsmnet, osmo_bsc_api()); - controlif_setup(bsc_gsmnet, 4249); + bsc_gsmnet->ctrl = controlif_setup(bsc_gsmnet, 4249); + ctrl_cmd_install(CTRL_NODE_NET, &cmd_net_loc); ctrl_cmd_install(CTRL_NODE_NET, &cmd_net_rf_lock); ctrl_cmd_install(CTRL_NODE_TRX, &cmd_trx_rf_lock); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index 445f45915..50e51f191 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -1750,7 +1750,7 @@ int main(int argc, char **argv) exit(1); } - controlif_setup(NULL, 4250); + nat->ctrl = controlif_setup(NULL, 4250); ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_fwd_cmd); nat->msc_con->connection_loss = msc_connection_was_lost; |