summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-04-23 16:38:20 +1000
committerDamien George <damien.p.george@gmail.com>2018-04-23 16:38:20 +1000
commitbdff68db9c1f7e35d0600841647cffac4b1d9ef0 (patch)
treedbfa77971b006b0b9a097e8ab52aad73dac193d0
parentf7be5f9bfa61a07a8256aaae8f22d151f6b8ad81 (diff)
extmod/modlwip: Check if getaddrinfo() constraints are supported or not.
In particular don't issue a warning if the passed-in constraints are actually supported because they are the default values.
-rw-r--r--extmod/modlwip.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/extmod/modlwip.c b/extmod/modlwip.c
index 9810089da..b23f53961 100644
--- a/extmod/modlwip.c
+++ b/extmod/modlwip.c
@@ -1292,14 +1292,33 @@ STATIC void lwip_getaddrinfo_cb(const char *name, ip_addr_t *ipaddr, void *arg)
// lwip.getaddrinfo
STATIC mp_obj_t lwip_getaddrinfo(size_t n_args, const mp_obj_t *args) {
- if (n_args > 2) {
- mp_warning("getaddrinfo constraints not supported");
- }
-
mp_obj_t host_in = args[0], port_in = args[1];
const char *host = mp_obj_str_get_str(host_in);
mp_int_t port = mp_obj_get_int(port_in);
+ // If constraints were passed then check they are compatible with the supported params
+ if (n_args > 2) {
+ mp_int_t family = mp_obj_get_int(args[2]);
+ mp_int_t type = 0;
+ mp_int_t proto = 0;
+ mp_int_t flags = 0;
+ if (n_args > 3) {
+ type = mp_obj_get_int(args[3]);
+ if (n_args > 4) {
+ proto = mp_obj_get_int(args[4]);
+ if (n_args > 5) {
+ flags = mp_obj_get_int(args[5]);
+ }
+ }
+ }
+ if (!((family == 0 || family == MOD_NETWORK_AF_INET)
+ && (type == 0 || type == MOD_NETWORK_SOCK_STREAM)
+ && proto == 0
+ && flags == 0)) {
+ mp_warning("unsupported getaddrinfo constraints");
+ }
+ }
+
getaddrinfo_state_t state;
state.status = 0;