Browse Source

restore TOS setting

pull/163/head
Richard Fuchs 11 years ago
parent
commit
d429bcf0d9
5 changed files with 19 additions and 17 deletions
  1. +1
    -0
      daemon/call.c
  2. +0
    -16
      daemon/media_socket.c
  3. +3
    -1
      daemon/media_socket.h
  4. +14
    -0
      daemon/socket.c
  5. +1
    -0
      daemon/socket.h

+ 1
- 0
daemon/call.c View File

@ -735,6 +735,7 @@ alloc:
g_queue_push_tail(&em->intf_sfds, em_il);
while ((sock = g_queue_pop_head(&il->list))) {
set_tos(sock, media->call->tos);
sfd = stream_fd_new(sock, media->call, il->local_intf);
g_queue_push_tail(&em_il->list, sfd); /* not referenced */
}


+ 0
- 16
daemon/media_socket.c View File

@ -377,23 +377,7 @@ struct local_intf *get_any_interface_address(const struct logical_intf *lif, soc
/* XXX family specific */
void set_tos(socket_t *sock, unsigned int tos) {
unsigned char ctos;
ctos = tos;
setsockopt(sock->fd, IPPROTO_IP, IP_TOS, &ctos, sizeof(tos));
#ifdef IPV6_TCLASS
setsockopt(sock->fd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos));
#else
#warning "Will not set IPv6 traffic class"
#endif
}
/* XXX family specific? unify? */
/* XXX set TOS after opening! */
static int get_port6(socket_t *r, unsigned int port, struct intf_spec *spec) {
if (open_socket(r, SOCK_DGRAM, port, &spec->address.addr))
return -1;


+ 3
- 1
daemon/media_socket.h View File

@ -74,7 +74,9 @@ void interfaces_exclude_port(unsigned int port);
//int get_port(socket_t *r, unsigned int port, const struct local_intf *lif, const struct call *c);
//void release_port(socket_t *r, const struct local_intf *);
void set_tos(socket_t *, unsigned int tos);
INLINE void set_tos(socket_t *s, unsigned int tos) {
s->family->tos(s, tos);
}
int get_consecutive_ports(GQueue *out, unsigned int num_ports, const struct logical_intf *log);
struct stream_fd *stream_fd_new(socket_t *fd, struct call *call, const struct local_intf *lif);


+ 14
- 0
daemon/socket.c View File

@ -27,6 +27,8 @@ static int __ip6_addrport2sockaddr(void *, const sockaddr_t *, unsigned int);
static ssize_t __ip_recvfrom(socket_t *s, void *buf, size_t len, 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 int __ip4_tos(socket_t *, unsigned int);
static int __ip6_tos(socket_t *, unsigned int);
@ -57,6 +59,7 @@ static struct socket_family __socket_families[__SF_LAST] = {
.recvfrom = __ip_recvfrom,
.sendmsg = __ip_sendmsg,
.sendto = __ip_sendto,
.tos = __ip4_tos,
},
[SF_IP6] = {
.af = AF_INET6,
@ -77,6 +80,7 @@ static struct socket_family __socket_families[__SF_LAST] = {
.recvfrom = __ip_recvfrom,
.sendmsg = __ip_sendmsg,
.sendto = __ip_sendto,
.tos = __ip6_tos,
},
};
@ -233,6 +237,16 @@ static ssize_t __ip_sendto(socket_t *s, const void *buf, size_t len, const endpo
s->family->endpoint2sockaddr(&sin, ep);
return sendto(s->fd, buf, len, 0, (void *) &sin, s->family->sockaddr_size);
}
static int __ip4_tos(socket_t *s, unsigned int tos) {
unsigned char ctos;
ctos = tos;
setsockopt(s->fd, IPPROTO_IP, IP_TOS, &ctos, sizeof(ctos));
return 0;
}
static int __ip6_tos(socket_t *s, unsigned int tos) {
setsockopt(s->fd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos));
return 0;
}


+ 1
- 0
daemon/socket.h View File

@ -60,6 +60,7 @@ struct socket_family {
ssize_t (*recvfrom)(socket_t *, void *, size_t, endpoint_t *);
ssize_t (*sendmsg)(socket_t *, struct msghdr *, const endpoint_t *);
ssize_t (*sendto)(socket_t *, const void *, size_t, const endpoint_t *);
int (*tos)(socket_t *, unsigned int);
};
struct socket_address {
sockfamily_t *family;


Loading…
Cancel
Save