#include "protocol.h"
#include "utils.h"
-int maxoutbufsize = 0;
-
-/* Status and error notification routines */
-
-bool status_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
- int statusno;
- char statusstring[MAX_STRING_SIZE];
-
- if(sscanf(request, "%*d %d " MAX_STRING, &statusno, statusstring) != 2) {
- logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "STATUS", c->name);
- return false;
- }
-
- logger(mesh, MESHLINK_INFO, "Status message from %s: %d: %s", c->name, statusno, statusstring);
-
- return true;
-}
-
-bool error_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
- int err;
- char errorstring[MAX_STRING_SIZE];
-
- if(sscanf(request, "%*d %d " MAX_STRING, &err, errorstring) != 2) {
- logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "ERROR", c->name);
- return false;
- }
-
- logger(mesh, MESHLINK_INFO, "Error message from %s: %d: %s", c->name, err, errorstring);
-
- return false;
-}
-
-bool termreq_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
- (void)mesh;
- (void)c;
- (void)request;
- return false;
-}
-
bool send_ping(meshlink_handle_t *mesh, connection_t *c) {
c->status.pinged = true;
c->last_ping_time = mesh->loop.now.tv_sec;
if(c->outgoing) {
c->outgoing->timeout = 0;
c->outgoing->cfg = NULL;
- if(c->outgoing->ai)
+
+ if(c->outgoing->ai) {
freeaddrinfo(c->outgoing->ai);
+ }
+
c->outgoing->ai = NULL;
c->outgoing->aip = NULL;
}
return true;
}
-
-/* Sending and receiving packets via TCP */
-
-bool tcppacket_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
- short int len;
-
- if(sscanf(request, "%*d %hd", &len) != 1) {
- logger(mesh, MESHLINK_ERROR, "Got bad %s from %s", "PACKET", c->name);
- return false;
- }
-
- // This should never happen with MeshLink.
- return false;
-}