[PATCH 11/15] gtphub: tweak logging

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/OpenBSC@lists.osmocom.org/.

Neels Hofmeyr nhofmeyr at sysmocom.de
Thu Oct 15 22:13:55 UTC 2015


Sponsored-by: On-Waves ehi

diff --git a/openbsc/src/gprs/gtphub.c b/openbsc/src/gprs/gtphub.c
index 1d9c6d5..e849a8f 100644
--- a/openbsc/src/gprs/gtphub.c
+++ b/openbsc/src/gprs/gtphub.c
@@ -107,6 +107,7 @@ void validate_gtp0_header(struct gtp_packet_desc *p)
 		return;
 	}
 
+	LOG("GTP v0 TID = %" PRIu64 "\n", pheader->tid);
 	p->header_len = GTP0_HEADER_SIZE;
 	p->rc = GTP_RC_PDU;
 }
@@ -129,6 +130,20 @@ void validate_gtp1_header(struct gtp_packet_desc *p)
 		return;
 	}
 
+	LOG("|GTPv1\n");
+	LOG("| type = %" PRIu8 " 0x%02" PRIx8 "\n",
+	    pheader->type, pheader->type);
+	LOG("| length = %" PRIu16 " 0x%04" PRIx16 "\n",
+	    ntoh16(pheader->length), ntoh16(pheader->length));
+	LOG("| TEI = %" PRIu32 " 0x%08" PRIx32 "\n",
+	    ntoh32(pheader->tei), ntoh32(pheader->tei));
+	LOG("| seq = %" PRIu16 " 0x%04" PRIx16 "\n",
+	    ntoh16(pheader->seq), ntoh16(pheader->seq));
+	LOG("| npdu = %" PRIu8 " 0x%02" PRIx8 "\n",
+	    pheader->npdu, pheader->npdu);
+	LOG("| next = %" PRIu8 " 0x%02" PRIx8 "\n",
+	    pheader->next, pheader->next);
+
 	if (p->data_len <= GTP1_HEADER_SIZE_LONG) {
 		p->rc = GTP_RC_TINY;
 		p->header_len = GTP1_HEADER_SIZE_SHORT;
@@ -366,6 +381,7 @@ static int gtp_relay(struct osmo_fd *from,
 	}
 
 	/* insert magic here */
+	LOG("Received %d\n%s\n", (int)received, osmo_hexdump(buf, received));
 
 	struct gtp_packet_desc p;
 	gtp_decode(buf, received, &p);
@@ -403,7 +419,7 @@ int from_ggsns_read_cb(struct osmo_fd *from_ggsns_ofd, unsigned int what)
 {
 	unsigned int port_idx = from_ggsns_ofd->priv_nr;
 	OSMO_ASSERT(port_idx < GTPH_PORT_N);
-	LOG("reading from GGSN (%s)\n", gtphub_port_idx_names[port_idx]);
+	LOG("\n\n=== reading from GGSN (%s)\n", gtphub_port_idx_names[port_idx]);
 	if (!(what & BSC_FD_READ))
 		return 0;
 
@@ -426,7 +442,7 @@ int from_sgsns_read_cb(struct osmo_fd *from_sgsns_ofd, unsigned int what)
 {
 	unsigned int port_idx = from_sgsns_ofd->priv_nr;
 	OSMO_ASSERT(port_idx < GTPH_PORT_N);
-	LOG("reading from SGSN (%s)\n", gtphub_port_idx_names[port_idx]);
+	LOG("\n\n=== reading from SGSN (%s)\n", gtphub_port_idx_names[port_idx]);
 
 	if (!(what & BSC_FD_READ))
 		return 0;
diff --git a/openbsc/src/gprs/gtphub_main.c b/openbsc/src/gprs/gtphub_main.c
index b43e28d..f3237fe 100644
--- a/openbsc/src/gprs/gtphub_main.c
+++ b/openbsc/src/gprs/gtphub_main.c
@@ -200,6 +200,7 @@ int main(int argc, char **argv)
 		LOGERR("Cannot resolve '%s port %d'\n", ggsn_addr_str, ggsn_port);
 		exit(-1);
 	}
+	LOG("DEBUG: using GGSN %s port %d\n", ggsn_addr_str, ggsn_port);
 
 	log_cfg(cfg);
 
-- 
2.1.4




More information about the OpenBSC mailing list