├── .gitattributes
├── .github
├── FUNDING.yml
└── workflows
│ └── star.yml
├── .gitignore
├── .travis.yml
├── AUTHORS
├── COPYING
├── ChangeLog
├── LICENSE
├── Makefile.am
├── README.md
├── build.sh
├── captagent.spec.in
├── captagent
└── conf
│ └── captagent.xml
├── common.am
├── conf
├── captagent.xml.in
├── captureplans
│ ├── diameter_capture_plan.cfg
│ ├── isup_capture_plan.cfg
│ ├── rtcp_capture_plan.cfg
│ ├── rtcpxr_capture_plan.cfg
│ ├── sip_capture_plan.cfg
│ ├── tls_capture_plan.cfg
│ └── tzsp_capture_plan.cfg
├── database_hash.xml
├── database_redis.xml
├── output_json.xml
├── protocol_diameter.xml
├── protocol_rtcp.xml
├── protocol_rtcpxr.xml
├── protocol_sip.xml
├── protocol_ss7.xml
├── protocol_tls.xml
├── socket_collector.xml
├── socket_pcap.xml
├── socket_tzsp.xml
└── transport_hep.xml
├── configure.ac
├── format_code.sh
├── fuzzing
├── build-captagent-clang-address.sh
├── build-captagent-clang.sh
├── build-captagent-gcc.sh
├── fuzz_test
│ ├── RTCP_CRASH
│ │ ├── rtcp_cr.sh
│ │ └── rtcp_crash.c
│ └── RTCP_TO_JSON_CRASH
│ │ ├── rtcp_capture_plan.cfg
│ │ └── rtcp_crash.go
└── run-captagent.sh
├── hep-tester
├── README
├── core_hep.h
├── heptester.c
└── heptester.h
├── include
├── Makefile.am
└── captagent
│ ├── action.h
│ ├── api.h
│ ├── capture.h
│ ├── export_function.h
│ ├── globals.h
│ ├── log.h
│ ├── md5.h
│ ├── modules.h
│ ├── modules_api.h
│ ├── proto_sip.h
│ ├── structure.h
│ └── xmlread.h
├── init
├── deb
│ └── debian
│ │ ├── captagent.default
│ │ ├── captagent.init
│ │ └── captagent.service
├── el
│ ├── captagent.init
│ ├── captagent.service
│ └── captagent.sysconfig
└── freebsd
│ └── captagent
├── m4
├── as-ac-expand.m4
└── modules_makefiles.m4
├── modules.am
├── pkg
├── centos
│ ├── builder-centos7
│ │ ├── builder.sh
│ │ ├── epel-release-latest-7.noarch.rpm
│ │ ├── libuv-1.8.0-1.el7.centos.x86_64.rpm
│ │ ├── libuv-devel-1.8.0-1.el7.centos.x86_64.rpm
│ │ └── run.sh
│ └── builder-centos8
│ │ ├── builder.sh
│ │ ├── flex-2.6.1-9.el8.x86_64.rpm
│ │ ├── flex-devel-2.6.1-9.el8.x86_64.rpm
│ │ ├── libuv-1.34.2-1.module_el8+8340+1d027fbb.x86_64.rpm
│ │ ├── libuv-devel-1.34.2-1.module_el8+8340+1d027fbb.x86_64.rpm
│ │ └── run.sh
├── debian
│ ├── builder-debian10
│ │ ├── builder.sh
│ │ └── run.sh
│ ├── builder-debian11
│ │ ├── builder.sh
│ │ └── run.sh
│ └── captagent.init.in
└── freebsd
│ └── captagent
├── run.sh
├── src
├── Makefile.am
├── capplan.l
├── capplan.tab.y
├── captagent.c
├── captagent.h
├── conf_function.c
├── conf_function.h
├── log.c
├── md5.c
├── md5.h
├── modules.c
├── modules
│ ├── database
│ │ ├── hash
│ │ │ ├── Makefile.am
│ │ │ ├── captarray.c
│ │ │ ├── captarray.h
│ │ │ ├── database_hash.c
│ │ │ ├── database_hash.h
│ │ │ ├── hash_structure.h
│ │ │ ├── list.h
│ │ │ ├── localapi.c
│ │ │ ├── localapi.h
│ │ │ ├── utarray.h
│ │ │ ├── uthash.h
│ │ │ ├── utlist.h
│ │ │ └── utstring.h
│ │ └── redis
│ │ │ ├── Makefile.am
│ │ │ ├── database_redis.c
│ │ │ └── database_redis.h
│ ├── interface
│ │ └── http
│ │ │ ├── Makefile.am
│ │ │ ├── civetweb.c
│ │ │ ├── civetweb.h
│ │ │ ├── extra_api.c
│ │ │ ├── extra_api.h
│ │ │ ├── interface_http.c
│ │ │ └── interface_http.h
│ ├── protocol
│ │ ├── diameter
│ │ │ ├── Makefile.am
│ │ │ ├── captureplan
│ │ │ │ └── Makefile.am
│ │ │ ├── parser_diameter.c
│ │ │ ├── parser_diameter.h
│ │ │ ├── protocol_diameter.c
│ │ │ └── protocol_diameter.h
│ │ ├── epan
│ │ │ ├── Makefile.am
│ │ │ └── protocol_epan.c
│ │ ├── rtcp
│ │ │ ├── Makefile.am
│ │ │ ├── captureplan
│ │ │ │ └── Makefile.am
│ │ │ ├── parser_rtcp.c
│ │ │ ├── parser_rtcp.h
│ │ │ ├── protocol_rtcp.c
│ │ │ └── protocol_rtcp.h
│ │ ├── rtcpxr
│ │ │ ├── Makefile.am
│ │ │ ├── captureplan
│ │ │ │ └── Makefile.am
│ │ │ ├── parser_rtcpxr.c
│ │ │ ├── parser_rtcpxr.h
│ │ │ ├── protocol_rtcpxr.c
│ │ │ └── protocol_rtcpxr.h
│ │ ├── sip
│ │ │ ├── Makefile.am
│ │ │ ├── captureplan
│ │ │ │ └── Makefile.am
│ │ │ ├── parser_sip.c
│ │ │ ├── parser_sip.h
│ │ │ ├── protocol_sip.c
│ │ │ └── protocol_sip.h
│ │ ├── ss7
│ │ │ ├── Makefile.am
│ │ │ ├── isup_generated.c
│ │ │ ├── isup_generated.h
│ │ │ ├── isup_parsed.c
│ │ │ ├── isup_parsed.h
│ │ │ ├── protocol_ss7.c
│ │ │ ├── srjson.c
│ │ │ └── srjson.h
│ │ └── tls
│ │ │ ├── Makefile.am
│ │ │ ├── captureplan
│ │ │ └── Makefile.am
│ │ │ ├── decryption.c
│ │ │ ├── decryption.h
│ │ │ ├── define.h
│ │ │ ├── hash_structure.h
│ │ │ ├── localapi.c
│ │ │ ├── localapi.h
│ │ │ ├── parser_tls.c
│ │ │ ├── parser_tls.h
│ │ │ ├── protocol_tls.c
│ │ │ ├── protocol_tls.h
│ │ │ └── uthash.h
│ ├── socket
│ │ ├── collector
│ │ │ ├── Makefile.am
│ │ │ ├── captureplan
│ │ │ │ └── Makefile.am
│ │ │ ├── socket_collector.c
│ │ │ └── socket_collector.h
│ │ ├── pcap
│ │ │ ├── Makefile.am
│ │ │ ├── ipreasm.c
│ │ │ ├── ipreasm.h
│ │ │ ├── localapi.c
│ │ │ ├── localapi.h
│ │ │ ├── sctp_support.c
│ │ │ ├── sctp_support.h
│ │ │ ├── socket_pcap.c
│ │ │ ├── socket_pcap.h
│ │ │ ├── tcpreasm.c
│ │ │ ├── tcpreasm.h
│ │ │ └── uthash.h
│ │ └── tzsp
│ │ │ ├── Makefile.am
│ │ │ ├── captureplan
│ │ │ ├── Makefile.am
│ │ │ └── Makefile.am~
│ │ │ ├── socket_tzsp.c
│ │ │ └── socket_tzsp.h
│ └── transport
│ │ ├── hep
│ │ ├── Makefile.am
│ │ ├── localapi.c
│ │ ├── localapi.h
│ │ ├── transport_hep.c
│ │ └── transport_hep.h
│ │ └── json
│ │ ├── Makefile.am
│ │ ├── output_json.c
│ │ └── output_json.h
├── xmlread.c
└── y.tab.h
└── test
├── README.md
├── hep.js
├── init.js
├── package-lock.json
└── package.json
/.gitattributes:
--------------------------------------------------------------------------------
1 | captagent/autom4te.cache/* linguist-vendored
2 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [qxip]
2 |
--------------------------------------------------------------------------------
/.github/workflows/star.yml:
--------------------------------------------------------------------------------
1 | name: Starring Partner
2 | on:
3 | issues:
4 | types: [opened, reopened]
5 | jobs:
6 | # This workflow checks if a user has starred a repository and takes actions
7 | starcheck:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - name: Please Star First
11 | uses: qxip/please-star-light@v3
12 | with:
13 | token: ${{ secrets.GITHUB_TOKEN }}
14 | message: "Your report is appreciated. Please star this repository to motivate its developers! :star:"
15 | label: "stargazed"
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | INSTALL
2 | Makefile
3 | Makefile.in
4 | aclocal.m4
5 | compile
6 | config.guess
7 | src/config.h
8 | src/config.h.in
9 | src/config.h.in~
10 | src/capplan.c
11 | src/capplan.h
12 | config.log
13 | config.status
14 | config.sub
15 | configure
16 | depcomp
17 | install-sh
18 | libtool
19 | ltmain.sh
20 | missing
21 | stamp-h1
22 | *.o
23 | *.lo
24 | *.a
25 | *.la
26 | *.Po
27 | *.Plo
28 | .*.swp
29 | .deps
30 | .libs
31 | autom4te.cache
32 | libtool.m4
33 | lt~obsolete.m4
34 | ltoptions.m4
35 | ltsugar.m4
36 | ltversion.m4
37 | capplan.tab.h
38 | lex.yy.c
39 | ylwrap
40 | captagent.spec
41 | conf/captagent.xml
42 | pkg/debian/*.substvars
43 | pkg/debian/*.debhelper
44 | pkg/debian/*.debhelper.log
45 | pkg/debian/files
46 | pkg/debian/captagent/
47 | pkg/debian/captagent.init
48 | src/captagent
49 | src/capplan.tab.c
50 | *.dh-orig
51 |
52 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | matrix:
2 | include:
3 | # Plain Agent
4 | - os: linux
5 | env:
6 | - CONFIGURE=""
7 | # TLS Agent
8 | - os: linux
9 | env:
10 | - CONFIGURE="--enable-tls --enable-ssl"
11 | # SSL Agent
12 | - os: linux
13 | env:
14 | - CONFIGURE="--enable-ssl"
15 |
16 | language: c
17 | addons:
18 | apt:
19 | packages:
20 | - net-tools
21 | compiler:
22 | - gcc
23 | before_install:
24 | # - sudo -E apt-add-repository -y ppa:linuxjedi/ppa
25 | - sudo apt-get update || true
26 | - sudo apt-get install -y build-essential
27 | - sudo apt-get install -y libpcap-dev libexpat-dev libjson0-dev bison flex libtool autoconf automake autogen libuv-dev libssl-dev libgcrypt20 libgcrypt20-dev
28 | - ip -o -4 a | awk '$2 == "eth0" { gsub(/\/.*/, "", $4); print $4 }' > /tmp/pubip
29 | - ip -o -4 a | awk '$2 == "lo" { gsub(/\/.*/, "", $4); print $4 }' > /tmp/localip
30 | install:
31 | - curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
32 | - sudo apt-get install -y nodejs
33 | - sudo npm i -g npm
34 |
35 | script:
36 | - sudo sed -i 's/any/lo/g' ./conf/socket_pcap.xml
37 | - ./build.sh
38 | - ./configure ${CONFIGURE}
39 | - make
40 | - sudo make install
41 | - sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' ./src/captagent || echo "Setcap failed"
42 | - ./src/captagent -v
43 | - cd test && npm install && sudo -s npm test
44 |
--------------------------------------------------------------------------------
/AUTHORS:
--------------------------------------------------------------------------------
1 | Alexandr Dubovikov
2 |
--------------------------------------------------------------------------------
/ChangeLog:
--------------------------------------------------------------------------------
1 | - 18.01.2023 cptagent 6.4.1 (latest)
2 |
3 | - 03.10.2019 cptagent 6.3.1
4 |
5 | - 02.01.2018 captagent 6.3.0
6 |
7 | - 22.05.2017 captagent 6.2.11
8 |
9 | - 16.06.2016 captagent 6.1.0.20
10 |
11 | - 10.07.2015 captagent 6.0.0 beta 1
12 |
--------------------------------------------------------------------------------
/Makefile.am:
--------------------------------------------------------------------------------
1 | include common.am
2 |
3 | SUBDIRS = \
4 | src \
5 | include
6 |
7 | EXTRA_DIST = \
8 | conf \
9 | README.md \
10 | @PACKAGE_NAME@.spec \
11 | @PACKAGE_NAME@.spec.in \
12 | pkg/debian/@PACKAGE_NAME@.init.in \
13 | pkg/el/captagent.sysconfig \
14 | pkg/el/7/captagent.service
15 |
16 | ACLOCAL_AMFLAGS = -I m4
17 |
18 | distclean-local:
19 | rm -rf autom4te.cache
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CaptAgent
5 | =========
6 |
7 | ### The Next-Generation HEP Capture Agent for [Homer](https://github.com/sipcapture/homer)
8 | -------------
9 | 
10 | 
11 | 
12 | 
13 | 
14 | 
15 | 
16 | 
17 | 
18 |
19 | Captagent is a powerful, flexible, completely modular HEP packet capture and mirroring framework for RTC, ready for _(virtually)_ any kind of IP protocol and encapsulation method - past, present - and future.
20 |
21 | ### Status
22 | [](https://travis-ci.org/sipcapture/captagent)
23 |
24 | ### Get Started
25 | Setup & Configuration instructions are available on the Project [Wiki](https://github.com/sipcapture/captagent/wiki/Installation)
26 |
27 | -------------
28 |
29 | ### Support
30 | If you found a bug or issue with the code, please raise an Issue on the project tracker.
31 |
32 | If you want to send a PR, please make sure to indent your code using our [format script](https://github.com/sipcapture/captagent/blob/dev/format_code.sh)
33 |
34 | If you have specific questions or require professional support please contact us at support@sipcapture.org
35 |
36 | 
37 |
38 |
39 | ### Developers
40 | Contributions to our project are always welcome! If you intend to participate and help us improve CAPTAGENT, we kindly ask you to sign a [CLA (Contributor License Agreement)](http://cla.qxip.net) and coordinate at best with the existing team via the [homer-dev](http://groups.google.com/group/homer-dev) mailing list.
41 |
42 |
43 | ----------
44 |
45 | ##### If you use CAPTAGENT in production, please consider supporting us with a [donation](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=donation%40sipcapture%2eorg&lc=US&item_name=SIPCAPTURE&no_note=0¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest)
46 |
47 | [](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=donation%40sipcapture%2eorg&lc=US&item_name=SIPCAPTURE&no_note=0¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest)
48 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | echo "You need to have m4, automake, autoconf, libtool...";
4 | #aclocal
5 |
6 | list_of_config_files="./src/modules";
7 | #
8 | list_of_config_files_pro="./src/modules_pro";
9 |
10 | #echo adding modules
11 | #for file in $list_of_config_files; do
12 | # echo "AC_CONFIG_FILES([${list_of_config_files}/${file}])"
13 | #done > modules_makefiles.m4
14 |
15 | autoreconf --force --install
16 | automake --add-missing
17 | autoconf
18 |
--------------------------------------------------------------------------------
/captagent/conf/captagent.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
48 |
49 |
50 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
65 |
66 |
67 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/common.am:
--------------------------------------------------------------------------------
1 | DISTCLEANFILES = \
2 | INSTALL \
3 | Makefile \
4 | Makefile.in \
5 | configure \
6 | config \
7 | aclocal.m4 \
8 | config.guess \
9 | config.h.in \
10 | config.h.in~ \
11 | config.log \
12 | config.status \
13 | config.sub \
14 | depcomp \
15 | install-sh \
16 | ltmain.sh \
17 | missing \
18 | capplan.tab.h \
19 | capplan.tab.c \
20 | capplan.c \
21 | m4/libtool.m4 \
22 | m4/lt~obsolete.m4 \
23 | m4/ltoptions.m4 \
24 | m4/ltsugar.m4 \
25 | m4/ltversion.m4 \
26 | ylwrap
27 |
28 | SUFFIXES = .c .h .y .l
29 | AM_YFLAGS = -d
30 | AM_LFLAGS = -i
31 |
--------------------------------------------------------------------------------
/conf/captagent.xml.in:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
34 |
35 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/conf/captureplans/diameter_capture_plan.cfg:
--------------------------------------------------------------------------------
1 | capture[pcap] {
2 |
3 | # here we can check source/destination IP/port, message size
4 | if(msg_check("size", "100")) {
5 |
6 | # parse the packet, check if is Diameter and make a json output
7 | if(parse_diameter_to_json()) {
8 | if(!send_hep("hepsocket")) {
9 | clog("ERROR", "Error sending !!!!");
10 | }
11 | } else {
12 | clog("ERROR", "couldn't parse DIAMETER to json");
13 | }
14 | } else {
15 | clog("ERROR", "This is not DIAMETER");
16 | }
17 | drop;
18 | }
19 |
--------------------------------------------------------------------------------
/conf/captureplans/isup_capture_plan.cfg:
--------------------------------------------------------------------------------
1 | capture[pcap] {
2 |
3 | # here we can check source/destination IP/port, message size
4 | if(parse_isup_to_json()) {
5 | #Can be defined many profiles in transport_hep.xml
6 | if(!send_hep("hepsocket")) {
7 | clog("ERROR", "Error sending HEP!!!!");
8 | }
9 | }
10 | drop;
11 | }
12 |
--------------------------------------------------------------------------------
/conf/captureplans/rtcp_capture_plan.cfg:
--------------------------------------------------------------------------------
1 | capture[pcap] {
2 |
3 | # here we can check source/destination IP/port, message size
4 | if(msg_check("size", "30")) {
5 |
6 | #Check for correct version
7 | if(is_rtcp()) {
8 | #Only for redis!
9 |
10 | if(is_rtcp_exist()) {
11 |
12 | #Convert to JSON if needed.
13 | if(parse_rtcp_to_json()) {
14 |
15 | #Can be defined many profiles in transport_hep.xml
16 | if(!send_hep("hepsocket")) {
17 | clog("ERROR", "Error sending HEP!!!!");
18 | }
19 |
20 | } else {
21 | clog("ERROR", "couldn't parse RTCP to json");
22 | }
23 |
24 | } else {
25 | clog("ERROR", "Couldnot find this call");
26 | }
27 | } else {
28 | clog("ERROR", "This is not RTCP");
29 | }
30 | }
31 | drop;
32 | }
33 |
--------------------------------------------------------------------------------
/conf/captureplans/rtcpxr_capture_plan.cfg:
--------------------------------------------------------------------------------
1 | capture[collector] {
2 |
3 | # here we can check source/destination IP/port, message size
4 | if(msg_check("size", "10")) {
5 |
6 | # check if pkt is rtcp-xr
7 | if(is_rtcpxr()) {
8 |
9 | # if yes, parse the field and make a json output
10 | if(parse_rtcpxr_to_json()) {
11 |
12 | if(!send_hep("hepsocket")) {
13 | clog("ERROR", "Error sending !!!!");
14 | }
15 | } else {
16 | clog("ERROR", "couldn't parse RTCP-XR to json");
17 | }
18 | } else {
19 | clog("ERROR", "This is not RTCP-RX");
20 | }
21 |
22 | # Do parsing
23 | if(parse_full_sip()) {
24 |
25 | #check if our methos is PUBLISH
26 | if(sip_is_method() && sip_check("method","PUBLISH")) {
27 |
28 | # Currently we send reply automaticaly
29 | # send_rtcpxr_reply("200", "OK");
30 |
31 | # Can be defined many profiles in transport_hep.xml
32 |
33 | if(!send_hep_proto("hepsocket", "99")) {
34 | clog("ERROR", "Error sending HEP!!!!");
35 | }
36 |
37 | } else {
38 | send_reply("503", "Server internal error");
39 | }
40 | }
41 | }
42 | drop;
43 | }
44 |
--------------------------------------------------------------------------------
/conf/captureplans/sip_capture_plan.cfg:
--------------------------------------------------------------------------------
1 | capture[pcap] {
2 |
3 | # here we can check source/destination IP/port, message size
4 | if(msg_check("size", "100")) {
5 |
6 | #Do parsing
7 | if(parse_sip()) {
8 | #Can be defined many profiles in transport_hep.xml
9 |
10 | if(!send_hep("hepsocket")) {
11 | clog("ERROR", "Error sending HEP!!!!");
12 | }
13 |
14 | if(sip_has_sdp())
15 | {
16 | #Activate it for RTCP checks
17 | if(!check_rtcp_ipport())
18 | {
19 | clog("ERROR", "ALREADY EXIST");
20 | }
21 | }
22 |
23 | #Duplicate all INVITEs to JSON transport
24 | # if(sip_is_method() && sip_check("method","INVITE")) {
25 | # #Can be defined many profiles in transport_json.xml
26 | # if(!send_json("jsonsocket")) {
27 | # clog("ERROR", "Error sending JSON!!!");
28 | # }
29 | # }
30 | }
31 | }
32 | drop;
33 | }
34 |
--------------------------------------------------------------------------------
/conf/captureplans/tls_capture_plan.cfg:
--------------------------------------------------------------------------------
1 | capture[pcap] {
2 |
3 | # check minimum message size
4 | if(msg_check("size", "10")) {
5 |
6 | # attempt TLS parsing
7 | if(parse_tls()) {
8 |
9 | # attempt SIP parsing
10 | if(parse_sip()) {
11 |
12 | # Send using a profile defined in transport_hep.xml
13 | if(!send_hep("hepsocket")) {
14 | clog("ERROR", "Error sending HEP!!!!");
15 | }
16 | # attempt SDP parsing
17 | if(sip_has_sdp())
18 | {
19 | #Activate it for RTCP checks
20 | if(!check_rtcp_ipport())
21 | {
22 | clog("ERROR", "Duplicate SDP Session!");
23 | }
24 | }
25 |
26 | } else {
27 | clog("ERROR", "Error parsing SIP!!!!");
28 | drop;
29 | }
30 |
31 | } else {
32 | clog("ERROR", "Error parsing TLS!!!!");
33 | drop;
34 | }
35 | }
36 | drop;
37 | }
38 |
--------------------------------------------------------------------------------
/conf/captureplans/tzsp_capture_plan.cfg:
--------------------------------------------------------------------------------
1 | capture[tzsp] {
2 |
3 | # here we can check source/destination IP/port, message size
4 | if(msg_check("size", "100")) {
5 |
6 | #Do parsing
7 | if(tzsp_payload_extract()) {
8 |
9 | #check if the message is sip
10 | if(parse_sip()) {
11 |
12 | if(!send_hep("hepsocket")) {
13 | clog("ERROR", "Error sending HEP!!!!");
14 | }
15 | }
16 | }
17 | }
18 | drop;
19 | }
20 |
--------------------------------------------------------------------------------
/conf/database_hash.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/conf/database_redis.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/conf/output_json.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/conf/protocol_diameter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/conf/protocol_rtcp.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/conf/protocol_rtcpxr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/conf/protocol_sip.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/conf/protocol_ss7.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/conf/protocol_tls.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/conf/socket_collector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/conf/socket_pcap.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | port 5060
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | portrange 8000-30000 and len >=64
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | tcp port 5061
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | proto 132
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | port 3868
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/conf/socket_tzsp.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/conf/transport_hep.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/format_code.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | ### You need to install indent
4 | echo "indent file $1..."
5 | indent -linux -l200 -i4 -nut "$1"
6 | echo "format done"
7 |
--------------------------------------------------------------------------------
/fuzzing/build-captagent-clang-address.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #mkdir -p work
4 | #cd work
5 | #rm -rf captagent
6 | #cp ../src/captagent.zip .
7 | #unzip -P 'XXX' captagent.zip
8 | #rm captagent.zip
9 | cd ../../
10 | ./build.sh
11 |
12 | export CFLAGS="-g -O0 -fsanitize=address -fprofile-instr-generate -fcoverage-mapping"
13 | export CC="clang"
14 | CC=clang CFLAGS="-g -O0 -fsanitize=address -fprofile-instr-generate -fcoverage-mapping" ./configure \
15 | --enable-tls --enable-ssl
16 |
17 | find . -type f -print0 | xargs -0 sed -i 's/static volatile/static volatile/g'
18 |
19 | make CFLAGS="-g -O0 -fsanitize=address -fprofile-instr-generate -fcoverage-mapping"
20 |
21 | #export DESTDIR="`pwd`/debug-build"
22 | make install
23 |
--------------------------------------------------------------------------------
/fuzzing/build-captagent-clang.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | mkdir -p work
4 | cd work
5 | rm -rf captagent
6 | cp ../src/captagent.zip .
7 | unzip -P 'XXX' captagent.zip
8 | rm captagent.zip
9 | cd captagent
10 | ./build.sh
11 |
12 | export CFLAGS="-g -O0 -fprofile-instr-generate -fcoverage-mapping"
13 | export CC="clang"
14 | CC=clang CFLAGS="-g -O0 -fprofile-instr-generate -fcoverage-mapping" ./configure \
15 | --enable-tls --enable-ssl
16 |
17 | find . -type f -print0 | xargs -0 sed -i 's/static volatile/static volatile/g'
18 |
19 | make CFLAGS="-g -O0 -fprofile-instr-generate -fcoverage-mapping"
20 |
21 | export DESTDIR="`pwd`/debug-build"
22 | make install
23 |
--------------------------------------------------------------------------------
/fuzzing/build-captagent-gcc.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | mkdir -p work
4 | cd work
5 | rm -rf captagent
6 | cp ../src/captagent.zip .
7 | unzip -P 'XXX' captagent.zip
8 | cd captagent
9 | ./build.sh
10 | ./configure --enable-ssl --enable-tls
11 | make
12 |
13 | export DESTDIR="`pwd`/debug-build"
14 | make install
15 |
--------------------------------------------------------------------------------
/fuzzing/fuzz_test/RTCP_CRASH/rtcp_cr.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | CAPTAGENT="../../../../captagent"
4 |
5 | clang -fsanitize=address \
6 | -o $CAPTAGENT/test/fuzzing/fuzz_test/RTCP_CRASH/rtcp_crash \
7 | -g -O0 -w -I$CAPAGENT/include \
8 | -I$CAPTAGENT/src \
9 | -I$CAPTAGENT/src/modules/protocol/rtcp \
10 | `find $CAPTAGENT/src/ -maxdepth 1 -name "*.c" ! -name 'captagent.c'` \
11 | `find $CAPTAGENT/src/modules/protocol/rtcp -maxdepth 1 -name "*.c"` \
12 | -ljson-c -lpcap -lexpat -ldl -lpthread -lfl -luv -lm -lcrypto -lpcre
13 |
--------------------------------------------------------------------------------
/fuzzing/fuzz_test/RTCP_CRASH/rtcp_crash.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include "md5.h"
11 | #include
12 | #include "captagent.h"
13 | #include "config.h"
14 | #include "modules/protocol/rtcp/parser_rtcp.h"
15 |
16 | int cfg_errors = 0;
17 | int debug = 0;
18 | struct capture_list main_ct;
19 | char *module_name_p = "";
20 | char *global_node_name = NULL;
21 | char *global_config_path = NULL;
22 | int print_lic_exit = 0;
23 | char *global_license = NULL;
24 | int not_send = 0;
25 | int flag_Lic = -1; // License: 1 = activate; 0 = deactivate
26 | int type_Lic = 1;
27 | int count_big_down_jump = 0;
28 | char *usefile = NULL;
29 | unsigned long expireLicTime = 0;
30 | int flag_is_lic_count_wrong = 0;
31 | char hwk[33];
32 | int flag_is_expire = 0;
33 | int flag_is_invalid = 0;
34 | int bytes_parsed = 0;
35 |
36 | int main()
37 | {
38 | /* MALFORMED RTCP RR PKT */
39 | // Correct pkt is 4 byte header + 4 bytes SSRC + 24 byte for every Report count (if exist)
40 | // in this case count == 1 (first byte 0x81)
41 | char rr[29] = {
42 | 0x81, 0xc9, 0x00, 0x07, 0x54, 0xf2, 0x00, 0x01,
43 | 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x81,
44 | 0xc9, 0x00, 0x07, 0x00, 0x00, 0x00, 0x01, 0x00,
45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
46 | };
47 |
48 | /* MALFORMED RTCP SR PKT */
49 | // Correct pkt is 4 byte header + 4 byte SSRC + 20 byte for sender info + 24 byte for every Report count (if exist)
50 | char sr[25] = {
51 | 0x80, 0xc8, 0x00, 0x06, 0x22, 0xa1, 0x04, 0x02,
52 | 0x83, 0xab, 0x11, 0x03, 0xeb, 0x00, 0x01, 0x3a,
53 | 0x00, 0x00, 0x94, 0x20, 0x00, 0x00, 0x00, 0xfb,
54 | 0x10,
55 | };
56 |
57 |
58 | char *json_rtcp_buffer;
59 | int ret, len;
60 |
61 | len = sizeof(sr);
62 | json_rtcp_buffer = calloc(5000, sizeof(char));
63 | ret = capt_parse_rtcp(&sr, len, json_rtcp_buffer, 5000);
64 | if(ret == -1 || ret == -2) {
65 | printf("capt_parse_rtcp :: error!\n");
66 | } else {
67 | printf("capt_parse_rtcp :: parsing correct\n");
68 | }
69 | if(json_rtcp_buffer) free(json_rtcp_buffer);
70 |
71 | printf("!!! IF WE ARE HERE NO CRASH DETECTED IN MEMORY !!!")
72 | return 0;
73 | }
74 |
--------------------------------------------------------------------------------
/fuzzing/fuzz_test/RTCP_TO_JSON_CRASH/rtcp_capture_plan.cfg:
--------------------------------------------------------------------------------
1 | capture[pcap] {
2 | if(msg_check("size","4")) {
3 | if(is_rtcp_or_rtp()) {
4 | if(is_flag_set("1","1")) {
5 | drop;
6 | } else {
7 | parse_rtcp_to_json();
8 | check_rtcp_session("hep","rtpsocket");
9 | drop;
10 | }
11 | drop;
12 | }
13 | drop;
14 | }
15 | drop;
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/fuzzing/fuzz_test/RTCP_TO_JSON_CRASH/rtcp_crash.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import(
4 | "net"
5 | )
6 |
7 | func main() {
8 | dat := []byte{
9 | 0x81,0xc9,0x00,0x07,0x00,0x00,0x00,0x01,0x00,
10 | 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,
11 | 0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
12 | 0x00,0x00,0x00,0x00,0x00}
13 |
14 | conn, _ := net.Dial("udp","127.0.0.1:9000")
15 |
16 | for i := 1; i < 50; i++ {
17 | conn.Write(dat)
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/fuzzing/run-captagent.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | rm -f *.profraw
4 | rm -f *.profdata
5 |
6 | coverage="coverage/"
7 | if [ "$2" != "" ]; then
8 | coverage="$2"
9 | fi
10 |
11 | rm -rf $coverage
12 | mkdir -p $coverage
13 | mkdir -p $coverage/line
14 | mkdir -p $coverage/source
15 | mkdir -p $coverage/functions
16 | LLVM_PROFILE_FILE="prof%p.profraw" \
17 | work/captagent/debug-build/usr/local/captagent/sbin/captagent \
18 | -f captagent-config/$1/captagent.xml
19 | llvm-profdata merge -sparse *.profraw -o captagent.profdata
20 |
21 | llvm-cov show work/captagent/debug-build/usr/local/captagent/sbin/captagent -instr-profile=captagent.profdata > $coverage/line/captagent-lines.txt
22 | for f in work/captagent/debug-build/usr/local/captagent/lib/captpagent/modules/*.so;
23 | do
24 | llvm-cov show $f -instr-profile=captagent.profdata > $coverage/line/`basename $f`-lines.txt
25 | done
26 |
27 | llvm-cov report work/captagent/debug-build/usr/local/captagent/sbin/captagent -instr-profile=captagent.profdata > $coverage/source/captagent-source.txt
28 | for f in work/captagent/debug-build/usr/local/captagent/lib/captagent/modules/*.so;
29 | do
30 | llvm-cov report $f -instr-profile=captagent.profdata > $coverage/source/`basename $f`-source.txt
31 | done
32 |
33 | llvm-cov report work/captagent/debug-build/usr/local/captagent/sbin/captagent -show-functions=true --instr-profile=captagent.profdata work/captagent
34 | for f in work/captagent/debug-build/usr/local/captagent/lib/captagent/modules/*.so;
35 | do
36 | llvm-cov report $f -show-functions=true -instr-profile=captagent.profdata work/captagent/ > $coverage/functions/`basename $f`-functions.txt
37 | done
38 |
39 | # rm -f *.profraw *.profdata
40 | chown root.root coverage
41 | chown root.root $coverage/*
42 |
--------------------------------------------------------------------------------
/hep-tester/README:
--------------------------------------------------------------------------------
1 | small tools that help you test hep packets
2 |
--------------------------------------------------------------------------------
/hep-tester/heptester.h:
--------------------------------------------------------------------------------
1 | #define VERSION "0.0.1"
2 |
3 | /* filter to extract SIP packets */
4 | char filter_expr[1024];
5 |
6 | /* Ethernet / IP / UDP header IPv4 */
7 | const int udp_payload_offset = 14+20+8;
8 |
9 | struct ethhdr_vlan {
10 | unsigned char h_dest[6];
11 | unsigned char h_source[6];
12 | uint16_t type; /* vlan type*/
13 | uint16_t ptt; /* priority */
14 | uint16_t h_proto;
15 | };
16 |
17 |
18 | #ifndef IP_OFFMASK
19 | #define IP_OFFMASK 0x1fff
20 | #endif
21 |
22 | #define PROTO_SIP 0x01
23 |
24 | /* FreeBSD or Solaris */
25 | #ifndef ETH_P_IP
26 | #define ETH_P_IP 0x0800
27 | struct ethhdr {
28 | unsigned char h_dest[6];
29 | unsigned char h_source[6];
30 | uint16_t h_proto;
31 | };
32 | #endif
33 |
34 | /* header offsets */
35 | #define ETHHDR_SIZE 14
36 | #define TOKENRING_SIZE 22
37 | #define PPPHDR_SIZE 4
38 | #define SLIPHDR_SIZE 16
39 | #define RAWHDR_SIZE 0
40 | #define LOOPHDR_SIZE 4
41 | #define FDDIHDR_SIZE 21
42 | #define ISDNHDR_SIZE 16
43 | #define IEEE80211HDR_SIZE 32
44 |
45 |
46 | /* functions */
47 | void callback_proto(u_char *useless, struct pcap_pkthdr *pkthdr, u_char *packet);
48 | int dump_proto_packet(struct pcap_pkthdr *pkthdr, u_char *packet, uint8_t proto, unsigned char *data, uint32_t len,
49 | const char *ip_src, const char *ip_dst, uint16_t sport, uint16_t dport, uint8_t flags,
50 | uint16_t hdr_offset, uint8_t frag, uint16_t frag_offset, uint32_t frag_id, uint32_t ip_ver);
--------------------------------------------------------------------------------
/include/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/common.am
2 |
3 | noinst_HEADERS = \
4 | captagent/action.h \
5 | captagent/api.h \
6 | captagent/capture.h \
7 | captagent/export_function.h \
8 | captagent/globals.h \
9 | captagent/log.h \
10 | captagent/md5.h \
11 | captagent/modules_api.h \
12 | captagent/modules.h \
13 | captagent/proto_sip.h \
14 | captagent/structure.h \
15 | captagent/xmlread.h
16 |
--------------------------------------------------------------------------------
/include/captagent/action.h:
--------------------------------------------------------------------------------
1 | #ifndef action_h
2 | #define action_h
3 |
4 |
5 | struct action{
6 | int type; /* forward, drop, log, send ...*/
7 | int index;
8 | int p1_type;
9 | int p2_type;
10 | int p3_type;
11 | union {
12 | int number;
13 | char* string;
14 | void* data;
15 | }p1, p2, p3;
16 | struct action* next;
17 | };
18 |
19 |
20 | struct run_act_ctx{
21 | int route_rec_lev;
22 | int rec_lev;
23 | int run_flags;
24 | int last_retcode; /* return from last route */
25 | };
26 |
27 | int do_action(struct run_act_ctx* c, struct action* a, msg_t *msg);
28 | int run_actions(struct run_act_ctx* c, struct action* a, msg_t* msg);
29 |
30 | #endif
31 |
32 |
--------------------------------------------------------------------------------
/include/captagent/api.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or
11 | * modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 3 of the License, or
14 | * (at your option) any later version
15 | *
16 | * Homer capture agent is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | *
25 | */
26 |
27 | #ifndef API_H_
28 | #define API_H_
29 |
30 |
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 | #include
43 |
44 | #include "config.h"
45 |
46 | #ifdef __GNUC__
47 | /* GNU C */
48 | #define PACK_OFF __attribute__ ((__packed__));
49 | #else
50 | #define PACK_OFF
51 | #endif
52 |
53 | #ifndef AGENT_CONFIG_DIR
54 | #define AGENT_CONFIG_DIR "/usr/local/etc/captagent/"
55 | #endif //DEF_CONF
56 |
57 | #ifndef AGENT_PLAN_DIR
58 | #define AGENT_PLAN_DIR "/usr/local/etc/captagent/captureplans"
59 | #endif
60 |
61 |
62 | #ifdef OS_LINUX
63 | #include
64 | #endif /* OS_LINUX */
65 |
66 | typedef struct xml_node {
67 | char *key;
68 | char *value;
69 | char **attr;
70 | struct xml_node *child;
71 | struct xml_node *parent;
72 | struct xml_node *next;
73 | } xml_node;
74 |
75 | typedef struct _str {
76 | char* s;
77 | int len;
78 | } str;
79 |
80 | typedef struct _str_static {
81 | char s[128];
82 | int len;
83 | } str_static;
84 |
85 | struct rc_info {
86 | uint8_t ip_family; /* IP family IPv6 IPv4 */
87 | uint8_t ip_proto; /* IP protocol ID : tcp/udp */
88 | uint8_t proto_type; /* SIP: 0x001, SDP: 0x03*/
89 | char *src_mac;
90 | char *dst_mac;
91 | char *src_ip;
92 | char *dst_ip;
93 | uint16_t src_port;
94 | uint16_t dst_port;
95 | uint32_t time_sec;
96 | uint32_t time_usec;
97 | uint32_t liid;
98 | uint32_t cval1;
99 | uint32_t cval2;
100 | uint16_t sessionid;
101 | uint8_t direction;
102 | char *uuid;
103 | str correlation_id;
104 | str_static tags;
105 | int *socket;
106 | } ;
107 |
108 | typedef struct rc_info rc_info_t;
109 |
110 |
111 | typedef enum msg_body_type {
112 | MSG_BODY_UNKNOWN = 0,
113 | MSG_BODY_SDP
114 | } msg_body_type_t;
115 |
116 |
117 | typedef struct stats_object {
118 | unsigned int total_req;
119 | unsigned int curr_req;
120 | unsigned int total_x2;
121 | unsigned int failed_x2;
122 | unsigned long total_x3;
123 | unsigned long failed_x3;
124 | unsigned int curr_calls;
125 | unsigned int total_calls;
126 | } stats_object_t;
127 |
128 | extern struct stats_object stats_obj;
129 |
130 | extern int get_basestat(char *module, char *stats, size_t len);
131 | extern struct module *module_list;
132 |
133 | #ifndef TRUE
134 | #define TRUE 1
135 | #endif /* TRUE */
136 |
137 | #ifndef FALSE
138 | #define FALSE 0
139 | #endif /* FALSE */
140 |
141 | typedef enum {
142 | DB_INT, /* Integer number */
143 | DB_DOUBLE, /* Decimal number */
144 | DB_STRING, /* String */
145 | DB_STR, /* str structure */
146 | DB_DATETIME, /* Date and time */
147 | DB_BLOB /* Binary large object */
148 | } db_type_t;
149 |
150 |
151 | typedef struct db_value {
152 | str key;
153 | db_type_t type; /* Type of the value */
154 | int nul; /* NULL flag */
155 | union {
156 | int int_val; /* Integer value */
157 | double double_val; /* Double value */
158 | time_t time_val; /* Unix time_t value */
159 | const char* string_val; /* Zero terminated string */
160 | str str_val; /* str structure */
161 | str blob_val; /* Structure describing blob */
162 | } val;
163 | } db_value_t;
164 |
165 |
166 | #define SAFE_FREE(pt) \
167 | assert(pt!=NULL); \
168 | free(pt); \
169 | pt = NULL;
170 |
171 | #define SAFE_PTR(pt) assert(pt!=NULL); pt
172 |
173 | #endif /* API_H_ */
174 |
--------------------------------------------------------------------------------
/include/captagent/capture.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #ifndef CAPTURE_H_
27 | #define CAPTURE_H_
28 |
29 | struct capture_list{
30 | struct action* clist[20];
31 | int idx;
32 | int entries;
33 | char names[20][100];
34 | };
35 |
36 | #define FILTER_LEN 4080
37 |
38 | /* our payload range between 0 - 191 */
39 | #define RTP_FILTER "(ip and ip[6] & 0x2 = 0 and ip[6:2] & 0x1fff = 0 and udp and udp[8] & 0xc0 = 0x80 )"
40 | /* our payload range between 200 and 204 */
41 | #define RTCP_FILTER "(ip and ip[6] & 0x2 = 0 and ip[6:2] & 0x1fff = 0 and udp and udp[8] & 0xc0 = 0x80 and udp[9] >= 0xc8 && udp[9] <= 0xcc)"
42 | /* IP-to-IP encapsulation filter // check portrange 5060-5090 */
43 | #define IP_IP_FILTER "(ip[9]=0x04 and ((ip[40:2]>=0x13c4 and ip[40:2]<=0x13e2) or (ip[42:2]>=0x13c4 and ip[42:2]<=0x13e2)))"
44 |
45 | #endif /* CAPTURE_H_ */
46 |
--------------------------------------------------------------------------------
/include/captagent/export_function.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or
11 | * modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 3 of the License, or
14 | * (at your option) any later version
15 | *
16 | * Homer capture agent is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | *
25 | */
26 |
27 | #ifndef EXPORT_FUNC_H_
28 | #define EXPORT_FUNC_H_
29 |
30 | /* new */
31 | cmd_function find_export(char* name, int param_no, int flags);
32 | cmd_export_t* find_mod_export_record(char* mod, char* name, int param_no, int flags, unsigned* mod_if_ver);
33 | cmd_export_t* find_export_record(char* name, int param_no, int flags, unsigned* mod_if_ver);
34 |
35 |
36 | #endif /* EXPORT_FUNC_H_ */
37 |
--------------------------------------------------------------------------------
/include/captagent/globals.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or
11 | * modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 3 of the License, or
14 | * (at your option) any later version
15 | *
16 | * Homer capture agent is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | *
25 | */
26 |
27 | #ifndef GLOBALS_H_
28 | #define GLOBALS_H_
29 |
30 | #define CT_NO 10 /* capture tables number */
31 | #define DEFAULT_CT 0 /* default capture table */
32 |
33 | #ifndef NULL
34 | #define NULL ((void *)0)
35 | #endif
36 |
37 | extern int cfg_errors;
38 |
39 | extern int debug;
40 | extern int nofork;
41 | extern int foreground;
42 | extern int debug_level;
43 | extern char *usefile;
44 | extern char *global_license;
45 | extern char *global_chroot;
46 | extern char *global_config_path;
47 | extern char *global_capture_plan_path;
48 | extern char *global_uuid;
49 | extern char *backup_dir;
50 | extern char *global_node_name;
51 | extern int timestart;
52 | extern int serial;
53 | extern const char *captagent_config;
54 |
55 | extern struct capture_list main_ct;
56 |
57 | extern struct action* clist[20];
58 |
59 | #endif /* GLOBALS_H_ */
60 |
--------------------------------------------------------------------------------
/include/captagent/log.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or
11 | * modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 3 of the License, or
14 | * (at your option) any later version
15 | *
16 | * Homer capture agent is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | *
25 | */
26 |
27 | #ifndef LOG_H_
28 | #define LOG_H_
29 |
30 | #include
31 |
32 | void init_log(char *_prgname, int _use_syslog);
33 |
34 | void set_log_level(int level);
35 |
36 | void destroy_log(void);
37 |
38 | void data_log(int priority, const char * fmt, ...);
39 |
40 | #define PA_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)));
41 |
42 | #define LEMERG(fmt, args...) data_log(LOG_EMERG, "[DEBUG] %s:%d " fmt, __FILE__, __LINE__, ## args)
43 | #define LALERT(fmt, args...) data_log(LOG_ALERT, "[ALERT] %s:%d " fmt, __FILE__, __LINE__, ## args)
44 | #define LCRIT(fmt, args...) data_log(LOG_CRIT, "[CRIT] %s:%d " fmt, __FILE__, __LINE__, ## args)
45 | #define LERR(fmt, args...) data_log(LOG_ERR, "[ERR] %s:%d " fmt, __FILE__, __LINE__, ## args)
46 | #define LWARNING(fmt, args...) data_log(LOG_WARNING, "[WARNING] %s:%d " fmt, __FILE__, __LINE__, ## args)
47 | #define LNOTICE(fmt, args...) data_log(LOG_NOTICE, "[NOTICE] " fmt, ## args)
48 | #define LINFO(fmt, args...) data_log(LOG_INFO, "[INFO] %s:%d " fmt, __FILE__, __LINE__, ## args)
49 | #define LDEBUG(fmt, args...) data_log(LOG_DEBUG, "[DEBUG] %s:%d " fmt, __FILE__, __LINE__, ## args)
50 | #define LMESSAGE(fmt, args...) data_log(LOG_ERR, "[MESSAGE] " fmt, ## args)
51 |
52 | #endif /* LOG_H_ */
53 |
--------------------------------------------------------------------------------
/include/captagent/md5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or
11 | * modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 3 of the License, or
14 | * (at your option) any later version
15 | *
16 | * Homer capture agent is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | *
25 | */
26 |
27 | #ifndef MD5_H_
28 | #define MD5_H_
29 |
30 | /*
31 | * This an amalgamation of md5.c and md5.h into a single file
32 | * with all static declaration to reduce linker conflicts
33 | * in Civetweb.
34 | *
35 | * The MD5_STATIC declaration was added to facilitate static
36 | * inclusion.
37 | * No Face Press, LLC
38 | */
39 |
40 | /* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
41 | /*
42 | Independent implementation of MD5 (RFC 1321).
43 |
44 | This code implements the MD5 Algorithm defined in RFC 1321, whose
45 | text is available at
46 | http://www.ietf.org/rfc/rfc1321.txt
47 | The code is derived from the text of the RFC, including the test suite
48 | (section A.5) but excluding the rest of Appendix A. It does not include
49 | any code or documentation that is identified in the RFC as being
50 | copyrighted.
51 |
52 | The original and principal author of md5.h is L. Peter Deutsch
53 | . Other authors are noted in the change history
54 | that follows (in reverse chronological order):
55 |
56 | 2002-04-13 lpd Removed support for non-ANSI compilers; removed
57 | references to Ghostscript; clarified derivation from RFC 1321;
58 | now handles byte order either statically or dynamically.
59 | 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
60 | 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
61 | added conditionalization for C++ compilation from Martin
62 | Purschke .
63 | 1999-05-03 lpd Original version.
64 | */
65 |
66 | /*
67 | * This package supports both compile-time and run-time determination of CPU
68 | * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
69 | * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
70 | * defined as non-zero, the code will be compiled to run only on big-endian
71 | * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
72 | * run on either big- or little-endian CPUs, but will run slightly less
73 | * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
74 | */
75 |
76 | typedef unsigned char md5_byte_t; /* 8-bit byte */
77 | typedef unsigned int md5_word_t; /* 32-bit word */
78 |
79 | /* Define the state of the MD5 Algorithm. */
80 | typedef struct md5_state_s {
81 | md5_word_t count[2]; /* message length in bits, lsw first */
82 | md5_word_t abcd[4]; /* digest buffer */
83 | md5_byte_t buf[64]; /* accumulate block */
84 | } md5_state_t;
85 |
86 | /* Initialize the algorithm. */
87 | void md5_init(md5_state_t *pms);
88 |
89 | /* Append a string to the message. */
90 | void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
91 |
92 | /* Finish the message and return the digest. */
93 | void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
94 |
95 | #endif /* MD5_H_ */
96 |
--------------------------------------------------------------------------------
/include/captagent/modules.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or
11 | * modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 3 of the License, or
14 | * (at your option) any later version
15 | *
16 | * Homer capture agent is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | *
25 | */
26 |
27 | #ifndef MODULES_H_
28 | #define MODULES_H_
29 |
30 | extern char *module_path;
31 |
32 | #define VAR_PARAM_NO -128
33 |
34 | struct rc_info;
35 |
36 | typedef struct hep_module {
37 | int (*send_hep_basic)(struct rc_info *rcinfo, unsigned char *data, unsigned int len);
38 | int (*send_hep_advance)(void);
39 | } hep_module_t;
40 |
41 |
42 | typedef int (*init_function)(xml_node *config);
43 | typedef int (*destroy_function)(void);
44 | typedef int (*description_function)(char *descr);
45 | typedef int (*statistic_function)(char *stats, size_t len);
46 | typedef void (*onbreak_function)(msg_t* msg);
47 | typedef uint64_t (*serial_function)(void);
48 |
49 | typedef struct module {
50 | init_function load_f;
51 | destroy_function unload_f;
52 | description_function description_f;
53 | statistic_function stats_f;
54 | serial_function serial_f;
55 | onbreak_function onbreak_f;
56 | cmd_export_t* cmds;
57 | void *lib;
58 | char *path;
59 | char name[256];
60 | struct module *next;
61 | } module_t;
62 |
63 | typedef struct module_exports {
64 | char* name;
65 | cmd_export_t* cmds;
66 | init_function load_f;
67 | destroy_function unload_f;
68 | description_function description_f;
69 | statistic_function stats_f;
70 | serial_function serial_f;
71 | onbreak_function onbreak_f;
72 |
73 | char** param_names; /* parameter names registered by this modules */
74 | char** cmd_names; /* cmd names registered by this modules */
75 | int cmd_no; /* number of registered commands */
76 | int par_no; /* number of registered parameters */
77 | int* param_no; /* number of parameters used*/
78 | cmd_function* cmd_pointers; /* pointers to the corresponding functions */
79 | modparam_t* param_types; /* Type of parameters */
80 | void** param_pointers; /* Pointers to the corresponding memory locations */
81 |
82 | } module_exports_t;
83 |
84 |
85 | int register_module(char *resource_name, xml_node *config, bool global);
86 | int register_modules(xml_node *tree);
87 | int unregister_modules(void);
88 | int usecount(void);
89 | /* How many channels provided by this module are in use? */
90 | //char *description(void); /* Description of this module */
91 | //int *statistic(char *stats, size_t len); /* Statistic of this module */
92 |
93 |
94 | #endif /* MODULES_H_ */
95 |
--------------------------------------------------------------------------------
/include/captagent/structure.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or
11 | * modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 3 of the License, or
14 | * (at your option) any later version
15 | *
16 | * Homer capture agent is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | *
25 | */
26 |
27 | #ifndef STRUCTURE_H_
28 | #define STRUCTURE_H_
29 |
30 | #include "proto_sip.h"
31 |
32 | typedef struct msg {
33 | void *data;
34 | char *profile_name;
35 | uint32_t len;
36 | uint16_t hdr_len;
37 | uint8_t tcpflag;
38 | uint32_t sctp_ppid;
39 | rc_info_t rcinfo;
40 | uint8_t parse_it;
41 | void *parsed_data;
42 | sip_msg_t sip;
43 | void *cap_packet;
44 | void *cap_header;
45 | void *var;
46 | char *corrdata;
47 | uint8_t mfree;
48 | int flag[10];
49 | } msg_t;
50 |
51 | typedef struct stats_msg {
52 | char *mod_name;
53 | uint32_t value;
54 | } stats_msg_t;
55 |
56 | typedef struct filter_msg {
57 | char *data;
58 | uint32_t value;
59 | } filter_msg_t;
60 |
61 |
62 | typedef struct db_msg {
63 | str key_name;
64 | str profile_name;
65 | uint16_t expire;
66 | uint32_t len;
67 | uint8_t batch;
68 | } db_msg_t;
69 |
70 |
71 |
72 | #endif /* STRUCTURE_H_ */
73 |
--------------------------------------------------------------------------------
/include/captagent/xmlread.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or
11 | * modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 3 of the License, or
14 | * (at your option) any later version
15 | *
16 | * Homer capture agent is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | *
25 | */
26 |
27 | #ifndef XMLREAD_H_
28 | #define XMLREAD_H_
29 |
30 |
31 | xml_node *xml_parse( const char *filename );
32 | int xml_parse_with_report(const char *filename, char *erbuf, int erlen);
33 | xml_node *xml_get( const char *key, xml_node *ref, int recurs );
34 | xml_node *xml_node_str(char *str, int len);
35 | void xml_free(xml_node *node);
36 |
37 | #define BUFSIZE 8192
38 |
39 | #endif /* XMLREAD_H_ */
40 |
--------------------------------------------------------------------------------
/init/deb/debian/captagent.default:
--------------------------------------------------------------------------------
1 | #
2 | # Captagent startup options
3 | #
4 |
5 | # Set to yes to enable captagent, once configured properly.
6 | RUN_CAPTAGENT=yes
7 |
8 | # Config file
9 | CFGFILE=/usr/local/captagent/etc/captagent/captagent.xml
10 |
11 | # Enable the server to leave a core file when it crashes.
12 | # Set this to 'yes' to enable Captagent to leave a core file when it crashes
13 | # or 'no' to disable this feature. This option is case sensitive and only
14 | # accepts 'yes' and 'no' and only in lowercase letters.
15 | # On some systems it is necessary to specify a directory for the core files
16 | # to get a dump. Look into the captagent init file for an example configuration.
17 | #DUMP_CORE=yes
18 |
--------------------------------------------------------------------------------
/init/deb/debian/captagent.init:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | #
3 | ### BEGIN INIT INFO
4 | # Provides: captagent
5 | # Required-Start: $syslog $network $local_fs $remote_fs $time
6 | # Should-Start: $named slapd mysql postgresql snmpd radiusd
7 | # Should-Stop: $named slapd mysql postgresql snmpd radiusd
8 | # Required-Stop: $syslog $network $local_fs $remote_fs
9 | # Default-Start: 2 3 4 5
10 | # Default-Stop: 0 1 6
11 | # Short-Description: Start the Captagent
12 | # Description: Start the Captagent
13 | ### END INIT INFO
14 |
15 | . /lib/lsb/init-functions
16 |
17 | PATH=/sbin:/bin:/usr/sbin:/usr/bin
18 | DAEMON=/usr/local/captagent/sbin/captagent
19 | NAME=`basename "$0"`
20 | DESC="Captagent"
21 | HOMEDIR=/var/run/$NAME
22 | PIDFILE=/var/run/$NAME.pid
23 | DEFAULTS=/etc/default/$NAME
24 | CFGFILE=/usr/local/captagent/etc/captagent/captagent.xml
25 | RUN_CAPTAGENT=no
26 | USER=captagent
27 | GROUP=captagent
28 | DUMP_CORE=no
29 |
30 | test -f $DAEMON || exit 0
31 |
32 | # Load startup options if available
33 | if [ -f $DEFAULTS ]; then
34 | . $DEFAULTS || true
35 | fi
36 |
37 | if [ "$RUN_CAPTAGENT" != "yes" ]; then
38 | log_failure_msg "Captagent not yet configured. Edit /etc/default/$NAME first."
39 | exit 0
40 | fi
41 |
42 | set -e
43 |
44 | if test "$DUMP_CORE" = "yes" ; then
45 | # set proper ulimit
46 | ulimit -c unlimited
47 |
48 | # directory for the core dump files
49 | # COREDIR=/home/corefiles
50 | # [ -d $COREDIR ] || mkdir $COREDIR
51 | # chmod 777 $COREDIR
52 | # echo "$COREDIR/core.%e.sig%s.%p" > /proc/sys/kernel/core_pattern
53 | fi
54 |
55 | # /var/run can be a tmpfs
56 | if [ ! -d $HOMEDIR ]; then
57 | mkdir -p $HOMEDIR
58 | chown ${USER}:${GROUP} $HOMEDIR
59 | fi
60 |
61 | OPTIONS="-d -f $CFGFILE"
62 |
63 | case "$1" in
64 | start|debug)
65 |
66 | log_daemon_msg "Starting $DESC: $NAME"
67 | start-stop-daemon --start --quiet --pidfile $PIDFILE \
68 | --exec $DAEMON -- $OPTIONS || log_failure_msg " already running"
69 | log_end_msg 0
70 | ;;
71 | stop)
72 | log_daemon_msg "Stopping $DESC: $NAME"
73 | start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
74 | --exec $DAEMON
75 | log_end_msg 0
76 | ;;
77 | restart|force-reload)
78 |
79 | $0 stop
80 | sleep 1
81 | $0 start
82 | ;;
83 | status)
84 | log_daemon_msg "Status of $DESC: "
85 |
86 | status_of_proc -p"$PIDFILE" $NAME $NAME
87 | ;;
88 | *)
89 | N=/etc/init.d/$NAME
90 | echo "Usage: $N {start|stop|restart|force-reload|status|debug}" >&2
91 | exit 1
92 | ;;
93 | esac
94 |
95 | exit 0
96 |
--------------------------------------------------------------------------------
/init/deb/debian/captagent.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Captagent - monitoring system
3 | After=network.target
4 |
5 | [Service]
6 | Type=forking
7 | Environment='CFGFILE=/usr/local/captagent/etc/captagent/captagent.xml'
8 | EnvironmentFile=-/etc/default/captagent
9 | EnvironmentFile=-/etc/default/captagent.d/*
10 | # PIDFile requires a full absolute path
11 | PIDFile=/var/run/captagent.pid
12 | # ExecStart requires a full absolute path
13 | ExecStart=/usr/local/captagent/sbin/captagent -f $CFGFILE -d
14 | Restart=always
15 | KillSignal=SIGKILL
16 |
17 | [Install]
18 | WantedBy=multi-user.target
19 |
--------------------------------------------------------------------------------
/init/el/captagent.init:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Startup script for captagent
4 | #
5 | # chkconfig: 345 85 15
6 | # description: captagent - the Open Source Homer Capture Agent
7 | #
8 | # processname: captagent
9 | # pidfile: /var/run/captagent.pid
10 | # config: /usr/local/etc/captagent/captagent.xml
11 | #
12 | ### BEGIN INIT INFO
13 | # Provides: captagent
14 | # Required-Start: $local_fs $network
15 | # Short-Description: captagent - the Open Source Homer Capture Agent
16 | # Description: Homer captagent is an Open Source Capture Programm released
17 | # under GPLv3, able to handle thousands of call setups per second.
18 | ### END INIT INFO
19 |
20 | # Source function library.
21 | . /etc/rc.d/init.d/functions
22 |
23 | prog=captagent
24 | APP_FILE=/usr/local/captagent/sbin/$prog
25 | PID_FILE=/var/run/$prog.pid
26 | LOCK_FILE=/var/lock/subsys/$prog
27 | RETVAL=0
28 |
29 | [ -z "$CFG_FILE" ] && CFG_FILE=/usr/local/captagent/etc/captagent/captagent.xml
30 |
31 | OPTIONS="-f $CFG_FILE -d"
32 |
33 |
34 | [ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
35 |
36 | start() {
37 | if [ -e $PID_FILE ]; then
38 | echo "[FAILED] Captagent is already running with PID: `cat $PID_FILE`"
39 | else
40 | echo -n $"Starting $prog: "
41 | # there is something at end of this output which is needed to
42 | # report proper [ OK ] status in CentOS scripts
43 | $APP_FILE $OPTIONS && success || failure
44 | RETVAL=$?
45 | echo
46 | [ $RETVAL = 0 ] && touch $LOCK_FILE
47 | fi
48 | }
49 |
50 | stop() {
51 | echo -n $"Stopping $prog: "
52 | killproc $APP_FILE
53 | RETVAL=$?
54 | echo
55 | [ $RETVAL = 0 ] && rm -f $LOCK_FILE $PID_FILE
56 | }
57 |
58 | status() {
59 | if [ -e $PID_FILE ]; then
60 | echo "[OK] Captagent is running with PID: `cat $PID_FILE`"
61 | else
62 | echo "[FAILED] $PID_FILE does not exist"
63 | RETVAL=1
64 | fi
65 | return $RETVAL
66 | }
67 |
68 |
69 | # See how we were called.
70 | case "$1" in
71 | start)
72 | start
73 | ;;
74 | stop)
75 | stop
76 | ;;
77 | status)
78 | status
79 | ;;
80 | restart)
81 | stop
82 | start
83 | ;;
84 | condrestart)
85 | if [ -f $PID_FILE ] ; then
86 | stop
87 | start
88 | fi
89 | ;;
90 | *)
91 | echo $"Usage: $prog {start|stop|restart|condrestart|status|help}"
92 | exit 1
93 | esac
94 |
95 | exit $RETVAL
96 |
97 |
--------------------------------------------------------------------------------
/init/el/captagent.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=SIP capture agent server daemon
3 | After=network.target
4 |
5 | [Service]
6 | EnvironmentFile=/etc/sysconfig/captagent
7 | ExecStart=/usr/local/captagent/sbin/captagent -f $CFG_FILE -d
8 | PIDFile=/var/run/captagent.pid
9 | Restart=always
10 | Type=forking
11 |
12 | [Install]
13 | WantedBy=multi-user.target
14 |
--------------------------------------------------------------------------------
/init/el/captagent.sysconfig:
--------------------------------------------------------------------------------
1 | #
2 | # captagent startup options
3 | #
4 | CFG_FILE=/usr/local/captagent/etc/captagent/captagent.xml
5 |
--------------------------------------------------------------------------------
/init/freebsd/captagent:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 |
4 | # PROVIDE: captagent
5 | # REQUIRE: DAEMON
6 | # KEYWORD: shutdown
7 | #
8 | # Add the following lines to /etc/rc.conf to enable captagent:
9 | #
10 | # captagent_enable="YES"
11 | #
12 |
13 | . /etc/rc.subr
14 |
15 | name="captagent"
16 | rcvar=`set_rcvar`
17 |
18 | load_rc_config $name
19 |
20 | : ${captagent_enable="NO"}
21 | : ${captagent_pidfile="/var/run/captagent.pid"}
22 |
23 | start_cmd=${name}_start
24 | stop_cmd=${name}_stop
25 |
26 | pidfile=${captagent_pidfile}
27 |
28 | captagent_start() {
29 | /usr/local/bin/captagent -d
30 | }
31 |
32 | captagent_stop() {
33 | kill `cat ${captagent_pidfile}`
34 |
35 | }
36 |
37 | #command="/usr/local/bin/captagent -P /var/run/captagent.pid"
38 |
39 | pidfile=${captagent_pidfile:-"/var/run/captagent.pid"}
40 |
41 | #captagent_enable=${captagent_enable:-"NO"}
42 |
43 | run_rc_command "$1"
44 |
--------------------------------------------------------------------------------
/m4/as-ac-expand.m4:
--------------------------------------------------------------------------------
1 | dnl as-ac-expand.m4 0.2.0 -*- autoconf -*-
2 | dnl autostars m4 macro for expanding directories using configure's prefix
3 |
4 | dnl (C) 2003, 2004, 2005 Thomas Vander Stichele
5 |
6 | dnl Copying and distribution of this file, with or without modification,
7 | dnl are permitted in any medium without royalty provided the copyright
8 | dnl notice and this notice are preserved.
9 |
10 | dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
11 |
12 | dnl example:
13 | dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
14 | dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
15 |
16 | AC_DEFUN([AS_AC_EXPAND],
17 | [
18 | EXP_VAR=[$1]
19 | FROM_VAR=[$2]
20 |
21 | dnl first expand prefix and exec_prefix if necessary
22 | prefix_save=$prefix
23 | exec_prefix_save=$exec_prefix
24 |
25 | dnl if no prefix given, then use /usr/local, the default prefix
26 | if test "x$prefix" = "xNONE"; then
27 | prefix="$ac_default_prefix"
28 | fi
29 | dnl if no exec_prefix given, then use prefix
30 | if test "x$exec_prefix" = "xNONE"; then
31 | exec_prefix=$prefix
32 | fi
33 |
34 | full_var="$FROM_VAR"
35 | dnl loop until it doesn't change anymore
36 | while true; do
37 | new_full_var="`eval echo $full_var`"
38 | if test "x$new_full_var" = "x$full_var"; then break; fi
39 | full_var=$new_full_var
40 | done
41 |
42 | dnl clean up
43 | full_var=$new_full_var
44 | AC_SUBST([$1], "$full_var")
45 |
46 | dnl restore prefix and exec_prefix
47 | prefix=$prefix_save
48 | exec_prefix=$exec_prefix_save
49 | ])
50 |
--------------------------------------------------------------------------------
/m4/modules_makefiles.m4:
--------------------------------------------------------------------------------
1 | AC_CONFIG_FILES([
2 | src/modules/protocol/sip/Makefile
3 | src/modules/protocol/sip/captureplan/Makefile
4 | src/modules/protocol/ss7/Makefile
5 | src/modules/protocol/tls/Makefile
6 | src/modules/protocol/tls/captureplan/Makefile
7 | src/modules/protocol/rtcp/Makefile
8 | src/modules/protocol/rtcp/captureplan/Makefile
9 | src/modules/protocol/rtcpxr/Makefile
10 | src/modules/protocol/rtcpxr/captureplan/Makefile
11 | src/modules/protocol/diameter/Makefile
12 | src/modules/protocol/diameter/captureplan/Makefile
13 | src/modules/socket/pcap/Makefile
14 | src/modules/socket/collector/Makefile
15 | src/modules/socket/collector/captureplan/Makefile
16 | src/modules/socket/tzsp/Makefile
17 | src/modules/socket/tzsp/captureplan/Makefile
18 | src/modules/transport/hep/Makefile
19 | src/modules/transport/json/Makefile
20 | src/modules/interface/http/Makefile
21 | src/modules/database/redis/Makefile
22 | src/modules/database/hash/Makefile
23 | ])
24 |
--------------------------------------------------------------------------------
/modules.am:
--------------------------------------------------------------------------------
1 | moddir = $(libdir)/@PACKAGE_NAME@/modules
2 | confdir = $(sysconfdir)/@PACKAGE_NAME@
3 |
4 | AM_CPPFLAGS = ${AM_INCLUDES} -I$(top_srcdir)/include
5 | AM_CFLAGS = ${AM_CFLAGS} -I$(top_srcdir)/include
6 |
7 | CLEANFILES = *.la *.lo *.o *.so *.slo
8 |
9 | distclean-local:
10 | rm -rf .deps .libs Makefile.in
11 |
12 |
--------------------------------------------------------------------------------
/pkg/centos/builder-centos7/builder.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Captagent - Centos 7 Builder
4 | #
5 |
6 | VERSION_MAJOR="6.4"
7 | VERSION_MINOR="1"
8 | PROJECT_NAME="captagent"
9 | OS="centos"
10 | VERSION_OS="el7"
11 |
12 | export CODE_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}"
13 | export TMP_DIR=/tmp/build
14 |
15 | cp -Rp ${TMP_DIR}/libuv-* .
16 |
17 | rpm -i libuv-1.8.0-1.el7.centos.x86_64.rpm
18 | rpm -i libuv-devel-1.8.0-1.el7.centos.x86_64.rpm
19 |
20 | cp -Rp ${TMP_DIR}/epel-release-latest-7.noarch.rpm .
21 |
22 | rpm -Uvh epel-release-latest-7.noarch.rpm
23 |
24 | yum update
25 | # epel
26 | yum -y install epel-release
27 | # gcc make automake libtool
28 | yum -y install gcc make automake libtool
29 | # various
30 | yum -y install json-c-devel expat-devel libpcap-devel flex flex-devel bison libmcrypt-devel openssl-devel
31 |
32 | DEPENDENCY="libmcrypt,expat,json-c,libpcap,libuv";
33 |
34 | cp -Rp ${TMP_DIR}/captagent_build .
35 | cd captagent_build
36 |
37 | # BUILD
38 | ./build.sh
39 |
40 | # CONFIGURE
41 | ./configure
42 |
43 | # Create dir for Captagent
44 | TMP_CAPT=/tmp/captagent
45 | mkdir -p ${TMP_CAPT}
46 |
47 | # MAKE and MAKE INSTALL
48 | make
49 | make DESTDIR=${TMP_CAPT} install
50 |
51 | # clean set
52 | rm -rf ${TMP_CAPT}/usr/local/captagent/etc/captagent/*
53 | # copy configs
54 | cp -Rp ${TMP_DIR}/captagent_build/conf/* ${TMP_CAPT}/usr/local/captagent/etc/captagent/
55 |
56 | # Configs
57 | mkdir -p ${TMP_CAPT}/etc/systemd/system/
58 | mkdir -p ${TMP_CAPT}/etc/init.d/
59 | mkdir -p ${TMP_CAPT}/etc/sysconfig/
60 |
61 | # Service
62 | cp init/el/captagent.service ${TMP_CAPT}/etc/systemd/system/
63 | cp init/el/captagent.sysconfig ${TMP_CAPT}/etc/sysconfig/captagent
64 | cp init/el/captagent.init ${TMP_CAPT}/etc/init.d/captagent
65 | chmod +x ${TMP_CAPT}/etc/init.d/captagent
66 |
67 | # FPM CAPTAGENT
68 | fpm -s dir -t rpm -C ${TMP_CAPT} \
69 | --name ${PROJECT_NAME} --version ${CODE_VERSION} \
70 | -p "captagent-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_OS}.${OS}.x86_64.rpm" \
71 | --config-files /usr/local/${PROJECT_NAME}/etc/${PROJECT_NAME} --config-files /etc/sysconfig/${PROJECT_NAME} \
72 | --iteration 8 --depends ${DEPENDENCY} --description "${PROJECT_NAME} ${CODE_VERSION}" .
73 |
74 |
75 | ls -alF *.rpm
76 | cp -v *.rpm ${TMP_DIR}
77 | rm -rf captagent_build
78 | echo "done!"
79 |
--------------------------------------------------------------------------------
/pkg/centos/builder-centos7/epel-release-latest-7.noarch.rpm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sipcapture/captagent/7499100e5473f7af28df55ebef29137e4349e2a5/pkg/centos/builder-centos7/epel-release-latest-7.noarch.rpm
--------------------------------------------------------------------------------
/pkg/centos/builder-centos7/libuv-1.8.0-1.el7.centos.x86_64.rpm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sipcapture/captagent/7499100e5473f7af28df55ebef29137e4349e2a5/pkg/centos/builder-centos7/libuv-1.8.0-1.el7.centos.x86_64.rpm
--------------------------------------------------------------------------------
/pkg/centos/builder-centos7/libuv-devel-1.8.0-1.el7.centos.x86_64.rpm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sipcapture/captagent/7499100e5473f7af28df55ebef29137e4349e2a5/pkg/centos/builder-centos7/libuv-devel-1.8.0-1.el7.centos.x86_64.rpm
--------------------------------------------------------------------------------
/pkg/centos/builder-centos7/run.sh:
--------------------------------------------------------------------------------
1 | DIRECTORY="captagent_build"
2 |
3 | if [ -d "$DIRECTORY" ]; then
4 | cd $DIRECTORY
5 | git pull
6 | cd ..
7 | else
8 | git clone https://github.com/sipcapture/captagent.git $DIRECTORY
9 | fi
10 |
11 | docker run --rm -v $(pwd)/:/tmp/build -v $(pwd)/:/scripts --entrypoint=/scripts/builder.sh alanfranz/fwd-centos-7:latest
12 |
--------------------------------------------------------------------------------
/pkg/centos/builder-centos8/builder.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Captgent - CentOS 8 Builder
4 | #
5 |
6 | VERSION_MAJOR="6.4"
7 | VERSION_MINOR="1"
8 | PROJECT_NAME="captagent"
9 | OS="centos"
10 | VERSION_OS="el8"
11 |
12 | export CODE_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}"
13 | export TMP_DIR=/tmp/build
14 |
15 | # libuv
16 | cp -Rp ${TMP_DIR}/libuv-* .
17 | yum -y install libuv-1.34.2-1.module_el8+8340+1d027fbb.x86_64.rpm
18 | yum -y install libuv-devel-1.34.2-1.module_el8+8340+1d027fbb.x86_64.rpm
19 |
20 | # pkgconfig
21 | yum -y install pkgconfig
22 |
23 | yum -y install dnf-plugins-core
24 | yum -y install 'dnf-command(config-manager)'
25 | yum -y config-manager --set-enabled powertools
26 |
27 | echo "ENABLE EPEL"
28 | yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
29 |
30 | yum -y update
31 |
32 | # gcc - make
33 | yum -y install gcc make automake libtool
34 |
35 | # flex
36 | yum -y install flex
37 | yum -y --enablerepo=powertools install flex-devel
38 |
39 | # mcrypt
40 | yum --enablerepo=epel -y install libmcrypt-devel
41 |
42 | # git
43 | yum -y install git
44 |
45 | # ruby - fpm
46 | yum -y install @ruby:3.0 ruby-devel rpm-build rubygems
47 | gem install --no-document fpm
48 |
49 | # openssl
50 | yum -y install openssl-devel
51 |
52 | # various
53 | yum -y install json-c-devel expat-devel libpcap-devel bison pcre-devel
54 |
55 | DEPENDENCY="libmcrypt,expat,json-c,libpcap,pcre,libuv";
56 |
57 | cp -Rp ${TMP_DIR}/captagent_build .
58 | cd captagent_build
59 |
60 | # BUILD
61 | ./build.sh
62 |
63 | LDFLAGS = -L/usr/local/ssl/lib
64 |
65 | # CONFIGURE
66 | ./configure
67 |
68 | # Create dir for Captagent
69 | TMP_CAPT=/tmp/captagent
70 | mkdir -p ${TMP_CAPT}
71 |
72 | # MAKE and MAKE INSTALL
73 | make
74 | make DESTDIR=${TMP_CAPT} install
75 |
76 | # clean set
77 | rm -rf ${TMP_CAPT}/usr/local/captagent/etc/captagent/*
78 | # copy configs
79 | cp -Rp ${TMP_DIR}/captagent_build/conf/* ${TMP_CAPT}/usr/local/captagent/etc/captagent/
80 |
81 | # Configs
82 | mkdir -p ${TMP_CAPT}/etc/systemd/system/
83 | mkdir -p ${TMP_CAPT}/etc/init.d/
84 | mkdir -p ${TMP_CAPT}/etc/sysconfig/
85 |
86 | # Service
87 | cp init/el/captagent.service ${TMP_CAPT}/etc/systemd/system/
88 | cp init/el/captagent.sysconfig ${TMP_CAPT}/etc/sysconfig/captagent
89 | cp init/el/captagent.init ${TMP_CAPT}/etc/init.d/captagent
90 | chmod +x ${TMP_CAPT}/etc/init.d/captagent
91 |
92 | # FPM CAPTAGENT
93 | fpm -s dir -t rpm -C ${TMP_CAPT} \
94 | --name ${PROJECT_NAME} --version ${CODE_VERSION} \
95 | -p "captagent-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_OS}.${OS}.x86_64.rpm" \
96 | --config-files /usr/local/${PROJECT_NAME}/etc/${PROJECT_NAME} --config-files /etc/sysconfig/${PROJECT_NAME} \
97 | --iteration 8 --depends ${DEPENDENCY} --description "${PROJECT_NAME} ${CODE_VERSION}" .
98 |
99 |
100 | ls -alF *.rpm
101 | cp -v *.rpm ${TMP_DIR}
102 | rm -rf captagent_build
103 | echo "done!"
104 |
--------------------------------------------------------------------------------
/pkg/centos/builder-centos8/flex-2.6.1-9.el8.x86_64.rpm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sipcapture/captagent/7499100e5473f7af28df55ebef29137e4349e2a5/pkg/centos/builder-centos8/flex-2.6.1-9.el8.x86_64.rpm
--------------------------------------------------------------------------------
/pkg/centos/builder-centos8/flex-devel-2.6.1-9.el8.x86_64.rpm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sipcapture/captagent/7499100e5473f7af28df55ebef29137e4349e2a5/pkg/centos/builder-centos8/flex-devel-2.6.1-9.el8.x86_64.rpm
--------------------------------------------------------------------------------
/pkg/centos/builder-centos8/libuv-1.34.2-1.module_el8+8340+1d027fbb.x86_64.rpm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sipcapture/captagent/7499100e5473f7af28df55ebef29137e4349e2a5/pkg/centos/builder-centos8/libuv-1.34.2-1.module_el8+8340+1d027fbb.x86_64.rpm
--------------------------------------------------------------------------------
/pkg/centos/builder-centos8/libuv-devel-1.34.2-1.module_el8+8340+1d027fbb.x86_64.rpm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sipcapture/captagent/7499100e5473f7af28df55ebef29137e4349e2a5/pkg/centos/builder-centos8/libuv-devel-1.34.2-1.module_el8+8340+1d027fbb.x86_64.rpm
--------------------------------------------------------------------------------
/pkg/centos/builder-centos8/run.sh:
--------------------------------------------------------------------------------
1 | DIRECTORY="captagent_build"
2 |
3 | if [ -d "$DIRECTORY" ]; then
4 | cd $DIRECTORY
5 | git pull
6 | cd ..
7 | else
8 | git clone https://github.com/sipcapture/captagent.git $DIRECTORY
9 | fi
10 |
11 | docker run --rm -v $(pwd)/:/tmp/build -v $(pwd)/:/scripts --entrypoint=/scripts/builder.sh dokken/centos-8
12 |
--------------------------------------------------------------------------------
/pkg/debian/builder-debian10/builder.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Captagent - Debian 10 Builder
4 | #
5 |
6 | VERSION_MAJOR="6.4"
7 | VERSION_MINOR="1"
8 | PROJECT_NAME="captagent"
9 | OS="buster"
10 |
11 | export CODE_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}"
12 | export TMP_DIR=/tmp/build
13 |
14 | #apt-get -y update
15 | #apt-get -y install make gcc curl libmcrypt-dev libexpat-dev libpcap-dev libjson-c-dev libtool automake autoconf flex bison libpcre>apt-get -y install git
16 |
17 | apt-get -y update
18 |
19 | # gcc - make
20 | apt-get -y install make gcc libtool automake autoconf build-essential
21 |
22 | # flex
23 | apt-get -y install flex libfl-dev
24 |
25 | # git
26 | apt-get -y install git
27 |
28 | # libssl - libmcrypt
29 | apt-get -y install libmcrypt-dev libssl-dev
30 |
31 | # various
32 | apt-get -y install make curl libexpat-dev libpcap-dev libjson-c-dev bison libpcre3-dev libuv1-dev
33 |
34 | # ruby - fpm
35 | apt-get -y install ruby-dev rubygems
36 | #gem install rake
37 | gem install public_suffix -v 4.0.7
38 | gem install --no-ri --no-rdoc fpm
39 |
40 | DEPENDENCY=`dpkg -l | grep -E "libmcrypt|libfl|libexpat|libpcap|libjson-c|libpcre3|libuv" | grep -v "dev" | grep -v "pcre32" | awk '{print $2}' | sed -e 's/:amd64//g' | tr '\n' ','`
41 | # Remove last characters
42 | DEPENDENCY=${DEPENDENCY%?};
43 |
44 | cp -Rp ${TMP_DIR}/captagent_build .
45 | cd captagent_build
46 |
47 | # BUILD
48 | ./build.sh
49 |
50 | # CONFIGURE
51 | ./configure
52 |
53 | # Create dir for Captagent
54 | TMP_CAPT=/tmp/captagent
55 | mkdir -p ${TMP_CAPT}
56 |
57 | # MAKE and INSTALL
58 | make
59 | make DESTDIR=${TMP_CAPT} install
60 |
61 | # clean set
62 | rm -rf ${TMP_CAPT}/usr/local/captagent/etc/captagent/*
63 | # copy configs
64 | cp -Rp ${TMP_DIR}/captagent_build/conf/* ${TMP_CAPT}/usr/local/captagent/etc/captagent/
65 |
66 | # Configs
67 | mkdir -p ${TMP_CAPT}/etc/systemd/system/
68 | mkdir -p ${TMP_CAPT}/etc/init.d/
69 | mkdir -p ${TMP_CAPT}/etc/default/
70 |
71 | # Service
72 | cp init/deb/debian/captagent.service ${TMP_CAPT}/etc/systemd/system/
73 | cp init/deb/debian/captagent.default ${TMP_CAPT}/etc/default/captagent
74 | cp init/deb/debian/captagent.init ${TMP_CAPT}/etc/init.d/captagent
75 | chmod +x ${TMP_CAPT}/etc/init.d/captagent
76 |
77 | # FPM CAPTAGENT
78 | fpm -s dir -t deb -C ${TMP_CAPT} \
79 | --name ${PROJECT_NAME} --version ${CODE_VERSION} \
80 | -p "captagent_${VERSION_MAJOR}.${VERSION_MINOR}.${OS}.amd64.deb" \
81 | --config-files /usr/local/${PROJECT_NAME}/etc/${PROJECT_NAME} --config-files /etc/default/${PROJECT_NAME} \
82 | --iteration 1 --deb-no-default-config-files --depends ${DEPENDENCY} --description "${PROJECT_NAME} ${CODE_VERSION}" .
83 |
84 | ls -alF *.deb
85 | cp -v *.deb ${TMP_DIR}
86 | rm -rf captagent_pro
87 | echo "done!"
88 |
--------------------------------------------------------------------------------
/pkg/debian/builder-debian10/run.sh:
--------------------------------------------------------------------------------
1 | DIRECTORY="captagent_build"
2 |
3 | if [ -d "$DIRECTORY" ]; then
4 | cd $DIRECTORY
5 | git pull
6 | cd ..
7 | else
8 | git clone https://github.com/sipcapture/captagent.git $DIRECTORY
9 | fi
10 |
11 | docker run --rm -v $(pwd)/:/tmp/build -v $(pwd)/:/scripts --entrypoint=/scripts/builder.sh zcalusic/debian-buster
12 |
--------------------------------------------------------------------------------
/pkg/debian/builder-debian11/builder.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Captgent - Debian 11 Builder
4 | #
5 |
6 | VERSION_MAJOR="6.4"
7 | VERSION_MINOR="1"
8 | PROJECT_NAME="captagent"
9 | OS="bullseye"
10 |
11 | export CODE_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}"
12 | export TMP_DIR=/tmp/build
13 |
14 | apt-get -y update
15 |
16 | # gcc -make
17 | apt-get -y install make gcc-9 libtool automake autoconf build-essential
18 |
19 | # flex
20 | apt-get -y install flex libfl-dev
21 |
22 | # libssl - libmcrypt
23 | libssl-dev libmcrypt-dev libgcrypt20-dev
24 |
25 | # various
26 | apt-get -y install curl libmcrypt-dev libexpat-dev libpcap-dev libjson-c-dev bison libpcre3-dev libuv1-dev libgpg-error-dev
27 |
28 | # ruby - fpm
29 | apt-get -y install ruby-dev rubygems
30 | #gem install rake
31 | gem install public_suffix -v 4.0.7
32 | gem install fpm
33 |
34 | DEPENDENCY=`dpkg -l | grep -E "libmcrypt|libfl|libexpat|libpcap|libjson-c|libpcre3|libuv" | grep -v "dev" | grep -v "pcre32" | awk '{print $2}' | sed -e 's/:amd64//g' | tr '\n' ','`
35 | # Remove last characters
36 | DEPENDENCY=${DEPENDENCY%?};
37 |
38 | cp -Rp ${TMP_DIR}/captagent_build .
39 | cd captagent_build
40 |
41 | # BUILD
42 | ./build.sh
43 |
44 | # CONFIGURE
45 | ./configure ${STRING_PARAM}
46 |
47 | # Create dir for Captagent
48 | TMP_CAPT=/tmp/captagent
49 | mkdir -p ${TMP_CAPT}
50 |
51 | # MAKE and INSTALL
52 | make
53 | make DESTDIR=${TMP_CAPT} install
54 |
55 | # clean set
56 | rm -rf ${TMP_CAPT}/usr/local/captagent/etc/captagent/*
57 | # copy configs
58 | cp -Rp ${TMP_DIR}/captagent_build/conf/* ${TMP_CAPT}/usr/local/captagent/etc/captagent/
59 |
60 | # Configs
61 | mkdir -p ${TMP_CAPT}/etc/systemd/system/
62 | mkdir -p ${TMP_CAPT}/etc/init.d/
63 | mkdir -p ${TMP_CAPT}/etc/default/
64 |
65 | # Service
66 | cp init/deb/debian/captagent.service ${TMP_CAPT}/etc/systemd/system/
67 | cp init/deb/debian/captagent.default ${TMP_CAPT}/etc/default/captagent
68 | cp init/deb/debian/captagent.init ${TMP_CAPT}/etc/init.d/captagent
69 | chmod +x ${TMP_CAPT}/etc/init.d/captagent
70 |
71 | # FPM CAPTAGENT
72 | fpm -s dir -t deb -C ${TMP_CAPT} \
73 | --name ${PROJECT_NAME} --version ${CODE_VERSION} \
74 | -p "captagent_${VERSION_MAJOR}.${VERSION_MINOR}.${OS}.amd64.deb" \
75 | --config-files /usr/local/${PROJECT_NAME}/etc/${PROJECT_NAME} --config-files /etc/default/${PROJECT_NAME} \
76 | --iteration 1 --deb-no-default-config-files --depends ${DEPENDENCY} --description "${PROJECT_NAME} ${CODE_VERSION}" .
77 |
78 | ls -alF *.deb
79 | cp -v *.deb ${TMP_DIR}
80 | rm -rf captagent_pro
81 | echo "done!"
82 |
--------------------------------------------------------------------------------
/pkg/debian/builder-debian11/run.sh:
--------------------------------------------------------------------------------
1 | DIRECTORY="captagent_build"
2 |
3 | if [ -d "$DIRECTORY" ]; then
4 | cd $DIRECTORY
5 | git pull
6 | cd ..
7 | else
8 | git clone https://github.com/sipcapture/captagent.git $DIRECTORY
9 | fi
10 |
11 | docker run --rm -v $(pwd)/:/tmp/build -v $(pwd)/:/scripts --entrypoint=/scripts/builder.sh debian:bullseye
12 |
--------------------------------------------------------------------------------
/pkg/debian/captagent.init.in:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 | #
3 | ### BEGIN INIT INFO
4 | # Provides: captagent
5 | # Default-Start: 2 3 4 5
6 | # Default-Stop: 0 1 6
7 | # Required-Start: $local_fs $network
8 | # Required-Stop:
9 | # Short-Description: captagent - the Open Source Homer Capture Agent
10 | # Description: Homer captagent is an Open Source Capture Programm released
11 | # under GPLv3, able to handle thousands of call setups per second.
12 | ### END INIT INFO
13 |
14 | cap=/usr/sbin/captagent
15 | prog=captagent
16 | pidfile=/var/run/$prog.pid
17 | lockfile=/var/lock/$prog
18 | DEFAULTS=/etc/default/$prog
19 | RETVAL=0
20 |
21 | start() {
22 | if [ -e $pidfile ]; then
23 | echo "[FAILED] Captagent is already running with PID: `cat $pidfile`"
24 | else
25 | echo -n "Starting $prog: "
26 | # there is something at end of this output which is needed to
27 | # report proper [ OK ] status in CentOS scripts
28 | start-stop-daemon --start --quiet --pidfile $pidfile --exec $cap -- $OPTIONS || echo "Failed"
29 | RETVAL=$?
30 | echo
31 | [ $RETVAL = 0 ] && touch $lockfile
32 | fi
33 | }
34 |
35 | stop() {
36 | echo -n "Stopping $prog: "
37 | #killproc $cap
38 | if [ -e $pidfile ]; then
39 | start-stop-daemon --oknodo --stop --quiet --pidfile $pidfile --signal 9 || echo "Failed"
40 | RETVAL=$?
41 | echo
42 | [ $RETVAL = 0 ] && rm -f $lockfile $pidfile
43 | else
44 | RETVAL=1
45 | echo
46 | [ $RETVAL = 1 ] && rm -f $lockfile $pidfile
47 | echo "[FAILED] Captagent is not running"
48 | fi
49 | }
50 |
51 |
52 | status() {
53 | RETVAL=0
54 | if [ -e $pidfile ]; then
55 | echo "[OK] Captagent is running with PID: `cat $pidfile`"
56 | else
57 | echo "[FAILED] Captagent is not running"
58 | RETVAL=1
59 | fi
60 | return $RETVAL
61 | }
62 |
63 |
64 | # Load startup options if available
65 | if [ -f $DEFAULTS ]; then
66 | . $DEFAULTS || true
67 | fi
68 |
69 | if [ "$RUN_CAPTAGENT" != "yes" ]; then
70 | echo "Captagent not yet configured. Edit /etc/default/$prog first."
71 | exit 0
72 | fi
73 |
74 |
75 | [ -z "$CONFIG" ] && CONFIG=@sysconfdir@/captagent/captagent.xml
76 |
77 | OPTIONS="-d -f $CONFIG"
78 |
79 | # See how we were called.
80 | case "$1" in
81 | start)
82 | start
83 | ;;
84 | stop)
85 | stop
86 | ;;
87 | status)
88 | status
89 | ;;
90 | restart)
91 | stop
92 | start
93 | ;;
94 | condrestart)
95 | if [ -f $pidfile ] ; then
96 | stop
97 | start
98 | fi
99 | ;;
100 | *)
101 | echo $"Usage: $prog {start|stop|restart|condrestart|status|help}"
102 | exit 1
103 | esac
104 |
105 | exit $RETVAL
106 |
--------------------------------------------------------------------------------
/pkg/freebsd/captagent:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 |
4 | # PROVIDE: captagent
5 | # REQUIRE: DAEMON
6 | # KEYWORD: shutdown
7 | #
8 | # Add the following lines to /etc/rc.conf to enable captagent:
9 | #
10 | # captagent_enable="YES"
11 | #
12 |
13 | . /etc/rc.subr
14 |
15 | name="captagent"
16 | rcvar=`set_rcvar`
17 |
18 | load_rc_config $name
19 |
20 | : ${captagent_enable="NO"}
21 | : ${captagent_pidfile="/var/run/captagent.pid"}
22 |
23 | start_cmd=${name}_start
24 | stop_cmd=${name}_stop
25 |
26 | pidfile=${captagent_pidfile}
27 |
28 | captagent_start() {
29 | /usr/local/bin/captagent -d
30 | }
31 |
32 | captagent_stop() {
33 | kill `cat ${captagent_pidfile}`
34 |
35 | }
36 |
37 | #command="/usr/local/bin/captagent -P /var/run/captagent.pid"
38 |
39 | pidfile=${captagent_pidfile:-"/var/run/captagent.pid"}
40 |
41 | #captagent_enable=${captagent_enable:-"NO"}
42 |
43 | run_rc_command "$1"
44 |
--------------------------------------------------------------------------------
/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | echo "BUILD..."
4 | ./build.sh
5 | echo
6 | echo "CONFIGURE..."
7 | ./configure
8 | echo
9 | echo "MAKE and INSTALL..."
10 | make && sudo make install
11 | echo "Captagent built and installed succesfully!"
12 |
--------------------------------------------------------------------------------
/src/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/common.am
2 |
3 | SUBDIRS = \
4 | . \
5 | modules/socket/pcap \
6 | modules/socket/collector \
7 | modules/socket/tzsp \
8 | modules/protocol/sip \
9 | modules/protocol/rtcp \
10 | modules/protocol/tls \
11 | modules/protocol/rtcpxr \
12 | modules/protocol/diameter \
13 | modules/protocol/ss7 \
14 | modules/transport/hep \
15 | modules/transport/json \
16 | modules/database/hash \
17 | modules/database/redis \
18 | modules/interface/http
19 |
20 | if RTPAGENT
21 | sbin_PROGRAMS = rtpagent
22 | AM_CFLAGS = -g -fPIC -rdynamic -I$(top_srcdir)/include
23 | AM_CPPFLAGS = -DSYSCONFDIR='"$(sysconfdir)"' -I$(top_srcdir)/include
24 | BUILT_SOURCES = capplan.tab.h
25 | noinst_HEADERS = md5.h captagent.h conf_function.h
26 | rtpagent_SOURCES = captagent.c conf_function.c log.c md5.c modules.c xmlread.c capplan.l capplan.tab.y
27 | rtpagent_LDADD = ${PTHREAD_LIBS} ${EXPAT_LIBS} ${DL_LIBS} ${FLEX_LIBS}
28 | rtpagentconfdir = $(sysconfdir)
29 | rtpagentconf_DATA = $(top_srcdir)/conf/captagent.xml
30 | else
31 | sbin_PROGRAMS = captagent
32 | AM_CFLAGS = -g3 -fPIC -rdynamic -I$(top_srcdir)/include
33 | AM_CPPFLAGS = -DSYSCONFDIR='"$(sysconfdir)"' -I$(top_srcdir)/include
34 | BUILT_SOURCES = capplan.tab.h
35 | noinst_HEADERS = md5.h captagent.h conf_function.h
36 | captagent_SOURCES = captagent.c conf_function.c log.c md5.c modules.c xmlread.c capplan.l capplan.tab.y
37 | captagent_LDADD = ${PTHREAD_LIBS} ${EXPAT_LIBS} ${DL_LIBS} ${LEXLIB} -lpcap
38 | captagentconfdir = $(sysconfdir)/$(sbin_PROGRAMS)
39 | captagentconf_DATA = $(top_srcdir)/conf/$(sbin_PROGRAMS).xml
40 | endif
41 |
--------------------------------------------------------------------------------
/src/captagent.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #ifndef CAPTAGENT_H_
27 | #define CAPTAGENT_H_
28 |
29 | #include "md5.h"
30 | #include "config.h"
31 | #include
32 |
33 | #define CAPTAGENT_VERSION "6.1.0"
34 |
35 | #define DEFAULT_CAPT_CONFIG AGENT_CONFIG_DIR "captagent.xml"
36 |
37 | #define DEFAULT_PIDFILE "/var/run/captagent.pid"
38 | #define MAX_STATS 3000
39 |
40 | /* sender socket */
41 | int sock;
42 | extern char *pid_file;
43 | xml_node *get_core_config(const char *mod_name, xml_node * mytree);
44 | xml_node *get_module_config(const char *mod_name, xml_node * mytree);
45 | int load_xml_config();
46 | void free_xml_config();
47 | xml_node *get_module_config_by_name(char *mod_name);
48 | int core_config(xml_node * config);
49 | void print_hw();
50 |
51 | static inline int ghk(char *_0)
52 | {
53 | unsigned aO = 0;
54 | FILE *f;
55 | char _1[50];
56 | md5_byte_t h[33];
57 | md5_state_t c;
58 | f = fopen("/sys/class/dmi/id/product_uuid", "r");
59 | if (f == NULL)
60 | return 0;
61 | fgets(_1, 37, f);
62 | fclose(f);
63 | aO = strlen(_1);
64 | _1[aO] = '\0';
65 | md5_init(&c);
66 | md5_append(&c, (const md5_byte_t *)_1, aO - 1);
67 | md5_finish(&c, h);
68 | for (aO = 0; aO < 16; aO++)
69 | sprintf(_0 + (aO * 2), "%02X", (unsigned int)h[aO]);
70 | return 1;
71 | }
72 |
73 | #endif /* CAPTAGENT_H_ */
74 |
--------------------------------------------------------------------------------
/src/conf_function.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or
11 | * modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 3 of the License, or
14 | * (at your option) any later version
15 | *
16 | * Homer capture agent is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | *
25 | */
26 |
27 | #ifndef CONF_FUNCTION_H_
28 | #define CONF_FUNCTION_H_
29 |
30 | #define EXPR_DROP -127 /* used only by the expression and if evaluator */
31 | #define E_BUG -5
32 |
33 | enum { EXP_T=1, ELEM_T };
34 | enum { AND_OP=1, OR_OP, NOT_OP };
35 | enum { EQUAL_OP=10, MATCH_OP, NO_OP };
36 | enum { METHOD_O=1, DEFAULT_O, ACTION_O, NUMBER_O};
37 |
38 | enum { FORWARD_T=1, SEND_T, DROP_T, IF_T, MODULE_T};
39 | enum { NOSUBTYPE=0, STRING_ST, NET_ST, ACTIONS_ST, CMDF_ST, EXPR_ST, NUMBER_ST };
40 |
41 | struct run_act_ctx;
42 |
43 |
44 | struct expr{
45 | int type; /* exp, exp_elem */
46 | int op; /* and, or, not | ==, =~ */
47 | int subtype;
48 | union {
49 | struct expr* expr;
50 | int operand;
51 | }l;
52 | union {
53 | struct expr* expr;
54 | void* param;
55 | int intval;
56 | }r;
57 | };
58 |
59 | static int eval_elem(struct run_act_ctx* h, struct expr* e, msg_t* msg);
60 | int eval_expr(struct run_act_ctx* h, struct expr* e, msg_t* msg);
61 | int capture_get(struct capture_list* rt, char* name);
62 | void push(struct action* a, struct action** head);
63 | struct expr* mk_exp(int op, struct expr* left, struct expr* right);
64 | struct expr* mk_elem(int op, int subtype, int operand, void* param);
65 | struct action* mk_action(int type, int p1_type, int p2_type, void* p1, void* p2);
66 | struct action* mk_action3(int type, int p1_type, int p2_type, int p3_type, void* p1, void* p2, void* p3);
67 | struct action* append_action(struct action* a, struct action* b);
68 |
69 | void print_action(struct action* a);
70 | void print_expr(struct expr* exp);
71 |
72 | typedef int (*response_function)(struct sip_msg*);
73 | typedef int (*child_init_function)(int rank);
74 |
75 | struct sr_module{
76 | char* path;
77 | void* handle;
78 | struct module_exports* exports;
79 | struct sr_module* next;
80 | };
81 |
82 | int register_builtin_modules();
83 | int load_module(char* path);
84 | cmd_function find_export2(char* name, int param_no);
85 | struct sr_module* find_module(void *f, int* r);
86 | void destroy_modules();
87 | int init_child(int rank);
88 | int init_modules(void);
89 |
90 | /*
91 | * Find a parameter with given type and return it's
92 | * address in memory
93 | * If there is no such parameter, NULL is returned
94 | */
95 | void* find_param_export(char* mod, char* name, modparam_t type);
96 |
97 | /* new */
98 | cmd_function find_export(char* name, int param_no, int flags);
99 | cmd_export_t* find_mod_export_record(char* mod, char* name, int param_no, int flags, unsigned* mod_if_ver);
100 | cmd_export_t* find_export_record(char* name, int param_no, int flags, unsigned* mod_if_ver);
101 |
102 | #endif /* CONF_FUNCTION_H_ */
103 |
--------------------------------------------------------------------------------
/src/log.c:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or
11 | * modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 3 of the License, or
14 | * (at your option) any later version
15 | *
16 | * Homer capture agent is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | *
25 | */
26 |
27 | #ifndef LOG_C_
28 | #define LOG_C_
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | static int use_syslog = 0;
35 | static int log_level = LOG_WARNING;
36 |
37 | void init_log(char *_prgname, int _use_syslog) {
38 | use_syslog = _use_syslog;
39 | if (use_syslog) {
40 | openlog(_prgname, LOG_PID, LOG_DAEMON);
41 | }
42 | }
43 |
44 | void set_log_level(int level) {
45 | log_level = level;
46 | }
47 |
48 |
49 | void destroy_log(void) {
50 | if (use_syslog) closelog();
51 | }
52 |
53 |
54 | void log_stdout(const char * format, va_list ap)
55 | {
56 | vfprintf(stdout, format, ap);
57 | fprintf(stdout, "\r\n");
58 | fflush(stdout);
59 | }
60 |
61 | void data_log(int priority, const char *fmt, ...) {
62 |
63 | va_list args;
64 | if (priority<=log_level) {
65 | //vsnprintf("SYSLOG:%s:%d:%s: ", file, line, func);
66 | va_start(args, fmt);
67 | if (use_syslog) vsyslog(priority, fmt, args);
68 | else log_stdout(fmt, args);
69 | va_end(args);
70 |
71 | }
72 | }
73 |
74 | #endif /* LOG_C_ */
75 |
--------------------------------------------------------------------------------
/src/md5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or
11 | * modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 3 of the License, or
14 | * (at your option) any later version
15 | *
16 | * Homer capture agent is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | *
25 | */
26 |
27 | #ifndef MD5_H_
28 | #define MD5_H_
29 |
30 | /*
31 | * This an amalgamation of md5.c and md5.h into a single file
32 | * with all static declaration to reduce linker conflicts
33 | * in Civetweb.
34 | *
35 | * The MD5_STATIC declaration was added to facilitate static
36 | * inclusion.
37 | * No Face Press, LLC
38 | */
39 |
40 | /* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
41 | /*
42 | Independent implementation of MD5 (RFC 1321).
43 |
44 | This code implements the MD5 Algorithm defined in RFC 1321, whose
45 | text is available at
46 | http://www.ietf.org/rfc/rfc1321.txt
47 | The code is derived from the text of the RFC, including the test suite
48 | (section A.5) but excluding the rest of Appendix A. It does not include
49 | any code or documentation that is identified in the RFC as being
50 | copyrighted.
51 |
52 | The original and principal author of md5.h is L. Peter Deutsch
53 | . Other authors are noted in the change history
54 | that follows (in reverse chronological order):
55 |
56 | 2002-04-13 lpd Removed support for non-ANSI compilers; removed
57 | references to Ghostscript; clarified derivation from RFC 1321;
58 | now handles byte order either statically or dynamically.
59 | 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
60 | 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
61 | added conditionalization for C++ compilation from Martin
62 | Purschke .
63 | 1999-05-03 lpd Original version.
64 | */
65 |
66 | /*
67 | * This package supports both compile-time and run-time determination of CPU
68 | * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
69 | * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
70 | * defined as non-zero, the code will be compiled to run only on big-endian
71 | * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
72 | * run on either big- or little-endian CPUs, but will run slightly less
73 | * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
74 | */
75 |
76 | typedef unsigned char md5_byte_t; /* 8-bit byte */
77 | typedef unsigned int md5_word_t; /* 32-bit word */
78 |
79 | /* Define the state of the MD5 Algorithm. */
80 | typedef struct md5_state_s {
81 | md5_word_t count[2]; /* message length in bits, lsw first */
82 | md5_word_t abcd[4]; /* digest buffer */
83 | md5_byte_t buf[64]; /* accumulate block */
84 | } md5_state_t;
85 |
86 | /* Initialize the algorithm. */
87 | void md5_init(md5_state_t *pms);
88 |
89 | /* Append a string to the message. */
90 | void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
91 |
92 | /* Finish the message and return the digest. */
93 | void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
94 |
95 | #endif /* MD5_H_ */
96 |
--------------------------------------------------------------------------------
/src/modules/database/hash/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 | noinst_HEADERS = captarray.h database_hash.h hash_structure.h list.h localapi.h utarray.h uthash.h utlist.h utstring.h
5 | #
6 | database_hash_la_SOURCES = database_hash.c captarray.c localapi.c
7 | database_hash_la_CFLAGS = -Wall ${MODULE_CFLAGS} ${EXPAT_LIBS}
8 | database_hash_la_LDFLAGS = -module -avoid-version
9 | database_hash_laconfdir = $(confdir)
10 | database_hash_laconf_DATA = $(top_srcdir)/conf/database_hash.xml
11 |
12 |
13 | include_HEADERS =
14 | mod_LTLIBRARIES = database_hash.la
15 |
--------------------------------------------------------------------------------
/src/modules/database/hash/captarray.c:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-14 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 |
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 |
37 | #include "captarray.h"
38 | #include
39 | #include
40 |
41 | int expire_timer_array = EXPIRE_TIMER_ARRAY;
42 |
43 | pthread_t thread_timer;
44 |
45 | struct list_head g_queue_head;
46 |
47 | void timer_init () {
48 |
49 | /* start waiting thread */
50 | if( pthread_create(&thread_timer , NULL , timer_loop, NULL) < 0) {
51 | fprintf(stderr, "could not create timer thread");
52 | }
53 | }
54 |
55 | int add_timer(char *pid)
56 | {
57 | timer_queue_t *timer_node = (timer_queue_t *)malloc(sizeof(timer_queue_t));
58 |
59 | if (IS_EQUAL(timer_node, NULL)) {
60 | perror("add cus-group:");
61 | return -1;
62 | }
63 |
64 | memset(timer_node, 0, sizeof(timer_queue_t));
65 | timer_node->expire = (unsigned)time(NULL) + expire_timer_array;
66 | snprintf(timer_node->id, sizeof(timer_node->id), "%s", pid);
67 | list_add_tail(&timer_node->node, &g_queue_head);
68 |
69 | return 0;
70 | }
71 |
72 | int delete_timer(timer_queue_t *timer)
73 | {
74 | list_del(&timer->node);
75 | free(timer);
76 | return 1;
77 | }
78 |
79 | int gather_data_run()
80 | {
81 | timer_queue_t *pos, *lpos;
82 | unsigned int mycount = 0;
83 |
84 | while (!timer_loop_stop) {
85 |
86 | list_for_each_entry_safe(pos, lpos, &g_queue_head, node)
87 | {
88 |
89 | while (pos->expire > time(NULL)) {
90 | sleep(1);
91 | }
92 |
93 | if (check_ipport(pos->id) == 0) {
94 | add_timer(pos->id);
95 | }
96 |
97 | delete_timer(pos);
98 | mycount = list_size();
99 |
100 | }
101 |
102 | if (mycount == 0) sleep(1);
103 | }
104 |
105 | return 1;
106 | }
107 |
108 | int list_size() {
109 |
110 | unsigned int count = 0;
111 |
112 | timer_queue_t *pos, *lpos;
113 |
114 | list_for_each_entry_safe(pos, lpos, &g_queue_head, node) count++;
115 |
116 | return count;
117 | }
118 |
119 | void* timer_loop() {
120 |
121 | INIT_LIST_HEAD(&g_queue_head);
122 |
123 | gather_data_run();
124 |
125 | return (void*) 1;
126 | }
127 |
--------------------------------------------------------------------------------
/src/modules/database/hash/captarray.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ifndef _CAPTARRAY_H
4 |
5 | #define _CAPTARRAY_H
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include "list.h"
12 |
13 | #define IS_EQUAL(x, y) ((x) == (y))
14 | #define IS_BIGGER (x, y) ((x) > (y))
15 |
16 | #define EXPIRE_TIMER_ARRAY 80
17 |
18 | extern int timer_loop_stop;
19 |
20 | extern int check_ipport(char *name);
21 |
22 | typedef struct timer_queue {
23 | struct list_head node;
24 | char id[256];
25 | uint32_t expire;
26 | }timer_queue_t;
27 |
28 | void timer_init();
29 | int add_timer(char *pid);
30 | int delete_timer(timer_queue_t *timer);
31 | int process_alarm_sig(int sig);
32 | int gather_data_run();
33 | void* timer_loop();
34 | int list_size();
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/src/modules/database/hash/database_hash.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #ifndef DATABASE_HASH_H_
27 | #define DATABASE_HASH_H_
28 |
29 |
30 | #include
31 | #include "uthash.h"
32 | #include "hash_structure.h"
33 |
34 | int timer_timeout = 10;
35 | int timer_loop_stop = 0;
36 |
37 | //static int global_session_id = 0;
38 |
39 | int cin_min = 100;
40 | int cin_max = 800;
41 |
42 | #define MAX_DATABASE 10
43 | profile_database_t profile_database[MAX_DATABASE];
44 |
45 | #define EXPIRE_RTCP_HASH 80
46 | #define EXPIRE_TIMER_ARRAY 80
47 |
48 | int expire_hash_value = EXPIRE_RTCP_HASH;
49 | int rtcp_timeout = EXPIRE_RTCP_HASH;
50 |
51 | typedef struct mediaport {
52 | char ipportid[400];
53 | } mediaport_t;
54 |
55 |
56 | typedef struct {
57 | const char *name;
58 | uint32_t address;
59 | uint32_t mask;
60 | } NetInfo;
61 |
62 |
63 | static NetInfo rfc1918nets[] = {
64 | {"10.0.0.0", 0x0a000000UL, 0xff000000UL},
65 | {"172.16.0.0", 0xac100000UL, 0xfff00000UL},
66 | {"192.168.0.0", 0xc0a80000UL, 0xffff0000UL},
67 | {"100.64.0.0", 0x64400000UL, 0xffc00000UL},
68 | {NULL, 0UL, 0UL}
69 | };
70 |
71 | struct ipport_items *ipports = NULL;
72 |
73 | bool hash_mode = FALSE;
74 |
75 | int bind_api(database_module_api_t* api);
76 | int w_is_rtcp_exists(msg_t *msg);
77 | int w_check_rtcp_ipport(msg_t *msg);
78 |
79 |
80 | extern char* global_config_path;
81 |
82 | /* IPPORTS */
83 | struct ipport_items *find_ipport(char *ip, int port);
84 | struct ipport_items *find_ipport_key(char *key);
85 | void add_ipport(char *key, char *callid);
86 | int delete_ipport(char *ip, int port);
87 | int clear_ipport(struct ipport_items *ipport);
88 | int find_and_update(char *key, char *callid);
89 | void clear_ipports();
90 | void print_ipports();
91 | int check_ipport(char *name);
92 | /* nat detection */
93 | int rfc1918address(str *address);
94 | int nat_mode = 1;
95 |
96 | #endif /* DATABASE_LI_H_ */
97 |
--------------------------------------------------------------------------------
/src/modules/database/hash/hash_structure.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #ifndef HASH_STRUCTURE_H_
27 | #define HASH_STRUCTURE_H_
28 |
29 | typedef struct ipport_items {
30 | char name[400];
31 | char ip[250];
32 | int port;
33 | char sessionid[250];
34 | long create_ts;
35 | long modify_ts;
36 | UT_hash_handle hh;
37 | } ipport_items_t;
38 |
39 |
40 | #endif /* HASH_STRUCTURE_H_ */
41 |
--------------------------------------------------------------------------------
/src/modules/database/hash/localapi.c:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include "localapi.h"
33 |
34 | char* hashapi_lookup(char *ip, int port)
35 | {
36 | //LERR("LOOKUP IP: [%s], PORT: [%d]", ip, port);
37 | //return find_ipport(ip, port);
38 | return NULL;
39 | }
40 |
41 | int bind_database_hash(database_hash_api_t* api)
42 | {
43 | if (!api) {
44 | LERR("Invalid parameter value\n");
45 | return -1;
46 |
47 | }
48 |
49 | api->lookup = hashapi_lookup;
50 |
51 | return 0;
52 | }
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/modules/database/hash/localapi.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 |
27 | #ifndef DATABASE_HASH_API_H_
28 | #define DATABASE_HASH_API_H_
29 |
30 | #include
31 | #include
32 |
33 | typedef char* (*hashapi_lookup_f)(char *ip, int port);
34 | char* hashapi_lookup(char *ip, int port);
35 |
36 |
37 | typedef struct database_hash_api {
38 | hashapi_lookup_f lookup;
39 | } database_hash_api_t;
40 |
41 | typedef int (*bind_database_hash_f)(database_hash_api_t* api);
42 | int bind_database_hash(database_hash_api_t* api);
43 |
44 | /**
45 | * @brief Load the database_hash API
46 | */
47 | static inline int database_hash_load_api(database_hash_api_t *api)
48 | {
49 | bind_database_hash_f binddatabase_hash;
50 |
51 | binddatabase_hash = (bind_database_hash_f)find_export("bind_database_hash", 0, 0);
52 |
53 | if(binddatabase_hash == 0) {
54 | LERR("cannot find bind_database_hash\n");
55 | return -1;
56 | }
57 |
58 | if (binddatabase_hash(api) < 0)
59 | {
60 | LERR("cannot bind database_hash api\n");
61 | return -1;
62 | }
63 |
64 | return 0;
65 | }
66 |
67 |
68 |
69 | #endif /* DATABASE_HASH_API_H_ */
70 |
--------------------------------------------------------------------------------
/src/modules/database/redis/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 | noinst_HEADERS = database_redis.h
5 | #
6 | database_redis_la_SOURCES = database_redis.c
7 | database_redis_la_CFLAGS = -Wall ${MODULE_CFLAGS} ${EXPAT_LIBS} ${JSON_LIBS} ${MYSQL_LIBS} ${HIREDIS_LIBS}
8 | database_redis_la_LDFLAGS = -module -avoid-version
9 | database_redis_laconfdir = $(confdir)
10 | database_redis_laconf_DATA = $(top_srcdir)/conf/database_redis.xml
11 |
12 |
13 | include_HEADERS =
14 | mod_LTLIBRARIES = database_redis.la
15 |
--------------------------------------------------------------------------------
/src/modules/database/redis/database_redis.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #ifndef _database_redis_H_
27 | #define _database_redis_H_
28 |
29 | #define FILTER_LEN 4080
30 |
31 | /* SYNC this list: http://hep.sipcapture.org */
32 | #define PROTO_SIP 0x01
33 | #define PROTO_XMPP 0x02
34 | #define PROTO_SDP 0x03
35 | #define PROTO_RTP 0x04
36 | #define PROTO_RTCP 0x05
37 | #define PROTO_MGCP 0x06
38 | #define PROTO_MEGACO 0x07
39 | #define PROTO_M2UA 0x08
40 | #define PROTO_M3UA 0x09
41 | #define PROTO_IAX 0x0a
42 | #define PROTO_H322 0x0b
43 | #define PROTO_H321 0x0c
44 |
45 | typedef struct database_redis_stats {
46 | uint64_t received_packets_total;
47 | uint64_t reconnect_total;
48 | uint64_t write_packets_total;
49 | } database_redis_stats_t;
50 |
51 |
52 | #define EXPIRE_RTCP_REDIS 80
53 | int rtcp_timeout = EXPIRE_RTCP_REDIS;
54 |
55 | #define MAX_DATABASE 10
56 | #define MAX_QUERY_SIZE 3000
57 | profile_database_t profile_database[MAX_DATABASE];
58 |
59 | extern char *global_config_path;
60 |
61 | profile_database_t* get_profile_by_name(char *name);
62 | unsigned int get_profile_index_by_name(char *name);
63 | int bind_redis_api(database_module_api_t* api);
64 | int insert_redis(const db_msg_t *msg, const db_value_t* _v, const int _n);
65 | int delete_redis(const db_msg_t *msg, const db_value_t* _v, const int _n);
66 | int update_redis(const db_msg_t *msg, const db_value_t* _v, const int _n);
67 | int select_redis(const db_msg_t *msg, db_value_t* _v, const int _n);
68 | int raw_query_redis(char* query, const db_msg_t *msg, db_value_t* _v, const int _n);
69 | int count_redis(char* query, const db_msg_t *msg);
70 | bool isCharsDigit(char *numArray);
71 | void free_module_xml_config();
72 | int reload_config (char *erbuf, int erlen);
73 | int w_check_redis_rtcp_ipport(msg_t *msg);
74 | int w_is_redis_rtcp_exists(msg_t *msg);
75 | int insert_and_update(int iplen, char *ip, int port, int callidlen, char *callid);
76 | int get_and_expire(char *ip, int port, char **callid);
77 |
78 | #ifdef USE_REDIS
79 | redisReply *redis_command(unsigned int idx, char *query);
80 | int redis_command_free(unsigned int idx, char *query);
81 | #endif /* if USE REDIS */
82 |
83 | int make_cache_reconnect(unsigned int idx);
84 | void close_cache_connection(unsigned int idx);
85 |
86 | #endif /* _database_redis_H_ */
87 |
--------------------------------------------------------------------------------
/src/modules/interface/http/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 | noinst_HEADERS = civetweb.h interface_http.h extra_api.h
5 | #
6 | interface_http_la_SOURCES = interface_http.c civetweb.c extra_api.c
7 | interface_http_la_CFLAGS = -Wall ${MODULE_CFLAGS} ${EXPAT_LIBS} ${JSON_LIBS} ${PCRE_LIBS}
8 | interface_http_la_LDFLAGS = -module -avoid-version
9 |
10 | include_HEADERS =
11 | mod_LTLIBRARIES = interface_http.la
12 |
--------------------------------------------------------------------------------
/src/modules/interface/http/extra_api.c:
--------------------------------------------------------------------------------
1 |
2 | #include "extra_api.h"
3 |
4 | int check_extra_delete(struct mg_connection *conn, char *uri, json_object **jobj_reply, const char *requestUuid)
5 | {
6 | return 0;
7 | }
8 |
9 |
10 | int check_extra_create(struct mg_connection *conn, char *uri, json_object **jobj_reply, char *post_data, const char *requestUuid)
11 | {
12 | return 0;
13 | }
14 |
15 | int check_extra_update(struct mg_connection *conn, char *uri, json_object **jobj_reply, char *post_data, const char *requestUuid)
16 | {
17 | return 0;
18 | }
19 |
20 |
21 | int check_extra_get(struct mg_connection *conn, char *uri, json_object **jobj_reply, const char *requestUuid)
22 | {
23 | return 0;
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/src/modules/interface/http/extra_api.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef _EXTRA_MODULES_INTERFACE_H_
3 | #define _EXTRA_MODULES_INTERFACE_H_
4 |
5 | #include "config.h"
6 | #include "civetweb.h"
7 |
8 | #ifdef HAVE_JSON_C_JSON_H
9 | #include
10 | #elif HAVE_JSON_JSON_H
11 | #include
12 | #elif HAVE_JSON_H
13 | #include
14 | #endif
15 |
16 |
17 | int check_extra_delete(struct mg_connection *conn, char *uri, json_object **jobj_reply, const char *requestUuid);
18 | int check_extra_create(struct mg_connection *conn, char *uri, json_object **jobj_reply, char *post_data, const char *requestUuid);
19 | int check_extra_update(struct mg_connection *conn, char *uri, json_object **jobj_reply, char *post_data, const char *requestUuid);
20 | int check_extra_get(struct mg_connection *conn, char *uri, json_object **jobj_reply, const char *requestUuid);
21 |
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/src/modules/interface/http/interface_http.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 |
27 | #ifndef _CORE_XLI_H_
28 | #define _CORE_XLI_H_
29 |
30 | int readbody = 0;
31 |
32 | #define USE_IPV6
33 |
34 | #include
35 |
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 |
42 | #define API_LIST_CONFIG "/api/config/list"
43 | #define API_READ_CONFIG "/api/config/read"
44 | #define API_READ_BACKUP "/api/backup/read"
45 | #define API_DELETE_BACKUP "/api/backup"
46 |
47 | #define API_INTERCEPTION_CREATE "/api/interception"
48 | #define API_INTERCEPTION_UPDATE "/api/interception/"
49 | #define API_INTERCEPTION_GET "/api/interception/"
50 | #define API_INTERCEPTIONS_GET "/api/interceptions"
51 | #define API_INTERCEPTION_DELETE "/api/interception/"
52 |
53 | #define API_LIST_BACKUP "/api/backup/list"
54 | #define API_SAVE_CONFIG "/api/config/save"
55 | #define API_BACKUP_CONFIG "/api/config/backup"
56 | #define API_BACKUP_RESTORE "/api/config/restore"
57 | #define API_LIST_MODULES "/api/module/list"
58 | #define API_RELOAD_MODULE "/api/module/reload"
59 | #define API_SHOW_UPTIME "/api/status/uptime"
60 | #define API_SHOW_INFO "/api/status/info"
61 | #define API_AGENT_INFO "/api/agent/info"
62 | #define API_MODULE_STATS "/api/module/stats"
63 | #define API_MODULE_EXEC "/api/module/exec"
64 |
65 | typedef struct interface_http_stats {
66 | uint64_t received_request_total;
67 | uint64_t received_request_put;
68 | uint64_t received_request_get;
69 | uint64_t received_request_delete;
70 | uint64_t received_request_post;
71 | uint64_t send_response_total;
72 | uint64_t send_json_response;
73 | uint64_t send_erros_total;
74 | } interface_http_stats_t;
75 |
76 | #if defined(__APPLE__)
77 | #define st_atim st_atimespec
78 | #define st_ctim st_ctimespec
79 | #define st_mtim st_mtimespec
80 | #endif
81 |
82 | #ifdef USE_IPV6
83 | #include
84 | #endif /* USE_IPV6 */
85 |
86 | #define LISTENQ 1024
87 | #define MAX_LINE 1000
88 |
89 | extern struct ah ah;
90 | struct mg_context *ctx;
91 | struct mg_connection *client;
92 | char auth_ha1[33];
93 | int max_requests = 20;
94 | #define MAX_OPTIONS 50
95 |
96 | profile_interface_t profile_interface;
97 |
98 | bind_socket_module_api_t socket_bind_api;
99 | bind_protocol_module_api_t protocol_bind_api;
100 | bind_transport_module_api_t transport_bind_api;
101 | bind_statistic_module_api_t statistic_bind_api;
102 | bind_database_module_api_t database_bind_api;
103 |
104 | int api_request_handler(struct mg_connection *conn, void *cbdata);
105 | int send_data_x2 (int socket, void *buf, unsigned int len);
106 | int sigPipe(void);
107 | char* read_file(char *name );
108 | int add_base_info(json_object *jobj, char *status, char *description);
109 | void free_module_xml_config();
110 | int load_module_xml_config();
111 | int reload_config (char *erbuf, int len);
112 | int make_file_backup(char * src_path, char * dst_path, int check);
113 |
114 | int proceed_delete_request(struct mg_request_info * request_info, struct mg_connection *conn);
115 | int proceed_post_request(struct mg_request_info * request_info, struct mg_connection *conn);
116 | int proceed_put_request(struct mg_request_info * request_info, struct mg_connection *conn);
117 | int proceed_get_request(struct mg_request_info * request_info, struct mg_connection *conn);
118 | int check_module_xml_config();
119 |
120 | /* Ethernet / IP / UDP header IPv4 */
121 | const int udp_payload_offset = 14+20+8;
122 |
123 | extern struct stats_object stats_obj;
124 |
125 |
126 | #endif
127 |
--------------------------------------------------------------------------------
/src/modules/protocol/diameter/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = \
4 | . \
5 | captureplan
6 |
7 | noinst_HEADERS = parser_diameter.h protocol_diameter.h
8 | #
9 | protocol_diameter_la_SOURCES = protocol_diameter.c parser_diameter.c
10 | protocol_diameter_la_CFLAGS = -Wall ${MODULE_CFLAGS}
11 | protocol_diameter_la_LDFLAGS = -module -avoid-version
12 | protocol_diameter_la_LIBADD = ${PTHREAD_LIBS} ${EXPAT_LIBS}
13 | protocol_diameter_laconfdir = $(confdir)
14 | protocol_diameter_laconf_DATA = $(top_srcdir)/conf/protocol_diameter.xml
15 |
16 | mod_LTLIBRARIES = protocol_diameter.la
17 |
--------------------------------------------------------------------------------
/src/modules/protocol/diameter/captureplan/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 |
5 | capture_planconfdir = $(confdir)/captureplans
6 | capture_planconf_DATA = $(top_srcdir)/conf/captureplans/diameter_capture_plan.cfg
7 |
--------------------------------------------------------------------------------
/src/modules/protocol/diameter/parser_diameter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Michele Campus
8 | *
9 | * (C) QXIP BV 2012-2023 (http://www.sipcapture.org)
10 | *
11 | * Homer capture agent is free software; you can redistribute it and/or modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 3 of the License, or
14 | * (at your option) any later version
15 | *
16 | * Homer capture agent is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License
22 | * along with this program; if not, write to the Free Software
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | *
25 | */
26 | #ifndef PARSER_DIAMETER_H
27 | #define PARSER_DIAMETER_H
28 |
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 | /* Definition of Diameter common info JSON */
35 | #define DIAMETER_HEADER_JSON "\"diameter_info\": {\"class\":\"%s\",\"type\":\"%s\",\"command\":\"%s\",\"app-ID\":%d}"
36 | #define JSON_BUFFER_LEN 5000
37 |
38 | #define UNK -1
39 | // Flags
40 | #define REQ 1
41 | #define ANSW 0
42 | // Classes
43 | #define DIAM_BASE 0
44 | #define _3GPP 1
45 | #define SIP 2
46 | #define CC 3
47 |
48 | /** ############################## COMMANDS ############################## **/
49 |
50 | /**
51 | A Command Code is used to determine the action that is to be taken for a particular message.
52 | Each command Request/Answer pair is assigned a command code.
53 | **/
54 | // Diameter protocol base
55 | typedef enum {
56 | CE = 257,
57 | RA = 258,
58 | AC = 271,
59 | AS = 274,
60 | ST = 275,
61 | DW = 280,
62 | DP = 282
63 | } com_diam_base_t;
64 |
65 | // 3GPP
66 | typedef enum {
67 | // Diameter base
68 | UA = 300,
69 | SA = 301,
70 | LI = 302,
71 | MA = 303,
72 | RT = 304,
73 | PP = 305,
74 | UD = 306,
75 | PU = 307,
76 | SN = 308,
77 | PN = 309,
78 | BI = 310,
79 | MP = 311,
80 | // 3GPP
81 | UL = 316,
82 | CL = 317,
83 | AI = 318,
84 | ID = 319,
85 | DS = 320,
86 | PE = 321,
87 | NO = 323,
88 | EC = 324
89 | } com_diam_3gpp_t;
90 |
91 | // Credit control
92 | typedef enum {
93 | CCC = 272
94 | } com_diam_CC_t;
95 |
96 | // SIP
97 | typedef enum {
98 | UAS = 283,
99 | SAS = 284,
100 | LIS = 285,
101 | MAS = 286,
102 | RTS = 287,
103 | PPS = 288
104 | } com_diam_sip_t;
105 |
106 |
107 | /** ############################## APPLICATION-ID ############################## **/
108 |
109 | /**
110 | Application-ID is used to identify for which Diameter application the message is belong to.
111 | The application can be an authentication application, an accounting application, or a vendor-specific application.
112 | **/
113 | // Diameter protocol base (establishment/teardown/maintenance)
114 | typedef enum {
115 | COMMON_MSG = 0,
116 | NASREQ = 1,
117 | BASE_ACC = 3,
118 | CREDIT_CTRL = 4, // CREDIT CONTROL
119 | SIP_ID = 6, // SIP
120 | QOS = 9,
121 | NAT_CA = 12,
122 | ERP = 13
123 | /* add more if necessary */
124 | } diam_app_id_t;
125 |
126 | // 3GPP protocol
127 | typedef enum {
128 | _3GPP_CX = 16777216, // IMS I/S-CSCF to HSS interface
129 | _3GPP_SH = 16777217, // VoIP/IMS SIP Application Server to HSS interface
130 | _3GPP_RE = 16777218,
131 | _3GPP_WX = 16777219,
132 | _3GPP_ZN = 16777220,
133 | _3GPP_ZH = 16777221,
134 | _3GPP_GQ = 16777222,
135 | _3GPP_GMB = 16777223,
136 | _3GPP_GX = 16777224,
137 | _3GPP_GXoGY = 16777225,
138 | _3GPP_MM10 = 16777226,
139 | _3GPP_PR = 16777230,
140 | _3GPP_RX = 16777236, // Policy and charging control
141 | _3GPP_S6t = 16777345, // Interface between SCEF and HSS
142 | _3GPP_Sta = 16777250,
143 | _3GPP_S6ad = 16777251, // LTE Roaming signaling
144 | _3GPP_S13 = 16777252, // Interface between EIR and MME
145 | _3GPP_SLg = 16777255 // Location services
146 | /* add more if necessary */
147 | } diam_3gpp_app_id_t;
148 |
149 | /******** HEADER STRUCUTRES ********/
150 |
151 | #define DIAM_HEADER_LEN 20
152 |
153 | // DIAMETER header
154 | struct diameter_header_t
155 | {
156 | u_int8_t version;
157 | u_int8_t length[3];
158 | u_int8_t flags;
159 | u_int8_t com_code[3];
160 | u_int32_t app_id;
161 | u_int32_t hop_id;
162 | u_int32_t end_id;
163 | };
164 |
165 | /**
166 | Functions for the dissection
167 | **/
168 | // Parse packet, check if it's Diameter and create JSON buffer with protocol information
169 | int diameter_dissector(const u_char *packet, int size_payload, char *json_buffer, int buffer_len);
170 |
171 | #endif
172 |
--------------------------------------------------------------------------------
/src/modules/protocol/diameter/protocol_diameter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * Michele Campus
9 | *
10 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
11 | *
12 | * Homer capture agent is free software; you can redistribute it and/or modify
13 | * it under the terms of the GNU General Public License as published by
14 | * the Free Software Foundation; either version 3 of the License, or
15 | * (at your option) any later version
16 | *
17 | * Homer capture agent is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU General Public License
23 | * along with this program; if not, write to the Free Software
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 | *
26 | */
27 |
28 | #ifndef PROTOCOL_DIAMETER_H_
29 | #define PROTOCOL_DIAMETER_H_
30 |
31 | #include
32 | #include "parser_diameter.h"
33 |
34 | #define PROTO_DIAMETER 0x38
35 |
36 | typedef struct protocol_diameter_stats {
37 | uint64_t received_packets_total;
38 | uint64_t parsed_packets;
39 | uint64_t send_packets;
40 | } protocol_diameter_stats_t;
41 |
42 | static protocol_diameter_stats_t stats;
43 |
44 | #define MAX_PROTOCOLS 10
45 | profile_protocol_t profile_protocol[MAX_PROTOCOLS];
46 |
47 | int bind_api(protocol_module_api_t* api);
48 | int reload_config (char *erbuf, int erlen);
49 | void free_module_xml_config();
50 | int load_module_xml_config();
51 |
52 | /** Functions for DIAMETER **/
53 | int w_parse_diameter_to_json(msg_t *msg);
54 |
55 | #endif /* PROTOCOL_DIAMETER_H_ */
56 |
--------------------------------------------------------------------------------
/src/modules/protocol/epan/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = \
4 | .
5 |
6 | noinst_HEADERS =
7 | #
8 | protocol_epan_la_SOURCES = protocol_epan.c
9 | protocol_epan_la_CFLAGS = -Wall ${MODULE_CFLAGS}
10 | protocol_epan_la_LDFLAGS = -module -avoid-version
11 | protocol_epan_la_LIBADD = ${PTHREAD_LIBS} ${EXPAT_LIBS} ${PCAP_LIBS}
12 | protocol_epan_laconfdir = $(confdir)
13 | protocol_epan_laconf_DATA = $(top_srcdir)/conf/protocol_epan.xml
14 |
15 | mod_LTLIBRARIES = protocol_epan.la
16 |
17 |
--------------------------------------------------------------------------------
/src/modules/protocol/epan/protocol_epan.c:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2016 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | #include
33 | #include
34 |
35 |
36 | static uint64_t module_serial = 0;
37 |
38 | static cmd_export_t epan_cmds[] = {
39 | {
40 | .name = "parse_epan",
41 | .function = epan_parse,
42 | .param_no = 0,
43 | .flags = 0,
44 | .fixup_flags = 0,
45 | },
46 | { 0, },
47 | };
48 |
49 | struct module_exports exports = {
50 | .name = "protocol_epan",
51 | .cmds = epan_cmds,
52 | .load_f = epan_load_module,
53 | .unload_f = epan_unload_module,
54 | .description_f = epan_description,
55 | .stats_f = epan_statistic,
56 | .serial_f = epan_serial_module,
57 | };
58 |
59 |
60 | static int epan_load_module(xml_node *config)
61 | {
62 | return 0;
63 | }
64 |
65 | static int epan_unload_module(void)
66 | {
67 | return 0;
68 | }
69 |
70 | static int epan_description(char *description)
71 | {
72 | return 1;
73 | }
74 |
75 | static int epan_statistic(char *buf, size_t len)
76 | {
77 | return 1;
78 | }
79 |
80 | static uint64_t epan_serial_module(void)
81 | {
82 | return module_serial;
83 | }
84 |
--------------------------------------------------------------------------------
/src/modules/protocol/rtcp/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = \
4 | . \
5 | captureplan
6 |
7 | noinst_HEADERS = parser_rtcp.h protocol_rtcp.h
8 | #
9 | protocol_rtcp_la_SOURCES = protocol_rtcp.c parser_rtcp.c
10 | protocol_rtcp_la_CFLAGS = -Wall ${MODULE_CFLAGS}
11 | protocol_rtcp_la_LDFLAGS = -module -avoid-version
12 | protocol_rtcp_la_LIBADD = ${PTHREAD_LIBS} ${EXPAT_LIBS}
13 | protocol_rtcp_laconfdir = $(confdir)
14 | protocol_rtcp_laconf_DATA = $(top_srcdir)/conf/protocol_rtcp.xml
15 |
16 | mod_LTLIBRARIES = protocol_rtcp.la
17 |
--------------------------------------------------------------------------------
/src/modules/protocol/rtcp/captureplan/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 |
5 | capture_planconfdir = $(confdir)/captureplans
6 | capture_planconf_DATA = $(top_srcdir)/conf/captureplans/rtcp_capture_plan.cfg
7 |
--------------------------------------------------------------------------------
/src/modules/protocol/rtcp/protocol_rtcp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #ifndef _PROTOCOL_RTCP_H_
27 | #define _PROTOCOL_RTCP_H_
28 |
29 | #include
30 | #include "parser_rtcp.h"
31 |
32 |
33 | /* SYNC this list: http://hep.sipcapture.org */
34 | #define PROTO_RTCP_JSON 0x05
35 |
36 | typedef struct protocol_rtcp_stats {
37 | uint64_t received_packets_total;
38 | uint64_t parsed_packets;
39 | uint64_t send_packets;
40 | } protocol_rtcp_stats_t;
41 |
42 | static protocol_rtcp_stats_t stats;
43 |
44 | char sip_callid[250];
45 | int rtcp_port = 0;
46 | char *rtcp_portrange = NULL;
47 | char *rtcp_userfilter=NULL;
48 | int rtcp_proto_type = PROTO_RTCP_JSON; /* DEFAULT RTCP */
49 | int rtcp_promisc = 1;
50 | int rtcp_vlan = 0; /*vlan filter*/
51 | int rtcp_as_json = 1;
52 | int send_sdes = 1;
53 |
54 | #define JSON_BUFFER_LEN 5000
55 |
56 | #define MAX_PROTOCOLS 10
57 | profile_protocol_t profile_protocol[MAX_PROTOCOLS];
58 |
59 | int w_parse_rtcp_to_json(msg_t *_m);
60 | int w_set_rtcp_flag(msg_t *msg);
61 | int w_is_rtcp (msg_t *msg);
62 | int w_is_rtcp_or_rtp (msg_t *msg);
63 |
64 |
65 | int bind_api(protocol_module_api_t* api);
66 |
67 | void free_module_xml_config();
68 | int load_module_xml_config();
69 | int reload_config (char *erbuf, int erlen);
70 | int check_module_xml_config();
71 |
72 | #endif /* _PROTOCOL_RTCP_H_ */
73 |
--------------------------------------------------------------------------------
/src/modules/protocol/rtcpxr/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = \
4 | . \
5 | captureplan
6 |
7 | noinst_HEADERS = parser_rtcpxr.h protocol_rtcpxr.h
8 | #
9 | protocol_rtcpxr_la_SOURCES = protocol_rtcpxr.c parser_rtcpxr.c
10 | protocol_rtcpxr_la_CFLAGS = -Wall ${MODULE_CFLAGS}
11 | protocol_rtcpxr_la_LDFLAGS = -module -avoid-version
12 | protocol_rtcpxr_la_LIBADD = ${PTHREAD_LIBS} ${EXPAT_LIBS}
13 | protocol_rtcpxr_laconfdir = $(confdir)
14 | protocol_rtcpxr_laconf_DATA = $(top_srcdir)/conf/protocol_rtcpxr.xml
15 |
16 | mod_LTLIBRARIES = protocol_rtcpxr.la
17 |
--------------------------------------------------------------------------------
/src/modules/protocol/rtcpxr/captureplan/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 |
5 | capture_planconfdir = $(confdir)/captureplans
6 | capture_planconf_DATA = $(top_srcdir)/conf/captureplans/rtcpxr_capture_plan.cfg
7 |
--------------------------------------------------------------------------------
/src/modules/protocol/rtcpxr/protocol_rtcpxr.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * Michele Campus
9 | *
10 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
11 | *
12 | * Homer capture agent is free software; you can redistribute it and/or modify
13 | * it under the terms of the GNU General Public License as published by
14 | * the Free Software Foundation; either version 3 of the License, or
15 | * (at your option) any later version
16 | *
17 | * Homer capture agent is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU General Public License
23 | * along with this program; if not, write to the Free Software
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 | *
26 | */
27 |
28 | #ifndef PROTOCOL_RTCPXR_H_
29 | #define PROTOCOL_RTCPXR_H_
30 |
31 | #include
32 | #include "parser_rtcpxr.h"
33 |
34 | typedef struct protocol_rtcpxr_stats {
35 | uint64_t received_packets_total;
36 | uint64_t parsed_packets;
37 | uint64_t send_packets;
38 | } protocol_rtcpxr_stats_t;
39 |
40 | static protocol_rtcpxr_stats_t stats;
41 |
42 | #define MAX_PROTOCOLS 10
43 | profile_protocol_t profile_protocol[MAX_PROTOCOLS];
44 |
45 | int bind_api(protocol_module_api_t* api);
46 | int reload_config (char *erbuf, int erlen);
47 | void free_module_xml_config();
48 | int load_module_xml_config();
49 |
50 | /** Functions for RTCP-XR **/
51 | int w_parse_rtcpxr_to_json(msg_t *msg);
52 | int w_is_rtcpxr(msg_t *msg);
53 |
54 | #endif /* PROTOCOL_RTCPXR_H_ */
55 |
--------------------------------------------------------------------------------
/src/modules/protocol/sip/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = \
4 | . \
5 | captureplan
6 |
7 | noinst_HEADERS = parser_sip.h protocol_sip.h
8 | #
9 | protocol_sip_la_SOURCES = protocol_sip.c parser_sip.c
10 | protocol_sip_la_CFLAGS = -Wall ${MODULE_CFLAGS}
11 | protocol_sip_la_LDFLAGS = -module -avoid-version
12 | protocol_sip_la_LIBADD = ${PTHREAD_LIBS} ${EXPAT_LIBS} ${PCAP_LIBS} -lpcre
13 | protocol_sip_laconfdir = $(confdir)
14 | protocol_sip_laconf_DATA = $(top_srcdir)/conf/protocol_sip.xml
15 |
16 | mod_LTLIBRARIES = protocol_sip.la
17 |
--------------------------------------------------------------------------------
/src/modules/protocol/sip/captureplan/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 |
5 | capture_planconfdir = $(confdir)/captureplans
6 | capture_planconf_DATA = $(top_srcdir)/conf/captureplans/sip_capture_plan.cfg
7 |
--------------------------------------------------------------------------------
/src/modules/protocol/sip/parser_sip.h:
--------------------------------------------------------------------------------
1 | /*
2 | * parser_sip.h
3 | *
4 | * Created on: Sep 1, 2014
5 | * Author: shurik
6 | */
7 |
8 | #ifndef _PARSE_SIP_H
9 | #define _PARSE_SIP_H
10 |
11 | #include
12 |
13 | #define MAX_PARSE_LEN 256
14 |
15 | int set_hname(str *hname, int len, char *s);
16 | int parse_message(char *message, unsigned int blen, unsigned int* bytes_parsed, sip_msg_t *psip, unsigned int type);
17 | int parseSdp(char *body, sip_msg_t *psip);
18 | int parseSdpCLine(miprtcp_t *mp, char *data, int len);
19 | int parseSdpALine(miprtcp_t *mp, char *data, int len);
20 | int parseSdpMLine(miprtcp_t *mp, char *data, int len);
21 | int light_parse_message(char *message, unsigned int blen, unsigned int* bytes_parsed, sip_msg_t *psip);
22 | int check_len_message(unsigned char *message, unsigned int blen);
23 | int check_sip_message(unsigned char *message, unsigned int blen);
24 | int w_sip_has_sdp(msg_t *_m);
25 |
26 |
27 | bool getUser(str *user, str *domain, char *s, int len);
28 | bool getTag(str *hname, char *uri, int len);
29 | int parseVQRtcpXR(char *body, sip_msg_t *psip);
30 |
31 |
32 |
33 | extern char* global_config_path;
34 |
35 | #endif /* _PARSE_SIP_H */
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/modules/protocol/sip/protocol_sip.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #ifndef _PROTOCOL_SIP_H_
27 | #define _PROTOCOL_SIP_H_
28 |
29 | #include
30 | #include
31 | #include "parser_sip.h"
32 |
33 | #define FILTER_LEN 4080
34 |
35 | bind_transport_module_api_t transport_bind_api;
36 | bind_database_module_api_t database_bind_api;
37 |
38 | /* SYNC this list: http://hep.sipcapture.org */
39 | #define PROTO_SIP 0x01
40 | #define PROTO_XMPP 0x02
41 | #define PROTO_SDP 0x03
42 | #define PROTO_RTP 0x04
43 | #define PROTO_RTCP 0x05
44 | #define PROTO_MGCP 0x06
45 | #define PROTO_MEGACO 0x07
46 | #define PROTO_M2UA 0x08
47 | #define PROTO_M3UA 0x09
48 | #define PROTO_IAX 0x0a
49 | #define PROTO_H322 0x0b
50 | #define PROTO_H321 0x0c
51 |
52 | typedef struct protocol_sip_stats {
53 | uint64_t received_packets_total;
54 | uint64_t parsed_packets;
55 | uint64_t send_packets;
56 | } protocol_sip_stats_t;
57 |
58 | static protocol_sip_stats_t stats;
59 |
60 | extern int handler(int value);
61 | extern int set_raw_rtp_filter();
62 |
63 | uint32_t pcre_options = PCRE_UNGREEDY|PCRE_CASELESS;
64 | int32_t err_offset;
65 | char *re_err = NULL;
66 |
67 | #define MAX_PROTOCOLS 10
68 | profile_protocol_t profile_protocol[MAX_PROTOCOLS];
69 |
70 | profile_protocol_t* get_profile_by_name(char *name);
71 | unsigned int get_profile_index_by_name(char *name);
72 | int bind_api(protocol_module_api_t* api);
73 | int set_value(unsigned int idx, msg_t *msg);
74 | int parse_packet(msg_t *msg, sip_msg_t *sipPacket, unsigned int type);
75 | int parse_only_packet(msg_t *msg, void* packet);
76 | int parse_sip(msg_t *msg, unsigned int type);
77 | int w_light_parse_sip(msg_t *_m);
78 | int w_parse_full_sip(msg_t *_m);
79 | int light_parse_sip(msg_t *msg);
80 |
81 |
82 |
83 | void free_module_xml_config();
84 | int load_module_xml_config();
85 | int reload_config (char *erbuf, int erlen);
86 | int check_module_xml_config();
87 | int makeEscape(const char *s, int len, char *out, int max);
88 |
89 | /* API */
90 | int w_proto_check_size(msg_t *_m, char *param1, char *param2);
91 | int w_parse_sip(msg_t *_m);
92 | int w_clog(msg_t *_m, char *param1, char* param2);
93 | int w_sip_is_method(msg_t *_m);
94 | int w_sip_check(msg_t *_m, char *param1, char *param2);
95 | int w_header_check(msg_t *_m, char *param1, char *param2);
96 | int8_t re_match_func (pcre *pattern, char *data, uint32_t len);
97 | int w_header_reg_match(msg_t *_m, char *param1, char *param2);
98 |
99 | int w_send_reply_p(msg_t *_m, char *param1, char *param2);
100 | int w_send_reply(msg_t *_m);
101 | int w_set_tag(msg_t *_m, char *param1, char *param2);
102 | int send_sip_reply(msg_t *_m, int code, char *description);
103 | int w_is_flag_set(msg_t *_m, char *param1, char *param2);
104 |
105 | int endswith(str *str, const char *suffix);
106 | int startwith(str *str, const char *suffix);
107 |
108 | uint8_t get_pcre_index_by_name(char *name);
109 | void free_regexp();
110 |
111 |
112 | #endif /* _PROTOCOL_SIP_H_ */
113 |
--------------------------------------------------------------------------------
/src/modules/protocol/ss7/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = \
4 | .
5 |
6 | noinst_HEADERS =
7 | #
8 | protocol_ss7_la_SOURCES = protocol_ss7.c isup_generated.c isup_parsed.c srjson.c
9 | protocol_ss7_la_CFLAGS = -Wall ${MODULE_CFLAGS}
10 | protocol_ss7_la_LDFLAGS = -module -avoid-version
11 | protocol_ss7_la_LIBADD = ${PTHREAD_LIBS} ${EXPAT_LIBS} ${PCAP_LIBS} -lm
12 | protocol_ss7_laconfdir = $(confdir)
13 | protocol_ss7_laconf_DATA = $(top_srcdir)/conf/protocol_ss7.xml
14 |
15 | mod_LTLIBRARIES = protocol_ss7.la
16 |
--------------------------------------------------------------------------------
/src/modules/protocol/ss7/isup_parsed.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ss7 module - ISUP parsed
3 | *
4 | * Copyright (C) 2016 Holger Hans Peter Freyther (help@moiji-mobile.com)
5 | * *
6 | */
7 | #pragma once
8 |
9 | #include
10 | #include
11 |
12 | #include "srjson.h"
13 |
14 | /**
15 | * State structure
16 | */
17 | struct isup_state {
18 | srjson_doc_t* json;
19 | };
20 |
21 | enum {
22 | ISUP_JSON_STRING,
23 | ISUP_FIELD_METHOD,
24 | ISUP_FIELD_OPC,
25 | ISUP_FIELD_DPC,
26 | ISUP_FIELD_CIC,
27 | ISUP_FIELD_CALLED_INN,
28 | ISUP_FIELD_CALLED_TON,
29 | ISUP_FIELD_CALLED_NPI,
30 | ISUP_FIELD_CALLED_NUM,
31 | ISUP_FIELD_CALLING_NI,
32 | ISUP_FIELD_CALLING_RESTRICT,
33 | ISUP_FIELD_CALLING_SCREENED,
34 | ISUP_FIELD_CALLING_TON,
35 | ISUP_FIELD_CALLING_NPI,
36 | ISUP_FIELD_CALLING_NUM,
37 | ISUP_FIELD_CALLING_CAT,
38 | ISUP_FIELD_CAUSE_STD,
39 | ISUP_FIELD_CAUSE_LOC,
40 | ISUP_FIELD_CAUSE_ITU_CLASS,
41 | ISUP_FIELD_CAUSE_ITU_NUM,
42 | ISUP_FIELD_EVENT_NUM,
43 | ISUP_FIELD_HOP_COUNTER,
44 | ISUP_FIELD_NOC_SAT,
45 | ISUP_FIELD_NOC_CHECK,
46 | ISUP_FIELD_NOC_ECHO,
47 | ISUP_FIELD_FWD_INTE,
48 | ISUP_FIELD_FWD_INTW,
49 | ISUP_FIELD_FWD_EE_METH,
50 | ISUP_FIELD_FWD_EE_INF,
51 | ISUP_FIELD_FWD_ISUP_NUM,
52 | ISUP_FIELD_FWD_ISUP_PREF,
53 | ISUP_FIELD_FWD_SCCP_METHOD,
54 | ISUP_FIELD_FWD_ISDN,
55 | ISUP_FIELD_MEDIUM,
56 | ISUP_FILED_UI_CODING,
57 | ISUP_FIELD_UI_TRANS_CAP,
58 | ISUP_FIELD_UI_TRANS_MODE,
59 | ISUP_FIELD_UI_TRANS_RATE,
60 | ISUP_FIELD_UI_LAYER1_IDENT,
61 | ISUP_FIELD_UI_LAYER1_PROTOCOL,
62 | };
63 |
64 | int isup_parse(const uint8_t *data, size_t len, struct isup_state *ptrs, uint16_t *cic);
65 |
--------------------------------------------------------------------------------
/src/modules/protocol/tls/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = \
4 | . \
5 | captureplan
6 |
7 | noinst_HEADERS = protocol_tls.h localapi.h uthash.h parser_tls.h define.h decryption.h
8 | #
9 | protocol_tls_la_SOURCES = protocol_tls.c localapi.c parser_tls.c decryption.c
10 | protocol_tls_la_CFLAGS = -Wall ${MODULE_CFLAGS}
11 | protocol_tls_la_LDFLAGS = -I/usr/include/openssl -module -avoid-version
12 | protocol_tls_la_LIBADD = ${PTHREAD_LIBS} ${EXPAT_LIBS} ${GCRYPT_LIBS} ${CRYPTO_LIBS} -lm
13 | protocol_tls_laconfdir = $(confdir)
14 | protocol_tls_laconf_DATA = $(top_srcdir)/conf/protocol_tls.xml
15 |
16 | mod_LTLIBRARIES = protocol_tls.la
17 |
--------------------------------------------------------------------------------
/src/modules/protocol/tls/captureplan/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 |
5 | capture_planconfdir = $(confdir)/captureplans
6 | capture_planconf_DATA = $(top_srcdir)/conf/captureplans/tls_capture_plan.cfg
7 |
--------------------------------------------------------------------------------
/src/modules/protocol/tls/define.h:
--------------------------------------------------------------------------------
1 | /**
2 | Definition of macro and header size
3 |
4 | Copyright (C) 2016-2017 Michele Campus
5 | (C) QXIP BV 2012-2023 (http://qxip.net)
6 |
7 | Homer capture agent is free software; you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation; either version 3 of the License, or
10 | (at your option) any later version
11 |
12 | Homer capture agent is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program; if not, write to the Free Software
19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 | **/
21 | #ifndef DEFINE_H_
22 | #define DEFINE_H_
23 |
24 | /* Header offsets */
25 | #define ETHHDR_SIZE 14
26 | #define TOKENRING_SIZE 22
27 | #define PPPHDR_SIZE 4
28 | #define SLIPHDR_SIZE 16
29 | #define RAWHDR_SIZE 0
30 | #define LOOPHDR_SIZE 4
31 | #define FDDIHDR_SIZE 21
32 | #define ISDNHDR_SIZE 16
33 | #define IEEE80211HDR_SIZE 32
34 |
35 | #define IPv4 4
36 | #define IPv6 6
37 |
38 | /* IPV6 header length */
39 | #define IPV6_HDR_LEN 40
40 | /* UDP header length */
41 | #define UDP_HDR_LEN 8
42 |
43 | /* Ethernet protocol ID's from Ether Type field */
44 | #define ETHERTYPE_ARP 0x0806 /* Address resolution */
45 | #define ETHERTYPE_RARP 0x8035 /* Reverse ARP */
46 | #define ETHERTYPE_APPLETLK 0x809B /* AppleTalk protocol */
47 | #define ETHERTYPE_APPLEARP 0x80F3 /* AppleTalk ARP */
48 | #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */
49 | #define ETHERTYPE_IPv4 0x0800 /* IP */
50 | #define ETHERTYPE_IPv6 0x86dd /* IP protocol version 6 */
51 | #define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */
52 | #define ETHERTYPE_MPLS_UNI 0x8847
53 | #define ETHERTYPE_MPLS_MULTI 0x8848
54 | #define ETHERTYPE_PPPoE_1 0x8863
55 | #define ETHERTYPE_PPPoE 0x8864
56 | #define ETHERTYPE_LLDP 0x88CC
57 |
58 | /* SNAP extension */
59 | #define SNAP 0xaa
60 |
61 | /* mask for FCF */
62 | #define WIFI_DATA 0x2 /* 0000 0010 */
63 | #define FCF_TYPE(fc) (((fc) >> 2) & 0x3) /* 0000 0011 = 0x3 */
64 | #define FCF_SUBTYPE(fc) (((fc) >> 4) & 0xF) /* 0000 1111 = 0xF */
65 | #define FCF_TO_DS(fc) ((fc) & 0x0100)
66 | #define FCF_FROM_DS(fc) ((fc) & 0x0200)
67 | /* mask for Bad FCF presence */
68 | #define BAD_FCS 0x50 /* 0101 0000 */
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/src/modules/protocol/tls/hash_structure.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #ifndef HASH_STRUCTURE_H_
27 | #define HASH_STRUCTURE_H_
28 |
29 | typedef struct ipport_items {
30 | char name[400];
31 | char ip[250];
32 | int port;
33 | char sessionid[250];
34 | long create_ts;
35 | long modify_ts;
36 | UT_hash_handle hh;
37 | } ipport_items_t;
38 |
39 |
40 | #endif /* HASH_STRUCTURE_H_ */
41 |
--------------------------------------------------------------------------------
/src/modules/protocol/tls/localapi.c:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include "localapi.h"
33 |
34 | char* hashapi_lookup(char *ip, int port)
35 | {
36 | //LERR("LOOKUP IP: [%s], PORT: [%d]", ip, port);
37 | return NULL;
38 | }
39 |
40 | int bind_protocol_tcp(protocol_tcp_api_t* api)
41 | {
42 | if (!api) {
43 | LERR("Invalid parameter value\n");
44 | return -1;
45 |
46 | }
47 |
48 | api->lookup = hashapi_lookup;
49 |
50 | return 0;
51 | }
52 |
53 |
54 |
--------------------------------------------------------------------------------
/src/modules/protocol/tls/localapi.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 |
27 | #ifndef LOCAL_API_H_
28 | #define LOCAL_API_H_
29 |
30 | #include
31 | #include
32 |
33 | /* ### CAPTAGENT FUNCTIONS ### */
34 |
35 | typedef char* (*hashapi_lookup_f)(char *ip, int port);
36 | char* hashapi_lookup(char *ip, int port);
37 |
38 |
39 | typedef struct protocol_tcp_api {
40 | hashapi_lookup_f lookup;
41 | } protocol_tcp_api_t;
42 |
43 | typedef int (*bind_protocol_tcp_f)(protocol_tcp_api_t* api);
44 | int bind_protocol_tcp(protocol_tcp_api_t* api);
45 |
46 | /**
47 | * @brief Load the protocol_tcp API
48 | */
49 | static inline int protocol_tcp_load_api(protocol_tcp_api_t *api)
50 | {
51 | bind_protocol_tcp_f bindprotocol_tcp;
52 |
53 | bindprotocol_tcp = (bind_protocol_tcp_f)find_export("bind_protocol_tcp", 0, 0);
54 |
55 | if(bindprotocol_tcp == 0) {
56 | LERR("cannot find bind_protocol_tcp\n");
57 | return -1;
58 | }
59 |
60 | if (bindprotocol_tcp(api) < 0)
61 | {
62 | LERR("cannot bind protocol_tcp api\n");
63 | return -1;
64 | }
65 |
66 | return 0;
67 | }
68 |
69 |
70 |
71 | #endif /* LOCAL_API_H_ */
72 |
--------------------------------------------------------------------------------
/src/modules/protocol/tls/protocol_tls.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) QXIP BV 2012-2023 (http://qxip.net)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 | #ifndef PROTOCOL_TCP_H_
26 | #define PROTOCOL_TCP_H_
27 |
28 | #include
29 | #include "uthash.h"
30 |
31 | typedef struct protocol_tcp_stats {
32 | uint64_t received_packets_total;
33 | uint64_t parsed_packets;
34 | uint64_t send_packets;
35 | } protocol_tcp_stats_t;
36 |
37 | // static protocol_tcp_stats_t stats;
38 |
39 | #define MAX_PROTOCOLS 10
40 | profile_protocol_t profile_protocol[MAX_PROTOCOLS];
41 |
42 | int bind_api(protocol_module_api_t* api);
43 | int reload_config(char *erbuf, int erlen);
44 | void free_module_xml_config();
45 | int load_module_xml_config();
46 |
47 | /** Functions for TLS **/
48 | int w_parse_tls(msg_t *msg);
49 |
50 | #endif /* PROTOCOL_TCP_H_ */
51 |
--------------------------------------------------------------------------------
/src/modules/socket/collector/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = \
4 | . \
5 | captureplan
6 |
7 | noinst_HEADERS = socket_collector.h
8 | #
9 | socket_collector_la_SOURCES = socket_collector.c
10 | socket_collector_la_CFLAGS = -Wall ${MODULE_CFLAGS}
11 | socket_collector_la_LDFLAGS = -module -avoid-version
12 | socket_collector_la_LIBADD = ${PTHREAD_LIBS} ${EXPAT_LIBS} ${collector_LIBS} ${UV_LIBS}
13 | socket_collector_laconfdir = $(confdir)
14 | socket_collector_laconf_DATA = $(top_srcdir)/conf/socket_collector.xml
15 |
16 | mod_LTLIBRARIES = socket_collector.la
17 |
--------------------------------------------------------------------------------
/src/modules/socket/collector/captureplan/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 |
5 | capture_planconfdir = $(confdir)/captureplans
6 | capture_planconf_DATA = $(top_srcdir)/conf/captureplans/rtcpxr_capture_plan.cfg
7 |
--------------------------------------------------------------------------------
/src/modules/socket/collector/socket_collector.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #ifndef SOCKET_COLLECTOR_H_
27 | #define SOCKET_COLLECTOR_H_
28 |
29 | #include
30 | #include
31 |
32 | #define FILTER_LEN 4080
33 |
34 | #define PROTO_SIP 0x01
35 | #define PROTO_REPORT 0x63
36 |
37 | #define JSON_BUFFER_LEN 5000
38 |
39 | extern char *global_config_path;
40 | extern char *global_scripts_path;
41 |
42 | extern int handler(int value);
43 |
44 | #define MAX_SOCKETS 10
45 |
46 | typedef struct socket_rtcpxr_stats {
47 | uint64_t received_packets_total;
48 | uint64_t received_tcp_packets;
49 | uint64_t received_udp_packets;
50 | uint64_t received_sctp_packets;
51 | uint64_t send_packets;
52 | } socket_rtcpxr_stats_t;
53 |
54 | extern FILE* yyin;
55 | extern int yyparse();
56 |
57 | int bind_api(socket_module_api_t* api);
58 | int reload_config (char *erbuf, int erlen);
59 | void free_module_xml_config();
60 | int load_module_xml_config();
61 |
62 | void _run_uv_loop(void *arg);
63 | int close_socket(unsigned int loc_idx);
64 | void on_send(uv_udp_send_t* req, int status);
65 | int send_sip_rtcpxr_reply(msg_t *_m, int code, char *description);
66 | int w_send_rtcpxr_reply_p(msg_t *_m, char *param1, char *param2);
67 | int w_send_rtcpxr_reply(msg_t *_m);
68 |
69 | #if UV_VERSION_MAJOR == 0
70 | uv_buf_t on_alloc(uv_handle_t* client, size_t suggested);
71 | void on_recv(uv_udp_t* handle, ssize_t nread, uv_buf_t rcvbuf, struct sockaddr* addr, unsigned flags);
72 | void _async_callback(uv_async_t *async, int status);
73 | #else
74 | void on_alloc(uv_handle_t* client, size_t suggested, uv_buf_t* buf);
75 | void on_recv(uv_udp_t* handle, ssize_t nread, const uv_buf_t* rcvbuf, const struct sockaddr* addr, unsigned flags);
76 | void _async_callback(uv_async_t *async);
77 | #endif
78 |
79 | #endif /* SOCKET_COLLECTOR_H_ */
80 |
--------------------------------------------------------------------------------
/src/modules/socket/pcap/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = \
4 | .
5 |
6 | noinst_HEADERS = ipreasm.h socket_pcap.h localapi.h tcpreasm.h sctp_support.h uthash.h
7 | #
8 | socket_pcap_la_SOURCES = socket_pcap.c ipreasm.c localapi.c tcpreasm.c sctp_support.c
9 | socket_pcap_la_CFLAGS = -Wall ${MODULE_CFLAGS} ${LUA_CFLAGS}
10 | socket_pcap_la_LDFLAGS = -module -avoid-version
11 | socket_pcap_la_LIBADD = ${PTHREAD_LIBS} ${EXPAT_LIBS} ${PCAP_LIBS} ${LUA_LIBS}
12 | socket_pcap_laconfdir = $(confdir)
13 | socket_pcap_laconf_DATA = $(top_srcdir)/conf/socket_pcap.xml
14 |
15 | mod_LTLIBRARIES = socket_pcap.la
16 |
--------------------------------------------------------------------------------
/src/modules/socket/pcap/ipreasm.h:
--------------------------------------------------------------------------------
1 | #ifndef _IPREASM_H
2 | #define _IPREASM_H
3 |
4 | #include
5 |
6 | #include
7 |
8 |
9 | /*
10 | * This is an abstract time stamp. ipreasm doesn't care whether it is
11 | * in seconds, milliseconds, or nanodecades. All it does it add the
12 | * configured timeout value to it, and then compare it to the timstamps
13 | * of subsequent packets to decide whether a fragment has expired.
14 | */
15 | typedef uint64_t reasm_time_t;
16 |
17 | struct reasm_ip;
18 |
19 | /*
20 | * Functions to create and destroy the reassembly environment.
21 | */
22 | struct reasm_ip *reasm_ip_new (void);
23 | void reasm_ip_free (struct reasm_ip *reasm);
24 |
25 | /*
26 | * This is the main packet processing function. It inputs one packet,
27 | * and MAY output one packet in turn. If the input was not a fragment,
28 | * it is passed unmodified. If the input was a fragment that completed
29 | * reassembly of a packet, the reassembled packet is output.
30 | * If more fragments are required for reassembly, or the input packet
31 | * is invalid for some reason, a NULL pointer is returned.
32 | *
33 | * The input must be a pointer allocated by malloc(). The output will
34 | * be a pointer allocated by malloc().
35 | *
36 | * Note that in the case of an IPv6 fragment, the input buffer will be
37 | * modified in-place. This is considered a bug and should be fixed in
38 | * the future.
39 | */
40 | unsigned char *reasm_ip_next (struct reasm_ip *reasm, unsigned char *packet, unsigned len, reasm_time_t timestamp, unsigned *output_len);
41 |
42 | /*
43 | * Set the timeout after which a noncompleted reassembly expires, in
44 | * abstract time units (see above for the definition of reasm_time_t).
45 | */
46 | bool reasm_ip_set_timeout (struct reasm_ip *reasm, reasm_time_t timeout);
47 |
48 | /*
49 | * Query certain information about the current state.
50 | */
51 | unsigned reasm_ip_waiting (const struct reasm_ip *reasm);
52 | unsigned reasm_ip_max_waiting (const struct reasm_ip *reasm);
53 | unsigned reasm_ip_timed_out (const struct reasm_ip *reasm);
54 | unsigned reasm_ip_dropped_frags (const struct reasm_ip *reasm);
55 |
56 |
57 | #endif /* _IPREASM_H */
58 |
--------------------------------------------------------------------------------
/src/modules/socket/pcap/localapi.c:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 |
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include "localapi.h"
35 |
36 |
37 | /**
38 | *
39 | */
40 | int rawapi_set_filter(unsigned int index, char *filter)
41 | {
42 | set_raw_filter(index, filter);
43 | return 1;
44 | }
45 |
46 | pcap_t* rawapi_get_pcap_handler(unsigned int loc_idx)
47 | {
48 | return get_pcap_handler(loc_idx);
49 | }
50 |
51 |
52 | /**
53 | *
54 | */
55 | int bind_socket_pcap(socket_pcap_api_t* api)
56 | {
57 | if (!api) {
58 | LERR("Invalid parameter value\n");
59 | return -1;
60 |
61 | }
62 |
63 | api->setfilter = rawapi_set_filter;
64 | api->getpcaphandler = rawapi_get_pcap_handler;
65 |
66 | return 0;
67 | }
68 |
69 |
70 |
--------------------------------------------------------------------------------
/src/modules/socket/pcap/localapi.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #ifndef SOCKET_RAW_API_H_
27 | #define SOCKET_RAW_API_H_
28 |
29 | #include
30 | #include
31 |
32 | extern int set_raw_filter(unsigned int loc_idx, char *filter);
33 | extern pcap_t* get_pcap_handler(unsigned int loc_idx);
34 |
35 |
36 | typedef int (*rawapi_set_filter_f)(unsigned int index, char *filter);
37 | int rawapi_set_filter(unsigned int index, char *filter);
38 |
39 | typedef pcap_t* (*rawapi_get_pcap_handler_f)(unsigned int loc_idx);
40 | pcap_t* rawapi_get_pcap_handler(unsigned int loc_idx);
41 |
42 |
43 | typedef struct socket_pcap_api {
44 | rawapi_set_filter_f setfilter;
45 | rawapi_get_pcap_handler_f getpcaphandler;
46 | } socket_pcap_api_t;
47 |
48 | typedef int (*bind_socket_pcap_f)(socket_pcap_api_t* api);
49 | int bind_socket_pcap(socket_pcap_api_t* api);
50 |
51 | /**
52 | * @brief Load the socket_pcap API
53 | */
54 | static inline int socket_pcap_load_api(socket_pcap_api_t *api)
55 | {
56 | bind_socket_pcap_f bindsocket_pcap;
57 |
58 | bindsocket_pcap = (bind_socket_pcap_f)find_export("bind_socket_pcap", 0, 0);
59 | if(bindsocket_pcap == 0) {
60 | LERR("cannot find bind_socket_pcap\n");
61 | return -1;
62 | }
63 | if (bindsocket_pcap(api) < 0)
64 | {
65 | LERR("cannot bind socket_pcap api\n");
66 | return -1;
67 | }
68 | return 0;
69 | }
70 |
71 |
72 |
73 | #endif /* SOCKET_RAW_API_H_ */
74 |
--------------------------------------------------------------------------------
/src/modules/socket/pcap/sctp_support.c:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Holger Hans Peter Freyther
8 | * (C) Homer Project 2016 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #include "sctp_support.h"
27 |
28 | #include
29 |
30 |
31 | int sctp_parse_common(msg_t *_msg, const uint8_t *data, size_t len)
32 | {
33 | struct sctp_common_hdr *sctp_hdr;
34 |
35 | /* not enough space for the header */
36 | if (len < sizeof(*sctp_hdr)) {
37 | LDEBUG("sctp: data too short %zu vs. %zu", len, sizeof(*sctp_hdr));
38 | return -1;
39 | }
40 |
41 | sctp_hdr = (struct sctp_common_hdr *) data;
42 | _msg->rcinfo.src_port = ntohs(sctp_hdr->source);
43 | _msg->rcinfo.dst_port = ntohs(sctp_hdr->dest);
44 | return sizeof(*sctp_hdr);;
45 | }
46 |
47 | int sctp_parse_chunk(msg_t *_msg, const uint8_t *data, size_t len, bool *send_data)
48 | {
49 | struct sctp_chunk_data_hdr *dhdr;
50 | uint16_t chunk_len;
51 |
52 | *send_data = false;
53 | if (len < sizeof(struct sctp_chunk_hdr)) {
54 | LDEBUG("sctp: chunk too short %zu vs. %zu",
55 | len, sizeof(struct sctp_chunk_hdr));
56 | return -1;
57 | }
58 |
59 | /* length smaller than the header */
60 | dhdr = (struct sctp_chunk_data_hdr *) data;
61 | chunk_len = ntohs(dhdr->len);
62 | if (chunk_len < sizeof(*dhdr)) {
63 | LDEBUG("sctp: chunk hdr too short %zu vs. %zu",
64 | chunk_len, sizeof(*dhdr));
65 | return -2;
66 | }
67 |
68 | if (chunk_len > len) {
69 | LDEBUG("sctp: chunk incomplete %zu vs. %zu",
70 | chunk_len, len);
71 | return -3;
72 | }
73 |
74 | if (dhdr->type != SCTP_CHUNK_DATA) {
75 | LDEBUG("sctp: chunk type ignored %u", dhdr->type);
76 | return chunk_len;
77 | }
78 |
79 | /* check for additional data */
80 | if (len < sizeof(*dhdr)) {
81 | LDEBUG("sctp: data chunk too short %zu vs. %zu",
82 | len, sizeof(*dhdr));
83 | return -4;
84 | }
85 |
86 | /* Only handle non-fragmented SCTP data chunks */
87 | if (dhdr->beginning && dhdr->ending)
88 | *send_data = true;
89 | else
90 | LDEBUG("sctp: ignoring data chunk beginning: %d ending: %d",
91 | dhdr->beginning, dhdr->ending);
92 | _msg->sctp_ppid = ntohl(dhdr->ppid);
93 | return chunk_len;
94 | }
95 |
--------------------------------------------------------------------------------
/src/modules/socket/pcap/sctp_support.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Holger Hans Peter Freyther
8 | * (C) Homer Project 2016 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 | #include
30 |
31 | #include
32 | #include
33 |
34 |
35 | enum sctp_chunk_type {
36 | SCTP_CHUNK_DATA,
37 | SCTP_CHUNK_INIT,
38 | SCTP_CHUNK_INIT_ACK,
39 | SCTP_CHUNK_SACK,
40 | /* Right now only _DATA matters */
41 | };
42 |
43 | struct sctp_common_hdr {
44 | uint16_t source;
45 | uint16_t dest;
46 | uint32_t ver_tag;
47 | uint32_t checksum;
48 | uint8_t data[0];
49 | } __attribute__((packed));
50 |
51 | struct sctp_chunk_hdr {
52 | uint8_t type;
53 | uint8_t flags;
54 | uint16_t len;
55 | uint8_t data[0];
56 | } __attribute__((packed));
57 |
58 | struct sctp_chunk_data_hdr {
59 | /* hdr */
60 | uint8_t type;
61 | #if __BYTE_ORDER == __BIG_ENDIAN
62 | uint8_t reserved:5,
63 | unordered:1,
64 | beginning:1,
65 | ending: 1;
66 | #elif __BYTE_ORDER == __LITTLE_ENDIAN
67 | uint8_t ending: 1,
68 | beginning:1,
69 | unordered:1,
70 | reserved:5;
71 | #else
72 | #error "Unknown endian type"
73 | #endif
74 | uint16_t len;
75 |
76 | /* chunk types */
77 | uint32_t tsn;
78 | uint16_t stream_id;
79 | uint16_t seqno;
80 | uint32_t ppid;
81 | uint8_t data[0];
82 | } __attribute__((packed));
83 |
84 | int sctp_parse_common(msg_t *msg, const uint8_t *data, size_t len);
85 | int sctp_parse_chunk(msg_t *msg, const uint8_t *data, size_t len, bool *send_data);
86 |
--------------------------------------------------------------------------------
/src/modules/socket/pcap/tcpreasm.h:
--------------------------------------------------------------------------------
1 | #ifndef _TCPIPREASM_H
2 | #define _TCPIPREASM_H
3 |
4 | #include
5 |
6 | #include
7 |
8 |
9 | /*
10 | * This is an abstract time stamp. iptcpreasm doesn't care whether it is
11 | * in seconds, milliseconds, or nanodecades. All it does it add the
12 | * configured timeout value to it, and then compare it to the timstamps
13 | * of subsequent packets to decide whether a fragment has expired.
14 | */
15 | typedef uint64_t tcpreasm_time_t;
16 |
17 | struct tcpreasm_ip;
18 |
19 | /*
20 | * Functions to create and destroy the reassembly environment.
21 | */
22 | struct tcpreasm_ip *tcpreasm_ip_new (void);
23 | void tcpreasm_ip_free (struct tcpreasm_ip *tcpreasm);
24 |
25 | /*
26 | * This is the main packet processing function. It inputs one packet,
27 | * and MAY output one packet in turn. If the input was not a fragment,
28 | * it is passed unmodified. If the input was a fragment that completed
29 | * reassembly of a packet, the reassembled packet is output.
30 | * If more fragments are required for reassembly, or the input packet
31 | * is invalid for some reason, a NULL pointer is returned.
32 | *
33 | * The input must be a pointer allocated by malloc(). The output will
34 | * be a pointer allocated by malloc().
35 | *
36 | * Note that in the case of an IPv6 fragment, the input buffer will be
37 | * modified in-place. This is considered a bug and should be fixed in
38 | * the future.
39 | */
40 | unsigned char *tcpreasm_ip_next (struct tcpreasm_ip *tcpreasm, unsigned char *packet, unsigned len, tcpreasm_time_t timestamp, unsigned *output_len);
41 |
42 | unsigned char *tcpreasm_ip_next_tcp (struct tcpreasm_ip *tcpreasm, unsigned char *packet, unsigned len, tcpreasm_time_t timestamp, unsigned *output_len, struct in_addr *ip_src, struct in_addr *ip_dst, uint16_t sport, uint16_t dport, uint8_t psh);
43 |
44 |
45 | /*
46 | * Set the timeout after which a noncompleted reassembly expires, in
47 | * abstract time units (see above for the definition of tcpreasm_time_t).
48 | */
49 | bool tcpreasm_ip_set_timeout (struct tcpreasm_ip *tcpreasm, tcpreasm_time_t timeout);
50 |
51 | /*
52 | * Query certain information about the current state.
53 | */
54 | unsigned tcpreasm_ip_waiting (const struct tcpreasm_ip *tcpreasm);
55 | unsigned tcpreasm_ip_max_waiting (const struct tcpreasm_ip *tcpreasm);
56 | unsigned tcpreasm_ip_timed_out (const struct tcpreasm_ip *tcpreasm);
57 | unsigned tcpreasm_ip_dropped_frags (const struct tcpreasm_ip *tcpreasm);
58 |
59 |
60 | #endif /* _TCPIPREASM_H */
61 |
--------------------------------------------------------------------------------
/src/modules/socket/tzsp/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = \
4 | . \
5 | captureplan
6 |
7 | noinst_HEADERS = socket_tzsp.h
8 | #
9 | socket_tzsp_la_SOURCES = socket_tzsp.c
10 | socket_tzsp_la_CFLAGS = -Wall ${MODULE_CFLAGS}
11 | socket_tzsp_la_LDFLAGS = -module -avoid-version
12 | socket_tzsp_la_LIBADD = ${PTHREAD_LIBS} ${EXPAT_LIBS} ${PCAP_LIBS} ${UV_LIBS}
13 | socket_tzsp_laconfdir = $(confdir)
14 | socket_tzsp_laconf_DATA = $(top_srcdir)/conf/socket_tzsp.xml
15 |
16 | mod_LTLIBRARIES = socket_tzsp.la
17 |
--------------------------------------------------------------------------------
/src/modules/socket/tzsp/captureplan/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 |
5 | capture_planconfdir = $(confdir)/captureplans
6 | capture_planconf_DATA = $(top_srcdir)/conf/captureplans/tzsp_capture_plan.cfg
7 |
--------------------------------------------------------------------------------
/src/modules/socket/tzsp/captureplan/Makefile.am~:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 |
5 | capture_planconfdir = $(confdir)/captureplans
6 | capture_planconf_DATA = $(top_srcdir)/conf/captureplans/rtcpxr_capture_plan.cfg
7 |
--------------------------------------------------------------------------------
/src/modules/socket/tzsp/socket_tzsp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #ifndef _socket_tzsp_H_
27 | #define _socket_tzsp_H_
28 |
29 | #include
30 |
31 | #include
32 | #include
33 |
34 | #define FILTER_LEN 4080
35 |
36 | #define PROTO_SIP 0x01
37 | #define TZSP_PORT "37008"
38 | #define TZSP_HOST "127.0.0.1"
39 | #define TZSP_PROTO "udp"
40 |
41 | #define TZSP_TYPE_RECEIVED_TAG_LIST 0
42 | #define TZSP_TYPE_PACKET_FOR_TRANSMIT 1
43 | #define TZSP_TYPE_RESERVED 2
44 | #define TZSP_TYPE_CONFIGURATION 3
45 | #define TZSP_TYPE_KEEPALIVE 4
46 | #define TZSP_TYPE_PORT_OPENER 5
47 |
48 | #define ARRAYSZ(x) (sizeof(x)/sizeof(*x))
49 |
50 | extern char *global_config_path;
51 | extern char *global_scripts_path;
52 |
53 | extern int handler(int value);
54 |
55 | #define MAX_SOCKETS 10
56 |
57 | typedef struct socket_tzsp_stats {
58 | uint64_t received_packets_total;
59 | uint64_t received_tcp_packets;
60 | uint64_t received_udp_packets;
61 | uint64_t received_sctp_packets;
62 | uint64_t send_packets;
63 | } socket_tzsp_stats_t;
64 |
65 |
66 | #define TZSP_TYPE_RECEIVED_TAG_LIST 0
67 | #define TZSP_TYPE_PACKET_FOR_TRANSMIT 1
68 | #define TZSP_TYPE_RESERVED 2
69 | #define TZSP_TYPE_CONFIGURATION 3
70 | #define TZSP_TYPE_KEEPALIVE 4
71 | #define TZSP_TYPE_PORT_OPENER 5
72 |
73 | static const char * const tzsp_type_names[] = {
74 | [TZSP_TYPE_RECEIVED_TAG_LIST] = "RECEIVED_TAG_LIST",
75 | [TZSP_TYPE_PACKET_FOR_TRANSMIT] = "PACKET_FOR_TRANSMIT",
76 | [TZSP_TYPE_RESERVED] = "RESERVED",
77 | [TZSP_TYPE_CONFIGURATION] = "CONFIGURATION",
78 | [TZSP_TYPE_KEEPALIVE] = "KEEPALIVE",
79 | [TZSP_TYPE_PORT_OPENER] = "PORT_OPENER",
80 | };
81 |
82 | #define TZSP_TAG_END 1
83 | #define TZSP_TAG_PADDING 0
84 |
85 | static const char * const tzsp_tag_names[] = {
86 | [TZSP_TAG_END] = "END",
87 | [TZSP_TAG_PADDING] = "PADDING",
88 | };
89 |
90 | struct tzsp_header {
91 | uint8_t version;
92 | uint8_t type;
93 | uint16_t encap;
94 | } __attribute__((packed));
95 |
96 | struct tzsp_tag {
97 | uint8_t type;
98 | uint8_t length;
99 | char data[];
100 | } __attribute__((packed));
101 |
102 |
103 | extern FILE* yyin;
104 | extern int yyparse();
105 |
106 | int bind_api(socket_module_api_t* api);
107 | int reload_config (char *erbuf, int erlen);
108 | void free_module_xml_config();
109 | int load_module_xml_config();
110 |
111 | void _run_uv_loop(void *arg);
112 | int close_socket(unsigned int loc_idx);
113 | void on_send(uv_udp_send_t* req, int status);
114 |
115 | #if UV_VERSION_MAJOR == 0
116 | uv_buf_t on_alloc(uv_handle_t* client, size_t suggested);
117 | void on_recv(uv_udp_t* handle, ssize_t nread, uv_buf_t rcvbuf, struct sockaddr* addr, unsigned flags);
118 | void _async_callback(uv_async_t *async, int status);
119 | #else
120 | void on_alloc(uv_handle_t* client, size_t suggested, uv_buf_t* buf);
121 | void on_recv(uv_udp_t* handle, ssize_t nread, const uv_buf_t* rcvbuf, const struct sockaddr* addr, unsigned flags);
122 | void _async_callback(uv_async_t *async);
123 | #endif
124 |
125 |
126 |
127 |
128 |
129 | #endif /* _socket_tzsp_H_ */
130 |
--------------------------------------------------------------------------------
/src/modules/transport/hep/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 | noinst_HEADERS = transport_hep.h localapi.h
5 | #
6 | transport_hep_la_SOURCES = localapi.c transport_hep.c
7 | transport_hep_la_CFLAGS = -Wall ${MODULE_CFLAGS}
8 | transport_hep_la_LDFLAGS = -module -avoid-version
9 | transport_hep_la_LIBADD = ${PTHREAD_LIBS} ${EXPAT_LIBS} ${PCAP_LIBS} ${UV_LIBS}
10 | transport_hep_laconfdir = $(confdir)
11 | transport_hep_laconf_DATA = $(top_srcdir)/conf/transport_hep.xml
12 |
13 | mod_LTLIBRARIES = transport_hep.la
14 |
--------------------------------------------------------------------------------
/src/modules/transport/hep/localapi.c:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 |
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include "localapi.h"
34 |
35 |
36 | /**
37 | *
38 | */
39 | int hepapi_send_hep(rc_info_t *rcinfo, unsigned char *data, unsigned int len, char *profile)
40 | {
41 | //set_raw_filter(index, filter);
42 | unsigned int idx = 0;
43 |
44 | idx = get_profile_index_by_name(profile);
45 |
46 | send_hepv3(rcinfo, data, len, 0, idx);
47 |
48 | LDEBUG("SEND HEP! [%d]\n", idx);
49 | return 1;
50 | }
51 |
52 | /**
53 | *
54 | */
55 | int bind_transport_hep(transport_hep_api_t* api)
56 | {
57 | if (!api) {
58 | LERR("Invalid parameter value\n");
59 | return -1;
60 |
61 | }
62 | api->sendhep = hepapi_send_hep;
63 |
64 | return 0;
65 | }
66 |
67 |
68 |
--------------------------------------------------------------------------------
/src/modules/transport/hep/localapi.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 | #ifndef TRANSPORT_HEP_API_H_
27 | #define TRANSPORT_HEP_API_H_
28 |
29 | #include
30 | #include
31 |
32 |
33 | extern int send_hepv3 (rc_info_t *rcinfo, unsigned char *data, unsigned int len, unsigned int sendzip, unsigned int idx);
34 | extern unsigned int get_profile_index_by_name(char *name);
35 |
36 | typedef int (*hepapi_send_hep_f)(rc_info_t *rcinfo, unsigned char *data, unsigned int len, char *profile);
37 | int hepapi_set_filter(rc_info_t *rcinfo, unsigned char *data, unsigned int len, char *profile);
38 |
39 | typedef struct transport_hep_api {
40 | hepapi_send_hep_f sendhep;
41 | } transport_hep_api_t;
42 |
43 | typedef int (*bind_transport_hep_f)(transport_hep_api_t* api);
44 | int bind_transport_hep(transport_hep_api_t* api);
45 |
46 | /**
47 | * @brief Load the socket_raw API
48 | */
49 | static inline int transport_hep_load_api(transport_hep_api_t *api)
50 | {
51 | bind_transport_hep_f bindtransport_hep;
52 |
53 | bindtransport_hep = (bind_transport_hep_f)find_export("bind_transport_hep", 0, 0);
54 |
55 |
56 | if(bindtransport_hep == 0) {
57 | LERR("cannot find bind_transport hep\n");
58 | return -1;
59 | }
60 | if (bindtransport_hep(api) < 0)
61 | {
62 | LERR("cannot bind transport_hep api\n");
63 | return -1;
64 | }
65 | return 0;
66 | }
67 |
68 |
69 | #endif /* TRANSPORT_HEP_API_H_ */
70 |
--------------------------------------------------------------------------------
/src/modules/transport/json/Makefile.am:
--------------------------------------------------------------------------------
1 | include $(top_srcdir)/modules.am
2 |
3 | SUBDIRS = .
4 | noinst_HEADERS = output_json.h
5 | #
6 | output_json_la_SOURCES = output_json.c
7 | output_json_la_CFLAGS = -Wall ${MODULE_CFLAGS}
8 | output_json_la_LDFLAGS = -module -avoid-version
9 | output_json_la_LIBADD = ${PTHREAD_LIBS} ${EXPAT_LIBS} ${JSON_LIBS}
10 | output_json_laconfdir = $(confdir)
11 | output_json_laconf_DATA = $(top_srcdir)/conf/output_json.xml
12 |
13 | mod_LTLIBRARIES = output_json.la
14 |
--------------------------------------------------------------------------------
/src/modules/transport/json/output_json.h:
--------------------------------------------------------------------------------
1 | /*
2 | * $Id$
3 | *
4 | * captagent - Homer capture agent. Modular
5 | * Duplicate SIP messages in Homer Encapulate Protocol [HEP] [ipv6 version]
6 | *
7 | * Author: Alexandr Dubovikov
8 | * (C) Homer Project 2012-2023 (http://www.sipcapture.org)
9 | *
10 | * Homer capture agent is free software; you can redistribute it and/or modify
11 | * it under the terms of the GNU General Public License as published by
12 | * the Free Software Foundation; either version 3 of the License, or
13 | * (at your option) any later version
14 | *
15 | * Homer capture agent is distributed in the hope that it will be useful,
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | * GNU General Public License for more details.
19 | *
20 | * You should have received a copy of the GNU General Public License
21 | * along with this program; if not, write to the Free Software
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 | *
24 | */
25 |
26 |
27 | #ifndef _OUTPUT_JSON_H_
28 | #define _OUTPUT_JSON_H_
29 |
30 | #include
31 |
32 | #include
33 | #include
34 | #include
35 | #include
36 |
37 | #ifdef USE_IPV6
38 | #include
39 | #endif /* USE_IPV6 */
40 |
41 |
42 | #ifdef USE_ZLIB
43 | #include
44 | #endif /* USE_ZLIB */
45 |
46 | #ifdef USE_SSL
47 | #include
48 | #include
49 |
50 | #endif /* USE_SSL */
51 |
52 | #define MAX_TRANPORTS 10
53 | profile_transport_t profile_transport[MAX_TRANPORTS];
54 |
55 | typedef struct output_json_stats {
56 | uint64_t received_packets_total;
57 | uint64_t send_packets_total;
58 | uint64_t reconnect_total;
59 | uint64_t compressed_total;
60 | uint64_t errors_total;
61 | } output_json_stats_t;
62 |
63 |
64 | #ifdef USE_SSL
65 | SSL_CTX* initCTX(void);
66 | #endif /* USE_SSL */
67 |
68 | //struct addrinfo *ai;
69 | //struct addrinfo hints[1] = {{ 0 }};
70 |
71 | extern char *global_config_path;
72 |
73 | int send_data (void *buf, unsigned int len, unsigned int idx);
74 | int init_jsonsocket_blocking (unsigned int idx);
75 | int init_jsonsocket (unsigned int idx);
76 | int sigPipe(void);
77 | profile_transport_t *get_profile_by_name(char *name);
78 | unsigned int get_profile_index_by_name(char *name);
79 | int bind_usrloc(transport_module_api_t *api);
80 | int send_json(msg_t *msg);
81 | void free_module_xml_config();
82 | int load_module_xml_config();
83 | int reload_config (char *erbuf, int erlen);
84 | int check_module_xml_config();
85 | int w_send_json_api(msg_t *_m, char *param1);
86 |
87 | #endif /* _OUTPUT_JSON_H_ */
88 |
--------------------------------------------------------------------------------
/src/y.tab.h:
--------------------------------------------------------------------------------
1 | /* A Bison parser, made by GNU Bison 2.5. */
2 |
3 | /* Bison interface for Yacc-like parsers in C
4 |
5 | Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see . */
19 |
20 | /* As a special exception, you may create a larger work that contains
21 | part or all of the Bison parser skeleton and distribute that work
22 | under terms of your choice, so long as that work isn't itself a
23 | parser generator using the skeleton or a modified version thereof
24 | as a parser skeleton. Alternatively, if you modify or redistribute
25 | the parser skeleton itself, you may (at your option) remove this
26 | special exception, which will cause the skeleton and the resulting
27 | Bison output files to be licensed under the GNU General Public
28 | License without this special exception.
29 |
30 | This special exception was added by the Free Software Foundation in
31 | version 2.2 of Bison. */
32 |
33 |
34 | /* Tokens. */
35 | #ifndef YYTOKENTYPE
36 | # define YYTOKENTYPE
37 | /* Put the tokens into the symbol table, so that GDB and other debuggers
38 | know about them. */
39 | enum yytokentype {
40 | FORWARD = 258,
41 | SEND = 259,
42 | DROP = 260,
43 | IF = 261,
44 | ELSE = 262,
45 | METHOD = 263,
46 | CAPTURE = 264,
47 | DEBUG = 265,
48 | EQUAL = 266,
49 | EQUAL_T = 267,
50 | MATCH = 268,
51 | OR = 269,
52 | AND = 270,
53 | NOT = 271,
54 | NUMBER = 272,
55 | ID = 273,
56 | STRING = 274,
57 | IPV6ADDR = 275,
58 | COMMA = 276,
59 | SEMICOLON = 277,
60 | RPAREN = 278,
61 | LPAREN = 279,
62 | LBRACE = 280,
63 | RBRACE = 281,
64 | LBRACK = 282,
65 | RBRACK = 283,
66 | SLASH = 284,
67 | DOT = 285,
68 | CR = 286
69 | };
70 | #endif
71 | /* Tokens. */
72 | #define FORWARD 258
73 | #define SEND 259
74 | #define DROP 260
75 | #define IF 261
76 | #define ELSE 262
77 | #define METHOD 263
78 | #define CAPTURE 264
79 | #define DEBUG 265
80 | #define EQUAL 266
81 | #define EQUAL_T 267
82 | #define MATCH 268
83 | #define OR 269
84 | #define AND 270
85 | #define NOT 271
86 | #define NUMBER 272
87 | #define ID 273
88 | #define STRING 274
89 | #define IPV6ADDR 275
90 | #define COMMA 276
91 | #define SEMICOLON 277
92 | #define RPAREN 278
93 | #define LPAREN 279
94 | #define LBRACE 280
95 | #define RBRACE 281
96 | #define LBRACK 282
97 | #define RBRACK 283
98 | #define SLASH 284
99 | #define DOT 285
100 | #define CR 286
101 |
102 |
103 |
104 |
105 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
106 | typedef union YYSTYPE
107 | {
108 |
109 | /* Line 2068 of yacc.c */
110 | #line 27 "capplan.y"
111 |
112 | int intval;
113 | unsigned uval;
114 | char* strval;
115 | struct expr* expr;
116 | struct action* action;
117 | struct net* ipnet;
118 |
119 |
120 |
121 | /* Line 2068 of yacc.c */
122 | #line 123 "y.tab.h"
123 | } YYSTYPE;
124 | # define YYSTYPE_IS_TRIVIAL 1
125 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */
126 | # define YYSTYPE_IS_DECLARED 1
127 | #endif
128 |
129 | extern YYSTYPE yylval;
130 |
131 |
132 |
--------------------------------------------------------------------------------
/test/README.md:
--------------------------------------------------------------------------------
1 | ## CaptAgent CI
2 |
3 | Automated tests for Captagent using Node JS and Mocha.
4 |
5 | NOTICE: `sudo` rights are required to spawn the agent and test sockets on interface `any`
6 |
7 | 
8 |
9 | ### Usage
10 | ```
11 | npm install -g mocha
12 | npm install hep-js
13 | sudo npm test
14 | ```
15 |
16 | #### Units
17 | ##### Initialization
18 | This suite will initialized the compiled agent and check various command options for the agent (`-v` `-a` `-c`).
19 | ```
20 | sudo mocha init.js
21 | ```
22 | ##### HEP Functionality
23 | This suite will test SIP and HEP features using the compiled agent, feeding it SIP and expecting HEP back.
24 | ```
25 | sudo mocha hep.js
26 | ```
27 |
--------------------------------------------------------------------------------
/test/hep.js:
--------------------------------------------------------------------------------
1 | const assert = require('assert');
2 | const spawn = require('child_process').spawn;
3 | const hepjs = require('hep-js');
4 | const dgram = require('dgram');
5 | const command = '../src/captagent';
6 | const ipserver = '127.0.0.1';
7 | const iptarget = '127.0.0.1';
8 |
9 | /*
10 | * Start Captagent, Check Code and Exit
11 | */
12 | describe('CaptAgent HEP Basic', () => {
13 | let args = ["-x 10"];
14 |
15 | let decoded;
16 | let network;
17 | var sipmessage = 'SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP there.com:5060\r\nFrom: LittleGuy \r\nTo: LittleGuy \r\nCall-ID: 123456789@there.com\r\nCSeq: 2 REGISTER\r\n\r\n';
18 | var udpmessage = new Buffer.from(sipmessage);
19 | var in_socket = dgram.createSocket('udp4');
20 | var out_socket = dgram.createSocket('udp4');
21 |
22 | before((done) => {
23 | let captagent = spawn(command, args);
24 | captagent.on('exit', () => {
25 | in_socket.close();
26 | out_socket.close();
27 | done();
28 | })
29 |
30 | in_socket.on('message', (message, socket) => {
31 | decoded = hepjs.decapsulate(message);
32 | network = socket;
33 | // console.log(network,decoded);
34 | captagent.kill();
35 | })
36 | var sendHep = function(){
37 | out_socket.send(udpmessage, 0, udpmessage.length, 5060, iptarget, function(err) {
38 | if (err) console.log(err);
39 | });
40 | }
41 |
42 | in_socket.on('listening', function () {
43 | captagent.stdout.on('data', (data) => {
44 | setTimeout(sendHep, 1200);
45 | })
46 | })
47 | in_socket.bind(9061, ipserver);
48 | })
49 |
50 | it('UDP should originate from 127.0.0.1', (done) => {
51 | assert.ok(network.address === '127.0.0.1');
52 | done();
53 | })
54 | it('UDP should decode to HEP', (done) => {
55 | assert.ok(decoded);
56 | done();
57 | })
58 | it('HEP should contain rcinfo', (done) => {
59 | assert.ok(decoded.rcinfo);
60 | done();
61 | })
62 | it('HEP should contain payload', (done) => {
63 | assert.ok(decoded.payload.length > 0);
64 | done();
65 | })
66 | it('HEP payload should equal sent payload', (done) => {
67 | assert.ok(decoded.payload.length === udpmessage.length);
68 | done();
69 | })
70 | it('HEP capturePass should be "myhep"', (done) => {
71 | assert.ok(decoded.rcinfo.capturePass === 'myhep');
72 | done();
73 | })
74 | it('HEP dstPort should be 5060', (done) => {
75 | assert.ok(decoded.rcinfo.dstPort === 5060);
76 | done();
77 | })
78 | it('HEP srcPort should exist', (done) => {
79 | assert.ok(decoded.rcinfo.srcPort >= 0 );
80 | done();
81 | })
82 | it('HEP captureId should be 2001', (done) => {
83 | assert.ok(decoded.rcinfo.captureId === 2001);
84 | done();
85 | })
86 | it('HEP payloadType should be "myhep"', (done) => {
87 | assert.ok(decoded.rcinfo.payloadType === 1);
88 | done();
89 | })
90 | it('HEP srcIp should be "127.0.0.1"', (done) => {
91 | assert.ok(decoded.rcinfo.srcIp === '127.0.0.1');
92 | done();
93 | })
94 | it('HEP dstIp should be "127.0.0.1"', (done) => {
95 | assert.ok(decoded.rcinfo.dstIp === '127.0.0.1');
96 | done();
97 | })
98 |
99 | })
100 |
--------------------------------------------------------------------------------
/test/init.js:
--------------------------------------------------------------------------------
1 | const assert = require('assert');
2 | const spawn = require('child_process').spawn;
3 |
4 | /*
5 | * Start Captagent, Check Exit Code
6 | */
7 | describe('CaptAgent Version', () => {
8 | let args = ["-v"];
9 | let exitCode;
10 | let output;
11 |
12 | before((done) => {
13 | let process = spawn('../src/captagent', args);
14 | process.stdout.on('data',
15 | function(data) {
16 | output = data.toString();
17 | });
18 | process.on('exit', (code) => {
19 | exitCode = code;
20 | done();
21 | });
22 | });
23 | it('exit code should be zero', () => {
24 | assert.equal(exitCode, 0);
25 | });
26 | it('should print version number', () => {
27 | assert.ok(output.length > 0);
28 | assert.ok(output.startsWith('version'));
29 | });
30 | });
31 |
32 | /*
33 | * Start Captagent, Check list of devices and exit
34 | */
35 | describe('CaptAgent -a option (List devices)', () => {
36 | let args = ["-a"];
37 | let exitCode;
38 | let output;
39 |
40 | before((done) => {
41 | let process = spawn('../src/captagent', args);
42 | process.stdout.on('data',
43 | function(data) {
44 | output = data.toString();
45 | });
46 | process.on('exit', (code) => {
47 | exitCode = code;
48 | done();
49 | });
50 | });
51 | it('exit code should be zero', () => {
52 | assert.equal(exitCode, 0);
53 | });
54 | it('should print the list of devices', () => {
55 | assert.ok(output.length > 0);
56 | assert.ok(output.startsWith('List'));
57 | });
58 | });
59 |
60 | /*
61 | * Start Captagent, Check configuration and exit
62 | */
63 | describe('CaptAgent -c option (Check configuration and exit)', () => {
64 | let args = ["-c"];
65 | let exitCode;
66 | let output;
67 |
68 | before((done) => {
69 | let process = spawn('../src/captagent', args);
70 | process.stdout.on('data',
71 | function(data) {
72 | output = data.toString();
73 | }
74 | );
75 | process.on('exit', (code) => {
76 | exitCode = code;
77 | done();
78 | });
79 | });
80 | it('exit code should be zero', () => {
81 | assert.equal(exitCode, 0);
82 | });
83 | it('should load config file and exit', () => {
84 | assert.ok(output.length > 0);
85 | assert.ok(output.startsWith('[NOTICE]'));
86 | });
87 | });
88 |
89 |
90 | /*
91 | * Start Captagent, Read test pcaps and exit
92 | */
93 |
--------------------------------------------------------------------------------
/test/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "captagent-ci",
3 | "version": "1.0.2",
4 | "description": "Captagent CI Tests",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "mocha --exit --timeout 5000 *.js"
8 | },
9 | "keywords": [
10 | "hep",
11 | "captagent",
12 | "sipcapture",
13 | "homer",
14 | "test",
15 | "ci"
16 | ],
17 | "author": "Lorenzo Mangani (http://qxip.net/)",
18 | "license": "GPL-3.0",
19 | "devDependencies": {
20 | "hep-js": "^1.0.20",
21 | "mocha": "^10.8.2"
22 | },
23 | "dependencies": {
24 | "mixin-deep": "^1.3.2"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------