summaryrefslogtreecommitdiff
path: root/src/socket_info.c
diff options
context:
space:
mode:
authorJannis Hoffmann <jannis@fehcom.de>2024-07-09 14:41:53 +0200
committerJannis Hoffmann <jannis@fehcom.de>2024-07-09 14:41:53 +0200
commit5fadc0cbb8577c61d66bd6f19ceaf0507c11e23b (patch)
tree684758441f5b431d0008253243034b6a4a29417c /src/socket_info.c
parent249866e3d1e11dc72eaa1305f4bb479ded92ef38 (diff)
initial clang-format
Diffstat (limited to 'src/socket_info.c')
-rw-r--r--src/socket_info.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/socket_info.c b/src/socket_info.c
index e644798..9300b24 100644
--- a/src/socket_info.c
+++ b/src/socket_info.c
@@ -1,10 +1,11 @@
-#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 "socket_if.h"
#include "ip.h"
+#include "socket_if.h"
/**
@file socket_info.c
@@ -13,44 +14,44 @@
@brief querying local and remote info for socket
*/
-int socket_local(int s,char ip[16],uint16 *port,uint32 *scope_id)
+int socket_local(int s, char ip[16], uint16 *port, uint32 *scope_id)
{
struct sockaddr_in6 sa;
unsigned int dummy = sizeof(sa);
- if (getsockname(s,(struct sockaddr *)&sa,&dummy) == -1) return -1;
-
+ if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -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);
+ 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);
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;
}
return 0;
}
-int socket_remote(int s,char ip[16],uint16 *port,uint32 *scope_id)
+int socket_remote(int s, char ip[16], uint16 *port, uint32 *scope_id)
{
struct sockaddr_in6 sa;
unsigned int dummy = sizeof(sa);
- if (getpeername(s,(struct sockaddr *)&sa,&dummy) == -1) return -1;
+ if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -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);
+ 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);
*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);
*scope_id = sa.sin6_scope_id;
}