From d0cf5bcbbf42479df43d0a2d8f75cb4d143cead0 Mon Sep 17 00:00:00 2001 From: Babak Farrokhi Date: Sun, 11 Oct 2015 14:56:33 +0330 Subject: [PATCH 1/2] - Correctly log source IP address and Port number (sip and sport) to syslog --- fsipd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fsipd.c b/fsipd.c index c5ed06e..9eebc80 100644 --- a/fsipd.c +++ b/fsipd.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -88,12 +89,9 @@ void process_request(char *str) { /* check input str for SIP requests */ - /* - * TODO: log connection info including SRC/DST IP, SRC/DST PORT, - * Timestamp and Message Type in CSV Format - */ - syslog(LOG_ALERT, "incoming packet: %s\n", str); + syslog(LOG_ALERT, "sip: %s, sport: %d, payload: \"%s\"\n", + inet_ntoa(sa.sin_addr), ntohs(sa.sin_port), str); } /* From 27d5bde5afb8807300dba36c0d7bea313885cb8b Mon Sep 17 00:00:00 2001 From: Babak Farrokhi Date: Mon, 12 Oct 2015 19:37:46 +0330 Subject: [PATCH 2/2] Structure cleanup --- Makefile | 14 ++++++++------ fsipd.c => src/fsipd.c | 0 2 files changed, 8 insertions(+), 6 deletions(-) rename fsipd.c => src/fsipd.c (100%) diff --git a/Makefile b/Makefile index b5e8132..d655b0b 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,16 @@ -PREFIX=/usr/local +PREFIX?=/usr/local INC=-I$(PREFIX)/include -LIB=-L$(PREFIX)/lib -lutil -FLAGS=-Wall -O2 -pipe -funroll-loops -ffast-math -fno-strict-aliasing +LIB=-L$(PREFIX)/lib -lutil +CFLAGS=-g -Wall -Wextra -O2 -pipe -funroll-loops -ffast-math -fno-strict-aliasing CC?=cc +SOURCES=$(wildcard src/**/*.c src/*.c) + all: fsipd -fsipd: fsipd.c Makefile - $(CC) $(FLAGS) $(INC) $(LIB) fsipd.c -o fsipd +fsipd: $(SOURCES) Makefile + $(CC) $(CFLAGS) $(INC) $(LIB) src/fsipd.c -o bin/fsipd clean: - rm -f fsipd + rm -f bin/* diff --git a/fsipd.c b/src/fsipd.c similarity index 100% rename from fsipd.c rename to src/fsipd.c