Skip to content

Commit

Permalink
Merge pull request #747 from robertdavidgraham/integration
Browse files Browse the repository at this point in the history
ISAKMP parser
  • Loading branch information
robertdavidgraham authored Dec 3, 2023
2 parents 017e8a0 + 309d021 commit 082c8ed
Show file tree
Hide file tree
Showing 7 changed files with 530 additions and 35 deletions.
3 changes: 3 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,8 @@ int main(int argc, char *argv[])
*/
{
int x = 0;
extern int proto_isakmp_selftest(void);

x += massip_selftest();
x += ranges6_selftest();
x += dedup_selftest();
Expand All @@ -1830,6 +1832,7 @@ int main(int argc, char *argv[])
x += siphash24_selftest();
x += ntp_selftest();
x += snmp_selftest();
x += proto_isakmp_selftest();
x += templ_payloads_selftest();
x += blackrock_selftest();
x += rawsock_selftest();
Expand Down
2 changes: 1 addition & 1 deletion src/out-binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ binary_out_status_ipv6(struct Output *out, FILE *fp, time_t timestamp,
int status, ipaddress ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
{
unsigned char buf[256+1];
size_t max = sizeof(buf-1);
size_t max = sizeof(buf)-1;
size_t offset = 0;
size_t bytes_written;

Expand Down
36 changes: 36 additions & 0 deletions src/proto-banout.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>

/***************************************************************************
***************************************************************************/
Expand Down Expand Up @@ -284,6 +285,41 @@ banout_expand(struct BannerOutput *banout, struct BannerOutput *p)
return n;
}






/***************************************************************************
***************************************************************************/
static void
banout_vprintf(struct BannerOutput *banout, unsigned proto,
const char *fmt, va_list marker) {
char str[10];
int len;

len = vsnprintf(str, sizeof(str), fmt, marker);
if (len > sizeof(str)-1) {
char *tmp = malloc(len+1);
vsnprintf(tmp, len+1, fmt, marker);
banout_append(banout, proto, tmp, len);
free(tmp);
} else {
banout_append(banout, proto, str, len);
}
}

/***************************************************************************
***************************************************************************/
void
banout_printf(struct BannerOutput *banout, unsigned proto, const char *fmt, ...) {
va_list marker;

va_start(marker, fmt);
banout_vprintf(banout, proto, fmt, marker);
va_end(marker);
}

/***************************************************************************
***************************************************************************/
void
Expand Down
3 changes: 3 additions & 0 deletions src/proto-banout.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ void
banout_append(struct BannerOutput *banout, unsigned proto, const void *px, size_t length);
#define AUTO_LEN ((size_t)~0)

void
banout_printf(struct BannerOutput *banout, unsigned proto, const char *fmt, ...);

/**
* Append a single character to the banner.
*/
Expand Down
Loading

0 comments on commit 082c8ed

Please sign in to comment.