mirror of https://gerrit.osmocom.org/libosmocore
socket: Introduce osmo_sock_set_priority() helper function
In some situations we want to set the SO_PRIORITY socket option to determine the in-kernel priority of packets generated by this socket. Change-Id: I89abffcd125e6d073338a5c6437b9433220e1823 Related: SYS#5427
This commit is contained in:
parent
c96d716606
commit
ecc0bd8d42
|
@ -123,6 +123,7 @@ char *osmo_sockaddr_to_str_buf(char *buf, size_t buf_len,
|
||||||
const struct osmo_sockaddr *sockaddr);
|
const struct osmo_sockaddr *sockaddr);
|
||||||
|
|
||||||
int osmo_sock_set_dscp(int fd, uint8_t dscp);
|
int osmo_sock_set_dscp(int fd, uint8_t dscp);
|
||||||
|
int osmo_sock_set_priority(int fd, int prio);
|
||||||
|
|
||||||
#endif /* (!EMBEDDED) */
|
#endif /* (!EMBEDDED) */
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
|
@ -1802,6 +1802,14 @@ int osmo_sock_set_dscp(int fd, uint8_t dscp)
|
||||||
return setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
|
return setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Set the priority value of a socket.
|
||||||
|
* \param[in] prio priority value. Values outside 0..6 require CAP_NET_ADMIN.
|
||||||
|
* \returns 0 on success; negative on error. */
|
||||||
|
int osmo_sock_set_priority(int fd, int prio)
|
||||||
|
{
|
||||||
|
/* and write it back to the kernel */
|
||||||
|
return setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio));
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* HAVE_SYS_SOCKET_H */
|
#endif /* HAVE_SYS_SOCKET_H */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue