mirror of https://gerrit.osmocom.org/libosmocore
gprs_ns: Fix another DSCP vs. TOS mistake in old NS code
DSCP is a 6-bit value stored in the upper 8 bit of what was used to be known as TOS. Let's use the newly introduced OSMO_SOCK_F_DSCP() to prevent having to worry about this in higher level code. Change-Id: I6b9848fd0752d99d3df5346313618d5847d64fb8 Related: OS#5136
This commit is contained in:
parent
485b3f7c85
commit
915caf75e2
|
@ -2068,7 +2068,8 @@ int gprs_ns_nsip_listen(struct gprs_ns_inst *nsi)
|
||||||
osmo_sock_init2_ofd(&nsi->nsip.fd, AF_INET, SOCK_DGRAM,
|
osmo_sock_init2_ofd(&nsi->nsip.fd, AF_INET, SOCK_DGRAM,
|
||||||
IPPROTO_UDP, inet_ntoa(in),
|
IPPROTO_UDP, inet_ntoa(in),
|
||||||
nsi->nsip.local_port, remote_str,
|
nsi->nsip.local_port, remote_str,
|
||||||
nsi->nsip.remote_port, OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT);
|
nsi->nsip.remote_port, OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT |
|
||||||
|
OSMO_SOCK_F_BIND | OSMO_SOCK_F_DSCP(nsi->nsip.dscp));
|
||||||
|
|
||||||
LOGP(DNS, LOGL_NOTICE,
|
LOGP(DNS, LOGL_NOTICE,
|
||||||
"Listening for nsip packets from %s:%u on %s:%u\n",
|
"Listening for nsip packets from %s:%u on %s:%u\n",
|
||||||
|
@ -2076,7 +2077,8 @@ int gprs_ns_nsip_listen(struct gprs_ns_inst *nsi)
|
||||||
} else {
|
} else {
|
||||||
/* Accept UDP packets from any source IP/Port */
|
/* Accept UDP packets from any source IP/Port */
|
||||||
ret = osmo_sock_init_ofd(&nsi->nsip.fd, AF_INET, SOCK_DGRAM,
|
ret = osmo_sock_init_ofd(&nsi->nsip.fd, AF_INET, SOCK_DGRAM,
|
||||||
IPPROTO_UDP, inet_ntoa(in), nsi->nsip.local_port, OSMO_SOCK_F_BIND);
|
IPPROTO_UDP, inet_ntoa(in), nsi->nsip.local_port,
|
||||||
|
OSMO_SOCK_F_BIND | OSMO_SOCK_F_DSCP(nsi->nsip.dscp));
|
||||||
|
|
||||||
LOGP(DNS, LOGL_NOTICE, "Listening for nsip packets on %s:%u\n", inet_ntoa(in), nsi->nsip.local_port);
|
LOGP(DNS, LOGL_NOTICE, "Listening for nsip packets on %s:%u\n", inet_ntoa(in), nsi->nsip.local_port);
|
||||||
}
|
}
|
||||||
|
@ -2087,13 +2089,6 @@ int gprs_ns_nsip_listen(struct gprs_ns_inst *nsi)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = setsockopt(nsi->nsip.fd.fd, IPPROTO_IP, IP_TOS,
|
|
||||||
&nsi->nsip.dscp, sizeof(nsi->nsip.dscp));
|
|
||||||
if (ret < 0)
|
|
||||||
LOGP(DNS, LOGL_ERROR,
|
|
||||||
"Failed to set the DSCP to %d with ret(%d) errno(%d)\n",
|
|
||||||
nsi->nsip.dscp, ret, errno);
|
|
||||||
|
|
||||||
LOGP(DNS, LOGL_NOTICE, "NS UDP socket at %s:%d\n", inet_ntoa(in), nsi->nsip.local_port);
|
LOGP(DNS, LOGL_NOTICE, "NS UDP socket at %s:%d\n", inet_ntoa(in), nsi->nsip.local_port);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue