diff mbox

[osmo-bts,3/5] utils: Changed the function check_oml_message for returning message vendor type

Message ID 1400564544-9709-1-git-send-email-anayuso@sysmocom.de
State Changes Requested
Headers show

Commit Message

Alvaro Neira May 20, 2014, 5:42 a.m. UTC
From: Álvaro Neira Ayuso <anayuso@sysmocom.de>

Added some changes for returning the vendor type of message that
we have checked. We are going to return OML, Manufacturer O&M
Ipaccess message or Manufacturer O&M osmocom message.

BTW, I have fixed a wrong use of sizeof in the code that I have modified.

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
---
 src/osmo-bts-sysmo/utils.c |   14 ++++++++------
 src/osmo-bts-sysmo/utils.h |    6 ++++++
 2 files changed, 14 insertions(+), 6 deletions(-)

Comments

Holger Freyther May 20, 2014, 7:04 a.m. UTC | #1
On Tue, May 20, 2014 at 07:42:24AM +0200, Alvaro Neira Ayuso wrote:

> BTW, I have fixed a wrong use of sizeof in the code that I have modified.

Please make a separate patch for this fix. It sneaked through my
review but deserves a fix by itself.
Holger Freyther May 20, 2014, 7:10 a.m. UTC | #2
On Tue, May 20, 2014 at 07:42:24AM +0200, Alvaro Neira Ayuso wrote:

> +enum check_message_type {
> +	OML_MSG_TYPE,
> +	MANUFACTURER_MSG_IPA_TYPE,
> +	MANUFACTURER_MSG_OSMO_TYPE,

In general elements of an enum have a common prefix. I will change
this here.
diff mbox

Patch

diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c
index 1fa5796..e676a3c 100644
--- a/src/osmo-bts-sysmo/utils.c
+++ b/src/osmo-bts-sysmo/utils.c
@@ -245,15 +245,17 @@  int check_oml_msg(struct msgb *msg)
 
 	if (omh->mdisc == ABIS_OM_MDISC_MANUF) {
 		strncpy(label_id, (const char *) msg->l3h + 1,
-			sizeof(ipaccess_magic) + 1);
+			sizeof(ipaccess_magic));
 
 		if (strncmp(ipaccess_magic, label_id,
-			    sizeof(ipaccess_magic) + 1) == 0)
+			    sizeof(ipaccess_magic)) == 0) {
 			msg->l3h = msg->l3h + sizeof(ipaccess_magic) + 1;
-		else if (strncmp(osmocom_magic, label_id,
-				 sizeof(osmocom_magic) + 1) == 0)
+			return MANUFACTURER_MSG_IPA_TYPE;
+		} else if (strncmp(osmocom_magic, label_id,
+				 sizeof(osmocom_magic)) == 0) {
 			msg->l3h = msg->l3h + sizeof(osmocom_magic) + 1;
-		else {
+			return MANUFACTURER_MSG_OSMO_TYPE;
+		} else {
 			msg->l3h = NULL;
 			LOGP(DL1C, LOGL_ERROR,
 			     "Manuf Label Unknown %s\n", label_id);
@@ -261,7 +263,7 @@  int check_oml_msg(struct msgb *msg)
 		}
 	}
 
-	return 0;
+	return OML_MSG_TYPE;
 }
 
 int check_ipa_header(struct msgb *msg)
diff --git a/src/osmo-bts-sysmo/utils.h b/src/osmo-bts-sysmo/utils.h
index 4f2293a..dbbe443 100644
--- a/src/osmo-bts-sysmo/utils.h
+++ b/src/osmo-bts-sysmo/utils.h
@@ -21,6 +21,12 @@  enum manuf_type_id {
 	OSMOCOM_MANUF_ID,
 };
 
+enum check_message_type {
+	OML_MSG_TYPE,
+	MANUFACTURER_MSG_IPA_TYPE,
+	MANUFACTURER_MSG_OSMO_TYPE,
+};
+
 static const char osmocom_magic[] = "org.osmocom";
 static const char ipaccess_magic[] = "com.ipaccess";