}
// Start an SPTPS session
- if(!sptps_start(&mesh->sptps, mesh, true, false, key, hiskey, "meshlink invitation", 15, invitation_send, invitation_receive)) {
+ if(!sptps_start(&mesh->sptps, mesh, true, false, key, hiskey, meshlink_invitation_label, sizeof meshlink_invitation_label, invitation_send, invitation_receive)) {
meshlink_errno = MESHLINK_EINTERNAL;
pthread_mutex_unlock(&(mesh->mesh_mutex));
return false;
#define MAXSOCKETS 8 /* Probably overkill... */
+static const char meshlink_invitation_label[] = "MeshLink invitation";
+static const char meshlink_tcp_label[] = "MeshLink TCP";
+static const char meshlink_udp_label[] = "MeshLink UDP";
+
struct CattaServer;
struct CattaSServiceBrowser;
struct CattaSimplePoll;
c->protocol_minor = 2;
c->allow_request = 1;
- static const char label[] = "MeshLink invitation";
-
- return sptps_start(&c->sptps, c, false, false, mesh->invitation_key, c->ecdsa, label, sizeof label - 1, send_meta_sptps, receive_invitation_sptps);
+ return sptps_start(&c->sptps, c, false, false, mesh->invitation_key, c->ecdsa, meshlink_invitation_label, sizeof meshlink_invitation_label, send_meta_sptps, receive_invitation_sptps);
}
/* Check if identity is a valid name */
}
c->allow_request = ACK;
- char label[14 + strlen(mesh->self->name) + strlen(c->name) + 1];
+ char label[sizeof meshlink_tcp_label + strlen(mesh->self->name) + strlen(c->name) + 2];
if(c->outgoing)
- snprintf(label, sizeof label, "MeshLink TCP %s %s", mesh->self->name, c->name);
+ snprintf(label, sizeof label, "%s %s %s", meshlink_tcp_label, mesh->self->name, c->name);
else
- snprintf(label, sizeof label, "MeshLink TCP %s %s", c->name, mesh->self->name);
+ snprintf(label, sizeof label, "%s %s %s", meshlink_tcp_label, c->name, mesh->self->name);
return sptps_start(&c->sptps, c, c->outgoing, false, mesh->self->connection->ecdsa, c->ecdsa, label, sizeof label - 1, send_meta_sptps, receive_meta_sptps);
}
if(to->sptps.label)
logger(mesh, MESHLINK_DEBUG, "send_req_key(%s) called while sptps->label != NULL!", to->name);
- char label[14 + strlen(mesh->self->name) + strlen(to->name) + 1];
- snprintf(label, sizeof label, "MeshLink UDP %s %s", mesh->self->name, to->name);
+ char label[sizeof meshlink_udp_label + strlen(mesh->self->name) + strlen(to->name) + 2];
+ snprintf(label, sizeof label, "%s %s %s", meshlink_udp_label, mesh->self->name, to->name);
sptps_stop(&to->sptps);
to->status.validkey = false;
to->status.waitingforkey = true;
return true;
}
- char label[14 + strlen(from->name) + strlen(mesh->self->name) + 1];
- snprintf(label, sizeof label, "MeshLink UDP %s %s", from->name, mesh->self->name);
+ char label[sizeof meshlink_udp_label + strlen(from->name) + strlen(mesh->self->name) + 2];
+ snprintf(label, sizeof label, "%s %s %s", meshlink_udp_label, from->name, mesh->self->name);
sptps_stop(&from->sptps);
from->status.validkey = false;
from->status.waitingforkey = true;