A little initial work at sending a server signature in an IS2 protocol

This commit is contained in:
Heikki Hannikainen 2013-06-26 00:57:54 +03:00
parent 04f629bec6
commit 922f1a56b3
10 changed files with 65 additions and 8 deletions

View File

@ -171,7 +171,7 @@ OBJS = aprsc.o accept.o worker.o errno_aprsc.o \
filter.o cellmalloc.o historydb.o \
counterdata.o status.o cJSON.o \
http.o tls.o sctp.o version.o \
aprsis2.pb-c.o \
aprsis2.pb-c.o aprsis2.o \
@LIBOBJS@
clean:

30
src/aprsis2.c Normal file
View File

@ -0,0 +1,30 @@
#include "hmalloc.h"
#include "worker.h"
#include "aprsis2.h"
#include "aprsis2.pb-c.h"
#include "version.h"
int is2_out_server_signature(struct worker_t *self, struct client_t *c)
{
ServerSignature sig = SERVER_SIGNATURE__INIT;
void *buf; // Buffer to store serialized data
unsigned len; // Length of serialized data
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);
c->write(self, c, buf, len);
hfree(buf);
return 0;
}
int is2_in_server_signature(struct worker_t *self, struct client_t *c)
{
return 0;
}

10
src/aprsis2.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef APRSIS2_H
#define APRSIS2_H
#include "worker.h"
extern int is2_out_server_signature(struct worker_t *self, struct client_t *c);
#endif

View File

@ -1,4 +1,9 @@
message ServerSignature {
required string app_name = 3;
required string app_version = 4;
}
message LoginRequest {
required string username = 1; // callsign-SSID
optional string password = 2;
@ -9,9 +14,9 @@ message LoginRequest {
enum VerificationStatus {
NONE = 0;
PASSCODE = 1;
PASSWORD = 2;
CERT = 3;
WEAK = 1;
MEDIUM = 2;
STRONG = 3;
}
enum LoginResult {

View File

@ -950,6 +950,9 @@ int do_listen(struct listen_config_t **lq, int argc, char **argv)
clflags |= CLFLAGS_IGATE;
} else if (strcasecmp(argv[2], "fullfeed") == 0) {
clflags |= CLFLAGS_FULLFEED;
} else if (strcasecmp(argv[2], "is2") == 0) {
clflags |= CLFLAGS_IGATE;
clflags |= CLFLAGS_IS2;
} else if (strcasecmp(argv[2], "dupefeed") == 0) {
clflags |= CLFLAGS_DUPEFEED;
} else if (strcasecmp(argv[2], "clientonly") == 0) {

View File

@ -296,7 +296,9 @@ int uplink_login_handler(struct worker_t *self, struct client_t *c, int l4proto,
int rc;
int argc;
char *argv[256];
//if (is2_in_server_signature(self, c, l4proto, s, len)
hlog_packet(LOG_INFO, s, len, "%s: Uplink server software: ", c->addr_rem);
#ifdef USE_SSL

View File

@ -6,6 +6,7 @@
#include "xpoll.h"
#include "tls.h"
const char verstr_progname[] = PROGNAME;
const char version_build[] = VERSION "-" SRCVERSION VERSION_BRANCH;
const char verstr[] = PROGNAME " " VERSION "-" SRCVERSION VERSION_BRANCH;
const char verstr_aprsis[] = PROGNAME " " VERSION "-" SRCVERSION VERSION_BRANCH;

View File

@ -15,6 +15,7 @@
#define APRSC_TOCALL "APSC20"
extern const char verstr_progname[];
extern const char version_build[];
extern const char verstr[];
extern const char verstr_aprsis[];

View File

@ -37,7 +37,7 @@
#include "version.h"
#include "status.h"
#include "sctp.h"
#include "aprsis2.h"
time_t now; /* current time, updated by the main thread, MAY be spun around by NTP */
time_t tick; /* monotonous clock, may or may not be wallclock */
@ -1584,8 +1584,12 @@ static void collect_new_clients(struct worker_t *self)
* In case of a live upgrade, this should maybe be skipped, but
* I'll leave it in for now.
*/
if (c->flags & CLFLAGS_INPORT)
client_printf(self, c, "# %s\r\n", (fake_version) ? fake_version : verstr_aprsis);
if (c->flags & CLFLAGS_INPORT) {
if (c->flags & CLFLAGS_IS2)
is2_out_server_signature(self, c);
else
client_printf(self, c, "# %s\r\n", (fake_version) ? fake_version : verstr_aprsis);
}
/* If the write failed immediately, c is already invalid at this point. Don't touch it. */
}

View File

@ -344,6 +344,7 @@ struct client_t {
#define CLFLAGS_CLIENTONLY 0x800 /* Client connected on client-only port */
#define CLFLAGS_IGATE 0x1000 /* Igate port */
#define CLFLAGS_UPLINKMULTI 0x2000 /* Allow multiple parallel outgoing connections */
#define CLFLAGS_IS2 0x4000 /* IS2 Protocol Buffers */
#define VALIDATED_WEAK 1 /* client validated with passcode */
#define VALIDATED_STRONG 3 /* client validated with SSL certificate */