Skip to content

Commit 4c2402e

Browse files
committed
extmod/modlwip: getaddrinfo: Allow to accept all 6 standard params.
But warn if anything else but host/port is passed.
1 parent de3a96b commit 4c2402e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

extmod/modlwip.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,12 @@ STATIC void lwip_getaddrinfo_cb(const char *name, ip_addr_t *ipaddr, void *arg)
12631263
}
12641264

12651265
// lwip.getaddrinfo
1266-
STATIC mp_obj_t lwip_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) {
1266+
STATIC mp_obj_t lwip_getaddrinfo(size_t n_args, const mp_obj_t *args) {
1267+
if (n_args > 2) {
1268+
mp_warning("getaddrinfo constraints not supported");
1269+
}
1270+
1271+
mp_obj_t host_in = args[0], port_in = args[1];
12671272
const char *host = mp_obj_str_get_str(host_in);
12681273
mp_int_t port = mp_obj_get_int(port_in);
12691274

@@ -1299,7 +1304,7 @@ STATIC mp_obj_t lwip_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) {
12991304
tuple->items[4] = netutils_format_inet_addr((uint8_t*)&state.ipaddr, port, NETUTILS_BIG);
13001305
return mp_obj_new_list(1, (mp_obj_t*)&tuple);
13011306
}
1302-
STATIC MP_DEFINE_CONST_FUN_OBJ_2(lwip_getaddrinfo_obj, lwip_getaddrinfo);
1307+
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(lwip_getaddrinfo_obj, 2, 6, lwip_getaddrinfo);
13031308

13041309
// Debug functions
13051310

0 commit comments

Comments
 (0)