Add li_sockaddr_dup

personal/stbuehler/wip
Stefan Bühler 13 years ago
parent 2e131dc93f
commit 7a63f69133
  1. 1
      include/lighttpd/utils.h
  2. 8
      src/common/utils.c

@ -70,6 +70,7 @@ LI_API liSocketAddress li_sockaddr_from_string(const GString *str, guint tcp_def
LI_API liSocketAddress li_sockaddr_local_from_socket(gint fd);
LI_API liSocketAddress li_sockaddr_remote_from_socket(gint fd);
LI_API void li_sockaddr_clear(liSocketAddress *saddr);
LI_API liSocketAddress li_sockaddr_dup(liSocketAddress saddr);
LI_API gboolean li_ipv4_in_ipv4_net(guint32 target, guint32 match, guint32 networkmask);
LI_API gboolean li_ipv6_in_ipv6_net(const unsigned char *target, const guint8 *match, guint network);

@ -678,6 +678,14 @@ void li_sockaddr_clear(liSocketAddress *saddr) {
saddr->len = 0;
}
liSocketAddress li_sockaddr_dup(liSocketAddress saddr) {
liSocketAddress naddr = { 0, NULL };
naddr.addr = (liSockAddr*) g_slice_alloc0(saddr.len);
naddr.len = saddr.len;
memcpy(naddr.addr, saddr.addr, saddr.len);
return naddr;
}
gboolean li_ipv4_in_ipv4_net(guint32 target, guint32 match, guint32 networkmask) {
return (target & networkmask) == (match & networkmask);
}

Loading…
Cancel
Save