3 #include <sys/socket.h> 4 #include <netinet/in.h> 14 struct sockaddr_in6 sa;
16 struct sockaddr_in sa;
18 unsigned int dummy =
sizeof sa;
22 r = recvfrom(s,buf,len,0,(
struct sockaddr *) &sa,&dummy);
23 if (r == -1)
return -1;
27 struct sockaddr_in *sa4=(
struct sockaddr_in *)&sa;
29 byte_copy(ip+12,4,(
char *) &sa4->sin_addr);
35 if (scope_id) *scope_id=sa.sin6_scope_id;
40 if (scope_id) *scope_id=0;
void byte_copy(void *, unsigned int, const void *)
int socket_recv6(int s, char *buf, unsigned int len, char ip[16], uint16 *port, uint32 *scope_id)
void byte_zero(void *, unsigned int)
const unsigned char V4mappedprefix[12]
void uint16_unpack_big(const char *, uint16 *)