From 5fadc0cbb8577c61d66bd6f19ceaf0507c11e23b Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Tue, 9 Jul 2024 14:41:53 +0200 Subject: initial clang-format --- src/socket_send.c | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'src/socket_send.c') diff --git a/src/socket_send.c b/src/socket_send.c index 9f09520..7c919f4 100644 --- a/src/socket_send.c +++ b/src/socket_send.c @@ -1,7 +1,8 @@ -#include +#include #include #include -#include +#include + #include "byte.h" #include "ip.h" #include "socket_if.h" @@ -13,50 +14,52 @@ @brief setup sending socket */ -int socket_send4(int s,const char *buf,unsigned int len,const char ip[4],uint16 port) +int socket_send4(int s, const char *buf, unsigned int len, const char ip[4], uint16 port) { struct sockaddr_in sa; - byte_zero(&sa,sizeof(sa)); + byte_zero(&sa, sizeof(sa)); sa.sin_family = AF_INET; - uint16_pack_big((char *)&sa.sin_port,port); - byte_copy((char *)&sa.sin_addr,4,ip); + uint16_pack_big((char *)&sa.sin_port, port); + byte_copy((char *)&sa.sin_addr, 4, ip); - return sendto(s,buf,len,0,(struct sockaddr *)&sa,sizeof(sa)); + return sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof(sa)); } -int socket_send6(int s,const char *buf,unsigned int len,const char ip[16],uint16 port,uint32 scope_id) +int socket_send6( + int s, const char *buf, unsigned int len, const char ip[16], uint16 port, uint32 scope_id) { struct sockaddr_in6 sa; - byte_zero(&sa,sizeof(sa)); + byte_zero(&sa, sizeof(sa)); sa.sin6_family = AF_INET6; sa.sin6_scope_id = scope_id; - uint16_pack_big((char *)&sa.sin6_port,port); - byte_copy((char *)&sa.sin6_addr,16,ip); + uint16_pack_big((char *)&sa.sin6_port, port); + byte_copy((char *)&sa.sin6_addr, 16, ip); - return sendto(s,buf,len,0,(struct sockaddr *)&sa,sizeof(sa)); + return sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof(sa)); } -int socket_send(int s,const char *buf,unsigned int len,const char ip[16],uint16 port,uint32 scope_id) -{ +int socket_send( + int s, const char *buf, unsigned int len, const char ip[16], uint16 port, uint32 scope_id) +{ if (ip6_isv4mapped(ip)) - return socket_send4(s,buf,len,ip + 12,port); - else - return socket_send6(s,buf,len,ip,port,scope_id); -} + return socket_send4(s, buf, len, ip + 12, port); + else + return socket_send6(s, buf, len, ip, port, scope_id); +} -int socket_broadcast4(int s,const char *buf,unsigned int len,uint16 port) +int socket_broadcast4(int s, const char *buf, unsigned int len, uint16 port) { struct sockaddr_in sa; - byte_zero(&sa,sizeof(sa)); + byte_zero(&sa, sizeof(sa)); sa.sin_family = AF_INET; - uint16_pack_big((char *)&sa.sin_port,port); - byte_copy((char *)&sa.sin_addr,4,V4broadcast); + uint16_pack_big((char *)&sa.sin_port, port); + byte_copy((char *)&sa.sin_addr, 4, V4broadcast); - return sendto(s,buf,len,0,(struct sockaddr *)&sa,sizeof(sa)); + return sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof(sa)); } -- cgit v1.2.3