mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-upf.git
synced 2025-11-03 05:23:46 +00:00
gtp-probe fu
This commit is contained in:
@@ -51,25 +51,22 @@ static int gtp_probe_cb(struct osmo_fd *ofd, unsigned int what)
|
||||
char strbuf[64];
|
||||
|
||||
uint8_t rxbuf[2048];
|
||||
struct udphdr *h = (void *)rxbuf;
|
||||
|
||||
if (!(what & OSMO_FD_READ))
|
||||
return 0;
|
||||
|
||||
rc = recvfrom(ofd->fd, rxbuf, sizeof(rxbuf), 0, (struct sockaddr *)&remote, &remote_len);
|
||||
if (rc <= 0)
|
||||
if (rc <= 0 || rc > sizeof(rxbuf)) {
|
||||
fprintf(stderr, "problem receiving on UDP probe: rc %d > sizeof(rxbuf) %zu\n", rc, sizeof(rxbuf));
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
osmo_sockaddr_str_from_sockaddr(&remote_str, &remote.u.sas);
|
||||
|
||||
size_t len = ntohl(h->len);
|
||||
uint8_t *data = rxbuf + sizeof(*h);
|
||||
size_t data_len = len - sizeof(*h);
|
||||
|
||||
if (ofd->priv_nr)
|
||||
osmo_escape_cstr_buf(strbuf, sizeof(strbuf), (char *)data, data_len);
|
||||
osmo_escape_cstr_buf(strbuf, sizeof(strbuf), (char *)rxbuf, rc);
|
||||
else
|
||||
osmo_hexdump_buf(strbuf, sizeof(strbuf), data, data_len, NULL, false);
|
||||
osmo_hexdump_buf(strbuf, sizeof(strbuf), rxbuf, rc, NULL, false);
|
||||
|
||||
LOGP(DLGLOBAL, LOGL_NOTICE,
|
||||
"Probe RX: " OSMO_SOCKADDR_STR_FMT " -> " OSMO_SOCKADDR_STR_FMT " '%s'\n",
|
||||
@@ -178,9 +175,6 @@ int gtp_probe_run_tunend(struct gtp_probe_state *s, struct pfcp_tool_gtp_tun *in
|
||||
pdu.ip.tot_len = htons(ip_len);
|
||||
pdu.udp.len = htons(udp_len);
|
||||
|
||||
LOGP(DLGLOBAL, LOGL_NOTICE, "GTP-probe: sending payload GTP{%zu IP{%zu UDP{%zu {%zu %s} } } }\n",
|
||||
gtp_len, ip_len, udp_len, data_len, osmo_quote_cstr_c(OTC_SELECT, pdu.data, data_len));
|
||||
|
||||
rc = osmo_sockaddr_str_to_32(&payload_src, &i32);
|
||||
if (rc) {
|
||||
LOGP(DLGLOBAL, LOGL_ERROR, "invalid payload source address: " OSMO_SOCKADDR_STR_FMT "\n",
|
||||
|
||||
Reference in New Issue
Block a user