From a74d3737dc4ff18441fa092c9d13ec59f0701c11 Mon Sep 17 00:00:00 2001 From: cpq Date: Fri, 25 Nov 2022 14:23:59 +0000 Subject: [PATCH] Fix mip-pcap --- examples/mip-pcap/main.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/examples/mip-pcap/main.c b/examples/mip-pcap/main.c index b9deff63..99830ca1 100644 --- a/examples/mip-pcap/main.c +++ b/examples/mip-pcap/main.c @@ -42,26 +42,6 @@ static size_t pcap_rx(void *buf, size_t len, void *userdata) { return received; } -static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { - if (ev == MG_EV_HTTP_MSG) { - struct mg_http_message *hm = (struct mg_http_message *) ev_data; - if (mg_http_match_uri(hm, "/api/debug")) { - int level = mg_json_get_long(hm->body, "$.level", MG_LL_DEBUG); - mg_log_set(level); - mg_http_reply(c, 200, "", "Debug level set to %d\n", level); - } else if (mg_http_match_uri(hm, "/api/bar")) { - mg_http_connect(c->mgr, ); - mg_http_reply(c, 200, NULL, "ok\r\n"); - } else if (mg_http_match_uri(hm, "/api/foo")) { - mg_http_reply(c, 200, NULL, "%.*s\r\n", - (int) hm->message.len, hm->message.ptr); - } else { - mg_http_reply(c, 200, "", "hi\n"); // Testing endpoint - } - } - (void) ev_data, (void) fn_data; -} - int main(int argc, char *argv[]) { const char *iface = "lo0"; // Network iface const char *mac = "02:00:01:02:03:77"; // MAC address @@ -122,8 +102,8 @@ int main(int argc, char *argv[]) { mip_init(&mgr, &mif); MG_INFO(("Init done, starting main loop")); - //extern void device_dashboard_fn(struct mg_connection *, int, void *, void *); - mg_http_listen(&mgr, "http://0.0.0.0:8000", fn, &mgr); + extern void device_dashboard_fn(struct mg_connection *, int, void *, void *); + mg_http_listen(&mgr, "http://0.0.0.0:8000", device_dashboard_fn, &mgr); while (s_signo == 0) mg_mgr_poll(&mgr, 100); // Infinite event loop