Skip to content

Commit

Permalink
Add support for registering a printf() callback
Browse files Browse the repository at this point in the history
for debug output. This is required by Firefox.
  • Loading branch information
t00fcxen committed Jan 19, 2013
1 parent 9ce774c commit b724b61
Show file tree
Hide file tree
Showing 16 changed files with 152 additions and 34 deletions.
17 changes: 14 additions & 3 deletions programs/client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2012 Michael Tuexen
* Copyright (C) 2011-2013 Michael Tuexen
*
* All rights reserved.
*
Expand Down Expand Up @@ -35,6 +35,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#ifndef _WIN32
#include <unistd.h>
#endif
Expand Down Expand Up @@ -74,6 +75,16 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return 1;
}

void
debug_printf(const char *format, ...)
{
va_list ap;

va_start(ap, format);
vprintf(format, ap);
va_end(ap);
}

int
main(int argc, char *argv[])
{
Expand All @@ -86,9 +97,9 @@ main(int argc, char *argv[])
int i, n;

if (argc > 3) {
usrsctp_init(atoi(argv[3]), NULL);
usrsctp_init(atoi(argv[3]), NULL, debug_printf);
} else {
usrsctp_init(9899, NULL);
usrsctp_init(9899, NULL, debug_printf);
}
#ifdef SCTP_DEBUG
usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
Expand Down
16 changes: 13 additions & 3 deletions programs/datachan_serv.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012 Michael Tuexen
* Copyright (C) 2012-2013 Michael Tuexen
*
* All rights reserved.
*
Expand Down Expand Up @@ -38,6 +38,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/types.h>
#ifndef _WIN32
#include <unistd.h>
Expand Down Expand Up @@ -267,6 +268,15 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return 1;
}

void
debug_printf(const char *format, ...)
{
va_list ap;

va_start(ap, format);
vprintf(format, ap);
va_end(ap);
}

int
main(int argc, char *argv[])
Expand All @@ -291,9 +301,9 @@ main(int argc, char *argv[])
}

if (argc > 1) {
usrsctp_init(atoi(argv[1]), NULL);
usrsctp_init(atoi(argv[1]), NULL, debug_printf);
} else {
usrsctp_init(9899, NULL);
usrsctp_init(9899, NULL, debug_printf);
}
#ifdef SCTP_DEBUG
usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
Expand Down
17 changes: 14 additions & 3 deletions programs/daytime_server.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012 Michael Tuexen
* Copyright (C) 2012-2013 Michael Tuexen
*
* All rights reserved.
*
Expand Down Expand Up @@ -38,6 +38,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/types.h>
#include <time.h>
#ifndef _WIN32
Expand All @@ -48,6 +49,16 @@
#endif
#include <usrsctp.h>

void
debug_printf(const char *format, ...)
{
va_list ap;

va_start(ap, format);
vprintf(format, ap);
va_end(ap);
}

#define DAYTIME_PPID 40
int
main(int argc, char *argv[])
Expand All @@ -61,9 +72,9 @@ main(int argc, char *argv[])
struct sctp_sndinfo sndinfo;

if (argc > 1) {
usrsctp_init(atoi(argv[1]), NULL);
usrsctp_init(atoi(argv[1]), NULL, debug_printf);
} else {
usrsctp_init(9899, NULL);
usrsctp_init(9899, NULL, debug_printf);
}
#ifdef SCTP_DEBUG
usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
Expand Down
17 changes: 14 additions & 3 deletions programs/discard_server.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2012 Michael Tuexen
* Copyright (C) 2011-2013 Michael Tuexen
*
* All rights reserved.
*
Expand Down Expand Up @@ -38,6 +38,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/types.h>
#ifndef _WIN32
#include <unistd.h>
Expand Down Expand Up @@ -105,6 +106,16 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return 1;
}

void
debug_printf(const char *format, ...)
{
va_list ap;

va_start(ap, format);
vprintf(format, ap);
va_end(ap);
}

int
main(int argc, char *argv[])
{
Expand All @@ -131,9 +142,9 @@ main(int argc, char *argv[])
unsigned int infotype;

if (argc > 1) {
usrsctp_init(atoi(argv[1]), NULL);
usrsctp_init(atoi(argv[1]), NULL, debug_printf);
} else {
usrsctp_init(9899, NULL);
usrsctp_init(9899, NULL, debug_printf);
}
#ifdef SCTP_DEBUG
usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
Expand Down
15 changes: 13 additions & 2 deletions programs/ekr_client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2012 Michael Tuexen
* Copyright (C) 2011-2013 Michael Tuexen
*
* All rights reserved.
*
Expand Down Expand Up @@ -34,6 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/types.h>
#ifndef _WIN32
#include <sys/socket.h>
Expand Down Expand Up @@ -141,6 +142,16 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return 1;
}

void
debug_printf(const char *format, ...)
{
va_list ap;

va_start(ap, format);
vprintf(format, ap);
va_end(ap);
}

int
main(int argc, char *argv[])
{
Expand All @@ -161,7 +172,7 @@ main(int argc, char *argv[])
struct sctp_sndinfo sndinfo;
char buffer[BUFFER_SIZE];

usrsctp_init(0, conn_output);
usrsctp_init(0, conn_output, debug_printf);
/* set up a connected UDP socket */
#ifdef _WIN32
if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
Expand Down
15 changes: 13 additions & 2 deletions programs/ekr_loop.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2012 Michael Tuexen
* Copyright (C) 2011-2013 Michael Tuexen
*
* All rights reserved.
*
Expand Down Expand Up @@ -31,6 +31,7 @@
#ifdef _WIN32
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -139,6 +140,16 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return 1;
}

void
debug_printf(const char *format, ...)
{
va_list ap;

va_start(ap, format);
vprintf(format, ap);
va_end(ap);
}

int
main(void)
{
Expand All @@ -158,7 +169,7 @@ main(void)
struct sctp_sndinfo sndinfo;
char line[LINE_LENGTH];

usrsctp_init(0, conn_output);
usrsctp_init(0, conn_output, debug_printf);
/* set up a connected UDP socket */
#ifdef _WIN32
if ((fd_c = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
Expand Down
16 changes: 14 additions & 2 deletions programs/ekr_peer.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2012 Michael Tuexen
* Copyright (C) 2011-2013 Michael Tuexen
*
* All rights reserved.
*
Expand Down Expand Up @@ -31,9 +31,11 @@
#ifdef _WIN32
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/types.h>
#ifndef _WIN32
#include <sys/socket.h>
Expand Down Expand Up @@ -330,6 +332,16 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return 1;
}

void
debug_printf(const char *format, ...)
{
va_list ap;

va_start(ap, format);
vprintf(format, ap);
va_end(ap);
}

int
main(int argc, char *argv[])
{
Expand All @@ -354,7 +366,7 @@ main(int argc, char *argv[])
struct sctp_sndinfo sndinfo;
char line[LINE_LENGTH];

usrsctp_init(0, conn_output);
usrsctp_init(0, conn_output, debug_printf);
/* set up a connected UDP socket */
#ifdef _WIN32
if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
Expand Down
15 changes: 13 additions & 2 deletions programs/ekr_server.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2012 Michael Tuexen
* Copyright (C) 2011-2013 Michael Tuexen
*
* All rights reserved.
*
Expand Down Expand Up @@ -36,6 +36,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <stdarg.h>
#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
Expand Down Expand Up @@ -142,6 +143,16 @@ receive_cb(struct socket *s, union sctp_sockstore addr, void *data,
return 1;
}

void
debug_printf(const char *format, ...)
{
va_list ap;

va_start(ap, format);
vprintf(format, ap);
va_end(ap);
}

int
main(int argc, char *argv[])
{
Expand All @@ -159,7 +170,7 @@ main(int argc, char *argv[])
pthread_t tid;
#endif

usrsctp_init(0, conn_output);
usrsctp_init(0, conn_output, debug_printf);
/* set up a connected UDP socket */
#ifdef _WIN32
if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
Expand Down
19 changes: 15 additions & 4 deletions programs/rtcweb.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*-
* Copyright (C) 2012 Michael Tuexen
* Copyright (C) 2012 Irene Ruengeler
* Copyright (C) 2012-2013 Michael Tuexen
* Copyright (C) 2012-2013 Irene Ruengeler
*
* All rights reserved.
*
Expand Down Expand Up @@ -50,6 +50,7 @@
#include <unistd.h>
#include <stdint.h>
#endif
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -1285,6 +1286,16 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return (1);
}

void
debug_printf(const char *format, ...)
{
va_list ap;

va_start(ap, format);
vprintf(format, ap);
va_end(ap);
}

int
main(int argc, char *argv[])
{
Expand All @@ -1310,9 +1321,9 @@ main(int argc, char *argv[])
SCTP_STREAM_CHANGE_EVENT};

if (argc > 1) {
usrsctp_init(atoi(argv[1]), NULL);
usrsctp_init(atoi(argv[1]), NULL, debug_printf);
} else {
usrsctp_init(9899, NULL);
usrsctp_init(9899, NULL, debug_printf);
}
#ifdef SCTP_DEBUG
usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
Expand Down
Loading

0 comments on commit b724b61

Please sign in to comment.