- if(c->status.encryptout) {
- result = EVP_EncryptUpdate(c->outctx, outbuf, &outlen, buffer, length);
- if(!result || outlen != length) {
- logger(LOG_ERR, _("Error while encrypting metadata to %s (%s): %s"),
- c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
- return false;
+ return true;
+}
+
+bool send_meta(meshlink_handle_t *mesh, connection_t *c, const char *buffer, int length) {
+ if(!c) {
+ logger(mesh, MESHLINK_ERROR, "send_meta() called with NULL pointer!");
+ abort();
+ }
+
+ logger(mesh, MESHLINK_DEBUG, "Sending %d bytes of metadata to %s", length, c->name);
+
+ if(c->allow_request == ID) {
+ buffer_add(&c->outbuf, buffer, length);
+ io_set(&mesh->loop, &c->io, IO_READ | IO_WRITE);
+ return true;
+ }
+
+ return sptps_send_record(&c->sptps, 0, buffer, length);
+}
+
+void broadcast_meta(meshlink_handle_t *mesh, connection_t *from, const char *buffer, int length) {
+ for list_each(connection_t, c, mesh->connections)
+ if(c != from && c->status.active) {
+ send_meta(mesh, c, buffer, length);