From ad33ea0eb5f633bf7f8015c2613695134e0269e1 Mon Sep 17 00:00:00 2001 From: Heikki Hannikainen Date: Tue, 2 Jul 2013 09:05:42 +0300 Subject: [PATCH] IS2: transmit packets to downstream servers --- src/aprsis2.c | 20 +++++++++++++++++++- src/aprsis2.proto | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/aprsis2.c b/src/aprsis2.c index 75720af..a115b47 100644 --- a/src/aprsis2.c +++ b/src/aprsis2.c @@ -524,7 +524,25 @@ int is2_deframe_input(struct worker_t *self, struct client_t *c, int start_at) return i; } +/* + * Write a packet to a client. + * + * OPTIMIZE: generate packet once, or reuse incoming prepacked buffer + */ + int is2_write_packet(struct worker_t *self, struct client_t *c, char *p, int len) { - return 0; + ProtobufCBinaryData data; + data.data = (uint8_t *)p; + data.len = len-2; + + ISPacket pa = ISPACKET__INIT; + pa.type = ISPACKET__TYPE__IS_PACKET; + pa.is_packet_data = data; + + IS2Message m = IS2_MESSAGE__INIT; + m.type = IS2_MESSAGE__TYPE__IS_PACKET; + m.is_packet = &pa; + + return is2_write_message(self, c, &m); } diff --git a/src/aprsis2.proto b/src/aprsis2.proto index acb215d..7374465 100644 --- a/src/aprsis2.proto +++ b/src/aprsis2.proto @@ -113,6 +113,23 @@ message KeepalivePing { optional bytes request_data = 3; } +/* + * APRS-IS packet + */ + +message ISPacket { + enum Type { + // Traditional APRS-IS format with embedded Q construct + IS_PACKET = 2; + } + + // Identifies which message is filled in. + required Type type = 1; + + // packet data in traditional APRS-IS format, without CRLF + optional bytes is_packet_data = 2; +} + /* * This is the main link-level container message being transmitted * between peers (or clients and servers). @@ -129,6 +146,7 @@ message IS2Message { LOGIN_REQUEST = 3; LOGIN_REPLY = 4; KEEPALIVE_PING = 5; + IS_PACKET = 6; } // Identifies which message is filled in. @@ -139,5 +157,6 @@ message IS2Message { optional LoginRequest login_request = 3; optional LoginReply login_reply = 4; optional KeepalivePing keepalive_ping = 5; + optional ISPacket is_packet = 6; }