Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 192 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
@AM_GIT_VERSION@

bin_PROGRAMS = sipp

TESTS = sipp_unittest

check_PROGRAMS = $(TESTS)

AM_CFLAGS=-I$(srcdir)/include -Wall -pedantic
AM_CXXFLAGS=-I$(srcdir)/include -Wall -pedantic

# For BSD-style elements in udphdr struct (uh_dport instead of dest)
# among others.
AM_CPPFLAGS=-D_BSD_SOURCE -D_DEFAULT_SOURCE

CLEANFILES =
EXTRA_DIST = \
$(srcdir)/example/fortune.cpp \
$(srcdir)/LICENSE.txt \
$(srcdir)/README.md \
$(srcdir)/THANKS \
$(srcdir)/sipp.dtd \
$(srcdir)/cpplint.py

if HAVE_OPENSSL
DEFS += -DUSE_TLS -DUSE_OPENSSL
ssl_incl = \
include/sslsocket.hpp
ssl_SOURCES = \
$(ssl_incl) \
src/sslsocket.cpp
endif

if HAVE_PCAP
DEFS += -DPCAPPLAY
pcap_incl = \
include/prepare_pcap.h \
include/send_packets.h
pcap_SOURCES = \
$(pcap_incl) \
src/prepare_pcap.c \
src/send_packets.c
endif

if HAVE_RTP
DEFS += -DRTP_STREAM
rtp_SOURCES = \
src/rtpstream.cpp \
include/rtpstream.hpp
endif

if HAVE_SCTP
DEFS += -DUSE_SCTP
endif

if HAVE_GSL
DEFS += -DHAVE_GSL
endif

if HAVE_EPOLL
DEFS += -DHAVE_EPOLL
endif

common_incl = \
include/comp.h \
include/infile.hpp \
include/listener.hpp \
include/logger.hpp \
include/md5.h \
include/message.hpp \
include/milenage.h \
include/call_generation_task.hpp \
include/ratetask.hpp \
include/reporttask.hpp \
include/rijndael.h \
include/scenario.hpp \
include/sip_parser.hpp \
include/screen.hpp \
include/socket.hpp \
include/socketowner.hpp \
include/stat.hpp \
include/strings.hpp \
include/task.hpp \
include/time.hpp \
include/variables.hpp \
include/watchdog.hpp \
include/xp_parser.h \
include/actions.hpp \
include/call.hpp \
include/auth.hpp \
include/deadcall.hpp \
include/jlsrtp.hpp

common_SOURCES = \
src/actions.cpp \
src/auth.cpp \
src/comp.c \
src/call.cpp \
src/deadcall.cpp \
src/infile.cpp \
src/listener.cpp \
src/logger.cpp \
src/md5.c \
src/message.cpp \
src/milenage.c \
src/call_generation_task.cpp \
src/ratetask.cpp \
src/reporttask.cpp \
src/rijndael.c \
src/scenario.cpp \
src/sip_parser.cpp \
src/screen.cpp \
src/socket.cpp \
src/socketowner.cpp \
src/stat.cpp \
src/strings.cpp \
src/task.cpp \
src/time.cpp \
src/variables.cpp \
src/watchdog.cpp \
src/xp_parser.c \
$(common_incl) \
$(ssl_SOURCES) \
$(pcap_SOURCES) \
$(rtp_SOURCES) \
src/jlsrtp.cpp

sipp_SOURCES = \
$(common_SOURCES) \
src/sipp.cpp \
include/sipp.hpp

sipp_CFLAGS = $(AM_CFLAGS) @GSL_CFLAGS@
sipp_CXXFLAGS = $(AM_CXXFLAGS) @GSL_CXXFLAGS@
sipp_LDADD = @LIBOBJS@ @GSL_LIBS@

# call.cpp and sipp.cpp use version.h; see AM_GIT_VERSION.
src/call.cpp: include/version.h
src/sipp.cpp: include/version.h

gtest_SOURCES = \
gtest/src/gtest-death-test.cc \
gtest/src/gtest-filepath.cc \
gtest/src/gtest-internal-inl.h \
gtest/src/gtest-port.cc \
gtest/src/gtest-printers.cc \
gtest/src/gtest-test-part.cc \
gtest/src/gtest-typed-test.cc \
gtest/src/gtest.cc \
gmock/src/gmock-internal-utils.cc \
gmock/src/gmock-matchers.cc

sipp_unittest_SOURCES = \
$(common_SOURCES) \
src/sipp_unittest.cpp \
src/xp_parser_ut.cpp \
$(gtest_SOURCES)

sipp_unittest_CFLAGS = $(AM_CFLAGS) -DGTEST=1 \
-I$(srcdir)/gtest/include \
-I$(srcdir)/gmock/include \
-I$(srcdir)/gtest \
-I$(srcdir)/gmock \
@GSL_CFLAGS@

sipp_unittest_CXXFLAGS = $(AM_CXXFLAGS) -DGTEST=1 \
-I$(srcdir)/gtest/include \
-I$(srcdir)/gmock/include \
-I$(srcdir)/gtest \
-I$(srcdir)/gmock \
@GSL_CXXFLAGS@

sipp_unittest_LDADD = @LIBOBJS@ @GSL_LIBS@

# Ensure that after a reconfigure the source is cleaned.
.autoclean: Makefile
make clean
echo > .autoclean
BUILT_SOURCES = .autoclean

if HAVE_HELP2MAN
man_MANS = sipp.1
CLEANFILES += $(man_MANS)

sipp.1: ./sipp $(sipp_SOURCES)
$(HELP2MAN) --output=$@ -v "-v" --no-info \
--name='SIP testing tool and traffic generator' \
./sipp
else
sipp.1:
@echo "Warning: help2man not available, no man page is created."
endif
6 changes: 6 additions & 0 deletions commandlines.rtpcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SET-SIDE command line:
./sipp 192.168.1.250:5060 -sf sipp_scenarios/pfca_uac_pattern.xml -i 192.168.1.147 -t u1 -p 5060 -mp 4000 -m 1 -s 16002

ICP-SIDE command line:
./sipp -sf sipp_scenarios/pfca_uas.xml -i 192.168.1.250 -t u1 -p 5060 -mp 5000 -m 1 -s 16001 -rtp_echo

6 changes: 6 additions & 0 deletions commandlines.srtpcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SET-SIDE command line:
./sipp 192.168.1.250:5060 -sf sipp_scenarios/pfca_uac_bpattern_crypto_simple.xml -i 192.168.1.147 -t u1 -p 5060 -mp 4000 -m 1 -s 16002 -rtpcheck_debug -srtpcheck_debug

ICP-SIDE command line:
./sipp -sf sipp_scenarios/pfca_uas_both_crypto_simple.xml -i 192.168.1.250 -t u1 -p 5060 -mp 5000 -m 1 -s 16001 -srtpcheck_debug

20 changes: 18 additions & 2 deletions include/actions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ class CAction
E_AT_RTP_STREAM_RESUME,
E_AT_RTP_STREAM_PLAY,
E_AT_RTP_ECHO,
E_AT_RTP_STREAM_PAUSEAPATTERN,
E_AT_RTP_STREAM_RESUMEAPATTERN,
E_AT_RTP_STREAM_PLAYAPATTERN,
E_AT_RTP_STREAM_PAUSEVPATTERN,
E_AT_RTP_STREAM_RESUMEVPATTERN,
E_AT_RTP_STREAM_PLAYVPATTERN,
E_AT_RTP_STREAM_RTPECHO_UPDATEAUDIO,
E_AT_RTP_STREAM_RTPECHO_STARTAUDIO,
E_AT_RTP_STREAM_RTPECHO_STOPAUDIO,
E_AT_RTP_STREAM_RTPECHO_UPDATEVIDEO,
E_AT_RTP_STREAM_RTPECHO_STARTVIDEO,
E_AT_RTP_STREAM_RTPECHO_STOPVIDEO,
#endif
E_AT_NB_ACTION
};
Expand Down Expand Up @@ -136,7 +148,8 @@ class CAction
pcap_pkts *getPcapPkts(); /* send_packets specific function */
#endif
#ifdef RTP_STREAM
rtpstream_actinfo_t *getRTPStreamActInfo(); /* return stored rtp stream playback params */
rtpecho_actinfo_t* getRTPEchoActInfo(); /* returns stored rtp echo params */
rtpstream_actinfo_t* getRTPStreamActInfo(); /* return stored rtp stream playback params */
#endif

void setActionType (T_ActionType P_value);
Expand Down Expand Up @@ -165,7 +178,9 @@ class CAction
void setPcapArgs (pcap_pkts * P_value); /* send_packets specific function */
#endif
#ifdef RTP_STREAM
void setRTPStreamActInfo(const char* P_value); /* parse rtp stream playback values from string */
void setRTPEchoActInfo(const char* P_value); /* parses rtp echo params from string */
void setRTPEchoActInfo(rtpecho_actinfo_t* P_value); /* copy stored rtp echo params */
void setRTPStreamActInfo(const char *P_value); /* parse rtp stream playback values from string */
void setRTPStreamActInfo(rtpstream_actinfo_t* P_value); /* copy stored rtp stream playback params */
#endif

Expand Down Expand Up @@ -220,6 +235,7 @@ class CAction
pcap_pkts * M_pcapArgs;
#endif
#ifdef RTP_STREAM
rtpecho_actinfo_t M_rtpecho_actinfo;
rtpstream_actinfo_t M_rtpstream_actinfo;
#endif
void setSubString(char** P_target, const char* P_source, int P_start, int P_stop);
Expand Down
63 changes: 57 additions & 6 deletions include/call.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
#endif
#ifdef RTP_STREAM
#include "rtpstream.hpp"
#endif
#include "jlsrtp.hpp"
#endif // RTP_STREAM

#include <stdarg.h>

#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
Expand All @@ -59,6 +62,18 @@ struct txnInstanceInfo {
int ackIndex;
};

typedef enum
{
eNoSession,
eOfferReceived,
eOfferSent,
eOfferRejected,
eAnswerReceived,
eAnswerSent,
eCompleted,
eNumSessionStates
} SessionState;

class call : virtual public task, virtual public listener, public virtual socketowner
{
public:
Expand Down Expand Up @@ -106,6 +121,9 @@ class call : virtual public task, virtual public listener, public virtual socket
private:
/* This is the core constructor function. */
void init(scenario * call_scenario, SIPpSocket *socket, struct sockaddr_storage *dest, const char * p_id, int userId, bool ipv6, bool isAutomatic, bool isInitCall);

bool checkAckCSeq(const char* msg);

/* This this call for initialization? */
bool initCall;

Expand Down Expand Up @@ -145,6 +163,8 @@ class call : virtual public task, virtual public listener, public virtual socket
int last_recv_index;
char * last_recv_msg;

unsigned long int last_recv_invite_cseq;

/* Recv message characteristics when we sent a valid message
* (scneario, no retrans) just after a valid reception. This was
* a cause relationship, so the next time this cookie will be recvd,
Expand All @@ -171,7 +191,19 @@ class call : virtual public task, virtual public listener, public virtual socket

#ifdef RTP_STREAM
rtpstream_callinfo_t rtpstream_callinfo;
#endif
JLSRTP _txUACAudio;
JLSRTP _rxUACAudio;
JLSRTP _txUASAudio;
JLSRTP _rxUASAudio;
JLSRTP _txUACVideo;
JLSRTP _rxUACVideo;
JLSRTP _txUASVideo;
JLSRTP _rxUASVideo;
#ifdef USE_OPENSSL
char _pref_audio_cs_out[24];
char _pref_video_cs_out[24];
#endif // USE_OPENSSL
#endif // RTP_STREAM

/* holds the auth header and if the challenge was 401 or 407 */
char * dialog_authentication;
Expand Down Expand Up @@ -224,7 +256,8 @@ class call : virtual public task, virtual public listener, public virtual socket
E_AR_TEST_DOESNT_MATCH,
E_AR_TEST_SHOULDNT_MATCH,
E_AR_STRCMP_DOESNT_MATCH,
E_AR_STRCMP_SHOULDNT_MATCH
E_AR_STRCMP_SHOULDNT_MATCH,
E_AR_RTPECHO_ERROR
};

/* Store the last action result to allow */
Expand Down Expand Up @@ -306,22 +339,40 @@ class call : virtual public task, virtual public listener, public virtual socket
void get_remote_media_addr(std::string const &msg);

#ifdef RTP_STREAM
void extract_rtp_remote_addr(const char* message);
#endif
std::string extract_rtp_remote_addr(const char * message, int &ip_ver, int &audio_port, int &video_port);
#ifdef USE_OPENSSL
int check_audio_ciphersuite_match(SrtpAudioInfoParams &pA);
int check_video_ciphersuite_match(SrtpVideoInfoParams &pV);
int extract_srtp_remote_info(const char * msg, SrtpAudioInfoParams &pA, SrtpVideoInfoParams &pV);
#endif // USE_OPENSSL
#endif // RTP_STREAM

bool lost(int index);

void setRtpEchoErrors(int value);
int getRtpEchoErrors();

void computeStat (CStat::E_Action P_action);
void computeStat (CStat::E_Action P_action, unsigned long P_value);
void computeStat (CStat::E_Action P_action, unsigned long P_value, int which);


void queue_up(const char* msg);
char *queued_msg;

int _callDebug(const char *fmt, ...) __attribute__((format(printf, 2, 3)));
char *debugBuffer;
int debugLength;

#ifdef USE_OPENSSL
FILE* _srtpctxdebugfile;
int logSrtpInfo(const char *fmt, ...);
#endif // USE_OPENSSL

SessionState _sessionStateCurrent;
SessionState _sessionStateOld;
void setSessionState(SessionState state);
SessionState getSessionStateCurrent();
SessionState getSessionStateOld();
};


Expand Down
1 change: 1 addition & 0 deletions include/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ extern "C" {
#define EXIT_OTHER 99
#define EXIT_FATAL_ERROR -1
#define EXIT_BIND_ERROR -2
#define EXIT_RTPCHECK_FAILED -3

#endif /* __DEFINES_H__ */
Loading