MCPcopy Create free account
hub / github.com/cppla/ServerStatus / sockaddr_to_netaddr

Function sockaddr_to_netaddr

server/src/system.c:589–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

587}
588
589static void sockaddr_to_netaddr(const struct sockaddr *src, NETADDR *dst)
590{
591 if(src->sa_family == AF_INET)
592 {
593 mem_zero(dst, sizeof(NETADDR));
594 dst->type = NETTYPE_IPV4;
595 dst->port = htons(((struct sockaddr_in*)src)->sin_port);
596 mem_copy(dst->ip, &((struct sockaddr_in*)src)->sin_addr.s_addr, 4);
597 }
598 else if(src->sa_family == AF_INET6)
599 {
600 mem_zero(dst, sizeof(NETADDR));
601 dst->type = NETTYPE_IPV6;
602 dst->port = htons(((struct sockaddr_in6*)src)->sin6_port);
603 mem_copy(dst->ip, &((struct sockaddr_in6*)src)->sin6_addr.s6_addr, 16);
604 }
605 else
606 {
607 mem_zero(dst, sizeof(struct sockaddr));
608 dbg_msg("system", "couldn't convert sockaddr of family %d", src->sa_family);
609 }
610}
611
612int net_addr_comp(const NETADDR *a, const NETADDR *b)
613{

Callers 4

net_host_lookupFunction · 0.85
net_addr_from_strFunction · 0.85
net_udp_recvFunction · 0.85
net_tcp_acceptFunction · 0.85

Calls 3

mem_zeroFunction · 0.85
mem_copyFunction · 0.85
dbg_msgFunction · 0.85

Tested by

no test coverage detected