unix/modsocket: sockaddr(): Handle AF_INET6 addresses.
This commit is contained in:
parent
8f54c08691
commit
ac37e0fd1f
@ -521,6 +521,16 @@ STATIC mp_obj_t mod_socket_sockaddr(mp_obj_t sockaddr_in) {
|
||||
t->items[2] = MP_OBJ_NEW_SMALL_INT(ntohs(sa->sin_port));
|
||||
return MP_OBJ_FROM_PTR(t);
|
||||
}
|
||||
case AF_INET6: {
|
||||
struct sockaddr_in6 *sa = (struct sockaddr_in6*)bufinfo.buf;
|
||||
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(5, NULL));
|
||||
t->items[0] = MP_OBJ_NEW_SMALL_INT(AF_INET6);
|
||||
t->items[1] = mp_obj_new_bytes((byte*)&sa->sin6_addr, sizeof(sa->sin6_addr));
|
||||
t->items[2] = MP_OBJ_NEW_SMALL_INT(ntohs(sa->sin6_port));
|
||||
t->items[3] = MP_OBJ_NEW_SMALL_INT(ntohl(sa->sin6_flowinfo));
|
||||
t->items[4] = MP_OBJ_NEW_SMALL_INT(ntohl(sa->sin6_scope_id));
|
||||
return MP_OBJ_FROM_PTR(t);
|
||||
}
|
||||
default: {
|
||||
struct sockaddr *sa = (struct sockaddr*)bufinfo.buf;
|
||||
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(2, NULL));
|
||||
|
Loading…
Reference in New Issue
Block a user