added define check for ipv6 structs

This commit is contained in:
jsorg71 2008-08-12 07:11:05 +00:00
parent fa30584146
commit edf6d54b55

View File

@ -259,7 +259,9 @@ int
scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr) scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
{ {
struct in_addr ip4; struct in_addr ip4;
#ifdef IN6ADDR_ANY_INIT
struct in6_addr ip6; struct in6_addr ip6;
#endif
int ret; int ret;
switch (type) switch (type)
@ -276,6 +278,10 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
} }
g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4); g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4);
break; break;
case SCP_ADDRESS_TYPE_IPV4_BIN:
g_memcpy(&(s->ipv4addr), addr, 4);
break;
#ifdef IN6ADDR_ANY_INIT
case SCP_ADDRESS_TYPE_IPV6: case SCP_ADDRESS_TYPE_IPV6:
/* convert from char to 128bit*/ /* convert from char to 128bit*/
ret = inet_pton(AF_INET6, addr, &ip6); ret = inet_pton(AF_INET6, addr, &ip6);
@ -288,12 +294,10 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
} }
g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16); g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16);
break; break;
case SCP_ADDRESS_TYPE_IPV4_BIN:
g_memcpy(&(s->ipv4addr), addr, 4);
break;
case SCP_ADDRESS_TYPE_IPV6_BIN: case SCP_ADDRESS_TYPE_IPV6_BIN:
g_memcpy(s->ipv6addr, addr, 16); g_memcpy(s->ipv6addr, addr, 16);
break; break;
#endif
default: default:
return 1; return 1;
} }