X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fmeta.c;h=a05c7bd24f4239287e27254f6391a12dcbaa661e;hb=613c121cdceec0199dc4d056857be021ed1d21de;hp=0849d3cda03dc98cdf45a34e13d60522aa248729;hpb=d237efd325cd7bdd73f5eb111c769470238dce6e;p=tinc diff --git a/src/meta.c b/src/meta.c index 0849d3cd..a05c7bd2 100644 --- a/src/meta.c +++ b/src/meta.c @@ -78,6 +78,20 @@ bool send_meta(connection_t *c, const char *buffer, int length) { return true; } +void send_meta_raw(connection_t *c, const char *buffer, int length) { + if(!c) { + logger(DEBUG_ALWAYS, LOG_ERR, "send_meta() called with NULL pointer!"); + abort(); + } + + logger(DEBUG_META, LOG_DEBUG, "Sending %d bytes of raw metadata to %s (%s)", length, + c->name, c->hostname); + + buffer_add(&c->outbuf, buffer, length); + + io_set(&c->io, IO_READ | IO_WRITE); +} + void broadcast_meta(connection_t *from, const char *buffer, int length) { for list_each(connection_t, c, connection_list) if(c != from && c->edge) @@ -159,6 +173,25 @@ bool receive_meta(connection_t *c) { } do { + /* Are we receiving a SPTPS packet? */ + + if(c->sptpslen) { + int len = MIN(inlen, c->sptpslen - c->inbuf.len); + buffer_add(&c->inbuf, bufp, len); + + char *sptpspacket = buffer_read(&c->inbuf, c->sptpslen); + if(!sptpspacket) + return true; + + if(!receive_tcppacket_sptps(c, sptpspacket, c->sptpslen)) + return false; + c->sptpslen = 0; + + bufp += len; + inlen -= len; + continue; + } + if(c->protocol_minor >= 2) { int len = sptps_receive_data(&c->sptps, bufp, inlen); if(!len)