[PATCH] osmo-ggsn[master]: sgsnemu: Use getprotobynumber() in print_ipprot()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sat Oct 14 14:39:18 UTC 2017


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

sgsnemu: Use getprotobynumber() in print_ipprot()

There's no point in sgsnemu doing a poor mans reimplementation
of what the C library provides already by means of getprotobynumber()

Change-Id: I8cdc460e4fa5d86d80addf6e5f341d2d80093a35
---
M sgsnemu/sgsnemu.c
1 file changed, 5 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/70/4270/1

diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c
index 50eca63..23cf208 100644
--- a/sgsnemu/sgsnemu.c
+++ b/sgsnemu/sgsnemu.c
@@ -993,16 +993,12 @@
 
 static char *print_ipprot(int t)
 {
-	switch (t) {
-	case 1:
-		return "ICMP";
-	case 6:
-		return "TCP";
-	case 17:
-		return "UDP";
-	default:
+	struct protoent *pe = getprotobynumber(t);
+
+	if (!pe)
 		return "Unknown";
-	};
+	else
+		return pe->p_name;
 }
 
 static char *print_icmptype(int t)

-- 
To view, visit https://gerrit.osmocom.org/4270
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8cdc460e4fa5d86d80addf6e5f341d2d80093a35
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list