diff --git a/app/modules/net.c b/app/modules/net.c index 90c25d26..6be1dfae 100644 --- a/app/modules/net.c +++ b/app/modules/net.c @@ -202,20 +202,29 @@ static void net_recv_cb(lnet_userdata *ud, struct pbuf *p, ip_addr_t *addr, u16_ pbuf_free(p); return; } - lua_State *L = lua_getstate(); + int num_args = 2; - lua_rawgeti(L, LUA_REGISTRYINDEX, ud->client.cb_receive_ref); - lua_rawgeti(L, LUA_REGISTRYINDEX, ud->self_ref); - lua_pushlstring(L, p->payload, p->len); - if (ud->type == TYPE_UDP_SOCKET) { + char iptmp[16] = { 0, }; + if (ud->type == TYPE_UDP_SOCKET) + { num_args += 2; - char iptmp[16]; - bzero(iptmp, 16); ets_sprintf(iptmp, IPSTR, IP2STR(&addr->addr)); - lua_pushinteger(L, port); - lua_pushstring(L, iptmp); } - lua_call(L, num_args, 0); + + lua_State *L = lua_getstate(); + struct pbuf *pp = p; + while (pp) + { + lua_rawgeti(L, LUA_REGISTRYINDEX, ud->client.cb_receive_ref); + lua_rawgeti(L, LUA_REGISTRYINDEX, ud->self_ref); + lua_pushlstring(L, pp->payload, pp->len); + if (ud->type == TYPE_UDP_SOCKET) { + lua_pushinteger(L, port); + lua_pushstring(L, iptmp); + } + lua_call(L, num_args, 0); + pp = pp->next; + } pbuf_free(p); }