From holger at freyther.de Sun May 15 19:25:57 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sun, 15 May 2011 21:25:57 +0200 Subject: Reseting Unit-ID on nanoBTS In-Reply-To: <0D34BC718F0D4A65ABBF0D494EAB83F0@dell6400> References: <0D34BC718F0D4A65ABBF0D494EAB83F0@dell6400> Message-ID: <4DD028C5.1050800@freyther.de> On 05/15/2011 06:05 PM, henry han wrote: > ??! Ni Hao! do you think you could try to write in English? From laforge at gnumonks.org Sun May 22 20:05:41 2011 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 22 May 2011 22:05:41 +0200 Subject: [PATCH 0/3] new VTY commands to enable IPA proxy In-Reply-To: <1303235267-14168-1-git-send-email-pablo@gnumonks.org> References: <1303235267-14168-1-git-send-email-pablo@gnumonks.org> Message-ID: <20110522200541.GY4243@prithivi.gnumonks.org> Hi Pablo, sorry for getting back to this after one month ... On Tue, Apr 19, 2011 at 07:47:44PM +0200, pablo at gnumonks.org wrote: > This patchset adds new VTY commands that allows to route IPA flows. can you re-base this patchset against current openbsc and develop it further into the following direction: * cleanly split the IPA part from openbsc, allowing it to be re-used from other applications. All related VTY code should be part of the IPA code. The application (like osmo-nitb) should only call an initialization function, which then takes care of registering with vty, etc. * I imagine something like a libosmoipa as a final result. initially it can be built as part of openbsc.git, later it should become part of libosmocore.git The idea behind this is simple: I'd like to re-use the existing IPA code from within osmo-bts, where right now Andreas has created a separate implementation of the same protocol (which I think is not the best style). Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From pablo at gnumonks.org Mon May 23 16:54:43 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Mon, 23 May 2011 18:54:43 +0200 Subject: [PATCH 0/3] new VTY commands to enable IPA proxy In-Reply-To: <20110522200541.GY4243@prithivi.gnumonks.org> References: <1303235267-14168-1-git-send-email-pablo@gnumonks.org> <20110522200541.GY4243@prithivi.gnumonks.org> Message-ID: <4DDA9153.30805@gnumonks.org> Hi Harald, On 22/05/11 22:05, Harald Welte wrote: > Hi Pablo, > > sorry for getting back to this after one month ... Never mind. I'm happy that all those things got merged :-). > On Tue, Apr 19, 2011 at 07:47:44PM +0200, pablo at gnumonks.org wrote: > >> This patchset adds new VTY commands that allows to route IPA flows. > > can you re-base this patchset against current openbsc and develop it > further into the following direction: > > * cleanly split the IPA part from openbsc, allowing it to be re-used > from other applications. All related VTY code should be part of the > IPA code. The application (like osmo-nitb) should only call an > initialization function, which then takes care of registering with > vty, etc. I guess that you refer to all IPA code, not only the code in my patch. > * I imagine something like a libosmoipa as a final result. initially it > can be built as part of openbsc.git, later it should become part of > libosmocore.git Sure. I'll make it part of libosmocore since the beginning, so we can skip the transition. > The idea behind this is simple: I'd like to re-use the existing IPA code > from within osmo-bts, where right now Andreas has created a separate > implementation of the same protocol (which I think is not the best > style). Having a look at that code, I guess that it's still quite experimental, but if there's some way to help/test it, let me know. The A-bis interface is the part that I better know at this point, I'll be happy to contribute to that part :-). From holger at freyther.de Mon May 2 11:52:25 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 02 May 2011 13:52:25 +0200 Subject: TODO: openbsc.cfg console logging options In-Reply-To: <4DBB4E78.5000800@gnumonks.org> References: <20110427164629.GC655@prithivi.gnumonks.org> <4DBAD1E0.10802@freyther.de> <4DBB4E78.5000800@gnumonks.org> Message-ID: <4DBE9AF9.10309@freyther.de> On 04/30/2011 01:49 AM, Pablo Neira Ayuso wrote: > Could you develop the scenario a bit? The problem that you refer would > occur if `-d' and `-e' are used? > Hi, the attached config file is the result of 'write' in the VTY code, e.g. it contains the current stderr config. $ ./src/osmo-bsc/osmo-bsc -c openbsc.bsc -e 1 now the -e 1 is applied (log_set_log_level(stderr_target, atoi(optarg));) before the call to bsc_bootstrap_network. So somehow we should define what takes precedence and make this work across our utilities. E.g. osmo-bsc and osmi-nitb behave the same right now (-e 1 being ignored if stderr is configured in the config file). With osmo-bsc one sees a lot more messages on startup if -e 1 is applied. holger -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: openbsc.bsc URL: From pablo at gnumonks.org Tue May 3 20:40:39 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 3 May 2011 22:40:39 +0200 Subject: [PATCH 0/5] libosmocore: logging framework updates Message-ID: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Hi! This patchset updates the logging framework, it contains one fix and several updates/improvements. You can find it in pablo/logging branch. Please, merge it! Pablo Neira Ayuso (5): logging: fix missing description of global loglevel logging: several memory allocation belong to tall_log_ctx context logging: rework _output() function logging: remove workaround now that _output() has been reworked logging: make sure the output is null-terminated src/logging.c | 77 +++++++++++++++++++++++++++++--------------------------- 1 files changed, 40 insertions(+), 37 deletions(-) -- 1.2.3.4 From pablo at gnumonks.org Tue May 3 20:40:40 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 3 May 2011 22:40:40 +0200 Subject: [PATCH 1/5] logging: fix missing description of global loglevel In-Reply-To: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> References: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304455244-15997-2-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso OpenBSC> logging level all Global setting for all subsystems <----- this description was missing rll A-bis Radio Link Layer (RLL) [...] This problem was introduced by myself in: "vty: integration with logging framework" 04139f14b6197e3ec996133a945af3fa8a68fb7a --- src/logging.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/logging.c b/src/logging.c index 77c8a50..7b1ab13 100644 --- a/src/logging.c +++ b/src/logging.c @@ -517,6 +517,7 @@ const char *log_vty_command_description(const struct log_info *info) for (i = 0; i < LOGLEVEL_DEFS; i++) size += strlen(loglevel_descriptions[i]) + 1; + size += strlen("Global setting for all subsystems") + 1; rem = size; str = talloc_zero_size(NULL, size); if (!str) @@ -528,6 +529,12 @@ const char *log_vty_command_description(const struct log_info *info) goto err; OSMO_SNPRINTF_RET(ret, rem, offset, len); + ret = snprintf(str + offset, rem, + "Global setting for all subsystems\n"); + if (ret < 0) + goto err; + OSMO_SNPRINTF_RET(ret, rem, offset, len); + for (i = 0; i < info->num_cat; i++) { ret = snprintf(str + offset, rem, "%s\n", info->cat[i].description); -- 1.7.2.3 From pablo at gnumonks.org Tue May 3 20:40:41 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 3 May 2011 22:40:41 +0200 Subject: [PATCH 2/5] logging: several memory allocation belong to tall_log_ctx context In-Reply-To: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> References: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304455244-15997-3-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Several talloc_zero in logging use NULL context, use tall_log_ctx instead. --- src/logging.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/logging.c b/src/logging.c index 7b1ab13..7fabfcb 100644 --- a/src/logging.c +++ b/src/logging.c @@ -448,7 +448,7 @@ const char *log_vty_command_string(const struct log_info *info) size += strlen(loglevel_strs[i].str) + 1; rem = size; - str = talloc_zero_size(NULL, size); + str = talloc_zero_size(tall_log_ctx, size); if (!str) return NULL; @@ -519,7 +519,7 @@ const char *log_vty_command_description(const struct log_info *info) size += strlen("Global setting for all subsystems") + 1; rem = size; - str = talloc_zero_size(NULL, size); + str = talloc_zero_size(tall_log_ctx, size); if (!str) return NULL; -- 1.7.2.3 From pablo at gnumonks.org Tue May 3 20:40:42 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 3 May 2011 22:40:42 +0200 Subject: [PATCH 3/5] logging: rework _output() function In-Reply-To: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> References: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304455244-15997-4-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso This patch reworks _output() to handle snprintf() return value appropriately and to use one single buffer to build the logging string, instead of four. --- src/logging.c | 51 +++++++++++++++++++++++++++------------------------ 1 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/logging.c b/src/logging.c index 7fabfcb..526b39e 100644 --- a/src/logging.c +++ b/src/logging.c @@ -143,29 +143,19 @@ static void _output(struct log_target *target, unsigned int subsys, unsigned int level, char *file, int line, int cont, const char *format, va_list ap) { - char col[30]; - char sub[30]; - char tim[30]; char buf[4096]; - char final[4096]; - - /* prepare the data */ - col[0] = '\0'; - sub[0] = '\0'; - tim[0] = '\0'; - buf[0] = '\0'; + int ret, len = 0, offset = 0, rem = sizeof(buf); /* are we using color */ if (target->use_color) { const char *c = color(subsys); if (c) { - snprintf(col, sizeof(col), "%s", color(subsys)); - col[sizeof(col)-1] = '\0'; + ret = snprintf(buf + offset, rem, "%s", color(subsys)); + if (ret < 0) + goto err; + OSMO_SNPRINTF_RET(ret, rem, offset, len); } } - vsnprintf(buf, sizeof(buf), format, ap); - buf[sizeof(buf)-1] = '\0'; - if (!cont) { if (target->print_timestamp) { char *timestr; @@ -173,17 +163,30 @@ static void _output(struct log_target *target, unsigned int subsys, tm = time(NULL); timestr = ctime(&tm); timestr[strlen(timestr)-1] = '\0'; - snprintf(tim, sizeof(tim), "%s ", timestr); - tim[sizeof(tim)-1] = '\0'; + ret = snprintf(buf + offset, rem, "%s ", timestr); + if (ret < 0) + goto err; + OSMO_SNPRINTF_RET(ret, rem, offset, len); } - snprintf(sub, sizeof(sub), "<%4.4x> %s:%d ", subsys, file, line); - sub[sizeof(sub)-1] = '\0'; + ret = snprintf(buf + offset, rem, "<%4.4x> %s:%d ", + subsys, file, line); + if (ret < 0) + goto err; + OSMO_SNPRINTF_RET(ret, rem, offset, len); } + ret = vsnprintf(buf + offset, rem, format, ap); + if (ret < 0) + goto err; + OSMO_SNPRINTF_RET(ret, rem, offset, len); - snprintf(final, sizeof(final), "%s%s%s%s%s", col, tim, sub, buf, - target->use_color ? "\033[0;m" : ""); - final[sizeof(final)-1] = '\0'; - target->output(target, level, final); + ret = snprintf(buf + offset, rem, "%s", + target->use_color ? "\033[0;m" : ""); + if (ret < 0) + goto err; + OSMO_SNPRINTF_RET(ret, rem, offset, len); +err: + buf[sizeof(buf)-1] = '\0'; + target->output(target, level, buf); } -- 1.7.2.3 From pablo at gnumonks.org Tue May 3 20:40:43 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 3 May 2011 22:40:43 +0200 Subject: [PATCH 4/5] logging: remove workaround now that _output() has been reworked In-Reply-To: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> References: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304455244-15997-5-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso This patch removes a workaround to fix some strange memory corruption now that _output() has been completely reworked and we make use of snprintf appropriately. --- src/logging.c | 15 +++------------ 1 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/logging.c b/src/logging.c index 526b39e..6797afc 100644 --- a/src/logging.c +++ b/src/logging.c @@ -221,19 +221,10 @@ static void _logp(unsigned int subsys, int level, char *file, int line, else if (osmo_log_info->filter_fn) output = osmo_log_info->filter_fn(&log_context, tar); + if (!output) + continue; - if (output) { - /* FIXME: copying the va_list is an ugly - * workaround against a bug hidden somewhere in - * _output. If we do not copy here, the first - * call to _output() will corrupt the va_list - * contents, and any further _output() calls - * with the same va_list will segfault */ - va_list bp; - va_copy(bp, ap); - _output(tar, subsys, level, file, line, cont, format, bp); - va_end(bp); - } + _output(tar, subsys, level, file, line, cont, format, ap); } } -- 1.7.2.3 From pablo at gnumonks.org Tue May 3 20:40:44 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 3 May 2011 22:40:44 +0200 Subject: [PATCH 5/5] logging: make sure the output is null-terminated In-Reply-To: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> References: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304455244-15997-6-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso If we reach the buffer size or snprintf fails, we want to make sure that the output is null-terminated. --- src/logging.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/src/logging.c b/src/logging.c index 6797afc..0911010 100644 --- a/src/logging.c +++ b/src/logging.c @@ -493,6 +493,7 @@ const char *log_vty_command_string(const struct log_info *info) goto err; OSMO_SNPRINTF_RET(ret, rem, offset, len); err: + str[size-1] = '\0'; return str; } @@ -544,6 +545,7 @@ const char *log_vty_command_description(const struct log_info *info) OSMO_SNPRINTF_RET(ret, rem, offset, len); } err: + str[size-1] = '\0'; return str; } -- 1.7.2.3 From laforge at gnumonks.org Wed May 4 09:10:20 2011 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 4 May 2011 11:10:20 +0200 Subject: [PATCH 0/5] libosmocore: logging framework updates In-Reply-To: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> References: <1304455244-15997-1-git-send-email-pablo@gnumonks.org> Message-ID: <20110504091020.GD2911@prithivi.gnumonks.org> On Tue, May 03, 2011 at 10:40:39PM +0200, pablo at gnumonks.org wrote: > This patchset updates the logging framework, it contains one fix and > several updates/improvements. thanks a lot for your clean-up work, it is much appreciated. I've rebased and merged yor logging branch. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From pablo at gnumonks.org Tue May 3 20:44:38 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 3 May 2011 22:44:38 +0200 Subject: [PATCH 0/3] openBSC: several misc updates Message-ID: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Hi! The following patchset contains one fix and two improvements. You can find them in the pablo/updates branch. Please, merge it! Pablo Neira Ayuso (3): msc: bail out if subscriber VTY command fails abis: skip e1_input nesting if empty bsc: on-demand setup of nanoBTS and HSL femto sockets openbsc/src/libabis/e1_input_vty.c | 8 ++++++-- openbsc/src/libbsc/bsc_init.c | 20 +++++++++++++++----- openbsc/src/libmsc/vty_interface_layer3.c | 11 ++++++++++- 3 files changed, 31 insertions(+), 8 deletions(-) -- 1.7.2.3 From pablo at gnumonks.org Tue May 3 20:44:39 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 3 May 2011 22:44:39 +0200 Subject: [PATCH 1/3] msc: bail out if subscriber VTY command fails In-Reply-To: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> References: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304455481-16231-2-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso This patch adds several messages that would be displayed if: * the Ki argument is missing. * you pass an invalid Ki. * the database fails to perform the operation (add/delete/update). Before this patch, no messages were spotted on this errors. I noticed this while adding Ki to the existing subscribers in the nanoBTS setup: I introduced a wrong Ki but the VTY command line did not report any error. A quick look at the database via sqlite command confirmed that the new authkey information was not added. --- openbsc/src/libmsc/vty_interface_layer3.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index 2d3dd14..6ac2c65 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -575,6 +575,8 @@ DEFUN(ena_subscr_a3a8, } else { /* Unknown method */ subscr_put(subscr); + vty_out(vty, "%% Unknown auth method %s%s", + alg_str, VTY_NEWLINE); return CMD_WARNING; } @@ -582,6 +584,8 @@ DEFUN(ena_subscr_a3a8, rc = hexparse(ki_str, ainfo.a3a8_ki, sizeof(ainfo.a3a8_ki)); if ((rc > maxlen) || (rc < minlen)) { subscr_put(subscr); + vty_out(vty, "%% Wrong Ki `%s'%s", + ki_str, VTY_NEWLINE); return CMD_WARNING; } ainfo.a3a8_ki_len = rc; @@ -589,6 +593,7 @@ DEFUN(ena_subscr_a3a8, ainfo.a3a8_ki_len = 0; if (minlen) { subscr_put(subscr); + vty_out(vty, "%% Missing Ki argument%s", VTY_NEWLINE); return CMD_WARNING; } } @@ -601,7 +606,11 @@ DEFUN(ena_subscr_a3a8, db_sync_lastauthtuple_for_subscr(NULL, subscr); subscr_put(subscr); - return rc ? CMD_WARNING : CMD_SUCCESS; + if (rc) { + vty_out(vty, "%% Operation has failed%s", VTY_NEWLINE); + return CMD_WARNING; + } + return CMD_SUCCESS; } DEFUN(subscriber_purge, -- 1.7.2.3 From laforge at gnumonks.org Wed May 4 09:04:16 2011 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 4 May 2011 11:04:16 +0200 Subject: [PATCH 1/3] msc: bail out if subscriber VTY command fails In-Reply-To: <1304455481-16231-2-git-send-email-pablo@gnumonks.org> References: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> <1304455481-16231-2-git-send-email-pablo@gnumonks.org> Message-ID: <20110504090416.GC2911@prithivi.gnumonks.org> On Tue, May 03, 2011 at 10:44:39PM +0200, pablo at gnumonks.org wrote: > From: Pablo Neira Ayuso > > This patch adds several messages that would be displayed if: thanks, applied. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From pablo at gnumonks.org Tue May 3 20:44:40 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 3 May 2011 22:44:40 +0200 Subject: [PATCH 2/3] abis: skip e1_input nesting if empty In-Reply-To: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> References: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304455481-16231-3-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso With this patch, we don't including e1_input if it's empty [...] timeslot 7 phys_chan_config TCH/F hopping enabled 0 e1_input <----------------- empty, it should not show up. msc [...] --- openbsc/src/libabis/e1_input_vty.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/openbsc/src/libabis/e1_input_vty.c b/openbsc/src/libabis/e1_input_vty.c index 7dbf17a..af984bc 100644 --- a/openbsc/src/libabis/e1_input_vty.c +++ b/openbsc/src/libabis/e1_input_vty.c @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -75,10 +76,13 @@ DEFUN(cfg_e1inp, cfg_e1inp_cmd, static int e1inp_config_write(struct vty *vty) { struct e1inp_line *line; - - vty_out(vty, "e1_input%s", VTY_NEWLINE); + bool heading = false; llist_for_each_entry(line, &e1inp_line_list, list) { + if (!heading) { + vty_out(vty, "e1_input%s", VTY_NEWLINE); + heading = true; + } vty_out(vty, " e1_line %u driver %s%s", line->num, line->driver->name, VTY_NEWLINE); } -- 1.7.2.3 From holger at freyther.de Tue May 3 21:14:41 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 03 May 2011 23:14:41 +0200 Subject: [PATCH 2/3] abis: skip e1_input nesting if empty In-Reply-To: <1304455481-16231-3-git-send-email-pablo@gnumonks.org> References: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> <1304455481-16231-3-git-send-email-pablo@gnumonks.org> Message-ID: <4DC07041.8080407@freyther.de> On 05/03/2011 10:44 PM, pablo at gnumonks.org wrote: > - vty_out(vty, "e1_input%s", VTY_NEWLINE); > + bool heading = false; what about if (llist_empty(&e1in..) return; > > llist_for_each_entry(line, &e1inp_line_list, list) { > + if (!heading) { > + vty_out(vty, "e1_input%s", VTY_NEWLINE); > + heading = true; > + } > vty_out(vty, " e1_line %u driver %s%s", line->num, > line->driver->name, VTY_NEWLINE); > } From pablo at gnumonks.org Thu May 5 15:10:50 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Thu, 05 May 2011 17:10:50 +0200 Subject: [PATCH 2/3] abis: skip e1_input nesting if empty In-Reply-To: <4DC07041.8080407@freyther.de> References: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> <1304455481-16231-3-git-send-email-pablo@gnumonks.org> <4DC07041.8080407@freyther.de> Message-ID: <4DC2BDFA.3060808@gnumonks.org> On 03/05/11 23:14, Holger Hans Peter Freyther wrote: > On 05/03/2011 10:44 PM, pablo at gnumonks.org wrote: > >> - vty_out(vty, "e1_input%s", VTY_NEWLINE); >> + bool heading = false; > > what about > > if (llist_empty(&e1in..) > return; Please, find it attached the new patch with your suggestion. -------------- next part -------------- A non-text attachment was scrubbed... Name: x.patch Type: text/x-patch Size: 900 bytes Desc: not available URL: From pablo at gnumonks.org Tue May 3 20:44:41 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Tue, 3 May 2011 22:44:41 +0200 Subject: [PATCH 3/3] bsc: on-demand setup of nanoBTS and HSL femto sockets In-Reply-To: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> References: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304455481-16231-4-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso The daemon set up nanoBTS and HSL femto sockets by default, ie. the three sockets to support these two drivers are open even if we have no BTS of that kind. This patch enables them if they are present in any configuration file. --- openbsc/src/libbsc/bsc_init.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c index 8ea2cfa..09d826e 100644 --- a/openbsc/src/libbsc/bsc_init.c +++ b/openbsc/src/libbsc/bsc_init.c @@ -19,6 +19,7 @@ * */ +#include #include #include #include @@ -415,6 +416,7 @@ int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *), struct telnet_connection dummy_conn; struct gsm_bts *bts; int rc; + bool enabled_nanobts = false, enabled_hsl = false; /* initialize our data structures */ bsc_gsmnet = gsm_network_init(1, 1, mncc_recv); @@ -444,7 +446,20 @@ int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *), switch (bts->type) { case GSM_BTS_TYPE_NANOBTS: + if (!enabled_nanobts) { + rc = ipaccess_setup(bsc_gsmnet); + if (rc < 0) + break; + enabled_nanobts = true; + } + break; case GSM_BTS_TYPE_HSL_FEMTO: + if (!enabled_hsl) { + rc = hsl_setup(bsc_gsmnet); + if (rc < 0) + break; + enabled_hsl = true; + } break; default: rc = e1_reconfig_bts(bts); @@ -456,10 +471,5 @@ int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *), exit (1); } } - - /* initialize nanoBTS support omce */ - rc = ipaccess_setup(bsc_gsmnet); - rc = hsl_setup(bsc_gsmnet); - return 0; } -- 1.7.2.3 From holger at freyther.de Tue May 3 21:29:16 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 03 May 2011 23:29:16 +0200 Subject: [PATCH 3/3] bsc: on-demand setup of nanoBTS and HSL femto sockets In-Reply-To: <1304455481-16231-4-git-send-email-pablo@gnumonks.org> References: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> <1304455481-16231-4-git-send-email-pablo@gnumonks.org> Message-ID: <4DC073AC.3080906@freyther.de> On 05/03/2011 10:44 PM, pablo at gnumonks.org wrote: > From: Pablo Neira Ayuso > > The daemon set up nanoBTS and HSL femto sockets by default, > ie. the three sockets to support these two drivers are open even > if we have no BTS of that kind. This patch enables them if they > are present in any configuration file. good goal, but maybe trigger this from within the VTY code? E.g. what if I want to add a HSL BTS to a running system? or start with no config file at all? Anyway our story of doing such config changes at runtime is not very good. holger From laforge at gnumonks.org Wed May 4 09:02:53 2011 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 4 May 2011 11:02:53 +0200 Subject: [PATCH 3/3] bsc: on-demand setup of nanoBTS and HSL femto sockets In-Reply-To: <4DC073AC.3080906@freyther.de> References: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> <1304455481-16231-4-git-send-email-pablo@gnumonks.org> <4DC073AC.3080906@freyther.de> Message-ID: <20110504090253.GB2911@prithivi.gnumonks.org> On Tue, May 03, 2011 at 11:29:16PM +0200, Holger Hans Peter Freyther wrote: > On 05/03/2011 10:44 PM, pablo at gnumonks.org wrote: > > From: Pablo Neira Ayuso > > > > The daemon set up nanoBTS and HSL femto sockets by default, > > ie. the three sockets to support these two drivers are open even > > if we have no BTS of that kind. This patch enables them if they > > are present in any configuration file. > > good goal, but maybe trigger this from within the VTY code? E.g. what > if I want to add a HSL BTS to a running system? or start with no > config file at all? Anyway our story of doing such config changes at > runtime is not very good. yes, but I agree we should do this from the VTY code. At least all new features we're adding should be more runtime vty based then thinking of a config file that we parse once and then forget about it. So when we get a 'bts type ...' command (or when we leave the BTS_NODE) we should check if the respective sockets are needed. But yes, another big long pending TODO is to think about how we can make most or even all runtime config changes work. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From pablo at gnumonks.org Thu May 5 15:08:08 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Thu, 05 May 2011 17:08:08 +0200 Subject: [PATCH 3/3] bsc: on-demand setup of nanoBTS and HSL femto sockets In-Reply-To: <20110504090253.GB2911@prithivi.gnumonks.org> References: <1304455481-16231-1-git-send-email-pablo@gnumonks.org> <1304455481-16231-4-git-send-email-pablo@gnumonks.org> <4DC073AC.3080906@freyther.de> <20110504090253.GB2911@prithivi.gnumonks.org> Message-ID: <4DC2BD58.5030407@gnumonks.org> On 04/05/11 11:02, Harald Welte wrote: > On Tue, May 03, 2011 at 11:29:16PM +0200, Holger Hans Peter Freyther wrote: >> On 05/03/2011 10:44 PM, pablo at gnumonks.org wrote: >>> From: Pablo Neira Ayuso >>> >>> The daemon set up nanoBTS and HSL femto sockets by default, >>> ie. the three sockets to support these two drivers are open even >>> if we have no BTS of that kind. This patch enables them if they >>> are present in any configuration file. >> >> good goal, but maybe trigger this from within the VTY code? E.g. what >> if I want to add a HSL BTS to a running system? or start with no >> config file at all? Anyway our story of doing such config changes at >> runtime is not very good. > > yes, but I agree we should do this from the VTY code. At least all new > features we're adding should be more runtime vty based then thinking of > a config file that we parse once and then forget about it. > > So when we get a 'bts type ...' command (or when we leave the BTS_NODE) > we should check if the respective sockets are needed. You can find a patch attached to support what you describe, I tried to make as generic as possible. Please, have a look at the description. The new start(...) function for e1inp_driver objects could be use to replace the e1inp_init() call. The idea that I propose is to register the dahdi and misdn input drivers if we receive an "e1_input" command (via VTY or config file), then invoke start(...). BTW, e1inp_init() is only used by osmo-nitb, any reason for that? I also added a new attribute to the BTS model object, this field is useless for bs11. I found no way to relate e1inp_driver and bts objects in the case of hsl and ipaccess. This is usually done by means of the "e1_input" command in bs11, but its use does not make sense for hsl and ipaccess. > But yes, another big long pending TODO is to think about how we can > make most or even all runtime config changes work. Adding support for config file reload in runtime seems interesting to me, I would prefer changing things in the config file and reloading than typing all those VTY commands to add a new BTS, IMO. -------------- next part -------------- A non-text attachment was scrubbed... Name: ondemand-sockets-creation.patch Type: text/x-patch Size: 7643 bytes Desc: not available URL: From pablo at netfilter.org Thu May 5 16:36:40 2011 From: pablo at netfilter.org (Pablo Neira Ayuso) Date: Thu, 05 May 2011 18:36:40 +0200 Subject: [PATCH] libosmocore: fix namespace pollution (1/*) Message-ID: <20110505163519.5214.4409.stgit@decadence> This is the first patch in the series, I'll start little by little. This first patch uses the new prefix for timer objects and functions. Please, apply! --- Pablo Neira Ayuso (1): timer: use namespace prefix osmo_timer* include/osmocom/core/timer.h | 20 ++++++++++---------- src/rate_ctr.c | 6 +++--- src/select.c | 8 ++++---- src/timer.c | 29 +++++++++++++++-------------- tests/timer/timer_test.c | 16 ++++++++-------- 5 files changed, 40 insertions(+), 39 deletions(-) -- Signature From pablo at netfilter.org Thu May 5 16:37:09 2011 From: pablo at netfilter.org (Pablo Neira Ayuso) Date: Thu, 05 May 2011 18:37:09 +0200 Subject: [PATCH] timer: use namespace prefix osmo_timer* In-Reply-To: <20110505163519.5214.4409.stgit@decadence> References: <20110505163519.5214.4409.stgit@decadence> Message-ID: <20110505163709.5214.64721.stgit@decadence> From: Pablo Neira Ayuso Summary of changes: s/struct timer_list/struct osmo_timer_list/g s/bsc_add_timer/osmo_timer_add/g s/bsc_schedule_timer/osmo_timer_schedule/g s/bsc_del_timer/osmo_timer_del/g s/bsc_timer_pending/osmo_timer_pending/g s/bsc_nearest_timer/osmo_timers_nearest/g s/bsc_prepare_timers/osmo_timers_prepare/g s/bsc_update_timers/osmo_timers_update/g s/bsc_timer_check/osmo_timers_check/g --- include/osmocom/core/timer.h | 20 ++++++++++---------- src/rate_ctr.c | 6 +++--- src/select.c | 8 ++++---- src/timer.c | 29 +++++++++++++++-------------- tests/timer/timer_test.c | 16 ++++++++-------- 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/include/osmocom/core/timer.h b/include/osmocom/core/timer.h index 1966478..db2ecbf 100644 --- a/include/osmocom/core/timer.h +++ b/include/osmocom/core/timer.h @@ -27,7 +27,7 @@ /** * Timer management: - * - Create a struct timer_list + * - Create a struct osmo_timer_list * - Fill out timeout and use add_timer or * use schedule_timer to schedule a timer in * x seconds and microseconds from now... @@ -41,7 +41,7 @@ * the timers. * */ -struct timer_list { +struct osmo_timer_list { struct llist_head entry; struct timeval timeout; unsigned int active : 1; @@ -55,18 +55,18 @@ struct timer_list { /** * timer management */ -void bsc_add_timer(struct timer_list *timer); -void bsc_schedule_timer(struct timer_list *timer, int seconds, int microseconds); -void bsc_del_timer(struct timer_list *timer); -int bsc_timer_pending(struct timer_list *timer); +void osmo_timer_add(struct osmo_timer_list *timer); +void osmo_timer_schedule(struct osmo_timer_list *timer, int seconds, int microseconds); +void osmo_timer_del(struct osmo_timer_list *timer); +int osmo_timer_pending(struct osmo_timer_list *timer); /** * internal timer list management */ -struct timeval *bsc_nearest_timer(); -void bsc_prepare_timers(); -int bsc_update_timers(); -int bsc_timer_check(void); +struct timeval *osmo_timers_nearest(); +void osmo_timers_prepare(); +int osmo_timers_update(); +int osmo_timers_check(void); #endif diff --git a/src/rate_ctr.c b/src/rate_ctr.c index a0e1814..6d771a4 100644 --- a/src/rate_ctr.c +++ b/src/rate_ctr.c @@ -82,7 +82,7 @@ static void interval_expired(struct rate_ctr *ctr, enum rate_ctr_intv intv) ctr->intv[intv+1].rate += ctr->intv[intv].rate; } -static struct timer_list rate_ctr_timer; +static struct osmo_timer_list rate_ctr_timer; static uint64_t timer_ticks; /* The one-second interval has expired */ @@ -114,14 +114,14 @@ static void rate_ctr_timer_cb(void *data) llist_for_each_entry(ctrg, &rate_ctr_groups, list) rate_ctr_group_intv(ctrg); - bsc_schedule_timer(&rate_ctr_timer, 1, 0); + osmo_timer_schedule(&rate_ctr_timer, 1, 0); } int rate_ctr_init(void *tall_ctx) { tall_rate_ctr_ctx = tall_ctx; rate_ctr_timer.cb = rate_ctr_timer_cb; - bsc_schedule_timer(&rate_ctr_timer, 1, 0); + osmo_timer_schedule(&rate_ctr_timer, 1, 0); return 0; } diff --git a/src/select.c b/src/select.c index adf3619..6c44f35 100644 --- a/src/select.c +++ b/src/select.c @@ -95,16 +95,16 @@ int bsc_select_main(int polling) FD_SET(ufd->fd, &exceptset); } - bsc_timer_check(); + osmo_timers_check(); if (!polling) - bsc_prepare_timers(); - rc = select(maxfd+1, &readset, &writeset, &exceptset, polling ? &no_time : bsc_nearest_timer()); + osmo_timers_prepare(); + rc = select(maxfd+1, &readset, &writeset, &exceptset, polling ? &no_time : osmo_timers_nearest()); if (rc < 0) return 0; /* fire timers */ - bsc_update_timers(); + osmo_timers_update(); /* call registered callback functions */ restart: diff --git a/src/timer.c b/src/timer.c index 9b2dd9e..ec75212 100644 --- a/src/timer.c +++ b/src/timer.c @@ -31,9 +31,9 @@ static struct timeval s_select_time; #define TIME_SMALLER(left, right) \ (left.tv_sec*MICRO_SECONDS+left.tv_usec) <= (right.tv_sec*MICRO_SECONDS+right.tv_usec) -void bsc_add_timer(struct timer_list *timer) +void osmo_timer_add(struct osmo_timer_list *timer) { - struct timer_list *list_timer; + struct osmo_timer_list *list_timer; /* TODO: Optimize and remember the closest item... */ timer->active = 1; @@ -47,7 +47,8 @@ void bsc_add_timer(struct timer_list *timer) llist_add(&timer->entry, &timer_list); } -void bsc_schedule_timer(struct timer_list *timer, int seconds, int microseconds) +void +osmo_timer_schedule(struct osmo_timer_list *timer, int seconds, int microseconds) { struct timeval current_time; @@ -56,10 +57,10 @@ void bsc_schedule_timer(struct timer_list *timer, int seconds, int microseconds) currentTime += seconds * MICRO_SECONDS + microseconds; timer->timeout.tv_sec = currentTime / MICRO_SECONDS; timer->timeout.tv_usec = currentTime % MICRO_SECONDS; - bsc_add_timer(timer); + osmo_timer_add(timer); } -void bsc_del_timer(struct timer_list *timer) +void osmo_timer_del(struct osmo_timer_list *timer) { if (timer->in_list) { timer->active = 0; @@ -68,7 +69,7 @@ void bsc_del_timer(struct timer_list *timer) } } -int bsc_timer_pending(struct timer_list *timer) +int osmo_timer_pending(struct osmo_timer_list *timer) { return timer->active; } @@ -79,7 +80,7 @@ int bsc_timer_pending(struct timer_list *timer) * If the nearest timer timed out return NULL and then we will * dispatch everything after the select */ -struct timeval *bsc_nearest_timer() +struct timeval *osmo_timers_nearest() { struct timeval current_time; @@ -106,9 +107,9 @@ struct timeval *bsc_nearest_timer() /* * Find the nearest time and update s_nearest_time */ -void bsc_prepare_timers() +void osmo_timers_prepare() { - struct timer_list *timer, *nearest_timer = NULL; + struct osmo_timer_list *timer, *nearest_timer = NULL; llist_for_each_entry(timer, &timer_list, entry) { if (!nearest_timer || TIME_SMALLER(timer->timeout, nearest_timer->timeout)) { nearest_timer = timer; @@ -125,10 +126,10 @@ void bsc_prepare_timers() /* * fire all timers... and remove them */ -int bsc_update_timers() +int osmo_timers_update() { struct timeval current_time; - struct timer_list *timer, *tmp; + struct osmo_timer_list *timer, *tmp; int work = 0; gettimeofday(¤t_time, NULL); @@ -166,16 +167,16 @@ restart: llist_for_each_entry_safe(timer, tmp, &timer_list, entry) { timer->handled = 0; if (!timer->active) { - bsc_del_timer(timer); + osmo_timer_del(timer); } } return work; } -int bsc_timer_check(void) +int osmo_timers_check(void) { - struct timer_list *timer; + struct osmo_timer_list *timer; int i = 0; llist_for_each_entry(timer, &timer_list, entry) { diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c index 30b08ad..69bcad9 100644 --- a/tests/timer/timer_test.c +++ b/tests/timer/timer_test.c @@ -27,17 +27,17 @@ static void timer_fired(void *data); -static struct timer_list timer_one = { +static struct osmo_timer_list timer_one = { .cb = timer_fired, .data = (void*)1, }; -static struct timer_list timer_two = { +static struct osmo_timer_list timer_two = { .cb = timer_fired, .data = (void*)2, }; -static struct timer_list timer_three = { +static struct osmo_timer_list timer_three = { .cb = timer_fired, .data = (void*)3, }; @@ -48,8 +48,8 @@ static void timer_fired(void *_data) printf("Fired timer: %lu\n", data); if (data == 1) { - bsc_schedule_timer(&timer_one, 3, 0); - bsc_del_timer(&timer_two); + osmo_timer_schedule(&timer_one, 3, 0); + osmo_timer_del(&timer_two); } else if (data == 2) { printf("Should not be fired... bug in del_timer\n"); } else if (data == 3) { @@ -63,9 +63,9 @@ int main(int argc, char** argv) { printf("Starting... timer\n"); - bsc_schedule_timer(&timer_one, 3, 0); - bsc_schedule_timer(&timer_two, 5, 0); - bsc_schedule_timer(&timer_three, 4, 0); + osmo_timer_schedule(&timer_one, 3, 0); + osmo_timer_schedule(&timer_two, 5, 0); + osmo_timer_schedule(&timer_three, 4, 0); #ifdef HAVE_SYS_SELECT_H while (1) { From 246tnt at gmail.com Thu May 5 18:20:19 2011 From: 246tnt at gmail.com (Sylvain Munaut) Date: Thu, 5 May 2011 20:20:19 +0200 Subject: [PATCH] libosmocore: fix namespace pollution (1/*) In-Reply-To: <20110505163519.5214.4409.stgit@decadence> References: <20110505163519.5214.4409.stgit@decadence> Message-ID: Hi, > This is the first patch in the series, I'll start little by > little. IMHO, Altough it's good to split the patch and replace subsysem by subsystem, it shouldn't be "spread out" too much in time because it creates a bunch of API incompatible librairies in the mean time. Cheers, Sylvain From pablo at gnumonks.org Fri May 6 08:53:08 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Fri, 06 May 2011 10:53:08 +0200 Subject: [PATCH] libosmocore: fix namespace pollution (1/*) In-Reply-To: References: <20110505163519.5214.4409.stgit@decadence> Message-ID: <4DC3B6F4.3000006@gnumonks.org> On 05/05/11 20:20, Sylvain Munaut wrote: > Hi, > >> This is the first patch in the series, I'll start little by >> little. > > IMHO, Altough it's good to split the patch and replace subsysem by > subsystem, it shouldn't be "spread out" too much in time because it > creates a bunch of API incompatible librairies in the mean time. I'll resend a bigger patchset then and put it in a branch. JFYI: I'm including the regular expression in the patch description. Thus, you can use this to get your branches in sync with changes in less than one minute. s/struct timer_list/struct osmo_timer_list/g s/bsc_add_timer/osmo_timer_add/g s/bsc_schedule_timer/osmo_timer_schedule/g s/bsc_del_timer/osmo_timer_del/g s/bsc_timer_pending/osmo_timer_pending/g s/bsc_nearest_timer/osmo_timers_nearest/g s/bsc_prepare_timers/osmo_timers_prepare/g s/bsc_update_timers/osmo_timers_update/g s/bsc_timer_check/osmo_timers_check/g put this into /tmp/replace.txt, then you can use this small script: cat /tmp/replace.txt | while read REPLACE do find ./ -type f -exec sed -i "$REPLACE" {} \; done Probably there are people with more scripting skills here that would make it in one single line, but this is enough for me. From pablo at netfilter.org Thu May 5 16:38:57 2011 From: pablo at netfilter.org (Pablo Neira Ayuso) Date: Thu, 05 May 2011 18:38:57 +0200 Subject: [PATCH] openBSC: use new osmo_timer* namespace for timers Message-ID: <20110505163804.5316.5045.stgit@decadence> This patch gets openBSC in sync with the changes that I'm proposing for libosmocore. Please, apply! --- Pablo Neira Ayuso (1): src: use new namespace prefix osmo_timer* for timer functions openbsc/include/openbsc/bsc_msc.h | 4 ++-- openbsc/include/openbsc/bsc_nat.h | 8 ++++---- openbsc/include/openbsc/e1_input.h | 2 +- openbsc/include/openbsc/gprs_llc.h | 4 ++-- openbsc/include/openbsc/gprs_ns.h | 2 +- openbsc/include/openbsc/gprs_sgsn.h | 4 ++-- openbsc/include/openbsc/gsm_data.h | 16 ++++++++-------- openbsc/include/openbsc/osmo_bsc.h | 4 ++-- openbsc/include/openbsc/osmo_bsc_rf.h | 6 +++--- openbsc/include/openbsc/osmo_msc_data.h | 4 ++-- openbsc/include/openbsc/paging.h | 2 +- openbsc/include/openbsc/sgsn.h | 2 +- openbsc/include/openbsc/transaction.h | 4 ++-- openbsc/src/gprs/gprs_gmm.c | 18 +++++++++--------- openbsc/src/gprs/gprs_sndcp.h | 2 +- openbsc/src/gprs/sgsn_libgtp.c | 2 +- openbsc/src/ipaccess/ipaccess-find.c | 6 +++--- openbsc/src/ipaccess/ipaccess-proxy.c | 8 ++++---- openbsc/src/libabis/e1_input.c | 6 +++--- openbsc/src/libabis/input/dahdi.c | 2 +- openbsc/src/libabis/input/hsl.c | 2 +- openbsc/src/libabis/input/ipaccess.c | 2 +- openbsc/src/libabis/input/lapd.c | 8 ++++---- openbsc/src/libabis/input/misdn.c | 2 +- openbsc/src/libbsc/abis_rsl.c | 10 +++++----- openbsc/src/libbsc/bsc_api.c | 12 ++++++------ openbsc/src/libbsc/bsc_msc.c | 8 ++++---- openbsc/src/libbsc/bsc_rll.c | 8 ++++---- openbsc/src/libbsc/chan_alloc.c | 8 ++++---- openbsc/src/libbsc/handover_logic.c | 10 +++++----- openbsc/src/libbsc/paging.c | 14 +++++++------- openbsc/src/libgb/gprs_ns.c | 12 ++++++------ openbsc/src/libmsc/gsm_04_08.c | 14 +++++++------- openbsc/src/libmsc/gsm_04_11.c | 10 +++++----- openbsc/src/libmsc/sms_queue.c | 12 ++++++------ openbsc/src/osmo-bsc/osmo_bsc_msc.c | 10 +++++----- openbsc/src/osmo-bsc/osmo_bsc_rf.c | 16 ++++++++-------- openbsc/src/osmo-bsc/osmo_bsc_sccp.c | 12 ++++++------ openbsc/src/osmo-bsc_nat/bsc_nat.c | 22 +++++++++++----------- openbsc/src/osmo-bsc_nat/bsc_ussd.c | 6 +++--- openbsc/src/osmo-nitb/bsc_hack.c | 6 +++--- openbsc/src/utils/bs11_config.c | 4 ++-- 42 files changed, 157 insertions(+), 157 deletions(-) -- Signature From pablo at gnumonks.org Fri May 6 10:28:04 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Fri, 6 May 2011 12:28:04 +0200 Subject: [PATCH 0/5] libosmocore: namespace pollution fixes (1/*) 2nd try Message-ID: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Hi! This is the first patchset that fixes the namespace pollution in libosmocore. You can find in the patch description the sed regular expression to automate the replacement of the function/structure names, e.g: s/struct counter/struct osmo_counter/g s/counter_inc/osmo_counter_inc/g s/counter_get/osmo_counter_get/g s/counter_reset/osmo_counter_reset/g s/counter_alloc/osmo_counter_alloc/g s/counter_free/osmo_counter_free You can use the following script: cat /tmp/replace.txt | while read REPLACE do echo "performing sed \"$REPLACE\"..." find ./ -type f -exec sed -i "$REPLACE" {} \; done The /tmp/replace.txt file have to contain the list of sed regular expressions, one per line. Thus, you can get in sync your branches in a couple of minutes. The entire list of changes in this patchset is the following: s/struct timer_list/struct osmo_timer_list/g s/bsc_add_timer/osmo_timer_add/g s/bsc_schedule_timer/osmo_timer_schedule/g s/bsc_del_timer/osmo_timer_del/g s/bsc_timer_pending/osmo_timer_pending/g s/bsc_nearest_timer/osmo_timers_nearest/g s/bsc_prepare_timers/osmo_timers_prepare/g s/bsc_update_timers/osmo_timers_update/g s/bsc_timer_check/osmo_timers_check/g s/struct bsc_fd/struct osmo_fd/g s/bsc_register_fd/osmo_fd_register/g s/bsc_unregister_fd/osmo_fd_unregister/g s/bsc_select_main/osmo_select_main/g s/signal_cbfn/osmo_signal_cbfn/g s/register_signal_handler/osmo_signal_register_handler/g s/unregister_signal_handler/osmo_signal_unregister_handler/g s/dispatch_signal/osmo_signal_dispatch/g s/struct write_queue/struct osmo_wqueue/g s/write_queue_init/osmo_wqueue_init/g s/write_queue_clear/osmo_wqueue_clear/g s/write_queue_enqueue/osmo_wqueue_enqueue/g s/write_queue_bfd_cb/osmo_wqueue_bfd_cb/g s/struct counter/struct osmo_counter/g s/counter_inc/osmo_counter_inc/g s/counter_get/osmo_counter_get/g s/counter_reset/osmo_counter_reset/g s/counter_alloc/osmo_counter_alloc/g s/counter_free/osmo_counter_free/g You can find it in the pablo/namespace branch. Please, merge it! Pablo Neira Ayuso (5): timer: use namespace prefix osmo_timer* select: use namespace prefix osmo_fd* and osmo_select* signal: use namespace prefix osmo_signal* write-queue: use namespace prefix osmo_wqueue* statistics: use namespace prefix osmo_counter* include/osmocom/core/select.h | 10 +++++----- include/osmocom/core/signal.h | 15 +++++++-------- include/osmocom/core/statistics.h | 16 ++++++++-------- include/osmocom/core/timer.h | 20 ++++++++++---------- include/osmocom/core/write_queue.h | 22 +++++++++++----------- include/osmocom/vty/telnet_interface.h | 2 +- src/gsmtap_util.c | 12 ++++++------ src/rate_ctr.c | 6 +++--- src/select.c | 30 +++++++++++++++--------------- src/signal.c | 11 +++++++---- src/statistics.c | 15 ++++++++------- src/timer.c | 29 +++++++++++++++-------------- src/vty/telnet_interface.c | 18 +++++++++--------- src/write_queue.c | 14 +++++++------- tests/timer/timer_test.c | 18 +++++++++--------- 15 files changed, 121 insertions(+), 117 deletions(-) -- 1.7.2.3 From pablo at gnumonks.org Fri May 6 10:28:05 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Fri, 6 May 2011 12:28:05 +0200 Subject: [PATCH 1/5] timer: use namespace prefix osmo_timer* In-Reply-To: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> References: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304677689-23598-2-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/struct timer_list/struct osmo_timer_list/g s/bsc_add_timer/osmo_timer_add/g s/bsc_schedule_timer/osmo_timer_schedule/g s/bsc_del_timer/osmo_timer_del/g s/bsc_timer_pending/osmo_timer_pending/g s/bsc_nearest_timer/osmo_timers_nearest/g s/bsc_prepare_timers/osmo_timers_prepare/g s/bsc_update_timers/osmo_timers_update/g s/bsc_timer_check/osmo_timers_check/g --- include/osmocom/core/timer.h | 20 ++++++++++---------- src/rate_ctr.c | 6 +++--- src/select.c | 8 ++++---- src/timer.c | 29 +++++++++++++++-------------- tests/timer/timer_test.c | 16 ++++++++-------- 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/include/osmocom/core/timer.h b/include/osmocom/core/timer.h index 1966478..db2ecbf 100644 --- a/include/osmocom/core/timer.h +++ b/include/osmocom/core/timer.h @@ -27,7 +27,7 @@ /** * Timer management: - * - Create a struct timer_list + * - Create a struct osmo_timer_list * - Fill out timeout and use add_timer or * use schedule_timer to schedule a timer in * x seconds and microseconds from now... @@ -41,7 +41,7 @@ * the timers. * */ -struct timer_list { +struct osmo_timer_list { struct llist_head entry; struct timeval timeout; unsigned int active : 1; @@ -55,18 +55,18 @@ struct timer_list { /** * timer management */ -void bsc_add_timer(struct timer_list *timer); -void bsc_schedule_timer(struct timer_list *timer, int seconds, int microseconds); -void bsc_del_timer(struct timer_list *timer); -int bsc_timer_pending(struct timer_list *timer); +void osmo_timer_add(struct osmo_timer_list *timer); +void osmo_timer_schedule(struct osmo_timer_list *timer, int seconds, int microseconds); +void osmo_timer_del(struct osmo_timer_list *timer); +int osmo_timer_pending(struct osmo_timer_list *timer); /** * internal timer list management */ -struct timeval *bsc_nearest_timer(); -void bsc_prepare_timers(); -int bsc_update_timers(); -int bsc_timer_check(void); +struct timeval *osmo_timers_nearest(); +void osmo_timers_prepare(); +int osmo_timers_update(); +int osmo_timers_check(void); #endif diff --git a/src/rate_ctr.c b/src/rate_ctr.c index a0e1814..6d771a4 100644 --- a/src/rate_ctr.c +++ b/src/rate_ctr.c @@ -82,7 +82,7 @@ static void interval_expired(struct rate_ctr *ctr, enum rate_ctr_intv intv) ctr->intv[intv+1].rate += ctr->intv[intv].rate; } -static struct timer_list rate_ctr_timer; +static struct osmo_timer_list rate_ctr_timer; static uint64_t timer_ticks; /* The one-second interval has expired */ @@ -114,14 +114,14 @@ static void rate_ctr_timer_cb(void *data) llist_for_each_entry(ctrg, &rate_ctr_groups, list) rate_ctr_group_intv(ctrg); - bsc_schedule_timer(&rate_ctr_timer, 1, 0); + osmo_timer_schedule(&rate_ctr_timer, 1, 0); } int rate_ctr_init(void *tall_ctx) { tall_rate_ctr_ctx = tall_ctx; rate_ctr_timer.cb = rate_ctr_timer_cb; - bsc_schedule_timer(&rate_ctr_timer, 1, 0); + osmo_timer_schedule(&rate_ctr_timer, 1, 0); return 0; } diff --git a/src/select.c b/src/select.c index adf3619..6c44f35 100644 --- a/src/select.c +++ b/src/select.c @@ -95,16 +95,16 @@ int bsc_select_main(int polling) FD_SET(ufd->fd, &exceptset); } - bsc_timer_check(); + osmo_timers_check(); if (!polling) - bsc_prepare_timers(); - rc = select(maxfd+1, &readset, &writeset, &exceptset, polling ? &no_time : bsc_nearest_timer()); + osmo_timers_prepare(); + rc = select(maxfd+1, &readset, &writeset, &exceptset, polling ? &no_time : osmo_timers_nearest()); if (rc < 0) return 0; /* fire timers */ - bsc_update_timers(); + osmo_timers_update(); /* call registered callback functions */ restart: diff --git a/src/timer.c b/src/timer.c index 9b2dd9e..ec75212 100644 --- a/src/timer.c +++ b/src/timer.c @@ -31,9 +31,9 @@ static struct timeval s_select_time; #define TIME_SMALLER(left, right) \ (left.tv_sec*MICRO_SECONDS+left.tv_usec) <= (right.tv_sec*MICRO_SECONDS+right.tv_usec) -void bsc_add_timer(struct timer_list *timer) +void osmo_timer_add(struct osmo_timer_list *timer) { - struct timer_list *list_timer; + struct osmo_timer_list *list_timer; /* TODO: Optimize and remember the closest item... */ timer->active = 1; @@ -47,7 +47,8 @@ void bsc_add_timer(struct timer_list *timer) llist_add(&timer->entry, &timer_list); } -void bsc_schedule_timer(struct timer_list *timer, int seconds, int microseconds) +void +osmo_timer_schedule(struct osmo_timer_list *timer, int seconds, int microseconds) { struct timeval current_time; @@ -56,10 +57,10 @@ void bsc_schedule_timer(struct timer_list *timer, int seconds, int microseconds) currentTime += seconds * MICRO_SECONDS + microseconds; timer->timeout.tv_sec = currentTime / MICRO_SECONDS; timer->timeout.tv_usec = currentTime % MICRO_SECONDS; - bsc_add_timer(timer); + osmo_timer_add(timer); } -void bsc_del_timer(struct timer_list *timer) +void osmo_timer_del(struct osmo_timer_list *timer) { if (timer->in_list) { timer->active = 0; @@ -68,7 +69,7 @@ void bsc_del_timer(struct timer_list *timer) } } -int bsc_timer_pending(struct timer_list *timer) +int osmo_timer_pending(struct osmo_timer_list *timer) { return timer->active; } @@ -79,7 +80,7 @@ int bsc_timer_pending(struct timer_list *timer) * If the nearest timer timed out return NULL and then we will * dispatch everything after the select */ -struct timeval *bsc_nearest_timer() +struct timeval *osmo_timers_nearest() { struct timeval current_time; @@ -106,9 +107,9 @@ struct timeval *bsc_nearest_timer() /* * Find the nearest time and update s_nearest_time */ -void bsc_prepare_timers() +void osmo_timers_prepare() { - struct timer_list *timer, *nearest_timer = NULL; + struct osmo_timer_list *timer, *nearest_timer = NULL; llist_for_each_entry(timer, &timer_list, entry) { if (!nearest_timer || TIME_SMALLER(timer->timeout, nearest_timer->timeout)) { nearest_timer = timer; @@ -125,10 +126,10 @@ void bsc_prepare_timers() /* * fire all timers... and remove them */ -int bsc_update_timers() +int osmo_timers_update() { struct timeval current_time; - struct timer_list *timer, *tmp; + struct osmo_timer_list *timer, *tmp; int work = 0; gettimeofday(¤t_time, NULL); @@ -166,16 +167,16 @@ restart: llist_for_each_entry_safe(timer, tmp, &timer_list, entry) { timer->handled = 0; if (!timer->active) { - bsc_del_timer(timer); + osmo_timer_del(timer); } } return work; } -int bsc_timer_check(void) +int osmo_timers_check(void) { - struct timer_list *timer; + struct osmo_timer_list *timer; int i = 0; llist_for_each_entry(timer, &timer_list, entry) { diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c index 30b08ad..69bcad9 100644 --- a/tests/timer/timer_test.c +++ b/tests/timer/timer_test.c @@ -27,17 +27,17 @@ static void timer_fired(void *data); -static struct timer_list timer_one = { +static struct osmo_timer_list timer_one = { .cb = timer_fired, .data = (void*)1, }; -static struct timer_list timer_two = { +static struct osmo_timer_list timer_two = { .cb = timer_fired, .data = (void*)2, }; -static struct timer_list timer_three = { +static struct osmo_timer_list timer_three = { .cb = timer_fired, .data = (void*)3, }; @@ -48,8 +48,8 @@ static void timer_fired(void *_data) printf("Fired timer: %lu\n", data); if (data == 1) { - bsc_schedule_timer(&timer_one, 3, 0); - bsc_del_timer(&timer_two); + osmo_timer_schedule(&timer_one, 3, 0); + osmo_timer_del(&timer_two); } else if (data == 2) { printf("Should not be fired... bug in del_timer\n"); } else if (data == 3) { @@ -63,9 +63,9 @@ int main(int argc, char** argv) { printf("Starting... timer\n"); - bsc_schedule_timer(&timer_one, 3, 0); - bsc_schedule_timer(&timer_two, 5, 0); - bsc_schedule_timer(&timer_three, 4, 0); + osmo_timer_schedule(&timer_one, 3, 0); + osmo_timer_schedule(&timer_two, 5, 0); + osmo_timer_schedule(&timer_three, 4, 0); #ifdef HAVE_SYS_SELECT_H while (1) { -- 1.7.2.3 From pablo at gnumonks.org Fri May 6 10:28:06 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Fri, 6 May 2011 12:28:06 +0200 Subject: [PATCH 2/5] select: use namespace prefix osmo_fd* and osmo_select* In-Reply-To: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> References: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304677689-23598-3-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/struct bsc_fd/struct osmo_fd/g s/bsc_register_fd/osmo_fd_register/g s/bsc_unregister_fd/osmo_fd_unregister/g s/bsc_select_main/osmo_select_main/g --- include/osmocom/core/select.h | 10 +++++----- include/osmocom/core/write_queue.h | 10 +++++----- include/osmocom/vty/telnet_interface.h | 2 +- src/gsmtap_util.c | 12 ++++++------ src/select.c | 22 +++++++++++----------- src/vty/telnet_interface.c | 18 +++++++++--------- src/write_queue.c | 2 +- tests/timer/timer_test.c | 2 +- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h index 5ca21c3..476c564 100644 --- a/include/osmocom/core/select.h +++ b/include/osmocom/core/select.h @@ -7,16 +7,16 @@ #define BSC_FD_WRITE 0x0002 #define BSC_FD_EXCEPT 0x0004 -struct bsc_fd { +struct osmo_fd { struct llist_head list; int fd; unsigned int when; - int (*cb)(struct bsc_fd *fd, unsigned int what); + int (*cb)(struct osmo_fd *fd, unsigned int what); void *data; unsigned int priv_nr; }; -int bsc_register_fd(struct bsc_fd *fd); -void bsc_unregister_fd(struct bsc_fd *fd); -int bsc_select_main(int polling); +int osmo_fd_register(struct osmo_fd *fd); +void osmo_fd_unregister(struct osmo_fd *fd); +int osmo_select_main(int polling); #endif /* _BSC_SELECT_H */ diff --git a/include/osmocom/core/write_queue.h b/include/osmocom/core/write_queue.h index 3b730c7..8d360cb 100644 --- a/include/osmocom/core/write_queue.h +++ b/include/osmocom/core/write_queue.h @@ -27,20 +27,20 @@ #include struct write_queue { - struct bsc_fd bfd; + struct osmo_fd bfd; unsigned int max_length; unsigned int current_length; struct llist_head msg_queue; - int (*read_cb)(struct bsc_fd *fd); - int (*write_cb)(struct bsc_fd *fd, struct msgb *msg); - int (*except_cb)(struct bsc_fd *fd); + int (*read_cb)(struct osmo_fd *fd); + int (*write_cb)(struct osmo_fd *fd, struct msgb *msg); + int (*except_cb)(struct osmo_fd *fd); }; void write_queue_init(struct write_queue *queue, int max_length); void write_queue_clear(struct write_queue *queue); int write_queue_enqueue(struct write_queue *queue, struct msgb *data); -int write_queue_bfd_cb(struct bsc_fd *fd, unsigned int what); +int write_queue_bfd_cb(struct osmo_fd *fd, unsigned int what); #endif diff --git a/include/osmocom/vty/telnet_interface.h b/include/osmocom/vty/telnet_interface.h index 0c034e4..1d8055e 100644 --- a/include/osmocom/vty/telnet_interface.h +++ b/include/osmocom/vty/telnet_interface.h @@ -29,7 +29,7 @@ struct telnet_connection { struct llist_head entry; void *priv; - struct bsc_fd fd; + struct osmo_fd fd; struct vty *vty; struct log_target *dbg; }; diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c index b47f6e3..e0bc848 100644 --- a/src/gsmtap_util.c +++ b/src/gsmtap_util.c @@ -42,8 +42,8 @@ #include #include -static struct bsc_fd gsmtap_bfd = { .fd = -1 }; -static struct bsc_fd gsmtap_sink_bfd = { .fd = -1 }; +static struct osmo_fd gsmtap_bfd = { .fd = -1 }; +static struct osmo_fd gsmtap_sink_bfd = { .fd = -1 }; static LLIST_HEAD(gsmtap_txqueue); uint8_t chantype_rsl2gsmtap(uint8_t rsl_chantype, uint8_t link_id) @@ -137,7 +137,7 @@ int gsmtap_sendmsg(uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, } /* Callback from select layer if we can write to the socket */ -static int gsmtap_fd_cb(struct bsc_fd *fd, unsigned int flags) +static int gsmtap_fd_cb(struct osmo_fd *fd, unsigned int flags) { struct msgb *msg; int rc; @@ -195,11 +195,11 @@ int gsmtap_init(uint32_t dst_ip) gsmtap_bfd.cb = gsmtap_fd_cb; gsmtap_bfd.data = NULL; - return bsc_register_fd(&gsmtap_bfd); + return osmo_fd_register(&gsmtap_bfd); } /* Callback from select layer if we can read from the sink socket */ -static int gsmtap_sink_fd_cb(struct bsc_fd *fd, unsigned int flags) +static int gsmtap_sink_fd_cb(struct osmo_fd *fd, unsigned int flags) { int rc; uint8_t buf[4096]; @@ -246,7 +246,7 @@ int gsmtap_sink_init(uint32_t bind_ip) gsmtap_sink_bfd.cb = gsmtap_sink_fd_cb; gsmtap_sink_bfd.data = NULL; - return bsc_register_fd(&gsmtap_sink_bfd); + return osmo_fd_register(&gsmtap_sink_bfd); } diff --git a/src/select.c b/src/select.c index 6c44f35..4ea9536 100644 --- a/src/select.c +++ b/src/select.c @@ -31,10 +31,10 @@ #ifdef HAVE_SYS_SELECT_H static int maxfd = 0; -static LLIST_HEAD(bsc_fds); +static LLIST_HEAD(osmo_fds); static int unregistered_count; -int bsc_register_fd(struct bsc_fd *fd) +int osmo_fd_register(struct osmo_fd *fd) { int flags; @@ -52,29 +52,29 @@ int bsc_register_fd(struct bsc_fd *fd) maxfd = fd->fd; #ifdef BSC_FD_CHECK - struct bsc_fd *entry; - llist_for_each_entry(entry, &bsc_fds, list) { + struct osmo_fd *entry; + llist_for_each_entry(entry, &osmo_fds, list) { if (entry == fd) { - fprintf(stderr, "Adding a bsc_fd that is already in the list.\n"); + fprintf(stderr, "Adding a osmo_fd that is already in the list.\n"); return 0; } } #endif - llist_add_tail(&fd->list, &bsc_fds); + llist_add_tail(&fd->list, &osmo_fds); return 0; } -void bsc_unregister_fd(struct bsc_fd *fd) +void osmo_fd_unregister(struct osmo_fd *fd) { unregistered_count++; llist_del(&fd->list); } -int bsc_select_main(int polling) +int osmo_select_main(int polling) { - struct bsc_fd *ufd, *tmp; + struct osmo_fd *ufd, *tmp; fd_set readset, writeset, exceptset; int work = 0, rc; struct timeval no_time = {0, 0}; @@ -84,7 +84,7 @@ int bsc_select_main(int polling) FD_ZERO(&exceptset); /* prepare read and write fdsets */ - llist_for_each_entry(ufd, &bsc_fds, list) { + llist_for_each_entry(ufd, &osmo_fds, list) { if (ufd->when & BSC_FD_READ) FD_SET(ufd->fd, &readset); @@ -109,7 +109,7 @@ int bsc_select_main(int polling) /* call registered callback functions */ restart: unregistered_count = 0; - llist_for_each_entry_safe(ufd, tmp, &bsc_fds, list) { + llist_for_each_entry_safe(ufd, tmp, &osmo_fds, list) { int flags = 0; if (FD_ISSET(ufd->fd, &readset)) { diff --git a/src/vty/telnet_interface.c b/src/vty/telnet_interface.c index 0d45d61..7845994 100644 --- a/src/vty/telnet_interface.c +++ b/src/vty/telnet_interface.c @@ -39,9 +39,9 @@ LLIST_HEAD(active_connections); static void *tall_telnet_ctx; /* per network data */ -static int telnet_new_connection(struct bsc_fd *fd, unsigned int what); +static int telnet_new_connection(struct osmo_fd *fd, unsigned int what); -static struct bsc_fd server_socket = { +static struct osmo_fd server_socket = { .when = BSC_FD_READ, .cb = telnet_new_connection, .priv_nr = 0, @@ -85,7 +85,7 @@ int telnet_init(void *tall_ctx, void *priv, int port) server_socket.data = priv; server_socket.fd = fd; - bsc_register_fd(&server_socket); + osmo_fd_register(&server_socket); return 0; } @@ -104,12 +104,12 @@ static void print_welcome(int fd) ret = write(fd, host.app_info->copyright, strlen(host.app_info->copyright)); } -int telnet_close_client(struct bsc_fd *fd) +int telnet_close_client(struct osmo_fd *fd) { struct telnet_connection *conn = (struct telnet_connection*)fd->data; close(fd->fd); - bsc_unregister_fd(fd); + osmo_fd_unregister(fd); if (conn->dbg) { log_del_target(conn->dbg); @@ -121,7 +121,7 @@ int telnet_close_client(struct bsc_fd *fd) return 0; } -static int client_data(struct bsc_fd *fd, unsigned int what) +static int client_data(struct osmo_fd *fd, unsigned int what) { struct telnet_connection *conn = fd->data; int rc = 0; @@ -144,7 +144,7 @@ static int client_data(struct bsc_fd *fd, unsigned int what) return rc; } -static int telnet_new_connection(struct bsc_fd *fd, unsigned int what) +static int telnet_new_connection(struct osmo_fd *fd, unsigned int what) { struct telnet_connection *connection; struct sockaddr_in sockaddr; @@ -162,7 +162,7 @@ static int telnet_new_connection(struct bsc_fd *fd, unsigned int what) connection->fd.fd = new_connection; connection->fd.when = BSC_FD_READ; connection->fd.cb = client_data; - bsc_register_fd(&connection->fd); + osmo_fd_register(&connection->fd); llist_add_tail(&connection->entry, &active_connections); print_welcome(new_connection); @@ -182,7 +182,7 @@ static int telnet_new_connection(struct bsc_fd *fd, unsigned int what) void vty_event(enum event event, int sock, struct vty *vty) { struct telnet_connection *connection = vty->priv; - struct bsc_fd *bfd = &connection->fd; + struct osmo_fd *bfd = &connection->fd; if (vty->type != VTY_TERM) return; diff --git a/src/write_queue.c b/src/write_queue.c index 0642aad..c357c3f 100644 --- a/src/write_queue.c +++ b/src/write_queue.c @@ -23,7 +23,7 @@ #include -int write_queue_bfd_cb(struct bsc_fd *fd, unsigned int what) +int write_queue_bfd_cb(struct osmo_fd *fd, unsigned int what) { struct write_queue *queue; diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c index 69bcad9..240bc48 100644 --- a/tests/timer/timer_test.c +++ b/tests/timer/timer_test.c @@ -69,7 +69,7 @@ int main(int argc, char** argv) #ifdef HAVE_SYS_SELECT_H while (1) { - bsc_select_main(0); + osmo_select_main(0); } #else printf("Select not supported on this platform!\n"); -- 1.7.2.3 From pablo at gnumonks.org Fri May 6 10:28:07 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Fri, 6 May 2011 12:28:07 +0200 Subject: [PATCH 3/5] signal: use namespace prefix osmo_signal* In-Reply-To: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> References: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304677689-23598-4-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/signal_cbfn/osmo_signal_cbfn/g s/register_signal_handler/osmo_signal_register_handler/g s/unregister_signal_handler/osmo_signal_unregister_handler/g s/dispatch_signal/osmo_signal_dispatch/g --- include/osmocom/core/signal.h | 15 +++++++-------- src/signal.c | 11 +++++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/osmocom/core/signal.h b/include/osmocom/core/signal.h index 02d83d2..535fd18 100644 --- a/include/osmocom/core/signal.h +++ b/include/osmocom/core/signal.h @@ -1,15 +1,14 @@ -#ifndef OSMOCORE_SIGNAL_H -#define OSMOCORE_SIGNAL_H +#ifndef OSMO_SIGNAL_H +#define OSMO_SIGNAL_H -typedef int signal_cbfn(unsigned int subsys, unsigned int signal, - void *handler_data, void *signal_data); +typedef int osmo_signal_cbfn(unsigned int subsys, unsigned int signal, void *handler_data, void *signal_data); /* Management */ -int register_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data); -void unregister_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data); +int osmo_signal_register_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data); +void osmo_signal_unregister_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data); /* Dispatch */ -void dispatch_signal(unsigned int subsys, unsigned int signal, void *signal_data); +void osmo_signal_dispatch(unsigned int subsys, unsigned int signal, void *signal_data); -#endif /* OSMOCORE_SIGNAL_H */ +#endif /* OSMO_SIGNAL_H */ diff --git a/src/signal.c b/src/signal.c index bb5c38e..bc339bb 100644 --- a/src/signal.c +++ b/src/signal.c @@ -31,12 +31,13 @@ static LLIST_HEAD(signal_handler_list); struct signal_handler { struct llist_head entry; unsigned int subsys; - signal_cbfn *cbfn; + osmo_signal_cbfn *cbfn; void *data; }; -int register_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data) +int osmo_signal_register_handler(unsigned int subsys, + osmo_signal_cbfn *cbfn, void *data) { struct signal_handler *sig_data; @@ -57,7 +58,8 @@ int register_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data) return 0; } -void unregister_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data) +void osmo_signal_unregister_handler(unsigned int subsys, + osmo_signal_cbfn *cbfn, void *data) { struct signal_handler *handler; @@ -72,7 +74,8 @@ void unregister_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *dat } -void dispatch_signal(unsigned int subsys, unsigned int signal, void *signal_data) +void osmo_signal_dispatch(unsigned int subsys, unsigned int signal, + void *signal_data) { struct signal_handler *handler; -- 1.7.2.3 From pablo at gnumonks.org Fri May 6 10:28:08 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Fri, 6 May 2011 12:28:08 +0200 Subject: [PATCH 4/5] write-queue: use namespace prefix osmo_wqueue* In-Reply-To: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> References: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304677689-23598-5-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/struct write_queue/struct osmo_wqueue/g s/write_queue_init/osmo_wqueue_init/g s/write_queue_clear/osmo_wqueue_clear/g s/write_queue_enqueue/osmo_wqueue_enqueue/g s/write_queue_bfd_cb/osmo_wqueue_bfd_cb/g --- include/osmocom/core/write_queue.h | 14 +++++++------- src/write_queue.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/osmocom/core/write_queue.h b/include/osmocom/core/write_queue.h index 8d360cb..41748d7 100644 --- a/include/osmocom/core/write_queue.h +++ b/include/osmocom/core/write_queue.h @@ -20,13 +20,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ -#ifndef write_queue_h -#define write_queue_h +#ifndef OSMO_WQUEUE_H +#define OSMO_WQUEUE_H #include #include -struct write_queue { +struct osmo_wqueue { struct osmo_fd bfd; unsigned int max_length; unsigned int current_length; @@ -38,9 +38,9 @@ struct write_queue { int (*except_cb)(struct osmo_fd *fd); }; -void write_queue_init(struct write_queue *queue, int max_length); -void write_queue_clear(struct write_queue *queue); -int write_queue_enqueue(struct write_queue *queue, struct msgb *data); -int write_queue_bfd_cb(struct osmo_fd *fd, unsigned int what); +void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length); +void osmo_wqueue_clear(struct osmo_wqueue *queue); +int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data); +int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what); #endif diff --git a/src/write_queue.c b/src/write_queue.c index c357c3f..a592104 100644 --- a/src/write_queue.c +++ b/src/write_queue.c @@ -23,11 +23,11 @@ #include -int write_queue_bfd_cb(struct osmo_fd *fd, unsigned int what) +int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what) { - struct write_queue *queue; + struct osmo_wqueue *queue; - queue = container_of(fd, struct write_queue, bfd); + queue = container_of(fd, struct osmo_wqueue, bfd); if (what & BSC_FD_READ) queue->read_cb(fd); @@ -56,17 +56,17 @@ int write_queue_bfd_cb(struct osmo_fd *fd, unsigned int what) return 0; } -void write_queue_init(struct write_queue *queue, int max_length) +void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length) { queue->max_length = max_length; queue->current_length = 0; queue->read_cb = NULL; queue->write_cb = NULL; - queue->bfd.cb = write_queue_bfd_cb; + queue->bfd.cb = osmo_wqueue_bfd_cb; INIT_LLIST_HEAD(&queue->msg_queue); } -int write_queue_enqueue(struct write_queue *queue, struct msgb *data) +int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data) { // if (queue->current_length + 1 >= queue->max_length) // LOGP(DMSC, LOGL_ERROR, "The queue is full. Dropping not yet implemented.\n"); @@ -78,7 +78,7 @@ int write_queue_enqueue(struct write_queue *queue, struct msgb *data) return 0; } -void write_queue_clear(struct write_queue *queue) +void osmo_wqueue_clear(struct osmo_wqueue *queue) { while (!llist_empty(&queue->msg_queue)) { struct msgb *msg = msgb_dequeue(&queue->msg_queue); -- 1.7.2.3 From pablo at gnumonks.org Fri May 6 10:28:09 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Fri, 6 May 2011 12:28:09 +0200 Subject: [PATCH 5/5] statistics: use namespace prefix osmo_counter* In-Reply-To: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> References: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304677689-23598-6-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/struct counter/struct osmo_counter/g s/counter_inc/osmo_counter_inc/g s/counter_get/osmo_counter_get/g s/counter_reset/osmo_counter_reset/g s/counter_alloc/osmo_counter_alloc/g s/counter_free/osmo_counter_free/g s/counters_for_each/osmo_counters_for_each/g --- include/osmocom/core/statistics.h | 16 ++++++++-------- src/statistics.c | 15 ++++++++------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/osmocom/core/statistics.h b/include/osmocom/core/statistics.h index 2c15965..1849327 100644 --- a/include/osmocom/core/statistics.h +++ b/include/osmocom/core/statistics.h @@ -1,33 +1,33 @@ #ifndef _STATISTICS_H #define _STATISTICS_H -struct counter { +struct osmo_counter { struct llist_head list; const char *name; const char *description; unsigned long value; }; -static inline void counter_inc(struct counter *ctr) +static inline void osmo_counter_inc(struct osmo_counter *ctr) { ctr->value++; } -static inline unsigned long counter_get(struct counter *ctr) +static inline unsigned long osmo_counter_get(struct osmo_counter *ctr) { return ctr->value; } -static inline void counter_reset(struct counter *ctr) +static inline void osmo_counter_reset(struct osmo_counter *ctr) { ctr->value = 0; } -struct counter *counter_alloc(const char *name); -void counter_free(struct counter *ctr); +struct osmo_counter *osmo_counter_alloc(const char *name); +void osmo_counter_free(struct osmo_counter *ctr); -int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data); +int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), void *data); -struct counter *counter_get_by_name(const char *name); +struct osmo_counter *osmo_counter_get_by_name(const char *name); #endif /* _STATISTICS_H */ diff --git a/src/statistics.c b/src/statistics.c index 83bb6ed..e28541b 100644 --- a/src/statistics.c +++ b/src/statistics.c @@ -30,9 +30,9 @@ static LLIST_HEAD(counters); void *tall_ctr_ctx; -struct counter *counter_alloc(const char *name) +struct osmo_counter *osmo_counter_alloc(const char *name) { - struct counter *ctr = talloc_zero(tall_ctr_ctx, struct counter); + struct osmo_counter *ctr = talloc_zero(tall_ctr_ctx, struct osmo_counter); if (!ctr) return NULL; @@ -43,15 +43,16 @@ struct counter *counter_alloc(const char *name) return ctr; } -void counter_free(struct counter *ctr) +void osmo_counter_free(struct osmo_counter *ctr) { llist_del(&ctr->list); talloc_free(ctr); } -int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data) +int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), + void *data) { - struct counter *ctr; + struct osmo_counter *ctr; int rc = 0; llist_for_each_entry(ctr, &counters, list) { @@ -63,9 +64,9 @@ int counters_for_each(int (*handle_counter)(struct counter *, void *), void *dat return rc; } -struct counter *counter_get_by_name(const char *name) +struct osmo_counter *osmo_counter_get_by_name(const char *name) { - struct counter *ctr; + struct osmo_counter *ctr; llist_for_each_entry(ctr, &counters, list) { if (!strcmp(ctr->name, name)) -- 1.7.2.3 From laforge at gnumonks.org Fri May 6 11:39:11 2011 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 6 May 2011 13:39:11 +0200 Subject: [PATCH 0/5] libosmocore: namespace pollution fixes (1/*) 2nd try In-Reply-To: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> References: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> Message-ID: <20110506113911.GT5155@prithivi.gnumonks.org> Hi Pablo, On Fri, May 06, 2011 at 12:28:04PM +0200, pablo at gnumonks.org wrote: > This is the first patchset that fixes the namespace pollution > in libosmocore. thanks. > You can find in the patch description the sed regular expression > to automate the replacement of the function/structure names, e.g: great idea. > You can find it in the pablo/namespace branch. > Please, merge it! Ok, I have checked the 'nm' output of current libosmocore.a of that branch, and the only functions without an osmo_ prefix are: msgb_* (which is ok) bitvec_* (which is ok, too) log_* (i guess ok, too) gsmtap_* (which is ok) talloc_* (which is ok) rate_ctr_* (which is ok) chantype_rsl2gsmtap (ok) get_string_value/get_value_string (ok) However, there are seome others. Pablo, can you please also prefix those: bcd2char, char2bcd crc16 generate_backtrace plugin_load_all Once this has been resolved, I will merge your branch. We should also make a first official libosmocore release soon, and from now on make sure we keep binary (ABI) compatibility within the autotools library versioning rules. As a second step, we can try to get the library included in Debian and other distros. Finally, we have one remaining issue: msg_entry_parse I think msg / msgb are a bit too close and they don't do anything related. Maybe we can come up with a different name, possibly including the osmo_ prefix? Holger? Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Fri May 6 11:53:03 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 06 May 2011 13:53:03 +0200 Subject: [PATCH 0/5] libosmocore: namespace pollution fixes (1/*) 2nd try In-Reply-To: <20110506113911.GT5155@prithivi.gnumonks.org> References: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> <20110506113911.GT5155@prithivi.gnumonks.org> Message-ID: <4DC3E11F.5000203@freyther.de> On 05/06/2011 01:39 PM, Harald Welte wrote: > I think msg / msgb are a bit too close and they don't do anything > related. Maybe we can come up with a different name, possibly including > the osmo_ prefix? Holger? Good question... the file is a very limited (fixed amount of columns) CSV like list. osmo_config_list? osmo_simple_config_list? any other ideas? holger From pablo at gnumonks.org Sat May 7 11:33:05 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Sat, 07 May 2011 13:33:05 +0200 Subject: [PATCH 0/5] libosmocore: namespace pollution fixes (1/*) 2nd try In-Reply-To: <20110506113911.GT5155@prithivi.gnumonks.org> References: <1304677689-23598-1-git-send-email-pablo@gnumonks.org> <20110506113911.GT5155@prithivi.gnumonks.org> Message-ID: <4DC52DF1.9040707@gnumonks.org> On 06/05/11 13:39, Harald Welte wrote: > Ok, I have checked the 'nm' output of current libosmocore.a of that > branch, and the only functions without an osmo_ prefix are: > > msgb_* (which is ok) > bitvec_* (which is ok, too) > log_* (i guess ok, too) > gsmtap_* (which is ok) > talloc_* (which is ok) > rate_ctr_* (which is ok) > chantype_rsl2gsmtap (ok) > get_string_value/get_value_string (ok) > > However, there are seome others. Pablo, can you please also prefix those: > bcd2char, char2bcd > crc16 > generate_backtrace > plugin_load_all > > Once this has been resolved, I will merge your branch. I have also fixed this. You can find the patches in the mailing list and all the changes in pablo/namespace branch. > We should also make a first official libosmocore release soon, and from > now on make sure we keep binary (ABI) compatibility within the autotools > library versioning rules. As a second step, we can try to get the > library included in Debian and other distros. I'll make a patch to make libosmocore use: * EXPORT_SYMBOL * a .map file with exported symbols and versions * use libversion (we only have to use revisions field, current and aging field should never be used) I'll document the way of working, of course. > Finally, we have one remaining issue: msg_entry_parse > > I think msg / msgb are a bit too close and they don't do anything > related. Maybe we can come up with a different name, possibly including > the osmo_ prefix? Holger? I have used osmo_config_list and osmo_config_entry for this, as suggested by Holger. From pablo at gnumonks.org Fri May 6 10:31:23 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Fri, 6 May 2011 12:31:23 +0200 Subject: [PATCH 0/5] openbsc: sync with namespace changes in libosmocore (1/*) Message-ID: <1304677888-23639-1-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso This patch gets openBSC in sync with the namespace pollution fixes available in the libosmocore pablo/namespace branch. See: [PATCH 0/5] libosmocore: namespace pollution fixes (1/*) 2nd try For further details. You can find this changes in the pablo/namespace branch. Please, merge it! Pablo Neira Ayuso (5): src: use namespace prefix osmo_timer* for timer functions src: use namespace prefix osmo_fd* and osmo_select* src: use namespace prefix osmo_signal* src: use namespace prefix osmo_wqueue* src: use namespace prefix osmo_counter* openbsc/doc/e1-data-model.txt | 2 +- openbsc/include/openbsc/bsc_msc.h | 6 +- openbsc/include/openbsc/bsc_nat.h | 32 ++++++------ openbsc/include/openbsc/db.h | 4 +- openbsc/include/openbsc/e1_input.h | 8 ++-- openbsc/include/openbsc/gprs_llc.h | 4 +- openbsc/include/openbsc/gprs_ns.h | 6 +- openbsc/include/openbsc/gprs_sgsn.h | 4 +- openbsc/include/openbsc/gsm_data.h | 76 ++++++++++++++-------------- openbsc/include/openbsc/ipaccess.h | 4 +- openbsc/include/openbsc/mgcp.h | 2 +- openbsc/include/openbsc/mgcp_internal.h | 4 +- openbsc/include/openbsc/osmo_bsc.h | 4 +- openbsc/include/openbsc/osmo_bsc_rf.h | 10 ++-- openbsc/include/openbsc/osmo_msc_data.h | 6 +- openbsc/include/openbsc/paging.h | 2 +- openbsc/include/openbsc/rtp_proxy.h | 2 +- openbsc/include/openbsc/sgsn.h | 8 ++-- openbsc/include/openbsc/socket.h | 4 +- openbsc/include/openbsc/transaction.h | 4 +- openbsc/src/gprs/gb_proxy_main.c | 6 +- openbsc/src/gprs/gprs_gmm.c | 18 +++--- openbsc/src/gprs/gprs_sndcp.h | 2 +- openbsc/src/gprs/sgsn_libgtp.c | 10 ++-- openbsc/src/gprs/sgsn_main.c | 4 +- openbsc/src/ipaccess/ipaccess-config.c | 6 +- openbsc/src/ipaccess/ipaccess-find.c | 16 +++--- openbsc/src/ipaccess/ipaccess-proxy.c | 72 ++++++++++++++-------------- openbsc/src/ipaccess/network_listen.c | 4 +- openbsc/src/libabis/e1_input.c | 12 ++-- openbsc/src/libabis/input/dahdi.c | 22 ++++---- openbsc/src/libabis/input/hsl.c | 24 +++++----- openbsc/src/libabis/input/ipaccess.c | 58 +++++++++++----------- openbsc/src/libabis/input/lapd.c | 8 ++-- openbsc/src/libabis/input/misdn.c | 18 +++--- openbsc/src/libbsc/abis_nm.c | 20 ++++---- openbsc/src/libbsc/abis_om2000.c | 6 +- openbsc/src/libbsc/abis_rsl.c | 26 +++++----- openbsc/src/libbsc/bsc_api.c | 14 +++--- openbsc/src/libbsc/bsc_init.c | 10 ++-- openbsc/src/libbsc/bsc_msc.c | 36 +++++++------- openbsc/src/libbsc/bsc_rll.c | 10 ++-- openbsc/src/libbsc/bsc_vty.c | 18 +++--- openbsc/src/libbsc/bts_ericsson_rbs2000.c | 6 +- openbsc/src/libbsc/bts_hsl_femtocell.c | 2 +- openbsc/src/libbsc/bts_ipaccess_nanobts.c | 2 +- openbsc/src/libbsc/bts_siemens_bs11.c | 4 +- openbsc/src/libbsc/chan_alloc.c | 14 +++--- openbsc/src/libbsc/gsm_04_08_utils.c | 2 +- openbsc/src/libbsc/handover_decision.c | 2 +- openbsc/src/libbsc/handover_logic.c | 26 +++++----- openbsc/src/libbsc/meas_proc.c | 2 +- openbsc/src/libbsc/paging.c | 20 ++++---- openbsc/src/libcommon/gsm_data.c | 60 +++++++++++----------- openbsc/src/libcommon/socket.c | 6 +- openbsc/src/libgb/gprs_ns.c | 36 +++++++------- openbsc/src/libgb/gprs_ns_frgre.c | 10 ++-- openbsc/src/libmgcp/mgcp_network.c | 24 +++++----- openbsc/src/libmsc/db.c | 2 +- openbsc/src/libmsc/gsm_04_08.c | 48 +++++++++--------- openbsc/src/libmsc/gsm_04_11.c | 22 ++++---- openbsc/src/libmsc/gsm_subscriber.c | 6 +- openbsc/src/libmsc/mncc_sock.c | 28 +++++----- openbsc/src/libmsc/rrlp.c | 4 +- openbsc/src/libmsc/silent_call.c | 4 +- openbsc/src/libmsc/sms_queue.c | 16 +++--- openbsc/src/libmsc/token_auth.c | 4 +- openbsc/src/libmsc/vty_interface_layer3.c | 46 +++++++++--------- openbsc/src/libtrau/rtp_proxy.c | 14 +++--- openbsc/src/osmo-bsc/osmo_bsc_audio.c | 2 +- openbsc/src/osmo-bsc/osmo_bsc_grace.c | 2 +- openbsc/src/osmo-bsc/osmo_bsc_main.c | 4 +- openbsc/src/osmo-bsc/osmo_bsc_msc.c | 30 ++++++------ openbsc/src/osmo-bsc/osmo_bsc_rf.c | 38 +++++++------- openbsc/src/osmo-bsc/osmo_bsc_sccp.c | 14 +++--- openbsc/src/osmo-bsc_mgcp/mgcp_main.c | 6 +- openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c | 12 ++-- openbsc/src/osmo-bsc_nat/bsc_nat.c | 48 +++++++++--------- openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 22 ++++---- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 10 ++-- openbsc/src/osmo-bsc_nat/bsc_sccp.c | 2 +- openbsc/src/osmo-bsc_nat/bsc_ussd.c | 20 ++++---- openbsc/src/osmo-nitb/bsc_hack.c | 14 +++--- openbsc/src/utils/bs11_config.c | 8 ++-- openbsc/src/utils/rs232.c | 12 ++-- openbsc/tests/channel/channel_test.c | 2 +- 86 files changed, 634 insertions(+), 634 deletions(-) -- 1.7.2.3 From pablo at gnumonks.org Fri May 6 10:31:24 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Fri, 6 May 2011 12:31:24 +0200 Subject: [PATCH 1/5] src: use namespace prefix osmo_timer* for timer functions In-Reply-To: <1304677888-23639-1-git-send-email-pablo@gnumonks.org> References: <1304677888-23639-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304677888-23639-2-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/struct timer_list/struct osmo_timer_list/g s/bsc_add_timer/osmo_timer_add/g s/bsc_schedule_timer/osmo_timer_schedule/g s/bsc_del_timer/osmo_timer_del/g s/bsc_timer_pending/osmo_timer_pending/g s/bsc_nearest_timer/osmo_timers_nearest/g s/bsc_prepare_timers/osmo_timers_prepare/g s/bsc_update_timers/osmo_timers_update/g s/bsc_timer_check/osmo_timers_check/g --- openbsc/include/openbsc/bsc_msc.h | 4 ++-- openbsc/include/openbsc/bsc_nat.h | 8 ++++---- openbsc/include/openbsc/e1_input.h | 2 +- openbsc/include/openbsc/gprs_llc.h | 4 ++-- openbsc/include/openbsc/gprs_ns.h | 2 +- openbsc/include/openbsc/gprs_sgsn.h | 4 ++-- openbsc/include/openbsc/gsm_data.h | 16 ++++++++-------- openbsc/include/openbsc/osmo_bsc.h | 4 ++-- openbsc/include/openbsc/osmo_bsc_rf.h | 6 +++--- openbsc/include/openbsc/osmo_msc_data.h | 4 ++-- openbsc/include/openbsc/paging.h | 2 +- openbsc/include/openbsc/sgsn.h | 2 +- openbsc/include/openbsc/transaction.h | 4 ++-- openbsc/src/gprs/gprs_gmm.c | 18 +++++++++--------- openbsc/src/gprs/gprs_sndcp.h | 2 +- openbsc/src/gprs/sgsn_libgtp.c | 2 +- openbsc/src/ipaccess/ipaccess-find.c | 6 +++--- openbsc/src/ipaccess/ipaccess-proxy.c | 8 ++++---- openbsc/src/libabis/e1_input.c | 6 +++--- openbsc/src/libabis/input/dahdi.c | 2 +- openbsc/src/libabis/input/hsl.c | 2 +- openbsc/src/libabis/input/ipaccess.c | 2 +- openbsc/src/libabis/input/lapd.c | 8 ++++---- openbsc/src/libabis/input/misdn.c | 2 +- openbsc/src/libbsc/abis_rsl.c | 10 +++++----- openbsc/src/libbsc/bsc_api.c | 12 ++++++------ openbsc/src/libbsc/bsc_msc.c | 8 ++++---- openbsc/src/libbsc/bsc_rll.c | 8 ++++---- openbsc/src/libbsc/chan_alloc.c | 8 ++++---- openbsc/src/libbsc/handover_logic.c | 10 +++++----- openbsc/src/libbsc/paging.c | 14 +++++++------- openbsc/src/libgb/gprs_ns.c | 12 ++++++------ openbsc/src/libmsc/gsm_04_08.c | 14 +++++++------- openbsc/src/libmsc/gsm_04_11.c | 10 +++++----- openbsc/src/libmsc/sms_queue.c | 12 ++++++------ openbsc/src/osmo-bsc/osmo_bsc_msc.c | 10 +++++----- openbsc/src/osmo-bsc/osmo_bsc_rf.c | 16 ++++++++-------- openbsc/src/osmo-bsc/osmo_bsc_sccp.c | 12 ++++++------ openbsc/src/osmo-bsc_nat/bsc_nat.c | 22 +++++++++++----------- openbsc/src/osmo-bsc_nat/bsc_ussd.c | 6 +++--- openbsc/src/osmo-nitb/bsc_hack.c | 6 +++--- openbsc/src/utils/bs11_config.c | 4 ++-- 42 files changed, 157 insertions(+), 157 deletions(-) diff --git a/openbsc/include/openbsc/bsc_msc.h b/openbsc/include/openbsc/bsc_msc.h index e3653ac..88f0de4 100644 --- a/openbsc/include/openbsc/bsc_msc.h +++ b/openbsc/include/openbsc/bsc_msc.h @@ -44,8 +44,8 @@ struct bsc_msc_connection { void (*connection_loss) (struct bsc_msc_connection *); void (*connected) (struct bsc_msc_connection *); - struct timer_list reconnect_timer; - struct timer_list timeout_timer; + struct osmo_timer_list reconnect_timer; + struct osmo_timer_list timeout_timer; }; struct bsc_msc_connection *bsc_msc_create(void *ctx, struct llist_head *dest); diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 19f8efa..7d8c37e 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -82,11 +82,11 @@ struct bsc_connection { struct bsc_config *cfg; /* a timeout node */ - struct timer_list id_timeout; + struct osmo_timer_list id_timeout; /* pong timeout */ - struct timer_list ping_timeout; - struct timer_list pong_timeout; + struct osmo_timer_list ping_timeout; + struct osmo_timer_list pong_timeout; /* mgcp related code */ char *_endpoint_status; @@ -290,7 +290,7 @@ struct bsc_nat_ussd_con { struct bsc_nat *nat; int authorized; - struct timer_list auth_timeout; + struct osmo_timer_list auth_timeout; }; /* create and init the structures */ diff --git a/openbsc/include/openbsc/e1_input.h b/openbsc/include/openbsc/e1_input.h index 8a966ad..cd8abca 100644 --- a/openbsc/include/openbsc/e1_input.h +++ b/openbsc/include/openbsc/e1_input.h @@ -69,7 +69,7 @@ struct e1inp_ts { /* delay for the queue */ int delay; /* timer when to dequeue next frame */ - struct timer_list tx_timer; + struct osmo_timer_list tx_timer; } sign; struct { /* subchannel demuxer for frames from E1 */ diff --git a/openbsc/include/openbsc/gprs_llc.h b/openbsc/include/openbsc/gprs_llc.h index 02945e1..9f17605 100644 --- a/openbsc/include/openbsc/gprs_llc.h +++ b/openbsc/include/openbsc/gprs_llc.h @@ -99,8 +99,8 @@ struct gprs_llc_lle { enum gprs_llc_lle_state state; - struct timer_list t200; - struct timer_list t201; /* wait for acknowledgement */ + struct osmo_timer_list t200; + struct osmo_timer_list t201; /* wait for acknowledgement */ uint16_t v_sent; uint16_t v_ack; diff --git a/openbsc/include/openbsc/gprs_ns.h b/openbsc/include/openbsc/gprs_ns.h index 0b50149..f497e23 100644 --- a/openbsc/include/openbsc/gprs_ns.h +++ b/openbsc/include/openbsc/gprs_ns.h @@ -163,7 +163,7 @@ struct gprs_nsvc { uint32_t state; uint32_t remote_state; - struct timer_list timer; + struct osmo_timer_list timer; enum nsvc_timer_mode timer_mode; int alive_retries; diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index bd60d4e..5023d06 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -102,7 +102,7 @@ struct sgsn_mm_ctx { uint16_t nsei; uint16_t bvci; struct rate_ctr_group *ctrg; - struct timer_list timer; + struct osmo_timer_list timer; unsigned int T; /* Txxxx number */ unsigned int num_T_exp; /* number of consecutive T expirations */ @@ -168,7 +168,7 @@ struct sgsn_pdp_ctx { //uint32_t charging_id; int reordering_reqd; - struct timer_list timer; + struct osmo_timer_list timer; unsigned int T; /* Txxxx number */ unsigned int num_T_exp; /* number of consecutive T expirations */ }; diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 31044ec..e6d6467 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -177,7 +177,7 @@ struct gsm_nm_state { * - Accept/Reject according to global policy */ struct gsm_loc_updating_operation { - struct timer_list updating_timer; + struct osmo_timer_list updating_timer; unsigned int waiting_for_imsi : 1; unsigned int waiting_for_imei : 1; unsigned int key_seq : 4; @@ -197,7 +197,7 @@ struct gsm_security_operation { * a couple of seconds to work around MSC issues. */ struct gsm_anchor_operation { - struct timer_list timeout; + struct osmo_timer_list timeout; }; /* Maximum number of neighbor cells whose average we track */ @@ -263,7 +263,7 @@ struct gsm_subscriber_connection { struct gsm_bts *bts; /* for assignment handling */ - struct timer_list T10; + struct osmo_timer_list T10; struct gsm_lchan *secondary_lchan; }; @@ -291,9 +291,9 @@ struct gsm_lchan { uint8_t key[MAX_A5_KEY_LEN]; } encr; - struct timer_list T3101; - struct timer_list T3111; - struct timer_list error_timer; + struct osmo_timer_list T3101; + struct osmo_timer_list T3111; + struct osmo_timer_list error_timer; /* AMR bits */ struct gsm48_multi_rate_conf mr_conf; @@ -464,8 +464,8 @@ struct gsm_bts_paging_state { struct llist_head pending_requests; struct gsm_bts *bts; - struct timer_list work_timer; - struct timer_list credit_timer; + struct osmo_timer_list work_timer; + struct osmo_timer_list credit_timer; /* free chans needed */ int free_chans_need; diff --git a/openbsc/include/openbsc/osmo_bsc.h b/openbsc/include/openbsc/osmo_bsc.h index ef0f11a..2620147 100644 --- a/openbsc/include/openbsc/osmo_bsc.h +++ b/openbsc/include/openbsc/osmo_bsc.h @@ -16,8 +16,8 @@ struct osmo_bsc_sccp_con { /* SCCP connection realted */ struct sccp_connection *sccp; struct bsc_msc_connection *msc_con; - struct timer_list sccp_it_timeout; - struct timer_list sccp_cc_timeout; + struct osmo_timer_list sccp_it_timeout; + struct osmo_timer_list sccp_cc_timeout; struct llist_head sccp_queue; unsigned int sccp_queue_size; diff --git a/openbsc/include/openbsc/osmo_bsc_rf.h b/openbsc/include/openbsc/osmo_bsc_rf.h index 7de9866..f1ff9ba 100644 --- a/openbsc/include/openbsc/osmo_bsc_rf.h +++ b/openbsc/include/openbsc/osmo_bsc_rf.h @@ -16,13 +16,13 @@ struct osmo_bsc_rf { /* delay the command */ char last_request; - struct timer_list delay_cmd; + struct osmo_timer_list delay_cmd; /* verify that RF is up as it should be */ - struct timer_list rf_check; + struct osmo_timer_list rf_check; /* some handling for the automatic grace switch */ - struct timer_list grace_timeout; + struct osmo_timer_list grace_timeout; }; struct osmo_bsc_rf_conn { diff --git a/openbsc/include/openbsc/osmo_msc_data.h b/openbsc/include/openbsc/osmo_msc_data.h index f360da5..495c923 100644 --- a/openbsc/include/openbsc/osmo_msc_data.h +++ b/openbsc/include/openbsc/osmo_msc_data.h @@ -43,8 +43,8 @@ struct osmo_msc_data { char *bsc_token; int ping_timeout; int pong_timeout; - struct timer_list ping_timer; - struct timer_list pong_timer; + struct osmo_timer_list ping_timer; + struct osmo_timer_list pong_timer; struct bsc_msc_connection *msc_con; int core_ncc; int core_mcc; diff --git a/openbsc/include/openbsc/paging.h b/openbsc/include/openbsc/paging.h index 991c4ec..0872eb8 100644 --- a/openbsc/include/openbsc/paging.h +++ b/openbsc/include/openbsc/paging.h @@ -43,7 +43,7 @@ struct gsm_paging_request { int chan_type; /* Timer 3113: how long do we try to page? */ - struct timer_list T3113; + struct osmo_timer_list T3113; /* How often did we ask the BTS to page? */ int attempts; diff --git a/openbsc/include/openbsc/sgsn.h b/openbsc/include/openbsc/sgsn.h index 53d3c05..00e1ec3 100644 --- a/openbsc/include/openbsc/sgsn.h +++ b/openbsc/include/openbsc/sgsn.h @@ -25,7 +25,7 @@ struct sgsn_instance { struct bsc_fd gtp_fd1c; struct bsc_fd gtp_fd1u; /* Timer for libGTP */ - struct timer_list gtp_timer; + struct osmo_timer_list gtp_timer; /* GSN instance for libgtp */ struct gsn_t *gsn; }; diff --git a/openbsc/include/openbsc/transaction.h b/openbsc/include/openbsc/transaction.h index 5f11ef2..c008a96 100644 --- a/openbsc/include/openbsc/transaction.h +++ b/openbsc/include/openbsc/transaction.h @@ -41,14 +41,14 @@ struct gsm_trans { /* current timer and message queue */ int Tcurrent; /* current CC timer */ int T308_second; /* used to send release again */ - struct timer_list timer; + struct osmo_timer_list timer; struct gsm_mncc msg; /* stores setup/disconnect/release message */ } cc; struct { uint8_t link_id; /* RSL Link ID to be used for this trans */ int is_mt; /* is this a MO (0) or MT (1) transfer */ enum gsm411_cp_state cp_state; - struct timer_list cp_timer; + struct osmo_timer_list cp_timer; enum gsm411_rp_state rp_state; diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 7fd8641..a49900e 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -208,7 +208,7 @@ static void mmctx_timer_cb(void *_mm); static void mmctx_timer_start(struct sgsn_mm_ctx *mm, unsigned int T, unsigned int seconds) { - if (bsc_timer_pending(&mm->timer)) + if (osmo_timer_pending(&mm->timer)) LOGP(DMM, LOGL_ERROR, "Starting MM timer %u while old " "timer %u pending\n", T, mm->T); mm->T = T; @@ -218,7 +218,7 @@ static void mmctx_timer_start(struct sgsn_mm_ctx *mm, unsigned int T, mm->timer.data = mm; mm->timer.cb = &mmctx_timer_cb; - bsc_schedule_timer(&mm->timer, seconds, 0); + osmo_timer_schedule(&mm->timer, seconds, 0); } static void mmctx_timer_stop(struct sgsn_mm_ctx *mm, unsigned int T) @@ -226,7 +226,7 @@ static void mmctx_timer_stop(struct sgsn_mm_ctx *mm, unsigned int T) if (mm->T != T) LOGP(DMM, LOGL_ERROR, "Stopping MM timer %u but " "%u is running\n", T, mm->T); - bsc_del_timer(&mm->timer); + osmo_timer_del(&mm->timer); } /* Send a message through the underlying layer */ @@ -1087,7 +1087,7 @@ static void mmctx_timer_cb(void *_mm) /* FIXME */ break; } - bsc_schedule_timer(&mm->timer, GSM0408_T3350_SECS, 0); + osmo_timer_schedule(&mm->timer, GSM0408_T3350_SECS, 0); break; case 3360: /* waiting for AUTH AND CIPH RESP */ if (mm->num_T_exp >= 5) { @@ -1096,7 +1096,7 @@ static void mmctx_timer_cb(void *_mm) break; } /* FIXME: re-transmit the respective msg and re-start timer */ - bsc_schedule_timer(&mm->timer, GSM0408_T3360_SECS, 0); + osmo_timer_schedule(&mm->timer, GSM0408_T3360_SECS, 0); break; case 3370: /* waiting for IDENTITY RESPONSE */ if (mm->num_T_exp >= 5) { @@ -1107,7 +1107,7 @@ static void mmctx_timer_cb(void *_mm) } /* re-tranmit IDENTITY REQUEST and re-start timer */ gsm48_tx_gmm_id_req(mm, mm->t3370_id_type); - bsc_schedule_timer(&mm->timer, GSM0408_T3370_SECS, 0); + osmo_timer_schedule(&mm->timer, GSM0408_T3370_SECS, 0); break; default: LOGP(DMM, LOGL_ERROR, "timer expired in unknown mode %u\n", @@ -1122,7 +1122,7 @@ static void pdpctx_timer_cb(void *_mm); static void pdpctx_timer_start(struct sgsn_pdp_ctx *pdp, unsigned int T, unsigned int seconds) { - if (bsc_timer_pending(&pdp->timer)) + if (osmo_timer_pending(&pdp->timer)) LOGP(DMM, LOGL_ERROR, "Starting MM timer %u while old " "timer %u pending\n", T, pdp->T); pdp->T = T; @@ -1132,7 +1132,7 @@ static void pdpctx_timer_start(struct sgsn_pdp_ctx *pdp, unsigned int T, pdp->timer.data = pdp; pdp->timer.cb = &pdpctx_timer_cb; - bsc_schedule_timer(&pdp->timer, seconds, 0); + osmo_timer_schedule(&pdp->timer, seconds, 0); } @@ -1457,7 +1457,7 @@ static void pdpctx_timer_cb(void *_pdp) break; } gsm48_tx_gsm_deact_pdp_req(pdp, GSM_CAUSE_NET_FAIL); - bsc_schedule_timer(&pdp->timer, GSM0408_T3395_SECS, 0); + osmo_timer_schedule(&pdp->timer, GSM0408_T3395_SECS, 0); break; default: LOGP(DMM, LOGL_ERROR, "timer expired in unknown mode %u\n", diff --git a/openbsc/src/gprs/gprs_sndcp.h b/openbsc/src/gprs/gprs_sndcp.h index ec35d7b..fef871a 100644 --- a/openbsc/src/gprs/gprs_sndcp.h +++ b/openbsc/src/gprs/gprs_sndcp.h @@ -20,7 +20,7 @@ struct defrag_state { /* linked list of defrag_queue_entry: one for each fragment */ struct llist_head frag_list; - struct timer_list timer; + struct osmo_timer_list timer; }; /* See 6.7.1.2 Reassembly */ diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c index 37d976f..7e66035 100644 --- a/openbsc/src/gprs/sgsn_libgtp.c +++ b/openbsc/src/gprs/sgsn_libgtp.c @@ -538,7 +538,7 @@ static void sgsn_gtp_tmr_start(struct sgsn_instance *sgi) gtp_retranstimeout(sgi->gsn, &next); /* re-schedule the timer */ - bsc_schedule_timer(&sgi->gtp_timer, next.tv_sec, next.tv_usec/1000); + osmo_timer_schedule(&sgi->gtp_timer, next.tv_sec, next.tv_usec/1000); } /* timer callback for libgtp retransmissions and ping */ diff --git a/openbsc/src/ipaccess/ipaccess-find.c b/openbsc/src/ipaccess/ipaccess-find.c index 9335ec8..24f602e 100644 --- a/openbsc/src/ipaccess/ipaccess-find.c +++ b/openbsc/src/ipaccess/ipaccess-find.c @@ -152,7 +152,7 @@ static int bfd_cb(struct bsc_fd *bfd, unsigned int flags) return 0; } -static struct timer_list timer; +static struct osmo_timer_list timer; static void timer_cb(void *_data) { @@ -160,7 +160,7 @@ static void timer_cb(void *_data) bfd->when |= BSC_FD_WRITE; - bsc_schedule_timer(&timer, 5, 0); + osmo_timer_schedule(&timer, 5, 0); } int main(int argc, char **argv) @@ -192,7 +192,7 @@ int main(int argc, char **argv) timer.cb = timer_cb; timer.data = &bfd; - bsc_schedule_timer(&timer, 5, 0); + osmo_timer_schedule(&timer, 5, 0); printf("Trying to find ip.access BTS by broadcast UDP...\n"); diff --git a/openbsc/src/ipaccess/ipaccess-proxy.c b/openbsc/src/ipaccess/ipaccess-proxy.c index bb4841c..f40590a 100644 --- a/openbsc/src/ipaccess/ipaccess-proxy.c +++ b/openbsc/src/ipaccess/ipaccess-proxy.c @@ -57,7 +57,7 @@ struct ipa_proxy { /* list of BTS's (struct ipa_bts_conn */ struct llist_head bts_list; /* the BSC reconnect timer */ - struct timer_list reconn_timer; + struct osmo_timer_list reconn_timer; /* global GPRS NS data */ struct in_addr gprs_addr; struct in_addr listen_addr; @@ -657,7 +657,7 @@ static void reconn_tmr_cb(void *data) return; reschedule: - bsc_schedule_timer(&ipp->reconn_timer, 5, 0); + osmo_timer_schedule(&ipp->reconn_timer, 5, 0); } static void handle_dead_socket(struct bsc_fd *bfd) @@ -709,13 +709,13 @@ static void handle_dead_socket(struct bsc_fd *bfd) ipbc->bsc_oml_conn = NULL; bsc_conn = ipbc->oml_conn; /* start reconnect timer */ - bsc_schedule_timer(&ipp->reconn_timer, 5, 0); + osmo_timer_schedule(&ipp->reconn_timer, 5, 0); break; case RSL_TO_BSC: /* incoming RSL data from BSC, forward to BTS RSL */ ipbc->bsc_rsl_conn[trx_id] = NULL; bsc_conn = ipbc->rsl_conn[trx_id]; /* start reconnect timer */ - bsc_schedule_timer(&ipp->reconn_timer, 5, 0); + osmo_timer_schedule(&ipp->reconn_timer, 5, 0); break; default: bsc_conn = NULL; diff --git a/openbsc/src/libabis/e1_input.c b/openbsc/src/libabis/e1_input.c index 1a79261..d3a5cda 100644 --- a/openbsc/src/libabis/e1_input.c +++ b/openbsc/src/libabis/e1_input.c @@ -241,7 +241,7 @@ int abis_rsl_sendmsg(struct msgb *msg) sign_link = msg->trx->rsl_link; e1i_ts = sign_link->ts; - if (!bsc_timer_pending(&e1i_ts->sign.tx_timer)) { + if (!osmo_timer_pending(&e1i_ts->sign.tx_timer)) { /* notify the driver we have something to write */ e1inp_driver = sign_link->ts->line->driver; e1inp_driver->want_write(e1i_ts); @@ -276,7 +276,7 @@ int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml) sign_link = msg->trx->bts->oml_link; e1i_ts = sign_link->ts; - if (!bsc_timer_pending(&e1i_ts->sign.tx_timer)) { + if (!osmo_timer_pending(&e1i_ts->sign.tx_timer)) { /* notify the driver we have something to write */ e1inp_driver = sign_link->ts->line->driver; e1inp_driver->want_write(e1i_ts); @@ -471,7 +471,7 @@ void e1inp_sign_link_destroy(struct e1inp_sign_link *link) } if (link->ts->type == E1INP_TS_TYPE_SIGN) - bsc_del_timer(&link->ts->sign.tx_timer); + osmo_timer_del(&link->ts->sign.tx_timer); talloc_free(link); } diff --git a/openbsc/src/libabis/input/dahdi.c b/openbsc/src/libabis/input/dahdi.c index 93c8fa5..4fcd64f 100644 --- a/openbsc/src/libabis/input/dahdi.c +++ b/openbsc/src/libabis/input/dahdi.c @@ -222,7 +222,7 @@ static int handle_ts1_write(struct bsc_fd *bfd) /* set tx delay timer for next event */ e1i_ts->sign.tx_timer.cb = timeout_ts1_write; e1i_ts->sign.tx_timer.data = e1i_ts; - bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, 50000); + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, 50000); return 0; } diff --git a/openbsc/src/libabis/input/hsl.c b/openbsc/src/libabis/input/hsl.c index 44528dd..9ff8552 100644 --- a/openbsc/src/libabis/input/hsl.c +++ b/openbsc/src/libabis/input/hsl.c @@ -340,7 +340,7 @@ static int handle_ts1_write(struct bsc_fd *bfd) e1i_ts->sign.tx_timer.data = e1i_ts; /* Reducing this might break the nanoBTS 900 init. */ - bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); return ret; } diff --git a/openbsc/src/libabis/input/ipaccess.c b/openbsc/src/libabis/input/ipaccess.c index d2572fb..95e84f6 100644 --- a/openbsc/src/libabis/input/ipaccess.c +++ b/openbsc/src/libabis/input/ipaccess.c @@ -633,7 +633,7 @@ static int handle_ts1_write(struct bsc_fd *bfd) e1i_ts->sign.tx_timer.data = e1i_ts; /* Reducing this might break the nanoBTS 900 init. */ - bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); return ret; } diff --git a/openbsc/src/libabis/input/lapd.c b/openbsc/src/libabis/input/lapd.c index c8830d2..d0fab18 100644 --- a/openbsc/src/libabis/input/lapd.c +++ b/openbsc/src/libabis/input/lapd.c @@ -137,7 +137,7 @@ struct lapd_sap { int va; /* last acked by peer */ int vr; /* next expected to be received */ - struct timer_list sabme_timer; /* timer to re-transmit SABM message */ + struct osmo_timer_list sabme_timer; /* timer to re-transmit SABM message */ }; /* 3.5.2.2 Send state variable V(S) @@ -259,11 +259,11 @@ static void lapd_sap_set_state(struct lapd_tei *teip, uint8_t sapi, switch (sap->state) { case SAP_STATE_SABM_RETRANS: if (newstate != SAP_STATE_SABM_RETRANS) - bsc_del_timer(&sap->sabme_timer); + osmo_timer_del(&sap->sabme_timer); break; default: if (newstate == SAP_STATE_SABM_RETRANS) - bsc_schedule_timer(&sap->sabme_timer, SABM_INTERVAL); + osmo_timer_schedule(&sap->sabme_timer, SABM_INTERVAL); break; } @@ -608,7 +608,7 @@ static void sabme_timer_cb(void *_sap) lapd_send_sabm(sap->tei->li, sap->tei->tei, sap->sapi); if (sap->state == SAP_STATE_SABM_RETRANS) - bsc_schedule_timer(&sap->sabme_timer, SABM_INTERVAL); + osmo_timer_schedule(&sap->sabme_timer, SABM_INTERVAL); } /* Start a (user-side) SAP for the specified TEI/SAPI on the LAPD instance */ diff --git a/openbsc/src/libabis/input/misdn.c b/openbsc/src/libabis/input/misdn.c index 2d52441..3c33792 100644 --- a/openbsc/src/libabis/input/misdn.c +++ b/openbsc/src/libabis/input/misdn.c @@ -246,7 +246,7 @@ static int handle_ts1_write(struct bsc_fd *bfd) /* set tx delay timer for next event */ e1i_ts->sign.tx_timer.cb = timeout_ts1_write; e1i_ts->sign.tx_timer.data = e1i_ts; - bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); + osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); return ret; } diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index eb6ed03..941a4ba 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -669,7 +669,7 @@ static int rsl_rf_chan_release(struct gsm_lchan *lchan, int error) rsl_lchan_set_state(lchan, LCHAN_S_REL_ERR); lchan->error_timer.data = lchan; lchan->error_timer.cb = error_timeout_cb; - bsc_schedule_timer(&lchan->error_timer, + osmo_timer_schedule(&lchan->error_timer, msg->trx->bts->network->T3111 + 2, 0); } @@ -694,7 +694,7 @@ static int rsl_rx_rf_chan_rel_ack(struct gsm_lchan *lchan) LOGP(DRSL, LOGL_NOTICE, "%s CHAN REL ACK but state %s\n", gsm_lchan_name(lchan), gsm_lchans_name(lchan->state)); - bsc_del_timer(&lchan->T3111); + osmo_timer_del(&lchan->T3111); /* we have an error timer pending to release that */ if (lchan->state != LCHAN_S_REL_ERR) rsl_lchan_set_state(lchan, LCHAN_S_NONE); @@ -1354,7 +1354,7 @@ static int rsl_send_imm_assignment(struct gsm_lchan *lchan) /* Start timer T3101 to wait for GSM48_MT_RR_PAG_RESP */ lchan->T3101.cb = t3101_expired; lchan->T3101.data = lchan; - bsc_schedule_timer(&lchan->T3101, bts->network->T3101, 0); + osmo_timer_schedule(&lchan->T3101, bts->network->T3101, 0); /* send IMMEDIATE ASSIGN CMD on RSL to BTS (to send on CCCH to MS) */ return rsl_imm_assign_cmd(bts, sizeof(*ia)+ia->mob_alloc_len, (uint8_t *) ia); @@ -1466,7 +1466,7 @@ static void rsl_handle_release(struct gsm_lchan *lchan) lchan->T3111.cb = t3111_expired; lchan->T3111.data = lchan; bts = lchan->ts->trx->bts; - bsc_schedule_timer(&lchan->T3111, bts->network->T3111, 0); + osmo_timer_schedule(&lchan->T3111, bts->network->T3111, 0); } /* ESTABLISH INDICATION, LOCATION AREA UPDATE REQUEST @@ -1500,7 +1500,7 @@ static int abis_rsl_rx_rll(struct msgb *msg) DEBUGPC(DRLL, "ESTABLISH INDICATION\n"); /* lchan is established, stop T3101 */ msg->lchan->sapis[rllh->link_id & 0x7] = LCHAN_SAPI_MS; - bsc_del_timer(&msg->lchan->T3101); + osmo_timer_del(&msg->lchan->T3101); if (msgb_l2len(msg) > sizeof(struct abis_rsl_common_hdr) + sizeof(*rllh) && rllh->data[0] == RSL_IE_L3_INFO) { diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c index 4b48ec6..09e9de4 100644 --- a/openbsc/src/libbsc/bsc_api.c +++ b/openbsc/src/libbsc/bsc_api.c @@ -325,7 +325,7 @@ int gsm0808_assign_req(struct gsm_subscriber_connection *conn, int chan_mode, in /* we will now start the timer to complete the assignment */ conn->T10.cb = assignment_t10_timeout; conn->T10.data = conn; - bsc_schedule_timer(&conn->T10, GSM0808_T10_VALUE); + osmo_timer_schedule(&conn->T10, GSM0808_T10_VALUE); return 0; error: @@ -358,7 +358,7 @@ static void handle_ass_compl(struct gsm_subscriber_connection *conn, } /* swap channels */ - bsc_del_timer(&conn->T10); + osmo_timer_del(&conn->T10); lchan_release(conn->lchan, 0, 1); conn->lchan = conn->secondary_lchan; @@ -387,7 +387,7 @@ static void handle_ass_fail(struct gsm_subscriber_connection *conn, } /* stop the timer and release it */ - bsc_del_timer(&conn->T10); + osmo_timer_del(&conn->T10); lchan_release(conn->secondary_lchan, 0, 1); conn->secondary_lchan = NULL; @@ -435,7 +435,7 @@ static void dispatch_dtap(struct gsm_subscriber_connection *conn, handle_ass_fail(conn, msg); break; case GSM48_MT_RR_CHAN_MODE_MODIF_ACK: - bsc_del_timer(&conn->T10); + osmo_timer_del(&conn->T10); rc = gsm48_rx_rr_modif_ack(msg); if (rc < 0 && api->assign_fail) { api->assign_fail(conn, @@ -536,7 +536,7 @@ int gsm0808_clear(struct gsm_subscriber_connection *conn) conn->ho_lchan = NULL; conn->bts = NULL; - bsc_del_timer(&conn->T10); + osmo_timer_del(&conn->T10); return 0; } @@ -621,7 +621,7 @@ static void handle_release(struct gsm_subscriber_connection *conn, int destruct = 1; if (conn->secondary_lchan == lchan) { - bsc_del_timer(&conn->T10); + osmo_timer_del(&conn->T10); conn->secondary_lchan = NULL; bsc->assign_fail(conn, diff --git a/openbsc/src/libbsc/bsc_msc.c b/openbsc/src/libbsc/bsc_msc.c index 8eef6f4..f4eee9c 100644 --- a/openbsc/src/libbsc/bsc_msc.c +++ b/openbsc/src/libbsc/bsc_msc.c @@ -77,7 +77,7 @@ static int msc_connection_connect(struct bsc_fd *fd, unsigned int what) con = container_of(queue, struct bsc_msc_connection, write_queue); /* From here on we will either be connected or reconnect */ - bsc_del_timer(&con->timeout_timer); + osmo_timer_del(&con->timeout_timer); /* check the socket state */ rc = getsockopt(fd->fd, SOL_SOCKET, SO_ERROR, &val, &len); @@ -184,7 +184,7 @@ int bsc_msc_connect(struct bsc_msc_connection *con) fd->cb = msc_connection_connect; con->timeout_timer.cb = msc_con_timeout; con->timeout_timer.data = con; - bsc_schedule_timer(&con->timeout_timer, 20, 0); + osmo_timer_schedule(&con->timeout_timer, 20, 0); } else if (ret < 0) { perror("Connection failed"); connection_loss(con); @@ -226,7 +226,7 @@ struct bsc_msc_connection *bsc_msc_create(void *ctx, struct llist_head *dests) void bsc_msc_lost(struct bsc_msc_connection *con) { write_queue_clear(&con->write_queue); - bsc_del_timer(&con->timeout_timer); + osmo_timer_del(&con->timeout_timer); if (con->write_queue.bfd.fd >= 0) bsc_unregister_fd(&con->write_queue.bfd); @@ -246,7 +246,7 @@ void bsc_msc_schedule_connect(struct bsc_msc_connection *con) LOGP(DMSC, LOGL_NOTICE, "Attempting to reconnect to the MSC.\n"); con->reconnect_timer.cb = reconnect_msc; con->reconnect_timer.data = con; - bsc_schedule_timer(&con->reconnect_timer, 5, 0); + osmo_timer_schedule(&con->reconnect_timer, 5, 0); } struct msgb *bsc_msc_id_get_resp(const char *token) diff --git a/openbsc/src/libbsc/bsc_rll.c b/openbsc/src/libbsc/bsc_rll.c index b02394a..9fbe7c6 100644 --- a/openbsc/src/libbsc/bsc_rll.c +++ b/openbsc/src/libbsc/bsc_rll.c @@ -34,7 +34,7 @@ struct bsc_rll_req { struct llist_head list; - struct timer_list timer; + struct osmo_timer_list timer; struct gsm_lchan *lchan; uint8_t link_id; @@ -92,7 +92,7 @@ int rll_establish(struct gsm_lchan *lchan, uint8_t sapi, rllr->timer.cb = &timer_cb; rllr->timer.data = rllr; - bsc_schedule_timer(&rllr->timer, 10, 0); + osmo_timer_schedule(&rllr->timer, 10, 0); /* send the RSL RLL ESTablish REQuest */ return rsl_establish_request(rllr->lchan, rllr->link_id); @@ -107,7 +107,7 @@ void rll_indication(struct gsm_lchan *lchan, uint8_t link_id, uint8_t type) llist_for_each_entry_safe(rllr, rllr2, &bsc_rll_reqs, list) { if (rllr->lchan == lchan && (rllr->link_id & LINKID_MASK) == (link_id & LINKID_MASK)) { - bsc_del_timer(&rllr->timer); + osmo_timer_del(&rllr->timer); complete_rllr(rllr, type); return; } @@ -127,7 +127,7 @@ static int rll_lchan_signal(unsigned int subsys, unsigned int signal, llist_for_each_entry_safe(rllr, rllr2, &bsc_rll_reqs, list) { if (rllr->lchan == challoc->lchan) { - bsc_del_timer(&rllr->timer); + osmo_timer_del(&rllr->timer); complete_rllr(rllr, BSC_RLLR_IND_ERR_IND); } } diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c index b794132..ff745f5 100644 --- a/openbsc/src/libbsc/chan_alloc.c +++ b/openbsc/src/libbsc/chan_alloc.c @@ -311,7 +311,7 @@ void lchan_free(struct gsm_lchan *lchan) /* stop the timer */ - bsc_del_timer(&lchan->T3101); + osmo_timer_del(&lchan->T3101); /* clear cached measuement reports */ lchan->meas_rep_idx = 0; @@ -356,9 +356,9 @@ void lchan_free(struct gsm_lchan *lchan) */ void lchan_reset(struct gsm_lchan *lchan) { - bsc_del_timer(&lchan->T3101); - bsc_del_timer(&lchan->T3111); - bsc_del_timer(&lchan->error_timer); + osmo_timer_del(&lchan->T3101); + osmo_timer_del(&lchan->T3111); + osmo_timer_del(&lchan->error_timer); lchan->type = GSM_LCHAN_NONE; lchan->state = LCHAN_S_NONE; diff --git a/openbsc/src/libbsc/handover_logic.c b/openbsc/src/libbsc/handover_logic.c index 976a7fd..bf9588b 100644 --- a/openbsc/src/libbsc/handover_logic.c +++ b/openbsc/src/libbsc/handover_logic.c @@ -47,7 +47,7 @@ struct bsc_handover { struct gsm_lchan *old_lchan; struct gsm_lchan *new_lchan; - struct timer_list T3103; + struct osmo_timer_list T3103; uint8_t ho_ref; }; @@ -170,7 +170,7 @@ void bsc_clear_handover(struct gsm_subscriber_connection *conn, int free_lchan) if (free_lchan) lchan_release(ho->new_lchan, 0, 1); - bsc_del_timer(&ho->T3103); + osmo_timer_del(&ho->T3103); llist_del(&ho->list); talloc_free(ho); } @@ -214,7 +214,7 @@ static int ho_chan_activ_ack(struct gsm_lchan *new_lchan) * 04.08 HANDOVER COMPLETE or 04.08 HANDOVER FAIL */ ho->T3103.cb = ho_T3103_cb; ho->T3103.data = ho; - bsc_schedule_timer(&ho->T3103, 10, 0); + osmo_timer_schedule(&ho->T3103, 10, 0); /* create a RTP connection */ if (is_ipaccess_bts(new_lchan->ts->trx->bts)) @@ -264,7 +264,7 @@ static int ho_gsm48_ho_compl(struct gsm_lchan *new_lchan) counter_inc(net->stats.handover.completed); - bsc_del_timer(&ho->T3103); + osmo_timer_del(&ho->T3103); /* Replace the ho lchan with the primary one */ if (ho->old_lchan != new_lchan->conn->lchan) @@ -302,7 +302,7 @@ static int ho_gsm48_ho_fail(struct gsm_lchan *old_lchan) counter_inc(net->stats.handover.failed); - bsc_del_timer(&ho->T3103); + osmo_timer_del(&ho->T3103); llist_del(&ho->list); /* release the channel and forget about it */ diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index a336144..324104f 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -73,7 +73,7 @@ static unsigned int calculate_group(struct gsm_bts *bts, struct gsm_subscriber * static void paging_remove_request(struct gsm_bts_paging_state *paging_bts, struct gsm_paging_request *to_be_deleted) { - bsc_del_timer(&to_be_deleted->T3113); + osmo_timer_del(&to_be_deleted->T3113); llist_del(&to_be_deleted->entry); subscr_put(to_be_deleted->subscr); talloc_free(to_be_deleted); @@ -102,8 +102,8 @@ static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts) if (llist_empty(&paging_bts->pending_requests)) return; - if (!bsc_timer_pending(&paging_bts->work_timer)) - bsc_schedule_timer(&paging_bts->work_timer, PAGING_TIMER); + if (!osmo_timer_pending(&paging_bts->work_timer)) + osmo_timer_schedule(&paging_bts->work_timer, PAGING_TIMER); } @@ -192,7 +192,7 @@ static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_b if (paging_bts->available_slots == 0) { paging_bts->credit_timer.cb = paging_give_credit; paging_bts->credit_timer.data = paging_bts; - bsc_schedule_timer(&paging_bts->credit_timer, 5, 0); + osmo_timer_schedule(&paging_bts->credit_timer, 5, 0); return; } @@ -215,7 +215,7 @@ static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_b llist_add_tail(&request->entry, &paging_bts->pending_requests); skip_paging: - bsc_schedule_timer(&paging_bts->work_timer, PAGING_TIMER); + osmo_timer_schedule(&paging_bts->work_timer, PAGING_TIMER); } static void paging_worker(void *data) @@ -298,7 +298,7 @@ static int _paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr, req->cbfn_param = data; req->T3113.cb = paging_T3113_expired; req->T3113.data = req; - bsc_schedule_timer(&req->T3113, bts->network->T3113, 0); + osmo_timer_schedule(&req->T3113, bts->network->T3113, 0); llist_add_tail(&req->entry, &bts_entry->pending_requests); paging_schedule_if_needed(bts_entry); @@ -399,7 +399,7 @@ void paging_update_buffer_space(struct gsm_bts *bts, uint16_t free_slots) { paging_init_if_needed(bts); - bsc_del_timer(&bts->paging.credit_timer); + osmo_timer_del(&bts->paging.credit_timer); bts->paging.available_slots = free_slots; paging_schedule_if_needed(&bts->paging); } diff --git a/openbsc/src/libgb/gprs_ns.c b/openbsc/src/libgb/gprs_ns.c index 95e5a55..1c3c1b6 100644 --- a/openbsc/src/libgb/gprs_ns.c +++ b/openbsc/src/libgb/gprs_ns.c @@ -166,8 +166,8 @@ struct gprs_nsvc *nsvc_create(struct gprs_ns_inst *nsi, uint16_t nsvci) void nsvc_delete(struct gprs_nsvc *nsvc) { - if (bsc_timer_pending(&nsvc->timer)) - bsc_del_timer(&nsvc->timer); + if (osmo_timer_pending(&nsvc->timer)) + osmo_timer_del(&nsvc->timer); llist_del(&nsvc->list); talloc_free(nsvc); } @@ -405,11 +405,11 @@ static void nsvc_start_timer(struct gprs_nsvc *nsvc, enum nsvc_timer_mode mode) nsvc->nsei, get_value_string(timer_mode_strs, mode), seconds); - if (bsc_timer_pending(&nsvc->timer)) - bsc_del_timer(&nsvc->timer); + if (osmo_timer_pending(&nsvc->timer)) + osmo_timer_del(&nsvc->timer); nsvc->timer_mode = mode; - bsc_schedule_timer(&nsvc->timer, seconds, 0); + osmo_timer_schedule(&nsvc->timer, seconds, 0); } static void gprs_ns_timer_cb(void *data) @@ -786,7 +786,7 @@ int gprs_ns_rcvmsg(struct gprs_ns_inst *nsi, struct msgb *msg, rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_BLOCKED]); if (nsvc->persistent || nsvc->remote_end_is_sgsn) { /* stop RESET timer */ - bsc_del_timer(&nsvc->timer); + osmo_timer_del(&nsvc->timer); } /* Initiate TEST proc.: Send ALIVE and start timer */ rc = gprs_ns_tx_simple(nsvc, NS_PDUT_ALIVE); diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 7d6580a..9b7549f 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -243,7 +243,7 @@ static void release_loc_updating_req(struct gsm_subscriber_connection *conn) /* No need to keep the connection up */ release_anchor(conn); - bsc_del_timer(&conn->loc_operation->updating_timer); + osmo_timer_del(&conn->loc_operation->updating_timer); talloc_free(conn->loc_operation); conn->loc_operation = NULL; msc_release_connection(conn); @@ -483,7 +483,7 @@ static void schedule_reject(struct gsm_subscriber_connection *conn) { conn->loc_operation->updating_timer.cb = loc_upd_rej_cb; conn->loc_operation->updating_timer.data = conn; - bsc_schedule_timer(&conn->loc_operation->updating_timer, 5, 0); + osmo_timer_schedule(&conn->loc_operation->updating_timer, 5, 0); } static const char *lupd_name(uint8_t type) @@ -1331,9 +1331,9 @@ static int gsm48_tx_simple(struct gsm_subscriber_connection *conn, static void gsm48_stop_cc_timer(struct gsm_trans *trans) { - if (bsc_timer_pending(&trans->cc.timer)) { + if (osmo_timer_pending(&trans->cc.timer)) { DEBUGP(DCC, "stopping pending timer T%x\n", trans->cc.Tcurrent); - bsc_del_timer(&trans->cc.timer); + osmo_timer_del(&trans->cc.timer); trans->cc.Tcurrent = 0; } } @@ -1816,7 +1816,7 @@ static void gsm48_start_cc_timer(struct gsm_trans *trans, int current, DEBUGP(DCC, "starting timer T%x with %d seconds\n", current, sec); trans->cc.timer.cb = gsm48_cc_timeout; trans->cc.timer.data = trans; - bsc_schedule_timer(&trans->cc.timer, sec, micro); + osmo_timer_schedule(&trans->cc.timer, sec, micro); trans->cc.Tcurrent = current; } @@ -3269,7 +3269,7 @@ static void release_anchor(struct gsm_subscriber_connection *conn) if (!conn->anch_operation) return; - bsc_del_timer(&conn->anch_operation->timeout); + osmo_timer_del(&conn->anch_operation->timeout); talloc_free(conn->anch_operation); conn->anch_operation = NULL; } @@ -3290,7 +3290,7 @@ int gsm0408_new_conn(struct gsm_subscriber_connection *conn) conn->anch_operation->timeout.data = conn; conn->anch_operation->timeout.cb = anchor_timeout; - bsc_schedule_timer(&conn->anch_operation->timeout, 5, 0); + osmo_timer_schedule(&conn->anch_operation->timeout, 5, 0); return 0; } diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c index c7ac8f4..1db307a 100644 --- a/openbsc/src/libmsc/gsm_04_11.c +++ b/openbsc/src/libmsc/gsm_04_11.c @@ -210,7 +210,7 @@ static int gsm411_cp_sendmsg(struct msgb *msg, struct gsm_trans *trans, trans->sms.cp_timer.data = trans; trans->sms.cp_timer.cb = cp_timer_expired; /* 5.3.2.1: Set Timer TC1A */ - bsc_schedule_timer(&trans->sms.cp_timer, GSM411_TMR_TC1A); + osmo_timer_schedule(&trans->sms.cp_timer, GSM411_TMR_TC1A); DEBUGP(DSMS, "TX: CP-DATA "); break; case GSM411_MT_CP_ACK: @@ -1008,7 +1008,7 @@ int gsm0411_rcv_sms(struct gsm_subscriber_connection *conn, DEBUGP(DSMS, "Implicit CP-ACK for trans_id=%x\n", i); /* Finish it for good */ - bsc_del_timer(&ptrans->sms.cp_timer); + osmo_timer_del(&ptrans->sms.cp_timer); ptrans->sms.cp_state = GSM411_CPS_IDLE; trans_free(ptrans); } @@ -1039,7 +1039,7 @@ int gsm0411_rcv_sms(struct gsm_subscriber_connection *conn, /* 5.2.3.2.4: MT state exists when SMC has received CP-ACK */ trans->sms.cp_state = GSM411_CPS_MM_ESTABLISHED; /* Stop TC1* after CP-ACK has been received */ - bsc_del_timer(&trans->sms.cp_timer); + osmo_timer_del(&trans->sms.cp_timer); if (!trans->sms.is_mt) { /* FIXME: we have sent one CP-DATA, which was now @@ -1052,7 +1052,7 @@ int gsm0411_rcv_sms(struct gsm_subscriber_connection *conn, case GSM411_MT_CP_ERROR: DEBUGPC(DSMS, "RX SMS CP-ERROR, cause %d (%s)\n", gh->data[0], get_value_string(cp_cause_strs, gh->data[0])); - bsc_del_timer(&trans->sms.cp_timer); + osmo_timer_del(&trans->sms.cp_timer); trans->sms.cp_state = GSM411_CPS_IDLE; trans_free(trans); break; @@ -1208,7 +1208,7 @@ void _gsm411_sms_trans_free(struct gsm_trans *trans) trans->sms.sms = NULL; } - bsc_del_timer(&trans->sms.cp_timer); + osmo_timer_del(&trans->sms.cp_timer); } void gsm411_sapi_n_reject(struct gsm_subscriber_connection *conn) diff --git a/openbsc/src/libmsc/sms_queue.c b/openbsc/src/libmsc/sms_queue.c index f0d3d37..18545bf 100644 --- a/openbsc/src/libmsc/sms_queue.c +++ b/openbsc/src/libmsc/sms_queue.c @@ -54,8 +54,8 @@ struct gsm_sms_pending { }; struct gsm_sms_queue { - struct timer_list resend_pending; - struct timer_list push_queue; + struct osmo_timer_list resend_pending; + struct osmo_timer_list push_queue; struct gsm_network *network; int max_fail; int max_pending; @@ -129,10 +129,10 @@ static void sms_pending_resend(struct gsm_sms_pending *pending) pending->resend = 1; smsq = pending->subscr->net->sms_queue; - if (bsc_timer_pending(&smsq->resend_pending)) + if (osmo_timer_pending(&smsq->resend_pending)) return; - bsc_schedule_timer(&smsq->resend_pending, 1, 0); + osmo_timer_schedule(&smsq->resend_pending, 1, 0); } static void sms_pending_failed(struct gsm_sms_pending *pending, int paging_error) @@ -288,10 +288,10 @@ static void sms_submit_pending(void *_data) */ int sms_queue_trigger(struct gsm_sms_queue *smsq) { - if (bsc_timer_pending(&smsq->push_queue)) + if (osmo_timer_pending(&smsq->push_queue)) return 0; - bsc_schedule_timer(&smsq->push_queue, 1, 0); + osmo_timer_schedule(&smsq->push_queue, 1, 0); return 0; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c index 66d18c8..e1a95a8 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c @@ -239,7 +239,7 @@ static int ipaccess_a_fd_cb(struct bsc_fd *bfd) else if (msg->l2h[0] == IPAC_MSGT_ID_GET) { send_id_get_response(data, bfd->fd); } else if (msg->l2h[0] == IPAC_MSGT_PONG) { - bsc_del_timer(&data->pong_timer); + osmo_timer_del(&data->pong_timer); } } else if (hh->proto == IPAC_PROTO_SCCP) { sccp_system_incoming(msg); @@ -278,10 +278,10 @@ static void msc_ping_timeout_cb(void *_data) send_ping(data); /* send another ping in 20 seconds */ - bsc_schedule_timer(&data->ping_timer, data->ping_timeout, 0); + osmo_timer_schedule(&data->ping_timer, data->ping_timeout, 0); /* also start a pong timer */ - bsc_schedule_timer(&data->pong_timer, data->pong_timeout, 0); + osmo_timer_schedule(&data->pong_timer, data->pong_timeout, 0); } static void msc_pong_timeout_cb(void *_data) @@ -321,8 +321,8 @@ static void msc_connection_was_lost(struct bsc_msc_connection *msc) LOGP(DMSC, LOGL_ERROR, "Lost MSC connection. Freing stuff.\n"); data = (struct osmo_msc_data *) msc->write_queue.bfd.data; - bsc_del_timer(&data->ping_timer); - bsc_del_timer(&data->pong_timer); + osmo_timer_del(&data->ping_timer); + osmo_timer_del(&data->pong_timer); sig.data = data; dispatch_signal(SS_MSC, S_MSC_LOST, &sig); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_rf.c b/openbsc/src/osmo-bsc/osmo_bsc_rf.c index 436474c..8df0306 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_rf.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_rf.c @@ -160,7 +160,7 @@ static int enter_grace(struct osmo_bsc_rf *rf) { rf->grace_timeout.cb = grace_timeout; rf->grace_timeout.data = rf; - bsc_schedule_timer(&rf->grace_timeout, rf->gsm_network->msc_data->mid_call_timeout, 0); + osmo_timer_schedule(&rf->grace_timeout, rf->gsm_network->msc_data->mid_call_timeout, 0); LOGP(DINP, LOGL_NOTICE, "Going to switch RF off in %d seconds.\n", rf->gsm_network->msc_data->mid_call_timeout); @@ -175,20 +175,20 @@ static void rf_delay_cmd_cb(void *data) switch (rf->last_request) { case RF_CMD_D_OFF: rf->last_state_command = "RF Direct Off"; - bsc_del_timer(&rf->rf_check); - bsc_del_timer(&rf->grace_timeout); + osmo_timer_del(&rf->rf_check); + osmo_timer_del(&rf->grace_timeout); switch_rf_off(rf); break; case RF_CMD_ON: rf->last_state_command = "RF Direct On"; - bsc_del_timer(&rf->grace_timeout); + osmo_timer_del(&rf->grace_timeout); lock_each_trx(rf->gsm_network, 0); send_signal(rf, S_RF_ON); - bsc_schedule_timer(&rf->rf_check, 3, 0); + osmo_timer_schedule(&rf->rf_check, 3, 0); break; case RF_CMD_OFF: rf->last_state_command = "RF Scheduled Off"; - bsc_del_timer(&rf->rf_check); + osmo_timer_del(&rf->rf_check); enter_grace(rf); break; } @@ -218,8 +218,8 @@ static int rf_read_cmd(struct bsc_fd *fd) case RF_CMD_ON: case RF_CMD_OFF: conn->rf->last_request = buf[0]; - if (!bsc_timer_pending(&conn->rf->delay_cmd)) - bsc_schedule_timer(&conn->rf->delay_cmd, 1, 0); + if (!osmo_timer_pending(&conn->rf->delay_cmd)) + osmo_timer_schedule(&conn->rf->delay_cmd, 1, 0); break; default: conn->rf->last_state_command = "Unknown command"; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c index 718f305..099552b 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c @@ -95,8 +95,8 @@ static void msc_outgoing_sccp_state(struct sccp_connection *conn, int old_state) LOGP(DMSC, LOGL_DEBUG, "Connection established: %p\n", conn); con_data = (struct osmo_bsc_sccp_con *) conn->data_ctx; - bsc_del_timer(&con_data->sccp_cc_timeout); - bsc_schedule_timer(&con_data->sccp_it_timeout, SCCP_IT_TIMER, 0); + osmo_timer_del(&con_data->sccp_cc_timeout); + osmo_timer_schedule(&con_data->sccp_it_timeout, SCCP_IT_TIMER, 0); send_queued(con_data); } @@ -122,7 +122,7 @@ static void sccp_it_timeout(void *_data) (struct osmo_bsc_sccp_con *) _data; sccp_connection_send_it(data->sccp); - bsc_schedule_timer(&data->sccp_it_timeout, SCCP_IT_TIMER, 0); + osmo_timer_schedule(&data->sccp_it_timeout, SCCP_IT_TIMER, 0); } static void sccp_cc_timeout(void *_data) @@ -231,7 +231,7 @@ int bsc_create_new_connection(struct gsm_subscriber_connection *conn) int bsc_open_connection(struct osmo_bsc_sccp_con *conn, struct msgb *msg) { - bsc_schedule_timer(&conn->sccp_cc_timeout, 10, 0); + osmo_timer_schedule(&conn->sccp_cc_timeout, 10, 0); sccp_connection_connect(conn->sccp, &sccp_ssn_bssap, msg); msgb_free(msg); return 0; @@ -246,8 +246,8 @@ int bsc_delete_connection(struct osmo_bsc_sccp_con *sccp) LOGP(DMSC, LOGL_ERROR, "Should have been cleared.\n"); llist_del(&sccp->entry); - bsc_del_timer(&sccp->sccp_it_timeout); - bsc_del_timer(&sccp->sccp_cc_timeout); + osmo_timer_del(&sccp->sccp_it_timeout); + osmo_timer_del(&sccp->sccp_cc_timeout); talloc_free(sccp); return 0; } diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index 3112ff3..ffcd388 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -66,7 +66,7 @@ static const char *config_file = "bsc-nat.cfg"; static struct in_addr local_addr; static struct bsc_fd bsc_listen; static const char *msc_ip = NULL; -static struct timer_list sccp_close; +static struct osmo_timer_list sccp_close; static int daemonize = 0; const char *openbsc_copyright = @@ -153,10 +153,10 @@ static void bsc_ping_timeout(void *_bsc) send_ping(bsc); /* send another ping in 20 seconds */ - bsc_schedule_timer(&bsc->ping_timeout, bsc->nat->ping_timeout, 0); + osmo_timer_schedule(&bsc->ping_timeout, bsc->nat->ping_timeout, 0); /* also start a pong timer */ - bsc_schedule_timer(&bsc->pong_timeout, bsc->nat->pong_timeout, 0); + osmo_timer_schedule(&bsc->pong_timeout, bsc->nat->pong_timeout, 0); } static void start_ping_pong(struct bsc_connection *bsc) @@ -848,9 +848,9 @@ void bsc_close_connection(struct bsc_connection *connection) struct rate_ctr *ctr = NULL; /* stop the timeout timer */ - bsc_del_timer(&connection->id_timeout); - bsc_del_timer(&connection->ping_timeout); - bsc_del_timer(&connection->pong_timeout); + osmo_timer_del(&connection->id_timeout); + osmo_timer_del(&connection->ping_timeout); + osmo_timer_del(&connection->pong_timeout); if (connection->cfg) ctr = &connection->cfg->stats.ctrg->ctr[BCFG_CTR_DROPPED_SCCP]; @@ -930,7 +930,7 @@ static void ipaccess_auth_bsc(struct tlv_parsed *tvp, struct bsc_connection *bsc rate_ctr_inc(&conf->stats.ctrg->ctr[BCFG_CTR_NET_RECONN]); bsc->authenticated = 1; bsc->cfg = conf; - bsc_del_timer(&bsc->id_timeout); + osmo_timer_del(&bsc->id_timeout); LOGP(DNAT, LOGL_NOTICE, "Authenticated bsc nr: %d on fd %d\n", conf->nr, bsc->write_queue.bfd.fd); start_ping_pong(bsc); @@ -1177,7 +1177,7 @@ static int ipaccess_bsc_read_cb(struct bsc_fd *bfd) /* stop the pong timeout */ if (hh->proto == IPAC_PROTO_IPACCESS) { if (msg->l2h[0] == IPAC_MSGT_PONG) { - bsc_del_timer(&bsc->pong_timeout); + osmo_timer_del(&bsc->pong_timeout); msgb_free(msg); return 0; } else if (msg->l2h[0] == IPAC_MSGT_PING) { @@ -1275,7 +1275,7 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what) */ bsc->id_timeout.data = bsc; bsc->id_timeout.cb = ipaccess_close_bsc; - bsc_schedule_timer(&bsc->id_timeout, nat->auth_timeout, 0); + osmo_timer_schedule(&bsc->id_timeout, nat->auth_timeout, 0); return 0; } @@ -1391,7 +1391,7 @@ static void sccp_close_unconfirmed(void *_data) bsc_maybe_close(bsc); out: - bsc_schedule_timer(&sccp_close, SCCP_CLOSE_TIME, 0); + osmo_timer_schedule(&sccp_close, SCCP_CLOSE_TIME, 0); } extern void *tall_msgb_ctx; @@ -1511,7 +1511,7 @@ int main(int argc, char **argv) sccp_set_log_area(DSCCP); sccp_close.cb = sccp_close_unconfirmed; sccp_close.data = NULL; - bsc_schedule_timer(&sccp_close, SCCP_CLOSE_TIME, 0); + osmo_timer_schedule(&sccp_close, SCCP_CLOSE_TIME, 0); while (1) { bsc_select_main(0); diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c index 0392e9b..5d599c7 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c +++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c @@ -59,7 +59,7 @@ static void bsc_nat_ussd_destroy(struct bsc_nat_ussd_con *con) close(con->queue.bfd.fd); bsc_unregister_fd(&con->queue.bfd); - bsc_del_timer(&con->auth_timeout); + osmo_timer_del(&con->auth_timeout); write_queue_clear(&con->queue); talloc_free(con); } @@ -168,7 +168,7 @@ static void ussd_auth_con(struct tlv_parsed *tvp, struct bsc_nat_ussd_con *conn) bsc_nat_ussd_destroy(conn->nat->ussd_con); LOGP(DNAT, LOGL_ERROR, "USSD token specified. USSD provider is connected.\n"); - bsc_del_timer(&conn->auth_timeout); + osmo_timer_del(&conn->auth_timeout); conn->authorized = 1; conn->nat->ussd_con = conn; } @@ -179,7 +179,7 @@ static void ussd_start_auth(struct bsc_nat_ussd_con *conn) conn->auth_timeout.data = conn; conn->auth_timeout.cb = ussd_auth_cb; - bsc_schedule_timer(&conn->auth_timeout, conn->nat->auth_timeout, 0); + osmo_timer_schedule(&conn->auth_timeout, conn->nat->auth_timeout, 0); msg = msgb_alloc_headroom(4096, 128, "auth message"); if (!msg) { diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index 739253b..8fec368 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -53,7 +53,7 @@ static int use_mncc_sock = 0; /* timer to store statistics */ #define DB_SYNC_INTERVAL 60, 0 -static struct timer_list db_sync_timer; +static struct osmo_timer_list db_sync_timer; extern int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *), const char *cfg_file); @@ -204,7 +204,7 @@ static void db_sync_timer_cb(void *data) { /* store counters to database and re-schedule */ counters_for_each(_db_store_counter, NULL); - bsc_schedule_timer(&db_sync_timer, DB_SYNC_INTERVAL); + osmo_timer_schedule(&db_sync_timer, DB_SYNC_INTERVAL); } extern int bts_model_unknown_init(void); @@ -285,7 +285,7 @@ int main(int argc, char **argv) /* setup the timer */ db_sync_timer.cb = db_sync_timer_cb; db_sync_timer.data = NULL; - bsc_schedule_timer(&db_sync_timer, DB_SYNC_INTERVAL); + osmo_timer_schedule(&db_sync_timer, DB_SYNC_INTERVAL); signal(SIGINT, &signal_handler); signal(SIGABRT, &signal_handler); diff --git a/openbsc/src/utils/bs11_config.c b/openbsc/src/utils/bs11_config.c index 9a61f4c..8e987de 100644 --- a/openbsc/src/utils/bs11_config.c +++ b/openbsc/src/utils/bs11_config.c @@ -50,7 +50,7 @@ enum bs11cfg_state { }; static enum bs11cfg_state bs11cfg_state = STATE_NONE; static char *command, *value; -struct timer_list status_timer; +struct osmo_timer_list status_timer; static const uint8_t obj_li_attr[] = { NM_ATT_BS11_BIT_ERR_THESH, 0x09, 0x00, @@ -731,7 +731,7 @@ int handle_serial_msg(struct msgb *rx_msg) abis_nm_bs11_factory_logon(g_bts, 1); break; case STATE_LOGON_ACK: - bsc_schedule_timer(&status_timer, 5, 0); + osmo_timer_schedule(&status_timer, 5, 0); break; default: break; -- 1.7.2.3 From pablo at gnumonks.org Fri May 6 10:31:25 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Fri, 6 May 2011 12:31:25 +0200 Subject: [PATCH 2/5] src: use namespace prefix osmo_fd* and osmo_select* In-Reply-To: <1304677888-23639-1-git-send-email-pablo@gnumonks.org> References: <1304677888-23639-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304677888-23639-3-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/struct bsc_fd/struct osmo_fd/g s/bsc_register_fd/osmo_fd_register/g s/bsc_unregister_fd/osmo_fd_unregister/g s/bsc_select_main/osmo_select_main/g --- openbsc/doc/e1-data-model.txt | 2 +- openbsc/include/openbsc/bsc_nat.h | 4 +- openbsc/include/openbsc/e1_input.h | 6 +- openbsc/include/openbsc/gprs_ns.h | 4 +- openbsc/include/openbsc/ipaccess.h | 4 +- openbsc/include/openbsc/mgcp_internal.h | 4 +- openbsc/include/openbsc/osmo_bsc_rf.h | 2 +- openbsc/include/openbsc/rtp_proxy.h | 2 +- openbsc/include/openbsc/sgsn.h | 6 +- openbsc/include/openbsc/socket.h | 4 +- openbsc/src/gprs/gb_proxy_main.c | 2 +- openbsc/src/gprs/sgsn_libgtp.c | 8 ++-- openbsc/src/gprs/sgsn_main.c | 2 +- openbsc/src/ipaccess/ipaccess-config.c | 2 +- openbsc/src/ipaccess/ipaccess-find.c | 10 ++-- openbsc/src/ipaccess/ipaccess-proxy.c | 64 ++++++++++++++-------------- openbsc/src/libabis/input/dahdi.c | 16 ++++---- openbsc/src/libabis/input/hsl.c | 22 +++++----- openbsc/src/libabis/input/ipaccess.c | 56 +++++++++++++------------- openbsc/src/libabis/input/misdn.c | 16 ++++---- openbsc/src/libbsc/bsc_msc.c | 14 +++--- openbsc/src/libcommon/socket.c | 6 +- openbsc/src/libgb/gprs_ns.c | 8 ++-- openbsc/src/libgb/gprs_ns_frgre.c | 10 ++-- openbsc/src/libmgcp/mgcp_network.c | 24 +++++----- openbsc/src/libmsc/mncc_sock.c | 28 ++++++------ openbsc/src/libtrau/rtp_proxy.c | 14 +++--- openbsc/src/osmo-bsc/osmo_bsc_main.c | 2 +- openbsc/src/osmo-bsc/osmo_bsc_msc.c | 10 ++-- openbsc/src/osmo-bsc/osmo_bsc_rf.c | 14 +++--- openbsc/src/osmo-bsc_mgcp/mgcp_main.c | 6 +- openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c | 6 +- openbsc/src/osmo-bsc_nat/bsc_nat.c | 16 ++++---- openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 2 +- openbsc/src/osmo-bsc_nat/bsc_ussd.c | 8 ++-- openbsc/src/osmo-nitb/bsc_hack.c | 2 +- openbsc/src/utils/bs11_config.c | 2 +- openbsc/src/utils/rs232.c | 12 +++--- openbsc/tests/channel/channel_test.c | 2 +- 39 files changed, 211 insertions(+), 211 deletions(-) diff --git a/openbsc/doc/e1-data-model.txt b/openbsc/doc/e1-data-model.txt index 9286d5f..509004f 100644 --- a/openbsc/doc/e1-data-model.txt +++ b/openbsc/doc/e1-data-model.txt @@ -140,7 +140,7 @@ struct e1inp_ts { union { struct { /* mISDN driver has one fd for each ts */ - struct bsc_fd; + struct osmo_fd; } misdn; } driver; }; diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 7d8c37e..73911bc 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -275,7 +275,7 @@ struct bsc_nat { regex_t ussd_query_re; char *ussd_token; char *ussd_local; - struct bsc_fd ussd_listen; + struct osmo_fd ussd_listen; struct bsc_nat_ussd_con *ussd_con; /* for maintainenance */ @@ -363,7 +363,7 @@ uint32_t bsc_mgcp_extract_ci(const char *resp); int bsc_write(struct bsc_connection *bsc, struct msgb *msg, int id); int bsc_do_write(struct write_queue *queue, struct msgb *msg, int id); int bsc_write_msg(struct write_queue *queue, struct msgb *msg); -int bsc_write_cb(struct bsc_fd *bfd, struct msgb *msg); +int bsc_write_cb(struct osmo_fd *bfd, struct msgb *msg); /* IMSI allow/deny handling */ int bsc_parse_reg(void *ctx, regex_t *reg, char **imsi, int argc, const char **argv) __attribute__ ((warn_unused_result)); diff --git a/openbsc/include/openbsc/e1_input.h b/openbsc/include/openbsc/e1_input.h index cd8abca..0eae5d9 100644 --- a/openbsc/include/openbsc/e1_input.h +++ b/openbsc/include/openbsc/e1_input.h @@ -81,15 +81,15 @@ struct e1inp_ts { union { struct { /* mISDN driver has one fd for each ts */ - struct bsc_fd fd; + struct osmo_fd fd; } misdn; struct { /* ip.access driver has one fd for each ts */ - struct bsc_fd fd; + struct osmo_fd fd; } ipaccess; struct { /* DAHDI driver has one fd for each ts */ - struct bsc_fd fd; + struct osmo_fd fd; struct lapd_instance *lapd; } dahdi; } driver; diff --git a/openbsc/include/openbsc/gprs_ns.h b/openbsc/include/openbsc/gprs_ns.h index f497e23..8f28d46 100644 --- a/openbsc/include/openbsc/gprs_ns.h +++ b/openbsc/include/openbsc/gprs_ns.h @@ -133,13 +133,13 @@ struct gprs_ns_inst { /* NS-over-IP specific bits */ struct { - struct bsc_fd fd; + struct osmo_fd fd; uint32_t local_ip; uint16_t local_port; } nsip; /* NS-over-FR-over-GRE-over-IP specific bits */ struct { - struct bsc_fd fd; + struct osmo_fd fd; uint32_t local_ip; int enabled:1; } frgre; diff --git a/openbsc/include/openbsc/ipaccess.h b/openbsc/include/openbsc/ipaccess.h index 388ad64..8d30327 100644 --- a/openbsc/include/openbsc/ipaccess.h +++ b/openbsc/include/openbsc/ipaccess.h @@ -85,8 +85,8 @@ int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa); /* * methods for parsing and sending a message */ -int ipaccess_rcvmsg_base(struct msgb *msg, struct bsc_fd *bfd); -struct msgb *ipaccess_read_msg(struct bsc_fd *bfd, int *error); +int ipaccess_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd); +struct msgb *ipaccess_read_msg(struct osmo_fd *bfd, int *error); void ipaccess_prepend_header(struct msgb *msg, int proto); void ipaccess_prepend_header_ext(struct msgb *msg, int proto); int ipaccess_send_pong(int fd); diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h index 0214318..a9d5149 100644 --- a/openbsc/include/openbsc/mgcp_internal.h +++ b/openbsc/include/openbsc/mgcp_internal.h @@ -66,8 +66,8 @@ struct mgcp_rtp_end { /* * Each end has a socket... */ - struct bsc_fd rtp; - struct bsc_fd rtcp; + struct osmo_fd rtp; + struct osmo_fd rtcp; int local_port; int local_alloc; diff --git a/openbsc/include/openbsc/osmo_bsc_rf.h b/openbsc/include/openbsc/osmo_bsc_rf.h index f1ff9ba..dbbb3db 100644 --- a/openbsc/include/openbsc/osmo_bsc_rf.h +++ b/openbsc/include/openbsc/osmo_bsc_rf.h @@ -9,7 +9,7 @@ struct gsm_network; struct osmo_bsc_rf { /* the value of signal.h */ int policy; - struct bsc_fd listen; + struct osmo_fd listen; struct gsm_network *gsm_network; const char *last_state_command; diff --git a/openbsc/include/openbsc/rtp_proxy.h b/openbsc/include/openbsc/rtp_proxy.h index 8ad3636..3b208c3 100644 --- a/openbsc/include/openbsc/rtp_proxy.h +++ b/openbsc/include/openbsc/rtp_proxy.h @@ -48,7 +48,7 @@ struct rtp_sub_socket { struct sockaddr_in sin_local; struct sockaddr_in sin_remote; - struct bsc_fd bfd; + struct osmo_fd bfd; /* linked list of to-be-transmitted msgb's */ struct llist_head tx_queue; }; diff --git a/openbsc/include/openbsc/sgsn.h b/openbsc/include/openbsc/sgsn.h index 00e1ec3..7456614 100644 --- a/openbsc/include/openbsc/sgsn.h +++ b/openbsc/include/openbsc/sgsn.h @@ -21,9 +21,9 @@ struct sgsn_instance { char *config_file; struct sgsn_config cfg; /* File descriptor wrappers for LibGTP */ - struct bsc_fd gtp_fd0; - struct bsc_fd gtp_fd1c; - struct bsc_fd gtp_fd1u; + struct osmo_fd gtp_fd0; + struct osmo_fd gtp_fd1c; + struct osmo_fd gtp_fd1u; /* Timer for libGTP */ struct osmo_timer_list gtp_timer; /* GSN instance for libgtp */ diff --git a/openbsc/include/openbsc/socket.h b/openbsc/include/openbsc/socket.h index 87ef37f..0fd85f1 100644 --- a/openbsc/include/openbsc/socket.h +++ b/openbsc/include/openbsc/socket.h @@ -7,8 +7,8 @@ #define IPPROTO_GRE 47 #endif -int make_sock(struct bsc_fd *bfd, int proto, +int make_sock(struct osmo_fd *bfd, int proto, uint32_t ip, uint16_t port, int priv_nr, - int (*cb)(struct bsc_fd *fd, unsigned int what), void *data); + int (*cb)(struct osmo_fd *fd, unsigned int what), void *data); #endif /* _BSC_SOCKET_H */ diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c index 4f6944f..b0fb664 100644 --- a/openbsc/src/gprs/gb_proxy_main.c +++ b/openbsc/src/gprs/gb_proxy_main.c @@ -279,7 +279,7 @@ int main(int argc, char **argv) gbprox_reset_persistent_nsvcs(bssgp_nsi); while (1) { - rc = bsc_select_main(0); + rc = osmo_select_main(0); if (rc < 0) exit(3); } diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c index 7e66035..f193aa3 100644 --- a/openbsc/src/gprs/sgsn_libgtp.c +++ b/openbsc/src/gprs/sgsn_libgtp.c @@ -505,7 +505,7 @@ int sgsn_rx_sndcp_ud_ind(struct gprs_ra_id *ra_id, int32_t tlli, uint8_t nsapi, } /* libgtp select loop integration */ -static int sgsn_gtp_fd_cb(struct bsc_fd *fd, unsigned int what) +static int sgsn_gtp_fd_cb(struct osmo_fd *fd, unsigned int what) { struct sgsn_instance *sgi = fd->data; int rc; @@ -570,7 +570,7 @@ int sgsn_gtp_init(struct sgsn_instance *sgi) sgi->gtp_fd0.data = sgi; sgi->gtp_fd0.when = BSC_FD_READ; sgi->gtp_fd0.cb = sgsn_gtp_fd_cb; - rc = bsc_register_fd(&sgi->gtp_fd0); + rc = osmo_fd_register(&sgi->gtp_fd0); if (rc < 0) return rc; @@ -579,7 +579,7 @@ int sgsn_gtp_init(struct sgsn_instance *sgi) sgi->gtp_fd1c.data = sgi; sgi->gtp_fd1c.when = BSC_FD_READ; sgi->gtp_fd1c.cb = sgsn_gtp_fd_cb; - bsc_register_fd(&sgi->gtp_fd1c); + osmo_fd_register(&sgi->gtp_fd1c); if (rc < 0) return rc; @@ -588,7 +588,7 @@ int sgsn_gtp_init(struct sgsn_instance *sgi) sgi->gtp_fd1u.data = sgi; sgi->gtp_fd1u.when = BSC_FD_READ; sgi->gtp_fd1u.cb = sgsn_gtp_fd_cb; - bsc_register_fd(&sgi->gtp_fd1u); + osmo_fd_register(&sgi->gtp_fd1u); if (rc < 0) return rc; diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c index f6a645f..6876939 100644 --- a/openbsc/src/gprs/sgsn_main.c +++ b/openbsc/src/gprs/sgsn_main.c @@ -279,7 +279,7 @@ int main(int argc, char **argv) } while (1) { - rc = bsc_select_main(0); + rc = osmo_select_main(0); if (rc < 0) exit(3); } diff --git a/openbsc/src/ipaccess/ipaccess-config.c b/openbsc/src/ipaccess/ipaccess-config.c index aa38d10..5cd901c 100644 --- a/openbsc/src/ipaccess/ipaccess-config.c +++ b/openbsc/src/ipaccess/ipaccess-config.c @@ -927,7 +927,7 @@ int main(int argc, char **argv) bts->oml_link->ts->sign.delay = 10; bts->c0->rsl_link->ts->sign.delay = 10; while (1) { - rc = bsc_select_main(0); + rc = osmo_select_main(0); if (rc < 0) exit(3); } diff --git a/openbsc/src/ipaccess/ipaccess-find.c b/openbsc/src/ipaccess/ipaccess-find.c index 24f602e..b0db045 100644 --- a/openbsc/src/ipaccess/ipaccess-find.c +++ b/openbsc/src/ipaccess/ipaccess-find.c @@ -141,7 +141,7 @@ static int read_response(int fd) return parse_response(buf+6, len-6); } -static int bfd_cb(struct bsc_fd *bfd, unsigned int flags) +static int bfd_cb(struct osmo_fd *bfd, unsigned int flags) { if (flags & BSC_FD_READ) return read_response(bfd->fd); @@ -156,7 +156,7 @@ static struct osmo_timer_list timer; static void timer_cb(void *_data) { - struct bsc_fd *bfd = _data; + struct osmo_fd *bfd = _data; bfd->when |= BSC_FD_WRITE; @@ -165,7 +165,7 @@ static void timer_cb(void *_data) int main(int argc, char **argv) { - struct bsc_fd bfd; + struct osmo_fd bfd; char *ifname; int rc; @@ -187,7 +187,7 @@ int main(int argc, char **argv) exit(1); } - bsc_register_fd(&bfd); + osmo_fd_register(&bfd); timer.cb = timer_cb; timer.data = &bfd; @@ -197,7 +197,7 @@ int main(int argc, char **argv) printf("Trying to find ip.access BTS by broadcast UDP...\n"); while (1) { - rc = bsc_select_main(0); + rc = osmo_select_main(0); if (rc < 0) exit(3); } diff --git a/openbsc/src/ipaccess/ipaccess-proxy.c b/openbsc/src/ipaccess/ipaccess-proxy.c index f40590a..2717ba1 100644 --- a/openbsc/src/ipaccess/ipaccess-proxy.c +++ b/openbsc/src/ipaccess/ipaccess-proxy.c @@ -51,9 +51,9 @@ static struct log_target *stderr_target; /* one instance of an ip.access protocol proxy */ struct ipa_proxy { /* socket where we listen for incoming OML from BTS */ - struct bsc_fd oml_listen_fd; + struct osmo_fd oml_listen_fd; /* socket where we listen for incoming RSL from BTS */ - struct bsc_fd rsl_listen_fd; + struct osmo_fd rsl_listen_fd; /* list of BTS's (struct ipa_bts_conn */ struct llist_head bts_list; /* the BSC reconnect timer */ @@ -67,7 +67,7 @@ struct ipa_proxy { static struct ipa_proxy *ipp; struct ipa_proxy_conn { - struct bsc_fd fd; + struct osmo_fd fd; struct llist_head tx_queue; struct ipa_bts_conn *bts_conn; }; @@ -94,12 +94,12 @@ struct ipa_bts_conn { struct ipa_proxy_conn *bsc_rsl_conn[MAX_TRX]; /* UDP sockets for BTS and BSC injection */ - struct bsc_fd udp_bts_fd; - struct bsc_fd udp_bsc_fd; + struct osmo_fd udp_bts_fd; + struct osmo_fd udp_bsc_fd; /* NS data */ struct in_addr bts_addr; - struct bsc_fd gprs_ns_fd; + struct osmo_fd gprs_ns_fd; int gprs_local_port; uint16_t gprs_orig_port; uint32_t gprs_orig_ip; @@ -125,7 +125,7 @@ static char *listen_ipaddr; static char *bsc_ipaddr; static char *gprs_ns_ipaddr; -static int gprs_ns_cb(struct bsc_fd *bfd, unsigned int what); +static int gprs_ns_cb(struct osmo_fd *bfd, unsigned int what); #define PROXY_ALLOC_SIZE 1200 @@ -197,7 +197,7 @@ static void _logp_ipbc_uid(unsigned int ss, unsigned int lvl, char *file, int li logp2(ss, lvl, file, line, 0, "unknown "); } -static int handle_udp_read(struct bsc_fd *bfd) +static int handle_udp_read(struct osmo_fd *bfd) { struct ipa_bts_conn *ipbc = bfd->data; struct ipa_proxy_conn *other_conn = NULL; @@ -217,7 +217,7 @@ static int handle_udp_read(struct bsc_fd *bfd) } if (ret == 0) { DEBUGP(DINP, "UDP peer disappeared, dead socket\n"); - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); close(bfd->fd); bfd->fd = -1; msgb_free(msg); @@ -288,7 +288,7 @@ static int handle_udp_read(struct bsc_fd *bfd) return 0; } -static int handle_udp_write(struct bsc_fd *bfd) +static int handle_udp_write(struct osmo_fd *bfd) { /* not implemented yet */ bfd->when &= ~BSC_FD_WRITE; @@ -297,7 +297,7 @@ static int handle_udp_write(struct bsc_fd *bfd) } /* callback from select.c in case one of the fd's can be read/written */ -static int udp_fd_cb(struct bsc_fd *bfd, unsigned int what) +static int udp_fd_cb(struct osmo_fd *bfd, unsigned int what) { int rc = 0; @@ -310,7 +310,7 @@ static int udp_fd_cb(struct bsc_fd *bfd, unsigned int what) } -static int ipbc_alloc_connect(struct ipa_proxy_conn *ipc, struct bsc_fd *bfd, +static int ipbc_alloc_connect(struct ipa_proxy_conn *ipc, struct osmo_fd *bfd, uint16_t site_id, uint16_t bts_id, uint16_t trx_id, struct tlv_parsed *tlvp, struct msgb *msg) @@ -414,9 +414,9 @@ static int ipbc_alloc_connect(struct ipa_proxy_conn *ipc, struct bsc_fd *bfd, return 0; err_udp_bsc: - bsc_unregister_fd(&ipbc->udp_bts_fd); + osmo_fd_unregister(&ipbc->udp_bts_fd); err_udp_bts: - bsc_unregister_fd(&ipbc->bsc_oml_conn->fd); + osmo_fd_unregister(&ipbc->bsc_oml_conn->fd); close(ipbc->bsc_oml_conn->fd.fd); talloc_free(ipbc->bsc_oml_conn); ipbc->bsc_oml_conn = NULL; @@ -424,7 +424,7 @@ err_bsc_conn: talloc_free(ipbc->id_resp); talloc_free(ipbc); #if 0 - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); close(bfd->fd); talloc_free(bfd); #endif @@ -433,7 +433,7 @@ err_out: } static int ipaccess_rcvmsg(struct ipa_proxy_conn *ipc, struct msgb *msg, - struct bsc_fd *bfd) + struct osmo_fd *bfd) { struct tlv_parsed tlvp; uint8_t msg_type = *(msg->l2h); @@ -536,7 +536,7 @@ static int ipaccess_rcvmsg(struct ipa_proxy_conn *ipc, struct msgb *msg, return 0; } -struct msgb *ipaccess_proxy_read_msg(struct bsc_fd *bfd, int *error) +struct msgb *ipaccess_proxy_read_msg(struct osmo_fd *bfd, int *error) { struct msgb *msg = msgb_alloc(PROXY_ALLOC_SIZE, "Abis/IP"); struct ipaccess_head *hh; @@ -660,7 +660,7 @@ reschedule: osmo_timer_schedule(&ipp->reconn_timer, 5, 0); } -static void handle_dead_socket(struct bsc_fd *bfd) +static void handle_dead_socket(struct osmo_fd *bfd) { struct ipa_proxy_conn *ipc = bfd->data; /* local conn */ struct ipa_proxy_conn *bsc_conn; /* remote conn */ @@ -668,7 +668,7 @@ static void handle_dead_socket(struct bsc_fd *bfd) unsigned int trx_id = bfd->priv_nr >> 8; struct msgb *msg, *msg2; - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); close(bfd->fd); bfd->fd = -1; @@ -686,7 +686,7 @@ static void handle_dead_socket(struct bsc_fd *bfd) ipbc->oml_conn = NULL; bsc_conn = ipbc->bsc_oml_conn; /* close the connection to the BSC */ - bsc_unregister_fd(&bsc_conn->fd); + osmo_fd_unregister(&bsc_conn->fd); close(bsc_conn->fd.fd); llist_for_each_entry_safe(msg, msg2, &bsc_conn->tx_queue, list) msgb_free(msg); @@ -698,7 +698,7 @@ static void handle_dead_socket(struct bsc_fd *bfd) ipbc->rsl_conn[trx_id] = NULL; bsc_conn = ipbc->bsc_rsl_conn[trx_id]; /* close the connection to the BSC */ - bsc_unregister_fd(&bsc_conn->fd); + osmo_fd_unregister(&bsc_conn->fd); close(bsc_conn->fd.fd); llist_for_each_entry_safe(msg, msg2, &bsc_conn->tx_queue, list) msgb_free(msg); @@ -761,7 +761,7 @@ static void patch_gprs_msg(struct ipa_bts_conn *ipbc, int priv_nr, struct msgb * } } -static int handle_tcp_read(struct bsc_fd *bfd) +static int handle_tcp_read(struct osmo_fd *bfd) { struct ipa_proxy_conn *ipc = bfd->data; struct ipa_bts_conn *ipbc = ipc->bts_conn; @@ -795,7 +795,7 @@ static int handle_tcp_read(struct bsc_fd *bfd) if (hh->proto == IPAC_PROTO_IPACCESS) { ret = ipaccess_rcvmsg(ipc, msg, bfd); if (ret < 0) { - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); close(bfd->fd); bfd->fd = -1; talloc_free(bfd); @@ -835,7 +835,7 @@ static int handle_tcp_read(struct bsc_fd *bfd) } /* a TCP socket is ready to be written to */ -static int handle_tcp_write(struct bsc_fd *bfd) +static int handle_tcp_write(struct osmo_fd *bfd) { struct ipa_proxy_conn *ipc = bfd->data; struct ipa_bts_conn *ipbc = ipc->bts_conn; @@ -876,7 +876,7 @@ static int handle_tcp_write(struct bsc_fd *bfd) } /* callback from select.c in case one of the fd's can be read/written */ -static int ipaccess_fd_cb(struct bsc_fd *bfd, unsigned int what) +static int ipaccess_fd_cb(struct osmo_fd *bfd, unsigned int what) { int rc = 0; @@ -892,11 +892,11 @@ static int ipaccess_fd_cb(struct bsc_fd *bfd, unsigned int what) } /* callback of the listening filedescriptor */ -static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what) +static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what) { int ret; struct ipa_proxy_conn *ipc; - struct bsc_fd *bfd; + struct osmo_fd *bfd; struct sockaddr_in sa; socklen_t sa_len = sizeof(sa); @@ -924,7 +924,7 @@ static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what) bfd->priv_nr = listen_bfd->priv_nr; bfd->cb = ipaccess_fd_cb; bfd->when = BSC_FD_READ; - ret = bsc_register_fd(bfd); + ret = osmo_fd_register(bfd); if (ret < 0) { LOGP(DINP, LOGL_ERROR, "could not register FD\n"); close(bfd->fd); @@ -955,7 +955,7 @@ static void send_ns(int fd, const char *buf, int size, struct in_addr ip, int po } } -static int gprs_ns_cb(struct bsc_fd *bfd, unsigned int what) +static int gprs_ns_cb(struct osmo_fd *bfd, unsigned int what) { struct ipa_bts_conn *bts; char buf[4096]; @@ -990,7 +990,7 @@ static int gprs_ns_cb(struct bsc_fd *bfd, unsigned int what) static struct ipa_proxy_conn *connect_bsc(struct sockaddr_in *sa, int priv_nr, void *data) { struct ipa_proxy_conn *ipc; - struct bsc_fd *bfd; + struct osmo_fd *bfd; int ret, on = 1; ipc = alloc_conn(); @@ -1018,7 +1018,7 @@ static struct ipa_proxy_conn *connect_bsc(struct sockaddr_in *sa, int priv_nr, v } /* pre-fill tx_queue with identity request */ - ret = bsc_register_fd(bfd); + ret = osmo_fd_register(bfd); if (ret < 0) { close(bfd->fd); talloc_free(ipc); @@ -1200,6 +1200,6 @@ int main(int argc, char **argv) signal(SIGABRT, &signal_handler); while (1) { - bsc_select_main(0); + osmo_select_main(0); } } diff --git a/openbsc/src/libabis/input/dahdi.c b/openbsc/src/libabis/input/dahdi.c index 4fcd64f..e02e141 100644 --- a/openbsc/src/libabis/input/dahdi.c +++ b/openbsc/src/libabis/input/dahdi.c @@ -92,7 +92,7 @@ static void handle_dahdi_exception(struct e1inp_ts *ts) } } -static int handle_ts1_read(struct bsc_fd *bfd) +static int handle_ts1_read(struct osmo_fd *bfd) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -184,7 +184,7 @@ static void timeout_ts1_write(void *data) static void dahdi_write_msg(uint8_t *data, int len, void *cbdata) { - struct bsc_fd *bfd = cbdata; + struct osmo_fd *bfd = cbdata; struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1]; @@ -197,7 +197,7 @@ static void dahdi_write_msg(uint8_t *data, int len, void *cbdata) LOGP(DMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret); } -static int handle_ts1_write(struct bsc_fd *bfd) +static int handle_ts1_write(struct osmo_fd *bfd) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -259,7 +259,7 @@ static uint8_t * flip_buf_bits ( uint8_t * buf , int len) #define D_BCHAN_TX_GRAN 160 /* write to a B channel TS */ -static int handle_tsX_write(struct bsc_fd *bfd) +static int handle_tsX_write(struct osmo_fd *bfd) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -293,7 +293,7 @@ static int handle_tsX_write(struct bsc_fd *bfd) #define D_TSX_ALLOC_SIZE (D_BCHAN_TX_GRAN) /* FIXME: read from a B channel TS */ -static int handle_tsX_read(struct bsc_fd *bfd) +static int handle_tsX_read(struct osmo_fd *bfd) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -329,7 +329,7 @@ static int handle_tsX_read(struct bsc_fd *bfd) } /* callback from select.c in case one of the fd's can be read/written */ -static int dahdi_fd_cb(struct bsc_fd *bfd, unsigned int what) +static int dahdi_fd_cb(struct osmo_fd *bfd, unsigned int what) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -420,7 +420,7 @@ static int dahdi_e1_setup(struct e1inp_line *line) unsigned int idx = ts-1; char openstr[128]; struct e1inp_ts *e1i_ts = &line->ts[idx]; - struct bsc_fd *bfd = &e1i_ts->driver.dahdi.fd; + struct osmo_fd *bfd = &e1i_ts->driver.dahdi.fd; bfd->data = line; bfd->priv_nr = ts; @@ -463,7 +463,7 @@ static int dahdi_e1_setup(struct e1inp_line *line) return bfd->fd; } - ret = bsc_register_fd(bfd); + ret = osmo_fd_register(bfd); if (ret < 0) { fprintf(stderr, "could not register FD: %s\n", strerror(ret)); diff --git a/openbsc/src/libabis/input/hsl.c b/openbsc/src/libabis/input/hsl.c index 9ff8552..af95afa 100644 --- a/openbsc/src/libabis/input/hsl.c +++ b/openbsc/src/libabis/input/hsl.c @@ -64,7 +64,7 @@ /* data structure for one E1 interface with A-bis */ struct hsl_e1_handle { - struct bsc_fd listen_fd; + struct osmo_fd listen_fd; struct gsm_network *gsmnet; }; @@ -81,7 +81,7 @@ int hsl_drop_oml(struct gsm_bts *bts) struct gsm_bts_trx *trx; struct e1inp_ts *ts; struct e1inp_line *line; - struct bsc_fd *bfd; + struct osmo_fd *bfd; if (!bts || !bts->oml_link) return -1; @@ -92,7 +92,7 @@ int hsl_drop_oml(struct gsm_bts *bts) e1inp_event(ts, S_INP_TEI_DN, bts->oml_link->tei, bts->oml_link->sapi); bfd = &ts->driver.ipaccess.fd; - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); close(bfd->fd); bfd->fd = -1; @@ -109,7 +109,7 @@ int hsl_drop_oml(struct gsm_bts *bts) return -1; } -static int hsl_drop_ts_fd(struct e1inp_ts *ts, struct bsc_fd *bfd) +static int hsl_drop_ts_fd(struct e1inp_ts *ts, struct osmo_fd *bfd) { struct e1inp_sign_link *link, *link2; int bts_nr = -1; @@ -119,7 +119,7 @@ static int hsl_drop_ts_fd(struct e1inp_ts *ts, struct bsc_fd *bfd) e1inp_sign_link_destroy(link); } - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); close(bfd->fd); bfd->fd = -1; @@ -195,7 +195,7 @@ static int process_hsl_rsl(struct msgb *msg, struct e1inp_line *line) return 0; } -static int handle_ts1_read(struct bsc_fd *bfd) +static int handle_ts1_read(struct osmo_fd *bfd) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -290,7 +290,7 @@ static void timeout_ts1_write(void *data) ts_want_write(e1i_ts); } -static int handle_ts1_write(struct bsc_fd *bfd) +static int handle_ts1_write(struct osmo_fd *bfd) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -346,7 +346,7 @@ static int handle_ts1_write(struct bsc_fd *bfd) } /* callback from select.c in case one of the fd's can be read/written */ -static int hsl_fd_cb(struct bsc_fd *bfd, unsigned int what) +static int hsl_fd_cb(struct osmo_fd *bfd, unsigned int what) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -377,14 +377,14 @@ struct e1inp_driver hsl_driver = { }; /* callback of the OML listening filedescriptor */ -static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what) +static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what) { int ret; int idx = 0; int i; struct e1inp_line *line; struct e1inp_ts *e1i_ts; - struct bsc_fd *bfd; + struct osmo_fd *bfd; struct sockaddr_in sa; socklen_t sa_len = sizeof(sa); @@ -421,7 +421,7 @@ static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what) bfd->priv_nr = PRIV_OML; bfd->cb = hsl_fd_cb; bfd->when = BSC_FD_READ; - ret = bsc_register_fd(bfd); + ret = osmo_fd_register(bfd); if (ret < 0) { LOGP(DINP, LOGL_ERROR, "could not register FD\n"); close(bfd->fd); diff --git a/openbsc/src/libabis/input/ipaccess.c b/openbsc/src/libabis/input/ipaccess.c index 95e84f6..13294dc 100644 --- a/openbsc/src/libabis/input/ipaccess.c +++ b/openbsc/src/libabis/input/ipaccess.c @@ -51,8 +51,8 @@ /* data structure for one E1 interface with A-bis */ struct ia_e1_handle { - struct bsc_fd listen_fd; - struct bsc_fd rsl_listen_fd; + struct osmo_fd listen_fd; + struct osmo_fd rsl_listen_fd; struct gsm_network *gsmnet; }; @@ -222,7 +222,7 @@ int ipaccess_send_id_req(int fd) /* base handling of the ip.access protocol */ int ipaccess_rcvmsg_base(struct msgb *msg, - struct bsc_fd *bfd) + struct osmo_fd *bfd) { uint8_t msg_type = *(msg->l2h); int ret = 0; @@ -243,7 +243,7 @@ int ipaccess_rcvmsg_base(struct msgb *msg, } static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg, - struct bsc_fd *bfd) + struct osmo_fd *bfd) { struct tlv_parsed tlvp; uint8_t msg_type = *(msg->l2h); @@ -294,14 +294,14 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg, bts->oml_tei, 0); } else if (bfd->priv_nr == PRIV_RSL) { struct e1inp_ts *e1i_ts; - struct bsc_fd *newbfd; + struct osmo_fd *newbfd; struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, trx_id); /* drop any old rsl connection */ ipaccess_drop_rsl(trx); if (!bts->oml_link) { - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); close(bfd->fd); bfd->fd = -1; talloc_free(bfd); @@ -321,10 +321,10 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg, /* get rid of our old temporary bfd */ memcpy(newbfd, bfd, sizeof(*newbfd)); newbfd->priv_nr = PRIV_RSL + trx_id; - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); bfd->fd = -1; talloc_free(bfd); - bsc_register_fd(newbfd); + osmo_fd_register(newbfd); } break; } @@ -338,7 +338,7 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg, * read one ipa message from the socket * return NULL in case of error */ -struct msgb *ipaccess_read_msg(struct bsc_fd *bfd, int *error) +struct msgb *ipaccess_read_msg(struct osmo_fd *bfd, int *error) { struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE, "Abis/IP"); struct ipaccess_head *hh; @@ -394,7 +394,7 @@ int ipaccess_drop_oml(struct gsm_bts *bts) struct gsm_bts_trx *trx; struct e1inp_ts *ts; struct e1inp_line *line; - struct bsc_fd *bfd; + struct osmo_fd *bfd; if (!bts || !bts->oml_link) return -1; @@ -405,7 +405,7 @@ int ipaccess_drop_oml(struct gsm_bts *bts) e1inp_event(ts, S_INP_TEI_DN, bts->oml_link->tei, bts->oml_link->sapi); bfd = &ts->driver.ipaccess.fd; - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); close(bfd->fd); bfd->fd = -1; @@ -424,7 +424,7 @@ int ipaccess_drop_oml(struct gsm_bts *bts) return -1; } -static int ipaccess_drop(struct e1inp_ts *ts, struct bsc_fd *bfd) +static int ipaccess_drop(struct e1inp_ts *ts, struct osmo_fd *bfd) { struct e1inp_sign_link *link; int bts_nr; @@ -436,7 +436,7 @@ static int ipaccess_drop(struct e1inp_ts *ts, struct bsc_fd *bfd) * handling yet. So we can safely delete this bfd and * wait for a reconnect. */ - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); close(bfd->fd); bfd->fd = -1; talloc_free(bfd); @@ -455,7 +455,7 @@ static int ipaccess_drop(struct e1inp_ts *ts, struct bsc_fd *bfd) /* error case */ LOGP(DINP, LOGL_ERROR, "Failed to find a signalling link for ts: %p\n", ts); - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); close(bfd->fd); bfd->fd = -1; return -1; @@ -463,7 +463,7 @@ static int ipaccess_drop(struct e1inp_ts *ts, struct bsc_fd *bfd) int ipaccess_drop_rsl(struct gsm_bts_trx *trx) { - struct bsc_fd *bfd; + struct osmo_fd *bfd; struct e1inp_ts *ts; if (!trx || !trx->rsl_link) @@ -475,7 +475,7 @@ int ipaccess_drop_rsl(struct gsm_bts_trx *trx) /* close the socket */ bfd = &ts->driver.ipaccess.fd; - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); close(bfd->fd); bfd->fd = -1; @@ -486,7 +486,7 @@ int ipaccess_drop_rsl(struct gsm_bts_trx *trx) return -1; } -static int handle_ts1_read(struct bsc_fd *bfd) +static int handle_ts1_read(struct osmo_fd *bfd) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -588,7 +588,7 @@ static void timeout_ts1_write(void *data) ts_want_write(e1i_ts); } -static int handle_ts1_write(struct bsc_fd *bfd) +static int handle_ts1_write(struct osmo_fd *bfd) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -639,7 +639,7 @@ static int handle_ts1_write(struct bsc_fd *bfd) } /* callback from select.c in case one of the fd's can be read/written */ -static int ipaccess_fd_cb(struct bsc_fd *bfd, unsigned int what) +static int ipaccess_fd_cb(struct osmo_fd *bfd, unsigned int what) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -670,14 +670,14 @@ struct e1inp_driver ipaccess_driver = { }; /* callback of the OML listening filedescriptor */ -static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what) +static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what) { int ret; int idx = 0; int i; struct e1inp_line *line; struct e1inp_ts *e1i_ts; - struct bsc_fd *bfd; + struct osmo_fd *bfd; struct sockaddr_in sa; socklen_t sa_len = sizeof(sa); @@ -714,7 +714,7 @@ static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what) bfd->priv_nr = PRIV_OML; bfd->cb = ipaccess_fd_cb; bfd->when = BSC_FD_READ; - ret = bsc_register_fd(bfd); + ret = osmo_fd_register(bfd); if (ret < 0) { LOGP(DINP, LOGL_ERROR, "could not register FD\n"); close(bfd->fd); @@ -729,17 +729,17 @@ static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what) //return e1inp_line_register(line); } -static int rsl_listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what) +static int rsl_listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what) { struct sockaddr_in sa; socklen_t sa_len = sizeof(sa); - struct bsc_fd *bfd; + struct osmo_fd *bfd; int ret; if (!(what & BSC_FD_READ)) return 0; - bfd = talloc_zero(tall_bsc_ctx, struct bsc_fd); + bfd = talloc_zero(tall_bsc_ctx, struct osmo_fd); if (!bfd) return -ENOMEM; @@ -756,7 +756,7 @@ static int rsl_listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what) bfd->priv_nr = PRIV_RSL; bfd->cb = ipaccess_fd_cb; bfd->when = BSC_FD_READ; - ret = bsc_register_fd(bfd); + ret = osmo_fd_register(bfd); if (ret < 0) { LOGP(DINP, LOGL_ERROR, "could not register FD\n"); close(bfd->fd); @@ -773,7 +773,7 @@ static int rsl_listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what) int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa) { struct e1inp_ts *e1i_ts = &line->ts[0]; - struct bsc_fd *bfd = &e1i_ts->driver.ipaccess.fd; + struct osmo_fd *bfd = &e1i_ts->driver.ipaccess.fd; int ret, on = 1; bfd->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -796,7 +796,7 @@ int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa) return ret; } - ret = bsc_register_fd(bfd); + ret = osmo_fd_register(bfd); if (ret < 0) { close(bfd->fd); return ret; diff --git a/openbsc/src/libabis/input/misdn.c b/openbsc/src/libabis/input/misdn.c index 3c33792..d239ee7 100644 --- a/openbsc/src/libabis/input/misdn.c +++ b/openbsc/src/libabis/input/misdn.c @@ -85,7 +85,7 @@ const char *get_prim_name(unsigned int prim) return "UNKNOWN"; } -static int handle_ts1_read(struct bsc_fd *bfd) +static int handle_ts1_read(struct osmo_fd *bfd) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -200,7 +200,7 @@ static void timeout_ts1_write(void *data) ts_want_write(e1i_ts); } -static int handle_ts1_write(struct bsc_fd *bfd) +static int handle_ts1_write(struct osmo_fd *bfd) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -253,7 +253,7 @@ static int handle_ts1_write(struct bsc_fd *bfd) #define BCHAN_TX_GRAN 160 /* write to a B channel TS */ -static int handle_tsX_write(struct bsc_fd *bfd) +static int handle_tsX_write(struct osmo_fd *bfd) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -281,7 +281,7 @@ static int handle_tsX_write(struct bsc_fd *bfd) #define TSX_ALLOC_SIZE 4096 /* FIXME: read from a B channel TS */ -static int handle_tsX_read(struct bsc_fd *bfd) +static int handle_tsX_read(struct osmo_fd *bfd) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -329,7 +329,7 @@ static int handle_tsX_read(struct bsc_fd *bfd) } /* callback from select.c in case one of the fd's can be read/written */ -static int misdn_fd_cb(struct bsc_fd *bfd, unsigned int what) +static int misdn_fd_cb(struct osmo_fd *bfd, unsigned int what) { struct e1inp_line *line = bfd->data; unsigned int ts_nr = bfd->priv_nr; @@ -365,7 +365,7 @@ static int activate_bchan(struct e1inp_line *line, int ts, int act) int ret; unsigned int idx = ts-1; struct e1inp_ts *e1i_ts = &line->ts[idx]; - struct bsc_fd *bfd = &e1i_ts->driver.misdn.fd; + struct osmo_fd *bfd = &e1i_ts->driver.misdn.fd; fprintf(stdout, "activate bchan\n"); if (act) @@ -400,7 +400,7 @@ static int mi_e1_setup(struct e1inp_line *line, int release_l2) for (ts = 1; ts < NUM_E1_TS; ts++) { unsigned int idx = ts-1; struct e1inp_ts *e1i_ts = &line->ts[idx]; - struct bsc_fd *bfd = &e1i_ts->driver.misdn.fd; + struct osmo_fd *bfd = &e1i_ts->driver.misdn.fd; struct sockaddr_mISDN addr; bfd->data = line; @@ -470,7 +470,7 @@ static int mi_e1_setup(struct e1inp_line *line, int release_l2) if (e1i_ts->type == E1INP_TS_TYPE_TRAU) activate_bchan(line, ts, 1); - ret = bsc_register_fd(bfd); + ret = osmo_fd_register(bfd); if (ret < 0) { fprintf(stderr, "could not register FD: %s\n", strerror(ret)); diff --git a/openbsc/src/libbsc/bsc_msc.c b/openbsc/src/libbsc/bsc_msc.c index f4eee9c..a46f4b9 100644 --- a/openbsc/src/libbsc/bsc_msc.c +++ b/openbsc/src/libbsc/bsc_msc.c @@ -36,7 +36,7 @@ static void connection_loss(struct bsc_msc_connection *con) { - struct bsc_fd *fd; + struct osmo_fd *fd; fd = &con->write_queue.bfd; @@ -59,7 +59,7 @@ static void msc_con_timeout(void *_con) } /* called in the case of a non blocking connect */ -static int msc_connection_connect(struct bsc_fd *fd, unsigned int what) +static int msc_connection_connect(struct osmo_fd *fd, unsigned int what) { int rc; int val; @@ -102,11 +102,11 @@ static int msc_connection_connect(struct bsc_fd *fd, unsigned int what) return 0; error: - bsc_unregister_fd(fd); + osmo_fd_unregister(fd); connection_loss(con); return -1; } -static void setnonblocking(struct bsc_fd *fd) +static void setnonblocking(struct osmo_fd *fd) { int flags; @@ -131,7 +131,7 @@ static void setnonblocking(struct bsc_fd *fd) int bsc_msc_connect(struct bsc_msc_connection *con) { struct bsc_msc_dest *dest; - struct bsc_fd *fd; + struct osmo_fd *fd; struct sockaddr_in sin; int on = 1, ret; @@ -197,7 +197,7 @@ int bsc_msc_connect(struct bsc_msc_connection *con) con->connected(con); } - ret = bsc_register_fd(fd); + ret = osmo_fd_register(fd); if (ret < 0) { perror("Registering the fd failed"); close(fd->fd); @@ -229,7 +229,7 @@ void bsc_msc_lost(struct bsc_msc_connection *con) osmo_timer_del(&con->timeout_timer); if (con->write_queue.bfd.fd >= 0) - bsc_unregister_fd(&con->write_queue.bfd); + osmo_fd_unregister(&con->write_queue.bfd); connection_loss(con); } diff --git a/openbsc/src/libcommon/socket.c b/openbsc/src/libcommon/socket.c index dd25dd7..ff846aa 100644 --- a/openbsc/src/libcommon/socket.c +++ b/openbsc/src/libcommon/socket.c @@ -39,9 +39,9 @@ #include #include -int make_sock(struct bsc_fd *bfd, int proto, +int make_sock(struct osmo_fd *bfd, int proto, uint32_t ip, uint16_t port, int priv_nr, - int (*cb)(struct bsc_fd *fd, unsigned int what), void *data) + int (*cb)(struct osmo_fd *fd, unsigned int what), void *data) { struct sockaddr_in addr; int ret, on = 1; @@ -99,7 +99,7 @@ int make_sock(struct bsc_fd *bfd, int proto, } } - ret = bsc_register_fd(bfd); + ret = osmo_fd_register(bfd); if (ret < 0) { perror("register_listen_fd"); close(bfd->fd); diff --git a/openbsc/src/libgb/gprs_ns.c b/openbsc/src/libgb/gprs_ns.c index 1c3c1b6..2e549f3 100644 --- a/openbsc/src/libgb/gprs_ns.c +++ b/openbsc/src/libgb/gprs_ns.c @@ -858,7 +858,7 @@ void gprs_ns_destroy(struct gprs_ns_inst *nsi) * We don't support Size Procedure, Configuration Procedure, ChangeWeight Procedure */ /* Read a single NS-over-IP message */ -static struct msgb *read_nsip_msg(struct bsc_fd *bfd, int *error, +static struct msgb *read_nsip_msg(struct osmo_fd *bfd, int *error, struct sockaddr_in *saddr) { struct msgb *msg = gprs_ns_msgb_alloc(); @@ -890,7 +890,7 @@ static struct msgb *read_nsip_msg(struct bsc_fd *bfd, int *error, return msg; } -static int handle_nsip_read(struct bsc_fd *bfd) +static int handle_nsip_read(struct osmo_fd *bfd) { int error; struct sockaddr_in saddr; @@ -907,7 +907,7 @@ static int handle_nsip_read(struct bsc_fd *bfd) return error; } -static int handle_nsip_write(struct bsc_fd *bfd) +static int handle_nsip_write(struct osmo_fd *bfd) { /* FIXME: actually send the data here instead of nsip_sendmsg() */ return -EIO; @@ -928,7 +928,7 @@ static int nsip_sendmsg(struct gprs_nsvc *nsvc, struct msgb *msg) } /* UDP Port 23000 carries the LLC-in-BSSGP-in-NS protocol stack */ -static int nsip_fd_cb(struct bsc_fd *bfd, unsigned int what) +static int nsip_fd_cb(struct osmo_fd *bfd, unsigned int what) { int rc = 0; diff --git a/openbsc/src/libgb/gprs_ns_frgre.c b/openbsc/src/libgb/gprs_ns_frgre.c index 85019e1..3662572 100644 --- a/openbsc/src/libgb/gprs_ns_frgre.c +++ b/openbsc/src/libgb/gprs_ns_frgre.c @@ -49,7 +49,7 @@ struct gre_hdr { } __attribute__ ((packed)); /* IPv4 messages inside the GRE tunnel might be GRE keepalives */ -static int handle_rx_gre_ipv4(struct bsc_fd *bfd, struct msgb *msg, +static int handle_rx_gre_ipv4(struct osmo_fd *bfd, struct msgb *msg, struct iphdr *iph, struct gre_hdr *greh) { struct gprs_ns_inst *nsi = bfd->data; @@ -101,7 +101,7 @@ static int handle_rx_gre_ipv4(struct bsc_fd *bfd, struct msgb *msg, (struct sockaddr *)&daddr, sizeof(daddr)); } -static struct msgb *read_nsfrgre_msg(struct bsc_fd *bfd, int *error, +static struct msgb *read_nsfrgre_msg(struct osmo_fd *bfd, int *error, struct sockaddr_in *saddr) { struct msgb *msg = msgb_alloc(NS_ALLOC_SIZE, "Gb/NS/FR/GRE Rx"); @@ -203,7 +203,7 @@ out_err: int gprs_ns_rcvmsg(struct gprs_ns_inst *nsi, struct msgb *msg, struct sockaddr_in *saddr, enum gprs_ns_ll ll); -static int handle_nsfrgre_read(struct bsc_fd *bfd) +static int handle_nsfrgre_read(struct osmo_fd *bfd) { int rc; struct sockaddr_in saddr; @@ -230,7 +230,7 @@ out: return rc; } -static int handle_nsfrgre_write(struct bsc_fd *bfd) +static int handle_nsfrgre_write(struct osmo_fd *bfd) { /* FIXME: actually send the data here instead of nsip_sendmsg() */ return -EIO; @@ -268,7 +268,7 @@ int gprs_ns_frgre_sendmsg(struct gprs_nsvc *nsvc, struct msgb *msg) return rc; } -static int nsfrgre_fd_cb(struct bsc_fd *bfd, unsigned int what) +static int nsfrgre_fd_cb(struct osmo_fd *bfd, unsigned int what) { int rc = 0; diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index 18d43a0..10f117b 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -255,7 +255,7 @@ static int recevice_from(struct mgcp_endpoint *endp, int fd, struct sockaddr_in return rc; } -static int rtp_data_net(struct bsc_fd *fd, unsigned int what) +static int rtp_data_net(struct osmo_fd *fd, unsigned int what) { char buf[4096]; struct sockaddr_in addr; @@ -327,7 +327,7 @@ static void discover_bts(struct mgcp_endpoint *endp, int proto, struct sockaddr_ } } -static int rtp_data_bts(struct bsc_fd *fd, unsigned int what) +static int rtp_data_bts(struct osmo_fd *fd, unsigned int what) { char buf[4096]; struct sockaddr_in addr; @@ -381,7 +381,7 @@ static int rtp_data_bts(struct bsc_fd *fd, unsigned int what) } static int rtp_data_transcoder(struct mgcp_rtp_end *end, struct mgcp_endpoint *_endp, - int dest, struct bsc_fd *fd) + int dest, struct osmo_fd *fd) { char buf[4096]; struct sockaddr_in addr; @@ -421,7 +421,7 @@ static int rtp_data_transcoder(struct mgcp_rtp_end *end, struct mgcp_endpoint *_ return send_to(_endp, dest, proto == PROTO_RTP, &addr, &buf[0], rc); } -static int rtp_data_trans_net(struct bsc_fd *fd, unsigned int what) +static int rtp_data_trans_net(struct osmo_fd *fd, unsigned int what) { struct mgcp_endpoint *endp; endp = (struct mgcp_endpoint *) fd->data; @@ -429,7 +429,7 @@ static int rtp_data_trans_net(struct bsc_fd *fd, unsigned int what) return rtp_data_transcoder(&endp->trans_net, endp, DEST_NETWORK, fd); } -static int rtp_data_trans_bts(struct bsc_fd *fd, unsigned int what) +static int rtp_data_trans_bts(struct osmo_fd *fd, unsigned int what) { struct mgcp_endpoint *endp; endp = (struct mgcp_endpoint *) fd->data; @@ -437,7 +437,7 @@ static int rtp_data_trans_bts(struct bsc_fd *fd, unsigned int what) return rtp_data_transcoder(&endp->trans_bts, endp, DEST_BTS, fd); } -static int create_bind(const char *source_addr, struct bsc_fd *fd, int port) +static int create_bind(const char *source_addr, struct osmo_fd *fd, int port) { struct sockaddr_in addr; int on = 1; @@ -489,14 +489,14 @@ static int bind_rtp(struct mgcp_config *cfg, struct mgcp_rtp_end *rtp_end, int e set_ip_tos(rtp_end->rtcp.fd, cfg->endp_dscp); rtp_end->rtp.when = BSC_FD_READ; - if (bsc_register_fd(&rtp_end->rtp) != 0) { + if (osmo_fd_register(&rtp_end->rtp) != 0) { LOGP(DMGCP, LOGL_ERROR, "Failed to register RTP port %d on 0x%x\n", rtp_end->local_port, endpno); goto cleanup2; } rtp_end->rtcp.when = BSC_FD_READ; - if (bsc_register_fd(&rtp_end->rtcp) != 0) { + if (osmo_fd_register(&rtp_end->rtcp) != 0) { LOGP(DMGCP, LOGL_ERROR, "Failed to register RTCP port %d on 0x%x\n", rtp_end->local_port + 1, endpno); goto cleanup3; @@ -505,7 +505,7 @@ static int bind_rtp(struct mgcp_config *cfg, struct mgcp_rtp_end *rtp_end, int e return 0; cleanup3: - bsc_unregister_fd(&rtp_end->rtp); + osmo_fd_unregister(&rtp_end->rtp); cleanup2: close(rtp_end->rtcp.fd); rtp_end->rtcp.fd = -1; @@ -517,7 +517,7 @@ cleanup0: } static int int_bind(const char *port, - struct mgcp_rtp_end *end, int (*cb)(struct bsc_fd *, unsigned), + struct mgcp_rtp_end *end, int (*cb)(struct osmo_fd *, unsigned), struct mgcp_endpoint *_endp, int rtp_port) { if (end->rtp.fd != -1 || end->rtcp.fd != -1) { @@ -564,13 +564,13 @@ int mgcp_free_rtp_port(struct mgcp_rtp_end *end) if (end->rtp.fd != -1) { close(end->rtp.fd); end->rtp.fd = -1; - bsc_unregister_fd(&end->rtp); + osmo_fd_unregister(&end->rtp); } if (end->rtcp.fd != -1) { close(end->rtcp.fd); end->rtcp.fd = -1; - bsc_unregister_fd(&end->rtcp); + osmo_fd_unregister(&end->rtcp); } return 0; diff --git a/openbsc/src/libmsc/mncc_sock.c b/openbsc/src/libmsc/mncc_sock.c index f3841b0..5ef9922 100644 --- a/openbsc/src/libmsc/mncc_sock.c +++ b/openbsc/src/libmsc/mncc_sock.c @@ -39,8 +39,8 @@ struct mncc_sock_state { struct gsm_network *net; - struct bsc_fd listen_bfd; /* fd for listen socket */ - struct bsc_fd conn_bfd; /* fd for connection to lcr */ + struct osmo_fd listen_bfd; /* fd for listen socket */ + struct osmo_fd conn_bfd; /* fd for connection to lcr */ }; /* FIXME: avoid this */ @@ -85,17 +85,17 @@ void mncc_sock_write_pending(void) } /* FIXME: move this to libosmocore */ -int osmo_unixsock_listen(struct bsc_fd *bfd, int type, const char *path); +int osmo_unixsock_listen(struct osmo_fd *bfd, int type, const char *path); static void mncc_sock_close(struct mncc_sock_state *state) { - struct bsc_fd *bfd = &state->conn_bfd; + struct osmo_fd *bfd = &state->conn_bfd; LOGP(DMNCC, LOGL_NOTICE, "MNCC Socket has LOST connection\n"); close(bfd->fd); bfd->fd = -1; - bsc_unregister_fd(bfd); + osmo_fd_unregister(bfd); /* re-enable the generation of ACCEPT for new connections */ state->listen_bfd.when |= BSC_FD_READ; @@ -112,7 +112,7 @@ static void mncc_sock_close(struct mncc_sock_state *state) } } -static int mncc_sock_read(struct bsc_fd *bfd) +static int mncc_sock_read(struct osmo_fd *bfd) { struct mncc_sock_state *state = (struct mncc_sock_state *)bfd->data; struct gsm_mncc *mncc_prim; @@ -149,7 +149,7 @@ close: return -1; } -static int mncc_sock_write(struct bsc_fd *bfd) +static int mncc_sock_write(struct osmo_fd *bfd) { struct mncc_sock_state *state = bfd->data; struct gsm_network *net = state->net; @@ -189,7 +189,7 @@ close: return -1; } -static int mncc_sock_cb(struct bsc_fd *bfd, unsigned int flags) +static int mncc_sock_cb(struct osmo_fd *bfd, unsigned int flags) { int rc = 0; @@ -205,10 +205,10 @@ static int mncc_sock_cb(struct bsc_fd *bfd, unsigned int flags) } /* accept a new connection */ -static int mncc_sock_accept(struct bsc_fd *bfd, unsigned int flags) +static int mncc_sock_accept(struct osmo_fd *bfd, unsigned int flags) { struct mncc_sock_state *state = (struct mncc_sock_state *)bfd->data; - struct bsc_fd *conn_bfd = &state->conn_bfd; + struct osmo_fd *conn_bfd = &state->conn_bfd; struct sockaddr_un un_addr; socklen_t len; int rc; @@ -234,7 +234,7 @@ static int mncc_sock_accept(struct bsc_fd *bfd, unsigned int flags) conn_bfd->cb = mncc_sock_cb; conn_bfd->data = state; - if (bsc_register_fd(conn_bfd) != 0) { + if (osmo_fd_register(conn_bfd) != 0) { LOGP(DMNCC, LOGL_ERROR, "Failed to register new connection fd\n"); close(conn_bfd->fd); conn_bfd->fd = -1; @@ -251,7 +251,7 @@ static int mncc_sock_accept(struct bsc_fd *bfd, unsigned int flags) int mncc_sock_init(struct gsm_network *net) { struct mncc_sock_state *state; - struct bsc_fd *bfd; + struct osmo_fd *bfd; int rc; state = talloc_zero(tall_bsc_ctx, struct mncc_sock_state); @@ -275,7 +275,7 @@ int mncc_sock_init(struct gsm_network *net) bfd->cb = mncc_sock_accept; bfd->data = state; - rc = bsc_register_fd(bfd); + rc = osmo_fd_register(bfd); if (rc < 0) { LOGP(DMNCC, LOGL_ERROR, "Could not register listen fd: %d\n", rc); close(bfd->fd); @@ -289,7 +289,7 @@ int mncc_sock_init(struct gsm_network *net) } /* FIXME: move this to libosmocore */ -int osmo_unixsock_listen(struct bsc_fd *bfd, int type, const char *path) +int osmo_unixsock_listen(struct osmo_fd *bfd, int type, const char *path) { struct sockaddr_un local; unsigned int namelen; diff --git a/openbsc/src/libtrau/rtp_proxy.c b/openbsc/src/libtrau/rtp_proxy.c index 04e224c..86d5624 100644 --- a/openbsc/src/libtrau/rtp_proxy.c +++ b/openbsc/src/libtrau/rtp_proxy.c @@ -482,7 +482,7 @@ static int rtp_socket_write(struct rtp_socket *rs, struct rtp_sub_socket *rss) /* callback for the select.c:bfd_* layer */ -static int rtp_bfd_cb(struct bsc_fd *bfd, unsigned int flags) +static int rtp_bfd_cb(struct osmo_fd *bfd, unsigned int flags) { struct rtp_socket *rs = bfd->data; struct rtp_sub_socket *rss; @@ -536,7 +536,7 @@ struct rtp_socket *rtp_socket_create(void) goto out_free; init_rss(&rs->rtp, rs, rc, RTP_PRIV_RTP); - rc = bsc_register_fd(&rs->rtp.bfd); + rc = osmo_fd_register(&rs->rtp.bfd); if (rc < 0) goto out_rtp_socket; @@ -545,7 +545,7 @@ struct rtp_socket *rtp_socket_create(void) goto out_rtp_bfd; init_rss(&rs->rtcp, rs, rc, RTP_PRIV_RTCP); - rc = bsc_register_fd(&rs->rtcp.bfd); + rc = osmo_fd_register(&rs->rtcp.bfd); if (rc < 0) goto out_rtcp_socket; @@ -558,11 +558,11 @@ struct rtp_socket *rtp_socket_create(void) return rs; out_rtcp_bfd: - bsc_unregister_fd(&rs->rtcp.bfd); + osmo_fd_unregister(&rs->rtcp.bfd); out_rtcp_socket: close(rs->rtcp.bfd.fd); out_rtp_bfd: - bsc_unregister_fd(&rs->rtp.bfd); + osmo_fd_unregister(&rs->rtp.bfd); out_rtp_socket: close(rs->rtp.bfd.fd); out_free: @@ -713,11 +713,11 @@ int rtp_socket_free(struct rtp_socket *rs) rs->proxy.other_sock) rs->proxy.other_sock->proxy.other_sock = NULL; - bsc_unregister_fd(&rs->rtp.bfd); + osmo_fd_unregister(&rs->rtp.bfd); close(rs->rtp.bfd.fd); free_tx_queue(&rs->rtp); - bsc_unregister_fd(&rs->rtcp.bfd); + osmo_fd_unregister(&rs->rtcp.bfd); close(rs->rtcp.bfd.fd); free_tx_queue(&rs->rtcp); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index 51e5077..6437d93 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -256,7 +256,7 @@ int main(int argc, char **argv) } while (1) { - bsc_select_main(0); + osmo_select_main(0); } return 0; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c index e1a95a8..8b7c6e2 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c @@ -44,7 +44,7 @@ static void send_ping(struct osmo_msc_data *data); /* * MGCP forwarding code */ -static int mgcp_do_read(struct bsc_fd *fd) +static int mgcp_do_read(struct osmo_fd *fd) { struct osmo_msc_data *data = (struct osmo_msc_data *) fd->data; struct msgb *mgcp; @@ -72,7 +72,7 @@ static int mgcp_do_read(struct bsc_fd *fd) return 0; } -static int mgcp_do_write(struct bsc_fd *fd, struct msgb *msg) +static int mgcp_do_write(struct osmo_fd *fd, struct msgb *msg) { int ret; @@ -150,7 +150,7 @@ static int mgcp_create_port(struct osmo_msc_data *data) data->mgcp_agent.read_cb = mgcp_do_read; data->mgcp_agent.write_cb = mgcp_do_write; - if (bsc_register_fd(&data->mgcp_agent.bfd) != 0) { + if (osmo_fd_register(&data->mgcp_agent.bfd) != 0) { LOGP(DMGCP, LOGL_FATAL, "Failed to register BFD\n"); close(data->mgcp_agent.bfd.fd); data->mgcp_agent.bfd.fd = -1; @@ -175,7 +175,7 @@ int msc_queue_write(struct bsc_msc_connection *conn, struct msgb *msg, int proto return 0; } -static int msc_alink_do_write(struct bsc_fd *fd, struct msgb *msg) +static int msc_alink_do_write(struct osmo_fd *fd, struct msgb *msg) { int ret; @@ -208,7 +208,7 @@ static void osmo_ext_handle(struct osmo_msc_data *msc, struct msgb *msg) send_lacs(msc->network, msc->msc_con); } -static int ipaccess_a_fd_cb(struct bsc_fd *bfd) +static int ipaccess_a_fd_cb(struct osmo_fd *bfd) { int error; struct msgb *msg = ipaccess_read_msg(bfd, &error); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_rf.c b/openbsc/src/osmo-bsc/osmo_bsc_rf.c index 8df0306..5ce6bf5 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_rf.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_rf.c @@ -194,7 +194,7 @@ static void rf_delay_cmd_cb(void *data) } } -static int rf_read_cmd(struct bsc_fd *fd) +static int rf_read_cmd(struct osmo_fd *fd) { struct osmo_bsc_rf_conn *conn = fd->data; char buf[1]; @@ -203,7 +203,7 @@ static int rf_read_cmd(struct bsc_fd *fd) rc = read(fd->fd, buf, sizeof(buf)); if (rc != sizeof(buf)) { LOGP(DINP, LOGL_ERROR, "Short read %d/%s\n", errno, strerror(errno)); - bsc_unregister_fd(fd); + osmo_fd_unregister(fd); close(fd->fd); write_queue_clear(&conn->queue); talloc_free(conn); @@ -230,7 +230,7 @@ static int rf_read_cmd(struct bsc_fd *fd) return 0; } -static int rf_write_cmd(struct bsc_fd *fd, struct msgb *msg) +static int rf_write_cmd(struct osmo_fd *fd, struct msgb *msg) { int rc; @@ -243,7 +243,7 @@ static int rf_write_cmd(struct bsc_fd *fd, struct msgb *msg) return 0; } -static int rf_ctl_accept(struct bsc_fd *bfd, unsigned int what) +static int rf_ctl_accept(struct osmo_fd *bfd, unsigned int what) { struct osmo_bsc_rf_conn *conn; struct osmo_bsc_rf *rf = bfd->data; @@ -273,7 +273,7 @@ static int rf_ctl_accept(struct bsc_fd *bfd, unsigned int what) conn->queue.write_cb = rf_write_cmd; conn->rf = rf; - if (bsc_register_fd(&conn->queue.bfd) != 0) { + if (osmo_fd_register(&conn->queue.bfd) != 0) { close(fd); talloc_free(conn); return -1; @@ -286,7 +286,7 @@ struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net { unsigned int namelen; struct sockaddr_un local; - struct bsc_fd *bfd; + struct osmo_fd *bfd; struct osmo_bsc_rf *rf; int rc; @@ -341,7 +341,7 @@ struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net bfd->cb = rf_ctl_accept; bfd->data = rf; - if (bsc_register_fd(bfd) != 0) { + if (osmo_fd_register(bfd) != 0) { LOGP(DINP, LOGL_ERROR, "Failed to register bfd.\n"); close(bfd->fd); talloc_free(rf); diff --git a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c index 2077929..8cb90c5 100644 --- a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c +++ b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c @@ -135,7 +135,7 @@ static int mgcp_change_cb(struct mgcp_trunk_config *cfg, int endpoint, int state return 0; } -static int read_call_agent(struct bsc_fd *fd, unsigned int what) +static int read_call_agent(struct osmo_fd *fd, unsigned int what) { struct sockaddr_in addr; socklen_t slen = sizeof(addr); @@ -254,7 +254,7 @@ int main(int argc, char **argv) } - if (bsc_register_fd(&cfg->gw_fd.bfd) != 0) { + if (osmo_fd_register(&cfg->gw_fd.bfd) != 0) { LOGP(DMGCP, LOGL_FATAL, "Failed to register the fd\n"); return -1; } @@ -275,7 +275,7 @@ int main(int argc, char **argv) /* main loop */ while (1) { - bsc_select_main(0); + osmo_select_main(0); } diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c index 95a5388..be2666d 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c @@ -598,7 +598,7 @@ struct msgb *bsc_mgcp_rewrite(char *input, int length, int endpoint, const char return output; } -static int mgcp_do_read(struct bsc_fd *fd) +static int mgcp_do_read(struct osmo_fd *fd) { struct bsc_nat *nat; struct msgb *msg, *resp; @@ -637,7 +637,7 @@ static int mgcp_do_read(struct bsc_fd *fd) return 0; } -static int mgcp_do_write(struct bsc_fd *bfd, struct msgb *msg) +static int mgcp_do_write(struct osmo_fd *bfd, struct msgb *msg) { int rc; @@ -704,7 +704,7 @@ int bsc_mgcp_nat_init(struct bsc_nat *nat) cfg->gw_fd.read_cb = mgcp_do_read; cfg->gw_fd.write_cb = mgcp_do_write; - if (bsc_register_fd(&cfg->gw_fd.bfd) != 0) { + if (osmo_fd_register(&cfg->gw_fd.bfd) != 0) { LOGP(DMGCP, LOGL_ERROR, "Failed to register MGCP fd.\n"); close(cfg->gw_fd.bfd.fd); cfg->gw_fd.bfd.fd = -1; diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index ffcd388..0fb5843 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -64,7 +64,7 @@ struct log_target *stderr_target; static const char *config_file = "bsc-nat.cfg"; static struct in_addr local_addr; -static struct bsc_fd bsc_listen; +static struct osmo_fd bsc_listen; static const char *msc_ip = NULL; static struct osmo_timer_list sccp_close; static int daemonize = 0; @@ -780,7 +780,7 @@ static void msc_send_reset(struct bsc_msc_connection *msc_con) LOGP(DMSC, LOGL_NOTICE, "Scheduled GSM0808 reset msg for the MSC.\n"); } -static int ipaccess_msc_read_cb(struct bsc_fd *bfd) +static int ipaccess_msc_read_cb(struct osmo_fd *bfd) { int error; struct bsc_msc_connection *msc_con; @@ -818,7 +818,7 @@ static int ipaccess_msc_read_cb(struct bsc_fd *bfd) return 0; } -static int ipaccess_msc_write_cb(struct bsc_fd *bfd, struct msgb *msg) +static int ipaccess_msc_write_cb(struct osmo_fd *bfd, struct msgb *msg) { int rc; rc = write(bfd->fd, msg->data, msg->len); @@ -875,7 +875,7 @@ void bsc_close_connection(struct bsc_connection *connection) /* close endpoints allocated by this BSC */ bsc_mgcp_clear_endpoints_for(connection); - bsc_unregister_fd(&connection->write_queue.bfd); + osmo_fd_unregister(&connection->write_queue.bfd); close(connection->write_queue.bfd.fd); write_queue_clear(&connection->write_queue); llist_del(&connection->list_entry); @@ -1147,7 +1147,7 @@ exit3: return -1; } -static int ipaccess_bsc_read_cb(struct bsc_fd *bfd) +static int ipaccess_bsc_read_cb(struct osmo_fd *bfd) { int error; struct bsc_connection *bsc = bfd->data; @@ -1194,7 +1194,7 @@ static int ipaccess_bsc_read_cb(struct bsc_fd *bfd) return 0; } -static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what) +static int ipaccess_listen_bsc_cb(struct osmo_fd *bfd, unsigned int what) { struct bsc_connection *bsc; int fd, rc, on; @@ -1256,7 +1256,7 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what) bsc->write_queue.read_cb = ipaccess_bsc_read_cb; bsc->write_queue.write_cb = bsc_write_cb; bsc->write_queue.bfd.when = BSC_FD_READ; - if (bsc_register_fd(&bsc->write_queue.bfd) < 0) { + if (osmo_fd_register(&bsc->write_queue.bfd) < 0) { LOGP(DNAT, LOGL_ERROR, "Failed to register BSC fd.\n"); close(fd); talloc_free(bsc); @@ -1514,7 +1514,7 @@ int main(int argc, char **argv) osmo_timer_schedule(&sccp_close, SCCP_CLOSE_TIME, 0); while (1) { - bsc_select_main(0); + osmo_select_main(0); } return 0; diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index 9ddc948..e796b2b 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c @@ -787,7 +787,7 @@ int bsc_conn_type_to_ctr(struct sccp_connections *conn) return con_to_ctr[conn->con_type]; } -int bsc_write_cb(struct bsc_fd *bfd, struct msgb *msg) +int bsc_write_cb(struct osmo_fd *bfd, struct msgb *msg) { int rc; diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c index 5d599c7..910ef40 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c +++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c @@ -58,7 +58,7 @@ static void bsc_nat_ussd_destroy(struct bsc_nat_ussd_con *con) } close(con->queue.bfd.fd); - bsc_unregister_fd(&con->queue.bfd); + osmo_fd_unregister(&con->queue.bfd); osmo_timer_del(&con->auth_timeout); write_queue_clear(&con->queue); talloc_free(con); @@ -95,7 +95,7 @@ static int forward_sccp(struct bsc_nat *nat, struct msgb *msg) return 0; } -static int ussd_read_cb(struct bsc_fd *bfd) +static int ussd_read_cb(struct osmo_fd *bfd) { int error; struct bsc_nat_ussd_con *conn = bfd->data; @@ -191,7 +191,7 @@ static void ussd_start_auth(struct bsc_nat_ussd_con *conn) bsc_do_write(&conn->queue, msg, IPAC_PROTO_IPACCESS); } -static int ussd_listen_cb(struct bsc_fd *bfd, unsigned int what) +static int ussd_listen_cb(struct osmo_fd *bfd, unsigned int what) { struct bsc_nat_ussd_con *conn; struct bsc_nat *nat; @@ -225,7 +225,7 @@ static int ussd_listen_cb(struct bsc_fd *bfd, unsigned int what) conn->queue.read_cb = ussd_read_cb; conn->queue.write_cb = bsc_write_cb; - if (bsc_register_fd(&conn->queue.bfd) < 0) { + if (osmo_fd_register(&conn->queue.bfd) < 0) { LOGP(DNAT, LOGL_ERROR, "Failed to register USSD fd.\n"); bsc_nat_ussd_destroy(conn); return -1; diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index 8fec368..261c426 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -307,6 +307,6 @@ int main(int argc, char **argv) while (1) { log_reset_context(); - bsc_select_main(0); + osmo_select_main(0); } } diff --git a/openbsc/src/utils/bs11_config.c b/openbsc/src/utils/bs11_config.c index 8e987de..9cb6897 100644 --- a/openbsc/src/utils/bs11_config.c +++ b/openbsc/src/utils/bs11_config.c @@ -903,7 +903,7 @@ int main(int argc, char **argv) status_timer.cb = status_timer_cb; while (1) { - bsc_select_main(0); + osmo_select_main(0); } abis_nm_bs11_factory_logon(g_bts, 0); diff --git a/openbsc/src/utils/rs232.c b/openbsc/src/utils/rs232.c index 43b0dc4..b322e8a 100644 --- a/openbsc/src/utils/rs232.c +++ b/openbsc/src/utils/rs232.c @@ -36,7 +36,7 @@ /* adaption layer from GSM 08.59 + 12.21 to RS232 */ struct serial_handle { - struct bsc_fd fd; + struct osmo_fd fd; struct llist_head tx_queue; struct msgb *rx_msg; @@ -51,7 +51,7 @@ static struct serial_handle _ser_handle, *ser_handle = &_ser_handle; #define LAPD_HDR_LEN 10 -static int handle_ser_write(struct bsc_fd *bfd); +static int handle_ser_write(struct osmo_fd *bfd); /* callback from abis_nm */ int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml) @@ -88,7 +88,7 @@ int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml) } /* select.c callback in case we can write to the RS232 */ -static int handle_ser_write(struct bsc_fd *bfd) +static int handle_ser_write(struct osmo_fd *bfd) { struct serial_handle *sh = bfd->data; struct msgb *msg; @@ -119,7 +119,7 @@ static int handle_ser_write(struct bsc_fd *bfd) #define SERIAL_ALLOC_SIZE 300 /* select.c callback in case we can read from the RS232 */ -static int handle_ser_read(struct bsc_fd *bfd) +static int handle_ser_read(struct osmo_fd *bfd) { struct serial_handle *sh = bfd->data; struct msgb *msg; @@ -182,7 +182,7 @@ static int handle_ser_read(struct bsc_fd *bfd) } /* select.c callback */ -static int serial_fd_cb(struct bsc_fd *bfd, unsigned int what) +static int serial_fd_cb(struct osmo_fd *bfd, unsigned int what) { int rc = 0; @@ -237,7 +237,7 @@ int rs232_setup(const char *serial_port, unsigned int delay_ms, ser_handle->fd.data = ser_handle; ser_handle->delay_ms = delay_ms; ser_handle->bts = bts; - rc = bsc_register_fd(&ser_handle->fd); + rc = osmo_fd_register(&ser_handle->fd); if (rc < 0) { fprintf(stderr, "could not register FD: %s\n", strerror(rc)); diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c index 258938c..e05af1e 100644 --- a/openbsc/tests/channel/channel_test.c +++ b/openbsc/tests/channel/channel_test.c @@ -68,7 +68,7 @@ int main(int argc, char **argv) subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L); while (1) { - bsc_select_main(0); + osmo_select_main(0); } } -- 1.7.2.3 From pablo at gnumonks.org Fri May 6 10:31:26 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Fri, 6 May 2011 12:31:26 +0200 Subject: [PATCH 3/5] src: use namespace prefix osmo_signal* In-Reply-To: <1304677888-23639-1-git-send-email-pablo@gnumonks.org> References: <1304677888-23639-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304677888-23639-4-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/signal_cbfn/osmo_signal_cbfn/g s/register_signal_handler/osmo_signal_register_handler/g s/unregister_signal_handler/osmo_signal_unregister_handler/g s/dispatch_signal/osmo_signal_dispatch/g --- openbsc/src/gprs/gb_proxy_main.c | 4 ++-- openbsc/src/gprs/sgsn_main.c | 2 +- openbsc/src/ipaccess/ipaccess-config.c | 4 ++-- openbsc/src/ipaccess/network_listen.c | 4 ++-- openbsc/src/libabis/e1_input.c | 6 +++--- openbsc/src/libabis/input/dahdi.c | 4 ++-- openbsc/src/libbsc/abis_nm.c | 20 ++++++++++---------- openbsc/src/libbsc/abis_om2000.c | 6 +++--- openbsc/src/libbsc/abis_rsl.c | 8 ++++---- openbsc/src/libbsc/bsc_api.c | 2 +- openbsc/src/libbsc/bsc_init.c | 6 +++--- openbsc/src/libbsc/bsc_rll.c | 2 +- openbsc/src/libbsc/bts_ericsson_rbs2000.c | 6 +++--- openbsc/src/libbsc/bts_hsl_femtocell.c | 2 +- openbsc/src/libbsc/bts_ipaccess_nanobts.c | 2 +- openbsc/src/libbsc/bts_siemens_bs11.c | 4 ++-- openbsc/src/libbsc/chan_alloc.c | 6 +++--- openbsc/src/libbsc/handover_decision.c | 2 +- openbsc/src/libbsc/handover_logic.c | 6 +++--- openbsc/src/libbsc/meas_proc.c | 2 +- openbsc/src/libgb/gprs_ns.c | 16 ++++++++-------- openbsc/src/libmsc/gsm_04_08.c | 14 +++++++------- openbsc/src/libmsc/gsm_04_11.c | 2 +- openbsc/src/libmsc/gsm_subscriber.c | 6 +++--- openbsc/src/libmsc/rrlp.c | 4 ++-- openbsc/src/libmsc/silent_call.c | 4 ++-- openbsc/src/libmsc/sms_queue.c | 4 ++-- openbsc/src/libmsc/token_auth.c | 4 ++-- openbsc/src/libmsc/vty_interface_layer3.c | 2 +- openbsc/src/osmo-bsc/osmo_bsc_audio.c | 2 +- openbsc/src/osmo-bsc/osmo_bsc_grace.c | 2 +- openbsc/src/osmo-bsc/osmo_bsc_main.c | 2 +- openbsc/src/osmo-bsc/osmo_bsc_msc.c | 4 ++-- openbsc/src/osmo-bsc/osmo_bsc_rf.c | 2 +- openbsc/src/osmo-bsc/osmo_bsc_sccp.c | 2 +- openbsc/src/osmo-nitb/bsc_hack.c | 2 +- 36 files changed, 85 insertions(+), 85 deletions(-) diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c index b0fb664..9ef9098 100644 --- a/openbsc/src/gprs/gb_proxy_main.c +++ b/openbsc/src/gprs/gb_proxy_main.c @@ -98,7 +98,7 @@ static void signal_handler(int signal) switch (signal) { case SIGINT: - dispatch_signal(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL); + osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL); sleep(1); exit(0); break; @@ -239,7 +239,7 @@ int main(int argc, char **argv) } gbcfg.nsi = bssgp_nsi; gprs_ns_vty_init(bssgp_nsi); - register_signal_handler(SS_NS, &gbprox_signal, NULL); + osmo_signal_register_handler(SS_NS, &gbprox_signal, NULL); rc = gbproxy_parse_config(config_file, &gbcfg); if (rc < 0) { diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c index 6876939..5fdc5b7 100644 --- a/openbsc/src/gprs/sgsn_main.c +++ b/openbsc/src/gprs/sgsn_main.c @@ -105,7 +105,7 @@ static void signal_handler(int signal) switch (signal) { case SIGINT: - dispatch_signal(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL); + osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL); sleep(1); exit(0); break; diff --git a/openbsc/src/ipaccess/ipaccess-config.c b/openbsc/src/ipaccess/ipaccess-config.c index 5cd901c..e84892c 100644 --- a/openbsc/src/ipaccess/ipaccess-config.c +++ b/openbsc/src/ipaccess/ipaccess-config.c @@ -908,8 +908,8 @@ int main(int argc, char **argv) gsm_bts_trx_alloc(bts); bts->oml_tei = stream_id; - register_signal_handler(SS_NM, nm_sig_cb, NULL); - register_signal_handler(SS_IPAC_NWL, nwl_sig_cb, NULL); + osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL); + osmo_signal_register_handler(SS_IPAC_NWL, nwl_sig_cb, NULL); ipac_nwl_init(); diff --git a/openbsc/src/ipaccess/network_listen.c b/openbsc/src/ipaccess/network_listen.c index cf0a6dc..27d8a1d 100644 --- a/openbsc/src/ipaccess/network_listen.c +++ b/openbsc/src/ipaccess/network_listen.c @@ -222,7 +222,7 @@ static int test_rep(void *_msg) msg->trx->ipaccess.test_state = IPAC_TEST_S_IDLE; /* Send signal to notify higher layers of test completion */ DEBUGP(DNM, "dispatching S_IPAC_NWL_COMPLETE signal\n"); - dispatch_signal(SS_IPAC_NWL, S_IPAC_NWL_COMPLETE, msg->trx); + osmo_signal_dispatch(SS_IPAC_NWL, S_IPAC_NWL_COMPLETE, msg->trx); break; case NM_IPACC_TESTRES_PARTIAL: msg->trx->ipaccess.test_state = IPAC_TEST_S_PARTIAL; @@ -247,5 +247,5 @@ static int nwl_sig_cb(unsigned int subsys, unsigned int signal, void ipac_nwl_init(void) { - register_signal_handler(SS_NM, nwl_sig_cb, NULL); + osmo_signal_register_handler(SS_NM, nwl_sig_cb, NULL); } diff --git a/openbsc/src/libabis/e1_input.c b/openbsc/src/libabis/e1_input.c index d3a5cda..dd33852 100644 --- a/openbsc/src/libabis/e1_input.c +++ b/openbsc/src/libabis/e1_input.c @@ -576,7 +576,7 @@ int e1inp_event(struct e1inp_ts *ts, int evt, uint8_t tei, uint8_t sapi) isd.sapi = sapi; /* report further upwards */ - dispatch_signal(SS_INPUT, evt, &isd); + osmo_signal_dispatch(SS_INPUT, evt, &isd); return 0; } @@ -612,7 +612,7 @@ int e1inp_line_update(struct e1inp_line *line) * configured */ memset(&isd, 0, sizeof(isd)); isd.line = line; - dispatch_signal(SS_INPUT, S_INP_LINE_INIT, &isd); + osmo_signal_dispatch(SS_INPUT, S_INP_LINE_INIT, &isd); return rc; } @@ -639,7 +639,7 @@ void e1inp_init(void) { tall_sigl_ctx = talloc_named_const(tall_bsc_ctx, 1, "e1inp_sign_link"); - register_signal_handler(SS_GLOBAL, e1i_sig_cb, NULL); + osmo_signal_register_handler(SS_GLOBAL, e1i_sig_cb, NULL); e1inp_misdn_init(); #ifdef HAVE_DAHDI_USER_H diff --git a/openbsc/src/libabis/input/dahdi.c b/openbsc/src/libabis/input/dahdi.c index e02e141..9b85b7d 100644 --- a/openbsc/src/libabis/input/dahdi.c +++ b/openbsc/src/libabis/input/dahdi.c @@ -83,11 +83,11 @@ static void handle_dahdi_exception(struct e1inp_ts *ts) switch (evt) { case DAHDI_EVENT_ALARM: /* we should notify the code that the line is gone */ - dispatch_signal(SS_INPUT, S_INP_LINE_ALARM, &isd); + osmo_signal_dispatch(SS_INPUT, S_INP_LINE_ALARM, &isd); break; case DAHDI_EVENT_NOALARM: /* alarm has gone, we should re-start the SABM requests */ - dispatch_signal(SS_INPUT, S_INP_LINE_NOALARM, &isd); + osmo_signal_dispatch(SS_INPUT, S_INP_LINE_NOALARM, &isd); break; } } diff --git a/openbsc/src/libbsc/abis_nm.c b/openbsc/src/libbsc/abis_nm.c index 0007816..6ca45f7 100644 --- a/openbsc/src/libbsc/abis_nm.c +++ b/openbsc/src/libbsc/abis_nm.c @@ -701,7 +701,7 @@ static int update_admstate(struct gsm_bts *bts, uint8_t obj_class, nsd.old_state = nm_state; nsd.new_state = &new_state; nsd.obj_inst = obj_inst; - dispatch_signal(SS_NM, S_NM_STATECHG_ADM, &nsd); + osmo_signal_dispatch(SS_NM, S_NM_STATECHG_ADM, &nsd); nm_state->administrative = adm_state; @@ -760,7 +760,7 @@ static int abis_nm_rx_statechg_rep(struct msgb *mb) nsd.new_state = &new_state; nsd.obj_inst = &foh->obj_inst; nsd.bts = bts; - dispatch_signal(SS_NM, S_NM_STATECHG_OPER, &nsd); + osmo_signal_dispatch(SS_NM, S_NM_STATECHG_OPER, &nsd); nm_state->operational = new_state.operational; nm_state->availability = new_state.availability; if (nm_state->administrative == 0) @@ -827,15 +827,15 @@ static int abis_nm_rcvmsg_report(struct msgb *mb) break; case NM_MT_SW_ACTIVATED_REP: DEBUGPC(DNM, "Software Activated Report\n"); - dispatch_signal(SS_NM, S_NM_SW_ACTIV_REP, mb); + osmo_signal_dispatch(SS_NM, S_NM_SW_ACTIV_REP, mb); break; case NM_MT_FAILURE_EVENT_REP: rx_fail_evt_rep(mb); - dispatch_signal(SS_NM, S_NM_FAIL_REP, mb); + osmo_signal_dispatch(SS_NM, S_NM_FAIL_REP, mb); break; case NM_MT_TEST_REP: DEBUGPC(DNM, "Test Report\n"); - dispatch_signal(SS_NM, S_NM_TEST_REP, mb); + osmo_signal_dispatch(SS_NM, S_NM_TEST_REP, mb); break; default: DEBUGPC(DNM, "reporting NM MT 0x%02x\n", mt); @@ -1043,7 +1043,7 @@ static int abis_nm_rcvmsg_fom(struct msgb *mb) nack_data.msg = mb; nack_data.mt = mt; - dispatch_signal(SS_NM, S_NM_NACK, &nack_data); + osmo_signal_dispatch(SS_NM, S_NM_NACK, &nack_data); abis_nm_queue_send_next(mb->trx->bts); return 0; } @@ -1078,10 +1078,10 @@ static int abis_nm_rcvmsg_fom(struct msgb *mb) DEBUGP(DNM, "CONN MDROP LINK ACK\n"); break; case NM_MT_IPACC_RESTART_ACK: - dispatch_signal(SS_NM, S_NM_IPACC_RESTART_ACK, NULL); + osmo_signal_dispatch(SS_NM, S_NM_IPACC_RESTART_ACK, NULL); break; case NM_MT_IPACC_RESTART_NACK: - dispatch_signal(SS_NM, S_NM_IPACC_RESTART_NACK, NULL); + osmo_signal_dispatch(SS_NM, S_NM_IPACC_RESTART_NACK, NULL); break; case NM_MT_SET_BTS_ATTR_ACK: /* The HSL wants an OPSTART _after_ the SI has been set */ @@ -2884,12 +2884,12 @@ static int abis_nm_rx_ipacc(struct msgb *msg) case NM_MT_IPACC_GET_NVATTR_NACK: signal.trx = gsm_bts_trx_by_nr(msg->trx->bts, foh->obj_inst.trx_nr); signal.msg_type = foh->msg_type; - dispatch_signal(SS_NM, S_NM_IPACC_NACK, &signal); + osmo_signal_dispatch(SS_NM, S_NM_IPACC_NACK, &signal); break; case NM_MT_IPACC_SET_NVATTR_ACK: signal.trx = gsm_bts_trx_by_nr(msg->trx->bts, foh->obj_inst.trx_nr); signal.msg_type = foh->msg_type; - dispatch_signal(SS_NM, S_NM_IPACC_ACK, &signal); + osmo_signal_dispatch(SS_NM, S_NM_IPACC_ACK, &signal); break; default: break; diff --git a/openbsc/src/libbsc/abis_om2000.c b/openbsc/src/libbsc/abis_om2000.c index 7743cd8..19d2042 100644 --- a/openbsc/src/libbsc/abis_om2000.c +++ b/openbsc/src/libbsc/abis_om2000.c @@ -753,7 +753,7 @@ static void update_mo_state(struct gsm_bts *bts, struct abis_om2k_mo *mo, nsd.new_state = &new_state; nsd.om2k_mo = mo; - dispatch_signal(SS_NM, S_NM_STATECHG_ADM, &nsd); + osmo_signal_dispatch(SS_NM, S_NM_STATECHG_ADM, &nsd); nm_state->availability = new_state.availability; } @@ -794,7 +794,7 @@ static void signal_op_state(struct gsm_bts *bts, struct abis_om2k_mo *mo) nsd.new_state = nm_state; nsd.om2k_mo = mo; - dispatch_signal(SS_NM, S_NM_STATECHG_OPER, &nsd); + osmo_signal_dispatch(SS_NM, S_NM_STATECHG_OPER, &nsd); } static int abis_om2k_sendmsg(struct gsm_bts *bts, struct msgb *msg) @@ -1434,7 +1434,7 @@ static int process_conf_res(struct gsm_bts *bts, struct msgb *msg) nsd.obj = mo2obj(bts, &o2h->mo); nsd.om2k_mo = &o2h->mo; nsd.accordance_ind = acc; - dispatch_signal(SS_NM, S_NM_OM2K_CONF_RES, &nsd); + osmo_signal_dispatch(SS_NM, S_NM_OM2K_CONF_RES, &nsd); return ret; } diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 941a4ba..4d61dc0 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -55,7 +55,7 @@ static void send_lchan_signal(int sig_no, struct gsm_lchan *lchan, struct lchan_signal_data sig; sig.lchan = lchan; sig.mr = resp; - dispatch_signal(SS_LCHAN, sig_no, &sig); + osmo_signal_dispatch(SS_LCHAN, sig_no, &sig); } static uint8_t mdisc_by_msgtype(uint8_t msg_type) @@ -1806,7 +1806,7 @@ static int abis_rsl_rx_ipacc_crcx_ack(struct msgb *msg) ipac_parse_rtp(lchan, &tv); - dispatch_signal(SS_ABISIP, S_ABISIP_CRCX_ACK, msg->lchan); + osmo_signal_dispatch(SS_ABISIP, S_ABISIP_CRCX_ACK, msg->lchan); return 0; } @@ -1823,7 +1823,7 @@ static int abis_rsl_rx_ipacc_mdcx_ack(struct msgb *msg) rsl_tlv_parse(&tv, dh->data, msgb_l2len(msg)-sizeof(*dh)); ipac_parse_rtp(lchan, &tv); - dispatch_signal(SS_ABISIP, S_ABISIP_MDCX_ACK, msg->lchan); + osmo_signal_dispatch(SS_ABISIP, S_ABISIP_MDCX_ACK, msg->lchan); return 0; } @@ -1839,7 +1839,7 @@ static int abis_rsl_rx_ipacc_dlcx_ind(struct msgb *msg) print_rsl_cause(LOGL_DEBUG, TLVP_VAL(&tv, RSL_IE_CAUSE), TLVP_LEN(&tv, RSL_IE_CAUSE)); - dispatch_signal(SS_ABISIP, S_ABISIP_DLCX_IND, msg->lchan); + osmo_signal_dispatch(SS_ABISIP, S_ABISIP_DLCX_IND, msg->lchan); return 0; } diff --git a/openbsc/src/libbsc/bsc_api.c b/openbsc/src/libbsc/bsc_api.c index 09e9de4..70d6413 100644 --- a/openbsc/src/libbsc/bsc_api.c +++ b/openbsc/src/libbsc/bsc_api.c @@ -671,5 +671,5 @@ static void handle_chan_nack(struct gsm_subscriber_connection *conn, static __attribute__((constructor)) void on_dso_load_bsc(void) { - register_signal_handler(SS_LCHAN, bsc_handle_lchan_signal, NULL); + osmo_signal_register_handler(SS_LCHAN, bsc_handle_lchan_signal, NULL); } diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c index 1d14df1..0056bb0 100644 --- a/openbsc/src/libbsc/bsc_init.c +++ b/openbsc/src/libbsc/bsc_init.c @@ -82,7 +82,7 @@ int bsc_shutdown_net(struct gsm_network *net) llist_for_each_entry(bts, &net->bts_list, list) { LOGP(DNM, LOGL_NOTICE, "shutting down OML for BTS %u\n", bts->nr); - dispatch_signal(SS_GLOBAL, S_GLOBAL_BTS_CLOSE_OM, bts); + osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_BTS_CLOSE_OM, bts); } return 0; @@ -434,8 +434,8 @@ int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *), if (rc < 0) return rc; - register_signal_handler(SS_NM, nm_sig_cb, NULL); - register_signal_handler(SS_INPUT, inp_sig_cb, NULL); + osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL); + osmo_signal_register_handler(SS_INPUT, inp_sig_cb, NULL); llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) { rc = bootstrap_bts(bts); diff --git a/openbsc/src/libbsc/bsc_rll.c b/openbsc/src/libbsc/bsc_rll.c index 9fbe7c6..d12aeee 100644 --- a/openbsc/src/libbsc/bsc_rll.c +++ b/openbsc/src/libbsc/bsc_rll.c @@ -137,5 +137,5 @@ static int rll_lchan_signal(unsigned int subsys, unsigned int signal, static __attribute__((constructor)) void on_dso_load_rll(void) { - register_signal_handler(SS_CHALLOC, rll_lchan_signal, NULL); + osmo_signal_register_handler(SS_CHALLOC, rll_lchan_signal, NULL); } diff --git a/openbsc/src/libbsc/bts_ericsson_rbs2000.c b/openbsc/src/libbsc/bts_ericsson_rbs2000.c index 95bf38b..c2ae0e7 100644 --- a/openbsc/src/libbsc/bts_ericsson_rbs2000.c +++ b/openbsc/src/libbsc/bts_ericsson_rbs2000.c @@ -257,9 +257,9 @@ int bts_model_rbs2k_init(void) gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING); gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD); - register_signal_handler(SS_INPUT, inp_sig_cb, NULL); - register_signal_handler(SS_GLOBAL, gbl_sig_cb, NULL); - register_signal_handler(SS_NM, nm_sig_cb, NULL); + osmo_signal_register_handler(SS_INPUT, inp_sig_cb, NULL); + osmo_signal_register_handler(SS_GLOBAL, gbl_sig_cb, NULL); + osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL); return gsm_bts_model_register(&model_rbs2k); } diff --git a/openbsc/src/libbsc/bts_hsl_femtocell.c b/openbsc/src/libbsc/bts_hsl_femtocell.c index 9bbf6d2..7264a21 100644 --- a/openbsc/src/libbsc/bts_hsl_femtocell.c +++ b/openbsc/src/libbsc/bts_hsl_femtocell.c @@ -156,7 +156,7 @@ int bts_model_hslfemto_init(void) gsm_btsmodel_set_feature(&model_hslfemto, BTS_FEAT_GPRS); gsm_btsmodel_set_feature(&model_hslfemto, BTS_FEAT_EGPRS); - register_signal_handler(SS_INPUT, inp_sig_cb, NULL); + osmo_signal_register_handler(SS_INPUT, inp_sig_cb, NULL); return gsm_bts_model_register(&model_hslfemto); } diff --git a/openbsc/src/libbsc/bts_ipaccess_nanobts.c b/openbsc/src/libbsc/bts_ipaccess_nanobts.c index 097a889..13bed22 100644 --- a/openbsc/src/libbsc/bts_ipaccess_nanobts.c +++ b/openbsc/src/libbsc/bts_ipaccess_nanobts.c @@ -443,7 +443,7 @@ int bts_model_nanobts_init(void) gsm_btsmodel_set_feature(&model_nanobts, BTS_FEAT_GPRS); gsm_btsmodel_set_feature(&model_nanobts, BTS_FEAT_EGPRS); - register_signal_handler(SS_NM, nm_sig_cb, NULL); + osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL); return gsm_bts_model_register(&model_nanobts); } diff --git a/openbsc/src/libbsc/bts_siemens_bs11.c b/openbsc/src/libbsc/bts_siemens_bs11.c index 57625cd..44f9358 100644 --- a/openbsc/src/libbsc/bts_siemens_bs11.c +++ b/openbsc/src/libbsc/bts_siemens_bs11.c @@ -583,8 +583,8 @@ int bts_model_bs11_init(void) gsm_btsmodel_set_feature(&model_bs11, BTS_FEAT_HOPPING); gsm_btsmodel_set_feature(&model_bs11, BTS_FEAT_HSCSD); - register_signal_handler(SS_INPUT, inp_sig_cb, NULL); - register_signal_handler(SS_GLOBAL, gbl_sig_cb, NULL); + osmo_signal_register_handler(SS_INPUT, inp_sig_cb, NULL); + osmo_signal_register_handler(SS_GLOBAL, gbl_sig_cb, NULL); return gsm_bts_model_register(&model_bs11); } diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c index ff745f5..cfd3874 100644 --- a/openbsc/src/libbsc/chan_alloc.c +++ b/openbsc/src/libbsc/chan_alloc.c @@ -284,7 +284,7 @@ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type, struct challoc_signal_data sig; sig.bts = bts; sig.type = type; - dispatch_signal(SS_CHALLOC, S_CHALLOC_ALLOC_FAIL, &sig); + osmo_signal_dispatch(SS_CHALLOC, S_CHALLOC_ALLOC_FAIL, &sig); } return lchan; @@ -306,7 +306,7 @@ void lchan_free(struct gsm_lchan *lchan) /* We might kill an active channel... */ sig.lchan = lchan; sig.mr = NULL; - dispatch_signal(SS_LCHAN, S_LCHAN_UNEXPECTED_RELEASE, &sig); + osmo_signal_dispatch(SS_LCHAN, S_LCHAN_UNEXPECTED_RELEASE, &sig); } @@ -330,7 +330,7 @@ void lchan_free(struct gsm_lchan *lchan) sig.lchan = lchan; sig.bts = lchan->ts->trx->bts; - dispatch_signal(SS_CHALLOC, S_CHALLOC_FREED, &sig); + osmo_signal_dispatch(SS_CHALLOC, S_CHALLOC_FREED, &sig); if (lchan->conn) { LOGP(DRLL, LOGL_ERROR, "the subscriber connection should be gone.\n"); diff --git a/openbsc/src/libbsc/handover_decision.c b/openbsc/src/libbsc/handover_decision.c index d6fd4f4..24c0f79 100644 --- a/openbsc/src/libbsc/handover_decision.c +++ b/openbsc/src/libbsc/handover_decision.c @@ -293,5 +293,5 @@ static int ho_dec_sig_cb(unsigned int subsys, unsigned int signal, void on_dso_load_ho_dec(void) { - register_signal_handler(SS_LCHAN, ho_dec_sig_cb, NULL); + osmo_signal_register_handler(SS_LCHAN, ho_dec_sig_cb, NULL); } diff --git a/openbsc/src/libbsc/handover_logic.c b/openbsc/src/libbsc/handover_logic.c index bf9588b..1aa8fde 100644 --- a/openbsc/src/libbsc/handover_logic.c +++ b/openbsc/src/libbsc/handover_logic.c @@ -344,7 +344,7 @@ static int ho_ipac_crcx_ack(struct gsm_lchan *new_lchan) sig_ho.old_lchan = ho->old_lchan; sig_ho.new_lchan = new_lchan; - dispatch_signal(SS_HO, S_HANDOVER_ACK, &sig_ho); + osmo_signal_dispatch(SS_HO, S_HANDOVER_ACK, &sig_ho); return 0; } @@ -388,6 +388,6 @@ static int ho_logic_sig_cb(unsigned int subsys, unsigned int signal, static __attribute__((constructor)) void on_dso_load_ho_logic(void) { - register_signal_handler(SS_LCHAN, ho_logic_sig_cb, NULL); - register_signal_handler(SS_ABISIP, ho_logic_sig_cb, NULL); + osmo_signal_register_handler(SS_LCHAN, ho_logic_sig_cb, NULL); + osmo_signal_register_handler(SS_ABISIP, ho_logic_sig_cb, NULL); } diff --git a/openbsc/src/libbsc/meas_proc.c b/openbsc/src/libbsc/meas_proc.c index 5ca013d..5b97e74 100644 --- a/openbsc/src/libbsc/meas_proc.c +++ b/openbsc/src/libbsc/meas_proc.c @@ -80,5 +80,5 @@ static int meas_proc_sig_cb(unsigned int subsys, unsigned int signal, static __attribute__((constructor)) void on_dso_load_meas(void) { - register_signal_handler(SS_LCHAN, meas_proc_sig_cb, NULL); + osmo_signal_register_handler(SS_LCHAN, meas_proc_sig_cb, NULL); } diff --git a/openbsc/src/libgb/gprs_ns.c b/openbsc/src/libgb/gprs_ns.c index 2e549f3..dab57e6 100644 --- a/openbsc/src/libgb/gprs_ns.c +++ b/openbsc/src/libgb/gprs_ns.c @@ -172,7 +172,7 @@ void nsvc_delete(struct gprs_nsvc *nsvc) talloc_free(nsvc); } -static void ns_dispatch_signal(struct gprs_nsvc *nsvc, unsigned int signal, +static void ns_osmo_signal_dispatch(struct gprs_nsvc *nsvc, unsigned int signal, uint8_t cause) { struct ns_signal_data nssd; @@ -180,7 +180,7 @@ static void ns_dispatch_signal(struct gprs_nsvc *nsvc, unsigned int signal, nssd.nsvc = nsvc; nssd.cause = cause; - dispatch_signal(SS_NS, signal, &nssd); + osmo_signal_dispatch(SS_NS, signal, &nssd); } /* Section 10.3.2, Table 13 */ @@ -437,8 +437,8 @@ static void gprs_ns_timer_cb(void *data) "NSEI=%u Tns-alive expired more then " "%u times, blocking NS-VC\n", nsvc->nsei, nsvc->nsi->timeout[NS_TOUT_TNS_ALIVE_RETRIES]); - ns_dispatch_signal(nsvc, S_NS_ALIVE_EXP, 0); - ns_dispatch_signal(nsvc, S_NS_BLOCK, NS_CAUSE_NSVC_BLOCKED); + ns_osmo_signal_dispatch(nsvc, S_NS_ALIVE_EXP, 0); + ns_osmo_signal_dispatch(nsvc, S_NS_BLOCK, NS_CAUSE_NSVC_BLOCKED); return; } /* Tns-test case: send NS-ALIVE PDU */ @@ -631,7 +631,7 @@ static int gprs_ns_rx_reset(struct gprs_nsvc *nsvc, struct msgb *msg) /* inform interested parties about the fact that this NSVC * has received RESET */ - ns_dispatch_signal(nsvc, S_NS_RESET, *cause); + ns_osmo_signal_dispatch(nsvc, S_NS_RESET, *cause); return gprs_ns_tx_reset_ack(nsvc); } @@ -665,7 +665,7 @@ static int gprs_ns_rx_block(struct gprs_nsvc *nsvc, struct msgb *msg) cause = (uint8_t *) TLVP_VAL(&tp, NS_IE_CAUSE); //nsvci = (uint16_t *) TLVP_VAL(&tp, NS_IE_VCI); - ns_dispatch_signal(nsvc, S_NS_BLOCK, *cause); + ns_osmo_signal_dispatch(nsvc, S_NS_BLOCK, *cause); rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_BLOCKED]); return gprs_ns_tx_simple(nsvc, NS_PDUT_BLOCK_ACK); @@ -796,7 +796,7 @@ int gprs_ns_rcvmsg(struct gprs_ns_inst *nsi, struct msgb *msg, /* Section 7.2: unblocking procedure */ LOGP(DNS, LOGL_INFO, "NSEI=%u Rx NS UNBLOCK\n", nsvc->nsei); nsvc->state &= ~NSE_S_BLOCKED; - ns_dispatch_signal(nsvc, S_NS_UNBLOCK, 0); + ns_osmo_signal_dispatch(nsvc, S_NS_UNBLOCK, 0); rc = gprs_ns_tx_simple(nsvc, NS_PDUT_UNBLOCK_ACK); break; case NS_PDUT_UNBLOCK_ACK: @@ -804,7 +804,7 @@ int gprs_ns_rcvmsg(struct gprs_ns_inst *nsi, struct msgb *msg, /* mark NS-VC as unblocked + active */ nsvc->state = NSE_S_ALIVE; nsvc->remote_state = NSE_S_ALIVE; - ns_dispatch_signal(nsvc, S_NS_UNBLOCK, 0); + ns_osmo_signal_dispatch(nsvc, S_NS_UNBLOCK, 0); break; case NS_PDUT_BLOCK: rc = gprs_ns_rx_block(nsvc, msg); diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 9b7549f..153c1e5 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -439,7 +439,7 @@ static int mm_rx_id_resp(struct gsm_subscriber_connection *conn, struct msgb *ms DEBUGP(DMM, "IDENTITY RESPONSE: mi_type=0x%02x MI(%s)\n", mi_type, mi_string); - dispatch_signal(SS_SUBSCR, S_SUBSCR_IDENTITY, gh->data); + osmo_signal_dispatch(SS_SUBSCR, S_SUBSCR_IDENTITY, gh->data); switch (mi_type) { case GSM_MI_TYPE_IMSI: @@ -520,7 +520,7 @@ static int mm_rx_loc_upd_req(struct gsm_subscriber_connection *conn, struct msgb DEBUGPC(DMM, "mi_type=0x%02x MI(%s) type=%s ", mi_type, mi_string, lupd_name(lu->type)); - dispatch_signal(SS_SUBSCR, S_SUBSCR_IDENTITY, &lu->mi_len); + osmo_signal_dispatch(SS_SUBSCR, S_SUBSCR_IDENTITY, &lu->mi_len); switch (lu->type) { case GSM48_LUPD_NORMAL: @@ -842,7 +842,7 @@ static int gsm48_rx_mm_serv_req(struct gsm_subscriber_connection *conn, struct m DEBUGPC(DMM, "serv_type=0x%02x mi_type=0x%02x M(%s)\n", req->cm_service_type, mi_type, mi_string); - dispatch_signal(SS_SUBSCR, S_SUBSCR_IDENTITY, (classmark2 + classmark2_len)); + osmo_signal_dispatch(SS_SUBSCR, S_SUBSCR_IDENTITY, (classmark2 + classmark2_len)); if (is_siemens_bts(bts)) send_siemens_mrpci(msg->lchan, classmark2-1); @@ -1190,7 +1190,7 @@ static int gsm48_rx_rr_ho_compl(struct msgb *msg) sig.lchan = msg->lchan; sig.mr = NULL; - dispatch_signal(SS_LCHAN, S_LCHAN_HANDOVER_COMPL, &sig); + osmo_signal_dispatch(SS_LCHAN, S_LCHAN_HANDOVER_COMPL, &sig); /* FIXME: release old channel */ return 0; @@ -1207,7 +1207,7 @@ static int gsm48_rx_rr_ho_fail(struct msgb *msg) sig.lchan = msg->lchan; sig.mr = NULL; - dispatch_signal(SS_LCHAN, S_LCHAN_HANDOVER_FAIL, &sig); + osmo_signal_dispatch(SS_LCHAN, S_LCHAN_HANDOVER_FAIL, &sig); /* FIXME: release allocated new channel */ return 0; @@ -3343,6 +3343,6 @@ int gsm0408_dispatch(struct gsm_subscriber_connection *conn, struct msgb *msg) */ static __attribute__((constructor)) void on_dso_load_0408(void) { - register_signal_handler(SS_HO, handle_ho_signal, NULL); - register_signal_handler(SS_ABISIP, handle_abisip_signal, NULL); + osmo_signal_register_handler(SS_HO, handle_ho_signal, NULL); + osmo_signal_register_handler(SS_ABISIP, handle_abisip_signal, NULL); } diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c index 1db307a..326c2b8 100644 --- a/openbsc/src/libmsc/gsm_04_11.c +++ b/openbsc/src/libmsc/gsm_04_11.c @@ -151,7 +151,7 @@ static void send_signal(int sig_no, sig.trans = trans; sig.sms = sms; sig.paging_result = paging_result; - dispatch_signal(SS_SMS, sig_no, &sig); + osmo_signal_dispatch(SS_SMS, sig_no, &sig); } /* diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c index f0372af..f9eebc8 100644 --- a/openbsc/src/libmsc/gsm_subscriber.c +++ b/openbsc/src/libmsc/gsm_subscriber.c @@ -97,7 +97,7 @@ static int subscr_paging_dispatch(unsigned int hooknum, unsigned int event, sig_data.bts = conn ? conn->bts : NULL; sig_data.conn = conn; sig_data.paging_result = event; - dispatch_signal( + osmo_signal_dispatch( SS_PAGING, event == GSM_PAGING_SUCCEEDED ? S_PAGING_SUCCEEDED : S_PAGING_EXPIRED, @@ -337,7 +337,7 @@ int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason) subscr_name(s), s->lac); rc = db_sync_subscriber(s); db_subscriber_update(s); - dispatch_signal(SS_SUBSCR, S_SUBSCR_ATTACHED, s); + osmo_signal_dispatch(SS_SUBSCR, S_SUBSCR_ATTACHED, s); break; case GSM_SUBSCRIBER_UPDATE_DETACHED: /* Only detach if we are currently in this area */ @@ -346,7 +346,7 @@ int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason) LOGP(DMM, LOGL_INFO, "Subscriber %s DETACHED\n", subscr_name(s)); rc = db_sync_subscriber(s); db_subscriber_update(s); - dispatch_signal(SS_SUBSCR, S_SUBSCR_DETACHED, s); + osmo_signal_dispatch(SS_SUBSCR, S_SUBSCR_DETACHED, s); break; default: fprintf(stderr, "subscr_update with unknown reason: %d\n", diff --git a/openbsc/src/libmsc/rrlp.c b/openbsc/src/libmsc/rrlp.c index 75bccb5..161456a 100644 --- a/openbsc/src/libmsc/rrlp.c +++ b/openbsc/src/libmsc/rrlp.c @@ -99,6 +99,6 @@ static int paging_sig_cb(unsigned int subsys, unsigned int signal, void on_dso_load_rrlp(void) { - register_signal_handler(SS_SUBSCR, subscr_sig_cb, NULL); - register_signal_handler(SS_PAGING, paging_sig_cb, NULL); + osmo_signal_register_handler(SS_SUBSCR, subscr_sig_cb, NULL); + osmo_signal_register_handler(SS_PAGING, paging_sig_cb, NULL); } diff --git a/openbsc/src/libmsc/silent_call.c b/openbsc/src/libmsc/silent_call.c index 9e9b72d..6a188c8 100644 --- a/openbsc/src/libmsc/silent_call.c +++ b/openbsc/src/libmsc/silent_call.c @@ -56,13 +56,13 @@ static int paging_cb_silent(unsigned int hooknum, unsigned int event, conn->lchan->ts->nr, conn->lchan->ts->trx->arfcn); conn->silent_call = 1; /* increment lchan reference count */ - dispatch_signal(SS_SCALL, S_SCALL_SUCCESS, &sigdata); + osmo_signal_dispatch(SS_SCALL, S_SCALL_SUCCESS, &sigdata); break; case GSM_PAGING_EXPIRED: case GSM_PAGING_BUSY: case GSM_PAGING_OOM: DEBUGP(DSMS, "expired\n"); - dispatch_signal(SS_SCALL, S_SCALL_EXPIRED, &sigdata); + osmo_signal_dispatch(SS_SCALL, S_SCALL_EXPIRED, &sigdata); break; default: rc = -EINVAL; diff --git a/openbsc/src/libmsc/sms_queue.c b/openbsc/src/libmsc/sms_queue.c index 18545bf..30fa5f0 100644 --- a/openbsc/src/libmsc/sms_queue.c +++ b/openbsc/src/libmsc/sms_queue.c @@ -303,8 +303,8 @@ int sms_queue_start(struct gsm_network *network, int max_pending) return -1; } - register_signal_handler(SS_SUBSCR, sms_subscr_cb, network); - register_signal_handler(SS_SMS, sms_sms_cb, network); + osmo_signal_register_handler(SS_SUBSCR, sms_subscr_cb, network); + osmo_signal_register_handler(SS_SMS, sms_sms_cb, network); network->sms_queue = sms; INIT_LLIST_HEAD(&sms->pending_sms); diff --git a/openbsc/src/libmsc/token_auth.c b/openbsc/src/libmsc/token_auth.c index b9e481d..cf26ba8 100644 --- a/openbsc/src/libmsc/token_auth.c +++ b/openbsc/src/libmsc/token_auth.c @@ -148,6 +148,6 @@ static int token_sms_cb(unsigned int subsys, unsigned int signal, //static __attribute__((constructor)) void on_dso_load_token(void) void on_dso_load_token(void) { - register_signal_handler(SS_SUBSCR, token_subscr_cb, NULL); - register_signal_handler(SS_SMS, token_sms_cb, NULL); + osmo_signal_register_handler(SS_SUBSCR, token_subscr_cb, NULL); + osmo_signal_register_handler(SS_SMS, token_sms_cb, NULL); } diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index 6ac2c65..1d0097a 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -764,7 +764,7 @@ DEFUN(smsqueue_fail, int bsc_vty_init_extra(void) { - register_signal_handler(SS_SCALL, scall_cbfn, NULL); + osmo_signal_register_handler(SS_SCALL, scall_cbfn, NULL); install_element_ve(&show_subscr_cmd); install_element_ve(&show_subscr_cache_cmd); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_audio.c b/openbsc/src/osmo-bsc/osmo_bsc_audio.c index 515cfa7..64260aa 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_audio.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_audio.c @@ -65,6 +65,6 @@ static int handle_abisip_signal(unsigned int subsys, unsigned int signal, int osmo_bsc_audio_init(struct gsm_network *net) { net->hardcoded_rtp_payload = 98; - register_signal_handler(SS_ABISIP, handle_abisip_signal, net); + osmo_signal_register_handler(SS_ABISIP, handle_abisip_signal, net); return 0; } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_grace.c b/openbsc/src/osmo-bsc/osmo_bsc_grace.c index f699cf3..c67984b 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_grace.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_grace.c @@ -103,5 +103,5 @@ static int handle_rf_signal(unsigned int subsys, unsigned int signal, static __attribute__((constructor)) void on_dso_load_grace(void) { - register_signal_handler(SS_RF, handle_rf_signal, NULL); + osmo_signal_register_handler(SS_RF, handle_rf_signal, NULL); } diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index 6437d93..78a0ccb 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -149,7 +149,7 @@ static void signal_handler(int signal) switch (signal) { case SIGINT: bsc_shutdown_net(bsc_gsmnet); - dispatch_signal(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL); + osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL); sleep(3); exit(0); break; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c index 8b7c6e2..b4feded 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c @@ -306,7 +306,7 @@ static void msc_connection_connected(struct bsc_msc_connection *con) msc_ping_timeout_cb(data); sig.data = data; - dispatch_signal(SS_MSC, S_MSC_CONNECTED, &sig); + osmo_signal_dispatch(SS_MSC, S_MSC_CONNECTED, &sig); } /* @@ -325,7 +325,7 @@ static void msc_connection_was_lost(struct bsc_msc_connection *msc) osmo_timer_del(&data->pong_timer); sig.data = data; - dispatch_signal(SS_MSC, S_MSC_LOST, &sig); + osmo_signal_dispatch(SS_MSC, S_MSC_LOST, &sig); msc->is_authenticated = 0; bsc_msc_schedule_connect(msc); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_rf.c b/openbsc/src/osmo-bsc/osmo_bsc_rf.c index 5ce6bf5..78550d7 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_rf.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_rf.c @@ -137,7 +137,7 @@ static void send_signal(struct osmo_bsc_rf *rf, int val) sig.net = rf->gsm_network; rf->policy = val; - dispatch_signal(SS_RF, val, &sig); + osmo_signal_dispatch(SS_RF, val, &sig); } static int switch_rf_off(struct osmo_bsc_rf *rf) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c index 099552b..f4cdf36 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_sccp.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_sccp.c @@ -282,7 +282,7 @@ int osmo_bsc_sccp_init(struct gsm_network *gsmnet) sccp_connection_set_incoming(&sccp_ssn_bssap, msc_sccp_accept, NULL); sccp_set_read(&sccp_ssn_bssap, msc_sccp_read, gsmnet); - register_signal_handler(SS_MSC, handle_msc_signal, gsmnet); + osmo_signal_register_handler(SS_MSC, handle_msc_signal, gsmnet); return 0; } diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index 261c426..8e987b2 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -175,7 +175,7 @@ static void signal_handler(int signal) switch (signal) { case SIGINT: bsc_shutdown_net(bsc_gsmnet); - dispatch_signal(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL); + osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL); sleep(3); exit(0); break; -- 1.7.2.3 From pablo at gnumonks.org Fri May 6 10:31:27 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Fri, 6 May 2011 12:31:27 +0200 Subject: [PATCH 4/5] src: use namespace prefix osmo_wqueue* In-Reply-To: <1304677888-23639-1-git-send-email-pablo@gnumonks.org> References: <1304677888-23639-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304677888-23639-5-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/struct write_queue/struct osmo_wqueue/g s/write_queue_init/osmo_wqueue_init/g s/write_queue_clear/osmo_wqueue_clear/g s/write_queue_enqueue/osmo_wqueue_enqueue/g s/write_queue_bfd_cb/osmo_wqueue_bfd_cb/g --- openbsc/include/openbsc/bsc_msc.h | 2 +- openbsc/include/openbsc/bsc_nat.h | 8 ++++---- openbsc/include/openbsc/mgcp.h | 2 +- openbsc/include/openbsc/osmo_bsc_rf.h | 2 +- openbsc/include/openbsc/osmo_msc_data.h | 2 +- openbsc/src/libbsc/bsc_msc.c | 14 +++++++------- openbsc/src/osmo-bsc/osmo_bsc_msc.c | 6 +++--- openbsc/src/osmo-bsc/osmo_bsc_rf.c | 6 +++--- openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c | 6 +++--- openbsc/src/osmo-bsc_nat/bsc_nat.c | 4 ++-- openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 8 ++++---- openbsc/src/osmo-bsc_nat/bsc_ussd.c | 4 ++-- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/openbsc/include/openbsc/bsc_msc.h b/openbsc/include/openbsc/bsc_msc.h index 88f0de4..9543002 100644 --- a/openbsc/include/openbsc/bsc_msc.h +++ b/openbsc/include/openbsc/bsc_msc.h @@ -35,7 +35,7 @@ struct bsc_msc_dest { struct bsc_msc_connection { - struct write_queue write_queue; + struct osmo_wqueue write_queue; int is_connected; int is_authenticated; int first_contact; diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 73911bc..52b2ce5 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -76,7 +76,7 @@ struct bsc_connection { int authenticated; /* the fd we use to communicate */ - struct write_queue write_queue; + struct osmo_wqueue write_queue; /* the BSS associated */ struct bsc_config *cfg; @@ -286,7 +286,7 @@ struct bsc_nat { }; struct bsc_nat_ussd_con { - struct write_queue queue; + struct osmo_wqueue queue; struct bsc_nat *nat; int authorized; @@ -361,8 +361,8 @@ uint32_t bsc_mgcp_extract_ci(const char *resp); int bsc_write(struct bsc_connection *bsc, struct msgb *msg, int id); -int bsc_do_write(struct write_queue *queue, struct msgb *msg, int id); -int bsc_write_msg(struct write_queue *queue, struct msgb *msg); +int bsc_do_write(struct osmo_wqueue *queue, struct msgb *msg, int id); +int bsc_write_msg(struct osmo_wqueue *queue, struct msgb *msg); int bsc_write_cb(struct osmo_fd *bfd, struct msgb *msg); /* IMSI allow/deny handling */ diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h index 3d8e711..b9f8116 100644 --- a/openbsc/include/openbsc/mgcp.h +++ b/openbsc/include/openbsc/mgcp.h @@ -135,7 +135,7 @@ struct mgcp_config { struct in_addr transcoder_in; int transcoder_remote_base; - struct write_queue gw_fd; + struct osmo_wqueue gw_fd; struct mgcp_port_range bts_ports; struct mgcp_port_range net_ports; diff --git a/openbsc/include/openbsc/osmo_bsc_rf.h b/openbsc/include/openbsc/osmo_bsc_rf.h index dbbb3db..6db28cd 100644 --- a/openbsc/include/openbsc/osmo_bsc_rf.h +++ b/openbsc/include/openbsc/osmo_bsc_rf.h @@ -26,7 +26,7 @@ struct osmo_bsc_rf { }; struct osmo_bsc_rf_conn { - struct write_queue queue; + struct osmo_wqueue queue; struct osmo_bsc_rf *rf; }; diff --git a/openbsc/include/openbsc/osmo_msc_data.h b/openbsc/include/openbsc/osmo_msc_data.h index 495c923..3212b36 100644 --- a/openbsc/include/openbsc/osmo_msc_data.h +++ b/openbsc/include/openbsc/osmo_msc_data.h @@ -59,7 +59,7 @@ struct osmo_msc_data { /* mgcp agent */ - struct write_queue mgcp_agent; + struct osmo_wqueue mgcp_agent; /* rf ctl related bits */ char *mid_call_txt; diff --git a/openbsc/src/libbsc/bsc_msc.c b/openbsc/src/libbsc/bsc_msc.c index a46f4b9..e9ffce3 100644 --- a/openbsc/src/libbsc/bsc_msc.c +++ b/openbsc/src/libbsc/bsc_msc.c @@ -42,7 +42,7 @@ static void connection_loss(struct bsc_msc_connection *con) close(fd->fd); fd->fd = -1; - fd->cb = write_queue_bfd_cb; + fd->cb = osmo_wqueue_bfd_cb; fd->when = 0; con->is_connected = 0; @@ -64,7 +64,7 @@ static int msc_connection_connect(struct osmo_fd *fd, unsigned int what) int rc; int val; struct bsc_msc_connection *con; - struct write_queue *queue; + struct osmo_wqueue *queue; socklen_t len = sizeof(val); @@ -73,7 +73,7 @@ static int msc_connection_connect(struct osmo_fd *fd, unsigned int what) return -1; } - queue = container_of(fd, struct write_queue, bfd); + queue = container_of(fd, struct osmo_wqueue, bfd); con = container_of(queue, struct bsc_msc_connection, write_queue); /* From here on we will either be connected or reconnect */ @@ -92,7 +92,7 @@ static int msc_connection_connect(struct osmo_fd *fd, unsigned int what) /* go to full operation */ - fd->cb = write_queue_bfd_cb; + fd->cb = osmo_wqueue_bfd_cb; fd->when = BSC_FD_READ | BSC_FD_EXCEPT; con->is_connected = 1; @@ -191,7 +191,7 @@ int bsc_msc_connect(struct bsc_msc_connection *con) return ret; } else { fd->when = BSC_FD_READ | BSC_FD_EXCEPT; - fd->cb = write_queue_bfd_cb; + fd->cb = osmo_wqueue_bfd_cb; con->is_connected = 1; if (con->connected) con->connected(con); @@ -219,13 +219,13 @@ struct bsc_msc_connection *bsc_msc_create(void *ctx, struct llist_head *dests) con->dests = dests; con->write_queue.bfd.fd = -1; - write_queue_init(&con->write_queue, 100); + osmo_wqueue_init(&con->write_queue, 100); return con; } void bsc_msc_lost(struct bsc_msc_connection *con) { - write_queue_clear(&con->write_queue); + osmo_wqueue_clear(&con->write_queue); osmo_timer_del(&con->timeout_timer); if (con->write_queue.bfd.fd >= 0) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c index b4feded..6ea8c4f 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c @@ -102,7 +102,7 @@ static void mgcp_forward(struct osmo_msc_data *data, struct msgb *msg) msgb_put(mgcp, msgb_l2len(msg)); memcpy(mgcp->data, msg->l2h, mgcp->len); - if (write_queue_enqueue(&data->mgcp_agent, mgcp) != 0) { + if (osmo_wqueue_enqueue(&data->mgcp_agent, mgcp) != 0) { LOGP(DMGCP, LOGL_FATAL, "Could not queue message to MGCP GW.\n"); msgb_free(mgcp); } @@ -144,7 +144,7 @@ static int mgcp_create_port(struct osmo_msc_data *data) return -1; } - write_queue_init(&data->mgcp_agent, 10); + osmo_wqueue_init(&data->mgcp_agent, 10); data->mgcp_agent.bfd.when = BSC_FD_READ; data->mgcp_agent.bfd.data = data; data->mgcp_agent.read_cb = mgcp_do_read; @@ -166,7 +166,7 @@ static int mgcp_create_port(struct osmo_msc_data *data) int msc_queue_write(struct bsc_msc_connection *conn, struct msgb *msg, int proto) { ipaccess_prepend_header(msg, proto); - if (write_queue_enqueue(&conn->write_queue, msg) != 0) { + if (osmo_wqueue_enqueue(&conn->write_queue, msg) != 0) { LOGP(DMSC, LOGL_FATAL, "Failed to queue IPA/%d\n", proto); msgb_free(msg); return -1; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_rf.c b/openbsc/src/osmo-bsc/osmo_bsc_rf.c index 78550d7..11cdffe 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_rf.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_rf.c @@ -69,7 +69,7 @@ static void send_resp(struct osmo_bsc_rf_conn *conn, char send) msg->l2h = msgb_put(msg, 1); msg->l2h[0] = send; - if (write_queue_enqueue(&conn->queue, msg) != 0) { + if (osmo_wqueue_enqueue(&conn->queue, msg) != 0) { LOGP(DINP, LOGL_ERROR, "Failed to enqueue the answer.\n"); msgb_free(msg); return; @@ -205,7 +205,7 @@ static int rf_read_cmd(struct osmo_fd *fd) LOGP(DINP, LOGL_ERROR, "Short read %d/%s\n", errno, strerror(errno)); osmo_fd_unregister(fd); close(fd->fd); - write_queue_clear(&conn->queue); + osmo_wqueue_clear(&conn->queue); talloc_free(conn); return -1; } @@ -265,7 +265,7 @@ static int rf_ctl_accept(struct osmo_fd *bfd, unsigned int what) return -1; } - write_queue_init(&conn->queue, 10); + osmo_wqueue_init(&conn->queue, 10); conn->queue.bfd.data = conn; conn->queue.bfd.fd = fd; conn->queue.bfd.when = BSC_FD_READ | BSC_FD_WRITE; diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c index be2666d..9ac54da 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c @@ -478,7 +478,7 @@ void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg) return; } - if (write_queue_enqueue(&bsc->nat->mgcp_cfg->gw_fd, output) != 0) { + if (osmo_wqueue_enqueue(&bsc->nat->mgcp_cfg->gw_fd, output) != 0) { LOGP(DMGCP, LOGL_ERROR, "Failed to queue MGCP msg.\n"); msgb_free(output); } @@ -628,7 +628,7 @@ static int mgcp_do_read(struct osmo_fd *fd) /* we do have a direct answer... e.g. AUEP */ if (resp) { - if (write_queue_enqueue(&nat->mgcp_cfg->gw_fd, resp) != 0) { + if (osmo_wqueue_enqueue(&nat->mgcp_cfg->gw_fd, resp) != 0) { LOGP(DMGCP, LOGL_ERROR, "Failed to enqueue msg.\n"); msgb_free(resp); } @@ -698,7 +698,7 @@ int bsc_mgcp_nat_init(struct bsc_nat *nat) return -1; } - write_queue_init(&cfg->gw_fd, 10); + osmo_wqueue_init(&cfg->gw_fd, 10); cfg->gw_fd.bfd.when = BSC_FD_READ; cfg->gw_fd.bfd.data = nat; cfg->gw_fd.read_cb = mgcp_do_read; diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index 0fb5843..f732488 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -100,7 +100,7 @@ static void queue_for_msc(struct bsc_msc_connection *con, struct msgb *msg) } - if (write_queue_enqueue(&con->write_queue, msg) != 0) { + if (osmo_wqueue_enqueue(&con->write_queue, msg) != 0) { LOGP(DINP, LOGL_ERROR, "Failed to enqueue the write.\n"); msgb_free(msg); } @@ -877,7 +877,7 @@ void bsc_close_connection(struct bsc_connection *connection) osmo_fd_unregister(&connection->write_queue.bfd); close(connection->write_queue.bfd.fd); - write_queue_clear(&connection->write_queue); + osmo_wqueue_clear(&connection->write_queue); llist_del(&connection->list_entry); talloc_free(connection); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index e796b2b..4f90cdf 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c @@ -124,7 +124,7 @@ struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat) return NULL; con->nat = nat; - write_queue_init(&con->write_queue, 100); + osmo_wqueue_init(&con->write_queue, 100); return con; } @@ -335,16 +335,16 @@ int bsc_write(struct bsc_connection *bsc, struct msgb *msg, int proto) return bsc_do_write(&bsc->write_queue, msg, proto); } -int bsc_do_write(struct write_queue *queue, struct msgb *msg, int proto) +int bsc_do_write(struct osmo_wqueue *queue, struct msgb *msg, int proto) { /* prepend the header */ ipaccess_prepend_header(msg, proto); return bsc_write_msg(queue, msg); } -int bsc_write_msg(struct write_queue *queue, struct msgb *msg) +int bsc_write_msg(struct osmo_wqueue *queue, struct msgb *msg) { - if (write_queue_enqueue(queue, msg) != 0) { + if (osmo_wqueue_enqueue(queue, msg) != 0) { LOGP(DINP, LOGL_ERROR, "Failed to enqueue the write.\n"); msgb_free(msg); return -1; diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c index 910ef40..69cb7a4 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c +++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c @@ -60,7 +60,7 @@ static void bsc_nat_ussd_destroy(struct bsc_nat_ussd_con *con) close(con->queue.bfd.fd); osmo_fd_unregister(&con->queue.bfd); osmo_timer_del(&con->auth_timeout); - write_queue_clear(&con->queue); + osmo_wqueue_clear(&con->queue); talloc_free(con); } @@ -218,7 +218,7 @@ static int ussd_listen_cb(struct osmo_fd *bfd, unsigned int what) return -1; } - write_queue_init(&conn->queue, 10); + osmo_wqueue_init(&conn->queue, 10); conn->queue.bfd.data = conn; conn->queue.bfd.fd = fd; conn->queue.bfd.when = BSC_FD_READ; -- 1.7.2.3 From pablo at gnumonks.org Fri May 6 10:31:28 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Fri, 6 May 2011 12:31:28 +0200 Subject: [PATCH 5/5] src: use namespace prefix osmo_counter* In-Reply-To: <1304677888-23639-1-git-send-email-pablo@gnumonks.org> References: <1304677888-23639-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304677888-23639-6-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/struct counter/struct osmo_counter/g s/counter_inc/osmo_counter_inc/g s/counter_get/osmo_counter_get/g s/counter_reset/osmo_counter_reset/g s/counter_alloc/osmo_counter_alloc/g s/counter_free/osmo_counter_free --- openbsc/include/openbsc/bsc_nat.h | 12 +++--- openbsc/include/openbsc/db.h | 4 +- openbsc/include/openbsc/gsm_data.h | 60 ++++++++++++++-------------- openbsc/src/libbsc/abis_rsl.c | 8 ++-- openbsc/src/libbsc/bsc_init.c | 4 +- openbsc/src/libbsc/bsc_vty.c | 18 ++++---- openbsc/src/libbsc/gsm_04_08_utils.c | 2 +- openbsc/src/libbsc/handover_logic.c | 10 ++-- openbsc/src/libbsc/paging.c | 6 +- openbsc/src/libcommon/gsm_data.c | 60 ++++++++++++++-------------- openbsc/src/libmsc/db.c | 2 +- openbsc/src/libmsc/gsm_04_08.c | 20 +++++----- openbsc/src/libmsc/gsm_04_11.c | 10 ++-- openbsc/src/libmsc/vty_interface_layer3.c | 44 ++++++++++---------- openbsc/src/osmo-bsc_nat/bsc_nat.c | 6 +- openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 12 +++--- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 10 ++-- openbsc/src/osmo-bsc_nat/bsc_sccp.c | 2 +- openbsc/src/osmo-bsc_nat/bsc_ussd.c | 2 +- openbsc/src/osmo-nitb/bsc_hack.c | 4 +- openbsc/src/utils/bs11_config.c | 2 +- 21 files changed, 149 insertions(+), 149 deletions(-) diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 52b2ce5..0894f25 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -179,21 +179,21 @@ struct bsc_endpoint { */ struct bsc_nat_statistics { struct { - struct counter *conn; - struct counter *calls; + struct osmo_counter *conn; + struct osmo_counter *calls; } sccp; struct { - struct counter *reconn; - struct counter *auth_fail; + struct osmo_counter *reconn; + struct osmo_counter *auth_fail; } bsc; struct { - struct counter *reconn; + struct osmo_counter *reconn; } msc; struct { - struct counter *reconn; + struct osmo_counter *reconn; } ussd; }; diff --git a/openbsc/include/openbsc/db.h b/openbsc/include/openbsc/db.h index 818d3d4..37011a1 100644 --- a/openbsc/include/openbsc/db.h +++ b/openbsc/include/openbsc/db.h @@ -73,8 +73,8 @@ int db_apdu_blob_store(struct gsm_subscriber *subscr, uint8_t *apdu); /* Statistics counter storage */ -struct counter; -int db_store_counter(struct counter *ctr); +struct osmo_counter; +int db_store_counter(struct osmo_counter *ctr); struct rate_ctr_group; int db_store_rate_ctr_group(struct rate_ctr_group *ctrg); diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index e6d6467..bc276d1 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -646,52 +646,52 @@ struct gsm_bts { /* Some statistics of our network */ struct gsmnet_stats { struct { - struct counter *total; - struct counter *no_channel; + struct osmo_counter *total; + struct osmo_counter *no_channel; } chreq; struct { - struct counter *attempted; - struct counter *no_channel; /* no channel available */ - struct counter *timeout; /* T3103 timeout */ - struct counter *completed; /* HO COMPL received */ - struct counter *failed; /* HO FAIL received */ + struct osmo_counter *attempted; + struct osmo_counter *no_channel; /* no channel available */ + struct osmo_counter *timeout; /* T3103 timeout */ + struct osmo_counter *completed; /* HO COMPL received */ + struct osmo_counter *failed; /* HO FAIL received */ } handover; struct { - struct counter *attach; - struct counter *normal; - struct counter *periodic; - struct counter *detach; + struct osmo_counter *attach; + struct osmo_counter *normal; + struct osmo_counter *periodic; + struct osmo_counter *detach; } loc_upd_type; struct { - struct counter *reject; - struct counter *accept; + struct osmo_counter *reject; + struct osmo_counter *accept; } loc_upd_resp; struct { - struct counter *attempted; - struct counter *detached; - struct counter *completed; - struct counter *expired; + struct osmo_counter *attempted; + struct osmo_counter *detached; + struct osmo_counter *completed; + struct osmo_counter *expired; } paging; struct { - struct counter *submitted; /* MO SMS submissions */ - struct counter *no_receiver; - struct counter *delivered; /* MT SMS deliveries */ - struct counter *rp_err_mem; - struct counter *rp_err_other; + struct osmo_counter *submitted; /* MO SMS submissions */ + struct osmo_counter *no_receiver; + struct osmo_counter *delivered; /* MT SMS deliveries */ + struct osmo_counter *rp_err_mem; + struct osmo_counter *rp_err_other; } sms; struct { - struct counter *mo_setup; - struct counter *mo_connect_ack; - struct counter *mt_setup; - struct counter *mt_connect; + struct osmo_counter *mo_setup; + struct osmo_counter *mo_connect_ack; + struct osmo_counter *mt_setup; + struct osmo_counter *mt_connect; } call; struct { - struct counter *rf_fail; - struct counter *rll_err; + struct osmo_counter *rf_fail; + struct osmo_counter *rll_err; } chan; struct { - struct counter *oml_fail; - struct counter *rsl_fail; + struct osmo_counter *oml_fail; + struct osmo_counter *rsl_fail; } bts; }; diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c index 4d61dc0..1001003 100644 --- a/openbsc/src/libbsc/abis_rsl.c +++ b/openbsc/src/libbsc/abis_rsl.c @@ -922,7 +922,7 @@ static int rsl_rx_conn_fail(struct msgb *msg) LOGPC(DRSL, LOGL_NOTICE, "\n"); /* FIXME: only free it after channel release ACK */ - counter_inc(msg->lchan->ts->trx->bts->network->stats.chan.rf_fail); + osmo_counter_inc(msg->lchan->ts->trx->bts->network->stats.chan.rf_fail); return rsl_rf_chan_release(msg->lchan, 1); } @@ -1268,7 +1268,7 @@ static int rsl_rx_chan_rqd(struct msgb *msg) lctype = get_ctype_by_chreq(bts->network, rqd_ref->ra); chreq_reason = get_reason_by_chreq(rqd_ref->ra, bts->network->neci); - counter_inc(bts->network->stats.chreq.total); + osmo_counter_inc(bts->network->stats.chreq.total); /* * We want LOCATION UPDATES to succeed and will assign a TCH @@ -1281,7 +1281,7 @@ static int rsl_rx_chan_rqd(struct msgb *msg) if (!lchan) { LOGP(DRSL, LOGL_NOTICE, "BTS %d CHAN RQD: no resources for %s 0x%x\n", msg->lchan->ts->trx->bts->nr, gsm_lchant_name(lctype), rqd_ref->ra); - counter_inc(bts->network->stats.chreq.no_channel); + osmo_counter_inc(bts->network->stats.chreq.no_channel); /* FIXME gather multiple CHAN RQD and reject up to 4 at the same time */ if (bts->network->T3122) rsl_send_imm_ass_rej(bts, 1, rqd_ref, bts->network->T3122 & 0xff); @@ -1436,7 +1436,7 @@ static int rsl_rx_rll_err_ind(struct msgb *msg) rll_indication(msg->lchan, rllh->link_id, BSC_RLLR_IND_ERR_IND); if (rlm_cause[1] == RLL_CAUSE_T200_EXPIRED) { - counter_inc(msg->lchan->ts->trx->bts->network->stats.chan.rll_err); + osmo_counter_inc(msg->lchan->ts->trx->bts->network->stats.chan.rll_err); return rsl_rf_chan_release(msg->lchan, 1); } diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c index 0056bb0..8e62dac 100644 --- a/openbsc/src/libbsc/bsc_init.c +++ b/openbsc/src/libbsc/bsc_init.c @@ -275,9 +275,9 @@ static int inp_sig_cb(unsigned int subsys, unsigned int signal, LOGP(DMI, LOGL_ERROR, "Lost some E1 TEI link: %d %p\n", isd->link_type, trx); if (isd->link_type == E1INP_SIGN_OML) - counter_inc(trx->bts->network->stats.bts.oml_fail); + osmo_counter_inc(trx->bts->network->stats.bts.oml_fail); else if (isd->link_type == E1INP_SIGN_RSL) - counter_inc(trx->bts->network->stats.bts.rsl_fail); + osmo_counter_inc(trx->bts->network->stats.bts.rsl_fail); /* * free all allocated channels. change the nm_state so the diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 5a4bd6e..4cd027f 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -2518,18 +2518,18 @@ DEFUN(cfg_ts_e1_subslot, void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net) { vty_out(vty, "Channel Requests : %lu total, %lu no channel%s", - counter_get(net->stats.chreq.total), - counter_get(net->stats.chreq.no_channel), VTY_NEWLINE); + osmo_counter_get(net->stats.chreq.total), + osmo_counter_get(net->stats.chreq.no_channel), VTY_NEWLINE); vty_out(vty, "Channel Failures : %lu rf_failures, %lu rll failures%s", - counter_get(net->stats.chan.rf_fail), - counter_get(net->stats.chan.rll_err), VTY_NEWLINE); + osmo_counter_get(net->stats.chan.rf_fail), + osmo_counter_get(net->stats.chan.rll_err), VTY_NEWLINE); vty_out(vty, "Paging : %lu attempted, %lu complete, %lu expired%s", - counter_get(net->stats.paging.attempted), - counter_get(net->stats.paging.completed), - counter_get(net->stats.paging.expired), VTY_NEWLINE); + osmo_counter_get(net->stats.paging.attempted), + osmo_counter_get(net->stats.paging.completed), + osmo_counter_get(net->stats.paging.expired), VTY_NEWLINE); vty_out(vty, "BTS failures : %lu OML, %lu RSL%s", - counter_get(net->stats.bts.oml_fail), - counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE); + osmo_counter_get(net->stats.bts.oml_fail), + osmo_counter_get(net->stats.bts.rsl_fail), VTY_NEWLINE); } DEFUN(logging_fltr_imsi, diff --git a/openbsc/src/libbsc/gsm_04_08_utils.c b/openbsc/src/libbsc/gsm_04_08_utils.c index 1cff1d9..7599cea 100644 --- a/openbsc/src/libbsc/gsm_04_08_utils.c +++ b/openbsc/src/libbsc/gsm_04_08_utils.c @@ -300,7 +300,7 @@ int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, subscr = conn->subscr; } - counter_inc(bts->network->stats.paging.completed); + osmo_counter_inc(bts->network->stats.paging.completed); /* Stop paging on the bts we received the paging response */ paging_request_stop(conn->bts, subscr, conn, msg); diff --git a/openbsc/src/libbsc/handover_logic.c b/openbsc/src/libbsc/handover_logic.c index 1aa8fde..0f1582e 100644 --- a/openbsc/src/libbsc/handover_logic.c +++ b/openbsc/src/libbsc/handover_logic.c @@ -96,7 +96,7 @@ int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts) DEBUGP(DHO, "(old_lchan on BTS %u, new BTS %u)\n", old_lchan->ts->trx->bts->nr, bts->nr); - counter_inc(bts->network->stats.handover.attempted); + osmo_counter_inc(bts->network->stats.handover.attempted); if (!old_lchan->conn) { LOGP(DHO, LOGL_ERROR, "Old lchan lacks connection data.\n"); @@ -106,7 +106,7 @@ int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts) new_lchan = lchan_alloc(bts, old_lchan->type, 0); if (!new_lchan) { LOGP(DHO, LOGL_NOTICE, "No free channel\n"); - counter_inc(bts->network->stats.handover.no_channel); + osmo_counter_inc(bts->network->stats.handover.no_channel); return -ENOSPC; } @@ -182,7 +182,7 @@ static void ho_T3103_cb(void *_ho) struct gsm_network *net = ho->new_lchan->ts->trx->bts->network; DEBUGP(DHO, "HO T3103 expired\n"); - counter_inc(net->stats.handover.timeout); + osmo_counter_inc(net->stats.handover.timeout); ho->new_lchan->conn->ho_lchan = NULL; ho->new_lchan->conn = NULL; @@ -262,7 +262,7 @@ static int ho_gsm48_ho_compl(struct gsm_lchan *new_lchan) ho->old_lchan->ts->trx->bts->nr, new_lchan->ts->trx->bts->nr, ho->old_lchan->ts->trx->arfcn, new_lchan->ts->trx->arfcn); - counter_inc(net->stats.handover.completed); + osmo_counter_inc(net->stats.handover.completed); osmo_timer_del(&ho->T3103); @@ -300,7 +300,7 @@ static int ho_gsm48_ho_fail(struct gsm_lchan *old_lchan) return -ENODEV; } - counter_inc(net->stats.handover.failed); + osmo_counter_inc(net->stats.handover.failed); osmo_timer_del(&ho->T3103); llist_del(&ho->list); diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c index 324104f..2dcd3b4 100644 --- a/openbsc/src/libbsc/paging.c +++ b/openbsc/src/libbsc/paging.c @@ -262,7 +262,7 @@ static void paging_T3113_expired(void *data) req, req->subscr->imsi); /* must be destroyed before calling cbfn, to prevent double free */ - counter_inc(req->bts->network->stats.paging.expired); + osmo_counter_inc(req->bts->network->stats.paging.expired); cbfn_param = req->cbfn_param; cbfn = req->cbfn; @@ -311,7 +311,7 @@ int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr, struct gsm_bts *bts = NULL; int num_pages = 0; - counter_inc(network->stats.paging.attempted); + osmo_counter_inc(network->stats.paging.attempted); /* start paging subscriber on all BTS within Location Area */ do { @@ -337,7 +337,7 @@ int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr, } while (1); if (num_pages == 0) - counter_inc(network->stats.paging.detached); + osmo_counter_inc(network->stats.paging.detached); return num_pages; } diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c index 5437548..45e56af 100644 --- a/openbsc/src/libcommon/gsm_data.c +++ b/openbsc/src/libcommon/gsm_data.c @@ -290,36 +290,36 @@ struct gsm_network *gsm_network_init(uint16_t country_code, uint16_t network_cod INIT_LLIST_HEAD(&net->upqueue); INIT_LLIST_HEAD(&net->bts_list); - net->stats.chreq.total = counter_alloc("net.chreq.total"); - net->stats.chreq.no_channel = counter_alloc("net.chreq.no_channel"); - net->stats.handover.attempted = counter_alloc("net.handover.attempted"); - net->stats.handover.no_channel = counter_alloc("net.handover.no_channel"); - net->stats.handover.timeout = counter_alloc("net.handover.timeout"); - net->stats.handover.completed = counter_alloc("net.handover.completed"); - net->stats.handover.failed = counter_alloc("net.handover.failed"); - net->stats.loc_upd_type.attach = counter_alloc("net.loc_upd_type.attach"); - net->stats.loc_upd_type.normal = counter_alloc("net.loc_upd_type.normal"); - net->stats.loc_upd_type.periodic = counter_alloc("net.loc_upd_type.periodic"); - net->stats.loc_upd_type.detach = counter_alloc("net.imsi_detach.count"); - net->stats.loc_upd_resp.reject = counter_alloc("net.loc_upd_resp.reject"); - net->stats.loc_upd_resp.accept = counter_alloc("net.loc_upd_resp.accept"); - net->stats.paging.attempted = counter_alloc("net.paging.attempted"); - net->stats.paging.detached = counter_alloc("net.paging.detached"); - net->stats.paging.completed = counter_alloc("net.paging.completed"); - net->stats.paging.expired = counter_alloc("net.paging.expired"); - net->stats.sms.submitted = counter_alloc("net.sms.submitted"); - net->stats.sms.no_receiver = counter_alloc("net.sms.no_receiver"); - net->stats.sms.delivered = counter_alloc("net.sms.delivered"); - net->stats.sms.rp_err_mem = counter_alloc("net.sms.rp_err_mem"); - net->stats.sms.rp_err_other = counter_alloc("net.sms.rp_err_other"); - net->stats.call.mo_setup = counter_alloc("net.call.mo_setup"); - net->stats.call.mo_connect_ack = counter_alloc("net.call.mo_connect_ack"); - net->stats.call.mt_setup = counter_alloc("net.call.mt_setup"); - net->stats.call.mt_connect = counter_alloc("net.call.mt_connect"); - net->stats.chan.rf_fail = counter_alloc("net.chan.rf_fail"); - net->stats.chan.rll_err = counter_alloc("net.chan.rll_err"); - net->stats.bts.oml_fail = counter_alloc("net.bts.oml_fail"); - net->stats.bts.rsl_fail = counter_alloc("net.bts.rsl_fail"); + net->stats.chreq.total = osmo_counter_alloc("net.chreq.total"); + net->stats.chreq.no_channel = osmo_counter_alloc("net.chreq.no_channel"); + net->stats.handover.attempted = osmo_counter_alloc("net.handover.attempted"); + net->stats.handover.no_channel = osmo_counter_alloc("net.handover.no_channel"); + net->stats.handover.timeout = osmo_counter_alloc("net.handover.timeout"); + net->stats.handover.completed = osmo_counter_alloc("net.handover.completed"); + net->stats.handover.failed = osmo_counter_alloc("net.handover.failed"); + net->stats.loc_upd_type.attach = osmo_counter_alloc("net.loc_upd_type.attach"); + net->stats.loc_upd_type.normal = osmo_counter_alloc("net.loc_upd_type.normal"); + net->stats.loc_upd_type.periodic = osmo_counter_alloc("net.loc_upd_type.periodic"); + net->stats.loc_upd_type.detach = osmo_counter_alloc("net.imsi_detach.count"); + net->stats.loc_upd_resp.reject = osmo_counter_alloc("net.loc_upd_resp.reject"); + net->stats.loc_upd_resp.accept = osmo_counter_alloc("net.loc_upd_resp.accept"); + net->stats.paging.attempted = osmo_counter_alloc("net.paging.attempted"); + net->stats.paging.detached = osmo_counter_alloc("net.paging.detached"); + net->stats.paging.completed = osmo_counter_alloc("net.paging.completed"); + net->stats.paging.expired = osmo_counter_alloc("net.paging.expired"); + net->stats.sms.submitted = osmo_counter_alloc("net.sms.submitted"); + net->stats.sms.no_receiver = osmo_counter_alloc("net.sms.no_receiver"); + net->stats.sms.delivered = osmo_counter_alloc("net.sms.delivered"); + net->stats.sms.rp_err_mem = osmo_counter_alloc("net.sms.rp_err_mem"); + net->stats.sms.rp_err_other = osmo_counter_alloc("net.sms.rp_err_other"); + net->stats.call.mo_setup = osmo_counter_alloc("net.call.mo_setup"); + net->stats.call.mo_connect_ack = osmo_counter_alloc("net.call.mo_connect_ack"); + net->stats.call.mt_setup = osmo_counter_alloc("net.call.mt_setup"); + net->stats.call.mt_connect = osmo_counter_alloc("net.call.mt_connect"); + net->stats.chan.rf_fail = osmo_counter_alloc("net.chan.rf_fail"); + net->stats.chan.rll_err = osmo_counter_alloc("net.chan.rll_err"); + net->stats.bts.oml_fail = osmo_counter_alloc("net.bts.oml_fail"); + net->stats.bts.rsl_fail = osmo_counter_alloc("net.bts.rsl_fail"); net->mncc_recv = mncc_recv; diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index f08fb79..d25bc21 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -1242,7 +1242,7 @@ int db_apdu_blob_store(struct gsm_subscriber *subscr, return 0; } -int db_store_counter(struct counter *ctr) +int db_store_counter(struct osmo_counter *ctr) { dbi_result result; char *q_name; diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 153c1e5..6486b19 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -361,7 +361,7 @@ int gsm0408_loc_upd_rej(struct gsm_subscriber_connection *conn, uint8_t cause) struct gsm_bts *bts = conn->bts; struct msgb *msg; - counter_inc(bts->network->stats.loc_upd_resp.reject); + osmo_counter_inc(bts->network->stats.loc_upd_resp.reject); msg = gsm48_create_loc_upd_rej(cause); if (!msg) { @@ -403,7 +403,7 @@ int gsm0408_loc_upd_acc(struct gsm_subscriber_connection *conn, uint32_t tmsi) DEBUGP(DMM, "-> LOCATION UPDATE ACCEPT\n"); - counter_inc(bts->network->stats.loc_upd_resp.accept); + osmo_counter_inc(bts->network->stats.loc_upd_resp.accept); return gsm48_conn_sendmsg(msg, conn, NULL); } @@ -524,13 +524,13 @@ static int mm_rx_loc_upd_req(struct gsm_subscriber_connection *conn, struct msgb switch (lu->type) { case GSM48_LUPD_NORMAL: - counter_inc(bts->network->stats.loc_upd_type.normal); + osmo_counter_inc(bts->network->stats.loc_upd_type.normal); break; case GSM48_LUPD_IMSI_ATT: - counter_inc(bts->network->stats.loc_upd_type.attach); + osmo_counter_inc(bts->network->stats.loc_upd_type.attach); break; case GSM48_LUPD_PERIODIC: - counter_inc(bts->network->stats.loc_upd_type.periodic); + osmo_counter_inc(bts->network->stats.loc_upd_type.periodic); break; } @@ -886,7 +886,7 @@ static int gsm48_rx_mm_imsi_detach_ind(struct msgb *msg) DEBUGP(DMM, "IMSI DETACH INDICATION: mi_type=0x%02x MI(%s): ", mi_type, mi_string); - counter_inc(bts->network->stats.loc_upd_type.detach); + osmo_counter_inc(bts->network->stats.loc_upd_type.detach); switch (mi_type) { case GSM_MI_TYPE_TMSI: @@ -1892,7 +1892,7 @@ static int gsm48_cc_rx_setup(struct gsm_trans *trans, struct msgb *msg) subscr_name(trans->subscr), trans->subscr->extension, setup.called.number); - counter_inc(trans->subscr->net->stats.call.mo_setup); + osmo_counter_inc(trans->subscr->net->stats.call.mo_setup); /* indicate setup to MNCC */ mncc_recvmsg(trans->subscr->net, trans, MNCC_SETUP_IND, &setup); @@ -1969,7 +1969,7 @@ static int gsm48_cc_tx_setup(struct gsm_trans *trans, void *arg) new_cc_state(trans, GSM_CSTATE_CALL_PRESENT); - counter_inc(trans->subscr->net->stats.call.mt_setup); + osmo_counter_inc(trans->subscr->net->stats.call.mt_setup); return gsm48_conn_sendmsg(msg, trans->conn, trans); } @@ -2190,7 +2190,7 @@ static int gsm48_cc_rx_connect(struct gsm_trans *trans, struct msgb *msg) } new_cc_state(trans, GSM_CSTATE_CONNECT_REQUEST); - counter_inc(trans->subscr->net->stats.call.mt_connect); + osmo_counter_inc(trans->subscr->net->stats.call.mt_connect); return mncc_recvmsg(trans->subscr->net, trans, MNCC_SETUP_CNF, &connect); } @@ -2203,7 +2203,7 @@ static int gsm48_cc_rx_connect_ack(struct gsm_trans *trans, struct msgb *msg) gsm48_stop_cc_timer(trans); new_cc_state(trans, GSM_CSTATE_ACTIVE); - counter_inc(trans->subscr->net->stats.call.mo_connect_ack); + osmo_counter_inc(trans->subscr->net->stats.call.mo_connect_ack); memset(&connect_ack, 0, sizeof(struct gsm_mncc)); connect_ack.callref = trans->callref; diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c index 326c2b8..5069be7 100644 --- a/openbsc/src/libmsc/gsm_04_11.c +++ b/openbsc/src/libmsc/gsm_04_11.c @@ -560,7 +560,7 @@ static int gsm340_rx_tpdu(struct gsm_subscriber_connection *conn, struct msgb *m uint8_t address_lv[12]; /* according to 03.40 / 9.1.2.5 */ int rc = 0; - counter_inc(conn->bts->network->stats.sms.submitted); + osmo_counter_inc(conn->bts->network->stats.sms.submitted); gsms = sms_alloc(); if (!gsms) @@ -656,7 +656,7 @@ static int gsm340_rx_tpdu(struct gsm_subscriber_connection *conn, struct msgb *m gsms->receiver = subscr_get_by_extension(conn->bts->network, gsms->dest_addr); if (!gsms->receiver) { rc = 1; /* cause 1: unknown subscriber */ - counter_inc(conn->bts->network->stats.sms.no_receiver); + osmo_counter_inc(conn->bts->network->stats.sms.no_receiver); goto out; } @@ -846,10 +846,10 @@ static int gsm411_rx_rp_error(struct msgb *msg, struct gsm_trans *trans, * to store this in our database and wait for a SMMA message */ /* FIXME */ send_signal(S_SMS_MEM_EXCEEDED, trans, sms, 0); - counter_inc(net->stats.sms.rp_err_mem); + osmo_counter_inc(net->stats.sms.rp_err_mem); } else { send_signal(S_SMS_UNKNOWN_ERROR, trans, sms, 0); - counter_inc(net->stats.sms.rp_err_other); + osmo_counter_inc(net->stats.sms.rp_err_other); } sms_free(sms); @@ -1139,7 +1139,7 @@ int gsm411_send_sms(struct gsm_subscriber_connection *conn, struct gsm_sms *sms) DEBUGP(DSMS, "TX: SMS DELIVER\n"); - counter_inc(conn->bts->network->stats.sms.delivered); + osmo_counter_inc(conn->bts->network->stats.sms.delivered); db_sms_inc_deliver_attempts(trans->sms.sms); return gsm411_rp_sendmsg(msg, trans, GSM411_MT_RP_DATA_MT, msg_ref); diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c index 1d0097a..f751555 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -673,37 +673,37 @@ DEFUN(show_stats, openbsc_vty_print_statistics(vty, net); vty_out(vty, "Channel Requests : %lu total, %lu no channel%s", - counter_get(net->stats.chreq.total), - counter_get(net->stats.chreq.no_channel), VTY_NEWLINE); + osmo_counter_get(net->stats.chreq.total), + osmo_counter_get(net->stats.chreq.no_channel), VTY_NEWLINE); vty_out(vty, "Location Update : %lu attach, %lu normal, %lu periodic%s", - counter_get(net->stats.loc_upd_type.attach), - counter_get(net->stats.loc_upd_type.normal), - counter_get(net->stats.loc_upd_type.periodic), VTY_NEWLINE); + osmo_counter_get(net->stats.loc_upd_type.attach), + osmo_counter_get(net->stats.loc_upd_type.normal), + osmo_counter_get(net->stats.loc_upd_type.periodic), VTY_NEWLINE); vty_out(vty, "IMSI Detach Indications : %lu%s", - counter_get(net->stats.loc_upd_type.detach), VTY_NEWLINE); + osmo_counter_get(net->stats.loc_upd_type.detach), VTY_NEWLINE); vty_out(vty, "Location Update Response: %lu accept, %lu reject%s", - counter_get(net->stats.loc_upd_resp.accept), - counter_get(net->stats.loc_upd_resp.reject), VTY_NEWLINE); + osmo_counter_get(net->stats.loc_upd_resp.accept), + osmo_counter_get(net->stats.loc_upd_resp.reject), VTY_NEWLINE); vty_out(vty, "Handover : %lu attempted, %lu no_channel, %lu timeout, " "%lu completed, %lu failed%s", - counter_get(net->stats.handover.attempted), - counter_get(net->stats.handover.no_channel), - counter_get(net->stats.handover.timeout), - counter_get(net->stats.handover.completed), - counter_get(net->stats.handover.failed), VTY_NEWLINE); + osmo_counter_get(net->stats.handover.attempted), + osmo_counter_get(net->stats.handover.no_channel), + osmo_counter_get(net->stats.handover.timeout), + osmo_counter_get(net->stats.handover.completed), + osmo_counter_get(net->stats.handover.failed), VTY_NEWLINE); vty_out(vty, "SMS MO : %lu submitted, %lu no receiver%s", - counter_get(net->stats.sms.submitted), - counter_get(net->stats.sms.no_receiver), VTY_NEWLINE); + osmo_counter_get(net->stats.sms.submitted), + osmo_counter_get(net->stats.sms.no_receiver), VTY_NEWLINE); vty_out(vty, "SMS MT : %lu delivered, %lu no memory, %lu other error%s", - counter_get(net->stats.sms.delivered), - counter_get(net->stats.sms.rp_err_mem), - counter_get(net->stats.sms.rp_err_other), VTY_NEWLINE); + osmo_counter_get(net->stats.sms.delivered), + osmo_counter_get(net->stats.sms.rp_err_mem), + osmo_counter_get(net->stats.sms.rp_err_other), VTY_NEWLINE); vty_out(vty, "MO Calls : %lu setup, %lu connect ack%s", - counter_get(net->stats.call.mo_setup), - counter_get(net->stats.call.mo_connect_ack), VTY_NEWLINE); + osmo_counter_get(net->stats.call.mo_setup), + osmo_counter_get(net->stats.call.mo_connect_ack), VTY_NEWLINE); vty_out(vty, "MT Calls : %lu setup, %lu connect%s", - counter_get(net->stats.call.mt_setup), - counter_get(net->stats.call.mt_connect), VTY_NEWLINE); + osmo_counter_get(net->stats.call.mt_setup), + osmo_counter_get(net->stats.call.mt_connect), VTY_NEWLINE); return CMD_SUCCESS; } diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index f732488..5df4cd8 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -663,7 +663,7 @@ static int forward_sccp_to_bts(struct bsc_msc_connection *msc_con, struct msgb * case SCCP_MSG_TYPE_IT: con = patch_sccp_src_ref_to_bsc(msg, parsed, nat); if (parsed->gsm_type == BSS_MAP_MSG_ASSIGMENT_RQST) { - counter_inc(nat->stats.sccp.calls); + osmo_counter_inc(nat->stats.sccp.calls); if (con) { struct rate_ctr_group *ctrg; @@ -752,7 +752,7 @@ static void msc_connection_was_lost(struct bsc_msc_connection *con) static void msc_connection_connected(struct bsc_msc_connection *con) { - counter_inc(nat->stats.msc.reconn); + osmo_counter_inc(nat->stats.msc.reconn); } static void msc_send_reset(struct bsc_msc_connection *msc_con) @@ -1211,7 +1211,7 @@ static int ipaccess_listen_bsc_cb(struct osmo_fd *bfd, unsigned int what) } /* count the reconnect */ - counter_inc(nat->stats.bsc.reconn); + osmo_counter_inc(nat->stats.bsc.reconn); /* * if we are not connected to a msc... just close the socket diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index 4f90cdf..8765f27 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c @@ -95,12 +95,12 @@ struct bsc_nat *bsc_nat_alloc(void) INIT_LLIST_HEAD(&nat->access_lists); INIT_LLIST_HEAD(&nat->dests); - nat->stats.sccp.conn = counter_alloc("nat.sccp.conn"); - nat->stats.sccp.calls = counter_alloc("nat.sccp.calls"); - nat->stats.bsc.reconn = counter_alloc("nat.bsc.conn"); - nat->stats.bsc.auth_fail = counter_alloc("nat.bsc.auth_fail"); - nat->stats.msc.reconn = counter_alloc("nat.msc.conn"); - nat->stats.ussd.reconn = counter_alloc("nat.ussd.conn"); + nat->stats.sccp.conn = osmo_counter_alloc("nat.sccp.conn"); + nat->stats.sccp.calls = osmo_counter_alloc("nat.sccp.calls"); + nat->stats.bsc.reconn = osmo_counter_alloc("nat.bsc.conn"); + nat->stats.bsc.auth_fail = osmo_counter_alloc("nat.bsc.auth_fail"); + nat->stats.msc.reconn = osmo_counter_alloc("nat.msc.conn"); + nat->stats.ussd.reconn = osmo_counter_alloc("nat.ussd.conn"); nat->auth_timeout = 2; nat->ping_timeout = 20; nat->pong_timeout = 5; diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index b892d7a..a115fad 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -250,15 +250,15 @@ static void dump_stat_total(struct vty *vty, struct bsc_nat *nat) { vty_out(vty, "NAT statistics%s", VTY_NEWLINE); vty_out(vty, " SCCP Connections %lu total, %lu calls%s", - counter_get(nat->stats.sccp.conn), - counter_get(nat->stats.sccp.calls), VTY_NEWLINE); + osmo_counter_get(nat->stats.sccp.conn), + osmo_counter_get(nat->stats.sccp.calls), VTY_NEWLINE); vty_out(vty, " MSC Connections %lu%s", - counter_get(nat->stats.msc.reconn), VTY_NEWLINE); + osmo_counter_get(nat->stats.msc.reconn), VTY_NEWLINE); vty_out(vty, " MSC Connected: %d%s", nat->msc_con->is_connected, VTY_NEWLINE); vty_out(vty, " BSC Connections %lu total, %lu auth failed.%s", - counter_get(nat->stats.bsc.reconn), - counter_get(nat->stats.bsc.auth_fail), VTY_NEWLINE); + osmo_counter_get(nat->stats.bsc.reconn), + osmo_counter_get(nat->stats.bsc.auth_fail), VTY_NEWLINE); } static void dump_stat_bsc(struct vty *vty, struct bsc_config *conf) diff --git a/openbsc/src/osmo-bsc_nat/bsc_sccp.c b/openbsc/src/osmo-bsc_nat/bsc_sccp.c index f7d868a..de6b421 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_sccp.c +++ b/openbsc/src/osmo-bsc_nat/bsc_sccp.c @@ -129,7 +129,7 @@ struct sccp_connections *create_sccp_src_ref(struct bsc_connection *bsc, bsc_mgcp_init(conn); llist_add_tail(&conn->list_entry, &bsc->nat->sccp_connections); rate_ctr_inc(&bsc->cfg->stats.ctrg->ctr[BCFG_CTR_SCCP_CONN]); - counter_inc(bsc->cfg->nat->stats.sccp.conn); + osmo_counter_inc(bsc->cfg->nat->stats.sccp.conn); LOGP(DNAT, LOGL_DEBUG, "Created 0x%x <-> 0x%x mapping for con %p\n", sccp_src_ref_to_int(&conn->real_ref), diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c index 69cb7a4..a6fcffc 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c +++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c @@ -209,7 +209,7 @@ static int ussd_listen_cb(struct osmo_fd *bfd, unsigned int what) } nat = (struct bsc_nat *) bfd->data; - counter_inc(nat->stats.ussd.reconn); + osmo_counter_inc(nat->stats.ussd.reconn); conn = bsc_nat_ussd_alloc(nat); if (!conn) { diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index 8e987b2..5e60441 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -195,7 +195,7 @@ static void signal_handler(int signal) } /* timer handling */ -static int _db_store_counter(struct counter *counter, void *data) +static int _db_store_counter(struct osmo_counter *counter, void *data) { return db_store_counter(counter); } @@ -203,7 +203,7 @@ static int _db_store_counter(struct counter *counter, void *data) static void db_sync_timer_cb(void *data) { /* store counters to database and re-schedule */ - counters_for_each(_db_store_counter, NULL); + osmo_counters_for_each(_db_store_counter, NULL); osmo_timer_schedule(&db_sync_timer, DB_SYNC_INTERVAL); } diff --git a/openbsc/src/utils/bs11_config.c b/openbsc/src/utils/bs11_config.c index 9cb6897..6e82126 100644 --- a/openbsc/src/utils/bs11_config.c +++ b/openbsc/src/utils/bs11_config.c @@ -72,7 +72,7 @@ static const uint8_t too_fast[] = { 0x12, 0x80, 0x00, 0x00, 0x02, 0x02 }; static struct log_target *stderr_target; /* dummy function to keep gsm_data.c happy */ -struct counter *counter_alloc(const char *name) +struct osmo_counter *osmo_counter_alloc(const char *name) { return NULL; } -- 1.7.2.3 From laforge at gnumonks.org Fri May 6 11:44:54 2011 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 6 May 2011 13:44:54 +0200 Subject: talloc linking / include magic Message-ID: <20110506114454.GU5155@prithivi.gnumonks.org> Hi Pablo, there is one more thing that would prevent libosmocore from being packaged by distributions right now: We include our own version of talloc. Debian, Fedora and Ubuntu e.g. by now have a shared libtalloc that we should probably use instead of our own copy. So what I'd like to see is: * split talloc.c from libosmocore and make a libosmotalloc instead * some autotools magic in the applications (openbsc, osmoocom-bb, osmo-tetra, etc.) that would try to # detect whether there is a system-wide libtalloc, if yes use it # if no, use libosmotalloc The only big question is how to deal with header files, as we do #include and in case of the system-wide libtalloc it should instead be #include I don't really have a good idea how to handle this. Any ideas? Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From 246tnt at gmail.com Fri May 6 12:16:54 2011 From: 246tnt at gmail.com (Sylvain Munaut) Date: Fri, 6 May 2011 14:16:54 +0200 Subject: talloc linking / include magic In-Reply-To: <20110506114454.GU5155@prithivi.gnumonks.org> References: <20110506114454.GU5155@prithivi.gnumonks.org> Message-ID: > The only big question is how to deal with header files, as we do > ? ? ? ?#include > and in case of the system-wide libtalloc it should instead be > ? ? ? ?#include > > I don't really have a good idea how to handle this. Any ideas? We could just have our local talloc have a .pc that includes a -I${PREFIX_STUFF}/osmocom/core/ in the cflags. So that the app always does a #include Then with autotools we can just check if either talloc.pc or osmotalloc.pc is present (in this order) and add the appropriate CFLAGS to the build. Alternatively, if during libosmocore compile, we detect global talloc is present, we don't build talloc.c and we have talloc.h be a simple #include compatibility ? Cheers, Sylvain From laforge at gnumonks.org Fri May 6 12:41:37 2011 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 6 May 2011 14:41:37 +0200 Subject: talloc linking / include magic In-Reply-To: References: <20110506114454.GU5155@prithivi.gnumonks.org> Message-ID: <20110506124137.GE7067@prithivi.gnumonks.org> Hi Sylvain, On Fri, May 06, 2011 at 02:16:54PM +0200, Sylvain Munaut wrote: > > The only big question is how to deal with header files, as we do > > ? ? ? ?#include > > and in case of the system-wide libtalloc it should instead be > > ? ? ? ?#include > > > > I don't really have a good idea how to handle this. Any ideas? > > We could just have our local talloc have a .pc that includes a > -I${PREFIX_STUFF}/osmocom/core/ in the cflags. So that the app always > does a #include > Then with autotools we can just check if either talloc.pc or > osmotalloc.pc is present (in this order) and add the appropriate > CFLAGS to the build. ok, good idea, makes sense. > Alternatively, if during libosmocore compile, we detect global talloc > is present, we don't build talloc.c and we have talloc.h be a simple > #include compatibility ? I think it shouldn't be a compile-time decision of libosmocore, but a compile-time decision of the application. Especially in the future case of a distribution-supplied libosmocore that may happen at different times. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From holger at freyther.de Fri May 6 12:30:34 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 06 May 2011 14:30:34 +0200 Subject: talloc linking / include magic In-Reply-To: <20110506114454.GU5155@prithivi.gnumonks.org> References: <20110506114454.GU5155@prithivi.gnumonks.org> Message-ID: <4DC3E9EA.1000001@freyther.de> On 05/06/2011 01:44 PM, Harald Welte wrote: > Hi Pablo, > > > The only big question is how to deal with header files, as we do > #include > and in case of the system-wide libtalloc it should instead be > #include a) Use #include_next in osmocom/core/talloc.h if one should use libosmotalloc? b) Take the fragile approach and hope the ABI is not changing in talloc c) prefix _talloc with osmo_talloc.. which then is either an (linker) alias to _talloc of libtalloc our own internal lib? Probably fragile as well.. no idea how well aliases across DSOs work. d) Find out if talloc.h is prefixed in Debian and use that way for includes. From pablo at gnumonks.org Sat May 7 11:22:02 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 7 May 2011 13:22:02 +0200 Subject: [PATCH 0/4] libosmocore: namespace pollution fixes (2/*) Message-ID: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso This patchset fixes the namespace pollution spotted by Harald: * bcd2char, char2bcd -> osmo_bcd2char, osmo_char2bcd * crc16 -> osmo_crc16 * generate_backtrace -> osmo_generate_backtrace * plugin_load_all -> osmo_plugin_load_all * msg_entry_parse -> osmo_config_list This patchset is a follow up, it comes after: [PATCH 0/5] libosmocore: namespace pollution fixes (1/*) 2nd try You can find the whole branch at pablo/namespace. Please, merge it. Thanks! Pablo Neira Ayuso (4): crc: use namespace prefix osmo_* backtrace: use namespace prefix osmo_* plugin: use namespace prefix osmo_* msgfile: use namespace prefix osmo_* and use more descriptive names include/osmocom/core/backtrace.h | 2 +- include/osmocom/core/crc16.h | 8 ++++---- include/osmocom/core/msgfile.h | 8 ++++---- include/osmocom/core/plugin.h | 2 +- src/backtrace.c | 2 +- src/crc16.c | 6 +++--- src/gsm/gprs_cipher_core.c | 2 +- src/msgfile.c | 22 ++++++++++++---------- src/panic.c | 2 +- src/plugin.c | 4 ++-- tests/msgfile/msgfile_test.c | 8 ++++---- 11 files changed, 34 insertions(+), 32 deletions(-) -- 1.7.2.3 From pablo at gnumonks.org Sat May 7 11:22:03 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 7 May 2011 13:22:03 +0200 Subject: [PATCH 1/4] crc: use namespace prefix osmo_* In-Reply-To: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> References: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304767326-25101-2-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/crc16_table/osmo_crc16_table/g s/crc16/osmo_crc16/g s/crc16_byte/osmo_crc16_byte/g --- include/osmocom/core/crc16.h | 8 ++++---- src/crc16.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/osmocom/core/crc16.h b/include/osmocom/core/crc16.h index 7a51249..0e52417 100644 --- a/include/osmocom/core/crc16.h +++ b/include/osmocom/core/crc16.h @@ -22,13 +22,13 @@ #include -extern uint16_t const crc16_table[256]; +extern uint16_t const osmo_crc16_table[256]; -extern uint16_t crc16(uint16_t crc, const uint8_t *buffer, size_t len); +extern uint16_t osmo_crc16(uint16_t crc, const uint8_t *buffer, size_t len); -static inline uint16_t crc16_byte(uint16_t crc, const uint8_t data) +static inline uint16_t osmo_crc16_byte(uint16_t crc, const uint8_t data) { - return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff]; + return (crc >> 8) ^ osmo_crc16_table[(crc ^ data) & 0xff]; } #endif /* __CRC16_H */ diff --git a/src/crc16.c b/src/crc16.c index 3a0d0dd..2741cf5 100644 --- a/src/crc16.c +++ b/src/crc16.c @@ -11,7 +11,7 @@ #include /** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */ -uint16_t const crc16_table[256] = { +uint16_t const osmo_crc16_table[256] = { 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, @@ -54,9 +54,9 @@ uint16_t const crc16_table[256] = { * * Returns the updated CRC value. */ -uint16_t crc16(uint16_t crc, uint8_t const *buffer, size_t len) +uint16_t osmo_crc16(uint16_t crc, uint8_t const *buffer, size_t len) { while (len--) - crc = crc16_byte(crc, *buffer++); + crc = osmo_crc16_byte(crc, *buffer++); return crc; } -- 1.7.2.3 From pablo at gnumonks.org Sat May 7 11:22:04 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 7 May 2011 13:22:04 +0200 Subject: [PATCH 2/4] backtrace: use namespace prefix osmo_* In-Reply-To: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> References: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304767326-25101-3-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/backtrace/osmo_backtrace/g --- include/osmocom/core/backtrace.h | 2 +- src/backtrace.c | 2 +- src/panic.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/osmocom/core/backtrace.h b/include/osmocom/core/backtrace.h index bbbb2c2..5a8a816 100644 --- a/include/osmocom/core/backtrace.h +++ b/include/osmocom/core/backtrace.h @@ -1,6 +1,6 @@ #ifndef _OSMO_BACKTRACE_H_ #define _OSMO_BACKTRACE_H_ -void generate_backtrace(); +void osmo_generate_backtrace(); #endif diff --git a/src/backtrace.c b/src/backtrace.c index ecd6b9c..8281fad 100644 --- a/src/backtrace.c +++ b/src/backtrace.c @@ -29,7 +29,7 @@ #ifdef HAVE_EXECINFO_H #include -void generate_backtrace() +void osmo_generate_backtrace() { int i, nptrs; void *buffer[100]; diff --git a/src/panic.c b/src/panic.c index 588a5fe..d445226 100644 --- a/src/panic.c +++ b/src/panic.c @@ -38,7 +38,7 @@ static osmo_panic_handler_t osmo_panic_handler = (void*)0; static void osmo_panic_default(const char *fmt, va_list args) { vfprintf(stderr, fmt, args); - generate_backtrace(); + osmo_generate_backtrace(); abort(); } -- 1.7.2.3 From pablo at gnumonks.org Sat May 7 11:22:05 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 7 May 2011 13:22:05 +0200 Subject: [PATCH 3/4] plugin: use namespace prefix osmo_* In-Reply-To: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> References: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304767326-25101-4-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/plugin_load_all/osmo_plugin_load_all/g --- include/osmocom/core/plugin.h | 2 +- src/gsm/gprs_cipher_core.c | 2 +- src/plugin.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/osmocom/core/plugin.h b/include/osmocom/core/plugin.h index 98f9b56..6c0eccc 100644 --- a/include/osmocom/core/plugin.h +++ b/include/osmocom/core/plugin.h @@ -1,6 +1,6 @@ #ifndef _OSMO_PLUGIN_H #define _OSMO_PLUGIN_H -int plugin_load_all(const char *directory); +int osmo_plugin_load_all(const char *directory); #endif diff --git a/src/gsm/gprs_cipher_core.c b/src/gsm/gprs_cipher_core.c index 0ff85e2..7884be0 100644 --- a/src/gsm/gprs_cipher_core.c +++ b/src/gsm/gprs_cipher_core.c @@ -53,7 +53,7 @@ int gprs_cipher_register(struct gprs_cipher_impl *ciph) int gprs_cipher_load(const char *path) { /* load all plugins available from path */ - return plugin_load_all(path); + return osmo_plugin_load_all(path); } /* function to be called by core code */ diff --git a/src/plugin.c b/src/plugin.c index 4d9fd31..998bca3 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -32,7 +32,7 @@ #include -int plugin_load_all(const char *directory) +int osmo_plugin_load_all(const char *directory) { unsigned int num = 0; char fname[PATH_MAX]; @@ -55,7 +55,7 @@ int plugin_load_all(const char *directory) return num; } #else -int plugin_load_all(const char *directory) +int osmo_plugin_load_all(const char *directory) { return 0; } -- 1.7.2.3 From pablo at gnumonks.org Sat May 7 11:22:06 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 7 May 2011 13:22:06 +0200 Subject: [PATCH 4/4] msgfile: use namespace prefix osmo_* and use more descriptive names In-Reply-To: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> References: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304767326-25101-5-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/msg_entry/osmo_config_entry/g s/msg_entries/osmo_config_list/g s/msg_entry_parse/osmo_config_list_parse/g minor glitch included in this patch while I was at it: -#include "linuxlist.h" +#include --- include/osmocom/core/msgfile.h | 8 ++++---- src/msgfile.c | 22 ++++++++++++---------- tests/msgfile/msgfile_test.c | 8 ++++---- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/osmocom/core/msgfile.h b/include/osmocom/core/msgfile.h index 92caa9f..c5e67a4 100644 --- a/include/osmocom/core/msgfile.h +++ b/include/osmocom/core/msgfile.h @@ -22,12 +22,12 @@ #ifndef MSG_FILE_H #define MSG_FILE_H -#include "linuxlist.h" +#include /** * One message in the list. */ -struct msg_entry { +struct osmo_config_entry { struct llist_head list; /* number for everyone to use */ @@ -40,10 +40,10 @@ struct msg_entry { char *text; }; -struct msg_entries { +struct osmo_config_list { struct llist_head entry; }; -struct msg_entries *msg_entry_parse(void *ctx, const char *filename); +struct osmo_config_list* osmo_config_list_parse(void *ctx, const char *filename); #endif diff --git a/src/msgfile.c b/src/msgfile.c index c13df51..d2b180d 100644 --- a/src/msgfile.c +++ b/src/msgfile.c @@ -29,11 +29,13 @@ #include #include -static struct msg_entry *alloc_entry(struct msg_entries *entries, - const char *mcc, const char *mnc, - const char *option, const char *text) +static struct osmo_config_entry * +alloc_entry(struct osmo_config_list *entries, + const char *mcc, const char *mnc, + const char *option, const char *text) { - struct msg_entry *entry = talloc_zero(entries, struct msg_entry); + struct osmo_config_entry *entry = + talloc_zero(entries, struct osmo_config_entry); if (!entry) return NULL; @@ -46,11 +48,11 @@ static struct msg_entry *alloc_entry(struct msg_entries *entries, return entry; } -static struct msg_entries *alloc_entries(void *ctx) +static struct osmo_config_list *alloc_entries(void *ctx) { - struct msg_entries *entries; + struct osmo_config_list *entries; - entries = talloc_zero(ctx, struct msg_entries); + entries = talloc_zero(ctx, struct osmo_config_list); if (!entries) return NULL; @@ -61,7 +63,7 @@ static struct msg_entries *alloc_entries(void *ctx) /* * split a line like 'foo:Text'. */ -static void handle_line(struct msg_entries *entries, char *line) +static void handle_line(struct osmo_config_list *entries, char *line) { int i; const int len = strlen(line); @@ -91,9 +93,9 @@ static void handle_line(struct msg_entries *entries, char *line) /* nothing found */ } -struct msg_entries *msg_entry_parse(void *ctx, const char *filename) +struct osmo_config_list *osmo_config_list_parse(void *ctx, const char *filename) { - struct msg_entries *entries; + struct osmo_config_list *entries; size_t n; char *line; FILE *file; diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c index 4637cea..ed7aa97 100644 --- a/tests/msgfile/msgfile_test.c +++ b/tests/msgfile/msgfile_test.c @@ -23,9 +23,9 @@ #include -static void dump_entries(struct msg_entries *entries) +static void dump_entries(struct osmo_config_list *entries) { - struct msg_entry *entry; + struct osmo_config_entry *entry; if (!entries) { fprintf(stderr, "Failed to parse the file\n"); @@ -40,10 +40,10 @@ static void dump_entries(struct msg_entries *entries) int main(int argc, char **argv) { - struct msg_entries *entries; + struct osmo_config_list *entries; /* todo use msgfile_test.c.in and replace the path */ - entries = msg_entry_parse(NULL, "msgconfig.cfg"); + entries = osmo_config_list_parse(NULL, "msgconfig.cfg"); dump_entries(entries); return 0; -- 1.7.2.3 From pablo at gnumonks.org Sat May 7 11:35:13 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Sat, 07 May 2011 13:35:13 +0200 Subject: [PATCH 0/4] libosmocore: namespace pollution fixes (2/*) In-Reply-To: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> References: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> Message-ID: <4DC52E71.6030506@gnumonks.org> On 07/05/11 13:22, pablo at gnumonks.org wrote: > From: Pablo Neira Ayuso > > This patchset fixes the namespace pollution spotted by Harald: > > * bcd2char, char2bcd -> osmo_bcd2char, osmo_char2bcd ^^^^ Sorry, it seems I forgot to include this patch. Find this attached. From pablo at gnumonks.org Sat May 7 10:43:08 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Sat, 7 May 2011 12:43:08 +0200 Subject: [PATCH] utils: use namespace prefix osmo_* Message-ID: Summary of changes: s/bcd2char/osmo_bcd2char/g s/char2bcd/osmo_char2bcd/g s/hexparse/osmo_hexparse/g s/hexdump/osmo_hexdump/g s/hexdump_nospc/osmo_hexdump_nospc/g s/ubit_dump/osmo_ubit_dump/g s/static_assert/osmo_static_assert/g --- include/osmocom/core/msgb.h | 2 +- include/osmocom/core/utils.h | 14 +++++++------- src/gsm/gsm48.c | 12 ++++++------ src/utils.c | 18 +++++++++--------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index 57b5d7f..8665c2b 100644 --- a/include/osmocom/core/msgb.h +++ b/include/osmocom/core/msgb.h @@ -181,7 +181,7 @@ static inline void msgb_reserve(struct msgb *msg, int len) static inline struct msgb *msgb_alloc_headroom(int size, int headroom, const char *name) { - static_assert(size > headroom, headroom_bigger); + osmo_static_assert(size > headroom, headroom_bigger); struct msgb *msg = msgb_alloc(size, name); if (msg) diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 252228d..0f1ea3b 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -13,16 +13,16 @@ struct value_string { const char *get_value_string(const struct value_string *vs, uint32_t val); int get_string_value(const struct value_string *vs, const char *str); -char bcd2char(uint8_t bcd); +char osmo_bcd2char(uint8_t bcd); /* only works for numbers in ascci */ -uint8_t char2bcd(char c); +uint8_t osmo_char2bcd(char c); -int hexparse(const char *str, uint8_t *b, int max_len); -char *hexdump(const unsigned char *buf, int len); -char *hexdump_nospc(const unsigned char *buf, int len); -char *ubit_dump(const uint8_t *bits, unsigned int len); +int osmo_hexparse(const char *str, uint8_t *b, int max_len); +char *osmo_hexdump(const unsigned char *buf, int len); +char *osmo_osmo_hexdump_nospc(const unsigned char *buf, int len); +char *osmo_ubit_dump(const uint8_t *bits, unsigned int len); -#define static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1]; +#define osmo_static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1]; void osmo_str2lower(char *out, const char *in); void osmo_str2upper(char *out, const char *in); diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c index 436bf14..d034589 100644 --- a/src/gsm/gsm48.c +++ b/src/gsm/gsm48.c @@ -301,7 +301,7 @@ int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi) uint8_t odd = (length & 0x1) == 1; buf[0] = GSM48_IE_MOBILE_ID; - buf[2] = char2bcd(imsi[0]) << 4 | GSM_MI_TYPE_IMSI | (odd << 3); + buf[2] = osmo_char2bcd(imsi[0]) << 4 | GSM_MI_TYPE_IMSI | (odd << 3); /* if the length is even we will fill half of the last octet */ if (odd) @@ -312,11 +312,11 @@ int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi) for (i = 1; i < buf[1]; ++i) { uint8_t lower, upper; - lower = char2bcd(imsi[++off]); + lower = osmo_char2bcd(imsi[++off]); if (!odd && off + 1 == length) upper = 0x0f; else - upper = char2bcd(imsi[++off]) & 0x0f; + upper = osmo_char2bcd(imsi[++off]) & 0x0f; buf[2 + i] = (upper << 4) | lower; } @@ -349,15 +349,15 @@ int gsm48_mi_to_string(char *string, const int str_len, const uint8_t *mi, case GSM_MI_TYPE_IMSI: case GSM_MI_TYPE_IMEI: case GSM_MI_TYPE_IMEISV: - *str_cur++ = bcd2char(mi[0] >> 4); + *str_cur++ = osmo_bcd2char(mi[0] >> 4); for (i = 1; i < mi_len; i++) { if (str_cur + 2 >= string + str_len) return str_cur - string; - *str_cur++ = bcd2char(mi[i] & 0xf); + *str_cur++ = osmo_bcd2char(mi[i] & 0xf); /* skip last nibble in last input byte when GSM_EVEN */ if( (i != mi_len-1) || (mi[0] & GSM_MI_ODD)) - *str_cur++ = bcd2char(mi[i] >> 4); + *str_cur++ = osmo_bcd2char(mi[i] >> 4); } break; default: diff --git a/src/utils.c b/src/utils.c index af1829c..3ee14ab 100644 --- a/src/utils.c +++ b/src/utils.c @@ -35,7 +35,7 @@ int get_string_value(const struct value_string *vs, const char *str) return -EINVAL; } -char bcd2char(uint8_t bcd) +char osmo_bcd2char(uint8_t bcd) { if (bcd < 0xa) return '0' + bcd; @@ -44,12 +44,12 @@ char bcd2char(uint8_t bcd) } /* only works for numbers in ascii */ -uint8_t char2bcd(char c) +uint8_t osmo_char2bcd(char c) { return c - 0x30; } -int hexparse(const char *str, uint8_t *b, int max_len) +int osmo_hexparse(const char *str, uint8_t *b, int max_len) { int i, l, v; @@ -78,7 +78,7 @@ int hexparse(const char *str, uint8_t *b, int max_len) static char hexd_buff[4096]; -static char *_hexdump(const unsigned char *buf, int len, char *delim) +static char *_osmo_hexdump(const unsigned char *buf, int len, char *delim) { int i; char *cur = hexd_buff; @@ -95,7 +95,7 @@ static char *_hexdump(const unsigned char *buf, int len, char *delim) return hexd_buff; } -char *ubit_dump(const uint8_t *bits, unsigned int len) +char *osmo_ubit_dump(const uint8_t *bits, unsigned int len) { int i; @@ -125,14 +125,14 @@ char *ubit_dump(const uint8_t *bits, unsigned int len) return hexd_buff; } -char *hexdump(const unsigned char *buf, int len) +char *osmo_hexdump(const unsigned char *buf, int len) { - return _hexdump(buf, len, " "); + return _osmo_hexdump(buf, len, " "); } -char *hexdump_nospc(const unsigned char *buf, int len) +char *osmo_osmo_hexdump_nospc(const unsigned char *buf, int len) { - return _hexdump(buf, len, ""); + return _osmo_hexdump(buf, len, ""); } #include "../config.h" -- 1.7.2.3 --------------080409000203030603090707-- From laforge at gnumonks.org Sun May 8 07:51:33 2011 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 8 May 2011 09:51:33 +0200 Subject: [PATCH 0/4] libosmocore: namespace pollution fixes (2/*) In-Reply-To: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> References: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> Message-ID: <20110508075133.GC16877@prithivi.gnumonks.org> Thanks pablo, I've applied your changes to libosmocore, tagged it as 0.3.0 and applied the changes to openbsc. I'm now manually fixing up libosmo-sccp, osmo-tetra, cemmlgr-ng and other projects that all refer to libosmocore. I would appreciate if you could take care of osmcoom-bb. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From pablo at gnumonks.org Sun May 8 09:17:24 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Sun, 08 May 2011 11:17:24 +0200 Subject: [PATCH 0/4] libosmocore: namespace pollution fixes (2/*) In-Reply-To: <20110508075133.GC16877@prithivi.gnumonks.org> References: <1304767326-25101-1-git-send-email-pablo@gnumonks.org> <20110508075133.GC16877@prithivi.gnumonks.org> Message-ID: <4DC65FA4.3050801@gnumonks.org> On 08/05/11 09:51, Harald Welte wrote: > Thanks pablo, > > I've applied your changes to libosmocore, tagged it as 0.3.0 and applied > the changes to openbsc. Thanks Harald. > I'm now manually fixing up libosmo-sccp, osmo-tetra, cemmlgr-ng and > other projects that all refer to libosmocore. I would appreciate if you > could take care of osmcoom-bb. I will take care of that, of course. From pablo at gnumonks.org Sat May 7 11:25:56 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 7 May 2011 13:25:56 +0200 Subject: [PATCH 1/5] utils: use namespace prefix osmo_* Message-ID: <1304767560-25218-1-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/bcd2char/osmo_bcd2char/g s/char2bcd/osmo_char2bcd/g s/hexparse/osmo_hexparse/g s/hexdump/osmo_hexdump/g s/hexdump_nospc/osmo_hexdump_nospc/g s/ubit_dump/osmo_ubit_dump/g s/static_assert/osmo_static_assert/g --- include/osmocom/core/msgb.h | 2 +- include/osmocom/core/utils.h | 14 +++++++------- src/gsm/gsm48.c | 12 ++++++------ src/utils.c | 18 +++++++++--------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index 57b5d7f..8665c2b 100644 --- a/include/osmocom/core/msgb.h +++ b/include/osmocom/core/msgb.h @@ -181,7 +181,7 @@ static inline void msgb_reserve(struct msgb *msg, int len) static inline struct msgb *msgb_alloc_headroom(int size, int headroom, const char *name) { - static_assert(size > headroom, headroom_bigger); + osmo_static_assert(size > headroom, headroom_bigger); struct msgb *msg = msgb_alloc(size, name); if (msg) diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 252228d..0f1ea3b 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -13,16 +13,16 @@ struct value_string { const char *get_value_string(const struct value_string *vs, uint32_t val); int get_string_value(const struct value_string *vs, const char *str); -char bcd2char(uint8_t bcd); +char osmo_bcd2char(uint8_t bcd); /* only works for numbers in ascci */ -uint8_t char2bcd(char c); +uint8_t osmo_char2bcd(char c); -int hexparse(const char *str, uint8_t *b, int max_len); -char *hexdump(const unsigned char *buf, int len); -char *hexdump_nospc(const unsigned char *buf, int len); -char *ubit_dump(const uint8_t *bits, unsigned int len); +int osmo_hexparse(const char *str, uint8_t *b, int max_len); +char *osmo_hexdump(const unsigned char *buf, int len); +char *osmo_osmo_hexdump_nospc(const unsigned char *buf, int len); +char *osmo_ubit_dump(const uint8_t *bits, unsigned int len); -#define static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1]; +#define osmo_static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1]; void osmo_str2lower(char *out, const char *in); void osmo_str2upper(char *out, const char *in); diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c index 436bf14..d034589 100644 --- a/src/gsm/gsm48.c +++ b/src/gsm/gsm48.c @@ -301,7 +301,7 @@ int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi) uint8_t odd = (length & 0x1) == 1; buf[0] = GSM48_IE_MOBILE_ID; - buf[2] = char2bcd(imsi[0]) << 4 | GSM_MI_TYPE_IMSI | (odd << 3); + buf[2] = osmo_char2bcd(imsi[0]) << 4 | GSM_MI_TYPE_IMSI | (odd << 3); /* if the length is even we will fill half of the last octet */ if (odd) @@ -312,11 +312,11 @@ int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi) for (i = 1; i < buf[1]; ++i) { uint8_t lower, upper; - lower = char2bcd(imsi[++off]); + lower = osmo_char2bcd(imsi[++off]); if (!odd && off + 1 == length) upper = 0x0f; else - upper = char2bcd(imsi[++off]) & 0x0f; + upper = osmo_char2bcd(imsi[++off]) & 0x0f; buf[2 + i] = (upper << 4) | lower; } @@ -349,15 +349,15 @@ int gsm48_mi_to_string(char *string, const int str_len, const uint8_t *mi, case GSM_MI_TYPE_IMSI: case GSM_MI_TYPE_IMEI: case GSM_MI_TYPE_IMEISV: - *str_cur++ = bcd2char(mi[0] >> 4); + *str_cur++ = osmo_bcd2char(mi[0] >> 4); for (i = 1; i < mi_len; i++) { if (str_cur + 2 >= string + str_len) return str_cur - string; - *str_cur++ = bcd2char(mi[i] & 0xf); + *str_cur++ = osmo_bcd2char(mi[i] & 0xf); /* skip last nibble in last input byte when GSM_EVEN */ if( (i != mi_len-1) || (mi[0] & GSM_MI_ODD)) - *str_cur++ = bcd2char(mi[i] >> 4); + *str_cur++ = osmo_bcd2char(mi[i] >> 4); } break; default: diff --git a/src/utils.c b/src/utils.c index af1829c..3ee14ab 100644 --- a/src/utils.c +++ b/src/utils.c @@ -35,7 +35,7 @@ int get_string_value(const struct value_string *vs, const char *str) return -EINVAL; } -char bcd2char(uint8_t bcd) +char osmo_bcd2char(uint8_t bcd) { if (bcd < 0xa) return '0' + bcd; @@ -44,12 +44,12 @@ char bcd2char(uint8_t bcd) } /* only works for numbers in ascii */ -uint8_t char2bcd(char c) +uint8_t osmo_char2bcd(char c) { return c - 0x30; } -int hexparse(const char *str, uint8_t *b, int max_len) +int osmo_hexparse(const char *str, uint8_t *b, int max_len) { int i, l, v; @@ -78,7 +78,7 @@ int hexparse(const char *str, uint8_t *b, int max_len) static char hexd_buff[4096]; -static char *_hexdump(const unsigned char *buf, int len, char *delim) +static char *_osmo_hexdump(const unsigned char *buf, int len, char *delim) { int i; char *cur = hexd_buff; @@ -95,7 +95,7 @@ static char *_hexdump(const unsigned char *buf, int len, char *delim) return hexd_buff; } -char *ubit_dump(const uint8_t *bits, unsigned int len) +char *osmo_ubit_dump(const uint8_t *bits, unsigned int len) { int i; @@ -125,14 +125,14 @@ char *ubit_dump(const uint8_t *bits, unsigned int len) return hexd_buff; } -char *hexdump(const unsigned char *buf, int len) +char *osmo_hexdump(const unsigned char *buf, int len) { - return _hexdump(buf, len, " "); + return _osmo_hexdump(buf, len, " "); } -char *hexdump_nospc(const unsigned char *buf, int len) +char *osmo_osmo_hexdump_nospc(const unsigned char *buf, int len) { - return _hexdump(buf, len, ""); + return _osmo_hexdump(buf, len, ""); } #include "../config.h" -- 1.7.2.3 From pablo at gnumonks.org Sat May 7 11:25:57 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 7 May 2011 13:25:57 +0200 Subject: [PATCH 2/5] crc: use namespace prefix osmo_* In-Reply-To: <1304767560-25218-1-git-send-email-pablo@gnumonks.org> References: <1304767560-25218-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304767560-25218-2-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/crc16_table/osmo_crc16_table/g s/crc16/osmo_crc16/g s/crc16_byte/osmo_crc16_byte/g --- include/osmocom/core/crc16.h | 8 ++++---- src/crc16.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/osmocom/core/crc16.h b/include/osmocom/core/crc16.h index 7a51249..0e52417 100644 --- a/include/osmocom/core/crc16.h +++ b/include/osmocom/core/crc16.h @@ -22,13 +22,13 @@ #include -extern uint16_t const crc16_table[256]; +extern uint16_t const osmo_crc16_table[256]; -extern uint16_t crc16(uint16_t crc, const uint8_t *buffer, size_t len); +extern uint16_t osmo_crc16(uint16_t crc, const uint8_t *buffer, size_t len); -static inline uint16_t crc16_byte(uint16_t crc, const uint8_t data) +static inline uint16_t osmo_crc16_byte(uint16_t crc, const uint8_t data) { - return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff]; + return (crc >> 8) ^ osmo_crc16_table[(crc ^ data) & 0xff]; } #endif /* __CRC16_H */ diff --git a/src/crc16.c b/src/crc16.c index 3a0d0dd..2741cf5 100644 --- a/src/crc16.c +++ b/src/crc16.c @@ -11,7 +11,7 @@ #include /** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */ -uint16_t const crc16_table[256] = { +uint16_t const osmo_crc16_table[256] = { 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, @@ -54,9 +54,9 @@ uint16_t const crc16_table[256] = { * * Returns the updated CRC value. */ -uint16_t crc16(uint16_t crc, uint8_t const *buffer, size_t len) +uint16_t osmo_crc16(uint16_t crc, uint8_t const *buffer, size_t len) { while (len--) - crc = crc16_byte(crc, *buffer++); + crc = osmo_crc16_byte(crc, *buffer++); return crc; } -- 1.7.2.3 From pablo at gnumonks.org Sat May 7 11:25:58 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 7 May 2011 13:25:58 +0200 Subject: [PATCH 3/5] backtrace: use namespace prefix osmo_* In-Reply-To: <1304767560-25218-1-git-send-email-pablo@gnumonks.org> References: <1304767560-25218-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304767560-25218-3-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/backtrace/osmo_backtrace/g --- include/osmocom/core/backtrace.h | 2 +- src/backtrace.c | 2 +- src/panic.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/osmocom/core/backtrace.h b/include/osmocom/core/backtrace.h index bbbb2c2..5a8a816 100644 --- a/include/osmocom/core/backtrace.h +++ b/include/osmocom/core/backtrace.h @@ -1,6 +1,6 @@ #ifndef _OSMO_BACKTRACE_H_ #define _OSMO_BACKTRACE_H_ -void generate_backtrace(); +void osmo_generate_backtrace(); #endif diff --git a/src/backtrace.c b/src/backtrace.c index ecd6b9c..8281fad 100644 --- a/src/backtrace.c +++ b/src/backtrace.c @@ -29,7 +29,7 @@ #ifdef HAVE_EXECINFO_H #include -void generate_backtrace() +void osmo_generate_backtrace() { int i, nptrs; void *buffer[100]; diff --git a/src/panic.c b/src/panic.c index 588a5fe..d445226 100644 --- a/src/panic.c +++ b/src/panic.c @@ -38,7 +38,7 @@ static osmo_panic_handler_t osmo_panic_handler = (void*)0; static void osmo_panic_default(const char *fmt, va_list args) { vfprintf(stderr, fmt, args); - generate_backtrace(); + osmo_generate_backtrace(); abort(); } -- 1.7.2.3 From pablo at gnumonks.org Sat May 7 11:25:59 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 7 May 2011 13:25:59 +0200 Subject: [PATCH 4/5] plugin: use namespace prefix osmo_* In-Reply-To: <1304767560-25218-1-git-send-email-pablo@gnumonks.org> References: <1304767560-25218-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304767560-25218-4-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/plugin_load_all/osmo_plugin_load_all/g --- include/osmocom/core/plugin.h | 2 +- src/gsm/gprs_cipher_core.c | 2 +- src/plugin.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/osmocom/core/plugin.h b/include/osmocom/core/plugin.h index 98f9b56..6c0eccc 100644 --- a/include/osmocom/core/plugin.h +++ b/include/osmocom/core/plugin.h @@ -1,6 +1,6 @@ #ifndef _OSMO_PLUGIN_H #define _OSMO_PLUGIN_H -int plugin_load_all(const char *directory); +int osmo_plugin_load_all(const char *directory); #endif diff --git a/src/gsm/gprs_cipher_core.c b/src/gsm/gprs_cipher_core.c index 0ff85e2..7884be0 100644 --- a/src/gsm/gprs_cipher_core.c +++ b/src/gsm/gprs_cipher_core.c @@ -53,7 +53,7 @@ int gprs_cipher_register(struct gprs_cipher_impl *ciph) int gprs_cipher_load(const char *path) { /* load all plugins available from path */ - return plugin_load_all(path); + return osmo_plugin_load_all(path); } /* function to be called by core code */ diff --git a/src/plugin.c b/src/plugin.c index 4d9fd31..998bca3 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -32,7 +32,7 @@ #include -int plugin_load_all(const char *directory) +int osmo_plugin_load_all(const char *directory) { unsigned int num = 0; char fname[PATH_MAX]; @@ -55,7 +55,7 @@ int plugin_load_all(const char *directory) return num; } #else -int plugin_load_all(const char *directory) +int osmo_plugin_load_all(const char *directory) { return 0; } -- 1.7.2.3 From pablo at gnumonks.org Sat May 7 11:26:00 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 7 May 2011 13:26:00 +0200 Subject: [PATCH 5/5] msgfile: use namespace prefix osmo_* and use more descriptive names In-Reply-To: <1304767560-25218-1-git-send-email-pablo@gnumonks.org> References: <1304767560-25218-1-git-send-email-pablo@gnumonks.org> Message-ID: <1304767560-25218-5-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso Summary of changes: s/msg_entry/osmo_config_entry/g s/msg_entries/osmo_config_list/g s/msg_entry_parse/osmo_config_list_parse/g minor glitch included in this patch while I was at it: -#include "linuxlist.h" +#include --- include/osmocom/core/msgfile.h | 8 ++++---- src/msgfile.c | 22 ++++++++++++---------- tests/msgfile/msgfile_test.c | 8 ++++---- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/osmocom/core/msgfile.h b/include/osmocom/core/msgfile.h index 92caa9f..c5e67a4 100644 --- a/include/osmocom/core/msgfile.h +++ b/include/osmocom/core/msgfile.h @@ -22,12 +22,12 @@ #ifndef MSG_FILE_H #define MSG_FILE_H -#include "linuxlist.h" +#include /** * One message in the list. */ -struct msg_entry { +struct osmo_config_entry { struct llist_head list; /* number for everyone to use */ @@ -40,10 +40,10 @@ struct msg_entry { char *text; }; -struct msg_entries { +struct osmo_config_list { struct llist_head entry; }; -struct msg_entries *msg_entry_parse(void *ctx, const char *filename); +struct osmo_config_list* osmo_config_list_parse(void *ctx, const char *filename); #endif diff --git a/src/msgfile.c b/src/msgfile.c index c13df51..d2b180d 100644 --- a/src/msgfile.c +++ b/src/msgfile.c @@ -29,11 +29,13 @@ #include #include -static struct msg_entry *alloc_entry(struct msg_entries *entries, - const char *mcc, const char *mnc, - const char *option, const char *text) +static struct osmo_config_entry * +alloc_entry(struct osmo_config_list *entries, + const char *mcc, const char *mnc, + const char *option, const char *text) { - struct msg_entry *entry = talloc_zero(entries, struct msg_entry); + struct osmo_config_entry *entry = + talloc_zero(entries, struct osmo_config_entry); if (!entry) return NULL; @@ -46,11 +48,11 @@ static struct msg_entry *alloc_entry(struct msg_entries *entries, return entry; } -static struct msg_entries *alloc_entries(void *ctx) +static struct osmo_config_list *alloc_entries(void *ctx) { - struct msg_entries *entries; + struct osmo_config_list *entries; - entries = talloc_zero(ctx, struct msg_entries); + entries = talloc_zero(ctx, struct osmo_config_list); if (!entries) return NULL; @@ -61,7 +63,7 @@ static struct msg_entries *alloc_entries(void *ctx) /* * split a line like 'foo:Text'. */ -static void handle_line(struct msg_entries *entries, char *line) +static void handle_line(struct osmo_config_list *entries, char *line) { int i; const int len = strlen(line); @@ -91,9 +93,9 @@ static void handle_line(struct msg_entries *entries, char *line) /* nothing found */ } -struct msg_entries *msg_entry_parse(void *ctx, const char *filename) +struct osmo_config_list *osmo_config_list_parse(void *ctx, const char *filename) { - struct msg_entries *entries; + struct osmo_config_list *entries; size_t n; char *line; FILE *file; diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c index 4637cea..ed7aa97 100644 --- a/tests/msgfile/msgfile_test.c +++ b/tests/msgfile/msgfile_test.c @@ -23,9 +23,9 @@ #include -static void dump_entries(struct msg_entries *entries) +static void dump_entries(struct osmo_config_list *entries) { - struct msg_entry *entry; + struct osmo_config_entry *entry; if (!entries) { fprintf(stderr, "Failed to parse the file\n"); @@ -40,10 +40,10 @@ static void dump_entries(struct msg_entries *entries) int main(int argc, char **argv) { - struct msg_entries *entries; + struct osmo_config_list *entries; /* todo use msgfile_test.c.in and replace the path */ - entries = msg_entry_parse(NULL, "msgconfig.cfg"); + entries = osmo_config_list_parse(NULL, "msgconfig.cfg"); dump_entries(entries); return 0; -- 1.7.2.3 From laforge at gnumonks.org Sun May 8 08:31:22 2011 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 8 May 2011 10:31:22 +0200 Subject: cellmgr-ng / libosmocore namespace changes Message-ID: <20110508083122.GD16877@prithivi.gnumonks.org> Hi Holger, for your convenience I have prepared a branch that makes cellmgr-ng compile against the recent libosmocore namespace changes. You can find it in 'cellmgr-ng.git:laforge/namespace' Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Sun May 8 10:01:59 2011 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 8 May 2011 12:01:59 +0200 Subject: [ADM] osmocom.org via IPv6 Message-ID: <20110508100158.GG16877@prithivi.gnumonks.org> Hi all, JFYI: For a couple of days, *.osmocom.org is reachable via IPv6. I've had native IPv6 at my co-located servers for more than 10 years, but somehow never configured it for the virtual machines like *.osmocom.org - this is now fixed. If you encounter any difficulties, please let me know. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Sun May 8 12:20:41 2011 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 8 May 2011 14:20:41 +0200 Subject: [ANN] libosmocore stable API/ABI Message-ID: <20110508122041.GI16877@prithivi.gnumonks.org> Hi all! I think now that the namespace issues in libosmocore have been resolved, we seriously have to think of maintaining a stable API and ABI. This allows us to have truly independent library and application releases, and the dynamic linker library versioning support should ensure compatibility. So please think twice about any modifying libosmocore. It is safe to add new functions, but we cannot change the prototypes (number of arguments) for existing functions. As soon as new functions are introduced, we should increment the library interface number. For more information, see http://www.gnu.org/software/libtool/manual/libtool.html#Versioning especially the rules in Chapter 7.3: # If the library source code has changed at all since the last update, then increment revision (?c:r:a? becomes ?c:r+1:a?). # If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0. # If any interfaces have been added since the last public release, then increment age. # If any interfaces have been removed or changed since the last public release, then set age to 0. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From pablo at gnumonks.org Sun May 8 16:57:37 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Sun, 08 May 2011 18:57:37 +0200 Subject: [ANN] libosmocore stable API/ABI In-Reply-To: <20110508122041.GI16877@prithivi.gnumonks.org> References: <20110508122041.GI16877@prithivi.gnumonks.org> Message-ID: <4DC6CB81.2040000@gnumonks.org> On 08/05/11 14:20, Harald Welte wrote: > Hi all! > > I think now that the namespace issues in libosmocore have been resolved, > we seriously have to think of maintaining a stable API and ABI. This > allows us to have truly independent library and application releases, > and the dynamic linker library versioning support should ensure > compatibility. Would it be worth if we make opaque declaration of some structures opaque? e.g. struct osmo_timer_list in the header file, and the real declaration in Encapsulation is good to avoid breaking backward compatibility. Not sure if we expect that this structure would ever change. Let me know if I'm being too conservative :-). > So please think twice about any modifying libosmocore. It is safe to > add new functions, but we cannot change the prototypes (number of > arguments) for existing functions. > > As soon as new functions are introduced, we should increment the library > interface number. > > For more information, see > http://www.gnu.org/software/libtool/manual/libtool.html#Versioning > especially the rules in Chapter 7.3: > > # If the library source code has changed at all since the last update, > then increment revision (?c:r:a? becomes ?c:r+1:a?). > # If any interfaces have been added, removed, or changed since the last > update, increment current, and set revision to 0. > # If any interfaces have been added since the last public release, then > increment age. > # If any interfaces have been removed or changed since the last public > release, then set age to 0. I think that we should also use a map file [1] and the EXPORT_SYMBOL declaration [2]. I can make a patch to support this. These references point to libmnl as one example of mine: [1] http://git.netfilter.org/cgi-bin/gitweb.cgi?p=libmnl.git;a=blob;f=src/libmnl.map;h=3147ae099f35b72a86bb74ffb19f9214bf187728;hb=HEAD [2] http://git.netfilter.org/cgi-bin/gitweb.cgi?p=libmnl.git;a=blob;f=src/internal.h;h=3a88d1a1f7d8b00c73a9e77524796811df7e9653;hb=HEAD From laforge at gnumonks.org Sun May 8 17:42:55 2011 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 8 May 2011 19:42:55 +0200 Subject: [ANN] libosmocore stable API/ABI In-Reply-To: <4DC6CB81.2040000@gnumonks.org> References: <20110508122041.GI16877@prithivi.gnumonks.org> <4DC6CB81.2040000@gnumonks.org> Message-ID: <20110508174255.GA11457@prithivi.gnumonks.org> Hi Pablo, On Sun, May 08, 2011 at 06:57:37PM +0200, Pablo Neira Ayuso wrote: > > I think now that the namespace issues in libosmocore have been resolved, > > we seriously have to think of maintaining a stable API and ABI. This > > allows us to have truly independent library and application releases, > > and the dynamic linker library versioning support should ensure > > compatibility. > > Would it be worth if we make opaque declaration of some structures > opaque? e.g. struct osmo_timer_list in the header file, and the real > declaration in I think this would be too much at this point. I also think we don't have any 'illegitimate' use of the structures, and we are only using the libraries from a couple of programs that all come 'from the same family' > I think that we should also use a map file [1] and the EXPORT_SYMBOL > declaration [2]. same here. I think for now it only creates additional work without much benefit from it. The EXPORT_SYMBOL stuff only becomes interesting once we have calls to private functions between multiple .o files. Rigth now off my head they only case where this would make practical sense is for libosmovty, where we have lots of buffer.c and cmd.c calls from within vty.c which shouldn't be public at all. I would definitely welcome a patch to that regard. Rather than spending time on map files and private/public header files, I would be more open to some kerneldoc or doxygen comments in the code, in order to generate some official libosmocore API documentation. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From christopher.henard at esial.net Tue May 10 08:31:31 2011 From: christopher.henard at esial.net (Christopher HENARD) Date: Tue, 10 May 2011 10:31:31 +0200 Subject: Questions Message-ID: Hello everyone, 1) Is it possible to act as a nano BTS and send packets to open BSC ? But how to do that since openBSC uses config files (openbsc.cfg.nanobts, ...) ? 2)I can't get last source code with git, the command always results in a timeout: git clone git://git.osmocom.org/openbsc.git Cloning into openbsc... git.osmocom.org[0: 213.95.46.201]: errno=Connection timed out git.osmocom.org[0: 2001:780:45:f046::201]: errno=Network is unreachable fatal: unable to connect a socket (Network is unreachable) Would that be possible to update the tarballs on the wiki? It seems the current tarball of openBSC (http://openbsc.osmocom.org/trac/wiki) doesn't contains config files in the osmo-nitb directory. There's only source and makefile. The wiki mention 'OpenBSC has a configuration file. The default config file name is *openbsc.cfg* in the current working directory of the osmo-nitb process.' Thank you, Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Tue May 10 09:12:40 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 10 May 2011 11:12:40 +0200 Subject: Questions In-Reply-To: References: Message-ID: <4DC90188.4020401@freyther.de> On 05/10/2011 10:31 AM, Christopher HENARD wrote: > Hello everyone, > > 1) Is it possible to act as a nano BTS and send packets to open BSC ? But how > to do that since openBSC uses config files (openbsc.cfg.nanobts, ...) ? well... you could start from the ipaccess-proxy code, or Andreas's GSM BTS work, or someone else posted another implementation. > > 2)I can't get last source code with git, the command always results in a timeout: You should talk to the IT department of your company, they firewall the GIT port. You can take a look at repo.or.cz that should have a OpenBSC mirror that is accessible via HTTP. In case projects like libosmocore are missing there, you can create them at repo.or.cz From christopher.henard at esial.net Tue May 10 14:33:40 2011 From: christopher.henard at esial.net (Christopher HENARD) Date: Tue, 10 May 2011 16:33:40 +0200 Subject: Questions In-Reply-To: <4DC90188.4020401@freyther.de> References: <4DC90188.4020401@freyther.de> Message-ID: Ok, I'll try with ipaccess-proxy code since I don't know what is Andrea's GSM BTS. However, the process osmo-nitb need a config file to start, and as I want to simulate nano BTS and forge IP packets, what config file am I supposed to provide to osmo-nitb? Thank you 2011/5/10 Holger Hans Peter Freyther > On 05/10/2011 10:31 AM, Christopher HENARD wrote: > > Hello everyone, > > > > 1) Is it possible to act as a nano BTS and send packets to open BSC ? But > how > > to do that since openBSC uses config files (openbsc.cfg.nanobts, ...) ? > > well... you could start from the ipaccess-proxy code, or Andreas's GSM BTS > work, or someone else posted another implementation. > > > > > 2)I can't get last source code with git, the command always results in a > timeout: > > You should talk to the IT department of your company, they firewall the GIT > port. You can take a look at repo.or.cz that should have a OpenBSC mirror > that > is accessible via HTTP. In case projects like libosmocore are missing > there, > you can create them at repo.or.cz > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at gnumonks.org Tue May 10 15:02:02 2011 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 10 May 2011 17:02:02 +0200 Subject: Questions In-Reply-To: References: <4DC90188.4020401@freyther.de> Message-ID: <20110510150202.GG9012@prithivi.gnumonks.org> On Tue, May 10, 2011 at 04:33:40PM +0200, Christopher HENARD wrote: > Ok, I'll try with ipaccess-proxy code since I don't know what is Andrea's > GSM BTS. see the osmo-bts.git repository on git.osmocom.org > However, the process osmo-nitb need a config file to start, and as I want to > simulate nano BTS and forge IP packets, what config file am I supposed to > provide to osmo-nitb? openbsc.cfg.nanobts or something along those lines. > Thank you -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From christopher.henard at esial.net Tue May 10 16:03:01 2011 From: christopher.henard at esial.net (Christopher HENARD) Date: Tue, 10 May 2011 18:03:01 +0200 Subject: Questions In-Reply-To: <20110510150202.GG9012@prithivi.gnumonks.org> References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> Message-ID: Ok, I'll see that, thanks. 2011/5/10 Harald Welte > On Tue, May 10, 2011 at 04:33:40PM +0200, Christopher HENARD wrote: > > Ok, I'll try with ipaccess-proxy code since I don't know what is Andrea's > > GSM BTS. > > see the osmo-bts.git repository on git.osmocom.org > > > However, the process osmo-nitb need a config file to start, and as I want > to > > simulate nano BTS and forge IP packets, what config file am I supposed to > > provide to osmo-nitb? > > openbsc.cfg.nanobts or something along those lines. > > > Thank you > -- > - Harald Welte > http://laforge.gnumonks.org/ > > ============================================================================ > "Privacy in residential applications is a desirable marketing option." > (ETSI EN 300 175-7 Ch. A6) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From christopher.henard at esial.net Wed May 11 08:30:59 2011 From: christopher.henard at esial.net (Christopher HENARD) Date: Wed, 11 May 2011 10:30:59 +0200 Subject: Questions In-Reply-To: References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> Message-ID: Hi everyone, As I said in previous messages, I want to write a program to dialogue with openBSC (more precisely, osmo-nitb) In fact I tried to compile osmo-bts but it seems some structures are not even define anywhere (struct osmobts_ms, struct osmol2_entity...). I know it's still under development but I can't test the main program and read the code is a little bit long. For ipaccess-proxy, the main thread also starts bsc_select_main, resulting in osmo-nitb and proxy both waiting for something but nothing happens. That brings these questions: Is there any documentation of the code of open BSC ? Are all the protocols of Abis interface implemented (LAPD, BTSM, RR) ? If yes, where can they be found in the code and is it possible to use them externally to forge packets ? Is it possible to connect 2 open BSC together ? What are the requirements? In the main loop of osmo-nitb, what are the message open BSC is waiting for (bsc_select_main)? Do you think it would be possible that a SMSC communicate with open BSC ? What are the requirements? Have you implemented part of the SS7 stacks (mtp, SCCP, ...) ? Thank you 2011/5/10 Christopher HENARD > Ok, I'll see that, thanks. > > > 2011/5/10 Harald Welte > >> On Tue, May 10, 2011 at 04:33:40PM +0200, Christopher HENARD wrote: >> > Ok, I'll try with ipaccess-proxy code since I don't know what is >> Andrea's >> > GSM BTS. >> >> see the osmo-bts.git repository on git.osmocom.org >> >> > However, the process osmo-nitb need a config file to start, and as I >> want to >> > simulate nano BTS and forge IP packets, what config file am I supposed >> to >> > provide to osmo-nitb? >> >> openbsc.cfg.nanobts or something along those lines. >> >> > Thank you >> -- >> - Harald Welte >> http://laforge.gnumonks.org/ >> >> ============================================================================ >> "Privacy in residential applications is a desirable marketing option." >> (ETSI EN 300 175-7 Ch. >> A6) >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bouchtaoui at gmail.com Wed May 11 08:44:53 2011 From: bouchtaoui at gmail.com (Nordin) Date: Wed, 11 May 2011 10:44:53 +0200 Subject: Questions In-Reply-To: References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> Message-ID: <4DCA4C85.4030701@gmail.com> I think you better try OpenBSC with a real nanoBTS if you own one. If that works, you can analize the traffice between OpenBSC and nanoBTS. You can than simulate packages as nanoBTS packages to OpenBSC and you get what you want I think. Hope this helps. On 11-5-2011 10:30, Christopher HENARD wrote: > Hi everyone, > > As I said in previous messages, I want to write a program to dialogue with > openBSC (more precisely, osmo-nitb) > > In fact I tried to compile osmo-bts but it seems some structures are not > even define anywhere (struct osmobts_ms, struct osmol2_entity...). I know > it's still under development but I can't test the main program and read the > code is a little bit long. > > For ipaccess-proxy, the main thread also starts bsc_select_main, resulting > in osmo-nitb and proxy both waiting for something but nothing happens. That > brings these questions: > > Is there any documentation of the code of open BSC ? > Are all the protocols of Abis interface implemented (LAPD, BTSM, RR) ? If > yes, where can they be found in the code and is it possible to use them > externally to forge packets ? > Is it possible to connect 2 open BSC together ? What are the requirements? > In the main loop of osmo-nitb, what are the message open BSC is waiting for > (bsc_select_main)? > Do you think it would be possible that a SMSC communicate with open BSC ? > What are the requirements? > Have you implemented part of the SS7 stacks (mtp, SCCP, ...) ? > > Thank you > > 2011/5/10 Christopher HENARD > >> Ok, I'll see that, thanks. >> >> >> 2011/5/10 Harald Welte >> >>> On Tue, May 10, 2011 at 04:33:40PM +0200, Christopher HENARD wrote: >>>> Ok, I'll try with ipaccess-proxy code since I don't know what is >>> Andrea's >>>> GSM BTS. >>> see the osmo-bts.git repository on git.osmocom.org >>> >>>> However, the process osmo-nitb need a config file to start, and as I >>> want to >>>> simulate nano BTS and forge IP packets, what config file am I supposed >>> to >>>> provide to osmo-nitb? >>> openbsc.cfg.nanobts or something along those lines. >>> >>>> Thank you >>> -- >>> - Harald Welte >>> http://laforge.gnumonks.org/ >>> >>> ============================================================================ >>> "Privacy in residential applications is a desirable marketing option." >>> (ETSI EN 300 175-7 Ch. >>> A6) >>> >> From christopher.henard at esial.net Wed May 11 09:17:08 2011 From: christopher.henard at esial.net (Christopher HENARD) Date: Wed, 11 May 2011 11:17:08 +0200 Subject: Questions In-Reply-To: <4DCA4C85.4030701@gmail.com> References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> <4DCA4C85.4030701@gmail.com> Message-ID: Yes I know it would be easier but I unfortunately don't have a nanoBTS. 2011/5/11 Nordin > I think you better try OpenBSC with a real nanoBTS if you own one. If that > works, you can analize the traffice between OpenBSC and nanoBTS. You can > than simulate packages as nanoBTS packages to OpenBSC and you get what you > want I think. Hope this helps. > > > > > On 11-5-2011 10:30, Christopher HENARD wrote: > >> Hi everyone, >> >> As I said in previous messages, I want to write a program to dialogue with >> openBSC (more precisely, osmo-nitb) >> >> In fact I tried to compile osmo-bts but it seems some structures are not >> even define anywhere (struct osmobts_ms, struct osmol2_entity...). I know >> it's still under development but I can't test the main program and read >> the >> code is a little bit long. >> >> For ipaccess-proxy, the main thread also starts bsc_select_main, resulting >> in osmo-nitb and proxy both waiting for something but nothing happens. >> That >> brings these questions: >> >> Is there any documentation of the code of open BSC ? >> Are all the protocols of Abis interface implemented (LAPD, BTSM, RR) ? If >> yes, where can they be found in the code and is it possible to use them >> externally to forge packets ? >> Is it possible to connect 2 open BSC together ? What are the requirements? >> In the main loop of osmo-nitb, what are the message open BSC is waiting >> for >> (bsc_select_main)? >> Do you think it would be possible that a SMSC communicate with open BSC ? >> What are the requirements? >> Have you implemented part of the SS7 stacks (mtp, SCCP, ...) ? >> >> Thank you >> >> 2011/5/10 Christopher HENARD >> >> Ok, I'll see that, thanks. >>> >>> >>> 2011/5/10 Harald Welte >>> >>> On Tue, May 10, 2011 at 04:33:40PM +0200, Christopher HENARD wrote: >>>> >>>>> Ok, I'll try with ipaccess-proxy code since I don't know what is >>>>> >>>> Andrea's >>>> >>>>> GSM BTS. >>>>> >>>> see the osmo-bts.git repository on git.osmocom.org >>>> >>>> However, the process osmo-nitb need a config file to start, and as I >>>>> >>>> want to >>>> >>>>> simulate nano BTS and forge IP packets, what config file am I supposed >>>>> >>>> to >>>> >>>>> provide to osmo-nitb? >>>>> >>>> openbsc.cfg.nanobts or something along those lines. >>>> >>>> Thank you >>>>> >>>> -- >>>> - Harald Welte >>>> http://laforge.gnumonks.org/ >>>> >>>> >>>> ============================================================================ >>>> "Privacy in residential applications is a desirable marketing option." >>>> (ETSI EN 300 175-7 Ch. >>>> A6) >>>> >>>> >>> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From christopher.henard at esial.net Wed May 11 09:18:55 2011 From: christopher.henard at esial.net (Christopher HENARD) Date: Wed, 11 May 2011 11:18:55 +0200 Subject: Questions In-Reply-To: References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> <4DCA4C85.4030701@gmail.com> Message-ID: May be someone has wireshark capture for me ? 2011/5/11 Christopher HENARD > Yes I know it would be easier but I unfortunately don't have a nanoBTS. > > > 2011/5/11 Nordin > >> I think you better try OpenBSC with a real nanoBTS if you own one. If >> that works, you can analize the traffice between OpenBSC and nanoBTS. You >> can than simulate packages as nanoBTS packages to OpenBSC and you get what >> you want I think. Hope this helps. >> >> >> >> >> On 11-5-2011 10:30, Christopher HENARD wrote: >> >>> Hi everyone, >>> >>> As I said in previous messages, I want to write a program to dialogue >>> with >>> openBSC (more precisely, osmo-nitb) >>> >>> In fact I tried to compile osmo-bts but it seems some structures are not >>> even define anywhere (struct osmobts_ms, struct osmol2_entity...). I know >>> it's still under development but I can't test the main program and read >>> the >>> code is a little bit long. >>> >>> For ipaccess-proxy, the main thread also starts bsc_select_main, >>> resulting >>> in osmo-nitb and proxy both waiting for something but nothing happens. >>> That >>> brings these questions: >>> >>> Is there any documentation of the code of open BSC ? >>> Are all the protocols of Abis interface implemented (LAPD, BTSM, RR) ? If >>> yes, where can they be found in the code and is it possible to use them >>> externally to forge packets ? >>> Is it possible to connect 2 open BSC together ? What are the >>> requirements? >>> In the main loop of osmo-nitb, what are the message open BSC is waiting >>> for >>> (bsc_select_main)? >>> Do you think it would be possible that a SMSC communicate with open BSC ? >>> What are the requirements? >>> Have you implemented part of the SS7 stacks (mtp, SCCP, ...) ? >>> >>> Thank you >>> >>> 2011/5/10 Christopher HENARD >>> >>> Ok, I'll see that, thanks. >>>> >>>> >>>> 2011/5/10 Harald Welte >>>> >>>> On Tue, May 10, 2011 at 04:33:40PM +0200, Christopher HENARD wrote: >>>>> >>>>>> Ok, I'll try with ipaccess-proxy code since I don't know what is >>>>>> >>>>> Andrea's >>>>> >>>>>> GSM BTS. >>>>>> >>>>> see the osmo-bts.git repository on git.osmocom.org >>>>> >>>>> However, the process osmo-nitb need a config file to start, and as I >>>>>> >>>>> want to >>>>> >>>>>> simulate nano BTS and forge IP packets, what config file am I supposed >>>>>> >>>>> to >>>>> >>>>>> provide to osmo-nitb? >>>>>> >>>>> openbsc.cfg.nanobts or something along those lines. >>>>> >>>>> Thank you >>>>>> >>>>> -- >>>>> - Harald Welte >>>>> http://laforge.gnumonks.org/ >>>>> >>>>> >>>>> ============================================================================ >>>>> "Privacy in residential applications is a desirable marketing option." >>>>> (ETSI EN 300 175-7 Ch. >>>>> A6) >>>>> >>>>> >>>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Wed May 11 09:34:50 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 11 May 2011 11:34:50 +0200 Subject: Questions In-Reply-To: References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> <4DCA4C85.4030701@gmail.com> Message-ID: <4DCA583A.5030707@freyther.de> On 05/11/2011 11:18 AM, Christopher HENARD wrote: > May be someone has wireshark capture for me ? Good question, maybe it is better to ask the other way around. Right now it seems that you do not want to use OpenBSC in itself but use it to learn about GSM. Is this correct? What part of GSM are you interested in, what do you want to learn? What is your motivation? holger From christopher.henard at esial.net Wed May 11 09:53:09 2011 From: christopher.henard at esial.net (Christopher HENARD) Date: Wed, 11 May 2011 11:53:09 +0200 Subject: Questions In-Reply-To: <4DCA583A.5030707@freyther.de> References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> <4DCA4C85.4030701@gmail.com> <4DCA583A.5030707@freyther.de> Message-ID: I would like to be able to simulate a GSM network in order to be able to develop and test an SMSC in an IP network. However, I don't have any BTS at the moment, and I don't know if I'll have one later. It's not I want to learn about GSM, it's just I can't use openBSC itself. Since openBSC acts like BSC/MSC/HLR (if we have BTS), then it's theoretically possible to communicate with it (for instance from SMSC). That's why I asked the previous questions and I'll be pleased if someone could answer them. Thank you 2011/5/11 Holger Hans Peter Freyther > On 05/11/2011 11:18 AM, Christopher HENARD wrote: > > May be someone has wireshark capture for me ? > > Good question, > > maybe it is better to ask the other way around. Right now it seems that you > do > not want to use OpenBSC in itself but use it to learn about GSM. Is this > correct? What part of GSM are you interested in, what do you want to learn? > What is your motivation? > > holger > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Wed May 11 10:00:31 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 11 May 2011 12:00:31 +0200 Subject: Questions In-Reply-To: References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> <4DCA4C85.4030701@gmail.com> <4DCA583A.5030707@freyther.de> Message-ID: <4DCA5E3F.5070205@freyther.de> On 05/11/2011 11:53 AM, Christopher HENARD wrote: > I would like to be able to simulate a GSM network in order to be able to > develop and test an SMSC in an IP network. However, I don't have any BTS at > the moment, and I don't know if I'll have one later. > Hi Tejas, do you think you could release the source of your SMSC. I think nobody will mind if the code is not tidied up, we all have time constraints that force us to make a compromise.. it is natural.. just put a README in the code. Hi Christopher, it appears you have skipped the MSC from your picture? The SMSC will mainly communicate with the MSC, right? I do have a Smalltalk virtual BSC (see cgit.osmocom.org/smalltalk) where adding code to 'terminate/send' SMS would be easy to add to. From christopher.henard at esial.net Wed May 11 10:07:52 2011 From: christopher.henard at esial.net (Christopher HENARD) Date: Wed, 11 May 2011 12:07:52 +0200 Subject: Questions In-Reply-To: <4DCA5E3F.5070205@freyther.de> References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> <4DCA4C85.4030701@gmail.com> <4DCA583A.5030707@freyther.de> <4DCA5E3F.5070205@freyther.de> Message-ID: Hi Holger, It's right the SMSC will communicate with the MSC, but I read openBSC includes MSC service, so I thought I don't have to care with the MSC... Thank you for the link, I'll check tonight, I can't from work (git port blocked).. 2011/5/11 Holger Hans Peter Freyther > On 05/11/2011 11:53 AM, Christopher HENARD wrote: > > I would like to be able to simulate a GSM network in order to be able to > > develop and test an SMSC in an IP network. However, I don't have any BTS > at > > the moment, and I don't know if I'll have one later. > > > > Hi Tejas, > > do you think you could release the source of your SMSC. I think nobody will > mind if the code is not tidied up, we all have time constraints that force > us > to make a compromise.. it is natural.. just put a README in the code. > > > Hi Christopher, > > it appears you have skipped the MSC from your picture? The SMSC will mainly > communicate with the MSC, right? I do have a Smalltalk virtual BSC (see > cgit.osmocom.org/smalltalk) where adding code to 'terminate/send' SMS > would be > easy to add to. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ozmank8 at gmail.com Wed May 11 13:04:32 2011 From: ozmank8 at gmail.com (tejas oza) Date: Wed, 11 May 2011 15:04:32 +0200 Subject: Questions In-Reply-To: <4DCA5E3F.5070205@freyther.de> References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> <4DCA4C85.4030701@gmail.com> <4DCA583A.5030707@freyther.de> <4DCA5E3F.5070205@freyther.de> Message-ID: Hi Holger, Currently we are developing LCS capable GSM Network which includes extension of our MSC ,So I am sorry to say that we are not able to release the code at the moment. And we build the MSC not the SMSC. :) On Wed, May 11, 2011 at 12:00 PM, Holger Hans Peter Freyther < holger at freyther.de> wrote: > On 05/11/2011 11:53 AM, Christopher HENARD wrote: > > I would like to be able to simulate a GSM network in order to be able to > > develop and test an SMSC in an IP network. However, I don't have any BTS > at > > the moment, and I don't know if I'll have one later. > > > > Hi Tejas, > > do you think you could release the source of your SMSC. I think nobody will > mind if the code is not tidied up, we all have time constraints that force > us > to make a compromise.. it is natural.. just put a README in the code. > > > Hi Christopher, > > it appears you have skipped the MSC from your picture? The SMSC will mainly > communicate with the MSC, right? I do have a Smalltalk virtual BSC (see > cgit.osmocom.org/smalltalk) where adding code to 'terminate/send' SMS > would be > easy to add to. > -- *Thanks & Regards Tejas Oza Masters in Computer Science, Department of Information Technology, Uppsala University, Sweden.* -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Wed May 11 13:06:04 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 11 May 2011 15:06:04 +0200 Subject: Questions In-Reply-To: References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> <4DCA4C85.4030701@gmail.com> <4DCA583A.5030707@freyther.de> <4DCA5E3F.5070205@freyther.de> Message-ID: <4DCA89BC.40202@freyther.de> On 05/11/2011 03:04 PM, tejas oza wrote: > Hi Holger, > > Currently we are developing LCS capable GSM Network which includes extension > of our MSC ,So I am sorry to say that we are not able to release the code at > the moment. > What is the concern regarding the sourcecode? From laforge at gnumonks.org Wed May 11 15:13:22 2011 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 11 May 2011 17:13:22 +0200 Subject: Questions In-Reply-To: References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> <4DCA4C85.4030701@gmail.com> <4DCA583A.5030707@freyther.de> Message-ID: <20110511151322.GC15823@prithivi.gnumonks.org> On Wed, May 11, 2011 at 11:53:09AM +0200, Christopher HENARD wrote: > I would like to be able to simulate a GSM network in order to be able to > develop and test an SMSC in an IP network. However, I don't have any BTS at > the moment, and I don't know if I'll have one later. OpenBSC and the various other software we offer in our git repositories are not suitable for this. Neither the C-language nor the Erlang-language SCCP/TCAP/MAP stacks are finished and in s state where you can use them to develop code that talks to your SMSC either. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Wed May 11 10:00:40 2011 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 11 May 2011 12:00:40 +0200 Subject: Questions In-Reply-To: References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> Message-ID: Christopher , please forgive my direct and blunt response: We have been working very hard ro put together rhe existing OpenBSC and related projects. It is all Free Software, ready to be used for whatever tou want to develop with it. Rhe very least you could do is to show some respect by first reading the full wiki and the actual source code in order to understanf what is there and what is not: http://cgit.osmocom.org/ If you want to develop something bases on it, it is your task to find out what the existing code does and how it works. This is not a customer/client relationship and you don't have a support contract! -- Sent from a mobile device, excuse my short response -------------- next part -------------- An HTML attachment was scrubbed... URL: From christopher.henard at esial.net Wed May 11 10:48:38 2011 From: christopher.henard at esial.net (Christopher HENARD) Date: Wed, 11 May 2011 12:48:38 +0200 Subject: Questions In-Reply-To: References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> Message-ID: *"OpenBSC includes functionality normally performed by the following components of a GSM network: BSC (Base Station Controller), MSC (Mobile Switching Center), HLR (Home Location Register), AuC (Authentication Center), VLR (Visitor Location Register), EIR (Equipment Identity Register)."* It's from the first page of the wiki (http://openbsc.osmocom.org/trac/wiki). I confess I havn't read and clearly understood all the source code, but concerning the wiki, I read it more than one time. I don't understand why you're blaming me cause I'm saying that openBSC includes MSC subset. It's written on the wiki. May be I'm just misunderstanding something in the GSM architecture. Anyway, I'm sorry If I hurt you or if you feel I disrespect your work, it's not the case. I"ll not disrupt you anymore with my stupid questions. As a final word, let me thank you for all the work you've done around openBSC and the libs it uses. I appreciate and admire your work. Thank you also for your time and your consideration regarding my questions. 2011/5/11 Harald Welte > Christopher , > > please forgive my direct and blunt response: We have been working very hard > ro put together rhe existing OpenBSC and related projects. It is all Free > Software, ready to be used for whatever tou want to develop with it. > > Rhe very least you could do is to show some respect by first reading the > full wiki and the actual source code in order to understanf what is there > and what is not: http://cgit.osmocom.org/ > > If you want to develop something bases on it, it is your task to find out > what the existing code does and how it works. > > This is not a customer/client relationship and you don't have a support > contract! > > -- > Sent from a mobile device, excuse my short response > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Wed May 11 11:51:03 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Wed, 11 May 2011 13:51:03 +0200 Subject: Questions In-Reply-To: References: <4DC90188.4020401@freyther.de> <20110510150202.GG9012@prithivi.gnumonks.org> Message-ID: <4DCA7827.7090308@freyther.de> On 05/11/2011 12:48 PM, Christopher HENARD wrote: > /"OpenBSC includes functionality normally performed by the following > components of a GSM network: BSC (Base Station Controller), *MSC* (Mobile > Switching Center), HLR (Home Location Register), AuC (Authentication Center), > VLR (Visitor Location Register), EIR (Equipment Identity Register)."/ > The key in this sentence is "includes functionality", yes we have functionality in osmo-nitb that is in the domain of a MSC but we do not have a MSC that implements the A-G protocols to interface with a real network From mortzy at gmail.com Thu May 12 15:20:12 2011 From: mortzy at gmail.com (Steve Mortimer) Date: Thu, 12 May 2011 16:20:12 +0100 Subject: Sim programmer Software for Linux Message-ID: <4DCBFAAC.50908@gmail.com> Hi, I am after recommendations for software that will allow me to program Super SIM's, etc. I have seen the recent thread on programmer's and understand that a CCID compliant reader is recommended. Many thanks, Steve From meierk at informatik.uni-freiburg.de Thu May 12 16:02:05 2011 From: meierk at informatik.uni-freiburg.de (Konrad Meier) Date: Thu, 12 May 2011 18:02:05 +0200 Subject: Sim programmer Software for Linux In-Reply-To: <4DCBFAAC.50908@gmail.com> References: <4DCBFAAC.50908@gmail.com> Message-ID: <4DCC047D.9050202@informatik.uni-freiburg.de> Am 12.05.2011 17:20, schrieb Steve Mortimer: > Hi, > > I am after recommendations for software that will allow me to program > Super SIM's, etc. I have seen the recent thread on programmer's and > understand that a CCID compliant reader is recommended. > Hi Steve, I am using pysim with a "Dell Smart Card Reader Keyboard" and pcsc. This combination woks grate. pysim can be found here: http://cgit.osmocom.org/cgit/ Regards Konrad From mortzy at gmail.com Fri May 13 11:15:31 2011 From: mortzy at gmail.com (Steve Mortimer) Date: Fri, 13 May 2011 12:15:31 +0100 Subject: Sim programmer Software for Linux In-Reply-To: <4DCC047D.9050202@informatik.uni-freiburg.de> References: <4DCBFAAC.50908@gmail.com> <4DCC047D.9050202@informatik.uni-freiburg.de> Message-ID: <4DCD12D3.9050006@gmail.com> On 12/05/11 17:02, Konrad Meier wrote: > Am 12.05.2011 17:20, schrieb Steve Mortimer: >> Hi, >> >> I am after recommendations for software that will allow me to program >> Super SIM's, etc. I have seen the recent thread on programmer's and >> understand that a CCID compliant reader is recommended. >> > > Hi Steve, > > I am using pysim with a "Dell Smart Card Reader Keyboard" and pcsc. > This combination woks grate. > > pysim can be found here: > http://cgit.osmocom.org/cgit/ > > Regards > Konrad > Thanks Konrad, I have a Dell Laptop (E6410) that has a SC reader in it. I have proved it detects a SuperSim installed in it using pcsc_scan. $ pcsc_scan PC/SC device scanner V 1.4.17 (c) 2001-2009, Ludovic Rousseau Compiled with PC/SC lite version: 1.5.5 Scanning present readers... 0: Broadcom 5880 [Broadcom USH] (0123456789ABCD) 00 00 . . However, when I try pysim, I am not sure which options to use for the reader hardware, including the device. Could you let me know what you use? Many thanks, Steve From meierk at informatik.uni-freiburg.de Fri May 13 13:50:46 2011 From: meierk at informatik.uni-freiburg.de (Konrad Meier) Date: Fri, 13 May 2011 15:50:46 +0200 Subject: Sim programmer Software for Linux In-Reply-To: <4DCD12D3.9050006@gmail.com> References: <4DCBFAAC.50908@gmail.com> <4DCC047D.9050202@informatik.uni-freiburg.de> <4DCD12D3.9050006@gmail.com> Message-ID: <4DCD3736.8070707@informatik.uni-freiburg.de> Am 13.05.2011 13:15, schrieb Steve Mortimer: > However, when I try pysim, I am not sure which options to use for the > reader hardware, including the device. Could you let me know what you use? If your pcscd daemon is running you can simply use the -p option of pysim. Example: ./pySim-prog.py -p 0 -n RZ-GSM -c 49 -x 262 -y 23 -j 101 From mortzy at gmail.com Fri May 13 15:44:57 2011 From: mortzy at gmail.com (Steve Mortimer) Date: Fri, 13 May 2011 16:44:57 +0100 Subject: Sim programmer Software for Linux In-Reply-To: <4DCD3736.8070707@informatik.uni-freiburg.de> References: <4DCBFAAC.50908@gmail.com> <4DCC047D.9050202@informatik.uni-freiburg.de> <4DCD12D3.9050006@gmail.com> <4DCD3736.8070707@informatik.uni-freiburg.de> Message-ID: <4DCD51F9.4010202@gmail.com> On 13/05/11 14:50, Konrad Meier wrote: > If your pcscd daemon is running you can simply use the -p option of > pysim. > > Example: > ./pySim-prog.py -p 0 -n RZ-GSM -c 49 -x 262 -y 23 -j 101 > Thanks Konrad, I just needed to add -t supersim and it now works. From laforge at gnumonks.org Thu May 12 18:09:37 2011 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 12 May 2011 20:09:37 +0200 Subject: Planning for Radio Village at 2011 CCC Camp Message-ID: <20110512180936.GA25011@prithivi.gnumonks.org> Hi all! [This message is cross-posted to many lists, please be careful when replying to it! Think twice if your respones really matters to all those projects...] In order to do some better planning for our Camp activities this summer, I would like to request all people who intend to participate in the radio village to add themselves to the wiki: https://events.ccc.de/camp/2011/wiki/index.php/RadioVillage The list of citizens is auto-generated if you use Person template like I have done in my user page at https://events.ccc.de/camp/2011/wiki/index.php/User:LaForge The large main tent is not really intended as a place to sleep, but more like a place where we set up our gear and work on the various projects, similar to what happened at HAR. Thanks in advance! -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 190 bytes Desc: Digital signature URL: From peter.hasse at fokus.fraunhofer.de Fri May 13 09:09:47 2011 From: peter.hasse at fokus.fraunhofer.de (Peter Hasse) Date: Fri, 13 May 2011 11:09:47 +0200 Subject: FrOSCon 2011 - DevRoom anyone? Message-ID: <4DCCF55B.2070901@fokus.fraunhofer.de> Hi I'm happy to invite you to the up comming FrOSCon. Like last year we can offer a developer room for the weekend and a official Licences to use one RFCN. We would futher be me more than happy to find some opensource GSM talks in our CFP. The FrOSCon 2011 takes palce in Sank Ausgustin near Bonn in Germany from the 20. to 21. August (one week after the CCC Camp). Below you find the offical CFP invite email. Looking forward to see some of you at FrOSCon 2011 mfg Peter Meanwhile, preparations for the sixth FrOSCon are well underway. This year's FrOSCon takes place on August 20th/21st 2011. We thought you might be interested to hear that the Call for Projects has started. If you as a project want to participate again, please visit https://callforprojects.froscon.org/ and sign up for a room or booth, depending on your needs. Since the demand for developer rooms and booths exceeds the number of rooms and booth we can offer, we need a short summary (1-2 paragraphs) of what you plan to do. On the basis of this text we will choose the projects that appear most promising to us. The deadline for submission of projects is 23rd May 2011. Additionally our Call for Papers has started, so we are looking forward to your submissions of talks. Please visit http://www.froscon.de/en/program/call- for-papers.html for further information. The Call for Papers will end on 23rd May 2011 If you have questions concerning the developer rooms feel free to contact projects at froscon.org . For questions concerning a booth contact exhibitors at froscon.org We would love to see all of you again in August. Also, please spread the word and help make this year's FrOSCon's special. Kind regards, Patrick Hallen The FrOSCon Team -- Address: FrOSCon e.V. c/o FH Bonn-Rhein-Sieg Grantham-Allee 20 53757 Sankt Augustin E-Mail: projects at froscon.org Homepage: http://www.froscon.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From hwelte at sysmocom.de Fri May 13 16:39:18 2011 From: hwelte at sysmocom.de (Harald Welte) Date: Fri, 13 May 2011 18:39:18 +0200 Subject: Osmocom project vs. sysmocom GmbH Message-ID: <20110513163918.GU25011@prithivi.gnumonks.org> Hi all! As some of you already know, Holger and I have recently started a new company called "sysmocom - systems for mobile communications GmbH". The process of establishing the new company has now formally concluded. Before some rumours start to spread, we would like to clarify some points and make sure there is mutual understanding between the Osmocom community and the sysmocom company. sysmocom is intended to provide commercial offerings related to the Osmocom projects. This is not entirely new. Especially on the network side, people like Holger and I have been doing quite a lot of paid development to bring those projects forward. We would not have many of the features we have today, if it wasn't for customers who actually pay us for development of OpenBSC, OsmoBSC, OsmoSGSN and the various side projects more targetted at a real network operator like cellmgr-ng, bsc-nat, gb_proxy - just to name a few. However, this has always only been freelancing development of Software. With sysmocom, we want to go one step further and work on hardware products related to the various Free Software projects. Right now I don't want to talk too much about unfinished products, but we are working towards an inexpensive BTS product, we are funding the prototypes for Osmocom SIMtrace, and we will likely also see stuff like OpenBSC appliances. Given our past involvement and exposure into other projects that share a split Free Software / business set-up, we think we understand very well where potential issues of conflict between the two sides may be. Let me make some more clarification what this is not about: * sysmocom is not about creating proprietary derivates of Osmocom software. We work on Free Software which is publicly available under OSI approved and FSF endorsed licenses. We may offer proprietary hardware and sometimes software - but those are independent projects from existing Osmocom software. * we specifically will not have a public and a non-public version of the same program with differences in features. * sysmocom is not a VC-funded startup. It's a very small company run out of personal funds with no intention to take external funding or grow rapidly. Nobody but Holger and I determine where it goes and what it does. * sysmocom does not hold any copyright on the Free Software projects. The copyrights stay distributed with the major authors such as Holger, Onwaves, Sylvain, Dieter, Andreas and myself. None of the others have any affiliation with sysmocom. I have (personally, unrelated to sysmocom) asked some of the smaller contributors for a copyright transfer to make sure we could do the AGPLv3 transition, or future re-licensing decisions without having to ask dozens and dozens of people. sysmocom does not seek to control the Free Software projects. * we will maintain a strict separation between the community side of things and the business side. Unlike some other popular projects, we will not end up in a situation where the osmocom.org websites will be full of advertisements and hidden links that lure you on the company website. * we will keep a strict separation of naming. Osmocom is for the FOSS projects, sysmocom for the business. The company will use the term "Osmocom" only in descriptive context, not as a product name, brand or for advertisement. If you do have any concerns, please feel free to share them. However, I'd like to avoid cross-posting them throguh different mailing lists. Please follow-up-to openbsc at lists.osmocom.org Regards, Harald -- - Harald Welte http://www.sysmocom.de/ ======================================================================= * sysmocom - systems for mobile communications GmbH * Schivelbeiner Str. 5 * 10439 Berlin, Germany * Sitz / Registered office: Berlin, HRB 134158 B * Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 482 bytes Desc: Digital signature URL: From pablo at gnumonks.org Sat May 14 11:57:47 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 14 May 2011 13:57:47 +0200 Subject: [PATCH 0/4] openBSC: minor fixes and updates Message-ID: <1305374271-21303-1-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso This patchset contains minor fixes and updates. You can find them in pablo/updates branch. Merge it if you consider that they're OK. Thanks. Pablo Neira Ayuso (4): abis: skip e1_input nesting if empty libbsc: fix bail out in case of problems bootstrapping BTS or E1 input libabis: add init function for emulated ipaccess/HSL emulated E1 input bsc: on-demand setup of nanoBTS and HSL femto sockets openbsc/include/openbsc/Makefile.am | 3 ++- openbsc/include/openbsc/bss.h | 17 +++++++++++++++++ openbsc/include/openbsc/e1_input.h | 1 + openbsc/include/openbsc/gsm_data.h | 3 +++ openbsc/src/libabis/e1_input.c | 4 ++++ openbsc/src/libabis/e1_input_vty.c | 3 +++ openbsc/src/libabis/input/hsl.c | 11 +++++------ openbsc/src/libabis/input/ipaccess.c | 11 +++++------ openbsc/src/libbsc/Makefile.am | 2 +- openbsc/src/libbsc/bsc_init.c | 23 ++++++++++++++--------- openbsc/src/libbsc/bts_ericsson_rbs2000.c | 10 +++++++++- openbsc/src/libbsc/bts_hsl_femtocell.c | 11 ++++++++++- openbsc/src/libbsc/bts_init.c | 29 +++++++++++++++++++++++++++++ openbsc/src/libbsc/bts_ipaccess_nanobts.c | 12 +++++++++++- openbsc/src/libbsc/bts_siemens_bs11.c | 10 +++++++++- openbsc/src/libcommon/gsm_data.c | 8 ++++++++ openbsc/src/osmo-bsc/osmo_bsc_main.c | 11 ++--------- openbsc/src/osmo-nitb/bsc_hack.c | 17 ++--------------- 18 files changed, 135 insertions(+), 51 deletions(-) create mode 100644 openbsc/include/openbsc/bss.h create mode 100644 openbsc/src/libbsc/bts_init.c -- 1.7.2.3 From pablo at gnumonks.org Sat May 14 11:57:48 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 14 May 2011 13:57:48 +0200 Subject: [PATCH 1/4] abis: skip e1_input nesting if empty In-Reply-To: <1305374271-21303-1-git-send-email-pablo@gnumonks.org> References: <1305374271-21303-1-git-send-email-pablo@gnumonks.org> Message-ID: <1305374271-21303-2-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso With this patch, we don't include e1_input if it's empty [...] timeslot 7 phys_chan_config TCH/F hopping enabled 0 e1_input <----------------- empty, it should not show up. msc [...] --- openbsc/src/libabis/e1_input_vty.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/openbsc/src/libabis/e1_input_vty.c b/openbsc/src/libabis/e1_input_vty.c index 7dbf17a..b211e81 100644 --- a/openbsc/src/libabis/e1_input_vty.c +++ b/openbsc/src/libabis/e1_input_vty.c @@ -76,6 +76,9 @@ static int e1inp_config_write(struct vty *vty) { struct e1inp_line *line; + if (llist_empty(&e1inp_line_list)) + return CMD_SUCCESS; + vty_out(vty, "e1_input%s", VTY_NEWLINE); llist_for_each_entry(line, &e1inp_line_list, list) { -- 1.7.2.3 From pablo at gnumonks.org Sat May 14 11:57:49 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 14 May 2011 13:57:49 +0200 Subject: [PATCH 2/4] libbsc: fix bail out in case of problems bootstrapping BTS or E1 input In-Reply-To: <1305374271-21303-1-git-send-email-pablo@gnumonks.org> References: <1305374271-21303-1-git-send-email-pablo@gnumonks.org> Message-ID: <1305374271-21303-3-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso The error message was missing in case of problems bootstrapping the BTS. The E1 input driver initialization was displayed in the standard output, now this error is reported via logs. --- openbsc/src/libbsc/bsc_init.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c index c173c62..ecb4e44 100644 --- a/openbsc/src/libbsc/bsc_init.c +++ b/openbsc/src/libbsc/bsc_init.c @@ -439,7 +439,10 @@ int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *), llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) { rc = bootstrap_bts(bts); - + if (rc < 0) { + LOGP(DNM, LOGL_FATAL, "Error bootstrapping BTS\n"); + return rc; + } switch (bts->type) { case GSM_BTS_TYPE_NANOBTS: case GSM_BTS_TYPE_HSL_FEMTO: @@ -448,10 +451,9 @@ int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *), rc = e1_reconfig_bts(bts); break; } - if (rc < 0) { - fprintf(stderr, "Error in E1 input driver setup\n"); - exit (1); + LOGP(DNM, LOGL_FATAL, "Error enabling E1 input driver\n"); + return rc; } } -- 1.7.2.3 From pablo at gnumonks.org Sat May 14 11:57:50 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 14 May 2011 13:57:50 +0200 Subject: [PATCH 3/4] libabis: add init function for emulated ipaccess/HSL emulated E1 input In-Reply-To: <1305374271-21303-1-git-send-email-pablo@gnumonks.org> References: <1305374271-21303-1-git-send-email-pablo@gnumonks.org> Message-ID: <1305374271-21303-4-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso This patch is a cleanup. It adds an init function for the ipaccess and HSL emulated E1 input drivers. --- openbsc/src/libabis/e1_input.c | 4 ++++ openbsc/src/libabis/input/hsl.c | 11 +++++------ openbsc/src/libabis/input/ipaccess.c | 11 +++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/openbsc/src/libabis/e1_input.c b/openbsc/src/libabis/e1_input.c index 089d544..97dcd33 100644 --- a/openbsc/src/libabis/e1_input.c +++ b/openbsc/src/libabis/e1_input.c @@ -634,6 +634,8 @@ static int e1i_sig_cb(unsigned int subsys, unsigned int signal, void e1inp_misdn_init(void); void e1inp_dahdi_init(void); +void e1inp_ipaccess_init(void); +void e1inp_hsl_init(void); void e1inp_init(void) { @@ -645,4 +647,6 @@ void e1inp_init(void) #ifdef HAVE_DAHDI_USER_H e1inp_dahdi_init(); #endif + e1inp_ipaccess_init(); + e1inp_hsl_init(); } diff --git a/openbsc/src/libabis/input/hsl.c b/openbsc/src/libabis/input/hsl.c index e842f0d..c98a22c 100644 --- a/openbsc/src/libabis/input/hsl.c +++ b/openbsc/src/libabis/input/hsl.c @@ -437,12 +437,6 @@ int hsl_setup(struct gsm_network *gsmnet) { int ret; - /* register the driver with the core */ - /* FIXME: do this in the plugin initializer function */ - ret = e1inp_driver_register(&hsl_driver); - if (ret) - return ret; - e1h = talloc_zero(tall_bsc_ctx, struct hsl_e1_handle); if (!e1h) return -ENOMEM; @@ -457,3 +451,8 @@ int hsl_setup(struct gsm_network *gsmnet) return 0; } + +void e1inp_hsl_init(void) +{ + e1inp_driver_register(&hsl_driver); +} diff --git a/openbsc/src/libabis/input/ipaccess.c b/openbsc/src/libabis/input/ipaccess.c index 8080129..1427118 100644 --- a/openbsc/src/libabis/input/ipaccess.c +++ b/openbsc/src/libabis/input/ipaccess.c @@ -812,12 +812,6 @@ int ipaccess_setup(struct gsm_network *gsmnet) { int ret; - /* register the driver with the core */ - /* FIXME: do this in the plugin initializer function */ - ret = e1inp_driver_register(&ipaccess_driver); - if (ret) - return ret; - e1h = talloc_zero(tall_bsc_ctx, struct ia_e1_handle); if (!e1h) return -ENOMEM; @@ -838,3 +832,8 @@ int ipaccess_setup(struct gsm_network *gsmnet) return ret; } + +void e1inp_ipaccess_init(void) +{ + e1inp_driver_register(&ipaccess_driver); +} -- 1.7.2.3 From pablo at gnumonks.org Sat May 14 11:57:51 2011 From: pablo at gnumonks.org (pablo at gnumonks.org) Date: Sat, 14 May 2011 13:57:51 +0200 Subject: [PATCH 4/4] bsc: on-demand setup of nanoBTS and HSL femto sockets In-Reply-To: <1305374271-21303-1-git-send-email-pablo@gnumonks.org> References: <1305374271-21303-1-git-send-email-pablo@gnumonks.org> Message-ID: <1305374271-21303-5-git-send-email-pablo@gnumonks.org> From: Pablo Neira Ayuso The daemons set up nanoBTS and HSL femto sockets by default, ie. the three sockets to support these two drivers are open even if we have no BTS of that kind. This patch enables on-demand socket creation, ie. we only enable them if we have one BTS at least that requires it. I added two new attributes to the gsm_bts object, they are: * the start() function includes the code that we need to run to start the BTS. This new function contains the socket creation in the particular case of nanoBTS and HSL femto. * the started boolean, which is used to know if we have already started the BTS, ie. we have already invoked start(). Note that, I have splitted the bts_model_*_init() function into two functions, the _init() functions that register the BTS driver and the _start() functions that start BTS driver on-demand. While I was at it, I added several changes/cleanups to this patch: * Group all bts_model_*_init() calls into one function bts_init(), which is called in the initialization path of osmo-nitb and osmo-bsc. * Add openbsc/bss.h that contains the declaration of bsc_bootstrap_network, bsc_shutdown_net and bts_init. * Add missing e1inp_init() in osmo-bsc. * Fix missing declaration of hsl_setup in openbsc/e1_input.h --- openbsc/include/openbsc/Makefile.am | 3 ++- openbsc/include/openbsc/bss.h | 17 +++++++++++++++++ openbsc/include/openbsc/e1_input.h | 1 + openbsc/include/openbsc/gsm_data.h | 3 +++ openbsc/src/libbsc/Makefile.am | 2 +- openbsc/src/libbsc/bsc_init.c | 13 ++++++++----- openbsc/src/libbsc/bts_ericsson_rbs2000.c | 10 +++++++++- openbsc/src/libbsc/bts_hsl_femtocell.c | 11 ++++++++++- openbsc/src/libbsc/bts_init.c | 29 +++++++++++++++++++++++++++++ openbsc/src/libbsc/bts_ipaccess_nanobts.c | 12 +++++++++++- openbsc/src/libbsc/bts_siemens_bs11.c | 10 +++++++++- openbsc/src/libcommon/gsm_data.c | 8 ++++++++ openbsc/src/osmo-bsc/osmo_bsc_main.c | 11 ++--------- openbsc/src/osmo-nitb/bsc_hack.c | 17 ++--------------- 14 files changed, 112 insertions(+), 35 deletions(-) create mode 100644 openbsc/include/openbsc/bss.h create mode 100644 openbsc/src/libbsc/bts_init.c diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 325d66d..f87eca1 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -11,7 +11,8 @@ noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \ gb_proxy.h gprs_sgsn.h gsm_04_08_gprs.h sgsn.h \ gprs_ns_frgre.h auth.h osmo_msc.h bsc_msc.h bsc_nat.h \ osmo_bsc_rf.h osmo_bsc.h network_listen.h bsc_nat_sccp.h \ - osmo_msc_data.h osmo_bsc_grace.h sms_queue.h abis_om2000.h + osmo_msc_data.h osmo_bsc_grace.h sms_queue.h abis_om2000.h \ + bss.h openbsc_HEADERS = gsm_04_08.h meas_rep.h bsc_api.h openbscdir = $(includedir)/openbsc diff --git a/openbsc/include/openbsc/bss.h b/openbsc/include/openbsc/bss.h new file mode 100644 index 0000000..05495dd --- /dev/null +++ b/openbsc/include/openbsc/bss.h @@ -0,0 +1,17 @@ +#ifndef _BSS_H_ +#define _BSS_H_ + +struct gsm_network; +struct msgb; + +/* start and stop network */ +extern int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *), const char *cfg_file); +extern int bsc_shutdown_net(struct gsm_network *net); + +/* register all supported BTS */ +extern int bts_init(void); +extern int bts_model_bs11_init(void); +extern int bts_model_rbs2k_init(void); +extern int bts_model_nanobts_init(void); +extern int bts_model_hslfemto_init(void); +#endif diff --git a/openbsc/include/openbsc/e1_input.h b/openbsc/include/openbsc/e1_input.h index 0eae5d9..0d79c7d 100644 --- a/openbsc/include/openbsc/e1_input.h +++ b/openbsc/include/openbsc/e1_input.h @@ -175,6 +175,7 @@ int e1_reconfig_bts(struct gsm_bts *bts); int ia_config_connect(struct gsm_bts *bts, struct sockaddr_in *sin); int ipaccess_setup(struct gsm_network *gsmnet); +int hsl_setup(struct gsm_network *gsmnet); extern struct llist_head e1inp_driver_list; extern struct llist_head e1inp_line_list; diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index bc276d1..c3cf104 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -1,6 +1,7 @@ #ifndef _GSM_DATA_H #define _GSM_DATA_H +#include struct osmo_msc_data; struct osmo_bsc_sccp_con; @@ -434,6 +435,8 @@ struct gsm_bts_model { enum gsm_bts_type type; const char *name; + bool started; + int (*start)(struct gsm_network *net); int (*oml_rcvmsg)(struct msgb *msg); void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts); diff --git a/openbsc/src/libbsc/Makefile.am b/openbsc/src/libbsc/Makefile.am index 70f6c1c..3af4a2a 100644 --- a/openbsc/src/libbsc/Makefile.am +++ b/openbsc/src/libbsc/Makefile.am @@ -20,5 +20,5 @@ libbsc_a_SOURCES = abis_nm.c abis_nm_vty.c \ e1_config.c \ bsc_api.c bsc_msc.c bsc_vty.c \ gsm_04_08_utils.c \ - bsc_init.c + bsc_init.c bts_init.c diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c index ecb4e44..19453f7 100644 --- a/openbsc/src/libbsc/bsc_init.c +++ b/openbsc/src/libbsc/bsc_init.c @@ -315,6 +315,14 @@ static int bootstrap_bts(struct gsm_bts *bts) { int i, n; + if (bts->model->start && !bts->model->started) { + int ret = bts->model->start(bts->network); + if (ret < 0) + return ret; + + bts->model->started = true; + } + /* FIXME: What about secondary TRX of a BTS? What about a BTS that has TRX * in different bands? Why is 'band' a parameter of the BTS and not of the TRX? */ switch (bts->band) { @@ -456,10 +464,5 @@ int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *), return rc; } } - - /* initialize nanoBTS support omce */ - rc = ipaccess_setup(bsc_gsmnet); - rc = hsl_setup(bsc_gsmnet); - return 0; } diff --git a/openbsc/src/libbsc/bts_ericsson_rbs2000.c b/openbsc/src/libbsc/bts_ericsson_rbs2000.c index c2ae0e7..9c98a9f 100644 --- a/openbsc/src/libbsc/bts_ericsson_rbs2000.c +++ b/openbsc/src/libbsc/bts_ericsson_rbs2000.c @@ -242,14 +242,17 @@ static void config_write_bts(struct vty *vty, struct gsm_bts *bts) abis_om2k_config_write_bts(vty, bts); } +static int bts_model_rbs2k_start(struct gsm_network *net); + static struct gsm_bts_model model_rbs2k = { .type = GSM_BTS_TYPE_RBS2000, .name = "rbs2000", + .start = bts_model_rbs2k_start, .oml_rcvmsg = &abis_om2k_rcvmsg, .config_write_bts = &config_write_bts, }; -int bts_model_rbs2k_init(void) +static int bts_model_rbs2k_start(struct gsm_network *net) { model_rbs2k.features.data = &model_rbs2k._features_data[0]; model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data); @@ -261,5 +264,10 @@ int bts_model_rbs2k_init(void) osmo_signal_register_handler(SS_GLOBAL, gbl_sig_cb, NULL); osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL); + return 0; +} + +int bts_model_rbs2k_init(void) +{ return gsm_bts_model_register(&model_rbs2k); } diff --git a/openbsc/src/libbsc/bts_hsl_femtocell.c b/openbsc/src/libbsc/bts_hsl_femtocell.c index 7264a21..f943693 100644 --- a/openbsc/src/libbsc/bts_hsl_femtocell.c +++ b/openbsc/src/libbsc/bts_hsl_femtocell.c @@ -30,8 +30,11 @@ #include #include +static int bts_model_hslfemto_start(struct gsm_network *net); + static struct gsm_bts_model model_hslfemto = { .type = GSM_BTS_TYPE_HSL_FEMTO, + .start = bts_model_hslfemto_start, .nm_att_tlvdef = { .def = { /* no HSL specific OML attributes that we know of */ @@ -148,7 +151,7 @@ static int inp_sig_cb(unsigned int subsys, unsigned int signal, return 0; } -int bts_model_hslfemto_init(void) +static int bts_model_hslfemto_start(struct gsm_network *net) { model_hslfemto.features.data = &model_hslfemto._features_data[0]; model_hslfemto.features.data_len = sizeof(model_hslfemto._features_data); @@ -158,5 +161,11 @@ int bts_model_hslfemto_init(void) osmo_signal_register_handler(SS_INPUT, inp_sig_cb, NULL); + /* Call A-bis input driver, start socket for OML and RSL. */ + return hsl_setup(net); +} + +int bts_model_hslfemto_init(void) +{ return gsm_bts_model_register(&model_hslfemto); } diff --git a/openbsc/src/libbsc/bts_init.c b/openbsc/src/libbsc/bts_init.c new file mode 100644 index 0000000..87bdde0 --- /dev/null +++ b/openbsc/src/libbsc/bts_init.c @@ -0,0 +1,29 @@ +/* (C) 2011 by Harald Welte + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +#include + +int bts_init(void) +{ + bts_model_bs11_init(); + bts_model_rbs2k_init(); + bts_model_nanobts_init(); + bts_model_hslfemto_init(); + /* Your new BTS here. */ + return 0; +} diff --git a/openbsc/src/libbsc/bts_ipaccess_nanobts.c b/openbsc/src/libbsc/bts_ipaccess_nanobts.c index 13bed22..706712e 100644 --- a/openbsc/src/libbsc/bts_ipaccess_nanobts.c +++ b/openbsc/src/libbsc/bts_ipaccess_nanobts.c @@ -26,10 +26,14 @@ #include #include #include +#include /* for ipaccess_setup() */ + +static int bts_model_nanobts_start(struct gsm_network *net); static struct gsm_bts_model model_nanobts = { .type = GSM_BTS_TYPE_NANOBTS, .name = "nanobts", + .start = bts_model_nanobts_start, .oml_rcvmsg = &abis_nm_rcvmsg, .nm_att_tlvdef = { .def = { @@ -435,7 +439,7 @@ static int nm_sig_cb(unsigned int subsys, unsigned int signal, return 0; } -int bts_model_nanobts_init(void) +static int bts_model_nanobts_start(struct gsm_network *net) { model_nanobts.features.data = &model_nanobts._features_data[0]; model_nanobts.features.data_len = sizeof(model_nanobts._features_data); @@ -445,5 +449,11 @@ int bts_model_nanobts_init(void) osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL); + /* Call A-bis input driver, start server sockets for OML and RSL. */ + return ipaccess_setup(net); +} + +int bts_model_nanobts_init(void) +{ return gsm_bts_model_register(&model_nanobts); } diff --git a/openbsc/src/libbsc/bts_siemens_bs11.c b/openbsc/src/libbsc/bts_siemens_bs11.c index 44f9358..df4a1dc 100644 --- a/openbsc/src/libbsc/bts_siemens_bs11.c +++ b/openbsc/src/libbsc/bts_siemens_bs11.c @@ -28,9 +28,12 @@ #include #include +static int bts_model_bs11_start(struct gsm_network *net); + static struct gsm_bts_model model_bs11 = { .type = GSM_BTS_TYPE_BS11, .name = "bs11", + .start = bts_model_bs11_start, .oml_rcvmsg = &abis_nm_rcvmsg, .nm_att_tlvdef = { .def = { @@ -575,7 +578,7 @@ static int inp_sig_cb(unsigned int subsys, unsigned int signal, return 0; } -int bts_model_bs11_init(void) +static int bts_model_bs11_start(struct gsm_network *net) { model_bs11.features.data = &model_bs11._features_data[0]; model_bs11.features.data_len = sizeof(model_bs11._features_data); @@ -586,5 +589,10 @@ int bts_model_bs11_init(void) osmo_signal_register_handler(SS_INPUT, inp_sig_cb, NULL); osmo_signal_register_handler(SS_GLOBAL, gbl_sig_cb, NULL); + return 0; +} + +int bts_model_bs11_init(void) +{ return gsm_bts_model_register(&model_bs11); } diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c index 45e56af..480eb80 100644 --- a/openbsc/src/libcommon/gsm_data.c +++ b/openbsc/src/libcommon/gsm_data.c @@ -573,6 +573,14 @@ int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type) bts->type = type; bts->model = model; + if (model->start && !model->started) { + int ret = model->start(bts->network); + if (ret < 0) + return ret; + + model->started = true; + } + switch (bts->type) { case GSM_BTS_TYPE_HSL_FEMTO: bts->c0->rsl_tei = 0; diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index 16495d8..42c74cc 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -50,8 +50,6 @@ static const char *rf_ctl = NULL; extern const char *openbsc_copyright; static int daemonize = 0; -extern int bsc_bootstrap_network(int (*layer4)(struct gsm_network *, struct msgb *), const char *cfg_file); - static void print_usage() { printf("Usage: osmo-bsc\n"); @@ -128,10 +126,6 @@ static void handle_options(int argc, char **argv) } } -extern int bts_model_unknown_init(void); -extern int bts_model_bs11_init(void); -extern int bts_model_nanobts_init(void); - extern enum node_type bsc_vty_go_parent(struct vty *vty); static struct vty_app_info vty_info = { @@ -183,9 +177,8 @@ int main(int argc, char **argv) osmo_init_logging(&log_info); - bts_model_unknown_init(); - bts_model_bs11_init(); - bts_model_nanobts_init(); + bts_init(); + e1inp_init(); /* enable filters */ diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index 1fa039b..2406873 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "../../bscconfig.h" @@ -55,10 +56,6 @@ static int use_mncc_sock = 0; #define DB_SYNC_INTERVAL 60, 0 static struct osmo_timer_list db_sync_timer; -extern int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *), - const char *cfg_file); -extern int bsc_shutdown_net(struct gsm_network *net); - static void create_pcap_file(char *file) { mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; @@ -207,11 +204,6 @@ static void db_sync_timer_cb(void *data) osmo_timer_schedule(&db_sync_timer, DB_SYNC_INTERVAL); } -extern int bts_model_unknown_init(void); -extern int bts_model_bs11_init(void); -extern int bts_model_nanobts_init(void); -extern int bts_model_rbs2k_init(void); -extern int bts_model_hslfemto_init(void); void talloc_ctx_init(void); extern enum node_type bsc_vty_go_parent(struct vty *vty); @@ -237,12 +229,7 @@ int main(int argc, char **argv) osmo_init_logging(&log_info); - bts_model_unknown_init(); - bts_model_bs11_init(); - bts_model_nanobts_init(); - bts_model_rbs2k_init(); - bts_model_hslfemto_init(); - + bts_init(); e1inp_init(); /* This needs to precede handle_options() */ -- 1.7.2.3 From laforge at gnumonks.org Sun May 22 19:04:06 2011 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 22 May 2011 21:04:06 +0200 Subject: [PATCH 0/4] openBSC: minor fixes and updates In-Reply-To: <1305374271-21303-1-git-send-email-pablo@gnumonks.org> References: <1305374271-21303-1-git-send-email-pablo@gnumonks.org> Message-ID: <20110522190406.GQ4243@prithivi.gnumonks.org> Hi Pablo, On Sat, May 14, 2011 at 01:57:47PM +0200, pablo at gnumonks.org wrote: > This patchset contains minor fixes and updates. thanks, I've merged all your updates now. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Sat May 14 12:35:56 2011 From: laforge at gnumonks.org (Harald Welte) Date: Sat, 14 May 2011 14:35:56 +0200 Subject: Wanted: dpkg/deb/rpm package maintainer Message-ID: <6ed9b68f-caad-44e0-a19c-656c2fe1bcfe@email.android.com> Hi all, for quite some time we've been having debian dpkg packaging information as part of our libosmocore, libosmo-sccp, openggsn and openbsc repositories. As the library ABI sis now considered stable, it starts to make sense not only to release source tarballs, but also to offer .deb packages for ubunto and debian, probably both i386 and amd64 and lenny, squeeze and natty as well as ubuntu 10.04. The resulting packages could initially be hosted on an osmoxom.org apt feed that people can wimply put in their sources.list We're looking for somebody with dpkg packaging experience, who would volunteer to take care of building the deb files and maintaining that apt feed. If somebody wants to take care about RPM packaging, that would of course be also welcome. Thanks in advance, Harald -- Sent from a mobile device, excuse my short response -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at gnumonks.org Tue May 17 07:15:31 2011 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 17 May 2011 09:15:31 +0200 Subject: Problems suspected to be related to _output() rework Message-ID: <20110517071531.GD2957@prithivi.gnumonks.org> Hi Pablo! I am sometimes getting osmo-nitb segfaults, and sometimes random bytes as output of log messages. I've quickly started it in valgrind, and even during connection of the BTS I get the following issues: <000d> input/ipaccess.c:693 accept()ed new OML link from 192.168.200.117 ==21897== Conditional jump or move depends on uninitialised value(s) ==21897== at 0x60D4BD4: vfprintf (vfprintf.c:1620) ==21897== by 0x60F8F01: vsnprintf (vsnprintf.c:120) ==21897== by 0x4E33670: _output (logging.c:177) ==21897== by 0x4E33878: _logp (logging.c:227) ==21897== by 0x4E33BCB: logp2 (logging.c:246) ==21897== by 0x435E5C: listen_fd_cb (ipaccess.c:692) ==21897== by 0x4E32419: osmo_select_main (select.c:132) ==21897== by 0x40555B: main (bsc_hack.c:306) ==21897== ==21897== Use of uninitialised value of size 8 ==21897== at 0x60D5008: vfprintf (vfprintf.c:1620) ==21897== by 0x60F8F01: vsnprintf (vsnprintf.c:120) ==21897== by 0x4E33670: _output (logging.c:177) ==21897== by 0x4E33878: _logp (logging.c:227) ==21897== by 0x4E33BCB: logp2 (logging.c:246) ==21897== by 0x435E5C: listen_fd_cb (ipaccess.c:692) ==21897== by 0x4E32419: osmo_select_main (select.c:132) ==21897== by 0x40555B: main (bsc_hack.c:306) ==21897== ==21897== Use of uninitialised value of size 8 ==21897== at 0x6101CE0: _IO_default_xsputn (genops.c:480) ==21897== by 0x60D4ED3: vfprintf (vfprintf.c:1620) ==21897== by 0x60F8F01: vsnprintf (vsnprintf.c:120) ==21897== by 0x4E33670: _output (logging.c:177) ==21897== by 0x4E33878: _logp (logging.c:227) ==21897== by 0x4E33BCB: logp2 (logging.c:246) ==21897== by 0x435E5C: listen_fd_cb (ipaccess.c:692) ==21897== by 0x4E32419: osmo_select_main (select.c:132) ==21897== by 0x40555B: main (bsc_hack.c:306) ==21897== ==21897== Conditional jump or move depends on uninitialised value(s) ==21897== at 0x6101CF2: _IO_default_xsputn (genops.c:479) ==21897== by 0x60D4ED3: vfprintf (vfprintf.c:1620) ==21897== by 0x60F8F01: vsnprintf (vsnprintf.c:120) ==21897== by 0x4E33670: _output (logging.c:177) ==21897== by 0x4E33878: _logp (logging.c:227) ==21897== by 0x4E33BCB: logp2 (logging.c:246) ==21897== by 0x435E5C: listen_fd_cb (ipaccess.c:692) ==21897== by 0x4E32419: osmo_select_main (select.c:132) ==21897== by 0x40555B: main (bsc_hack.c:306) ==21897== <000d> input/ipaccess.c:755 accept()ed new RSL link from 192.168.200.117 <0004> bsc_init.c:251 bootstrapping RSL for BTS/TRX (0/0) on ARFCN 871 using MCC=602 MNC=42 LAC=1 CID=0 BSIC=63 TSC=7 ==21897== Use of uninitialised value of size 8 ==21897== at 0x60D2EDB: _itoa_word (_itoa.c:195) ==21897== by 0x60D5386: vfprintf (vfprintf.c:1619) ==21897== by 0x60F8F01: vsnprintf (vsnprintf.c:120) ==21897== by 0x4E33670: _output (logging.c:177) ==21897== by 0x4E33878: _logp (logging.c:227) ==21897== by 0x4E33BCB: logp2 (logging.c:246) ==21897== by 0x410141: inp_sig_cb (bsc_init.c:247) Can you please investigate? I suspect it to be related to your recent _output() related changes in libosmocore. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Tue May 17 07:26:15 2011 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 17 May 2011 09:26:15 +0200 Subject: Problems suspected to be related to _output() rework In-Reply-To: <20110517071531.GD2957@prithivi.gnumonks.org> References: <20110517071531.GD2957@prithivi.gnumonks.org> Message-ID: <20110517072615.GE2957@prithivi.gnumonks.org> Hi again, On Tue, May 17, 2011 at 09:15:31AM +0200, Harald Welte wrote: > I am sometimes getting osmo-nitb segfaults, and sometimes random bytes > as output of log messages. > > I've quickly started it in valgrind, and even during connection of the > BTS I get the following issues: Some more info: On the stdout it looks fine, but on telnet it is wrong: Same log message, first on stdout: <0004> abis_rsl.c:1283 BTS 0 CHAN RQD: no resources for TCH/F 0xe3 <0004> abis_rsl.c:915 (bts=0,trx=0,ts=7,ss=0) CONNECTION FAIL: RELEASING CAUSE=0x01(Radio Link Failure) same message, but on telnet: <0004> abis_rsl.c:1283 BTS 109771072 CHAN RQD: no resources for 0x1 <0004> abis_rsl.c:915 (null) CONNECTION FAIL: RELEASING CAUSE=0x743ecab() Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From pablo at gnumonks.org Tue May 17 18:04:43 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Tue, 17 May 2011 20:04:43 +0200 Subject: Problems suspected to be related to _output() rework In-Reply-To: <20110517072615.GE2957@prithivi.gnumonks.org> References: <20110517071531.GD2957@prithivi.gnumonks.org> <20110517072615.GE2957@prithivi.gnumonks.org> Message-ID: <4DD2B8BB.9070503@gnumonks.org> On 17/05/11 09:26, Harald Welte wrote: > Hi again, > > On Tue, May 17, 2011 at 09:15:31AM +0200, Harald Welte wrote: > >> I am sometimes getting osmo-nitb segfaults, and sometimes random bytes >> as output of log messages. >> >> I've quickly started it in valgrind, and even during connection of the >> BTS I get the following issues: > > Some more info: > > On the stdout it looks fine, but on telnet it is wrong: > > Same log message, first on stdout: > <0004> abis_rsl.c:1283 BTS 0 CHAN RQD: no resources for TCH/F 0xe3 > <0004> abis_rsl.c:915 (bts=0,trx=0,ts=7,ss=0) CONNECTION FAIL: RELEASING CAUSE=0x01(Radio Link Failure) > > same message, but on telnet: > <0004> abis_rsl.c:1283 BTS 109771072 CHAN RQD: no resources for 0x1 > <0004> abis_rsl.c:915 (null) CONNECTION FAIL: RELEASING CAUSE=0x743ecab() Sorry, I'm completely lost here, how can I set up log messages over telnet? From holger at freyther.de Tue May 17 18:37:20 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 17 May 2011 20:37:20 +0200 Subject: Problems suspected to be related to _output() rework In-Reply-To: <4DD2B8BB.9070503@gnumonks.org> References: <20110517071531.GD2957@prithivi.gnumonks.org> <20110517072615.GE2957@prithivi.gnumonks.org> <4DD2B8BB.9070503@gnumonks.org> Message-ID: <4DD2C060.3040309@freyther.de> On 05/17/2011 08:04 PM, Pablo Neira Ayuso wrote: > > Sorry, I'm completely lost here, how can I set up log messages over telnet? > logging enable logging filter all 1 should be enough for that (on the telnet interface) From pablo at gnumonks.org Tue May 17 23:01:58 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Wed, 18 May 2011 01:01:58 +0200 Subject: Problems suspected to be related to _output() rework In-Reply-To: <4DD2C060.3040309@freyther.de> References: <20110517071531.GD2957@prithivi.gnumonks.org> <20110517072615.GE2957@prithivi.gnumonks.org> <4DD2B8BB.9070503@gnumonks.org> <4DD2C060.3040309@freyther.de> Message-ID: <4DD2FE66.1060108@gnumonks.org> On 17/05/11 20:37, Holger Hans Peter Freyther wrote: > On 05/17/2011 08:04 PM, Pablo Neira Ayuso wrote: > >> >> Sorry, I'm completely lost here, how can I set up log messages over telnet? >> > > logging enable > logging filter all 1 > > should be enough for that (on the telnet interface) thanks, I'll keep investigating this tomorrow. This tastes like a memory corruption, but not sure that this occurs in the _output() function. I'll try to get a fix for this by tomorrow. From laforge at gnumonks.org Wed May 18 10:15:01 2011 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 18 May 2011 12:15:01 +0200 Subject: Problems suspected to be related to _output() rework In-Reply-To: <4DD2FE66.1060108@gnumonks.org> References: <20110517071531.GD2957@prithivi.gnumonks.org> <20110517072615.GE2957@prithivi.gnumonks.org> <4DD2B8BB.9070503@gnumonks.org> <4DD2C060.3040309@freyther.de> <4DD2FE66.1060108@gnumonks.org> Message-ID: <20110518101500.GB7478@prithivi.gnumonks.org> On Wed, May 18, 2011 at 01:01:58AM +0200, Pablo Neira Ayuso wrote: > On 17/05/11 20:37, Holger Hans Peter Freyther wrote: > > On 05/17/2011 08:04 PM, Pablo Neira Ayuso wrote: > > > >> > >> Sorry, I'm completely lost here, how can I set up log messages over telnet? > >> > > > > logging enable > > logging filter all 1 > > > > should be enough for that (on the telnet interface) > > thanks, I'll keep investigating this tomorrow. This tastes like a memory > corruption, but not sure that this occurs in the _output() function. thanks a lot. I am currently busy in Egypt giving all-day training courses, so I don't have much time for testing. I've re-compiled libosmocore, openbsc and everything (with make clean) I also have some occasional crashes regarding to log/debug messages, see the attached file... I suspect they might be related. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) -------------- next part -------------- GNU gdb (GDB) 7.2-debian Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: ... Reading symbols from /home/laforge/projects/git/openbsc/openbsc/src/osmo-nitb/osmo-nitb...done. [New Thread 8168] Reading symbols from /usr/local/lib/libosmocore.so.0...done. Loaded symbols for /usr/local/lib/libosmocore.so.0 Reading symbols from /usr/local/lib/libosmogsm.so.0...done. Loaded symbols for /usr/local/lib/libosmogsm.so.0 Reading symbols from /lib/libdl.so.2...Reading symbols from /usr/lib/debug/lib/libdl-2.13.so...done. done. Loaded symbols for /lib/libdl.so.2 Reading symbols from /usr/lib/libdbi.so.0...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libdbi.so.0 Reading symbols from /usr/local/lib/libosmovty.so.0...done. Loaded symbols for /usr/local/lib/libosmovty.so.0 Reading symbols from /usr/local/lib/libgtp.so.0...done. Loaded symbols for /usr/local/lib/libgtp.so.0 Reading symbols from /lib/libcrypt.so.1...Reading symbols from /usr/lib/debug/lib/libcrypt-2.13.so...done. done. Loaded symbols for /lib/libcrypt.so.1 Reading symbols from /lib/libc.so.6...Reading symbols from /usr/lib/debug/lib/libc-2.13.so...done. done. Loaded symbols for /lib/libc.so.6 Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug/lib/ld-2.13.so...done. done. Loaded symbols for /lib64/ld-linux-x86-64.so.2 Reading symbols from /lib/libm.so.6...Reading symbols from /usr/lib/debug/lib/libm-2.13.so...done. done. Loaded symbols for /lib/libm.so.6 Reading symbols from /usr/lib/dbd/libdbdsqlite3.so...(no debugging symbols found)...done. Loaded symbols for /usr/lib/dbd/libdbdsqlite3.so Reading symbols from /usr/lib/libsqlite3.so.0...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libsqlite3.so.0 Reading symbols from /lib/libpthread.so.0...Reading symbols from /usr/lib/debug/lib/libpthread-2.13.so...done. done. Loaded symbols for /lib/libpthread.so.0 Core was generated by `./osmo-nitb -d DRSL:DMM:DRR:DNM'. Program terminated with signal 11, Segmentation fault. #0 0x00007f955a3bd008 in _IO_vfprintf_internal (s=0x7fff887a1fe0, format=0x4406d3 "SI%s: %s\n", ap=0x7fff887a3230) at vfprintf.c:1620 in vfprintf.c (gdb) fbacktrace full #0 0x00007f955a3bd008 in _IO_vfprintf_internal (s=0x7fff887a1fe0, format=0x4406d3 "SI%s: %s\n", ap=0x7fff887a3230) at vfprintf.c:1620 len = string_malloced = step0_jumps = {0, -15179, -14483, -14390, -14293, -14199, -15032, -14766, -13119, -13894, -13811, -13241, -12583, -2939, -3410, -3367, -3217, -3202, -10653, -8358, -2123, -12480, -2322, -2771, -1385, -1830, -2607, -3126, -3022, -14856} space = 0 is_short = 0 use_outdigits = 0 step1_jumps = {0, 0, 0, 0, 0, 0, 0, 0, 0, -13894, -13811, -13241, -12583, -2939, -3410, -3367, -3217, -3202, -10653, -8358, -2123, -12480, -2322, -2771, -1385, -1830, -2607, -3126, -3022, 0} group = 0 prec = step2_jumps = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -13811, -13241, -12583, -2939, -3410, -3367, -3217, -3202, -10653, -8358, -2123, -12480, -2322, -2771, -1385, -1830, -2607, -3126, -3022, 0} string = 0x367
left = 0 is_long_double = 0 width = step3a_jumps = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -13341, 0, 0, 0, -3410, -3367, -3217, -3202, -10653, 0, 0, 0, 0, -2771, 0, 0, 0, 0, 0, 0} alt = 0 showsign = 0 is_long = 0 is_char = 0 pad = step3b_jumps = {0 , -12583, 0, 0, -3410, -3367, -3217, -3202, -10653, -8358, -2123, -12480, -2322, -2771, -1385, -1830, -2607, 0, 0, 0} step4_jumps = {0 , -3410, -3367, -3217, -3202, -10653, -8358, -2123, -12480, -2322, -2771, -1385, -1830, -2607, 0, 0, 0} is_negative = base = -2005263712 the_arg = {pa_wchar = -2005261961 L'w', pa_int = -2005261961, pa_long_int = 140735483093367, pa_long_long_int = 140735483093367, pa_u_int = 2289705335, pa_u_long_int = 140735483093367, pa_u_long_long_int = 140735483093367, pa_double = 6.9532567347304201e-310, pa_long_double = , pa_string = 0x7fff887a2177 "<0003> bsc_init.c:105 SI(null): 19 8f b3 80 00 00 00 00 00 00 00 00 00 00 00 00 00 e5 04 00 2b \n\033[0;m", pa_wstring = 0x7fff887a2177 L"\x3030303c\x62203e33\x695f6373\x2e74696e\x30313a63\x49532035\x6c756e28\x203a296c\x20393120\x62206638\x30382033\x20303020\x30203030\x30302030\x20303020\x30203030\x30302030\x20303020\x30203030\x30302030\x20303020\x30203565\x30302034\x20623220\x305b1b0a\x20006d3b\x3d434e4d\x34333531\x39353134\x4c203534\x303d4341\x44494320\x3230333d\x30353535\x53422034\x313d4349\x53542034\x35313d43\x35353633\x30343630\x305b1b0a?", pa_pointer = 0x7fff887a2177, pa_user = 0x7fff887a2177} spec = _buffer = {__routine = 0, __arg = 0x0, __canceltype = 0, __prev = 0x7fff887a1f00} _avail = 0 thousands_sep = 0x0 grouping = 0xffffffffffffffff
done = 10 f = lead_str_end = 0x4406d5 "%s: %s\n" work_buffer = "0\034z\210\377\177\000\000\002\017>Z\225\177\000\000\001\200\255\373\377\177\000\000\060\034z\210\377\177\000\000\060\034z\210\377\177\000\000\060\034z\210\377\177\000\000\060\034z\210\377\177\000\000\061\034z\210\377\177\000\000/ z\210\377\177\000\000\060\034z\210\377\177\000\000/ z\210\377\177", '\000' , "`~oZ\000\000\000\000h\020\000\000\000\000\000\000\000\000\361Z\225\177\000\000\000\000\000\000\000\000\000\000\005\000\000\000\000\000\000\000\360\003?Z\225\177\000\000\377\377\377\377", '\000' , "\030\020\000\000\000\000\000\000@\345\317\001\000\000\000\000\377\377\377\377\225\177\000\000ITu[\225\177\000\000\000\000\000\000\000\000\000\000\300OoZ\225\177\000\000\000\000\000\000\000\000\000\000E\b\362Z\225\177\000\000\255\000\000\000\000\000\000\000\020\034z\210\377\177\000\000\220\345\317\001\000\000\000\000\372p\361Z\225\177"... workstart = 0x0 workend = 0x7fff887a1e98 "" ap_save = {{gp_offset = 48, fp_offset = 48, overflow_arg_area = 0x7fff887a3318, reg_save_area = 0x7fff887a3250}} nspecs_done = save_errno = 22 readonly_format = 0 jump_table = "\001\000\000\004\000\016\000\006\000\000\a\002\000\003\t\000\005\b\b\b\b\b\b\b\b\b\000\000\000\000\000\000\000\032\000\031\000\023\023\023\000\035\000\000\f\000\000\000\000\000\000\025\000\000\000\000\022\000\r\000\000\000\000\000\000\032\000\024\017\023\023\023\n\017\034\000\v\030\027\021\026\f\000\025\033\020\000\000\022\000\r" __PRETTY_FUNCTION__ = "_IO_vfprintf_internal" #1 0x00007f955a3e0f02 in _IO_vsnprintf (string=0x7fff887a218d "SI(null): 19 8f b3 80 00 00 00 00 00 00 00 00 00 00 00 00 00 e5 04 00 2b \n\033[0;m", maxlen=, format=0x4406d3 "SI%s: %s\n", args=0x7fff887a3230) at vsnprintf.c:120 sf = {f = {_sbf = {_f = {_flags = -72515583, _IO_read_ptr = 0x7fff887a218d "SI(null): 19 8f b3 80 00 00 00 00 00 00 00 00 00 00 00 00 00 e5 04 00 2b \n\033[0;m", _IO_read_end = 0x7fff887a218d "SI(null): 19 8f b3 80 00 00 00 00 00 00 00 00 00 00 00 00 00 e5 04 00 2b \n\033[0;m", _IO_read_base = 0x7fff887a218d "SI(null): 19 8f b3 80 00 00 00 00 00 00 00 00 00 00 00 00 00 e5 04 00 2b \n\033[0;m", _IO_write_base = 0x7fff887a218d "SI(null): 19 8f b3 80 00 00 00 00 00 00 00 00 00 00 00 00 00 e5 04 00 2b \n\033[0;m", _IO_write_ptr = 0x7fff887a2197 " 19 8f b3 80 00 00 00 00 00 00 00 00 00 00 00 00 00 e5 04 00 2b \n\033[0;m", _IO_write_end = 0x7fff887a316f "", _IO_buf_base = 0x7fff887a218d "SI(null): 19 8f b3 80 00 00 00 00 00 00 00 00 00 00 00 00 00 e5 04 00 2b \n\033[0;m", _IO_buf_end = 0x7fff887a316f "", _IO_save_base = 0x0, _IO_backup_base = 0x0, _IO_save_end = 0x0, _markers = 0x0, _chain = 0x0, _fileno = 3, _flags2 = 0, _old_offset = 140279440761395, _cur_column = 0, _vtable_offset = 0 '\000', _shortbuf = "", _lock = 0x0, _offset = 140735483093120, _codecvt = 0x7f955a6f6880, _wide_data = 0x7f955a6f6880, _freeres_list = 0x0, _freeres_buf = 0x6d, _freeres_size = 3, _mode = -1, _unused2 = "\000\000\000\000i\000\000\000\000\000\000\000\200hoZ\225\177\000"}, vtable = 0x7f955a6f4fc0}, _s = {_allocate_buffer = 0, _free_buffer = 0x7f955a3e761e <_IO_new_file_xsputn+510>}}, overflow_buf = "\000\000\000\000\000\000\000\000\200hoZ\225\177\000\000p!z\210\377\177\000\000m\000\000\000\000\000\000\000\035\000\000\000\000\000\000\000\003\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000l\322=Z\225\177\000"} ret = 0 #2 0x00007f955b751671 in _output (target=0x1cfdda0, subsys=3, level=1, file=0x4406c8 "bsc_init.c", line=, cont=, format=0x4406d3 "SI%s: %s\n", ap=0x7fff887a3230) at logging.c:177 buf = "\033[1;34m<0003> bsc_init.c:105 SI(null): 19 8f b3 80 00 00 00 00 00 00 00 00 00 00 00 00 00 e5 04 00 2b \n\033[0;m\000 MNC=1534415945 LAC=0 CID=30255504 BSIC=14 TSC=1536550640\n\033[0;m", '\000' "\260, \257\315\001\000\000\000\000\003~oZ\225\177\000\000\060[\317\001\000\000\000\000"... ret = len = offset = 29 rem = 4067 #3 0x00007f955b751879 in _logp (subsys=3, level=1, file=0x4406c8 "bsc_init.c", line=105, cont=0, format=0x4406d3 "SI%s: %s\n", ap=0x7fff887a3230) at logging.c:227 output = tar = 0x1cfdda0 #4 0x00007f955b751b41 in logp (subsys=, file=, line=, cont=, format=) at logging.c:237 ap = {{gp_offset = 48, fp_offset = 48, overflow_arg_area = 0x7fff887a3328, reg_save_area = 0x7fff887a3250}} #5 0x000000000041025e in generate_and_rsl_si (subsys=, signal=, handler_data=, signal_data=) at bsc_init.c:104 bts = si_len = 23 rc = 23 j = #6 set_system_infos (subsys=, signal=, handler_data=, signal_data=) at bsc_init.c:172 i = bts = 0x1cdafb0 #7 bootstrap_rsl (subsys=, signal=, handler_data=, signal_data=) at bsc_init.c:252 i = #8 inp_sig_cb (subsys=, signal=, handler_data=, signal_data=) at bsc_init.c:272 isd = trx = 0x1cdc5b0 ts_no = lchan_no = #9 0x00007f955b75068c in osmo_signal_dispatch (subsys=14, signal=1, signal_data=0x7fff887a33f0) at signal.c:85 handler = 0x1cda990 #10 0x0000000000434629 in e1inp_event (ts=, evt=, tei=, sapi=) at e1_input.c:579 link = 0x7fff887a1e98 isd = {link_type = 2, tei = 0 '\000', sapi = 0 '\000', trx = 0x1cdc5b0, line = 0x1} #11 0x0000000000436c7c in handle_ts1_read (bfd=0x1d17188, what=1) at input/ipaccess.c:537 line = link = msg = 0x1cfa7b0 hh = 0x1cfa838 ret = 0 ts_nr = e1i_ts = 0x1d16bf0 error = #12 ipaccess_fd_cb (bfd=0x1d17188, what=1) at input/ipaccess.c:657 line = ts_nr = idx = e1i_ts = rc = 0 #13 0x00007f955b75041a in osmo_select_main (polling=0) at select.c:132 flags = ufd = tmp = readset = {__fds_bits = {0 }} writeset = {__fds_bits = {0 }} exceptset = {__fds_bits = {0 }} work = 1 rc = no_time = {tv_sec = 0, tv_usec = 0} #14 0x000000000040555c in main (argc=3, argv=0x7fff887a3758) at bsc_hack.c:306 rc = (gdb) frame 5 #5 0x000000000041025e in generate_and_rsl_si (subsys=, signal=, handler_data=, signal_data=) at bsc_init.c:104 104 DEBUGP(DRR, "SI%s: %s\n", gsm_sitype_name(i), (gdb) p i $1 = SYSINFO_TYPE_1 (gdb) fquit From zecke at selfish.org Wed May 18 14:10:20 2011 From: zecke at selfish.org (Holger Freyther) Date: Wed, 18 May 2011 16:10:20 +0200 Subject: Problems suspected to be related to _output() rework In-Reply-To: <4DD2FE66.1060108@gnumonks.org> References: <20110517071531.GD2957@prithivi.gnumonks.org> <20110517072615.GE2957@prithivi.gnumonks.org> <4DD2B8BB.9070503@gnumonks.org> <4DD2C060.3040309@freyther.de> <4DD2FE66.1060108@gnumonks.org> Message-ID: <4DD3D34C.9060709@selfish.org> On 05/18/2011 01:01 AM, Pablo Neira Ayuso wrote: > thanks, I'll keep investigating this tomorrow. This tastes like a memory > corruption, but not sure that this occurs in the _output() function. > > I'll try to get a fix for this by tomorrow. > The easiest guess is that we either need the va_start/va_end inside the loop of _output, or need to copy the arguments again. to reproduce we should probably use the same arch and GCC/(E)GLIBC version that harald is using. holger From laforge at gnumonks.org Wed May 18 23:12:20 2011 From: laforge at gnumonks.org (Harald Welte) Date: Thu, 19 May 2011 01:12:20 +0200 Subject: Problems suspected to be related to _output() rework In-Reply-To: <4DD3D34C.9060709@selfish.org> References: <20110517071531.GD2957@prithivi.gnumonks.org> <20110517072615.GE2957@prithivi.gnumonks.org> <4DD2B8BB.9070503@gnumonks.org> <4DD2C060.3040309@freyther.de> <4DD2FE66.1060108@gnumonks.org> <4DD3D34C.9060709@selfish.org> Message-ID: <20110518231220.GE2974@prithivi.gnumonks.org> Hi all, On Wed, May 18, 2011 at 04:10:20PM +0200, Holger Freyther wrote: > The easiest guess is that we either need the va_start/va_end inside the loop > of _output, or need to copy the arguments again. to reproduce we should > probably use the same arch and GCC/(E)GLIBC version that harald is using. My testing is on Debian unstable on x86_64 (libc6-2.13-4). As indicated, reverting the commit Pablo indicated has fixed the problem. I have not seen the problem manifset itself on Ubuntu 11.04 on i386. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From pablo at gnumonks.org Thu May 19 00:16:03 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Thu, 19 May 2011 02:16:03 +0200 Subject: Problems suspected to be related to _output() rework In-Reply-To: <20110518231220.GE2974@prithivi.gnumonks.org> References: <20110517071531.GD2957@prithivi.gnumonks.org> <20110517072615.GE2957@prithivi.gnumonks.org> <4DD2B8BB.9070503@gnumonks.org> <4DD2C060.3040309@freyther.de> <4DD2FE66.1060108@gnumonks.org> <4DD3D34C.9060709@selfish.org> <20110518231220.GE2974@prithivi.gnumonks.org> Message-ID: <4DD46143.3060204@gnumonks.org> On 19/05/11 01:12, Harald Welte wrote: > Hi all, > > On Wed, May 18, 2011 at 04:10:20PM +0200, Holger Freyther wrote: > >> The easiest guess is that we either need the va_start/va_end inside the loop >> of _output, or need to copy the arguments again. to reproduce we should >> probably use the same arch and GCC/(E)GLIBC version that harald is using. > > My testing is on Debian unstable on x86_64 (libc6-2.13-4). As > indicated, reverting the commit Pablo indicated has fixed the problem. > > I have not seen the problem manifset itself on Ubuntu 11.04 on i386. While reading the manpages, I noticed this: "The functions vprintf(), vfprintf(), vsprintf(), vsnprintf() are equivalent to the functions printf(), fprintf(), sprintf(), snprintf(), respectively, except that they are called with a va_list instead of a variable number of arguments. These functions do not call the va_end macro. Consequently, the value of ap is undefined after the call. The application should call va_end(ap) itself afterwards." I have attached a patch, it basically restores: http://cgit.osmocom.org/cgit/libosmocore/commit/?id=81e9636454294ae10ef9bc8bf149dd0248afce76 But it includes a better notice. Please, apply. Thanks! -------------- next part -------------- A non-text attachment was scrubbed... Name: fix-logging.patch Type: text/x-patch Size: 1792 bytes Desc: not available URL: From pablo at gnumonks.org Tue May 17 18:04:05 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Tue, 17 May 2011 20:04:05 +0200 Subject: Problems suspected to be related to _output() rework In-Reply-To: <20110517071531.GD2957@prithivi.gnumonks.org> References: <20110517071531.GD2957@prithivi.gnumonks.org> Message-ID: <4DD2B895.80404@gnumonks.org> On 17/05/11 09:15, Harald Welte wrote: > Hi Pablo! > > I am sometimes getting osmo-nitb segfaults, and sometimes random bytes > as output of log messages. > > I've quickly started it in valgrind, and even during connection of the > BTS I get the following issues: > > <000d> input/ipaccess.c:693 accept()ed new OML link from 192.168.200.117 > ==21897== Conditional jump or move depends on uninitialised value(s) > ==21897== at 0x60D4BD4: vfprintf (vfprintf.c:1620) > ==21897== by 0x60F8F01: vsnprintf (vsnprintf.c:120) > ==21897== by 0x4E33670: _output (logging.c:177) > ==21897== by 0x4E33878: _logp (logging.c:227) > ==21897== by 0x4E33BCB: logp2 (logging.c:246) > ==21897== by 0x435E5C: listen_fd_cb (ipaccess.c:692) > ==21897== by 0x4E32419: osmo_select_main (select.c:132) > ==21897== by 0x40555B: main (bsc_hack.c:306) > ==21897== > ==21897== Use of uninitialised value of size 8 > ==21897== at 0x60D5008: vfprintf (vfprintf.c:1620) > ==21897== by 0x60F8F01: vsnprintf (vsnprintf.c:120) > ==21897== by 0x4E33670: _output (logging.c:177) > ==21897== by 0x4E33878: _logp (logging.c:227) > ==21897== by 0x4E33BCB: logp2 (logging.c:246) > ==21897== by 0x435E5C: listen_fd_cb (ipaccess.c:692) > ==21897== by 0x4E32419: osmo_select_main (select.c:132) > ==21897== by 0x40555B: main (bsc_hack.c:306) > ==21897== > ==21897== Use of uninitialised value of size 8 > ==21897== at 0x6101CE0: _IO_default_xsputn (genops.c:480) > ==21897== by 0x60D4ED3: vfprintf (vfprintf.c:1620) > ==21897== by 0x60F8F01: vsnprintf (vsnprintf.c:120) > ==21897== by 0x4E33670: _output (logging.c:177) > ==21897== by 0x4E33878: _logp (logging.c:227) > ==21897== by 0x4E33BCB: logp2 (logging.c:246) > ==21897== by 0x435E5C: listen_fd_cb (ipaccess.c:692) > ==21897== by 0x4E32419: osmo_select_main (select.c:132) > ==21897== by 0x40555B: main (bsc_hack.c:306) > ==21897== > ==21897== Conditional jump or move depends on uninitialised value(s) > ==21897== at 0x6101CF2: _IO_default_xsputn (genops.c:479) > ==21897== by 0x60D4ED3: vfprintf (vfprintf.c:1620) > ==21897== by 0x60F8F01: vsnprintf (vsnprintf.c:120) > ==21897== by 0x4E33670: _output (logging.c:177) > ==21897== by 0x4E33878: _logp (logging.c:227) > ==21897== by 0x4E33BCB: logp2 (logging.c:246) > ==21897== by 0x435E5C: listen_fd_cb (ipaccess.c:692) > ==21897== by 0x4E32419: osmo_select_main (select.c:132) > ==21897== by 0x40555B: main (bsc_hack.c:306) > ==21897== > <000d> input/ipaccess.c:755 accept()ed new RSL link from 192.168.200.117 > <0004> bsc_init.c:251 bootstrapping RSL for BTS/TRX (0/0) on ARFCN 871 > using MCC=602 MNC=42 LAC=1 CID=0 BSIC=63 TSC=7 > ==21897== Use of uninitialised value of size 8 > ==21897== at 0x60D2EDB: _itoa_word (_itoa.c:195) > ==21897== by 0x60D5386: vfprintf (vfprintf.c:1619) > ==21897== by 0x60F8F01: vsnprintf (vsnprintf.c:120) > ==21897== by 0x4E33670: _output (logging.c:177) > ==21897== by 0x4E33878: _logp (logging.c:227) > ==21897== by 0x4E33BCB: logp2 (logging.c:246) > ==21897== by 0x410141: inp_sig_cb (bsc_init.c:247) > > Can you please investigate? I suspect it to be related to your recent > _output() related changes in libosmocore. Not sure what's wrong yet, I don't hit those problems here, probabling we're using a different config file? You may want to revert this and give it a try: http://cgit.osmocom.org/cgit/libosmocore/commit/?id=81e9636454294ae10ef9bc8bf149dd0248afce76 From laforge at gnumonks.org Wed May 18 10:32:29 2011 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 18 May 2011 12:32:29 +0200 Subject: Problems suspected to be related to _output() rework In-Reply-To: <4DD2B895.80404@gnumonks.org> References: <20110517071531.GD2957@prithivi.gnumonks.org> <4DD2B895.80404@gnumonks.org> Message-ID: <20110518103229.GC7478@prithivi.gnumonks.org> Hi Pablo, On Tue, May 17, 2011 at 08:04:05PM +0200, Pablo Neira Ayuso wrote: > > Can you please investigate? I suspect it to be related to your recent > > _output() related changes in libosmocore. > > Not sure what's wrong yet, I don't hit those problems here, probabling > we're using a different config file? I will send you my config file in the attachment > You may want to revert this and give it a try: > > http://cgit.osmocom.org/cgit/libosmocore/commit/?id=81e9636454294ae10ef9bc8bf149dd0248afce76 I've reverted it, and the crashes and erroneous printouts appear to be gone, at least after the first test. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) -------------- next part -------------- ! ! OpenBSC configuration saved from vty ! ! password foo ! line vty no login ! network network country code 602 mobile network code 42 short name OpenBSC long name OpenBSC auth policy closed location updating reject cause 13 encryption a5 0 neci 1 rrlp mode none mm info 1 handover 0 handover window rxlev averaging 10 handover window rxqual averaging 1 handover window rxlev neighbor averaging 10 handover power budget interval 6 handover power budget hysteresis 3 handover maximum distance 9999 timer t3101 10 timer t3103 0 timer t3105 0 timer t3107 0 timer t3109 0 timer t3111 0 timer t3113 60 timer t3115 0 timer t3117 0 timer t3119 0 timer t3141 0 bts 0 type nanobts band DCS1800 cell_identity 0 location_area_code 1 training_sequence_code 7 base_station_id_code 63 ms max power 15 cell reselection hysteresis 4 rxlev access min 0 channel allocator ascending rach tx integer 9 rach max transmission 7 ip.access unit_id 900 0 oml ip.access stream_id 255 gprs mode none trx 0 rf_locked 0 arfcn 871 nominal power 23 max_power_red 20 rsl e1 tei 0 timeslot 0 phys_chan_config CCCH+SDCCH4 timeslot 1 phys_chan_config SDCCH8 timeslot 2 phys_chan_config TCH/F timeslot 3 phys_chan_config TCH/F timeslot 4 phys_chan_config TCH/F timeslot 5 phys_chan_config TCH/F timeslot 6 phys_chan_config TCH/F timeslot 7 phys_chan_config TCH/F From pablo at gnumonks.org Tue May 17 18:08:14 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Tue, 17 May 2011 20:08:14 +0200 Subject: comment on ipaccess-find: Work without providing an interface name Message-ID: <4DD2B98E.40400@gnumonks.org> Hi Holger, I think this patch is wrong: http://cgit.osmocom.org/cgit/openbsc/commit/?id=d3080be1317cfa0269b1c12c8f28ffe2c1855f98 ifname should be set if argc == 2, but it seems to be set if argc < 2, in that case argv[1] is always NULL. From zecke at selfish.org Tue May 17 18:32:05 2011 From: zecke at selfish.org (Holger Freyther) Date: Tue, 17 May 2011 20:32:05 +0200 Subject: comment on ipaccess-find: Work without providing an interface name In-Reply-To: <4DD2B98E.40400@gnumonks.org> References: <4DD2B98E.40400@gnumonks.org> Message-ID: <4DD2BF25.3080605@selfish.org> On 05/17/2011 08:08 PM, Pablo Neira Ayuso wrote: > Hi Holger, > > I think this patch is wrong: > > http://cgit.osmocom.org/cgit/openbsc/commit/?id=d3080be1317cfa0269b1c12c8f28ffe2c1855f98 > > ifname should be set if argc == 2, but it seems to be set if argc < 2, > in that case argv[1] is always NULL. yeah, it is broken for the interface case...sorry. From pablo at gnumonks.org Wed May 18 23:04:27 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Thu, 19 May 2011 01:04:27 +0200 Subject: fix missing all logging command option Message-ID: <4DD4507B.7000305@gnumonks.org> Hi Holger, Thanks for fixing this, I missed it: http://cgit.osmocom.org/cgit/libosmocore/commit/?id=952a18ed19f531b82e26108f8c46ef225fddef43 However, this fix is incomplete: /* This generates the logging command string for VTY. */ const char *log_vty_command_string(const struct log_info *info) { int len = 0, offset = 0, ret, i, rem; int size = strlen("logging level () ()") + 1; ^^ We also have to add `(all|' there. From zecke at selfish.org Wed May 18 23:10:02 2011 From: zecke at selfish.org (Holger Freyther) Date: Thu, 19 May 2011 01:10:02 +0200 Subject: fix missing all logging command option In-Reply-To: <4DD4507B.7000305@gnumonks.org> References: <4DD4507B.7000305@gnumonks.org> Message-ID: <4DD451CA.6030800@selfish.org> On 05/19/2011 01:04 AM, Pablo Neira Ayuso wrote: > Hi Holger, > > Thanks for fixing this, I missed it: > > http://cgit.osmocom.org/cgit/libosmocore/commit/?id=952a18ed19f531b82e26108f8c46ef225fddef43 > > However, this fix is incomplete: Hi, thanks for the review (*blushing*). I think we should rely more on talloc here, e.g. use the various _append functions provided by talloc. This way we avoid having such issues again. holger From pablo at gnumonks.org Thu May 19 00:18:33 2011 From: pablo at gnumonks.org (Pablo Neira Ayuso) Date: Thu, 19 May 2011 02:18:33 +0200 Subject: fix missing all logging command option In-Reply-To: <4DD451CA.6030800@selfish.org> References: <4DD4507B.7000305@gnumonks.org> <4DD451CA.6030800@selfish.org> Message-ID: <4DD461D9.6060403@gnumonks.org> On 19/05/11 01:10, Holger Freyther wrote: > On 05/19/2011 01:04 AM, Pablo Neira Ayuso wrote: >> Hi Holger, >> >> Thanks for fixing this, I missed it: >> >> http://cgit.osmocom.org/cgit/libosmocore/commit/?id=952a18ed19f531b82e26108f8c46ef225fddef43 >> >> However, this fix is incomplete: > > Hi, > > thanks for the review (*blushing*). I think we should rely more on talloc > here, e.g. use the various _append functions provided by talloc. This way we > avoid having such issues again. Yes, it's easy to make this sort of mistakes, that code looks better than before I patched it but still a bit sloppy. I'll see if I find some spare time to use your suggestion to improve it. From daniel at totalueberwachung.de Fri May 20 17:06:17 2011 From: daniel at totalueberwachung.de (Daniel Willmann) Date: Fri, 20 May 2011 19:06:17 +0200 Subject: [PATCH 00/10] Control interface for OpenBSC Message-ID: Hello, this patchset adds an SNMP-like control interface to OpenBSC. Currently you can set and get variables. This interface is enabled in osmo-bsc, osmo-bsc_nat, and in osmo-nitb. It currently supports querying the counters and rate counters, setting and querying the rf_locked status, and geographical location. In osmo-bsc_nat forwarding is implemented to set/query stuff in the actual osmo-bsc. The patches are located in the daniel/controlif branch. Please merge them if you feel they are ready or point me to the problems. Regards Daniel Willmann (10): Add documentation for the control interface protocol Add example to communicate through the control interface Add libctrl, an SNMP-like control interface libctrl: Add macros to help define commands libctrl: Add commands to query counters and rate_cntr bsc_hack: Use libctrl, listen on port 4249 osmo_bsc: Use libctrl, handle ctrl cmds on port 4249 or from the nat osmo_bsc: Add some libctrl commands libctrl: Add ctrl_cmd_cpy() to copy a command nat: Use libctrl and add command forwarding to osmo-bsc openbsc/configure.in | 1 + openbsc/contrib/bsc_control.py | 100 +++++ openbsc/doc/control-interface.txt | 21 + openbsc/include/openbsc/bsc_nat.h | 22 + openbsc/include/openbsc/control_cmd.h | 151 +++++++ openbsc/src/Makefile.am | 2 +- openbsc/src/libctrl/Makefile.am | 7 + openbsc/src/libctrl/control_cmd.c | 479 +++++++++++++++++++++++ openbsc/src/libctrl/control_if.c | 627 ++++++++++++++++++++++++++++++ openbsc/src/osmo-bsc/Makefile.am | 1 + openbsc/src/osmo-bsc/osmo_bsc_main.c | 167 ++++++++ openbsc/src/osmo-bsc/osmo_bsc_msc.c | 34 ++ openbsc/src/osmo-bsc_nat/Makefile.am | 1 + openbsc/src/osmo-bsc_nat/bsc_nat.c | 279 +++++++++++++ openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 1 + openbsc/src/osmo-nitb/Makefile.am | 3 +- openbsc/src/osmo-nitb/bsc_hack.c | 3 + 17 files changed, 1897 insertions(+), 2 deletions(-) create mode 100755 openbsc/contrib/bsc_control.py create mode 100644 openbsc/doc/control-interface.txt create mode 100644 openbsc/include/openbsc/control_cmd.h create mode 100644 openbsc/src/libctrl/Makefile.am create mode 100644 openbsc/src/libctrl/control_cmd.c create mode 100644 openbsc/src/libctrl/control_if.c -- 1.7.5.rc3 From daniel at totalueberwachung.de Fri May 20 17:06:18 2011 From: daniel at totalueberwachung.de (Daniel Willmann) Date: Fri, 20 May 2011 19:06:18 +0200 Subject: [PATCH 01/10] Add documentation for the control interface protocol In-Reply-To: References: Message-ID: <16498e0d14440d17513e4189e209d05f796a9548.1305905790.git.daniel@totalueberwachung.de> --- openbsc/doc/control-interface.txt | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) create mode 100644 openbsc/doc/control-interface.txt diff --git a/openbsc/doc/control-interface.txt b/openbsc/doc/control-interface.txt new file mode 100644 index 0000000..b43cafc --- /dev/null +++ b/openbsc/doc/control-interface.txt @@ -0,0 +1,21 @@ +The protocol for the control interface is wrapped inside the ip.access header +with the IPAC_PROTO_OSMO protocol ID (0xee). Inside the ip.access header is +a struct ipaccess_head_ext with protocol ID 0x00 which indicates the control +interface. + +After that the actual protocol is text based: + +* Getting the value of a variable +-> GET +<- GET_REPLY +or ERROR + +* Setting the value of a variable +-> SET +<- SET_REPLY +or ERROR + +* A value changes which triggers a trap +<- TRAP + + needs to be unique within a connection. '0' is not allowed -- 1.7.5.rc3 From daniel at totalueberwachung.de Fri May 20 17:06:19 2011 From: daniel at totalueberwachung.de (Daniel Willmann) Date: Fri, 20 May 2011 19:06:19 +0200 Subject: [PATCH 02/10] Add example to communicate through the control interface In-Reply-To: References: Message-ID: <53af2d3b339acbc084856bb8efc1ca50a997202a.1305905790.git.daniel@totalueberwachung.de> --- openbsc/contrib/bsc_control.py | 100 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 100 insertions(+), 0 deletions(-) create mode 100755 openbsc/contrib/bsc_control.py diff --git a/openbsc/contrib/bsc_control.py b/openbsc/contrib/bsc_control.py new file mode 100755 index 0000000..36c8e45 --- /dev/null +++ b/openbsc/contrib/bsc_control.py @@ -0,0 +1,100 @@ +#!/usr/bin/python + +import sys,os +from optparse import OptionParser +import socket +import struct + +verbose = False + +def prefix_ipa_ctrl_header(data): + return struct.pack(">HBB", len(data)+1, 0xee, 0) + data + +def remove_ipa_ctrl_header(data): + if (len(data) < 4): + raise BaseException("Answer too short!") + (plen, ipa_proto, osmo_proto) = struct.unpack(">HBB", data[:4]) + if (plen + 3 > len(data)): + print "Warning: Wrong payload length (expected %i, got %i)" % (plen, len(data) - 3) + if (ipa_proto != 0xee or osmo_proto != 0): + raise BaseException("Wrong protocol in answer!") + + return data[4:plen+3], data[plen+3:] + +def connect(host, port): + if verbose: + print "Connecting to host %s:%i" % (host, port) + + sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sck.setblocking(1) + sck.connect((host, port)) + return sck + +def send(sck, data): + if verbose: + print "Sending \"%s\"" %(data) + data = prefix_ipa_ctrl_header(data) + sck.send(data) + +def do_set(var, value, id, sck): + setmsg = "SET %s %s %s" %(options.id, var, value) + send(sck, setmsg) + +def do_get(var, id, sck): + getmsg = "GET %s %s" %(options.id, var) + send(sck, getmsg) + +parser = OptionParser("Usage: %prog [options] var [value]") +parser.add_option("-d", "--host", dest="host", + help="connect to HOST", metavar="HOST") +parser.add_option("-p", "--port", dest="port", type="int", + help="use PORT", metavar="PORT", default=4249) +parser.add_option("-g", "--get", action="store_true", + dest="cmd_get", help="perform GET operation") +parser.add_option("-s", "--set", action="store_true", + dest="cmd_set", help="perform SET operation") +parser.add_option("-i", "--id", dest="id", default="1", + help="set id manually", metavar="ID") +parser.add_option("-v", "--verbose", action="store_true", + dest="verbose", help="be verbose", default=False) +parser.add_option("-m", "--monitor", action="store_true", + dest="monitor", help="monitor the connection for traps", default=False) + +(options, args) = parser.parse_args() + +verbose = options.verbose + +if options.cmd_set and options.cmd_get: + parser.error("Get and set options are mutually exclusive!") + +if not (options.cmd_get or options.cmd_set or options.monitor): + parser.error("One of -m, -g, or -s must be set") + +if not (options.host): + parser.error("Destination host and port required!") + +sock = connect(options.host, options.port) + +if options.cmd_set: + if len(args) < 2: + parser.error("Set requires var and value arguments") + do_set(args[0], ' '.join(args[1:]), options.id, sock) + +if options.cmd_get: + if len(args) != 1: + parser.error("Get requires the var argument") + do_get(args[0], options.id, sock) + +data = sock.recv(1024) +while (len(data)>0): + (answer, data) = remove_ipa_ctrl_header(data) + print "Got message:", answer + +if options.monitor: + while (True): + data = sock.recv(1024) + while (len(data)>0): + (answer, data) = remove_ipa_ctrl_header(data) + print "Got message:", answer + +sock.close() -- 1.7.5.rc3 From daniel at totalueberwachung.de Fri May 20 17:06:20 2011 From: daniel at totalueberwachung.de (Daniel Willmann) Date: Fri, 20 May 2011 19:06:20 +0200 Subject: [PATCH 03/10] Add libctrl, an SNMP-like control interface In-Reply-To: References: Message-ID: <60dfe5d10b0854e63b2c187389a6fc7da958b7f3.1305905790.git.daniel@totalueberwachung.de> In contrast to the VTY interface the control interface is meant to be used by programs. This patch adds basic support, no commands are defined. --- openbsc/configure.in | 1 + openbsc/include/openbsc/control_cmd.h | 81 ++++++ openbsc/src/Makefile.am | 2 +- openbsc/src/libctrl/Makefile.am | 7 + openbsc/src/libctrl/control_cmd.c | 443 +++++++++++++++++++++++++++++++++ openbsc/src/libctrl/control_if.c | 369 +++++++++++++++++++++++++++ 6 files changed, 902 insertions(+), 1 deletions(-) create mode 100644 openbsc/include/openbsc/control_cmd.h create mode 100644 openbsc/src/libctrl/Makefile.am create mode 100644 openbsc/src/libctrl/control_cmd.c create mode 100644 openbsc/src/libctrl/control_if.c diff --git a/openbsc/configure.in b/openbsc/configure.in index e9bc079..af49c1e 100644 --- a/openbsc/configure.in +++ b/openbsc/configure.in @@ -92,6 +92,7 @@ AC_OUTPUT( src/libtrau/Makefile src/libabis/Makefile src/libbsc/Makefile + src/libctrl/Makefile src/libmsc/Makefile src/libmgcp/Makefile src/libcommon/Makefile diff --git a/openbsc/include/openbsc/control_cmd.h b/openbsc/include/openbsc/control_cmd.h new file mode 100644 index 0000000..8d543ee --- /dev/null +++ b/openbsc/include/openbsc/control_cmd.h @@ -0,0 +1,81 @@ +#ifndef _CONTROL_CMD_H +#define _CONTROL_CMD_H + +#include +#include + +#include + +#define CTRL_CMD_ERROR -1 +#define CTRL_CMD_HANDLED 0 +#define CTRL_CMD_REPLY 1 + +enum ctrl_node_type { + CTRL_NODE_ROOT, /* Root elements */ + CTRL_NODE_NET, /* Network specific (net.) */ + CTRL_NODE_BTS, /* BTS specific (net.btsN.) */ + CTRL_NODE_TRX, /* TRX specific (net.btsN.trxM.) */ + CTRL_NODE_TS, /* TS specific (net.btsN.trxM.tsI.) */ + _LAST_CTRL_NODE +}; + +enum ctrl_type { + CTRL_TYPE_UNKNOWN, + CTRL_TYPE_GET, + CTRL_TYPE_SET, + CTRL_TYPE_GET_REPLY, + CTRL_TYPE_SET_REPLY, + CTRL_TYPE_TRAP, + CTRL_TYPE_ERROR +}; + +struct ctrl_connection { + struct llist_head list_entry; + + /* The queue for sending data back */ + struct osmo_wqueue write_queue; + + /* Callback if the connection was closed */ + void (*closed_cb)(struct ctrl_connection *conn); + + /* Pending commands for this connection */ + struct llist_head cmds; +}; + +struct ctrl_cmd { + struct ctrl_connection *ccon; + enum ctrl_type type; + char *id; + void *node; + char *variable; + char *value; + char *reply; +}; + +struct ctrl_cmd_struct { + int nr_commands; + char **command; +}; + +struct ctrl_cmd_element { + const char *name; + const char *param; + struct ctrl_cmd_struct strcmd; + int (*set)(struct ctrl_cmd *cmd, void *data); + int (*get)(struct ctrl_cmd *cmd, void *data); + int (*verify)(struct ctrl_cmd *cmd, const char *value, void *data); +}; + +struct ctrl_cmd_map { + char *cmd; + enum ctrl_type type; +}; + +int ctrl_cmd_exec(vector vline, struct ctrl_cmd *command, vector node, void *data); +int ctrl_cmd_install(enum ctrl_node_type node, struct ctrl_cmd_element *cmd); +int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data); +int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd); +struct ctrl_cmd *ctrl_cmd_parse(void *ctx, struct msgb *msg); +struct msgb *ctrl_cmd_make(struct ctrl_cmd *cmd); + +#endif /* _CONTROL_CMD_H */ diff --git a/openbsc/src/Makefile.am b/openbsc/src/Makefile.am index df7b936..c7de811 100644 --- a/openbsc/src/Makefile.am +++ b/openbsc/src/Makefile.am @@ -2,7 +2,7 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS) AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS) -SUBDIRS = libcommon libabis libmgcp libbsc libmsc libtrau osmo-nitb osmo-bsc_mgcp utils ipaccess libgb gprs +SUBDIRS = libcommon libabis libmgcp libbsc libmsc libtrau libctrl osmo-nitb osmo-bsc_mgcp utils ipaccess libgb gprs # Conditional modules if BUILD_NAT diff --git a/openbsc/src/libctrl/Makefile.am b/openbsc/src/libctrl/Makefile.am new file mode 100644 index 0000000..286929b --- /dev/null +++ b/openbsc/src/libctrl/Makefile.am @@ -0,0 +1,7 @@ +INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) +AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS) +AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(COVERAGE_LDFLAGS) + +noinst_LIBRARIES = libctrl.a + +libctrl_a_SOURCES = control_if.c control_cmd.c diff --git a/openbsc/src/libctrl/control_cmd.c b/openbsc/src/libctrl/control_cmd.c new file mode 100644 index 0000000..06af3b3 --- /dev/null +++ b/openbsc/src/libctrl/control_cmd.c @@ -0,0 +1,443 @@ +/* SNMP-like status interface + * + * (C) 2010-2011 by Daniel Willmann + * (C) 2010-2011 by On-Waves + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +extern vector ctrl_node_vec; + +static struct ctrl_cmd_map ccm[] = { + {"GET", CTRL_TYPE_GET}, + {"SET", CTRL_TYPE_SET}, + {"GET_REPLY", CTRL_TYPE_GET_REPLY}, + {"SET_REPLY", CTRL_TYPE_SET_REPLY}, + {"TRAP", CTRL_TYPE_TRAP}, + {"ERROR", CTRL_TYPE_ERROR}, + {NULL} +}; + +int ctrl_cmd_str2type(char *s) +{ + int i; + for (i=0; ccm[i].cmd != NULL; i++) { + if (strcasecmp(s, ccm[i].cmd) == 0) + return ccm[i].type; + } + return CTRL_TYPE_UNKNOWN; +} + +char *ctrl_cmd_type2str(int type) +{ + int i; + for (i=0; ccm[i].cmd != NULL; i++) { + if (ccm[i].type == type) + return ccm[i].cmd; + } + return NULL; +} + +/* Functions from libosmocom */ +extern vector cmd_make_descvec(const char *string, const char *descstr); + +/* Get the ctrl_cmd_element that matches this command */ +static struct ctrl_cmd_element *ctrl_cmd_get_element_match(vector vline, vector node) +{ + int index, j; + const char *desc; + struct ctrl_cmd_element *cmd_el; + struct ctrl_cmd_struct *cmd_desc; + char *str; + + for (index = 0; index < vector_active(node); index++) { + if ((cmd_el = vector_slot(node, index))) { + cmd_desc = &cmd_el->strcmd; + if (cmd_desc->nr_commands > vector_active(vline)) + continue; + for (j =0; j < vector_active(vline); j++) { + str = vector_slot(vline, j); + desc = cmd_desc->command[j]; + if (desc[0] == '*') + return cmd_el; /* Partial match */ + if (strcmp(desc, str) != 0) + break; + } + /* We went through all the elements and all matched */ + if (j == cmd_desc->nr_commands) + return cmd_el; + } + } + + return NULL; +} + +int ctrl_cmd_exec(vector vline, struct ctrl_cmd *command, vector node, void *data) +{ + int ret = CTRL_CMD_ERROR; + struct ctrl_cmd_element *cmd_el; + + if ((command->type != CTRL_TYPE_GET) && (command->type != CTRL_TYPE_SET)) { + command->reply = "Trying to execute something not GET or SET"; + goto out; + } + if ((command->type == CTRL_TYPE_SET) && (!command->value)) { + command->reply = "SET without a value"; + goto out; + } + + if (!vline) + goto out; + + cmd_el = ctrl_cmd_get_element_match(vline, node); + + if (!cmd_el) { + command->reply = "Command not found"; + goto out; + } + + if (command->type == CTRL_TYPE_SET) { + if (!cmd_el->set) { + command->reply = "SET not implemented"; + goto out; + } + if (cmd_el->verify) { + if ((ret = cmd_el->verify(command, command->value, data))) { + ret = CTRL_CMD_ERROR; + command->reply = "Value failed verification."; + goto out; + } + } else if (cmd_el->param) { + LOGP(DINP, LOGL_NOTICE, "Parameter verification unimplemented, continuing without\n"); + } + ret = cmd_el->set(command, data); + goto out; + } else if (command->type == CTRL_TYPE_GET) { + if (!cmd_el->get) { + command->reply = "GET not implemented"; + goto out; + } + ret = cmd_el->get(command, data); + goto out; + } +out: + if (ret == CTRL_CMD_REPLY) { + if (command->type == CTRL_TYPE_SET) { + command->type = CTRL_TYPE_SET_REPLY; + } else if (command->type == CTRL_TYPE_GET) { + command->type = CTRL_TYPE_GET_REPLY; + } + } else if (ret == CTRL_CMD_ERROR) { + command->type = CTRL_TYPE_ERROR; + } + return ret; +} + +static void add_word(struct ctrl_cmd_struct *cmd, + const char *start, const char *end) +{ + if (!cmd->command) { + cmd->command = talloc_zero_array(tall_vty_vec_ctx, + char*, 1); + cmd->nr_commands = 0; + } else { + cmd->command = talloc_realloc(tall_vty_vec_ctx, + cmd->command, char*, + cmd->nr_commands + 1); + } + + cmd->command[cmd->nr_commands++] = talloc_strndup(cmd->command, + start, end - start); +} + +static void create_cmd_struct(struct ctrl_cmd_struct *cmd, const char *name) +{ + const char *cur, *word; + + for (cur = name, word = NULL; cur[0] != '\0'; ++cur) { + /* warn about optionals */ + if (cur[0] == '(' || cur[0] == ')' || cur[0] == '|') { + LOGP(DINP, LOGL_ERROR, + "Optionals are not supported in '%s'\n", name); + goto failure; + } + + if (isspace(cur[0])) { + if (word) { + add_word(cmd, word, cur); + word = NULL; + } + continue; + } + + if (!word) + word = cur; + } + + if (word) + add_word(cmd, word, cur); + + return; +failure: + cmd->nr_commands = 0; + talloc_free(cmd->command); +} + +int ctrl_cmd_install(enum ctrl_node_type node, struct ctrl_cmd_element *cmd) +{ + vector cmds_vec; + + cmds_vec = vector_lookup_ensure(ctrl_node_vec, node); + + if (!cmds_vec) { + cmds_vec = vector_init(5); + if (!cmds_vec) { + LOGP(DINP, LOGL_ERROR, "vector_init failed.\n"); + return -ENOMEM; + } + vector_set_index(ctrl_node_vec, node, cmds_vec); + } + + vector_set(cmds_vec, cmd); + + create_cmd_struct(&cmd->strcmd, cmd->name); + return 0; +} + +struct ctrl_cmd *ctrl_cmd_parse(void *ctx, struct msgb *msg) +{ + char *str, *tmp, *saveptr = NULL; + char *var, *val; + struct ctrl_cmd *cmd; + + cmd = talloc_zero(ctx, struct ctrl_cmd); + if (!cmd) { + LOGP(DINP, LOGL_ERROR, "Failed to allocate.\n"); + return NULL; + } + + /* Make sure input is NULL terminated */ + msgb_put_u8(msg, 0); + str = (char *) msg->l2h; + + tmp = strtok_r(str, " ", &saveptr); + if (!tmp) { + cmd->type = CTRL_TYPE_ERROR; + cmd->id = "err"; + cmd->reply = "Request malformed"; + goto err; + } + + cmd->type = ctrl_cmd_str2type(tmp); + if (cmd->type == CTRL_TYPE_UNKNOWN) { + cmd->type = CTRL_TYPE_ERROR; + cmd->id = "err"; + cmd->reply = "Request type unknown"; + goto err; + } + + tmp = strtok_r(NULL, " ", &saveptr); + + if (!tmp) { + cmd->type = CTRL_TYPE_ERROR; + cmd->id = "err"; + cmd->reply = "Missing ID"; + goto err; + } + cmd->id = talloc_strdup(cmd, tmp); + if (!cmd->id) + goto oom; + + switch (cmd->type) { + case CTRL_TYPE_GET: + var = strtok_r(NULL, " ", &saveptr); + if (!var) { + cmd->type = CTRL_TYPE_ERROR; + cmd->reply = "GET incomplete"; + LOGP(DINP, LOGL_NOTICE, "GET Command incomplete\n"); + goto err; + } + cmd->variable = talloc_strdup(cmd, var); + LOGP(DINP, LOGL_DEBUG, "Command: GET %s\n", cmd->variable); + break; + case CTRL_TYPE_SET: + var = strtok_r(NULL, " ", &saveptr); + val = strtok_r(NULL, " ", &saveptr); + if (!var || !val) { + cmd->type = CTRL_TYPE_ERROR; + cmd->reply = "SET incomplete"; + LOGP(DINP, LOGL_NOTICE, "SET Command incomplete\n"); + goto err; + } + cmd->variable = talloc_strdup(cmd, var); + cmd->value = talloc_strdup(cmd, val); + if (!cmd->variable || !cmd->value) + goto oom; + LOGP(DINP, LOGL_DEBUG, "Command: SET %s = %s\n", cmd->variable, cmd->value); + break; + case CTRL_TYPE_GET_REPLY: + case CTRL_TYPE_SET_REPLY: + case CTRL_TYPE_TRAP: + var = strtok_r(NULL, " ", &saveptr); + val = strtok_r(NULL, " ", &saveptr); + if (!var || !val) { + cmd->type = CTRL_TYPE_ERROR; + cmd->reply = "Trap/Reply incomplete"; + LOGP(DINP, LOGL_NOTICE, "Trap/Reply incomplete\n"); + goto err; + } + cmd->variable = talloc_strdup(cmd, var); + cmd->reply = talloc_strdup(cmd, val); + if (!cmd->variable || !cmd->reply) + goto oom; + LOGP(DINP, LOGL_DEBUG, "Command: TRAP/REPLY %s: %s\n", cmd->variable, cmd->reply); + break; + case CTRL_TYPE_ERROR: + var = strtok_r(NULL, "\0", &saveptr); + if (!var) { + cmd->reply = ""; + goto err; + } + cmd->reply = talloc_strdup(cmd, var); + if (!cmd->reply) + goto oom; + LOGP(DINP, LOGL_DEBUG, "Command: ERROR %s\n", cmd->reply); + break; + case CTRL_TYPE_UNKNOWN: + default: + cmd->type = CTRL_TYPE_ERROR; + cmd->reply = "Unknown type"; + goto err; + } + + return cmd; +oom: + cmd->type = CTRL_TYPE_ERROR; + cmd->id = "err"; + cmd->reply = "OOM"; +err: + talloc_free(cmd); + return NULL; +} + +struct msgb *ctrl_cmd_make(struct ctrl_cmd *cmd) +{ + struct msgb *msg; + char *type, *tmp; + + if (!cmd->id) + return NULL; + + msg = msgb_alloc_headroom(4096, 128, "ctrl command make"); + if (!msg) + return NULL; + + type = ctrl_cmd_type2str(cmd->type); + + switch (cmd->type) { + case CTRL_TYPE_GET: + if (!cmd->variable) + goto err; + + tmp = talloc_asprintf(cmd, "%s %s %s", type, cmd->id, cmd->variable); + if (!tmp) { + LOGP(DINP, LOGL_ERROR, "Failed to allocate cmd.\n"); + goto err; + } + + msg->l2h = msgb_put(msg, strlen(tmp)); + memcpy(msg->l2h, tmp, strlen(tmp)); + talloc_free(tmp); + break; + case CTRL_TYPE_SET: + if (!cmd->variable || !cmd->value) + goto err; + + tmp = talloc_asprintf(cmd, "%s %s %s %s", type, cmd->id, cmd->variable, + cmd->value); + if (!tmp) { + LOGP(DINP, LOGL_ERROR, "Failed to allocate cmd.\n"); + goto err; + } + + msg->l2h = msgb_put(msg, strlen(tmp)); + memcpy(msg->l2h, tmp, strlen(tmp)); + talloc_free(tmp); + break; + case CTRL_TYPE_GET_REPLY: + case CTRL_TYPE_SET_REPLY: + case CTRL_TYPE_TRAP: + if (!cmd->variable || !cmd->reply) + goto err; + + tmp = talloc_asprintf(cmd, "%s %s %s %s", type, cmd->id, cmd->variable, + cmd->reply); + if (!tmp) { + LOGP(DINP, LOGL_ERROR, "Failed to allocate cmd.\n"); + goto err; + } + + msg->l2h = msgb_put(msg, strlen(tmp)); + memcpy(msg->l2h, tmp, strlen(tmp)); + talloc_free(tmp); + break; + case CTRL_TYPE_ERROR: + if (!cmd->reply) + goto err; + + tmp = talloc_asprintf(cmd, "%s %s %s", type, cmd->id, + cmd->reply); + if (!tmp) { + LOGP(DINP, LOGL_ERROR, "Failed to allocate cmd.\n"); + goto err; + } + + msg->l2h = msgb_put(msg, strlen(tmp)); + memcpy(msg->l2h, tmp, strlen(tmp)); + talloc_free(tmp); + break; + default: + LOGP(DINP, LOGL_NOTICE, "Unknown command type %i\n", cmd->type); + goto err; + break; + } + + return msg; + +err: + msgb_free(msg); + return NULL; +} diff --git a/openbsc/src/libctrl/control_if.c b/openbsc/src/libctrl/control_if.c new file mode 100644 index 0000000..a607b10 --- /dev/null +++ b/openbsc/src/libctrl/control_if.c @@ -0,0 +1,369 @@ +/* SNMP-like status interface + * + * (C) 2010-2011 by Daniel Willmann + * (C) 2010-2011 by On-Waves + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include + +struct ctrl_handle { + struct osmo_fd listen_fd; + struct gsm_network *gsmnet; +}; + +vector ctrl_node_vec; + +int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd) +{ + int ret; + struct msgb *msg; + + msg = ctrl_cmd_make(cmd); + if (!msg) { + LOGP(DINP, LOGL_ERROR, "Could not generate msg\n"); + return -1; + } + + ipaccess_prepend_header_ext(msg, IPAC_PROTO_EXT_CTRL); + ipaccess_prepend_header(msg, IPAC_PROTO_OSMO); + + ret = osmo_wqueue_enqueue(queue, msg); + if (ret != 0) { + LOGP(DINP, LOGL_ERROR, "Failed to enqueue the command.\n"); + msgb_free(msg); + } + return ret; +} + +int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data) +{ + char *token, *request; + int num, i, j, ret, node; + struct gsm_network *gsmnet = data; + + struct gsm_network *net = NULL; + struct gsm_bts *bts = NULL; + struct gsm_bts_trx *trx = NULL; + struct gsm_bts_trx_ts *ts = NULL; + vector vline, cmdvec, cmds_vec; + + ret = CTRL_CMD_ERROR; + cmd->reply = "Someone forgot to fill in the reply."; + cmd->node = NULL; + node = CTRL_NODE_ROOT; + + request = talloc_strdup(tall_bsc_ctx, cmd->variable); + if (!request) + goto err; + + for (i=0;inode = net; + node = CTRL_NODE_NET; + } else if (!strncmp(token, "bts", 3)) { + if (!net) + break; + num = atoi(&token[3]); + bts = gsm_bts_num(net, num); + if (!bts) + break; + cmd->node = bts; + node = CTRL_NODE_BTS; + } else if (!strncmp(token, "trx", 3)) { + if (!bts) + break; + num = atoi(&token[3]); + trx = gsm_bts_trx_num(bts, num); + if (!trx) + break; + cmd->node = trx; + node = CTRL_NODE_TRX; + } else if (!strncmp(token, "ts", 2)) { + if (!trx) + break; + num = atoi(&token[2]); + if ((num >= 0) && (num < TRX_NR_TS)) + ts = &trx->ts[num]; + if (!ts) + break; + cmd->node = ts; + node = CTRL_NODE_TS; + } else { + /* If we're here the rest must be the command */ + cmdvec = vector_init(vector_active(vline)-i); + for (j=i; jreply = "Command not found"; + vector_free(cmdvec); + break; + } + + ret = ctrl_cmd_exec(cmdvec, cmd, cmds_vec, data); + + vector_free(cmdvec); + break; + } + } + + cmd_free_strvec(vline); + +err: + if (ret == CTRL_CMD_ERROR) + cmd->type = CTRL_TYPE_ERROR; + return ret; +} + +static void control_close_conn(struct ctrl_connection *ccon) +{ + close(ccon->write_queue.bfd.fd); + osmo_fd_unregister(&ccon->write_queue.bfd); + if (ccon->closed_cb) + ccon->closed_cb(ccon); + talloc_free(ccon); +} + +static int handle_control_read(struct osmo_fd * bfd) +{ + int ret = -1, error; + struct osmo_wqueue *queue; + struct ctrl_connection *ccon; + struct ipaccess_head *iph; + struct ipaccess_head_ext *iph_ext; + struct msgb *msg; + struct ctrl_cmd *cmd; + struct ctrl_handle *ctrl = bfd->data; + + queue = container_of(bfd, struct osmo_wqueue, bfd); + ccon = container_of(queue, struct ctrl_connection, write_queue); + + msg = ipaccess_read_msg(bfd, &error); + + if (!msg) { + if (error == 0) + LOGP(DINP, LOGL_INFO, "The control connection was closed\n"); + else + LOGP(DINP, LOGL_ERROR, "Failed to parse ip access message: %d\n", error); + + goto err; + } + + if (msg->len < sizeof(*iph) + sizeof(*iph_ext)) { + LOGP(DINP, LOGL_ERROR, "The message is too short.\n"); + goto err; + } + + iph = (struct ipaccess_head *) msg->data; + if (iph->proto != IPAC_PROTO_OSMO) { + LOGP(DINP, LOGL_ERROR, "Protocol mismatch. We got 0x%x\n", iph->proto); + goto err; + } + + iph_ext = (struct ipaccess_head_ext *) iph->data; + if (iph_ext->proto != IPAC_PROTO_EXT_CTRL) { + LOGP(DINP, LOGL_ERROR, "Extended protocol mismatch. We got 0x%x\n", iph_ext->proto); + goto err; + } + + msg->l2h = iph_ext->data; + + cmd = ctrl_cmd_parse(ccon, msg); + + if (cmd) { + cmd->ccon = ccon; + if (ctrl_cmd_handle(cmd, ctrl->gsmnet) != CTRL_CMD_HANDLED) { + ctrl_cmd_send(queue, cmd); + talloc_free(cmd); + } + } else { + cmd = talloc_zero(ccon, struct ctrl_cmd); + if (!cmd) + goto err; + LOGP(DINP, LOGL_ERROR, "Command parser error.\n"); + cmd->type = CTRL_TYPE_ERROR; + cmd->id = "err"; + cmd->reply = "Command parser error."; + ctrl_cmd_send(queue, cmd); + talloc_free(cmd); + } + + msgb_free(msg); + return 0; + +err: + control_close_conn(ccon); + msgb_free(msg); + return ret; +} + +static int control_write_cb(struct osmo_fd *bfd, struct msgb *msg) +{ + int rc; + + rc = write(bfd->fd, msg->data, msg->len); + if (rc != msg->len) + LOGP(DINP, LOGL_ERROR, "Failed to write message to the control connection.\n"); + + return rc; +} + +static struct ctrl_connection *ctrl_connection_alloc(void *ctx) +{ + struct ctrl_connection *ccon = talloc_zero(ctx, struct ctrl_connection); + if (!ccon) + return NULL; + + osmo_wqueue_init(&ccon->write_queue, 100); + /* Error handling here? */ + + INIT_LLIST_HEAD(&ccon->cmds); + return ccon; +} + +static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what) +{ + int ret, fd, on; + struct ctrl_connection *ccon; + struct sockaddr_in sa; + socklen_t sa_len = sizeof(sa); + + + if (!(what & BSC_FD_READ)) + return 0; + + fd = accept(listen_bfd->fd, (struct sockaddr *) &sa, &sa_len); + if (fd < 0) { + perror("accept"); + return fd; + } + LOGP(DINP, LOGL_INFO, "accept()ed new control connection from %s\n", + inet_ntoa(sa.sin_addr)); + + on = 1; + ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)); + if (ret != 0) { + LOGP(DNAT, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n", strerror(errno)); + close(fd); + return ret; + } + ccon = ctrl_connection_alloc(listen_bfd->data); + if (!ccon) { + LOGP(DINP, LOGL_ERROR, "Failed to allocate.\n"); + close(fd); + return -1; + } + + ccon->write_queue.bfd.data = listen_bfd->data; + ccon->write_queue.bfd.fd = fd; + ccon->write_queue.bfd.when = BSC_FD_READ; + ccon->write_queue.read_cb = handle_control_read; + ccon->write_queue.write_cb = control_write_cb; + + ret = osmo_fd_register(&ccon->write_queue.bfd); + if (ret < 0) { + LOGP(DINP, LOGL_ERROR, "Could not register FD.\n"); + close(ccon->write_queue.bfd.fd); + talloc_free(ccon); + } + + return ret; +} + +int 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; + + ctrl->gsmnet = gsmnet; + + ctrl_node_vec = vector_init(5); + if (!ctrl_node_vec) + return -ENOMEM; + + /* 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 ret; +} -- 1.7.5.rc3 From daniel at totalueberwachung.de Fri May 20 17:06:21 2011 From: daniel at totalueberwachung.de (Daniel Willmann) Date: Fri, 20 May 2011 19:06:21 +0200 Subject: [PATCH 04/10] libctrl: Add macros to help define commands In-Reply-To: References: Message-ID: --- openbsc/include/openbsc/control_cmd.h | 69 +++++++++++++++++++++++++++++++++ 1 files changed, 69 insertions(+), 0 deletions(-) diff --git a/openbsc/include/openbsc/control_cmd.h b/openbsc/include/openbsc/control_cmd.h index 8d543ee..c78b3dc 100644 --- a/openbsc/include/openbsc/control_cmd.h +++ b/openbsc/include/openbsc/control_cmd.h @@ -78,4 +78,73 @@ int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd); struct ctrl_cmd *ctrl_cmd_parse(void *ctx, struct msgb *msg); struct msgb *ctrl_cmd_make(struct ctrl_cmd *cmd); +#define CTRL_CMD_DEFINE_RANGE(cmdname, cmdstr, dtype, element, min, max) \ +int get_##cmdname(struct ctrl_cmd *cmd, void *data) \ +{ \ + dtype *node = data; \ + cmd->reply = talloc_asprintf(cmd, "%i", node->element); \ + if (!cmd->reply) { \ + cmd->reply = "OOM"; \ + return CTRL_CMD_ERROR; \ + } \ + return CTRL_CMD_REPLY; \ +} \ +int set_##cmdname(struct ctrl_cmd *cmd, void *data) \ +{ \ + dtype *node = data; \ + int tmp = atoi(cmd->value); \ + node->element = tmp; \ + return get_##cmdname(cmd, data); \ +} \ +int verify_##cmdname(struct ctrl_cmd *cmd, const char *value, void *data) \ +{ \ + int tmp = atoi(value); \ + if ((tmp >= min)&&(tmp <= max)) { \ + return 0; \ + } \ + return -1; \ +} \ +struct ctrl_cmd_element cmd_##cmdname = { \ + .name = cmdstr, \ + .param = NULL, \ + .get = &get_##cmdname, \ + .set = &set_##cmdname, \ + .verify = &verify_##cmdname, \ +} + +#define CTRL_CMD_DEFINE_STRING(cmdname, cmdstr, dtype, element) \ +int get_##cmdname(struct ctrl_cmd *cmd, dtype *data) \ +{ \ + cmd->reply = talloc_asprintf(cmd, "%s", data->element); \ + if (!cmd->reply) { \ + cmd->reply = "OOM"; \ + return CTRL_CMD_ERROR; \ + } \ + return CTRL_CMD_REPLY; \ +} \ +int set_##cmdname(struct ctrl_cmd *cmd, dtype *data) \ +{ \ + bsc_replace_string(cmd->node, &data->element, cmd->value); \ + return get_##cmdname(cmd, data); \ +} \ +struct ctrl_cmd_element cmd_##cmdname = { \ + .name = cmdstr, \ + .param = NULL, \ + .get = &get_##cmdname, \ + .set = &set_##cmdname, \ + .verify = NULL, \ +} + +#define CTRL_CMD_DEFINE(cmdname, cmdstr) \ +int get_##cmdname(struct ctrl_cmd *cmd, void *data); \ +int set_##cmdname(struct ctrl_cmd *cmd, void *data); \ +int verify_##cmdname(struct ctrl_cmd *cmd, const char *value, void *data); \ +struct ctrl_cmd_element cmd_##cmdname = { \ + .name = cmdstr, \ + .param = NULL, \ + .get = &get_##cmdname, \ + .set = &set_##cmdname, \ + .verify = &verify_##cmdname, \ +} + #endif /* _CONTROL_CMD_H */ -- 1.7.5.rc3 From daniel at totalueberwachung.de Fri May 20 17:06:22 2011 From: daniel at totalueberwachung.de (Daniel Willmann) Date: Fri, 20 May 2011 19:06:22 +0200 Subject: [PATCH 05/10] libctrl: Add commands to query counters and rate_cntr In-Reply-To: References: Message-ID: These commands are installed in controlif_setup. Query them like this: "rate_ctr...." for rate counters and "counter." for regular counters. may be either "abs" for absolute values or one or "per_{sec,min,hour,day}". It is possible to query all rate counters in a group (regardless of index) or all counters in a group and with a certain index if you omit and or just . --- openbsc/src/libctrl/control_if.c | 258 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 258 insertions(+), 0 deletions(-) diff --git a/openbsc/src/libctrl/control_if.c b/openbsc/src/libctrl/control_if.c index a607b10..0e625cd 100644 --- a/openbsc/src/libctrl/control_if.c +++ b/openbsc/src/libctrl/control_if.c @@ -49,7 +49,9 @@ #include #include +#include #include +#include #include #include @@ -342,6 +344,259 @@ static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what) return ret; } +static uint64_t get_rate_ctr_value(const struct rate_ctr *ctr, int intv) +{ + if (intv >= RATE_CTR_INTV_NUM) + return 0; + + /* Absolute value */ + if (intv == -1) { + return ctr->current; + } else { + return ctr->intv[intv].rate; + } +} + +static char *get_all_rate_ctr_in_group(const struct rate_ctr_group *ctrg, int intv) +{ + int i; + char *counters = talloc_strdup(tall_bsc_ctx, ""); + if (!counters) + return NULL; + + for (i=0;idesc->num_ctr;i++) { + counters = talloc_asprintf_append(counters, "\n%s.%u.%s %lu", + ctrg->desc->group_name_prefix, ctrg->idx, + ctrg->desc->ctr_desc[i].name, + get_rate_ctr_value(&ctrg->ctr[i], intv)); + if (!counters) + return NULL; + } + return counters; +} + +static int get_rate_ctr_group(const char *ctr_group, int intv, struct ctrl_cmd *cmd) +{ + int i; + char *counters; + struct rate_ctr_group *ctrg; + + cmd->reply = talloc_asprintf(cmd, "All counters in group %s", ctr_group); + if (!cmd->reply) + goto oom; + + for (i=0;;i++) { + ctrg = rate_ctr_get_group_by_name_idx(ctr_group, i); + if (!ctrg) + break; + + counters = get_all_rate_ctr_in_group(ctrg, intv); + if (!counters) + goto oom; + + cmd->reply = talloc_asprintf_append(cmd->reply, "%s", counters); + talloc_free(counters); + if (!cmd->reply) + goto oom; + } + + /* We found no counter group by that name */ + if (i == 0) { + cmd->reply = talloc_asprintf(cmd, "No counter group with name %s.", ctr_group); + return CTRL_CMD_ERROR; + } + + return CTRL_CMD_REPLY; +oom: + cmd->reply = "OOM."; + return CTRL_CMD_ERROR; +} + +static int get_rate_ctr_group_idx(const struct rate_ctr_group *ctrg, int intv, struct ctrl_cmd *cmd) +{ + char *counters; + + counters = get_all_rate_ctr_in_group(ctrg, intv); + if (!counters) + goto oom; + + cmd->reply = talloc_asprintf(cmd, "All counters in %s.%u%s", + ctrg->desc->group_name_prefix, ctrg->idx, counters); + talloc_free(counters); + if (!cmd->reply) + goto oom; + + return CTRL_CMD_REPLY; +oom: + cmd->reply = "OOM."; + return CTRL_CMD_ERROR; +} + +/* rate_ctr */ +CTRL_CMD_DEFINE(rate_ctr, "rate_ctr *"); +int get_rate_ctr(struct ctrl_cmd *cmd, void *data) +{ + int intv; + unsigned int idx; + char *ctr_group, *ctr_idx, *ctr_name, *tmp, *dup, *saveptr, *interval; + struct rate_ctr_group *ctrg; + const struct rate_ctr *ctr; + + dup = talloc_strdup(cmd, cmd->variable); + if (!dup) + goto oom; + + /* Skip over possible prefixes (net.) */ + tmp = strstr(dup, "rate_ctr"); + if (!tmp) { + talloc_free(dup); + cmd->reply = "rate_ctr not a token in rate_ctr command!"; + goto err; + } + + strtok_r(tmp, ".", &saveptr); + interval = strtok_r(NULL, ".", &saveptr); + if (!interval) { + talloc_free(dup); + cmd->reply = "Missing interval."; + goto err; + } + + if (!strcmp(interval, "abs")) { + intv = -1; + } else if (!strcmp(interval, "per_sec")) { + intv = RATE_CTR_INTV_SEC; + } else if (!strcmp(interval, "per_min")) { + intv = RATE_CTR_INTV_MIN; + } else if (!strcmp(interval, "per_hour")) { + intv = RATE_CTR_INTV_HOUR; + } else if (!strcmp(interval, "per_day")) { + intv = RATE_CTR_INTV_DAY; + } else { + talloc_free(dup); + cmd->reply = "Wrong interval."; + goto err; + } + + ctr_group = strtok_r(NULL, ".", &saveptr); + tmp = strtok_r(NULL, ".", &saveptr); + if (!ctr_group || !tmp) { + talloc_free(dup); + cmd->reply = "Counter group must be of form a.b"; + goto err; + } + ctr_group[strlen(ctr_group)] = '.'; + + ctr_idx = strtok_r(NULL, ".", &saveptr); + if (!ctr_idx) { + talloc_free(dup); + return get_rate_ctr_group(ctr_group, intv, cmd); + } + idx = atoi(ctr_idx); + + ctrg = rate_ctr_get_group_by_name_idx(ctr_group, idx); + if (!ctrg) { + talloc_free(dup); + cmd->reply = "Counter group not found."; + goto err; + } + + ctr_name = strtok_r(NULL, "\0", &saveptr); + if (!ctr_name) { + talloc_free(dup); + return get_rate_ctr_group_idx(ctrg, intv, cmd); + } + + ctr = rate_ctr_get_by_name(ctrg, ctr_name); + if (!ctr) { + cmd->reply = "Counter name not found."; + talloc_free(dup); + goto err; + } + + talloc_free(dup); + + cmd->reply = talloc_asprintf(cmd, "%lu", get_rate_ctr_value(ctr, intv)); + if (!cmd->reply) + goto oom; + + return CTRL_CMD_REPLY; +oom: + cmd->reply = "OOM"; +err: + return CTRL_CMD_ERROR; +} + +int set_rate_ctr(struct ctrl_cmd *cmd, void *data) +{ + cmd->reply = "Can't set rate counter."; + + return CTRL_CMD_ERROR; +} + +int verify_rate_ctr(struct ctrl_cmd *cmd, const char *value, void *data) +{ + return 0; +} + +/* counter */ +CTRL_CMD_DEFINE(counter, "counter *"); +int get_counter(struct ctrl_cmd *cmd, void *data) +{ + char *ctr_name, *tmp, *dup, *saveptr; + struct osmo_counter *counter; + + cmd->reply = "OOM"; + dup = talloc_strdup(cmd, cmd->variable); + if (!dup) + goto err; + + + tmp = strstr(dup, "counter"); + if (!tmp) { + talloc_free(dup); + goto err; + } + + strtok_r(tmp, ".", &saveptr); + ctr_name = strtok_r(NULL, "\0", &saveptr); + + if (!ctr_name) + goto err; + + counter = osmo_counter_get_by_name(ctr_name); + if (!counter) { + cmd->reply = "Counter name not found."; + talloc_free(dup); + goto err; + } + + talloc_free(dup); + + cmd->reply = talloc_asprintf(cmd, "%lu", counter->value); + if (!cmd->reply) { + cmd->reply = "OOM"; + goto err; + } + + return CTRL_CMD_REPLY; +err: + return CTRL_CMD_ERROR; +} + +int set_counter(struct ctrl_cmd *cmd, void *data) +{ + + cmd->reply = "Can't set counter."; + + return CTRL_CMD_ERROR; +} + +int verify_counter(struct ctrl_cmd *cmd, const char *value, void *data) +{ + return 0; +} + int controlif_setup(struct gsm_network *gsmnet, uint16_t port) { int ret; @@ -365,5 +620,8 @@ int controlif_setup(struct gsm_network *gsmnet, uint16_t port) return ret; } + ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_rate_ctr); + ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_counter); + return ret; } -- 1.7.5.rc3 From daniel at totalueberwachung.de Fri May 20 17:06:23 2011 From: daniel at totalueberwachung.de (Daniel Willmann) Date: Fri, 20 May 2011 19:06:23 +0200 Subject: [PATCH 06/10] bsc_hack: Use libctrl, listen on port 4249 In-Reply-To: References: Message-ID: --- openbsc/src/osmo-nitb/Makefile.am | 3 ++- openbsc/src/osmo-nitb/bsc_hack.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/openbsc/src/osmo-nitb/Makefile.am b/openbsc/src/osmo-nitb/Makefile.am index f067f43..2ad9f20 100644 --- a/openbsc/src/osmo-nitb/Makefile.am +++ b/openbsc/src/osmo-nitb/Makefile.am @@ -11,4 +11,5 @@ osmo_nitb_LDADD = -ldl -ldbi $(LIBCRYPT) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) \ $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libabis/libabis.a \ - $(top_builddir)/src/libcommon/libcommon.a + $(top_builddir)/src/libcommon/libcommon.a \ + $(top_builddir)/src/libctrl/libctrl.a diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c index 1fa039b..5ba84cd 100644 --- a/openbsc/src/osmo-nitb/bsc_hack.c +++ b/openbsc/src/osmo-nitb/bsc_hack.c @@ -214,6 +214,8 @@ extern int bts_model_rbs2k_init(void); extern int bts_model_hslfemto_init(void); void talloc_ctx_init(void); +extern int controlif_setup(struct gsm_network *gsmnet, uint16_t port); + extern enum node_type bsc_vty_go_parent(struct vty *vty); static struct vty_app_info vty_info = { @@ -263,6 +265,7 @@ int main(int argc, char **argv) exit(1); bsc_api_init(bsc_gsmnet, msc_bsc_api()); + controlif_setup(bsc_gsmnet, 4249); /* seed the PRNG */ srand(time(NULL)); -- 1.7.5.rc3 From daniel at totalueberwachung.de Fri May 20 17:06:24 2011 From: daniel at totalueberwachung.de (Daniel Willmann) Date: Fri, 20 May 2011 19:06:24 +0200 Subject: [PATCH 07/10] osmo_bsc: Use libctrl, handle ctrl cmds on port 4249 or from the nat In-Reply-To: References: Message-ID: <50eb7451410b565e706a7c096c16b4c3cc2d7664.1305905790.git.daniel@totalueberwachung.de> This patch initializes libctrl to listen for connections on port 4249. Additionally, control messages arriving from the nat will also be processed. --- openbsc/src/osmo-bsc/Makefile.am | 1 + openbsc/src/osmo-bsc/osmo_bsc_main.c | 3 +++ openbsc/src/osmo-bsc/osmo_bsc_msc.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 0 deletions(-) diff --git a/openbsc/src/osmo-bsc/Makefile.am b/openbsc/src/osmo-bsc/Makefile.am index 9a7619b..f32705c 100644 --- a/openbsc/src/osmo-bsc/Makefile.am +++ b/openbsc/src/osmo-bsc/Makefile.am @@ -15,4 +15,5 @@ osmo_bsc_LDADD = $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libabis/libabis.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libcommon/libcommon.a \ + $(top_builddir)/src/libctrl/libctrl.a \ $(LIBOSMOSCCP_LIBS) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index 16495d8..64daaf4 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -51,6 +51,7 @@ extern const char *openbsc_copyright; static int daemonize = 0; extern int bsc_bootstrap_network(int (*layer4)(struct gsm_network *, struct msgb *), const char *cfg_file); +extern void controlif_setup(struct gsm_network *gsmnet, uint16_t port); static void print_usage() { @@ -211,6 +212,8 @@ int main(int argc, char **argv) } bsc_api_init(bsc_gsmnet, osmo_bsc_api()); + controlif_setup(bsc_gsmnet, 4249); + data = bsc_gsmnet->msc_data; if (rf_ctl) bsc_replace_string(data, &data->rf_ctrl_name, rf_ctl); diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c index 2a32227..7b94af2 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c @@ -21,12 +21,15 @@ */ #include +#include #include #include #include #include #include +#include + #include #include @@ -189,6 +192,35 @@ static int msc_alink_do_write(struct osmo_fd *fd, struct msgb *msg) return ret; } +static void handle_ctrl(struct osmo_msc_data *msc, struct msgb *msg) +{ + int ret; + struct ctrl_cmd *cmd; + + cmd = ctrl_cmd_parse(msc->msc_con, msg); + if (!cmd) { + LOGP(DMSC, LOGL_ERROR, "Failed to parse control message.\n"); + cmd = talloc_zero(msc->msc_con, struct ctrl_cmd); + if (!cmd) { + LOGP(DMSC, LOGL_ERROR, "OOM!\n"); + return; + } + cmd->type = CTRL_TYPE_ERROR; + cmd->id = "err"; + cmd->reply = "Failed to parse control message."; + + ctrl_cmd_send(&msc->msc_con->write_queue, cmd); + talloc_free(cmd); + + return; + } + + ret = ctrl_cmd_handle(cmd, msc->network); + if (ret != CTRL_CMD_HANDLED) + ctrl_cmd_send(&msc->msc_con->write_queue, cmd); + talloc_free(cmd); +} + static void osmo_ext_handle(struct osmo_msc_data *msc, struct msgb *msg) { struct ipaccess_head *hh; @@ -206,6 +238,8 @@ static void osmo_ext_handle(struct osmo_msc_data *msc, struct msgb *msg) mgcp_forward(msc, msg); else if (hh_ext->proto == IPAC_PROTO_EXT_LAC) send_lacs(msc->network, msc->msc_con); + else if (hh_ext->proto == IPAC_PROTO_EXT_CTRL) + handle_ctrl(msc, msg); } static int ipaccess_a_fd_cb(struct osmo_fd *bfd) -- 1.7.5.rc3 From daniel at totalueberwachung.de Fri May 20 17:06:25 2011 From: daniel at totalueberwachung.de (Daniel Willmann) Date: Fri, 20 May 2011 19:06:25 +0200 Subject: [PATCH 08/10] osmo_bsc: Add some libctrl commands In-Reply-To: References: Message-ID: <14de2805e98e5f6767ebf2b824d17f6a1d767723.1305905790.git.daniel@totalueberwachung.de> * net.location to get/set the geographical location of the network format is ,,, * per trx rf_locked command (net.bts0.trx0.rf_locked) * network-wide rf_locked command (net.rf_locked) --- openbsc/src/osmo-bsc/osmo_bsc_main.c | 164 ++++++++++++++++++++++++++++++++++ 1 files changed, 164 insertions(+), 0 deletions(-) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index 64daaf4..5041a35 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -18,6 +18,7 @@ * */ +#include #include #include #include @@ -25,10 +26,12 @@ #include #include #include +#include #include #include #include +#include #include @@ -175,6 +178,164 @@ static void signal_handler(int signal) } } +struct location { + double lat; + double lon; + double height; + unsigned long age; +}; + +static struct location myloc; + +CTRL_CMD_DEFINE(net_loc, "location"); +int get_net_loc(struct ctrl_cmd *cmd, void *data) +{ + cmd->reply = talloc_asprintf(cmd, "%lu,%f,%f,%f", myloc.age, myloc.lat, myloc.lon, myloc.height); + if (!cmd->reply) { + cmd->reply = "OOM"; + return CTRL_CMD_ERROR; + } + + return CTRL_CMD_REPLY; +} + +int set_net_loc(struct ctrl_cmd *cmd, void *data) +{ + char *saveptr, *lat, *lon, *height, *age, *tmp; + + tmp = talloc_strdup(cmd, cmd->value); + if (!tmp) + goto oom; + + + age = strtok_r(tmp, ",", &saveptr); + lat = strtok_r(NULL, ",", &saveptr); + lon = strtok_r(NULL, ",", &saveptr); + height = strtok_r(NULL, "\0", &saveptr); + + myloc.age = atol(age); + myloc.lat = atof(lat); + myloc.lon = atof(lon); + myloc.height = atof(height); + talloc_free(tmp); + + return get_net_loc(cmd, data); +oom: + cmd->reply = "OOM"; + return CTRL_CMD_ERROR; +} + +int verify_net_loc(struct ctrl_cmd *cmd, const char *value, void *data) +{ + char *saveptr, *latstr, *lonstr, *heightstr, *agestr, *tmp; + int ret = 0; + unsigned long age; + double lat, lon, height; + + tmp = talloc_strdup(cmd, value); + if (!tmp) + return 1; + + agestr = strtok_r(tmp, ",", &saveptr); + latstr = strtok_r(NULL, ",", &saveptr); + lonstr = strtok_r(NULL, ",", &saveptr); + heightstr = strtok_r(NULL, "\0", &saveptr); + + if ((agestr == 0) || (latstr == 0) || (lonstr == 0) || (heightstr == 0)) + ret = 1; + + age = atol(agestr); + lat = atof(latstr); + lon = atof(lonstr); + height = atof(heightstr); + talloc_free(tmp); + + if ((age == 0) || (lat < -90) || (lat > 90) || (lon < -180) || (lon > 180)) + return 1; + + return ret; +} + +CTRL_CMD_DEFINE(trx_rf_lock, "rf_locked"); +int get_trx_rf_lock(struct ctrl_cmd *cmd, void *data) +{ + struct gsm_bts_trx *trx = cmd->node; + if (!trx) { + cmd->reply = "trx not found."; + return CTRL_CMD_ERROR; + } + + cmd->reply = talloc_asprintf(cmd, "%u", trx->nm_state.administrative == NM_STATE_LOCKED ? 1 : 0); + return CTRL_CMD_REPLY; +} + +int set_trx_rf_lock(struct ctrl_cmd *cmd, void *data) +{ + int locked = atoi(cmd->value); + struct gsm_bts_trx *trx = cmd->node; + if (!trx) { + cmd->reply = "trx not found."; + return CTRL_CMD_ERROR; + } + + gsm_trx_lock_rf(trx, locked); + + return get_trx_rf_lock(cmd, data); +} + +int verify_trx_rf_lock(struct ctrl_cmd *cmd, const char *value, void *data) +{ + int locked = atoi(cmd->value); + + if ((locked != 0) && (locked != 1)) + return 1; + + return 0; +} + +CTRL_CMD_DEFINE(net_rf_lock, "rf_locked"); +int get_net_rf_lock(struct ctrl_cmd *cmd, void *data) +{ + cmd->reply = "get only works for the individual trx properties."; + return CTRL_CMD_ERROR; +} + +int set_net_rf_lock(struct ctrl_cmd *cmd, void *data) +{ + int locked = atoi(cmd->value); + struct gsm_network *net = cmd->node; + struct gsm_bts *bts; + if (!net) { + cmd->reply = "net not found."; + return CTRL_CMD_ERROR; + } + + llist_for_each_entry(bts, &net->bts_list, list) { + struct gsm_bts_trx *trx; + llist_for_each_entry(trx, &bts->trx_list, list) { + gsm_trx_lock_rf(trx, locked); + } + } + + cmd->reply = talloc_asprintf(cmd, "%u", locked); + if (!cmd->reply) { + cmd->reply = "OOM."; + return CTRL_CMD_ERROR; + } + + return CTRL_CMD_REPLY; +} + +int verify_net_rf_lock(struct ctrl_cmd *cmd, const char *value, void *data) +{ + int locked = atoi(cmd->value); + + if ((locked != 0) && (locked != 1)) + return 1; + + return 0; +} + int main(int argc, char **argv) { struct osmo_msc_data *data; @@ -213,6 +374,9 @@ int main(int argc, char **argv) bsc_api_init(bsc_gsmnet, osmo_bsc_api()); 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); data = bsc_gsmnet->msc_data; if (rf_ctl) -- 1.7.5.rc3 From daniel at totalueberwachung.de Fri May 20 17:06:26 2011 From: daniel at totalueberwachung.de (Daniel Willmann) Date: Fri, 20 May 2011 19:06:26 +0200 Subject: [PATCH 09/10] libctrl: Add ctrl_cmd_cpy() to copy a command In-Reply-To: References: Message-ID: <66a5d0c11885f457323443ef643bd282e2d63dfa.1305905790.git.daniel@totalueberwachung.de> --- openbsc/include/openbsc/control_cmd.h | 1 + openbsc/src/libctrl/control_cmd.c | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 0 deletions(-) diff --git a/openbsc/include/openbsc/control_cmd.h b/openbsc/include/openbsc/control_cmd.h index c78b3dc..c94c7b5 100644 --- a/openbsc/include/openbsc/control_cmd.h +++ b/openbsc/include/openbsc/control_cmd.h @@ -77,6 +77,7 @@ int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data); int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd); struct ctrl_cmd *ctrl_cmd_parse(void *ctx, struct msgb *msg); struct msgb *ctrl_cmd_make(struct ctrl_cmd *cmd); +struct ctrl_cmd *ctrl_cmd_cpy(void *ctx, struct ctrl_cmd *cmd); #define CTRL_CMD_DEFINE_RANGE(cmdname, cmdstr, dtype, element, min, max) \ int get_##cmdname(struct ctrl_cmd *cmd, void *data) \ diff --git a/openbsc/src/libctrl/control_cmd.c b/openbsc/src/libctrl/control_cmd.c index 06af3b3..b5cff68 100644 --- a/openbsc/src/libctrl/control_cmd.c +++ b/openbsc/src/libctrl/control_cmd.c @@ -237,6 +237,42 @@ int ctrl_cmd_install(enum ctrl_node_type node, struct ctrl_cmd_element *cmd) return 0; } +struct ctrl_cmd *ctrl_cmd_cpy(void *ctx, struct ctrl_cmd *cmd) +{ + struct ctrl_cmd *cmd2; + + cmd2 = talloc_zero(ctx, struct ctrl_cmd); + if (!cmd2) + return NULL; + + cmd2->type = cmd->type; + if (cmd->id) { + cmd2->id = talloc_strdup(cmd2, cmd->id); + if (!cmd2->id) + goto err; + } + if (cmd->variable) { + cmd2->variable = talloc_strdup(cmd2, cmd->variable); + if (!cmd2->variable) + goto err; + } + if (cmd->value) { + cmd2->value = talloc_strdup(cmd2, cmd->value); + if (!cmd2->value) + goto err; + } + if (cmd->reply) { + cmd2->reply = talloc_strdup(cmd2, cmd->reply); + if (!cmd2->reply) + goto err; + } + + return cmd2; +err: + talloc_free(cmd2); + return NULL; +} + struct ctrl_cmd *ctrl_cmd_parse(void *ctx, struct msgb *msg) { char *str, *tmp, *saveptr = NULL; -- 1.7.5.rc3 From daniel at totalueberwachung.de Fri May 20 17:10:22 2011 From: daniel at totalueberwachung.de (Daniel Willmann) Date: Fri, 20 May 2011 19:10:22 +0200 Subject: [PATCH 10/10] nat: Use libctrl and add command forwarding to osmo-bsc In-Reply-To: References: Message-ID: <8e7cc41134347af88dc1341a13421cbd740c2790.1305905790.git.daniel@totalueberwachung.de> Passes commands beginning with "bsc." to the bsc that is responsible for LAC . --- openbsc/include/openbsc/bsc_nat.h | 22 +++ openbsc/src/osmo-bsc_nat/Makefile.am | 1 + openbsc/src/osmo-bsc_nat/bsc_nat.c | 279 ++++++++++++++++++++++++++++++ openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 1 + 4 files changed, 303 insertions(+), 0 deletions(-) diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index c3f32eb..442db2f 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -67,6 +67,24 @@ enum { }; /* + * Pending command entry + */ +struct bsc_cmd_list { + struct llist_head list_entry; + + struct osmo_timer_list timeout; + + /* The NATed ID used on the bsc_con*/ + int nat_id; + + /* The control connection from which the command originated */ + struct ctrl_connection *ccon; + + /* The command from the control connection */ + struct ctrl_cmd *cmd; +}; + +/* * Per BSC data structure */ struct bsc_connection { @@ -94,6 +112,10 @@ struct bsc_connection { int max_endpoints; int last_endpoint; + /* track the pending commands for this BSC */ + struct llist_head cmd_pending; + int last_id; + /* a back pointer */ struct bsc_nat *nat; }; diff --git a/openbsc/src/osmo-bsc_nat/Makefile.am b/openbsc/src/osmo-bsc_nat/Makefile.am index 03fe62b..eea720e 100644 --- a/openbsc/src/osmo-bsc_nat/Makefile.am +++ b/openbsc/src/osmo-bsc_nat/Makefile.am @@ -12,4 +12,5 @@ osmo_bsc_nat_LDADD = $(top_builddir)/src/libcommon/libcommon.a \ $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libabis/libabis.a \ $(top_builddir)/src/libtrau/libtrau.a \ + $(top_builddir)/src/libctrl/libctrl.a \ -lrt $(LIBOSMOSCCP_LIBS) diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index 8649f43..c28d4fc 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -79,6 +80,7 @@ static struct bsc_nat *nat; static void bsc_send_data(struct bsc_connection *bsc, const uint8_t *data, unsigned int length, int); static void msc_send_reset(struct bsc_msc_connection *con); static void bsc_stat_reject(int filter, struct bsc_connection *bsc, int normal); +static void bsc_del_pending(struct bsc_cmd_list *pending); struct bsc_config *bsc_config_num(struct bsc_nat *nat, int num) { @@ -845,6 +847,7 @@ static int ipaccess_msc_write_cb(struct osmo_fd *bfd, struct msgb *msg) void bsc_close_connection(struct bsc_connection *connection) { struct sccp_connections *sccp_patch, *tmp; + struct bsc_cmd_list *cmd_entry, *cmd_tmp; struct rate_ctr *ctr = NULL; /* stop the timeout timer */ @@ -872,6 +875,14 @@ void bsc_close_connection(struct bsc_connection *connection) sccp_connection_destroy(sccp_patch); } + /* Reply to all outstanding commands */ + llist_for_each_entry_safe(cmd_entry, cmd_tmp, &connection->cmd_pending, list_entry) { + cmd_entry->cmd->type = CTRL_TYPE_ERROR; + cmd_entry->cmd->reply = "BSC closed the connection"; + ctrl_cmd_send(&cmd_entry->ccon->write_queue, cmd_entry->cmd); + bsc_del_pending(cmd_entry); + } + /* close endpoints allocated by this BSC */ bsc_mgcp_clear_endpoints_for(connection); @@ -1147,12 +1158,36 @@ exit3: return -1; } +static struct bsc_cmd_list *bsc_get_pending(struct bsc_connection *bsc, char *id_str) +{ + struct bsc_cmd_list *cmd_entry; + int id = atoi(id_str); + if (id == 0) + return NULL; + + llist_for_each_entry(cmd_entry, &bsc->cmd_pending, list_entry) { + if (cmd_entry->nat_id == id) { + return cmd_entry; + } + } + return NULL; +} + +static void bsc_del_pending(struct bsc_cmd_list *pending) +{ + llist_del(&pending->list_entry); + osmo_timer_del(&pending->timeout); + talloc_free(pending->cmd); + talloc_free(pending); +} + static int ipaccess_bsc_read_cb(struct osmo_fd *bfd) { int error; struct bsc_connection *bsc = bfd->data; struct msgb *msg = ipaccess_read_msg(bfd, &error); struct ipaccess_head *hh; + struct ipaccess_head_ext *hh_ext; if (!msg) { if (error == 0) @@ -1185,6 +1220,80 @@ static int ipaccess_bsc_read_cb(struct osmo_fd *bfd) msgb_free(msg); return 0; } + /* Message contains the ipaccess_head_ext header, investigate further */ + } else if (hh->proto == IPAC_PROTO_OSMO && + msg->len > sizeof(*hh) + sizeof(*hh_ext)) { + + hh_ext = (struct ipaccess_head_ext *) hh->data; + /* l2h is where the actual command data is expected */ + msg->l2h = hh_ext->data; + + if (hh_ext->proto == IPAC_PROTO_EXT_CTRL) { + struct ctrl_cmd *cmd; + struct bsc_cmd_list *pending; + char *var, *id; + + cmd = ctrl_cmd_parse(bsc, msg); + msgb_free(msg); + + if (!cmd) { + cmd = talloc_zero(bsc, struct ctrl_cmd); + if (!cmd) { + LOGP(DNAT, LOGL_ERROR, "OOM!\n"); + return 0; + } + cmd->type = CTRL_TYPE_ERROR; + cmd->id = "err"; + cmd->reply = "Failed to parse command."; + ctrl_cmd_send(&bsc->write_queue, cmd); + talloc_free(cmd); + return 0; + } + + if (bsc->cfg) { + if (!llist_empty(&bsc->cfg->lac_list)) { + if (cmd->variable) { + var = talloc_asprintf(cmd, "bsc.%i.%s", ((struct bsc_lac_entry *)bsc->cfg->lac_list.next)->lac, + cmd->variable); + if (!var) { + cmd->type = CTRL_TYPE_ERROR; + cmd->reply = "OOM"; + goto err; + } + talloc_free(cmd->variable); + cmd->variable = var; + } + + /* Find the pending command */ + pending = bsc_get_pending(bsc, cmd->id); + if (pending) { + id = talloc_strdup(cmd, pending->cmd->id); + if (!id) { + cmd->type = CTRL_TYPE_ERROR; + cmd->reply = "OOM"; + goto err; + } + cmd->id = id; + ctrl_cmd_send(&pending->ccon->write_queue, cmd); + bsc_del_pending(pending); + } else { + /* We need to handle TRAPS here */ + if ((cmd->type != CTRL_TYPE_ERROR) && (cmd->type != CTRL_TYPE_TRAP)) { + LOGP(DNAT, LOGL_NOTICE, "Got control message from BSC without pending entry\n"); + cmd->type = CTRL_TYPE_ERROR; + cmd->reply = "No request outstanding"; + goto err; + } + } + } + } + talloc_free(cmd); + return 0; +err: + ctrl_cmd_send(&bsc->write_queue, cmd); + talloc_free(cmd); + return 0; + } } /* FIXME: Currently no PONG is sent to the BSC */ @@ -1265,7 +1374,10 @@ static int ipaccess_listen_bsc_cb(struct osmo_fd *bfd, unsigned int what) LOGP(DNAT, LOGL_NOTICE, "BSC connection on %d with IP: %s\n", fd, inet_ntoa(sa.sin_addr)); + llist_add(&bsc->list_entry, &nat->bsc_connections); + bsc->last_id = 0; + send_id_ack(bsc); send_id_req(bsc); send_mgcp_reset(bsc); @@ -1412,6 +1524,170 @@ static struct vty_app_info vty_info = { .is_config_node = bsc_vty_is_config_node, }; +static int get_next_free_bsc_id(struct bsc_connection *bsc) +{ + int new_id, overflow = 0; + struct bsc_cmd_list *pending; + + new_id = bsc->last_id; + do { + new_id++; + if (new_id <= 0) { + new_id = 1; + overflow++; + } + + llist_for_each_entry(pending, &bsc->cmd_pending, list_entry) { + if (pending->nat_id == new_id) + continue; + } + + /* ID is not in use */ + break; + } while ((new_id != bsc->last_id) && (overflow < 2)); + + if ((new_id == bsc->last_id) || (overflow == 2)) { + return -1; + } else { + bsc->last_id = new_id; + return new_id; + } +} + +static void pending_timeout_cb(void *data) +{ + struct bsc_cmd_list *pending = data; + LOGP(DNAT, LOGL_ERROR, "Command timed out\n"); + pending->cmd->type = CTRL_TYPE_ERROR; + pending->cmd->reply = "Command timed out"; + ctrl_cmd_send(&pending->ccon->write_queue, pending->cmd); + + bsc_del_pending(pending); +} + +static void ctrl_conn_closed_cb(struct ctrl_connection *connection) +{ + struct bsc_connection *bsc; + struct bsc_cmd_list *pending, *tmp; + + llist_for_each_entry(bsc, &nat->bsc_connections, list_entry) { + llist_for_each_entry_safe(pending, tmp, &bsc->cmd_pending, list_entry) { + if (pending->ccon == connection) + bsc_del_pending(pending); + } + } +} + +static int forward_to_bsc(struct ctrl_cmd *cmd) +{ + int ret = CTRL_CMD_HANDLED; + struct ctrl_cmd *bsc_cmd = NULL; + struct bsc_connection *bsc; + struct bsc_cmd_list *pending; + unsigned int lac; + char *lac_str, *tmp, *saveptr; + + /* Skip over the beginning (bsc.) */ + tmp = strtok_r(cmd->variable, ".", &saveptr); + lac_str = strtok_r(NULL, ".", &saveptr); + if (!lac_str) { + cmd->reply = "command incomplete"; + goto err; + } + lac = atoi(lac_str); + + tmp = strtok_r(NULL, "\0", &saveptr); + if (!tmp) { + cmd->reply = "command incomplete"; + goto err; + } + + llist_for_each_entry(bsc, &nat->bsc_connections, list_entry) { + if (!bsc->cfg) + continue; + if (!bsc->authenticated) + continue; + if (bsc_config_handles_lac(bsc->cfg, lac)) { + /* Add pending command to list */ + pending = talloc_zero(bsc, struct bsc_cmd_list); + if (!pending) { + cmd->reply = "OOM"; + goto err; + } + + pending->nat_id = get_next_free_bsc_id(bsc); + if (pending->nat_id < 0) { + cmd->reply = "No free ID found"; + goto err; + } + + bsc_cmd = ctrl_cmd_cpy(bsc, cmd); + if (!bsc_cmd) { + cmd->reply = "Could not forward command"; + goto err; + } + + talloc_free(bsc_cmd->id); + bsc_cmd->id = talloc_asprintf(bsc_cmd, "%i", pending->nat_id); + if (!bsc_cmd->id) { + cmd->reply = "OOM"; + goto err; + } + + talloc_free(bsc_cmd->variable); + bsc_cmd->variable = talloc_strdup(bsc_cmd, tmp); + if (!bsc_cmd->variable) { + cmd->reply = "OOM"; + goto err; + } + + if (ctrl_cmd_send(&bsc->write_queue, bsc_cmd)) { + cmd->reply = "Sending failed"; + goto err; + } + pending->ccon = cmd->ccon; + pending->ccon->closed_cb = ctrl_conn_closed_cb; + pending->cmd = cmd; + + /* Setup the timeout */ + pending->timeout.data = pending; + pending->timeout.cb = pending_timeout_cb; + /* TODO: Make timeout configurable */ + osmo_timer_schedule(&pending->timeout, 10, 0); + llist_add_tail(&pending->list_entry, &bsc->cmd_pending); + + goto done; + } + } + /* We end up here if there's no bsc to handle our LAC */ + cmd->reply = "no BSC with this LAC"; +err: + ret = CTRL_CMD_ERROR; +done: + if (bsc_cmd) + talloc_free(bsc_cmd); + return ret; + +} + +CTRL_CMD_DEFINE(fwd_cmd, "bsc *"); +int get_fwd_cmd(struct ctrl_cmd *cmd, void *data) +{ + return forward_to_bsc(cmd); +} + +int set_fwd_cmd(struct ctrl_cmd *cmd, void *data) +{ + return forward_to_bsc(cmd); +} + +int verify_fwd_cmd(struct ctrl_cmd *cmd, const char *value, void *data) +{ + return 0; +} + +extern int controlif_setup(struct gsm_network *gsmnet, uint16_t port); + int main(int argc, char **argv) { int rc; @@ -1471,6 +1747,9 @@ int main(int argc, char **argv) exit(1); } + controlif_setup(NULL, 4250); + ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_fwd_cmd); + nat->msc_con->connection_loss = msc_connection_was_lost; nat->msc_con->connected = msc_connection_connected; nat->msc_con->write_queue.read_cb = ipaccess_msc_read_cb; diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index dd32c75..f83323f 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c @@ -125,6 +125,7 @@ struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat) con->nat = nat; osmo_wqueue_init(&con->write_queue, 100); + INIT_LLIST_HEAD(&con->cmd_pending); return con; } -- 1.7.5.rc3 From alexander.huemer at xx.vu Tue May 24 13:16:12 2011 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Tue, 24 May 2011 15:16:12 +0200 Subject: [PATCH 0/2] libosmocore: autoconf improvements Message-ID: <1306242974-15358-1-git-send-email-alexander.huemer@xx.vu> These are improvements for the autoconf input of libosmocore. Please integrate them, if they seem useful. Alexander Huemer (2): libosmocore: add missing AC_LANG_SOURCE for current autoconf libosmocore: rename configure.in -> configure.ac configure.in => configure.ac | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) From alexander.huemer at xx.vu Tue May 24 13:16:13 2011 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Tue, 24 May 2011 15:16:13 +0200 Subject: [PATCH 1/2] libosmocore: add missing AC_LANG_SOURCE for current autoconf In-Reply-To: <1306242974-15358-1-git-send-email-alexander.huemer@xx.vu> References: <1306242974-15358-1-git-send-email-alexander.huemer@xx.vu> Message-ID: <1306242974-15358-2-git-send-email-alexander.huemer@xx.vu> autoconf >=2.68 demands the body of an AC_COMPILE_IFELSE to be wrapped in an AC_LANG_SOURCE macro, otherwise outputs annoying warnings on the invocation of `autoreconf -i`. this patch follows that demand. --- configure.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/configure.in b/configure.in index 2e22bb2..b923a21 100644 --- a/configure.in +++ b/configure.in @@ -24,7 +24,7 @@ AC_CHECK_HEADERS(execinfo.h sys/select.h sys/socket.h syslog.h ctype.h) saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden " AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) -AC_COMPILE_IFELSE([char foo;], +AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], [ AC_MSG_RESULT([yes]) SYMBOL_VISIBILITY="-fvisibility=hidden"], AC_MSG_RESULT([no])) -- 1.7.5.rc3 From alexander.huemer at xx.vu Tue May 24 13:16:14 2011 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Tue, 24 May 2011 15:16:14 +0200 Subject: [PATCH 2/2] libosmocore: rename configure.in -> configure.ac In-Reply-To: <1306242974-15358-1-git-send-email-alexander.huemer@xx.vu> References: <1306242974-15358-1-git-send-email-alexander.huemer@xx.vu> Message-ID: <1306242974-15358-3-git-send-email-alexander.huemer@xx.vu> rename autoconf input file to align with osmocom-bb host applications, and because that suffix is preferred nowadays. --- configure.in => configure.ac | 0 1 files changed, 0 insertions(+), 0 deletions(-) rename configure.in => configure.ac (100%) diff --git a/configure.in b/configure.ac similarity index 100% rename from configure.in rename to configure.ac -- 1.7.5.rc3 From laforge at gnumonks.org Tue May 24 15:20:15 2011 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 24 May 2011 17:20:15 +0200 Subject: [PATCH 0/2] libosmocore: autoconf improvements In-Reply-To: <1306242974-15358-1-git-send-email-alexander.huemer@xx.vu> References: <1306242974-15358-1-git-send-email-alexander.huemer@xx.vu> Message-ID: <20110524152015.GM10271@prithivi.gnumonks.org> On Tue, May 24, 2011 at 03:16:12PM +0200, Alexander Huemer wrote: > These are improvements for the autoconf input of libosmocore. > Please integrate them, if they seem useful. thanks, I've just merged them. I'll also merge the openbsc and libosmo-sccp related patches. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From alexander.huemer at xx.vu Tue May 24 13:16:53 2011 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Tue, 24 May 2011 15:16:53 +0200 Subject: [PATCH 0/4] openbsc: various improvements and fixes Message-ID: <1306243017-15661-1-git-send-email-alexander.huemer@xx.vu> These are improvements for the autoconf input of openbsc, an update to .gitignore, and a fix for a segfault. Please integrate them, if they seem useful. Alexander Huemer (4): openbsc: add missing AC_LANG_SOURCE for current autoconf openbsc: rename configure.in -> configure.ac openbsc: update .gitignore libabis: fix segfault on malformed ipaccess RSL link openbsc/.gitignore | 3 +++ openbsc/{configure.in => configure.ac} | 2 +- openbsc/src/libabis/input/ipaccess.c | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) From alexander.huemer at xx.vu Tue May 24 13:16:54 2011 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Tue, 24 May 2011 15:16:54 +0200 Subject: [PATCH 1/4] openbsc: add missing AC_LANG_SOURCE for current autoconf In-Reply-To: <1306243017-15661-1-git-send-email-alexander.huemer@xx.vu> References: <1306243017-15661-1-git-send-email-alexander.huemer@xx.vu> Message-ID: <1306243017-15661-2-git-send-email-alexander.huemer@xx.vu> autoconf >=2.68 demands the body of an AC_COMPILE_IFELSE to be wrapped in an AC_LANG_SOURCE macro, otherwise outputs annoying warnings on the invocation of `autoreconf -i`. this patch follows that demand. --- openbsc/configure.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/openbsc/configure.in b/openbsc/configure.in index e9bc079..74b3044 100644 --- a/openbsc/configure.in +++ b/openbsc/configure.in @@ -59,7 +59,7 @@ dnl Checks for typedefs, structures and compiler characteristics saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden " AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) -AC_COMPILE_IFELSE([char foo;], +AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], [ AC_MSG_RESULT([yes]) SYMBOL_VISIBILITY="-fvisibility=hidden"], AC_MSG_RESULT([no])) -- 1.7.5.rc3 From alexander.huemer at xx.vu Tue May 24 13:16:55 2011 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Tue, 24 May 2011 15:16:55 +0200 Subject: [PATCH 2/4] openbsc: rename configure.in -> configure.ac In-Reply-To: <1306243017-15661-1-git-send-email-alexander.huemer@xx.vu> References: <1306243017-15661-1-git-send-email-alexander.huemer@xx.vu> Message-ID: <1306243017-15661-3-git-send-email-alexander.huemer@xx.vu> rename autoconf input file to align with osmocom-bb host applications, and because that suffix is preferred nowadays. --- openbsc/{configure.in => configure.ac} | 0 1 files changed, 0 insertions(+), 0 deletions(-) rename openbsc/{configure.in => configure.ac} (100%) diff --git a/openbsc/configure.in b/openbsc/configure.ac similarity index 100% rename from openbsc/configure.in rename to openbsc/configure.ac -- 1.7.5.rc3 From alexander.huemer at xx.vu Tue May 24 13:16:56 2011 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Tue, 24 May 2011 15:16:56 +0200 Subject: [PATCH 3/4] openbsc: update .gitignore In-Reply-To: <1306243017-15661-1-git-send-email-alexander.huemer@xx.vu> References: <1306243017-15661-1-git-send-email-alexander.huemer@xx.vu> Message-ID: <1306243017-15661-4-git-send-email-alexander.huemer@xx.vu> --- openbsc/.gitignore | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/openbsc/.gitignore b/openbsc/.gitignore index bd35256..c19c16a 100644 --- a/openbsc/.gitignore +++ b/openbsc/.gitignore @@ -39,12 +39,15 @@ src/utils/isdnsync src/nat/bsc_nat src/gprs/osmo-sgsn src/gprs/osmo-gbproxy +src/osmo-bsc_nat/osmo-bsc_nat #tests +tests/bsc-nat/bsc_nat_test tests/channel/channel_test tests/db/db_test tests/debug/debug_test tests/gsm0408/gsm0408_test +tests/mgcp/mgcp_test tests/sccp/sccp_test tests/sms/sms_test tests/timer/timer_test -- 1.7.5.rc3 From alexander.huemer at xx.vu Tue May 24 13:16:57 2011 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Tue, 24 May 2011 15:16:57 +0200 Subject: [PATCH 4/4] libabis: fix segfault on malformed ipaccess RSL link In-Reply-To: <1306243017-15661-1-git-send-email-alexander.huemer@xx.vu> References: <1306243017-15661-1-git-send-email-alexander.huemer@xx.vu> Message-ID: <1306243017-15661-5-git-send-email-alexander.huemer@xx.vu> This patch fixes a segfault that occured when a ipaccess RSL link gets closed unexpectedly. The segfault can be provoked by connecting to the RSL port with ncat and hitting ^C. --- openbsc/src/libabis/input/ipaccess.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/openbsc/src/libabis/input/ipaccess.c b/openbsc/src/libabis/input/ipaccess.c index 1427118..cc2a7a0 100644 --- a/openbsc/src/libabis/input/ipaccess.c +++ b/openbsc/src/libabis/input/ipaccess.c @@ -429,12 +429,15 @@ static int ipaccess_drop(struct e1inp_ts *ts, struct osmo_fd *bfd) struct e1inp_sign_link *link; int bts_nr; - if (!ts) { + if (!ts || !bfd->data) { /* * If we don't have a TS this means that this is a RSL * connection but we are not past the authentication * handling yet. So we can safely delete this bfd and * wait for a reconnect. + * If we don't have bfd->data this means that a RSL + * connection was accept()ed, but nothing was recv()ed + * and the connection gets close()ed. */ osmo_fd_unregister(bfd); close(bfd->fd); -- 1.7.5.rc3 From alexander.huemer at xx.vu Tue May 24 13:17:25 2011 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Tue, 24 May 2011 15:17:25 +0200 Subject: [PATCH 0/2] libosmo-sccp: various improvements Message-ID: <1306243047-15767-1-git-send-email-alexander.huemer@xx.vu> These are improvements for the autoconf input of libosmo-sccp, and an update to .gitignore. Please integrate them, if they seem useful. Alexander Huemer (2): libosmo-sccp: add missing AC_LANG_SOURCE for current autoconf libosmo-sccp: update .gitignore .gitignore | 2 ++ configure.ac | 2 +- 2 files changed, 3 insertions(+), 1 deletions(-) From alexander.huemer at xx.vu Tue May 24 13:17:26 2011 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Tue, 24 May 2011 15:17:26 +0200 Subject: [PATCH 1/2] libosmo-sccp: add missing AC_LANG_SOURCE for current autoconf In-Reply-To: <1306243047-15767-1-git-send-email-alexander.huemer@xx.vu> References: <1306243047-15767-1-git-send-email-alexander.huemer@xx.vu> Message-ID: <1306243047-15767-2-git-send-email-alexander.huemer@xx.vu> autoconf >=2.68 demands the body of an AC_COMPILE_IFELSE to be wrapped in an AC_LANG_SOURCE macro, otherwise outputs annoying warnings on the invocation of `autoreconf -i`. this patch follows that demand. --- configure.ac | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index 41495fe..b16b1f3 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.3.0) saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden " AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) -AC_COMPILE_IFELSE([char foo;], +AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], [ AC_MSG_RESULT([yes]) SYMBOL_VISIBILITY="-fvisibility=hidden"], AC_MSG_RESULT([no])) -- 1.7.5.rc3 From alexander.huemer at xx.vu Tue May 24 13:17:27 2011 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Tue, 24 May 2011 15:17:27 +0200 Subject: [PATCH 2/2] libosmo-sccp: update .gitignore In-Reply-To: <1306243047-15767-1-git-send-email-alexander.huemer@xx.vu> References: <1306243047-15767-1-git-send-email-alexander.huemer@xx.vu> Message-ID: <1306243047-15767-3-git-send-email-alexander.huemer@xx.vu> --- .gitignore | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/.gitignore b/.gitignore index 7c9cb0f..d5c4bc9 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,8 @@ tests/channel/channel_test tests/db/db_test tests/debug/debug_test tests/gsm0408/gsm0408_test +tests/m2ua/m2ua_test +tests/mtp/mtp_parse_test tests/sccp/sccp_test tests/sms/sms_test tests/timer/timer_test -- 1.7.5.rc3 From mortzy at gmail.com Tue May 24 16:23:09 2011 From: mortzy at gmail.com (Steve Mortimer) Date: Tue, 24 May 2011 17:23:09 +0100 Subject: Cannot compile OpenBSC Message-ID: <4DDBDB6D.6050108@gmail.com> Hi, I have followed the instructions on building openBSC and have used the git versions of both libosmocore and openbsc. libosmocore builds fine but openbsc gives the following error when running make (after autoreconf -i && ./configure) Making all in libcommon make[3]: Entering directory `/home/user/Desktop/openbsc_git/openbsc/src/libcommon' CC common_vty.o In file included from common_vty.c:27: ../../include/openbsc/gsm_data.h:26: error: nested redefinition of ?enum gsm_phys_chan_config? ../../include/openbsc/gsm_data.h:26: error: redeclaration of ?enum gsm_phys_chan_config? ../../include/openbsc/gsm_data.h:27: error: redeclaration of enumerator ?GSM_PCHAN_NONE? /usr/local/include/osmocom/gsm/gsm_utils.h:119: note: previous definition of ?GSM_PCHAN_NONE? was here ../../include/openbsc/gsm_data.h:28: error: redeclaration of enumerator ?GSM_PCHAN_CCCH? /usr/local/include/osmocom/gsm/gsm_utils.h:120: note: previous definition of ?GSM_PCHAN_CCCH? was here ../../include/openbsc/gsm_data.h:29: error: redeclaration of enumerator ?GSM_PCHAN_CCCH_SDCCH4? /usr/local/include/osmocom/gsm/gsm_utils.h:121: note: previous definition of ?GSM_PCHAN_CCCH_SDCCH4? was here ../../include/openbsc/gsm_data.h:30: error: redeclaration of enumerator ?GSM_PCHAN_TCH_F? /usr/local/include/osmocom/gsm/gsm_utils.h:122: note: previous definition of ?GSM_PCHAN_TCH_F? was here ../../include/openbsc/gsm_data.h:31: error: redeclaration of enumerator ?GSM_PCHAN_TCH_H? /usr/local/include/osmocom/gsm/gsm_utils.h:123: note: previous definition of ?GSM_PCHAN_TCH_H? was here ../../include/openbsc/gsm_data.h:32: error: redeclaration of enumerator ?GSM_PCHAN_SDCCH8_SACCH8C? /usr/local/include/osmocom/gsm/gsm_utils.h:124: note: previous definition of ?GSM_PCHAN_SDCCH8_SACCH8C? was here ../../include/openbsc/gsm_data.h:33: error: redeclaration of enumerator ?GSM_PCHAN_PDCH? /usr/local/include/osmocom/gsm/gsm_utils.h:125: note: previous definition of ?GSM_PCHAN_PDCH? was here ../../include/openbsc/gsm_data.h:34: error: redeclaration of enumerator ?GSM_PCHAN_TCH_F_PDCH? /usr/local/include/osmocom/gsm/gsm_utils.h:126: note: previous definition of ?GSM_PCHAN_TCH_F_PDCH? was here ../../include/openbsc/gsm_data.h:35: error: redeclaration of enumerator ?GSM_PCHAN_UNKNOWN? /usr/local/include/osmocom/gsm/gsm_utils.h:127: note: previous definition of ?GSM_PCHAN_UNKNOWN? was here ../../include/openbsc/gsm_data.h:37: error: redeclaration of enumerator ?_GSM_PCHAN_MAX? /usr/local/include/osmocom/gsm/gsm_utils.h:129: note: previous definition of ?_GSM_PCHAN_MAX? was here ../../include/openbsc/gsm_data.h:39: error: nested redefinition of ?enum gsm_chan_t? ../../include/openbsc/gsm_data.h:39: error: redeclaration of ?enum gsm_chan_t? ../../include/openbsc/gsm_data.h:40: error: redeclaration of enumerator ?GSM_LCHAN_NONE? /usr/local/include/osmocom/gsm/gsm_utils.h:133: note: previous definition of ?GSM_LCHAN_NONE? was here ../../include/openbsc/gsm_data.h:41: error: redeclaration of enumerator ?GSM_LCHAN_SDCCH? /usr/local/include/osmocom/gsm/gsm_utils.h:134: note: previous definition of ?GSM_LCHAN_SDCCH? was here ../../include/openbsc/gsm_data.h:42: error: redeclaration of enumerator ?GSM_LCHAN_TCH_F? /usr/local/include/osmocom/gsm/gsm_utils.h:135: note: previous definition of ?GSM_LCHAN_TCH_F? was here ../../include/openbsc/gsm_data.h:43: error: redeclaration of enumerator ?GSM_LCHAN_TCH_H? /usr/local/include/osmocom/gsm/gsm_utils.h:136: note: previous definition of ?GSM_LCHAN_TCH_H? was here ../../include/openbsc/gsm_data.h:44: error: redeclaration of enumerator ?GSM_LCHAN_UNKNOWN? /usr/local/include/osmocom/gsm/gsm_utils.h:137: note: previous definition of ?GSM_LCHAN_UNKNOWN? was here ../../include/openbsc/gsm_data.h:45: error: redeclaration of enumerator ?GSM_LCHAN_CCCH? /usr/local/include/osmocom/gsm/gsm_utils.h:138: note: previous definition of ?GSM_LCHAN_CCCH? was here ../../include/openbsc/gsm_data.h:47: error: redeclaration of enumerator ?_GSM_LCHAN_MAX? /usr/local/include/osmocom/gsm/gsm_utils.h:140: note: previous definition of ?_GSM_LCHAN_MAX? was here make[3]: *** [common_vty.o] Error 1 make[3]: Leaving directory `/home/user/openbsc_git/openbsc/src/libcommon' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/user/openbsc_git/openbsc/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/user/openbsc_git/openbsc' make: *** [all] Error 2 Any ideas? Steve From laforge at gnumonks.org Tue May 24 17:17:32 2011 From: laforge at gnumonks.org (Harald Welte) Date: Tue, 24 May 2011 19:17:32 +0200 Subject: Cannot compile OpenBSC In-Reply-To: <4DDBDB6D.6050108@gmail.com> References: <4DDBDB6D.6050108@gmail.com> Message-ID: <20110524171732.GO10271@prithivi.gnumonks.org> Hi Steve, On Tue, May 24, 2011 at 05:23:09PM +0100, Steve Mortimer wrote: > I have followed the instructions on building openBSC and have used > the git versions of both libosmocore and openbsc. > libosmocore builds fine but openbsc gives the following error when > running make (after autoreconf -i && ./configure) sorry for the obvious hint, but can you please make sure you have the current git head of both versions and do a full make clean && autoreconf -fi && ./configure && make install for libosmocore and make clean && autoreconf -fi && ./configure && make for openbsc? it may be that you still have some old code somewhere causing this problem. I'm sorry for the fall-out, but in order to not duplicate code on the BTS side, I had to move quite a bit of stuff into libosmogsm recently, and will probably continue to do so over the next days or so. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From mortzy at gmail.com Wed May 25 09:06:44 2011 From: mortzy at gmail.com (Steve Mortimer) Date: Wed, 25 May 2011 10:06:44 +0100 Subject: Cannot compile OpenBSC In-Reply-To: <20110524171732.GO10271@prithivi.gnumonks.org> References: <4DDBDB6D.6050108@gmail.com> <20110524171732.GO10271@prithivi.gnumonks.org> Message-ID: <4DDCC6A4.5070701@gmail.com> On 24/05/11 18:17, Harald Welte wrote: > I'm sorry for the fall-out, but in order to not duplicate code on the > BTS side, I had to move quite a bit of stuff into libosmogsm recently, > and will probably continue to do so over the next days or so. > > Regards, > Harald Thanks Harold, I pulled down the git head for both again and OpenBSC now builds fine. I would like to build an older version of OpenBSC (from around December) I have but are you saying this is not possible or is there a way of pulling down a matching version of libosmocore? Many thanks, Steve From laforge at gnumonks.org Wed May 25 10:12:32 2011 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 25 May 2011 12:12:32 +0200 Subject: Cannot compile OpenBSC In-Reply-To: <4DDCC6A4.5070701@gmail.com> References: <4DDBDB6D.6050108@gmail.com> <20110524171732.GO10271@prithivi.gnumonks.org> <4DDCC6A4.5070701@gmail.com> Message-ID: <20110525101232.GB30526@prithivi.gnumonks.org> Hi Steve, On Wed, May 25, 2011 at 10:06:44AM +0100, Steve Mortimer wrote: > I would like to build an older version of OpenBSC (from around > December) I have but are you saying this is not possible or is there > a way of pulling down a matching version of libosmocore? well, i'd suggest to check out a version with the same date/timestamp. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From manatails007 at gmail.com Fri May 27 03:51:37 2011 From: manatails007 at gmail.com (Seungju Kim) Date: Thu, 26 May 2011 23:51:37 -0400 Subject: Roaming Message-ID: How does the phone know if it is roaming or not? When my phone camps to OpenBTS network it says it is roaming but in OpenBSC it doesn't. I wonder what makes such difference Sent from my iPhone From admin at manateeshome.com Fri May 27 04:02:31 2011 From: admin at manateeshome.com (Seungju Kim) Date: Fri, 27 May 2011 00:02:31 -0400 Subject: Roaming Message-ID: <7941B11B-9A03-4DF6-BFC6-AA80B89DE62A@manateeshome.com> How does the phone know if it is roaming or not? When my phone camps to OpenBTS network it says it is roaming but in OpenBSC it doesn't. I wonder what makes such difference Sent from my iPhone -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at gnumonks.org Fri May 27 08:05:15 2011 From: laforge at gnumonks.org (Harald Welte) Date: Fri, 27 May 2011 10:05:15 +0200 Subject: Roaming In-Reply-To: <7941B11B-9A03-4DF6-BFC6-AA80B89DE62A@manateeshome.com> References: <7941B11B-9A03-4DF6-BFC6-AA80B89DE62A@manateeshome.com> Message-ID: <20110527080515.GD17383@prithivi.gnumonks.org> On Fri, May 27, 2011 at 12:02:31AM -0400, Seungju Kim wrote: > How does the phone know if it is roaming or not? When my phone camps > to OpenBTS network it says it is roaming but in OpenBSC it doesn't. Are you running OpenBSC and OpenBTS with the same phone, same simcard oon the same MCC/MNC? Then you should not see any difference. They only way a phone knows is if the MCC/MNC of the IMSI in the SIM is identical with the MCC/MNC of the serving cell. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From admin at manateeshome.com Fri May 27 19:51:08 2011 From: admin at manateeshome.com (Seungju Kim) Date: Fri, 27 May 2011 15:51:08 -0400 Subject: Roaming In-Reply-To: <20110527080515.GD17383@prithivi.gnumonks.org> References: <7941B11B-9A03-4DF6-BFC6-AA80B89DE62A@manateeshome.com> <20110527080515.GD17383@prithivi.gnumonks.org> Message-ID: One of my feature phone does not open Roaming Manager. It says it can only be opened while roaming although I used MCC/MNC that the phone does not recognize Sent from my iPhone On May 27, 2011, at 4:05 AM, Harald Welte wrote: > On Fri, May 27, 2011 at 12:02:31AM -0400, Seungju Kim wrote: >> How does the phone know if it is roaming or not? When my phone camps >> to OpenBTS network it says it is roaming but in OpenBSC it doesn't. > > Are you running OpenBSC and OpenBTS with the same phone, same simcard > oon the same MCC/MNC? Then you should not see any difference. > > They only way a phone knows is if the MCC/MNC of the IMSI in the SIM is > identical with the MCC/MNC of the serving cell. > > -- > - Harald Welte http://laforge.gnumonks.org/ > ============================================================================ > "Privacy in residential applications is a desirable marketing option." > (ETSI EN 300 175-7 Ch. A6) > From hwit at a-domani.nl Fri May 27 06:49:40 2011 From: hwit at a-domani.nl (Hans Witvliet) Date: Fri, 27 May 2011 08:49:40 +0200 Subject: two questions Message-ID: <1306478980.7617.26.camel@t43.lan0.a-domani.nl> Hi all, Got two questions: Firstly, i would like to know if it is possible to have bts and bsc at completely different locations: can the connections be encapsulated in a vpn tunnel (openvpn, ipsec). Or is that connection very sensitive to latency? Secondly, anybody ever looked at the new nanobts/femtobts from "radio access"? Probably they don't manufacture those themselves, but are re-selling it allong with their own bsc/nomc/hlr (clarity) Clarity should be able to handle the new nanobts aswell as the model from ipaccess. >From what i read, it is scalled down model compared to the nano-bts from ipaccess. And scaleddown in two aspects: Limited power: just 200mW and price: around 50 euro. hw From holger at freyther.de Fri May 27 07:51:00 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 27 May 2011 09:51:00 +0200 Subject: two questions In-Reply-To: <1306478980.7617.26.camel@t43.lan0.a-domani.nl> References: <1306478980.7617.26.camel@t43.lan0.a-domani.nl> Message-ID: <4DDF57E4.70109@freyther.de> On 05/27/2011 08:49 AM, Hans Witvliet wrote: > Hi all, Hi, > > Got two questions: > Firstly, i would like to know if it is possible to have bts and bsc at > completely different locations: can the connections be encapsulated in a > vpn tunnel (openvpn, ipsec). Or is that connection very sensitive to > latency? It depends. There are some timeouts in GSM you want to set high, there is also the keep-a-live heartbeat (IPA-PING/PONG) (I don't know the interval right now). The other question is why do you think you > > Secondly, anybody ever looked at the new nanobts/femtobts from "radio > access"? > Probably they don't manufacture those themselves, but are re-selling it > allong with their own bsc/nomc/hlr (clarity) Clarity should be able to > handle the new nanobts aswell as the model from ipaccess. > >>From what i read, it is scalled down model compared to the nano-bts from > ipaccess. > And scaleddown in two aspects: > Limited power: just 200mW and price: around 50 euro. Do you have a link to their website, their product and their pricing? From admin at manateeshome.com Fri May 27 12:24:59 2011 From: admin at manateeshome.com (Seungju Kim) Date: Fri, 27 May 2011 08:24:59 -0400 Subject: two questions In-Reply-To: <1306478980.7617.26.camel@t43.lan0.a-domani.nl> References: <1306478980.7617.26.camel@t43.lan0.a-domani.nl> Message-ID: <5FBADBF0-535E-446B-BA3F-3EE4333C1E89@manateeshome.com> I presume you are talking about this website? http://radioaccess.nl/clarity/producten/ But I cannot find any prices for BTS It says 99 euros per end user.. Sent from my iPhone On May 27, 2011, at 2:49 AM, Hans Witvliet wrote: > Hi all, > > Got two questions: > Firstly, i would like to know if it is possible to have bts and bsc at > completely different locations: can the connections be encapsulated in a > vpn tunnel (openvpn, ipsec). Or is that connection very sensitive to > latency? > > Secondly, anybody ever looked at the new nanobts/femtobts from "radio > access"? > Probably they don't manufacture those themselves, but are re-selling it > allong with their own bsc/nomc/hlr (clarity) Clarity should be able to > handle the new nanobts aswell as the model from ipaccess. > >> From what i read, it is scalled down model compared to the nano-bts from > ipaccess. > And scaleddown in two aspects: > Limited power: just 200mW and price: around 50 euro. > > hw -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.huemer at xx.vu Fri May 27 12:55:19 2011 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Fri, 27 May 2011 14:55:19 +0200 Subject: two questions In-Reply-To: <5FBADBF0-535E-446B-BA3F-3EE4333C1E89@manateeshome.com> References: <1306478980.7617.26.camel@t43.lan0.a-domani.nl> <5FBADBF0-535E-446B-BA3F-3EE4333C1E89@manateeshome.com> Message-ID: <20110527125518.GF32065@de.xx.vu> The picture on the website looks very much like an ipaccess nanobts. I think this is just a resale. On Fri, May 27, 2011 at 08:24:59AM -0400, Seungju Kim wrote: > I presume you are talking about this website? > http://radioaccess.nl/clarity/producten/ > > But I cannot find any prices for BTS > It says 99 euros per end user.. > > Sent from my iPhone > > On May 27, 2011, at 2:49 AM, Hans Witvliet wrote: > > > Hi all, > > > > Got two questions: > > Firstly, i would like to know if it is possible to have bts and bsc at > > completely different locations: can the connections be encapsulated in a > > vpn tunnel (openvpn, ipsec). Or is that connection very sensitive to > > latency? > > > > Secondly, anybody ever looked at the new nanobts/femtobts from "radio > > access"? > > Probably they don't manufacture those themselves, but are re-selling it > > allong with their own bsc/nomc/hlr (clarity) Clarity should be able to > > handle the new nanobts aswell as the model from ipaccess. > > > >> From what i read, it is scalled down model compared to the nano-bts from > > ipaccess. > > And scaleddown in two aspects: > > Limited power: just 200mW and price: around 50 euro. > > > > hw > From bthomas at mailbox.hu Fri May 27 12:33:35 2011 From: bthomas at mailbox.hu (Bthomas) Date: Fri, 27 May 2011 14:33:35 +0200 Subject: OpenBSC operate FemtoCells? Message-ID: Dear OpenBSC lovers and developers! My questions is follow: 1. The OpenBSC software operate FemtoCell? (installed OpenBSC generate firmware to FemtoCell devices or operate FemtoCell devices? it is not clear to me) 2. If question nr1 is yes, you do not need any other hardware? (e.g. usrp device or BS11 or anything) 3. If question nr1 and nr2 both yes, then FemtoCell device and OpenBSC the combined use of mini private GSM network? I would like to deal with her hobby, and a better-cheaper-FemtoCell device access, such as a usrp device. Thank you for your answers! bthomyka from Hungary(EU) [ bthomas at mailbox dot hu ] -------------- next part -------------- An HTML attachment was scrubbed... URL: From luca.bongiorni1 at studenti.unimi.it Fri May 27 12:52:15 2011 From: luca.bongiorni1 at studenti.unimi.it (Luca Bongiorni) Date: Fri, 27 May 2011 14:52:15 +0200 Subject: NanoBTS for sale?! Message-ID: <7490d2c919813.4ddfba9f@studenti.unimi.it> Hi guys, someone has a NanoBTS for purchase or could send me in private, some european re-sellers?! Possibly, a version that fully supports A5/1-2 and openGGSN. Thank you for attention Cheers Luca From 246tnt at gmail.com Fri May 27 13:23:33 2011 From: 246tnt at gmail.com (Sylvain Munaut) Date: Fri, 27 May 2011 15:23:33 +0200 Subject: NanoBTS for sale?! In-Reply-To: <7490d2c919813.4ddfba9f@studenti.unimi.it> References: <7490d2c919813.4ddfba9f@studenti.unimi.it> Message-ID: Hi, > someone has a NanoBTS for purchase or could send me in private I have an rugby 139 (DCS1800) for sale at 2000EUR (excl tax, but for sale by a company so no tax if you're a company in the EU with a valid VAT). It's almost never been used, I bought it new from a surplus and wanted to do multi-trx but turns out you need the exact same fw version on all the unit in the group and they were not. > some european re-sellers?! Well, ip.access itself is in the UK. > Possibly, a version that fully supports A5/1-2 and openGGSN. I'm not sure if any support both A5/1 and /2 at the same time. I heard they were different firmware. Mine support A5/1 and GPRS. Cheers, Sylvain From 246tnt at gmail.com Fri May 27 13:24:34 2011 From: 246tnt at gmail.com (Sylvain Munaut) Date: Fri, 27 May 2011 15:24:34 +0200 Subject: NanoBTS for sale?! In-Reply-To: References: <7490d2c919813.4ddfba9f@studenti.unimi.it> Message-ID: Damnit forgot to remove the list, sorry about that. From admin at manateeshome.com Sun May 29 03:29:08 2011 From: admin at manateeshome.com (Seungju Kim) Date: Sat, 28 May 2011 23:29:08 -0400 Subject: GPRS Message-ID: <687D9C15-B5C1-4B19-B49A-2A377FA166FD@manateeshome.com> Hello, I am trying to make a GPRS/EDGE capable network using OpenBSC. These are my config files and results from console http://pastebin.com/rCW6cCeU But I still don't see any data indicator when I connect my iPhone to the network. What do you think is wrong? Sent from my iPhone From admin at manateeshome.com Mon May 30 04:27:55 2011 From: admin at manateeshome.com (Seungju Kim) Date: Mon, 30 May 2011 00:27:55 -0400 Subject: SGSN Crash Message-ID: <3DB73071-417E-409D-8A0E-09F046F79F5E@manateeshome.com> Hello, I am experiencing some crash with osmo-sgsn. This is the log : http://pastebin.com/XP8RcaaN I didnt make any modification except removing imsi roaming check. Every time when a phone tries to connect this happens. What might be wrong? Sent from my iPhone From holger at freyther.de Mon May 30 06:52:13 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 30 May 2011 08:52:13 +0200 Subject: SGSN Crash In-Reply-To: <3DB73071-417E-409D-8A0E-09F046F79F5E@manateeshome.com> References: <3DB73071-417E-409D-8A0E-09F046F79F5E@manateeshome.com> Message-ID: <4DE33E9D.7090308@freyther.de> On 05/30/2011 06:27 AM, Seungju Kim wrote: > Hello, I am experiencing some crash with osmo-sgsn. > This is the log : http://pastebin.com/XP8RcaaNI didnt make any modification except removing imsi roaming check. > Every time when a phone tries to connect this happens. What might be wrong? Hi, please make yourself gdb and git and create a patch. The struct msgb has detected a mis-use and forced a crash. What is going wrong is in the log, you will need to identify where this msgb got allocated (or change the panic message to print the name of the msgb) and see why it is using the amount of headroom it wants to use. happy hacking holger From laforge at gnumonks.org Mon May 30 07:08:09 2011 From: laforge at gnumonks.org (Harald Welte) Date: Mon, 30 May 2011 09:08:09 +0200 Subject: SGSN Crash In-Reply-To: <4DE33E9D.7090308@freyther.de> References: <3DB73071-417E-409D-8A0E-09F046F79F5E@manateeshome.com> <4DE33E9D.7090308@freyther.de> Message-ID: <20110530070809.GG4532@prithivi.gnumonks.org> Hi all, On Mon, May 30, 2011 at 08:52:13AM +0200, Holger Hans Peter Freyther wrote: > please make yourself gdb and git and create a patch. The struct msgb has > detected a mis-use and forced a crash. What is going wrong is in the log, you > will need to identify where this msgb got allocated (or change the panic > message to print the name of the msgb) and see why it is using the amount of > headroom it wants to use. I am quite certain it is the "MS Radio Access Capabilities IE" which for some reason seems to be _very_ large in this case. I've seen this before, but never was able to hunt it down. Everything seemed like it was _really_ that long. But it's more likely that we do something wrong while parsing it in GMM when the phone sends it. The SGSN saves this IE in its MM contaxt for the phone, and it will transmit it to the BTS in every BSSGP message. -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From admin at manateeshome.com Mon May 30 14:04:11 2011 From: admin at manateeshome.com (Seungju Kim) Date: Mon, 30 May 2011 10:04:11 -0400 Subject: SGSN Crash In-Reply-To: <20110530070809.GG4532@prithivi.gnumonks.org> References: <3DB73071-417E-409D-8A0E-09F046F79F5E@manateeshome.com> <4DE33E9D.7090308@freyther.de> <20110530070809.GG4532@prithivi.gnumonks.org> Message-ID: <6992944E-4A46-4BE6-A7E6-C5D7C9BEA00A@manateeshome.com> I wonder whether I am the only one experiencing the crash or not. I am using the newest git version with imsi check removed. Sent from my iPhone On May 30, 2011, at 3:08 AM, Harald Welte wrote: > Hi all, > > On Mon, May 30, 2011 at 08:52:13AM +0200, Holger Hans Peter Freyther wrote: > >> please make yourself gdb and git and create a patch. The struct msgb has >> detected a mis-use and forced a crash. What is going wrong is in the log, you >> will need to identify where this msgb got allocated (or change the panic >> message to print the name of the msgb) and see why it is using the amount of >> headroom it wants to use. > > I am quite certain it is the "MS Radio Access Capabilities IE" which for > some reason seems to be _very_ large in this case. I've seen this > before, but never was able to hunt it down. Everything seemed like it > was _really_ that long. But it's more likely that we do something wrong > while parsing it in GMM when the phone sends it. The SGSN saves this IE > in its MM contaxt for the phone, and it will transmit it to the BTS in > every BSSGP message. > > -- > - Harald Welte http://laforge.gnumonks.org/ > ============================================================================ > "Privacy in residential applications is a desirable marketing option." > (ETSI EN 300 175-7 Ch. A6) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Mon May 30 14:18:24 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 30 May 2011 16:18:24 +0200 Subject: SGSN Crash In-Reply-To: <6992944E-4A46-4BE6-A7E6-C5D7C9BEA00A@manateeshome.com> References: <3DB73071-417E-409D-8A0E-09F046F79F5E@manateeshome.com> <4DE33E9D.7090308@freyther.de> <20110530070809.GG4532@prithivi.gnumonks.org> <6992944E-4A46-4BE6-A7E6-C5D7C9BEA00A@manateeshome.com> Message-ID: <4DE3A730.20307@freyther.de> On 05/30/2011 04:04 PM, Seungju Kim wrote: > I wonder whether I am the only one experiencing the crash or not. I am using > the newest git version with imsi check removed. Well, there are not many people using the SGSN. It would be nice if you could attempt to understand the issue and send a patch. holger From 246tnt at gmail.com Mon May 30 06:52:52 2011 From: 246tnt at gmail.com (Sylvain Munaut) Date: Mon, 30 May 2011 08:52:52 +0200 Subject: SGSN Crash In-Reply-To: <3DB73071-417E-409D-8A0E-09F046F79F5E@manateeshome.com> References: <3DB73071-417E-409D-8A0E-09F046F79F5E@manateeshome.com> Message-ID: > Hello, I am experiencing some crash with osmo-sgsn. > This is the log : http://pastebin.com/XP8RcaaN > I didnt make any modification except removing imsi roaming check. > Every time when a phone tries to connect this happens. What might be wrong? Build with debug symbols so that the backtrace makes sense ... Cheers, Sylvain From bthomas at mailbox.hu Mon May 30 11:13:16 2011 From: bthomas at mailbox.hu (Bthomas) Date: Mon, 30 May 2011 13:13:16 +0200 Subject: Only nanoBTS, or any femtocell? Message-ID: Dear OpenBSC lovers and developers! question, I turn towards you again: if the operation OpenBSC nanoBTS and A-bis Over IP basis, you think any of the femtocell (eg Vodafone's preferred cells) are able to operate in the same way? I think that the same standard as well do they work? What is your opinion? For more information: http://wirelessfederation.com/news/74803-vodafone-hungary-launches-3ghsdpa-femtocell/ Thank You, and have nice day! bthomyka from Hungary -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Mon May 30 11:15:40 2011 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 30 May 2011 13:15:40 +0200 Subject: Only nanoBTS, or any femtocell? In-Reply-To: References: Message-ID: <4DE37C5C.7070808@freyther.de> On 05/30/2011 01:13 PM, Bthomas wrote: > Dear OpenBSC lovers and developers! Hi, please check the archives of this mailinglist. In general patches are welcome. holger