mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
socket-util: add getsockopt_int() helper
This commit is contained in:
parent
00ed2fff1a
commit
4e25d4cf0f
@ -258,6 +258,19 @@ static inline int setsockopt_int(int fd, int level, int optname, int value) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int getsockopt_int(int fd, int level, int optname, int *ret) {
|
||||||
|
int v;
|
||||||
|
socklen_t sl = sizeof(v);
|
||||||
|
|
||||||
|
if (getsockopt(fd, level, optname, &v, &sl) < 0)
|
||||||
|
return -errno;
|
||||||
|
if (sl != sizeof(v))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
|
*ret = v;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int socket_bind_to_ifname(int fd, const char *ifname);
|
int socket_bind_to_ifname(int fd, const char *ifname);
|
||||||
int socket_bind_to_ifindex(int fd, int ifindex);
|
int socket_bind_to_ifindex(int fd, int ifindex);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user