Browse Source

MT#55283 convert tos to bool

Change-Id: Icf424a04b79923c239f1ccdbb79115b080a84462
pull/1910/head
Richard Fuchs 10 months ago
parent
commit
3662b74009
2 changed files with 7 additions and 7 deletions
  1. +6
    -6
      lib/socket.c
  2. +1
    -1
      lib/socket.h

+ 6
- 6
lib/socket.c View File

@ -42,8 +42,8 @@ static ssize_t __ip4_recvfrom_to(socket_t *s, void *buf, size_t len, endpoint_t
static ssize_t __ip6_recvfrom_to(socket_t *s, void *buf, size_t len, endpoint_t *ep, sockaddr_t *to); static ssize_t __ip6_recvfrom_to(socket_t *s, void *buf, size_t len, endpoint_t *ep, sockaddr_t *to);
static ssize_t __ip_sendmsg(socket_t *s, struct msghdr *mh, const endpoint_t *ep); static ssize_t __ip_sendmsg(socket_t *s, struct msghdr *mh, const endpoint_t *ep);
static ssize_t __ip_sendto(socket_t *s, const void *buf, size_t len, const endpoint_t *ep); static ssize_t __ip_sendto(socket_t *s, const void *buf, size_t len, const endpoint_t *ep);
static int __ip4_tos(socket_t *, unsigned int);
static int __ip6_tos(socket_t *, unsigned int);
static bool __ip4_tos(socket_t *, unsigned int);
static bool __ip6_tos(socket_t *, unsigned int);
static int __ip_error(socket_t *s); static int __ip_error(socket_t *s);
static void __ip4_pmtu_disc(socket_t *, int); static void __ip4_pmtu_disc(socket_t *, int);
static void __ip4_endpoint2kernel(struct re_address *, const endpoint_t *); static void __ip4_endpoint2kernel(struct re_address *, const endpoint_t *);
@ -387,17 +387,17 @@ static ssize_t __ip_sendto(socket_t *s, const void *buf, size_t len, const endpo
ep->address.family->endpoint2sockaddr(&sin, ep); ep->address.family->endpoint2sockaddr(&sin, ep);
return sendto(s->fd, buf, len, 0, (void *) &sin, ep->address.family->sockaddr_size); return sendto(s->fd, buf, len, 0, (void *) &sin, ep->address.family->sockaddr_size);
} }
static int __ip4_tos(socket_t *s, unsigned int tos) {
static bool __ip4_tos(socket_t *s, unsigned int tos) {
unsigned char ctos; unsigned char ctos;
ctos = tos; ctos = tos;
if (setsockopt(s->fd, IPPROTO_IP, IP_TOS, &ctos, sizeof(ctos))) if (setsockopt(s->fd, IPPROTO_IP, IP_TOS, &ctos, sizeof(ctos)))
ilog(LOG_ERR, "Failed to set TOS on IPv4 socket: %s", strerror(errno)); ilog(LOG_ERR, "Failed to set TOS on IPv4 socket: %s", strerror(errno));
return 0;
return true;
} }
static int __ip6_tos(socket_t *s, unsigned int tos) {
static bool __ip6_tos(socket_t *s, unsigned int tos) {
if (setsockopt(s->fd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos))) if (setsockopt(s->fd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)))
ilog(LOG_ERR, "Failed to set TOS on IPv6 socket: %s", strerror(errno)); ilog(LOG_ERR, "Failed to set TOS on IPv6 socket: %s", strerror(errno));
return 0;
return true;
} }
static int __ip_error(socket_t *s) { static int __ip_error(socket_t *s) {
int optval; int optval;


+ 1
- 1
lib/socket.h View File

@ -80,7 +80,7 @@ struct socket_family {
ssize_t (*recvfrom_to)(socket_t *, void *, size_t, endpoint_t *, sockaddr_t *); ssize_t (*recvfrom_to)(socket_t *, void *, size_t, endpoint_t *, sockaddr_t *);
ssize_t (*sendmsg)(socket_t *, struct msghdr *, const endpoint_t *); ssize_t (*sendmsg)(socket_t *, struct msghdr *, const endpoint_t *);
ssize_t (*sendto)(socket_t *, const void *, size_t, const endpoint_t *); ssize_t (*sendto)(socket_t *, const void *, size_t, const endpoint_t *);
int (*tos)(socket_t *, unsigned int);
bool (*tos)(socket_t *, unsigned int);
void (*pmtu_disc)(socket_t *, int); void (*pmtu_disc)(socket_t *, int);
int (*error)(socket_t *); int (*error)(socket_t *);
void (*endpoint2kernel)(struct re_address *, const endpoint_t *); void (*endpoint2kernel)(struct re_address *, const endpoint_t *);


Loading…
Cancel
Save