[MERGED] 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
Sun Oct 15 16:01:08 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: sgsnemu: Use getprotobynumber() in print_ipprot()
......................................................................


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(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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: merged
Gerrit-Change-Id: I8cdc460e4fa5d86d80addf6e5f341d2d80093a35
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list