X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fprotocol_misc.c;h=c6a3630ae2ea190fc27ee41dbe8b9206c85591b9;hb=4c57e6902219ecca1872e18e34365d8e54a0f407;hp=5ec01d9253405e82849779905f02b66a42bf0ee0;hpb=f79cc0e0bba16a3aa42a5fa13098cda714623205;p=meshlink diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 5ec01d92..c6a3630a 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -34,6 +34,9 @@ int maxoutbufsize = 0; /* Status and error notification routines */ bool status_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { + assert(request); + assert(*request); + int statusno; char statusstring[MAX_STRING_SIZE]; @@ -48,6 +51,9 @@ bool status_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { } bool error_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { + assert(request); + assert(*request); + int err; char errorstring[MAX_STRING_SIZE]; @@ -65,6 +71,10 @@ bool termreq_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { (void)mesh; (void)c; (void)request; + + assert(request); + assert(*request); + return false; } @@ -72,32 +82,35 @@ bool send_ping(meshlink_handle_t *mesh, connection_t *c) { c->status.pinged = true; c->last_ping_time = mesh->loop.now.tv_sec; - return send_request(mesh, c, "%d", PING); + return send_request(mesh, c, NULL, "%d", PING); } bool ping_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { (void)request; + + assert(request); + assert(*request); + return send_pong(mesh, c); } bool send_pong(meshlink_handle_t *mesh, connection_t *c) { - return send_request(mesh, c, "%d", PONG); + return send_request(mesh, c, NULL, "%d", PONG); } bool pong_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { (void)mesh; (void)request; + + assert(request); + assert(*request); + c->status.pinged = false; - /* Succesful connection, reset timeout if this is an outgoing connection. */ + /* Successful connection, reset timeout if this is an outgoing connection. */ if(c->outgoing) { - c->outgoing->timeout = 0; - c->outgoing->cfg = NULL; - if(c->outgoing->ai) - freeaddrinfo(c->outgoing->ai); - c->outgoing->ai = NULL; - c->outgoing->aip = NULL; + reset_outgoing(c->outgoing); } return true; @@ -106,6 +119,9 @@ bool pong_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { /* Sending and receiving packets via TCP */ bool tcppacket_h(meshlink_handle_t *mesh, connection_t *c, const char *request) { + assert(request); + assert(*request); + short int len; if(sscanf(request, "%*d %hd", &len) != 1) {