X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=send.c;h=b6fb70b88e658e374d174dbd66f90add09007d07;hb=4e8c6809edc239dcfae1f9333375776e4c488dff;hp=89408e49ba7cfe2f34439fdbfa9d5df1f1ec470e;hpb=7f25c3510e1865a9200bd54293303c97e36cb700;p=dragonnet.git diff --git a/send.c b/send.c index 89408e4..b6fb70b 100644 --- a/send.c +++ b/send.c @@ -1,9 +1,10 @@ +#include #include #include +#include +#include -#include - -void send_raw(DragonnetPeer *p, bool submit, const void *buf, size_t n) +void dragonnet_send_raw(DragonnetPeer *p, bool submit, const void *buf, size_t n) { pthread_rwlock_rdlock(&p->mu); int sock = p->sock; @@ -20,3 +21,10 @@ void send_raw(DragonnetPeer *p, bool submit, const void *buf, size_t n) dragonnet_peer_delete(p); } } + +void dragonnet_write_raw(u8 **buf, size_t *n, const void *data, size_t len) +{ + *buf = realloc(*buf, len + *n); + memcpy(&((*buf)[*n]), data, len); + *n += len; +}