aprsis2: write header and tail around outgoing message
This commit is contained in:
parent
4a751c6b85
commit
0d4c8b594a
|
|
@ -5,6 +5,22 @@
|
|||
#include "aprsis2.pb-c.h"
|
||||
#include "version.h"
|
||||
|
||||
#define IS2_HEAD_LEN 4
|
||||
#define IS2_TAIL_LEN 1
|
||||
|
||||
static void *is2_allocate_buffer(int len)
|
||||
{
|
||||
int nlen = len + IS2_HEAD_LEN + IS2_TAIL_LEN;
|
||||
char *buf = hmalloc(nlen);
|
||||
uint32_t *ip = (uint32_t *)buf;
|
||||
|
||||
*ip = htonl(len);
|
||||
|
||||
buf[nlen-1] = '\n';
|
||||
|
||||
return (void *)buf;
|
||||
}
|
||||
|
||||
int is2_out_server_signature(struct worker_t *self, struct client_t *c)
|
||||
{
|
||||
ServerSignature sig = SERVER_SIGNATURE__INIT;
|
||||
|
|
@ -14,17 +30,17 @@ int is2_out_server_signature(struct worker_t *self, struct client_t *c)
|
|||
sig.app_name = verstr_progname;
|
||||
sig.app_version = version_build;
|
||||
len = server_signature__get_packed_size(&sig);
|
||||
buf = hmalloc(len);
|
||||
server_signature__pack(&sig, buf);
|
||||
buf = is2_allocate_buffer(len);
|
||||
server_signature__pack(&sig, buf + IS2_HEAD_LEN);
|
||||
|
||||
c->write(self, c, buf, len);
|
||||
c->write(self, c, buf, len + IS2_HEAD_LEN + IS2_TAIL_LEN);
|
||||
|
||||
hfree(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is2_in_server_signature(struct worker_t *self, struct client_t *c)
|
||||
int is2_data_in(struct worker_t *self, struct client_t *c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue