Skip to content

Commit

Permalink
unix/modsocket: sockaddr(): Handle AF_INET6 addresses.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Sokolovsky committed Jan 27, 2016
1 parent 8f54c08 commit ac37e0f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions unix/modsocket.c
Expand Up @@ -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));
Expand Down

2 comments on commit ac37e0f

@pfalcon
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dpgeorge: This is final change (+ a pending change to micropython-lib) to make unix port "ipv6 clean". So, in 1.6 changelog, feel free to include IPv6 support for unix port.

@dpgeorge
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pfalcon ok, great! I'll write a note to put it in main comment of v1.6 log.

Please sign in to comment.