diff options
Diffstat (limited to 'src/socket_recv.c')
-rw-r--r-- | src/socket_recv.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/socket_recv.c b/src/socket_recv.c index de8c856..03aa311 100644 --- a/src/socket_recv.c +++ b/src/socket_recv.c @@ -1,7 +1,8 @@ -#include <sys/types.h> +#include <netinet/in.h> #include <sys/param.h> #include <sys/socket.h> -#include <netinet/in.h> +#include <sys/types.h> + #include "byte.h" #include "ip.h" #include "socket_if.h" @@ -13,25 +14,25 @@ @brief setup receiving socket */ -int socket_recv(int s,char *buf,unsigned int len,char ip[16],uint16 *port,uint32 *scope_id) +int socket_recv(int s, char *buf, unsigned int len, char ip[16], uint16 *port, uint32 *scope_id) { struct sockaddr_in6 sa; unsigned int dummy = sizeof(sa); int r; - byte_zero(&sa,dummy); - r = recvfrom(s,buf,len,0,(struct sockaddr *)&sa,&dummy); + byte_zero(&sa, dummy); + r = recvfrom(s, buf, len, 0, (struct sockaddr *)&sa, &dummy); if (r == -1) return -1; if (sa.sin6_family == AF_INET) { struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa; - byte_copy(ip,12,V4mappedprefix); - byte_copy(ip+12,4,(char *)&sa4->sin_addr); - uint16_unpack_big((char *)&sa4->sin_port,port); + byte_copy(ip, 12, V4mappedprefix); + byte_copy(ip + 12, 4, (char *)&sa4->sin_addr); + uint16_unpack_big((char *)&sa4->sin_port, port); if (scope_id) *scope_id = 0; } else { - byte_copy(ip,16,(char *)&sa.sin6_addr); - uint16_unpack_big((char *)&sa.sin6_port,port); + byte_copy(ip, 16, (char *)&sa.sin6_addr); + uint16_unpack_big((char *)&sa.sin6_port, port); if (scope_id) *scope_id = sa.sin6_scope_id; } |