Compare commits

..
Author SHA1 Message Date
Luca Deri 6450ae256c Fix for loop on the git dissector 2016-07-13 10:33:06 +02:00
312 changed files with 15760 additions and 27263 deletions
-14
View File
@@ -10,13 +10,8 @@
*.la *.la
.libs .libs
.dirstamp .dirstamp
.autotools
.cproject
.project
.settings
stamp-h1 stamp-h1
/configure /configure
/configure.ac
/config.guess /config.guess
/config.h /config.h
/config.h.in /config.h.in
@@ -40,12 +35,3 @@ stamp-h1
/m4/ltsugar.m4 /m4/ltsugar.m4
/m4/ltversion.m4 /m4/ltversion.m4
/m4/lt~obsolete.m4 /m4/lt~obsolete.m4
/autom4te.cache/
/compile
/example/.deps/
/src/lib/.deps/
/src/lib/protocols/.deps/
/src/lib/third_party/src/.deps/
/src/include/ndpi_define.h
/test-driver
/tests/Makefile
+3 -30
View File
@@ -1,30 +1,16 @@
language: c language: c
os:
- osx
- linux
compiler: compiler:
- clang - clang
- gcc - gcc
matrix:
exclude:
# osx use always clang for build...
- os: osx
compiler: gcc
install: install:
#macos - sudo apt-get update || true
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update; fi - sudo apt-get install build-essential
#linux - sudo apt-get install libpcap-dev libtool autoconf automake autogen
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update || true; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install build-essential; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install libpcap-dev libtool autoconf automake autogen; fi
before_script: before_script:
- ./autogen.sh - ./autogen.sh
# - lcov --directory . --zerocounters
script: script:
- ./configure - ./configure
@@ -34,16 +20,3 @@ after_script:
- cd tests - cd tests
- ./do.sh - ./do.sh
#after_success:
#- cd ${TRAVIS_BUILD_DIR}
#- lcov --directory . --capture --output-file coverage.info # capture coverage info
#- lcov --remove coverage.info 'tests/*' 'packages/*' 'm4/*' 'doc/*' --output-file coverage.info
#- lcov --list coverage.info # debug before upload
#- coveralls-lcov --repo-token ${COVERALLS_TOKEN} coverage.info # uploads to coveralls
notifications:
email:
recipients:
- packager@ntop.org
on_success: never
on_failure: always
-151
View File
@@ -1,151 +0,0 @@
# CHANGELOG
#### nDPI 2.2.2 (April 2018)
## Main New Features
* Hyperscan support
* `ndpi_get_api_version` API call to be used in applications that are dynamically linking with nDPI
* `--enable-debug-messages` to enable debug information output
* Increased number of protocols to 512
## New Supported Protocols and Services
* GoogleDocs
* GoogleServices
* AmazonVideo
* ApplePush
* Diameter
* GooglePlus
* WhatsApp file exchage
## Improvements
* WhatsApp detection
* Amazon detection
* Improved Google Drive
* Improved Spotify support
* Improved SNI matching when using office365
* Improved HostShield VPN
## Fixes
* Fixed invalid RTP/Skype detection
* Fixed possible out-of-bounds due to malformed DHCP packets
* Fixed buffer overflow in function `ndpi_debug_printf`
------------------------------------------------------------------------
#### nDPI 2.2 (December 2017)
## Main New Features
* Custom protocol categories to allow personalization of protocols-categories mappings
* DHCP fingerprinting
* HTTP User Agent discovery
## New Supported Protocols and Services
* ICQ (instant messaging client)
* YouTube Upload
* LISP
* SoundCloud
* Sony PlayStation
* Nintendo (switch) gaming protocol
## Improvements
* Windows 10 detection from UA and indentation
* Determine STUN flows that turn into RTP
* Fixes for iQIYI and 1kxun
* Android fingerprint
* Added DHCP class identifier support
------------------------------------------------------------------------
#### nDPI 2.0 (May 2017)
## Main New Features
* nDPI Wireshark plugin for Layer-7 protocol dissection. The plugin, available via an extcap interface, passes Wireshark the nDPI-detected protocols by adding an ethernet packet trailer that is then interpreted and displayed inside the Wireshark GUI. Readme: https://github.com/ntop/nDPI/blob/dev/wireshark/README.md
## New Supported Protocols and Services
* STARTTLS
* IMAPS
* DNScrypt
* QUIC (Quick UDP Internet Connections)
* AMQP (Advanced Message Queueing Protocol)
* Ookla (SpeedTest)
* BJNP
* AFP (Apple Filing Protocol)
* SMPP (Short Message Peer-to-Peer)
* VNC
* OpenVPN
* OpenDNS
* RX protocol (used by AFS)
* CoAP and MQTT (IoT specific protocols)
* Cloudflare
* Office 365
* OCS
* MS Lync
* Ubiquity AirControl 2
* HEP (Extensible Encapsulation Protocol)
* WhatsApp Voice vs WhatsApp (chat, no voice)
* Viber
* Wechat
* Github
* Hotmail
* Slack
* Instagram
* Snapchat
* MPEG TS protocol
* Twitch
* KakaoTalk Voice and Chat
* Meu
* EAQ
* iQIYI media service
* Weibo
* PPStream
## Improvements
* SSH client/server version dissection
* Improved SSL dissection
* SSL server certificate detection
* Added double tagging 802.1Q in dissection of vlan-tagged packets
* Improved netBIOS dissection
* Improved Skype detection
* Improved Netflix traffic detection
* Improved HTTP subprotocol matching
* Implemented DHCP host name extraction
* Updated Facebook detection by ip server ranges
* Updated Twitter networks
* Improved Microsoft detection
* Enhanced Google detection
* Improved BT-uTP protocol dissection
* Added detection of Cisco datalink layer (Cisco hDLC and Cisco SLARP)
#### Older releases
#### 2014-03-21
* improved support for eDonkey/eMule/Kademlia
* improved support for PPLive
#### 2014-03-20
* code optimizations
* consistency improvements
* added support for new applications: Pando Media Booster
* improved support for Steam
* added support for new web services: Wikipedia, MSN, Amazon, eBay, CNN
#### 2014-03-19
* added new protocols: FTP, code improvements
#### 2014-03-17
* added new protocols: SOCKSv4, SOCKSv5, RTMP
+16
View File
@@ -0,0 +1,16 @@
2014-03-21:
- improved support for eDonkey/eMule/Kademlia
- improved support for PPLive
2014-03-20:
- code optimizations
- consistency improvements
- added support for new applications: Pando Media Booster
- improved support for Steam
- added support for new web services: Wikipedia, MSN, Amazon, eBay, CNN
2014-03-19:
- added new protocols: FTP, code improvements
2014-03-17:
- added new protocols: SOCKSv4, SOCKSv5, RTMP
+1 -1
View File
@@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src/lib example tests SUBDIRS = src/lib example
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libndpi.pc pkgconfig_DATA = libndpi.pc
+2 -18
View File
@@ -15,10 +15,6 @@ In order to compile this library do
- ./configure - ./configure
- make - make
To run tests do additionally:
- cd tests; ./do.sh
Please note that the pre-requisites for compilation include: Please note that the pre-requisites for compilation include:
- GNU tools (autogen, automake, autoconf, libtool) - GNU tools (autogen, automake, autoconf, libtool)
- GNU C compiler (gcc) - GNU C compiler (gcc)
@@ -27,9 +23,9 @@ Please note that the pre-requisites for compilation include:
The entire procedure of adding new protocols in detail: The entire procedure of adding new protocols in detail:
1. Add new protocol together with its unique ID to: src/include/ndpi_protocol_ids.h 1. Add new protocol together with its unique ID to: src/include/ndpi_protocols_osdpi.h
2. Create a new protocol in: src/lib/protocols/ 2. Create a new protocol in: src/lib/protocols/
3. Variables to be kept for the duration of the entire flow (as state variables) need to be placed in: src/include/ndpi_typedefs.h in ndpi_flow_tcp_struct (for TCP only), ndpi_flow_udp_struct (for UDP only), or ndpi_flow_struct (for both). 3. Variables to be kept for the duration of the entire flow (as state variables) needs to be placed in: /include/ndpi_structs.h in ndpi_flow_tcp_struct (for TCP only), ndpi_flow_udp_struct (for UDP only), or ndpi_flow_struct (for both).
4. Add a new entry for the search function for the new protocol in: src/include/ndpi_protocols.h 4. Add a new entry for the search function for the new protocol in: src/include/ndpi_protocols.h
5. Choose (do not change anything) a selection bitmask from: src/include/ndpi_define.h 5. Choose (do not change anything) a selection bitmask from: src/include/ndpi_define.h
6. Add a new entry in ndpi_set_protocol_detection_bitmask2 in: src/lib/ndpi_main.c 6. Add a new entry in ndpi_set_protocol_detection_bitmask2 in: src/lib/ndpi_main.c
@@ -38,14 +34,6 @@ The entire procedure of adding new protocols in detail:
9. ./autogen.sh 9. ./autogen.sh
10. ./configure 10. ./configure
11. make 11. make
12. make check
### How to use nDPI to Block Selected Traffic
You can use nDPI to selectively block selected Internet traffic by embedding it onto an application (remember that nDPI us just a library). Both [ntopng](https://github.com/ntop/ntopng) and [nProbe cento](http://www.ntop.org/products/netflow/nprobe-cento/) can do this.
### DISCLAIMER
While we do our best to detect network protocols, we cannot guarantee that our software is error free and 100% accurate in protocol detection. Please make sure that you respect the privacy of users and you have proper authorization to listen, capture and inspect network traffic.
### Creating A Source File Tar Ball ### Creating A Source File Tar Ball
@@ -53,10 +41,6 @@ If you want to distribute a source tar file of nDPI do:
- make dist - make dist
To ensure that a tar file includes all necessary files and to run tests on distribution do:
- make distcheck
[ntopng_logo]: https://camo.githubusercontent.com/0f789abcef232035c05e0d2e82afa3cc3be46485/687474703a2f2f7777772e6e746f702e6f72672f77702d636f6e74656e742f75706c6f6164732f323031312f30382f6e746f706e672d69636f6e2d313530783135302e706e67 [ntopng_logo]: https://camo.githubusercontent.com/0f789abcef232035c05e0d2e82afa3cc3be46485/687474703a2f2f7777772e6e746f702e6f72672f77702d636f6e74656e742f75706c6f6164732f323031312f30382f6e746f706e672d69636f6e2d313530783135302e706e67
[ntop_logo]: https://camo.githubusercontent.com/58e2a1ecfff62d8ecc9d74633bd1013f26e06cba/687474703a2f2f7777772e6e746f702e6f72672f77702d636f6e74656e742f75706c6f6164732f323031352f30352f6e746f702e706e67 [ntop_logo]: https://camo.githubusercontent.com/58e2a1ecfff62d8ecc9d74633bd1013f26e06cba/687474703a2f2f7777772e6e746f702e6f72672f77702d636f6e74656e742f75706c6f6164732f323031352f30352f6e746f702e706e67
+1 -2
View File
@@ -1,10 +1,9 @@
Prerequisites for Compilation rerequisites for Compilation
----------------------------- -----------------------------
Prerequisites Prerequisites
- GNU autotools/libtool - GNU autotools/libtool
- libpcap or PF_RING (optional but recommended) - libpcap or PF_RING (optional but recommended)
- apt-get install libjson-c-dev (for JSON support)
On Ubuntu/Debian On Ubuntu/Debian
- apt-get install build-essential - apt-get install build-essential
+6 -21
View File
@@ -1,17 +1,13 @@
#!/bin/sh #!/bin/sh
NDPI_MAJOR="2"
NDPI_MINOR="2"
NDPI_PATCH="2"
NDPI_VERSION_SHORT="$NDPI_MAJOR.$NDPI_MINOR.$NDPI_PATCH"
rm -f configure config.h config.h.in src/lib/Makefile.in /bin/rm -f configure config.h config.h.in src/lib/Makefile.in
AUTOCONF=$(command -v autoconf) AUTOCONF=$(which autoconf)
AUTOMAKE=$(command -v automake) AUTOMAKE=$(which automake)
LIBTOOL=$(command -v libtool) LIBTOOL=$(which libtool)
LIBTOOLIZE=$(command -v libtoolize) LIBTOOLIZE=$(which libtoolize)
AUTORECONF=$(command -v autoreconf) AUTORECONF=$(which autoreconf)
if test -z $AUTOCONF; then if test -z $AUTOCONF; then
echo "autoconf is missing: please install it and try again" echo "autoconf is missing: please install it and try again"
@@ -33,16 +29,5 @@ if test -z $AUTORECONF; then
exit exit
fi fi
cat configure.seed | sed \
-e "s/@NDPI_MAJOR@/$NDPI_MAJOR/g" \
-e "s/@NDPI_MINOR@/$NDPI_MINOR/g" \
-e "s/@NDPI_PATCH@/$NDPI_PATCH/g" \
-e "s/@NDPI_VERSION_SHORT@/$NDPI_VERSION_SHORT/g" \
> configure.ac
autoreconf -ivf autoreconf -ivf
cat configure | sed "s/#define PACKAGE/#define NDPI_PACKAGE/g" | sed "s/#define VERSION/#define NDPI_VERSION/g" > configure.tmp
cat configure.tmp > configure
chmod +x configure
./configure $* ./configure $*
+15 -49
View File
@@ -1,4 +1,4 @@
AC_INIT([libndpi], [@NDPI_VERSION_SHORT@]) AC_INIT([libndpi], [1.8.0])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
@@ -7,17 +7,8 @@ AM_INIT_AUTOMAKE([foreign subdir-objects])
LT_INIT LT_INIT
AC_PROG_CC AC_PROG_CC
AM_PROG_CC_C_O
AX_PTHREAD AX_PTHREAD
NDPI_MAJOR="@NDPI_MAJOR@"
NDPI_MINOR="@NDPI_MINOR@"
NDPI_PATCH="@NDPI_PATCH@"
AC_DEFINE_UNQUOTED(NDPI_MAJOR_RELEASE, "${NDPI_MAJOR}", [nDPI major release])
AC_DEFINE_UNQUOTED(NDPI_MINOR_RELEASE, "${NDPI_MINOR}", [nDPI minor release])
AC_DEFINE_UNQUOTED(NDPI_PATCH_LEVEL, "${NDPI_PATCH}", [nDPI patch level])
if test -d ".git"; then : if test -d ".git"; then :
GIT_TAG=`git log -1 --format=%h` GIT_TAG=`git log -1 --format=%h`
GIT_DATE=`git log -1 --format=%cd` GIT_DATE=`git log -1 --format=%cd`
@@ -26,7 +17,8 @@ if test -d ".git"; then :
# #
# #
GIT_NUM=`git log --pretty=oneline | wc -l | tr -d '[[:space:]]'` GIT_NUM=`git log --pretty=oneline | wc -l | tr -d '[[:space:]]'`
GIT_RELEASE="${PACKAGE_VERSION}-${GIT_NUM}-${GIT_TAG}" GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
GIT_RELEASE="${PACKAGE_VERSION}-${GIT_BRANCH}-${GIT_NUM}-${GIT_TAG}"
else else
GIT_RELEASE="${PACKAGE_VERSION}" GIT_RELEASE="${PACKAGE_VERSION}"
GIT_DATE=`date` GIT_DATE=`date`
@@ -48,18 +40,7 @@ SHORT_MACHINE=`uname -m | cut -b1-3`
if test $SHORT_MACHINE = "arm"; then if test $SHORT_MACHINE = "arm"; then
LIBNUMA="" LIBNUMA=""
else else
AC_CHECK_LIB([numa], [numa_available], [LIBNUMA="-lnuma"]) LIBNUMA="-lnuma"
fi
HS_LIB=
HS_INC=
AC_ARG_WITH(hyperscan, [ --with-hyperscan Enable Intel Hyperscan (if available)])
if test "${with_hyperscan}" == "yes"; then :
AC_CHECK_LIB([hs], [hs_compile_multi], AC_DEFINE_UNQUOTED(HAVE_HYPERSCAN, 1, [Intel Hyperscan is present]))
HS_INC=`pkg-config --cflags libhs`
HS_LIB=`pkg-config --libs libhs`
fi fi
if test -f $PCAP_HOME/libpcap/libpcap.a; then : if test -f $PCAP_HOME/libpcap/libpcap.a; then :
@@ -69,11 +50,6 @@ if test -f $PCAP_HOME/libpcap/libpcap.a; then :
AC_CHECK_LIB([rt], [clock_gettime], [PCAP_LIB="$PCAP_LIB -lrt"]) AC_CHECK_LIB([rt], [clock_gettime], [PCAP_LIB="$PCAP_LIB -lrt"])
AC_CHECK_LIB([nl], [nl_handle_alloc], [PCAP_LIB="$PCAP_LIB -lnl"]) AC_CHECK_LIB([nl], [nl_handle_alloc], [PCAP_LIB="$PCAP_LIB -lnl"])
# The dlopen() function is in libdl on GLIBC-based systems
# and in the C library for *BSD systems
AC_CHECK_LIB([dl], [dlopen, dlsym], [DL_LIB="-ldl"],
[AC_CHECK_LIB([c], [dlopen, dlsym], [DL_LIB="-lc"],
[AC_MSG_ERROR([unable to find the dlopen(), dlsym() functions]) ]) ])
else else
AC_CHECK_LIB([pcap], [pcap_open_live], [PCAP_LIB="-lpcap"]) AC_CHECK_LIB([pcap], [pcap_open_live], [PCAP_LIB="-lpcap"])
@@ -85,7 +61,6 @@ else
fi fi
fi fi
dnl> https://github.com/json-c/json-c
AC_ARG_ENABLE([json-c], AC_ARG_ENABLE([json-c],
AS_HELP_STRING([--disable-json-c], [Disable json-c support])) AS_HELP_STRING([--disable-json-c], [Disable json-c support]))
@@ -98,36 +73,27 @@ AS_IF([test "x$enable_json_c" != "xno"], [
LDFLAGS="$LDFLAGS $(pkg-config --libs json-c)" LDFLAGS="$LDFLAGS $(pkg-config --libs json-c)"
AC_CHECK_LIB(json-c, json_object_new_object, AC_DEFINE_UNQUOTED(HAVE_JSON_C, 1, [The JSON-C library is present])) AC_CHECK_LIB(json-c, json_object_new_object, AC_DEFINE_UNQUOTED(HAVE_JSON_C, 1, [The JSON-C library is present]))
], ],
[ [])
JSONC_HOME="$HOME/json-c"
if test -d "$JSONC_HOME"; then :
CFLAGS="$CFLAGS -I $JSONC_HOME"
LDFLAGS="$LDFLAGS $JSONC_HOME/.libs/libjson-c.a"
AC_MSG_RESULT([Found json-c in $JSONC_HOME])
AC_DEFINE_UNQUOTED(HAVE_JSON_C, 1, [The JSON-C library is present])
fi
])
]) ])
AC_ARG_ENABLE([debug-messages], OLD_LIBS=$LIBS
AS_HELP_STRING([--enable-debug-messages], [Define NDPI_ENABLE_DEBUG_MESSAGES=1]), [ LIBS="-L/opt/napatech3/lib $LIBS"
AC_DEFINE(NDPI_ENABLE_DEBUG_MESSAGES, 1, [Enable ndpi_debug_messages]) ]) AC_CHECK_LIB([ntapi],
[NT_Init],
[PCAP_LIB="$PCAP_LIB -L/opt/napatech3/lib -lntapi"],
[], [] )
LIBS=$OLD_LIBS
AC_CHECK_LIB(pthread, pthread_setaffinity_np, AC_DEFINE_UNQUOTED(HAVE_PTHREAD_SETAFFINITY_NP, 1, [libc has pthread_setaffinity_np])) AC_CHECK_LIB(pthread, pthread_setaffinity_np, AC_DEFINE_UNQUOTED(HAVE_PTHREAD_SETAFFINITY_NP, 1, [libc has pthread_setaffinity_np]))
AC_CONFIG_FILES([Makefile src/lib/Makefile example/Makefile tests/Makefile libndpi.pc src/include/ndpi_define.h]) AC_CONFIG_FILES([Makefile src/lib/Makefile example/Makefile libndpi.pc])
AC_CONFIG_HEADERS(src/include/ndpi_config.h) AC_CONFIG_HEADERS(config.h)
AC_SUBST(GIT_RELEASE) AC_SUBST(GIT_RELEASE)
AC_SUBST(NDPI_MAJOR)
AC_SUBST(NDPI_MINOR)
AC_SUBST(NDPI_PATCH)
AC_SUBST(SVN_DATE) AC_SUBST(SVN_DATE)
AC_SUBST(JSON_C_LIB) AC_SUBST(JSON_C_LIB)
AC_SUBST(PCAP_INC) AC_SUBST(PCAP_INC)
AC_SUBST(PCAP_LIB) AC_SUBST(PCAP_LIB)
AC_SUBST(DL_LIB)
AC_SUBST(HS_LIB)
AC_SUBST(HS_INC)
AC_SUBST(HAVE_PTHREAD_SETAFFINITY_NP) AC_SUBST(HAVE_PTHREAD_SETAFFINITY_NP)
AC_OUTPUT AC_OUTPUT
Binary file not shown.
Binary file not shown.
Binary file not shown.
-18
View File
@@ -1,18 +0,0 @@
# How to use?
You need to first compile the nDPI library as usual:
- ./autogen.sh
- ./configure
- make
Then open the Xcode project and you are ready to go. The default behavior is to analyze an embeded pcap file `capture.pcap`. You can change the behavior by changing command line input in `ViewController.m` file.
# What does the XCode project do?
It's a dummy Mac App project with a **Run** button. It doesn't modify any nDPI code except that it renamed the `main` function to `orginal_main` in `ndpiReader.c` (because the Mac App has it's own main function) and call the `orginal_main` with synthetic command line input from `ViewController.m` file when the **Run** button is clicked.
It also fixes some problems when compiling with Xcode. Some are listed below:
- Add missed `NDPI_LOG_DEBUG2` macro definition implementation (defined as `NDPI_LOG_DEBUG2_XCODE_PROJ` in `ViewController.m`)
- Add an empty ndpi_utils.h file to make `protocols/attic/ftp.c` and `protocols/attic/secondlife.c` can compile
- Specially treat `ndpi_patricia.c` by not adding it into compilation source, since it's directly included in `ndpi_main.c`
File diff suppressed because it is too large Load Diff
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:ndpiExample.xcodeproj">
</FileRef>
</Workspace>
@@ -1,29 +0,0 @@
/*
*
* Copyright (C) 2011-18 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@end
@@ -1,41 +0,0 @@
/*
*
* Copyright (C) 2011-18 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}
@end
@@ -1,58 +0,0 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -1,732 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Application-->
<scene sceneID="JPo-4y-FX3">
<objects>
<application id="hnw-xV-0zn" sceneMemberID="viewController">
<menu key="mainMenu" title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="ndpiExample" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="ndpiExample" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About ndpiExample" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="Ady-hI-5gd" id="Exp-CZ-Vem"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
<menuItem title="Services" id="NMo-om-nkz">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
<menuItem title="Hide ndpiExample" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="Ady-hI-5gd" id="PnN-Uc-m68"/>
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hideOtherApplications:" target="Ady-hI-5gd" id="VT4-aY-XCT"/>
</connections>
</menuItem>
<menuItem title="Show All" id="Kd2-mp-pUS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="unhideAllApplications:" target="Ady-hI-5gd" id="Dhg-Le-xox"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
<menuItem title="Quit ndpiExample" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="Ady-hI-5gd" id="Te7-pn-YzF"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="File" id="dMs-cI-mzQ">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="File" id="bib-Uj-vzu">
<items>
<menuItem title="New" keyEquivalent="n" id="Was-JA-tGl">
<connections>
<action selector="newDocument:" target="Ady-hI-5gd" id="4Si-XN-c54"/>
</connections>
</menuItem>
<menuItem title="Open…" keyEquivalent="o" id="IAo-SY-fd9">
<connections>
<action selector="openDocument:" target="Ady-hI-5gd" id="bVn-NM-KNZ"/>
</connections>
</menuItem>
<menuItem title="Open Recent" id="tXI-mr-wws">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Open Recent" systemMenu="recentDocuments" id="oas-Oc-fiZ">
<items>
<menuItem title="Clear Menu" id="vNY-rz-j42">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="clearRecentDocuments:" target="Ady-hI-5gd" id="Daa-9d-B3U"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="m54-Is-iLE"/>
<menuItem title="Close" keyEquivalent="w" id="DVo-aG-piG">
<connections>
<action selector="performClose:" target="Ady-hI-5gd" id="HmO-Ls-i7Q"/>
</connections>
</menuItem>
<menuItem title="Save…" keyEquivalent="s" id="pxx-59-PXV">
<connections>
<action selector="saveDocument:" target="Ady-hI-5gd" id="teZ-XB-qJY"/>
</connections>
</menuItem>
<menuItem title="Save As…" keyEquivalent="S" id="Bw7-FT-i3A">
<connections>
<action selector="saveDocumentAs:" target="Ady-hI-5gd" id="mDf-zr-I0C"/>
</connections>
</menuItem>
<menuItem title="Revert to Saved" keyEquivalent="r" id="KaW-ft-85H">
<connections>
<action selector="revertDocumentToSaved:" target="Ady-hI-5gd" id="iJ3-Pv-kwq"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="aJh-i4-bef"/>
<menuItem title="Page Setup…" keyEquivalent="P" id="qIS-W8-SiK">
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
<connections>
<action selector="runPageLayout:" target="Ady-hI-5gd" id="Din-rz-gC5"/>
</connections>
</menuItem>
<menuItem title="Print…" keyEquivalent="p" id="aTl-1u-JFS">
<connections>
<action selector="print:" target="Ady-hI-5gd" id="qaZ-4w-aoO"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Edit" id="5QF-Oa-p0T">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Edit" id="W48-6f-4Dl">
<items>
<menuItem title="Undo" keyEquivalent="z" id="dRJ-4n-Yzg">
<connections>
<action selector="undo:" target="Ady-hI-5gd" id="M6e-cu-g7V"/>
</connections>
</menuItem>
<menuItem title="Redo" keyEquivalent="Z" id="6dh-zS-Vam">
<connections>
<action selector="redo:" target="Ady-hI-5gd" id="oIA-Rs-6OD"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="WRV-NI-Exz"/>
<menuItem title="Cut" keyEquivalent="x" id="uRl-iY-unG">
<connections>
<action selector="cut:" target="Ady-hI-5gd" id="YJe-68-I9s"/>
</connections>
</menuItem>
<menuItem title="Copy" keyEquivalent="c" id="x3v-GG-iWU">
<connections>
<action selector="copy:" target="Ady-hI-5gd" id="G1f-GL-Joy"/>
</connections>
</menuItem>
<menuItem title="Paste" keyEquivalent="v" id="gVA-U4-sdL">
<connections>
<action selector="paste:" target="Ady-hI-5gd" id="UvS-8e-Qdg"/>
</connections>
</menuItem>
<menuItem title="Paste and Match Style" keyEquivalent="V" id="WeT-3V-zwk">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="pasteAsPlainText:" target="Ady-hI-5gd" id="cEh-KX-wJQ"/>
</connections>
</menuItem>
<menuItem title="Delete" id="pa3-QI-u2k">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="delete:" target="Ady-hI-5gd" id="0Mk-Ml-PaM"/>
</connections>
</menuItem>
<menuItem title="Select All" keyEquivalent="a" id="Ruw-6m-B2m">
<connections>
<action selector="selectAll:" target="Ady-hI-5gd" id="VNm-Mi-diN"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="uyl-h8-XO2"/>
<menuItem title="Find" id="4EN-yA-p0u">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Find" id="1b7-l0-nxx">
<items>
<menuItem title="Find…" tag="1" keyEquivalent="f" id="Xz5-n4-O0W">
<connections>
<action selector="performFindPanelAction:" target="Ady-hI-5gd" id="cD7-Qs-BN4"/>
</connections>
</menuItem>
<menuItem title="Find and Replace…" tag="12" keyEquivalent="f" id="YEy-JH-Tfz">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="performFindPanelAction:" target="Ady-hI-5gd" id="WD3-Gg-5AJ"/>
</connections>
</menuItem>
<menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye">
<connections>
<action selector="performFindPanelAction:" target="Ady-hI-5gd" id="NDo-RZ-v9R"/>
</connections>
</menuItem>
<menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV">
<connections>
<action selector="performFindPanelAction:" target="Ady-hI-5gd" id="HOh-sY-3ay"/>
</connections>
</menuItem>
<menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt">
<connections>
<action selector="performFindPanelAction:" target="Ady-hI-5gd" id="U76-nv-p5D"/>
</connections>
</menuItem>
<menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd">
<connections>
<action selector="centerSelectionInVisibleArea:" target="Ady-hI-5gd" id="IOG-6D-g5B"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Spelling and Grammar" id="Dv1-io-Yv7">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Spelling" id="3IN-sU-3Bg">
<items>
<menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="HFo-cy-zxI">
<connections>
<action selector="showGuessPanel:" target="Ady-hI-5gd" id="vFj-Ks-hy3"/>
</connections>
</menuItem>
<menuItem title="Check Document Now" keyEquivalent=";" id="hz2-CU-CR7">
<connections>
<action selector="checkSpelling:" target="Ady-hI-5gd" id="fz7-VC-reM"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="bNw-od-mp5"/>
<menuItem title="Check Spelling While Typing" id="rbD-Rh-wIN">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleContinuousSpellChecking:" target="Ady-hI-5gd" id="7w6-Qz-0kB"/>
</connections>
</menuItem>
<menuItem title="Check Grammar With Spelling" id="mK6-2p-4JG">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleGrammarChecking:" target="Ady-hI-5gd" id="muD-Qn-j4w"/>
</connections>
</menuItem>
<menuItem title="Correct Spelling Automatically" id="78Y-hA-62v">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticSpellingCorrection:" target="Ady-hI-5gd" id="2lM-Qi-WAP"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Substitutions" id="9ic-FL-obx">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Substitutions" id="FeM-D8-WVr">
<items>
<menuItem title="Show Substitutions" id="z6F-FW-3nz">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontSubstitutionsPanel:" target="Ady-hI-5gd" id="oku-mr-iSq"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="gPx-C9-uUO"/>
<menuItem title="Smart Copy/Paste" id="9yt-4B-nSM">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleSmartInsertDelete:" target="Ady-hI-5gd" id="3IJ-Se-DZD"/>
</connections>
</menuItem>
<menuItem title="Smart Quotes" id="hQb-2v-fYv">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticQuoteSubstitution:" target="Ady-hI-5gd" id="ptq-xd-QOA"/>
</connections>
</menuItem>
<menuItem title="Smart Dashes" id="rgM-f4-ycn">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticDashSubstitution:" target="Ady-hI-5gd" id="oCt-pO-9gS"/>
</connections>
</menuItem>
<menuItem title="Smart Links" id="cwL-P1-jid">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticLinkDetection:" target="Ady-hI-5gd" id="Gip-E3-Fov"/>
</connections>
</menuItem>
<menuItem title="Data Detectors" id="tRr-pd-1PS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticDataDetection:" target="Ady-hI-5gd" id="R1I-Nq-Kbl"/>
</connections>
</menuItem>
<menuItem title="Text Replacement" id="HFQ-gK-NFA">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticTextReplacement:" target="Ady-hI-5gd" id="DvP-Fe-Py6"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Transformations" id="2oI-Rn-ZJC">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Transformations" id="c8a-y6-VQd">
<items>
<menuItem title="Make Upper Case" id="vmV-6d-7jI">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="uppercaseWord:" target="Ady-hI-5gd" id="sPh-Tk-edu"/>
</connections>
</menuItem>
<menuItem title="Make Lower Case" id="d9M-CD-aMd">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="lowercaseWord:" target="Ady-hI-5gd" id="iUZ-b5-hil"/>
</connections>
</menuItem>
<menuItem title="Capitalize" id="UEZ-Bs-lqG">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="capitalizeWord:" target="Ady-hI-5gd" id="26H-TL-nsh"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Speech" id="xrE-MZ-jX0">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Speech" id="3rS-ZA-NoH">
<items>
<menuItem title="Start Speaking" id="Ynk-f8-cLZ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="startSpeaking:" target="Ady-hI-5gd" id="654-Ng-kyl"/>
</connections>
</menuItem>
<menuItem title="Stop Speaking" id="Oyz-dy-DGm">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="stopSpeaking:" target="Ady-hI-5gd" id="dX8-6p-jy9"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Format" id="jxT-CU-nIS">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Format" id="GEO-Iw-cKr">
<items>
<menuItem title="Font" id="Gi5-1S-RQB">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Font" systemMenu="font" id="aXa-aM-Jaq">
<items>
<menuItem title="Show Fonts" keyEquivalent="t" id="Q5e-8K-NDq">
<connections>
<action selector="orderFrontFontPanel:" target="YLy-65-1bz" id="WHr-nq-2xA"/>
</connections>
</menuItem>
<menuItem title="Bold" tag="2" keyEquivalent="b" id="GB9-OM-e27">
<connections>
<action selector="addFontTrait:" target="YLy-65-1bz" id="hqk-hr-sYV"/>
</connections>
</menuItem>
<menuItem title="Italic" tag="1" keyEquivalent="i" id="Vjx-xi-njq">
<connections>
<action selector="addFontTrait:" target="YLy-65-1bz" id="IHV-OB-c03"/>
</connections>
</menuItem>
<menuItem title="Underline" keyEquivalent="u" id="WRG-CD-K1S">
<connections>
<action selector="underline:" target="Ady-hI-5gd" id="FYS-2b-JAY"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="5gT-KC-WSO"/>
<menuItem title="Bigger" tag="3" keyEquivalent="+" id="Ptp-SP-VEL">
<connections>
<action selector="modifyFont:" target="YLy-65-1bz" id="Uc7-di-UnL"/>
</connections>
</menuItem>
<menuItem title="Smaller" tag="4" keyEquivalent="-" id="i1d-Er-qST">
<connections>
<action selector="modifyFont:" target="YLy-65-1bz" id="HcX-Lf-eNd"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kx3-Dk-x3B"/>
<menuItem title="Kern" id="jBQ-r6-VK2">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Kern" id="tlD-Oa-oAM">
<items>
<menuItem title="Use Default" id="GUa-eO-cwY">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="useStandardKerning:" target="Ady-hI-5gd" id="6dk-9l-Ckg"/>
</connections>
</menuItem>
<menuItem title="Use None" id="cDB-IK-hbR">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="turnOffKerning:" target="Ady-hI-5gd" id="U8a-gz-Maa"/>
</connections>
</menuItem>
<menuItem title="Tighten" id="46P-cB-AYj">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="tightenKerning:" target="Ady-hI-5gd" id="hr7-Nz-8ro"/>
</connections>
</menuItem>
<menuItem title="Loosen" id="ogc-rX-tC1">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="loosenKerning:" target="Ady-hI-5gd" id="8i4-f9-FKE"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Ligatures" id="o6e-r0-MWq">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Ligatures" id="w0m-vy-SC9">
<items>
<menuItem title="Use Default" id="agt-UL-0e3">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="useStandardLigatures:" target="Ady-hI-5gd" id="7uR-wd-Dx6"/>
</connections>
</menuItem>
<menuItem title="Use None" id="J7y-lM-qPV">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="turnOffLigatures:" target="Ady-hI-5gd" id="iX2-gA-Ilz"/>
</connections>
</menuItem>
<menuItem title="Use All" id="xQD-1f-W4t">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="useAllLigatures:" target="Ady-hI-5gd" id="KcB-kA-TuK"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Baseline" id="OaQ-X3-Vso">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Baseline" id="ijk-EB-dga">
<items>
<menuItem title="Use Default" id="3Om-Ey-2VK">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="unscript:" target="Ady-hI-5gd" id="0vZ-95-Ywn"/>
</connections>
</menuItem>
<menuItem title="Superscript" id="Rqc-34-cIF">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="superscript:" target="Ady-hI-5gd" id="3qV-fo-wpU"/>
</connections>
</menuItem>
<menuItem title="Subscript" id="I0S-gh-46l">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="subscript:" target="Ady-hI-5gd" id="Q6W-4W-IGz"/>
</connections>
</menuItem>
<menuItem title="Raise" id="2h7-ER-AoG">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="raiseBaseline:" target="Ady-hI-5gd" id="4sk-31-7Q9"/>
</connections>
</menuItem>
<menuItem title="Lower" id="1tx-W0-xDw">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="lowerBaseline:" target="Ady-hI-5gd" id="OF1-bc-KW4"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="Ndw-q3-faq"/>
<menuItem title="Show Colors" keyEquivalent="C" id="bgn-CT-cEk">
<connections>
<action selector="orderFrontColorPanel:" target="Ady-hI-5gd" id="mSX-Xz-DV3"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="iMs-zA-UFJ"/>
<menuItem title="Copy Style" keyEquivalent="c" id="5Vv-lz-BsD">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="copyFont:" target="Ady-hI-5gd" id="GJO-xA-L4q"/>
</connections>
</menuItem>
<menuItem title="Paste Style" keyEquivalent="v" id="vKC-jM-MkH">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="pasteFont:" target="Ady-hI-5gd" id="JfD-CL-leO"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Text" id="Fal-I4-PZk">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Text" id="d9c-me-L2H">
<items>
<menuItem title="Align Left" keyEquivalent="{" id="ZM1-6Q-yy1">
<connections>
<action selector="alignLeft:" target="Ady-hI-5gd" id="zUv-R1-uAa"/>
</connections>
</menuItem>
<menuItem title="Center" keyEquivalent="|" id="VIY-Ag-zcb">
<connections>
<action selector="alignCenter:" target="Ady-hI-5gd" id="spX-mk-kcS"/>
</connections>
</menuItem>
<menuItem title="Justify" id="J5U-5w-g23">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="alignJustified:" target="Ady-hI-5gd" id="ljL-7U-jND"/>
</connections>
</menuItem>
<menuItem title="Align Right" keyEquivalent="}" id="wb2-vD-lq4">
<connections>
<action selector="alignRight:" target="Ady-hI-5gd" id="r48-bG-YeY"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="4s2-GY-VfK"/>
<menuItem title="Writing Direction" id="H1b-Si-o9J">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Writing Direction" id="8mr-sm-Yjd">
<items>
<menuItem title="Paragraph" enabled="NO" id="ZvO-Gk-QUH">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem id="YGs-j5-SAR">
<string key="title"> Default</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeBaseWritingDirectionNatural:" target="Ady-hI-5gd" id="qtV-5e-UBP"/>
</connections>
</menuItem>
<menuItem id="Lbh-J2-qVU">
<string key="title"> Left to Right</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeBaseWritingDirectionLeftToRight:" target="Ady-hI-5gd" id="S0X-9S-QSf"/>
</connections>
</menuItem>
<menuItem id="jFq-tB-4Kx">
<string key="title"> Right to Left</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeBaseWritingDirectionRightToLeft:" target="Ady-hI-5gd" id="5fk-qB-AqJ"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="swp-gr-a21"/>
<menuItem title="Selection" enabled="NO" id="cqv-fj-IhA">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem id="Nop-cj-93Q">
<string key="title"> Default</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeTextWritingDirectionNatural:" target="Ady-hI-5gd" id="lPI-Se-ZHp"/>
</connections>
</menuItem>
<menuItem id="BgM-ve-c93">
<string key="title"> Left to Right</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeTextWritingDirectionLeftToRight:" target="Ady-hI-5gd" id="caW-Bv-w94"/>
</connections>
</menuItem>
<menuItem id="RB4-Sm-HuC">
<string key="title"> Right to Left</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeTextWritingDirectionRightToLeft:" target="Ady-hI-5gd" id="EXD-6r-ZUu"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="fKy-g9-1gm"/>
<menuItem title="Show Ruler" id="vLm-3I-IUL">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleRuler:" target="Ady-hI-5gd" id="FOx-HJ-KwY"/>
</connections>
</menuItem>
<menuItem title="Copy Ruler" keyEquivalent="c" id="MkV-Pr-PK5">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="copyRuler:" target="Ady-hI-5gd" id="71i-fW-3W2"/>
</connections>
</menuItem>
<menuItem title="Paste Ruler" keyEquivalent="v" id="LVM-kO-fVI">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="pasteRuler:" target="Ady-hI-5gd" id="cSh-wd-qM2"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="View" id="H8h-7b-M4v">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="View" id="HyV-fh-RgO">
<items>
<menuItem title="Show Toolbar" keyEquivalent="t" id="snW-S8-Cw5">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="toggleToolbarShown:" target="Ady-hI-5gd" id="BXY-wc-z0C"/>
</connections>
</menuItem>
<menuItem title="Customize Toolbar…" id="1UK-8n-QPP">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="runToolbarCustomizationPalette:" target="Ady-hI-5gd" id="pQI-g3-MTW"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="hB3-LF-h0Y"/>
<menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="toggleSourceList:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
</connections>
</menuItem>
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="toggleFullScreen:" target="Ady-hI-5gd" id="dU3-MA-1Rq"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Window" id="aUF-d1-5bR">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
<items>
<menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
<connections>
<action selector="performMiniaturize:" target="Ady-hI-5gd" id="VwT-WD-YPe"/>
</connections>
</menuItem>
<menuItem title="Zoom" id="R4o-n2-Eq4">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="performZoom:" target="Ady-hI-5gd" id="DIl-cC-cCs"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
<menuItem title="Bring All to Front" id="LE2-aR-0XJ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="arrangeInFront:" target="Ady-hI-5gd" id="DRN-fu-gQh"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Help" id="wpr-3q-Mcd">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Help" systemMenu="help" id="F2S-fz-NVQ">
<items>
<menuItem title="ndpiExample Help" keyEquivalent="?" id="FKE-Sm-Kum">
<connections>
<action selector="showHelp:" target="Ady-hI-5gd" id="y7X-2Q-9no"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
</connections>
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="75" y="0.0"/>
</scene>
<!--Window Controller-->
<scene sceneID="R2V-B0-nI4">
<objects>
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<connections>
<outlet property="delegate" destination="B8D-0N-5wS" id="98r-iN-zZc"/>
</connections>
</window>
<connections>
<segue destination="XfG-lQ-9wD" kind="relationship" relationship="window.shadowedContentViewController" id="cq2-FE-JQM"/>
</connections>
</windowController>
<customObject id="Oky-zY-oP4" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="75" y="250"/>
</scene>
<!--View Controller-->
<scene sceneID="hIz-AP-VOD">
<objects>
<viewController id="XfG-lQ-9wD" customClass="ViewController" sceneMemberID="viewController">
<view key="view" wantsLayer="YES" id="m2S-Jp-Qdl">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jdf-YK-4JB">
<rect key="frame" x="23" y="173" width="64" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Run" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="1eG-Fb-Ybk">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="onRunButtonClicked:" target="XfG-lQ-9wD" id="zyK-t7-vwt"/>
</connections>
</button>
</subviews>
</view>
</viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="75" y="655"/>
</scene>
</scenes>
</document>
@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018年 ZengYingpei. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
@@ -1,29 +0,0 @@
/*
*
* Copyright (C) 2011-18 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
#import <Cocoa/Cocoa.h>
@interface ViewController : NSViewController
@end
@@ -1,106 +0,0 @@
/*
*
* Copyright (C) 2011-18 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
#import "ViewController.h"
#include "ndpi_api.h"
// Declare the orginal_main defined in ndpiReader.c here
extern int orginal_main(int argc, char **argv);
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)setRepresentedObject:(id)representedObject {
[super setRepresentedObject:representedObject];
// Update the view, if already loaded.
}
- (IBAction)onRunButtonClicked:(id)sender
{
char* args[10];
extern int optind;
optind = 1; // reset the parse of getopt_long
// Check the "nDPI_QuickStartGuide.pdf" for comand option explanation.
/* Following code it to execute below command (remember to change args[2] to
* absolute path):
* ./ndpiReader -i capture.pcap
*/
args[0] = (char*)"ndpiReader";
args[1] = (char*)"-i";
NSString* pcap_file = [[NSBundle mainBundle]pathForResource:@"capture" ofType:@"pcap"];
args[2] = (char*)[pcap_file cStringUsingEncoding:NSUTF8StringEncoding];
// Change to you pcap file path if you want.
//args[2] = (char*)"/Users/zengyingpei/Documents/code/nDPI/example/MacOS/ndpiExample/ndpiExample/capture.pcap";
// Remember to change below number of args when you change to other command inputs.
orginal_main(3, args);
/* Following code it to execute below command:
* ./ndpiReader -i en1 -s 10 -p protos.txt
* The process seems to be not support re-entering. You may have to re-run the App.
*/
/*
args[0] = (char*)"ndpiReader";
args[1] = (char*)"-i";
args[2] = (char*)"en0";
args[3] = (char*)"-s";
args[4] = (char*)"10";
args[5] = (char*)"-p";
NSString* proto_file = [[NSBundle mainBundle]pathForResource:@"protos" ofType:@"txt"];
args[6] = (char*)[proto_file cStringUsingEncoding:NSUTF8StringEncoding];
//args[6] = (char*)"/Users/zengyingpei/Documents/code/nDPI/example/protos.txt";
orginal_main(7, args);
*/
}
// In order to fix the missing of NDPI_LOG_DEBUG2 (used in ndpi_main.c), we define
// NDPI_LOG_DEBUG2 as NDPI_LOG_DEBUG2_XCODE_PROJ.
void vNDPI_LOG_DEBUG2_XCODE_PROJ(struct ndpi_detection_module_struct * ndpi_struct,
const char *format, va_list ap)
{
vprintf(format, ap);
}
void NDPI_LOG_DEBUG2_XCODE_PROJ(struct ndpi_detection_module_struct * ndpi_struct,
const char *format, ...)
{
va_list ap;
va_start (ap, format);
vNDPI_LOG_DEBUG2_XCODE_PROJ(ndpi_struct, format, ap);
va_end (ap);
}
@end
Binary file not shown.
@@ -1,27 +0,0 @@
/*
*
* Copyright (C) 2011-18 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
#import <Cocoa/Cocoa.h>
int main(int argc, const char * argv[]) {
return NSApplicationMain(argc, argv);
}
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
@@ -1,29 +0,0 @@
/*
*
* Copyright (C) 2011-18 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ndpi_utils_h
#define ndpi_utils_h
// Empty placeholder head file. Just to make the compilations of protocols/attic/ftp.c and
// protocols/attic/secondlife.c don't break.
#endif /* ndpi_utils_h */
+5 -5
View File
@@ -1,12 +1,12 @@
bin_PROGRAMS = ndpiReader bin_PROGRAMS = ndpiReader
AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/lib/third_party/include @PCAP_INC@ @HS_INC@ AM_CPPFLAGS = -I$(top_srcdir)/src/include @PCAP_INC@
AM_CFLAGS = @PTHREAD_CFLAGS@ # --coverage AM_CFLAGS = @PTHREAD_CFLAGS@
LDADD = $(top_builddir)/src/lib/libndpi.la @JSON_C_LIB@ @PTHREAD_LIBS@ @PCAP_LIB@ @DL_LIB@ @HS_LIB@ -lm LDADD = $(top_builddir)/src/lib/libndpi.la @JSON_C_LIB@ @PTHREAD_LIBS@ @PCAP_LIB@
AM_LDFLAGS = -static @DL_LIB@ @HS_LIB@ AM_LDFLAGS = -static
ndpiReader_SOURCES = ndpiReader.c ndpi_util.c ndpi_util.h uthash.h ndpiReader_SOURCES = ndpiReader.c ndpi_util.c
ndpiReader.o: ndpiReader.c ndpiReader.o: ndpiReader.c
+141 -1998
View File
File diff suppressed because it is too large Load Diff
+197 -411
View File
@@ -1,7 +1,7 @@
/* /*
* ndpi_util.c * ndpi_util.c
* *
* Copyright (C) 2011-17 - ntop.org * Copyright (C) 2011-16 - ntop.org
* *
* This file is part of nDPI, an open source deep packet inspection * This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH * library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -48,7 +48,6 @@
#define MPLS_MULTI 0x8848 #define MPLS_MULTI 0x8848
#define PPPoE 0x8864 #define PPPoE 0x8864
#define SNAP 0xaa #define SNAP 0xaa
#define BSTP 0x42 /* Bridge Spanning Tree Protocol */
/* mask for FCF */ /* mask for FCF */
#define WIFI_DATA 0x2 /* 0000 0010 */ #define WIFI_DATA 0x2 /* 0000 0010 */
@@ -63,9 +62,8 @@
#define GTP_U_V1_PORT 2152 #define GTP_U_V1_PORT 2152
#define TZSP_PORT 37008 #define TZSP_PORT 37008
#ifndef DLT_LINUX_SLL #define SIZEOF_ID_STRUCT (sizeof(struct ndpi_id_struct))
#define DLT_LINUX_SLL 113 #define SIZEOF_FLOW_STRUCT (sizeof(struct ndpi_flow_struct))
#endif
#include "ndpi_main.h" #include "ndpi_main.h"
#include "ndpi_util.h" #include "ndpi_util.h"
@@ -73,13 +71,18 @@
/* ***************************************************** */ /* ***************************************************** */
void ndpi_free_flow_info_half(struct ndpi_flow_info *flow) { void ndpi_free_flow_info_half(struct ndpi_flow_info *flow) {
if(flow->ndpi_flow) { ndpi_flow_free(flow->ndpi_flow); flow->ndpi_flow = NULL; } if(flow->ndpi_flow) { ndpi_free_flow(flow->ndpi_flow); flow->ndpi_flow = NULL; }
if(flow->src_id) { ndpi_free(flow->src_id); flow->src_id = NULL; } if(flow->src_id) { ndpi_free(flow->src_id); flow->src_id = NULL; }
if(flow->dst_id) { ndpi_free(flow->dst_id); flow->dst_id = NULL; } if(flow->dst_id) { ndpi_free(flow->dst_id); flow->dst_id = NULL; }
} }
/* ***************************************************** */ /* ***************************************************** */
static const u_int8_t nDPI_traceLevel = 0;
/* ***************************************************** */
extern u_int32_t current_ndpi_memory, max_ndpi_memory; extern u_int32_t current_ndpi_memory, max_ndpi_memory;
/** /**
@@ -105,64 +108,9 @@ static void free_wrapper(void *freeable) {
/* ***************************************************** */ /* ***************************************************** */
static uint16_t ndpi_get_proto_id(struct ndpi_detection_module_struct *ndpi_mod, const char *name) {
uint16_t proto_id;
char *e;
unsigned long p = strtol(name,&e,0);
if(e && !*e) {
if(p < NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS &&
ndpi_mod->proto_defaults[p].protoName) return (uint16_t)p;
return NDPI_PROTOCOL_UNKNOWN;
}
for(proto_id=NDPI_PROTOCOL_UNKNOWN; proto_id < NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS; proto_id++) {
if(ndpi_mod->proto_defaults[proto_id].protoName &&
!strcasecmp(ndpi_mod->proto_defaults[proto_id].protoName,name))
return proto_id;
}
return NDPI_PROTOCOL_UNKNOWN;
}
static NDPI_PROTOCOL_BITMASK debug_bitmask;
static char _proto_delim[] = " \t,:;";
static int parse_debug_proto(struct ndpi_detection_module_struct *ndpi_mod, char *str) {
char *n;
uint16_t proto;
char op=1;
for(n = strtok(str,_proto_delim); n && *n; n = strtok(NULL,_proto_delim)) {
if(*n == '-') {
op = 0;
n++;
} else if(*n == '+') {
op = 1;
n++;
}
if(!strcmp(n,"all")) {
if(op)
NDPI_BITMASK_SET_ALL(debug_bitmask);
else
NDPI_BITMASK_RESET(debug_bitmask);
continue;
}
proto = ndpi_get_proto_id(ndpi_mod, n);
if(proto == NDPI_PROTOCOL_UNKNOWN && strcmp(n,"unknown") && strcmp(n,"0")) {
fprintf(stderr,"Invalid protocol %s\n",n);
return 1;
}
if(op)
NDPI_BITMASK_ADD(debug_bitmask,proto);
else
NDPI_BITMASK_DEL(debug_bitmask,proto);
}
return 0;
}
/* ***************************************************** */
extern char *_debug_protocols;
static int _debug_protocols_ok = 0;
struct ndpi_workflow * ndpi_workflow_init(const struct ndpi_workflow_prefs * prefs, pcap_t * pcap_handle) { struct ndpi_workflow * ndpi_workflow_init(const struct ndpi_workflow_prefs * prefs, pcap_t * pcap_handle) {
set_ndpi_malloc(malloc_wrapper), set_ndpi_free(free_wrapper); set_ndpi_malloc(malloc_wrapper), set_ndpi_free(free_wrapper);
set_ndpi_flow_malloc(NULL), set_ndpi_flow_free(NULL);
/* TODO: just needed here to init ndpi malloc wrapper */ /* TODO: just needed here to init ndpi malloc wrapper */
struct ndpi_detection_module_struct * module = ndpi_init_detection_module(); struct ndpi_detection_module_struct * module = ndpi_init_detection_module();
@@ -176,25 +124,14 @@ struct ndpi_workflow * ndpi_workflow_init(const struct ndpi_workflow_prefs * pre
NDPI_LOG(0, NULL, NDPI_LOG_ERROR, "global structure initialization failed\n"); NDPI_LOG(0, NULL, NDPI_LOG_ERROR, "global structure initialization failed\n");
exit(-1); exit(-1);
} }
module->ndpi_log_level = nDPI_LogLevel;
if(_debug_protocols != NULL && ! _debug_protocols_ok) {
if(parse_debug_proto(module,_debug_protocols))
exit(-1);
_debug_protocols_ok = 1;
}
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
NDPI_BITMASK_RESET(module->debug_bitmask);
if(_debug_protocols_ok)
module->debug_bitmask = debug_bitmask;
#endif
workflow->ndpi_flows_root = ndpi_calloc(workflow->prefs.num_roots, sizeof(void *)); workflow->ndpi_flows_root = ndpi_calloc(workflow->prefs.num_roots, sizeof(void *));
return workflow; return workflow;
} }
/* ***************************************************** */ /* ***************************************************** */
void ndpi_flow_info_freer(void *node) { static void ndpi_flow_info_freer(void *node) {
struct ndpi_flow_info *flow = (struct ndpi_flow_info*)node; struct ndpi_flow_info *flow = (struct ndpi_flow_info*)node;
ndpi_free_flow_info_half(flow); ndpi_free_flow_info_half(flow);
@@ -220,54 +157,14 @@ int ndpi_workflow_node_cmp(const void *a, const void *b) {
struct ndpi_flow_info *fa = (struct ndpi_flow_info*)a; struct ndpi_flow_info *fa = (struct ndpi_flow_info*)a;
struct ndpi_flow_info *fb = (struct ndpi_flow_info*)b; struct ndpi_flow_info *fb = (struct ndpi_flow_info*)b;
if(fa->hashval < fb->hashval) return(-1); else if(fa->hashval > fb->hashval) return(1);
/* Flows have the same hash */
if(fa->vlan_id < fb->vlan_id ) return(-1); else { if(fa->vlan_id > fb->vlan_id ) return(1); } if(fa->vlan_id < fb->vlan_id ) return(-1); else { if(fa->vlan_id > fb->vlan_id ) return(1); }
if(fa->lower_ip < fb->lower_ip ) return(-1); else { if(fa->lower_ip > fb->lower_ip ) return(1); }
if(fa->lower_port < fb->lower_port) return(-1); else { if(fa->lower_port > fb->lower_port) return(1); }
if(fa->upper_ip < fb->upper_ip ) return(-1); else { if(fa->upper_ip > fb->upper_ip ) return(1); }
if(fa->upper_port < fb->upper_port) return(-1); else { if(fa->upper_port > fb->upper_port) return(1); }
if(fa->protocol < fb->protocol ) return(-1); else { if(fa->protocol > fb->protocol ) return(1); } if(fa->protocol < fb->protocol ) return(-1); else { if(fa->protocol > fb->protocol ) return(1); }
if(
(
(fa->src_ip == fb->src_ip )
&& (fa->src_port == fb->src_port)
&& (fa->dst_ip == fb->dst_ip )
&& (fa->dst_port == fb->dst_port)
)
||
(
(fa->src_ip == fb->dst_ip )
&& (fa->src_port == fb->dst_port)
&& (fa->dst_ip == fb->src_ip )
&& (fa->dst_port == fb->src_port)
)
)
return(0); return(0);
if(fa->src_ip < fb->src_ip ) return(-1); else { if(fa->src_ip > fb->src_ip ) return(1); }
if(fa->src_port < fb->src_port) return(-1); else { if(fa->src_port > fb->src_port) return(1); }
if(fa->dst_ip < fb->dst_ip ) return(-1); else { if(fa->dst_ip > fb->dst_ip ) return(1); }
if(fa->dst_port < fb->dst_port) return(-1); else { if(fa->dst_port > fb->dst_port) return(1); }
return(0); /* notreached */
}
/* ***************************************************** */
static void patchIPv6Address(char *str) {
int i = 0, j = 0;
while(str[i] != '\0') {
if((str[i] == ':')
&& (str[i+1] == '0')
&& (str[i+2] == ':')) {
str[j++] = ':';
str[j++] = ':';
i += 3;
} else
str[j++] = str[i++];
}
if(str[j] != '\0') str[j] = '\0';
} }
/* ***************************************************** */ /* ***************************************************** */
@@ -289,7 +186,11 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow
u_int8_t **payload, u_int8_t **payload,
u_int16_t *payload_len, u_int16_t *payload_len,
u_int8_t *src_to_dst_direction) { u_int8_t *src_to_dst_direction) {
u_int32_t idx, l4_offset, hashval; u_int32_t idx, l4_offset;
u_int32_t lower_ip;
u_int32_t upper_ip;
u_int16_t lower_port;
u_int16_t upper_port;
struct ndpi_flow_info flow; struct ndpi_flow_info flow;
void *ret; void *ret;
u_int8_t *l3, *l4; u_int8_t *l3, *l4;
@@ -298,12 +199,12 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow
Note: to keep things simple (ndpiReader is just a demo app) Note: to keep things simple (ndpiReader is just a demo app)
we handle IPv6 a-la-IPv4. we handle IPv6 a-la-IPv4.
*/ */
if(version == IPVERSION) { if(version == 4) {
if(ipsize < 20) if(ipsize < 20)
return NULL; return NULL;
if((iph->ihl * 4) > ipsize || ipsize < ntohs(iph->tot_len) if((iph->ihl * 4) > ipsize || ipsize < ntohs(iph->tot_len)
/* || (iph->frag_off & htons(0x1FFF)) != 0 */) || (iph->frag_off & htons(0x1FFF)) != 0)
return NULL; return NULL;
l4_offset = iph->ihl * 4; l4_offset = iph->ihl * 4;
@@ -329,107 +230,134 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow
if(l4_packet_len > workflow->stats.max_packet_len) if(l4_packet_len > workflow->stats.max_packet_len)
workflow->stats.max_packet_len = l4_packet_len; workflow->stats.max_packet_len = l4_packet_len;
if(iph->saddr < iph->daddr) {
lower_ip = iph->saddr;
upper_ip = iph->daddr;
} else {
lower_ip = iph->daddr;
upper_ip = iph->saddr;
}
*proto = iph->protocol; *proto = iph->protocol;
l4 = ((u_int8_t *) l3 + l4_offset); l4 = ((u_int8_t *) l3 + l4_offset);
if(iph->protocol == IPPROTO_TCP && l4_packet_len >= 20) { if(iph->protocol == 6 && l4_packet_len >= 20) {
u_int tcp_len; u_int tcp_len;
// tcp
workflow->stats.tcp_count++; workflow->stats.tcp_count++;
// tcp
*tcph = (struct ndpi_tcphdr *)l4; *tcph = (struct ndpi_tcphdr *)l4;
*sport = ntohs((*tcph)->source), *dport = ntohs((*tcph)->dest); *sport = ntohs((*tcph)->source), *dport = ntohs((*tcph)->dest);
if(iph->saddr < iph->daddr) {
lower_port = (*tcph)->source, upper_port = (*tcph)->dest;
*src_to_dst_direction = 1;
} else {
lower_port = (*tcph)->dest;
upper_port = (*tcph)->source;
*src_to_dst_direction = 0;
if(iph->saddr == iph->daddr) {
if(lower_port > upper_port) {
u_int16_t p = lower_port;
lower_port = upper_port;
upper_port = p;
}
}
}
tcp_len = ndpi_min(4*(*tcph)->doff, l4_packet_len); tcp_len = ndpi_min(4*(*tcph)->doff, l4_packet_len);
*payload = &l4[tcp_len]; *payload = &l4[tcp_len];
*payload_len = ndpi_max(0, l4_packet_len-4*(*tcph)->doff); *payload_len = ndpi_max(0, l4_packet_len-4*(*tcph)->doff);
} else if(iph->protocol == IPPROTO_UDP && l4_packet_len >= 8) { } else if(iph->protocol == 17 && l4_packet_len >= 8) {
// udp // udp
workflow->stats.udp_count++; workflow->stats.udp_count++;
*udph = (struct ndpi_udphdr *)l4; *udph = (struct ndpi_udphdr *)l4;
*sport = ntohs((*udph)->source), *dport = ntohs((*udph)->dest); *sport = ntohs((*udph)->source), *dport = ntohs((*udph)->dest);
*payload = &l4[sizeof(struct ndpi_udphdr)]; *payload = &l4[sizeof(struct ndpi_udphdr)];
*payload_len = ndpi_max(0, l4_packet_len-sizeof(struct ndpi_udphdr)); *payload_len = ndpi_max(0, l4_packet_len-sizeof(struct ndpi_udphdr));
if(iph->saddr < iph->daddr) {
lower_port = (*udph)->source, upper_port = (*udph)->dest;
*src_to_dst_direction = 1;
} else {
lower_port = (*udph)->dest, upper_port = (*udph)->source;
*src_to_dst_direction = 0;
if(iph->saddr == iph->daddr) {
if(lower_port > upper_port) {
u_int16_t p = lower_port;
lower_port = upper_port;
upper_port = p;
}
}
}
*sport = ntohs(lower_port), *dport = ntohs(upper_port);
} else { } else {
// non tcp/udp protocols // non tcp/udp protocols
*sport = *dport = 0; lower_port = 0;
upper_port = 0;
} }
flow.protocol = iph->protocol, flow.vlan_id = vlan_id; flow.protocol = iph->protocol, flow.vlan_id = vlan_id;
flow.src_ip = iph->saddr, flow.dst_ip = iph->daddr; flow.lower_ip = lower_ip, flow.upper_ip = upper_ip;
flow.src_port = htons(*sport), flow.dst_port = htons(*dport); flow.lower_port = lower_port, flow.upper_port = upper_port;
flow.hashval = hashval = flow.protocol + flow.vlan_id + flow.src_ip + flow.dst_ip + flow.src_port + flow.dst_port;
idx = hashval % workflow->prefs.num_roots; if(0)
NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_DEBUG, "[NDPI] [%u][%u:%u <-> %u:%u]\n",
iph->protocol, lower_ip, ntohs(lower_port), upper_ip, ntohs(upper_port));
idx = (vlan_id + lower_ip + upper_ip + iph->protocol + lower_port + upper_port) % workflow->prefs.num_roots;
ret = ndpi_tfind(&flow, &workflow->ndpi_flows_root[idx], ndpi_workflow_node_cmp); ret = ndpi_tfind(&flow, &workflow->ndpi_flows_root[idx], ndpi_workflow_node_cmp);
/* to avoid two nodes in one binary tree for a flow */
int is_changed = 0;
if(ret == NULL)
{
u_int32_t orig_src_ip = flow.src_ip;
u_int16_t orig_src_port = flow.src_port;
u_int32_t orig_dst_ip = flow.dst_ip;
u_int16_t orig_dst_port = flow.dst_port;
flow.src_ip = orig_dst_ip;
flow.src_port = orig_dst_port;
flow.dst_ip = orig_src_ip;
flow.dst_port = orig_src_port;
is_changed = 1;
ret = ndpi_tfind(&flow, &workflow->ndpi_flows_root[idx], ndpi_workflow_node_cmp);
}
if(ret == NULL) { if(ret == NULL) {
if(workflow->stats.ndpi_flow_count == workflow->prefs.max_ndpi_flows) { if(workflow->stats.ndpi_flow_count == workflow->prefs.max_ndpi_flows) {
NDPI_LOG(0, workflow->ndpi_struct, NDPI_LOG_ERROR, NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_ERROR, "maximum flow count (%u) has been exceeded\n", workflow->prefs.max_ndpi_flows);
"maximum flow count (%u) has been exceeded\n",
workflow->prefs.max_ndpi_flows);
exit(-1); exit(-1);
} else { } else {
struct ndpi_flow_info *newflow = (struct ndpi_flow_info*)malloc(sizeof(struct ndpi_flow_info)); struct ndpi_flow_info *newflow = (struct ndpi_flow_info*)malloc(sizeof(struct ndpi_flow_info));
if(newflow == NULL) { if(newflow == NULL) {
NDPI_LOG(0, workflow->ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(1): not enough memory\n", __FUNCTION__); NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(1): not enough memory\n", __FUNCTION__);
return(NULL); return(NULL);
} else
workflow->num_allocated_flows++;
memset(newflow, 0, sizeof(struct ndpi_flow_info));
newflow->hashval = hashval;
newflow->protocol = iph->protocol, newflow->vlan_id = vlan_id;
newflow->src_ip = iph->saddr, newflow->dst_ip = iph->daddr;
newflow->src_port = htons(*sport), newflow->dst_port = htons(*dport);
newflow->ip_version = version;
if(version == IPVERSION) {
inet_ntop(AF_INET, &newflow->src_ip, newflow->src_name, sizeof(newflow->src_name));
inet_ntop(AF_INET, &newflow->dst_ip, newflow->dst_name, sizeof(newflow->dst_name));
} else {
inet_ntop(AF_INET6, &iph6->ip6_src, newflow->src_name, sizeof(newflow->src_name));
inet_ntop(AF_INET6, &iph6->ip6_dst, newflow->dst_name, sizeof(newflow->dst_name));
/* For consistency across platforms replace :0: with :: */
patchIPv6Address(newflow->src_name), patchIPv6Address(newflow->dst_name);
} }
if((newflow->ndpi_flow = ndpi_flow_malloc(SIZEOF_FLOW_STRUCT)) == NULL) { memset(newflow, 0, sizeof(struct ndpi_flow_info));
NDPI_LOG(0, workflow->ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(2): not enough memory\n", __FUNCTION__); newflow->protocol = iph->protocol, newflow->vlan_id = vlan_id;
newflow->lower_ip = lower_ip, newflow->upper_ip = upper_ip;
newflow->lower_port = lower_port, newflow->upper_port = upper_port;
newflow->ip_version = version;
if(version == 4) {
inet_ntop(AF_INET, &lower_ip, newflow->lower_name, sizeof(newflow->lower_name));
inet_ntop(AF_INET, &upper_ip, newflow->upper_name, sizeof(newflow->upper_name));
} else {
inet_ntop(AF_INET6, &iph6->ip6_src, newflow->lower_name, sizeof(newflow->lower_name));
inet_ntop(AF_INET6, &iph6->ip6_dst, newflow->upper_name, sizeof(newflow->upper_name));
}
if((newflow->ndpi_flow = ndpi_malloc(SIZEOF_FLOW_STRUCT)) == NULL) {
NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(2): not enough memory\n", __FUNCTION__);
free(newflow); free(newflow);
return(NULL); return(NULL);
} else } else
memset(newflow->ndpi_flow, 0, SIZEOF_FLOW_STRUCT); memset(newflow->ndpi_flow, 0, SIZEOF_FLOW_STRUCT);
if((newflow->src_id = ndpi_malloc(SIZEOF_ID_STRUCT)) == NULL) { if((newflow->src_id = ndpi_malloc(SIZEOF_ID_STRUCT)) == NULL) {
NDPI_LOG(0, workflow->ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(3): not enough memory\n", __FUNCTION__); NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(3): not enough memory\n", __FUNCTION__);
free(newflow); free(newflow);
return(NULL); return(NULL);
} else } else
memset(newflow->src_id, 0, SIZEOF_ID_STRUCT); memset(newflow->src_id, 0, SIZEOF_ID_STRUCT);
if((newflow->dst_id = ndpi_malloc(SIZEOF_ID_STRUCT)) == NULL) { if((newflow->dst_id = ndpi_malloc(SIZEOF_ID_STRUCT)) == NULL) {
NDPI_LOG(0, workflow->ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(4): not enough memory\n", __FUNCTION__); NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(4): not enough memory\n", __FUNCTION__);
free(newflow); free(newflow);
return(NULL); return(NULL);
} else } else
@@ -445,26 +373,12 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow
} else { } else {
struct ndpi_flow_info *flow = *(struct ndpi_flow_info**)ret; struct ndpi_flow_info *flow = *(struct ndpi_flow_info**)ret;
if (is_changed) { if(flow->lower_ip == lower_ip && flow->upper_ip == upper_ip
if(flow->src_ip == iph->saddr && flow->lower_port == lower_port && flow->upper_port == upper_port)
&& flow->dst_ip == iph->daddr *src = flow->src_id, *dst = flow->dst_id;
&& flow->src_port == htons(*sport)
&& flow->dst_port == htons(*dport)
)
*src = flow->dst_id, *dst = flow->src_id, *src_to_dst_direction = 0, flow->bidirectional = 1;
else else
*src = flow->src_id, *dst = flow->dst_id, *src_to_dst_direction = 1; *src = flow->dst_id, *dst = flow->src_id;
}
else {
if(flow->src_ip == iph->saddr
&& flow->dst_ip == iph->daddr
&& flow->src_port == htons(*sport)
&& flow->dst_port == htons(*dport)
)
*src = flow->src_id, *dst = flow->dst_id, *src_to_dst_direction = 1;
else
*src = flow->dst_id, *dst = flow->src_id, *src_to_dst_direction = 0, flow->bidirectional = 1;
}
return flow; return flow;
} }
} }
@@ -487,12 +401,12 @@ static struct ndpi_flow_info *get_ndpi_flow_info6(struct ndpi_workflow * workflo
struct ndpi_iphdr iph; struct ndpi_iphdr iph;
memset(&iph, 0, sizeof(iph)); memset(&iph, 0, sizeof(iph));
iph.version = IPVERSION; iph.version = 4;
iph.saddr = iph6->ip6_src.u6_addr.u6_addr32[2] + iph6->ip6_src.u6_addr.u6_addr32[3]; iph.saddr = iph6->ip6_src.u6_addr.u6_addr32[2] + iph6->ip6_src.u6_addr.u6_addr32[3];
iph.daddr = iph6->ip6_dst.u6_addr.u6_addr32[2] + iph6->ip6_dst.u6_addr.u6_addr32[3]; iph.daddr = iph6->ip6_dst.u6_addr.u6_addr32[2] + iph6->ip6_dst.u6_addr.u6_addr32[3];
iph.protocol = iph6->ip6_hdr.ip6_un1_nxt; iph.protocol = iph6->ip6_ctlun.ip6_un1.ip6_un1_nxt;
if(iph.protocol == IPPROTO_DSTOPTS /* IPv6 destination option */) { if(iph.protocol == 0x3C /* IPv6 destination option */) {
u_int8_t *options = (u_int8_t*)iph6 + sizeof(const struct ndpi_ipv6hdr); u_int8_t *options = (u_int8_t*)iph6 + sizeof(const struct ndpi_ipv6hdr);
iph.protocol = options[0]; iph.protocol = options[0];
@@ -500,79 +414,15 @@ static struct ndpi_flow_info *get_ndpi_flow_info6(struct ndpi_workflow * workflo
return(get_ndpi_flow_info(workflow, 6, vlan_id, &iph, iph6, ip_offset, return(get_ndpi_flow_info(workflow, 6, vlan_id, &iph, iph6, ip_offset,
sizeof(struct ndpi_ipv6hdr), sizeof(struct ndpi_ipv6hdr),
ntohs(iph6->ip6_hdr.ip6_un1_plen), ntohs(iph6->ip6_ctlun.ip6_un1.ip6_un1_plen),
tcph, udph, sport, dport, tcph, udph, sport, dport,
src, dst, proto, payload, payload_len, src_to_dst_direction)); src, dst, proto, payload, payload_len, src_to_dst_direction));
} }
/* ****************************************************** */ /* ****************************************************** */
void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow) { // ipsize = header->len - ip_offset ; rawsize = header->len
if(!flow->ndpi_flow) return; static unsigned int packet_processing(struct ndpi_workflow * workflow,
snprintf(flow->host_server_name, sizeof(flow->host_server_name), "%s",
flow->ndpi_flow->host_server_name);
/* BITTORRENT */
if(flow->detected_protocol.app_protocol == NDPI_PROTOCOL_BITTORRENT) {
int i, j, n = 0;
for(i=0, j = 0; j < sizeof(flow->bittorent_hash)-1; i++) {
sprintf(&flow->bittorent_hash[j], "%02x", flow->ndpi_flow->protos.bittorrent.hash[i]);
j += 2, n += flow->ndpi_flow->protos.bittorrent.hash[i];
}
if(n == 0) flow->bittorent_hash[0] = '\0';
}
/* MDNS */
else if(flow->detected_protocol.app_protocol == NDPI_PROTOCOL_MDNS) {
snprintf(flow->info, sizeof(flow->info), "%s", flow->ndpi_flow->protos.mdns.answer);
}
/* UBNTAC2 */
else if(flow->detected_protocol.app_protocol == NDPI_PROTOCOL_UBNTAC2) {
snprintf(flow->info, sizeof(flow->info), "%s", flow->ndpi_flow->protos.ubntac2.version);
}
if(flow->detected_protocol.app_protocol != NDPI_PROTOCOL_DNS) {
/* SSH */
if(flow->detected_protocol.app_protocol == NDPI_PROTOCOL_SSH) {
snprintf(flow->ssh_ssl.client_info, sizeof(flow->ssh_ssl.client_info), "%s",
flow->ndpi_flow->protos.ssh.client_signature);
snprintf(flow->ssh_ssl.server_info, sizeof(flow->ssh_ssl.server_info), "%s",
flow->ndpi_flow->protos.ssh.server_signature);
}
/* SSL */
else if((flow->detected_protocol.app_protocol == NDPI_PROTOCOL_SSL)
|| (flow->detected_protocol.master_protocol == NDPI_PROTOCOL_SSL)) {
snprintf(flow->ssh_ssl.client_info, sizeof(flow->ssh_ssl.client_info), "%s",
flow->ndpi_flow->protos.ssl.client_certificate);
snprintf(flow->ssh_ssl.server_info, sizeof(flow->ssh_ssl.server_info), "%s",
flow->ndpi_flow->protos.ssl.server_certificate);
}
}
if(flow->detection_completed && !flow->check_extra_packets) {
if(flow->detected_protocol.app_protocol == NDPI_PROTOCOL_UNKNOWN) {
if (workflow->__flow_giveup_callback != NULL)
workflow->__flow_giveup_callback(workflow, flow, workflow->__flow_giveup_udata);
} else {
if (workflow->__flow_detected_callback != NULL)
workflow->__flow_detected_callback(workflow, flow, workflow->__flow_detected_udata);
}
ndpi_free_flow_info_half(flow);
}
}
/* ****************************************************** */
/**
Function to process the packet:
determine the flow of a packet and try to decode it
@return: 0 if success; else != 0
@Note: ipsize = header->len - ip_offset ; rawsize = header->len
*/
static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
const u_int64_t time, const u_int64_t time,
u_int16_t vlan_id, u_int16_t vlan_id,
const struct ndpi_iphdr *iph, const struct ndpi_iphdr *iph,
@@ -580,7 +430,7 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
u_int16_t ip_offset, u_int16_t ip_offset,
u_int16_t ipsize, u_int16_t rawsize) { u_int16_t ipsize, u_int16_t rawsize) {
struct ndpi_id_struct *src, *dst; struct ndpi_id_struct *src, *dst;
struct ndpi_flow_info *flow = NULL; struct ndpi_flow_info *flow;
struct ndpi_flow_struct *ndpi_flow = NULL; struct ndpi_flow_struct *ndpi_flow = NULL;
u_int8_t proto; u_int8_t proto;
struct ndpi_tcphdr *tcph = NULL; struct ndpi_tcphdr *tcph = NULL;
@@ -588,10 +438,9 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
u_int16_t sport, dport, payload_len; u_int16_t sport, dport, payload_len;
u_int8_t *payload; u_int8_t *payload;
u_int8_t src_to_dst_direction= 1; u_int8_t src_to_dst_direction= 1;
struct ndpi_proto nproto = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN };
if(iph) if(iph)
flow = get_ndpi_flow_info(workflow, IPVERSION, vlan_id, iph, NULL, flow = get_ndpi_flow_info(workflow, 4, vlan_id, iph, NULL,
ip_offset, ipsize, ip_offset, ipsize,
ntohs(iph->tot_len) - (iph->ihl * 4), ntohs(iph->tot_len) - (iph->ihl * 4),
&tcph, &udph, &sport, &dport, &tcph, &udph, &sport, &dport,
@@ -605,83 +454,85 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow,
if(flow != NULL) { if(flow != NULL) {
workflow->stats.ip_packet_count++; workflow->stats.ip_packet_count++;
workflow->stats.total_wire_bytes += rawsize + 24 /* CRC etc */, workflow->stats.total_wire_bytes += rawsize + 24 /* CRC etc */, workflow->stats.total_ip_bytes += rawsize;
workflow->stats.total_ip_bytes += rawsize;
ndpi_flow = flow->ndpi_flow; ndpi_flow = flow->ndpi_flow;
flow->packets++, flow->bytes += rawsize;
if(src_to_dst_direction)
flow->src2dst_packets++, flow->src2dst_bytes += rawsize;
else
flow->dst2src_packets++, flow->dst2src_bytes += rawsize;
flow->last_seen = time; flow->last_seen = time;
} else { // flow is NULL } else {
workflow->stats.total_discarded_bytes++; return(0);
return(nproto);
} }
/* Protocol already detected */ /* Protocol already detected */
if(flow->detection_completed) { if(flow->detection_completed) return(0);
if(flow->check_extra_packets && ndpi_flow != NULL && ndpi_flow->check_extra_packets) {
if(ndpi_flow->num_extra_packets_checked == 0 && ndpi_flow->max_extra_packets_to_check == 0) {
/* Protocols can set this, but we set it here in case they didn't */
ndpi_flow->max_extra_packets_to_check = MAX_EXTRA_PACKETS_TO_CHECK;
}
if(ndpi_flow->num_extra_packets_checked < ndpi_flow->max_extra_packets_to_check) {
ndpi_process_extra_packet(workflow->ndpi_struct, ndpi_flow,
iph ? (uint8_t *)iph : (uint8_t *)iph6,
ipsize, time, src, dst);
if (ndpi_flow->check_extra_packets == 0) {
flow->check_extra_packets = 0;
process_ndpi_collected_info(workflow, flow);
}
}
} else if (ndpi_flow != NULL) {
/* If this wasn't NULL we should do the half free */
/* TODO: When half_free is deprecated, get rid of this */
ndpi_free_flow_info_half(flow);
}
return(flow->detected_protocol);
}
flow->detected_protocol = ndpi_detection_process_packet(workflow->ndpi_struct, ndpi_flow, flow->detected_protocol = ndpi_detection_process_packet(workflow->ndpi_struct, ndpi_flow,
iph ? (uint8_t *)iph : (uint8_t *)iph6, iph ? (uint8_t *)iph : (uint8_t *)iph6,
ipsize, time, src, dst); ipsize, time, src, dst);
if((flow->detected_protocol.app_protocol != NDPI_PROTOCOL_UNKNOWN) if((flow->detected_protocol.protocol != NDPI_PROTOCOL_UNKNOWN)
|| ((proto == IPPROTO_UDP) && ((flow->src2dst_packets + flow->dst2src_packets) > 8)) || ((proto == IPPROTO_UDP) && (flow->packets > 8))
|| ((proto == IPPROTO_TCP) && ((flow->src2dst_packets + flow->dst2src_packets) > 10))) { || ((proto == IPPROTO_TCP) && (flow->packets > 10))) {
/* New protocol detected or give up */ /* New protocol detected or give up */
flow->detection_completed = 1; flow->detection_completed = 1;
/* Check if we should keep checking extra packets */
if (ndpi_flow->check_extra_packets)
flow->check_extra_packets = 1;
if(flow->detected_protocol.app_protocol == NDPI_PROTOCOL_UNKNOWN) if((flow->detected_protocol.protocol == NDPI_PROTOCOL_UNKNOWN) && (ndpi_flow->num_stun_udp_pkts > 0))
flow->detected_protocol = ndpi_detection_giveup(workflow->ndpi_struct, ndpi_set_detected_protocol(workflow->ndpi_struct, ndpi_flow, NDPI_PROTOCOL_STUN, NDPI_PROTOCOL_UNKNOWN);
flow->ndpi_flow);
process_ndpi_collected_info(workflow, flow); snprintf(flow->host_server_name, sizeof(flow->host_server_name), "%s", flow->ndpi_flow->host_server_name);
if(flow->detected_protocol.protocol == NDPI_PROTOCOL_BITTORRENT) {
int i, j, n = 0;
for(i=0, j = 0; i<20; i++) {
sprintf(&flow->bittorent_hash[j], "%02x", flow->ndpi_flow->bittorent_hash[i]);
j += 2, n += flow->ndpi_flow->bittorent_hash[i];
} }
return(flow->detected_protocol); if(n == 0) flow->bittorent_hash[0] = '\0';
}
if((proto == IPPROTO_TCP) && (flow->detected_protocol.protocol != NDPI_PROTOCOL_DNS)) {
snprintf(flow->ssl.client_certificate, sizeof(flow->ssl.client_certificate), "%s", flow->ndpi_flow->protos.ssl.client_certificate);
snprintf(flow->ssl.server_certificate, sizeof(flow->ssl.server_certificate), "%s", flow->ndpi_flow->protos.ssl.server_certificate);
}
if(flow->detected_protocol.protocol == NDPI_PROTOCOL_UNKNOWN) {
flow->detected_protocol = ndpi_detection_giveup(workflow->ndpi_struct, flow->ndpi_flow);
if (workflow->__flow_giveup_callback != NULL)
workflow->__flow_giveup_callback(workflow, flow, workflow->__flow_giveup_udata);
} else {
if (workflow->__flow_detected_callback != NULL)
workflow->__flow_detected_callback(workflow, flow, workflow->__flow_detected_udata);
}
ndpi_free_flow_info_half(flow);
}
return 0;
} }
/* ****************************************************** */ /* ****************************************************** */
void ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
const struct pcap_pkthdr *header, const struct pcap_pkthdr *header,
const u_char *packet) { const u_char *packet) {
/* /*
* Declare pointers to packet headers * Declare pointers to packet headers
*/ */
/* --- Ethernet header --- */ /* --- Ethernet header --- */
const struct ndpi_ethhdr *ethernet; const struct ndpi_ethhdr *ethernet;
/* --- Ethernet II header --- */
const struct ndpi_ethhdr *ethernet_2;
/* --- LLC header --- */ /* --- LLC header --- */
const struct ndpi_llc_header_snap *llc; const struct ndpi_llc_header *llc;
/* --- Cisco HDLC header --- */ /* --- Cisco HDLC header --- */
const struct ndpi_chdlc *chdlc; const struct ndpi_chdlc *chdlc;
/* --- SLARP frame --- */
struct ndpi_slarp *slarp;
/* --- CDP --- */
struct ndpi_cdp *cdp;
/* --- Radio Tap header --- */ /* --- Radio Tap header --- */
const struct ndpi_radiotap_header *radiotap; const struct ndpi_radiotap_header *radiotap;
@@ -689,28 +540,24 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
const struct ndpi_wifi_header *wifi; const struct ndpi_wifi_header *wifi;
/* --- MPLS header --- */ /* --- MPLS header --- */
union mpls { struct ndpi_mpls_header *mpls;
uint32_t u32;
struct ndpi_mpls_header mpls;
} mpls;
/** --- IP header --- **/ /** --- IP header --- **/
struct ndpi_iphdr *iph; struct ndpi_iphdr *iph;
/** --- IPv6 header --- **/ /** --- IPv6 header --- **/
struct ndpi_ipv6hdr *iph6; struct ndpi_ipv6hdr *iph6;
struct ndpi_proto nproto = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN };
/* lengths and offsets */ /* lengths and offsets */
u_int16_t eth_offset = 0; u_int16_t eth_offset = 0;
u_int16_t radio_len; u_int16_t radio_len;
u_int16_t fc; u_int16_t fc;
u_int16_t type = 0; u_int16_t type;
int wifi_len = 0; int wifi_len = 0;
int llc_off;
int pyld_eth_len = 0; int pyld_eth_len = 0;
int check; int check;
u_int64_t time; u_int64_t time;
u_int16_t ip_offset = 0, ip_len; u_int16_t ip_offset, ip_len, ip6_offset;
u_int16_t frag_off = 0, vlan_id = 0; u_int16_t frag_off = 0, vlan_id = 0;
u_int8_t proto = 0; u_int8_t proto = 0;
u_int32_t label; u_int32_t label;
@@ -753,9 +600,8 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
type = ntohs(chdlc->proto_code); type = ntohs(chdlc->proto_code);
break; break;
/* Cisco PPP - 9 or 104 */ /* Cisco PPP with HDLC framing - 104 */
case DLT_C_HDLC: case DLT_C_HDLC:
case DLT_PPP:
chdlc = (struct ndpi_chdlc *) &packet[eth_offset]; chdlc = (struct ndpi_chdlc *) &packet[eth_offset];
ip_offset = sizeof(struct ndpi_chdlc); /* CHDLC_OFF = 4 */ ip_offset = sizeof(struct ndpi_chdlc); /* CHDLC_OFF = 4 */
type = ntohs(chdlc->proto_code); type = ntohs(chdlc->proto_code);
@@ -773,16 +619,12 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
type = check; type = check;
if(pyld_eth_len != 0) { if(pyld_eth_len != 0) {
llc = (struct ndpi_llc_header_snap *)(&packet[ip_offset]);
/* check for LLC layer with SNAP extension */ /* check for LLC layer with SNAP extension */
if(llc->dsap == SNAP || llc->ssap == SNAP) { if(packet[ip_offset] == SNAP) {
llc = (struct ndpi_llc_header *)(&packet[ip_offset]);
type = llc->snap.proto_ID; type = llc->snap.proto_ID;
ip_offset += + 8; ip_offset += + 8;
} }
/* No SNAP extension - Spanning Tree pkt must be discarted */
else if(llc->dsap == BSTP || llc->ssap == BSTP) {
goto v4_warning;
}
} }
break; break;
@@ -800,7 +642,7 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
/* Check Bad FCS presence */ /* Check Bad FCS presence */
if((radiotap->flags & BAD_FCS) == BAD_FCS) { if((radiotap->flags & BAD_FCS) == BAD_FCS) {
workflow->stats.total_discarded_bytes += header->len; workflow->stats.total_discarded_bytes += header->len;
return(nproto); return;
} }
/* Calculate 802.11 header length (variable) */ /* Calculate 802.11 header length (variable) */
@@ -816,12 +658,12 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
break; break;
/* Check ether_type from LLC */ /* Check ether_type from LLC */
llc = (struct ndpi_llc_header_snap*)(packet + eth_offset + wifi_len + radio_len); llc = (struct ndpi_llc_header*)(packet + eth_offset + wifi_len + radio_len);
if(llc->dsap == SNAP) if(llc->dsap == SNAP)
type = ntohs(llc->snap.proto_ID); type = ntohs(llc->snap.proto_ID);
/* Set IP header offset */ /* Set IP header offset */
ip_offset = wifi_len + radio_len + sizeof(struct ndpi_llc_header_snap) + eth_offset; ip_offset = wifi_len + radio_len + sizeof(struct ndpi_llc_header) + eth_offset;
break; break;
case DLT_RAW: case DLT_RAW:
@@ -830,7 +672,7 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
default: default:
/* printf("Unknown datalink %d\n", datalink_type); */ /* printf("Unknown datalink %d\n", datalink_type); */
return(nproto); return;
} }
/* check ether type */ /* check ether type */
@@ -840,24 +682,18 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
type = (packet[ip_offset+2] << 8) + packet[ip_offset+3]; type = (packet[ip_offset+2] << 8) + packet[ip_offset+3];
ip_offset += 4; ip_offset += 4;
vlan_packet = 1; vlan_packet = 1;
// double tagging for 802.1Q
if(type == 0x8100) {
vlan_id = ((packet[ip_offset] << 8) + packet[ip_offset+1]) & 0xFFF;
type = (packet[ip_offset+2] << 8) + packet[ip_offset+3];
ip_offset += 4;
}
break; break;
case MPLS_UNI: case MPLS_UNI:
case MPLS_MULTI: case MPLS_MULTI:
mpls.u32 = *((uint32_t *) &packet[ip_offset]); mpls = (struct ndpi_mpls_header *) &packet[ip_offset];
mpls.u32 = ntohl(mpls.u32); label = ntohl(mpls->label);
/* label = ntohl(*((u_int32_t*)&packet[ip_offset])); */
workflow->stats.mpls_count++; workflow->stats.mpls_count++;
type = ETH_P_IP, ip_offset += 4; type = ETH_P_IP, ip_offset += 4;
while(!mpls.mpls.s) { while((label & 0x100) != 0x100) {
mpls.u32 = *((uint32_t *) &packet[ip_offset]);
mpls.u32 = ntohl(mpls.u32);
ip_offset += 4; ip_offset += 4;
label = ntohl(mpls->label);
} }
break; break;
case PPPoE: case PPPoE:
@@ -885,17 +721,17 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
if(cap_warning_used == 0) { if(cap_warning_used == 0) {
if(!workflow->prefs.quiet_mode) if(!workflow->prefs.quiet_mode)
NDPI_LOG(0, workflow->ndpi_struct, NDPI_LOG_DEBUG, "\n\nWARNING: packet capture size is smaller than packet size, DETECTION MIGHT NOT WORK CORRECTLY\n\n"); NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_DEBUG, "\n\nWARNING: packet capture size is smaller than packet size, DETECTION MIGHT NOT WORK CORRECTLY\n\n");
cap_warning_used = 1; cap_warning_used = 1;
} }
} }
} }
if(iph->version == IPVERSION) { if(iph->version == 4) {
ip_len = ((u_int16_t)iph->ihl * 4); ip_len = ((u_short)iph->ihl * 4);
iph6 = NULL; iph6 = NULL;
if(iph->protocol == IPPROTO_IPV6) { if(iph->protocol == 41) {
ip_offset += ip_len; ip_offset += ip_len;
goto iph_check; goto iph_check;
} }
@@ -906,19 +742,19 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
if(ipv4_frags_warning_used == 0) { if(ipv4_frags_warning_used == 0) {
if(!workflow->prefs.quiet_mode) if(!workflow->prefs.quiet_mode)
NDPI_LOG(0, workflow->ndpi_struct, NDPI_LOG_DEBUG, "\n\nWARNING: IPv4 fragments are not handled by this demo (nDPI supports them)\n"); NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_DEBUG, "\n\nWARNING: IPv4 fragments are not handled by this demo (nDPI supports them)\n");
ipv4_frags_warning_used = 1; ipv4_frags_warning_used = 1;
} }
workflow->stats.total_discarded_bytes += header->len; workflow->stats.total_discarded_bytes += header->len;
return(nproto); return;
} }
} else if(iph->version == 6) { } else if(iph->version == 6) {
iph6 = (struct ndpi_ipv6hdr *)&packet[ip_offset]; iph6 = (struct ndpi_ipv6hdr *)&packet[ip_offset];
proto = iph6->ip6_hdr.ip6_un1_nxt; proto = iph6->ip6_ctlun.ip6_un1.ip6_un1_nxt;
ip_len = sizeof(struct ndpi_ipv6hdr); ip_len = sizeof(struct ndpi_ipv6hdr);
if(proto == IPPROTO_DSTOPTS /* IPv6 destination option */) { if(proto == 0x3C /* IPv6 destination option */) {
u_int8_t *options = (u_int8_t*)&packet[ip_offset+ip_len]; u_int8_t *options = (u_int8_t*)&packet[ip_offset+ip_len];
proto = options[0]; proto = options[0];
@@ -932,11 +768,11 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
v4_warning: v4_warning:
if(ipv4_warning_used == 0) { if(ipv4_warning_used == 0) {
if(!workflow->prefs.quiet_mode) if(!workflow->prefs.quiet_mode)
NDPI_LOG(0, workflow->ndpi_struct, NDPI_LOG_DEBUG, "\n\nWARNING: only IPv4/IPv6 packets are supported in this demo (nDPI supports both IPv4 and IPv6), all other packets will be discarded\n\n"); NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_DEBUG, "\n\nWARNING: only IPv4/IPv6 packets are supported in this demo (nDPI supports both IPv4 and IPv6), all other packets will be discarded\n\n");
ipv4_warning_used = 1; ipv4_warning_used = 1;
} }
workflow->stats.total_discarded_bytes += header->len; workflow->stats.total_discarded_bytes += header->len;
return(nproto); return;
} }
if(workflow->prefs.decode_tunnels && (proto == IPPROTO_UDP)) { if(workflow->prefs.decode_tunnels && (proto == IPPROTO_UDP)) {
@@ -959,7 +795,7 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
iph = (struct ndpi_iphdr *) &packet[ip_offset]; iph = (struct ndpi_iphdr *) &packet[ip_offset];
if(iph->version != IPVERSION) { if(iph->version != 4) {
// printf("WARNING: not good (packet_id=%u)!\n", (unsigned int)workflow->stats.raw_packet_count); // printf("WARNING: not good (packet_id=%u)!\n", (unsigned int)workflow->stats.raw_packet_count);
goto v4_warning; goto v4_warning;
} }
@@ -995,7 +831,7 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
offset += tag_len; offset += tag_len;
if(offset >= header->caplen) if(offset >= header->caplen)
return(nproto); /* Invalid packet */ return; /* Invalid packet */
else { else {
eth_offset = offset; eth_offset = offset;
goto datalink_check; goto datalink_check;
@@ -1006,56 +842,6 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
} }
/* process the packet */ /* process the packet */
return(packet_processing(workflow, time, vlan_id, iph, iph6, packet_processing(workflow, time, vlan_id, iph, iph6,
ip_offset, header->caplen - ip_offset, header->caplen)); ip_offset, header->len - ip_offset, header->len);
} }
/* ********************************************************** */
/* http://home.thep.lu.se/~bjorn/crc/crc32_fast.c */
/* ********************************************************** */
static uint32_t crc32_for_byte(uint32_t r) {
int j;
for(j = 0; j < 8; ++j)
r = (r & 1? 0: (uint32_t)0xEDB88320L) ^ r >> 1;
return r ^ (uint32_t)0xFF000000L;
}
/* Any unsigned integer type with at least 32 bits may be used as
* accumulator type for fast crc32-calulation, but unsigned long is
* probably the optimal choice for most systems. */
typedef unsigned long accum_t;
static void init_tables(uint32_t* table, uint32_t* wtable) {
size_t i, j, k, w;
for(i = 0; i < 0x100; ++i)
table[i] = crc32_for_byte(i);
for(k = 0; k < sizeof(accum_t); ++k)
for(i = 0; i < 0x100; ++i) {
for(j = w = 0; j < sizeof(accum_t); ++j)
w = table[(uint8_t)(j == k? w ^ i: w)] ^ w >> 8;
wtable[(k << 8) + i] = w ^ (k? wtable[0]: 0);
}
}
static void __crc32(const void* data, size_t n_bytes, uint32_t* crc) {
static uint32_t table[0x100], wtable[0x100*sizeof(accum_t)];
size_t n_accum = n_bytes/sizeof(accum_t);
size_t i, j;
if(!*table)
init_tables(table, wtable);
for(i = 0; i < n_accum; ++i) {
accum_t a = *crc ^ ((accum_t*)data)[i];
for(j = *crc = 0; j < sizeof(accum_t); ++j)
*crc ^= wtable[(j << 8) + (uint8_t)(a >> 8*j)];
}
for(i = n_accum*sizeof(accum_t); i < n_bytes; ++i)
*crc = table[(uint8_t)*crc ^ ((uint8_t*)data)[i]] ^ *crc >> 8;
}
u_int32_t ethernet_crc32(const void* data, size_t n_bytes) {
u_int32_t crc = 0;
__crc32(data, n_bytes, &crc);
return crc;
}
+21 -55
View File
@@ -26,6 +26,7 @@
* *
* WARNING: this API is unstable! Use it at your own risk! * WARNING: this API is unstable! Use it at your own risk!
*/ */
#ifndef __NDPI_UTIL_H__ #ifndef __NDPI_UTIL_H__
#define __NDPI_UTIL_H__ #define __NDPI_UTIL_H__
@@ -36,57 +37,38 @@
#define MAX_IDLE_TIME 30000 #define MAX_IDLE_TIME 30000
#define IDLE_SCAN_BUDGET 1024 #define IDLE_SCAN_BUDGET 1024
#define NUM_ROOTS 512 #define NUM_ROOTS 512
#define MAX_EXTRA_PACKETS_TO_CHECK 7
#define MAX_NDPI_FLOWS 200000000 #define MAX_NDPI_FLOWS 200000000
#define TICK_RESOLUTION 1000 #define TICK_RESOLUTION 1000
#define MAX_NUM_IP_ADDRESS 5 /* len of ip address array */
#define UPDATED_TREE 1
#define AGGRESSIVE_PERCENT 95.00
#define DIR_SRC 10
#define DIR_DST 20
#define PORT_ARRAY_SIZE 20
#define HOST_ARRAY_SIZE 20
#define FLOWS_PACKETS_THRESHOLD 0.9
#define FLOWS_PERCENT_THRESHOLD 1.0
#define FLOWS_PERCENT_THRESHOLD_2 0.2
#define FLOWS_THRESHOLD 1000
#define PKTS_PERCENT_THRESHOLD 0.1
#define MAX_TABLE_SIZE_1 4096
#define MAX_TABLE_SIZE_2 8192
#define INIT_VAL -1
// flow tracking // flow tracking
typedef struct ndpi_flow_info { typedef struct ndpi_flow_info {
u_int32_t hashval; u_int32_t lower_ip;
u_int32_t src_ip; u_int32_t upper_ip;
u_int32_t dst_ip; u_int16_t lower_port;
u_int16_t src_port; u_int16_t upper_port;
u_int16_t dst_port; u_int8_t detection_completed, protocol;
u_int8_t detection_completed, protocol, bidirectional, check_extra_packets;
u_int16_t vlan_id; u_int16_t vlan_id;
struct ndpi_flow_struct *ndpi_flow; struct ndpi_flow_struct *ndpi_flow;
char src_name[48], dst_name[48]; char lower_name[48], upper_name[48];
u_int8_t ip_version; u_int8_t ip_version;
u_int64_t last_seen; u_int64_t last_seen;
u_int64_t src2dst_bytes, dst2src_bytes; u_int64_t bytes;
u_int32_t src2dst_packets, dst2src_packets; u_int32_t packets;
// result only, not used for flow identification // result only, not used for flow identification
ndpi_protocol detected_protocol; ndpi_protocol detected_protocol;
char info[96];
char host_server_name[192]; char host_server_name[192];
char bittorent_hash[41]; char bittorent_hash[41];
struct { struct {
char client_info[48], server_info[48]; char client_certificate[48], server_certificate[48];
} ssh_ssl; } ssl;
void *src_id, *dst_id; void *src_id, *dst_id;
} ndpi_flow_info_t; } ndpi_flow_info_t;
// flow statistics info
typedef struct ndpi_stats { typedef struct ndpi_stats {
u_int32_t guessed_flow_protocols; u_int32_t guessed_flow_protocols;
u_int64_t raw_packet_count; u_int64_t raw_packet_count;
@@ -102,8 +84,6 @@ typedef struct ndpi_stats {
u_int16_t max_packet_len; u_int16_t max_packet_len;
} ndpi_stats_t; } ndpi_stats_t;
// flow preferences
typedef struct ndpi_workflow_prefs { typedef struct ndpi_workflow_prefs {
u_int8_t decode_tunnels; u_int8_t decode_tunnels;
u_int8_t quiet_mode; u_int8_t quiet_mode;
@@ -112,12 +92,9 @@ typedef struct ndpi_workflow_prefs {
} ndpi_workflow_prefs_t; } ndpi_workflow_prefs_t;
struct ndpi_workflow; struct ndpi_workflow;
/** workflow, flow, user data */ /** workflow, flow, user data */
typedef void (*ndpi_workflow_callback_ptr) (struct ndpi_workflow *, struct ndpi_flow_info *, void *); typedef void (*ndpi_workflow_callback_ptr) (struct ndpi_workflow *, struct ndpi_flow_info *, void *);
// workflow main structure
typedef struct ndpi_workflow { typedef struct ndpi_workflow {
u_int64_t last_time; u_int64_t last_time;
@@ -135,51 +112,40 @@ typedef struct ndpi_workflow {
/* allocated by prefs */ /* allocated by prefs */
void **ndpi_flows_root; void **ndpi_flows_root;
struct ndpi_detection_module_struct *ndpi_struct; struct ndpi_detection_module_struct *ndpi_struct;
u_int32_t num_allocated_flows;
} ndpi_workflow_t; } ndpi_workflow_t;
/* TODO: remove wrappers parameters and use ndpi global, when their initialization will be fixed... */ /* TODO: remove wrappers parameters and use ndpi global, when their initialization will be fixed... */
struct ndpi_workflow * ndpi_workflow_init(const struct ndpi_workflow_prefs * prefs, pcap_t * pcap_handle); struct ndpi_workflow * ndpi_workflow_init(const struct ndpi_workflow_prefs * prefs, pcap_t * pcap_handle);
/* workflow main free function */
void ndpi_workflow_free(struct ndpi_workflow * workflow); void ndpi_workflow_free(struct ndpi_workflow * workflow);
/** Free flow_info ndpi support structures but not the flow_info itself /** Free flow_info ndpi support structures but not the flow_info itself
* *
* TODO remove! Half freeing things is bad! * TODO remove! Half freeing things is bad!
*/ */
void ndpi_free_flow_info_half(struct ndpi_flow_info *flow); void ndpi_free_flow_info_half(struct ndpi_flow_info *flow);
/** Process a @packet and update the @workflow. */
/* Process a packet and update the workflow */ void ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
const struct pcap_pkthdr *header, const struct pcap_pkthdr *header,
const u_char *packet); const u_char *packet);
/* flow callbacks: ndpi_flow_info will be freed right after */
/* flow callbacks for complete detected flow static inline void ndpi_workflow_set_flow_detected_callback(struct ndpi_workflow * workflow,
(ndpi_flow_info will be freed right after) */ ndpi_workflow_callback_ptr callback,
static inline void ndpi_workflow_set_flow_detected_callback(struct ndpi_workflow * workflow, ndpi_workflow_callback_ptr callback, void * udata) { void * udata) {
workflow->__flow_detected_callback = callback; workflow->__flow_detected_callback = callback;
workflow->__flow_detected_udata = udata; workflow->__flow_detected_udata = udata;
} }
/* flow callbacks for sufficient detected flow static inline void ndpi_workflow_set_flow_giveup_callback(struct ndpi_workflow * workflow,
(ndpi_flow_info will be freed right after) */ ndpi_workflow_callback_ptr callback,
static inline void ndpi_workflow_set_flow_giveup_callback(struct ndpi_workflow * workflow, ndpi_workflow_callback_ptr callback, void * udata) { void * udata) {
workflow->__flow_giveup_callback = callback; workflow->__flow_giveup_callback = callback;
workflow->__flow_giveup_udata = udata; workflow->__flow_giveup_udata = udata;
} }
/* compare two nodes in workflow */
int ndpi_workflow_node_cmp(const void *a, const void *b); int ndpi_workflow_node_cmp(const void *a, const void *b);
void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow);
u_int32_t ethernet_crc32(const void* data, size_t n_bytes);
void ndpi_flow_info_freer(void *node);
extern int nDPI_LogLevel;
#endif #endif
+1 -1
View File
@@ -10,7 +10,7 @@ tcp:3000@ntop
# Format: # Format:
# host:"<value>",host:"<value>",.....@<subproto> # host:"<value>",host:"<value>",.....@<subproto>
host:"googlesyndication.com"@Google host:"googlesyndacation.com"@Google
host:"venere.com"@Venere host:"venere.com"@Venere
host:"kataweb.it",host:"repubblica.it"@Repubblica host:"kataweb.it",host:"repubblica.it"@Repubblica
host:"ntop"@ntop host:"ntop"@ntop
-1096
View File
File diff suppressed because it is too large Load Diff
-18
View File
@@ -3,7 +3,6 @@ ndpi_strnstr
ndpi_detection_giveup ndpi_detection_giveup
ndpi_get_proto_name ndpi_get_proto_name
ndpi_free ndpi_free
ndpi_flow_free
ndpi_guess_undetected_protocol ndpi_guess_undetected_protocol
ndpi_tfind ndpi_tfind
ndpi_tsearch ndpi_tsearch
@@ -22,7 +21,6 @@ ndpi_init_detection_module
ndpi_get_num_supported_protocols ndpi_get_num_supported_protocols
ndpi_set_proto_defaults ndpi_set_proto_defaults
ndpi_get_protocol_id ndpi_get_protocol_id
ndpi_get_category_id
ndpi_find_port_based_protocol ndpi_find_port_based_protocol
ndpi_get_http_method ndpi_get_http_method
ndpi_get_http_url ndpi_get_http_url
@@ -31,7 +29,6 @@ ndpi_free_flow
ndpi_get_proto_breed ndpi_get_proto_breed
ndpi_get_proto_breed_name ndpi_get_proto_breed_name
ndpi_get_proto_by_id ndpi_get_proto_by_id
ndpi_get_proto_by_name
ndpi_get_protocol_id_master_proto ndpi_get_protocol_id_master_proto
ndpi_guess_protocol_id ndpi_guess_protocol_id
ndpi_protocol2name ndpi_protocol2name
@@ -43,24 +40,9 @@ ndpi_set_detected_protocol
ndpi_match_string_subprotocol ndpi_match_string_subprotocol
ndpi_init_automa ndpi_init_automa
ndpi_free_automa ndpi_free_automa
ndpi_add_string_value_to_automa
ndpi_add_string_to_automa ndpi_add_string_to_automa
ndpi_finalize_automa ndpi_finalize_automa
ndpi_match_string ndpi_match_string
ndpi_match_string_id
set_ndpi_malloc set_ndpi_malloc
set_ndpi_flow_malloc
set_ndpi_free set_ndpi_free
set_ndpi_flow_free
set_ndpi_debug_function set_ndpi_debug_function
ndpi_category_str
ndpi_get_proto_category
ndpi_netbios_name_interpret
ndpi_category_set_name
ndpi_category_get_name
ndpi_is_custom_category
ndpi_is_subprotocol_informative
ndpi_set_proto_category
ndpi_get_api_version
ndpi_network_ptree_match
ndpi_check_flow_func
+98 -251
View File
@@ -19,10 +19,10 @@
# is necessary on AIX to use the special cc_r compiler alias.) # is necessary on AIX to use the special cc_r compiler alias.)
# #
# NOTE: You are assumed to not only compile your program with these flags, # NOTE: You are assumed to not only compile your program with these flags,
# but also to link with them as well. For example, you might link with # but also link it with them as well. e.g. you should link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
# #
# If you are only building threaded programs, you may wish to use these # If you are only building threads programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC: # variables in your default LIBS, CFLAGS, and CC:
# #
# LIBS="$PTHREAD_LIBS $LIBS" # LIBS="$PTHREAD_LIBS $LIBS"
@@ -30,8 +30,8 @@
# CC="$PTHREAD_CC" # CC="$PTHREAD_CC"
# #
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to # has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). # (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
# #
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the # Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with # PTHREAD_PRIO_INHERIT symbol is defined when compiling with
@@ -82,40 +82,35 @@
# modified version of the Autoconf Macro, you may extend this special # modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well. # exception to the GPL to apply to your modified version as well.
#serial 23 #serial 21
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [ AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_SED])
AC_LANG_PUSH([C]) AC_LANG_PUSH([C])
ax_pthread_ok=no ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h # We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on Tru64 or Sequent). # requires special compiler flags (e.g. on True64 or Sequent).
# It gets checked for in the link test anyway. # It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS, # First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using # etcetera environment variables, and if threads linking works using
# them: # them:
if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
ax_pthread_save_CC="$CC" save_CFLAGS="$CFLAGS"
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS" LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes]) AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
AC_MSG_RESULT([$ax_pthread_ok]) AC_MSG_RESULT([$ax_pthread_ok])
if test "x$ax_pthread_ok" = "xno"; then if test x"$ax_pthread_ok" = xno; then
PTHREAD_LIBS="" PTHREAD_LIBS=""
PTHREAD_CFLAGS="" PTHREAD_CFLAGS=""
fi fi
CC="$ax_pthread_save_CC" LIBS="$save_LIBS"
CFLAGS="$ax_pthread_save_CFLAGS" CFLAGS="$save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
fi fi
# We must check for the threads library under a number of different # We must check for the threads library under a number of different
@@ -128,7 +123,7 @@ fi
# which indicates that we try without any flags at all, and "pthread-config" # which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library. # which is a program returning the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the # The ordering *is* (sometimes) important. Some notes on the
# individual items follow: # individual items follow:
@@ -137,225 +132,82 @@ ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --
# none: in case threads are in libc; should be tried before -Kthread and # none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings # other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# (Note: HP C rejects this with "bad form for `-t' option") # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthreads: Solaris/gcc (Note: HP C also rejects) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # -pthreads: Solaris/gcc
# doesn't hurt to check since this sometimes defines pthreads and
# -D_REENTRANT too), HP C (must be checked before -lpthread, which
# is present but should not be used directly; and before -mthreads,
# because the compiler interprets this as "-mt" + "-hreads")
# -mthreads: Mingw32/gcc, Lynx/gcc # -mthreads: Mingw32/gcc, Lynx/gcc
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# ... -mt is also the pthreads flag for HP/aCC
# pthread: Linux, etcetera # pthread: Linux, etcetera
# --thread-safe: KAI C++ # --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library) # pthread-config: use pthread-config program (for GNU Pth library)
case $host_os in case ${host_os} in
freebsd*)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
ax_pthread_flags="-kthread lthread $ax_pthread_flags"
;;
hpux*)
# From the cc(1) man page: "[-mt] Sets various -D flags to enable
# multi-threading and also sets -lpthread."
ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
;;
openedition*)
# IBM z/OS requires a feature-test macro to be defined in order to
# enable POSIX threads at all, so give the user a hint if this is
# not set. (We don't define these ourselves, as they can affect
# other portions of the system API in unpredictable ways.)
AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
[
# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
AX_PTHREAD_ZOS_MISSING
# endif
],
[AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
;;
solaris*) solaris*)
# On Solaris (at least, for some versions), libc contains stubbed # On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based # (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (N.B.: The stubs are missing # tests will erroneously succeed. (We need to link with -pthreads/-mt/
# pthread_cleanup_push, or rather a function called by this macro, # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# so we could check for that, but who knows whether they'll stub # a function called by this macro, so we could check for that, but
# that too in a future libc.) So we'll check first for the # who knows whether they'll stub that too in a future libc.) So,
# standard Solaris way of linking pthreads (-mt -lpthread). # we'll just look for -pthreads and -lpthread first:
ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
;;
darwin*)
ax_pthread_flags="-pthread $ax_pthread_flags"
;; ;;
esac esac
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) # Clang doesn't consider unrecognized options an error unless we specify
# -Werror. We throw in some extra Clang-specific options to ensure that
# this doesn't happen for GCC, which also accepts -Werror.
AS_IF([test "x$GCC" = "xyes"], AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
[ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"]) save_CFLAGS="$CFLAGS"
ax_pthread_extra_flags="-Werror"
CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
[AC_MSG_RESULT([yes])],
[ax_pthread_extra_flags=
AC_MSG_RESULT([no])])
CFLAGS="$save_CFLAGS"
# The presence of a feature test macro requesting re-entrant function if test x"$ax_pthread_ok" = xno; then
# definitions is, on some systems, a strong hint that pthreads support is for flag in $ax_pthread_flags; do
# correctly enabled
case $host_os in case $flag in
darwin* | hpux* | linux* | osf* | solaris*)
ax_pthread_check_macro="_REENTRANT"
;;
aix*)
ax_pthread_check_macro="_THREAD_SAFE"
;;
*)
ax_pthread_check_macro="--"
;;
esac
AS_IF([test "x$ax_pthread_check_macro" = "x--"],
[ax_pthread_check_cond=0],
[ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
# Are we compiling with Clang?
AC_CACHE_CHECK([whether $CC is Clang],
[ax_cv_PTHREAD_CLANG],
[ax_cv_PTHREAD_CLANG=no
# Note that Autoconf sets GCC=yes for Clang as well as GCC
if test "x$GCC" = "xyes"; then
AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
[/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
# if defined(__clang__) && defined(__llvm__)
AX_PTHREAD_CC_IS_CLANG
# endif
],
[ax_cv_PTHREAD_CLANG=yes])
fi
])
ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
ax_pthread_clang_warning=no
# Clang needs special handling, because older versions handle the -pthread
# option in a rather... idiosyncratic way
if test "x$ax_pthread_clang" = "xyes"; then
# Clang takes -pthread; it has never supported any other flag
# (Note 1: This will need to be revisited if a system that Clang
# supports has POSIX threads in a separate library. This tends not
# to be the way of modern systems, but it's conceivable.)
# (Note 2: On some systems, notably Darwin, -pthread is not needed
# to get POSIX threads support; the API is always present and
# active. We could reasonably leave PTHREAD_CFLAGS empty. But
# -pthread does define _REENTRANT, and while the Darwin headers
# ignore this macro, third-party headers might not.)
PTHREAD_CFLAGS="-pthread"
PTHREAD_LIBS=
ax_pthread_ok=yes
# However, older versions of Clang make a point of warning the user
# that, in an invocation where only linking and no compilation is
# taking place, the -pthread option has no effect ("argument unused
# during compilation"). They expect -pthread to be passed in only
# when source code is being compiled.
#
# Problem is, this is at odds with the way Automake and most other
# C build frameworks function, which is that the same flags used in
# compilation (CFLAGS) are also used in linking. Many systems
# supported by AX_PTHREAD require exactly this for POSIX threads
# support, and in fact it is often not straightforward to specify a
# flag that is used only in the compilation phase and not in
# linking. Such a scenario is extremely rare in practice.
#
# Even though use of the -pthread flag in linking would only print
# a warning, this can be a nuisance for well-run software projects
# that build with -Werror. So if the active version of Clang has
# this misfeature, we search for an option to squash it.
AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
# Create an alternate version of $ac_link that compiles and
# links in two steps (.c -> .o, .o -> exe) instead of one
# (.c -> exe), because the warning occurs only in the second
# step
ax_pthread_save_ac_link="$ac_link"
ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
ax_pthread_save_CFLAGS="$CFLAGS"
for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
ac_link="$ax_pthread_save_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[ac_link="$ax_pthread_2step_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[break])
])
done
ac_link="$ax_pthread_save_ac_link"
CFLAGS="$ax_pthread_save_CFLAGS"
AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
])
case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
no | unknown) ;;
*) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
esac
fi # $ax_pthread_clang = yes
if test "x$ax_pthread_ok" = "xno"; then
for ax_pthread_try_flag in $ax_pthread_flags; do
case $ax_pthread_try_flag in
none) none)
AC_MSG_CHECKING([whether pthreads work without any flags]) AC_MSG_CHECKING([whether pthreads work without any flags])
;; ;;
-mt,pthread)
AC_MSG_CHECKING([whether pthreads work with -mt -lpthread])
PTHREAD_CFLAGS="-mt"
PTHREAD_LIBS="-lpthread"
;;
-*) -*)
AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) AC_MSG_CHECKING([whether pthreads work with $flag])
PTHREAD_CFLAGS="$ax_pthread_try_flag" PTHREAD_CFLAGS="$flag"
;; ;;
pthread-config) pthread-config)
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) if test x"$ax_pthread_config" = xno; then continue; fi
PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;; ;;
*) *)
AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) AC_MSG_CHECKING([for the pthreads library -l$flag])
PTHREAD_LIBS="-l$ax_pthread_try_flag" PTHREAD_LIBS="-l$flag"
;; ;;
esac esac
ax_pthread_save_CFLAGS="$CFLAGS" save_LIBS="$LIBS"
ax_pthread_save_LIBS="$LIBS" save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS" LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
# Check for various functions. We must include pthread.h, # Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we # since some functions may be macros. (On the Sequent, we
@@ -366,11 +218,7 @@ for ax_pthread_try_flag in $ax_pthread_flags; do
# pthread_cleanup_push because it is one of the few pthread # pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub. # functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles. # We try pthread_create on general principles.
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h> AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
# if $ax_pthread_check_cond
# error "$ax_pthread_check_macro must be defined"
# endif
static void routine(void *a) { a = 0; } static void routine(void *a) { a = 0; }
static void *start_routine(void *a) { return a; }], static void *start_routine(void *a) { return a; }],
[pthread_t th; pthread_attr_t attr; [pthread_t th; pthread_attr_t attr;
@@ -382,11 +230,13 @@ for ax_pthread_try_flag in $ax_pthread_flags; do
[ax_pthread_ok=yes], [ax_pthread_ok=yes],
[]) [])
CFLAGS="$ax_pthread_save_CFLAGS" LIBS="$save_LIBS"
LIBS="$ax_pthread_save_LIBS" CFLAGS="$save_CFLAGS"
AC_MSG_RESULT([$ax_pthread_ok]) AC_MSG_RESULT([$ax_pthread_ok])
AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) if test "x$ax_pthread_ok" = xyes; then
break;
fi
PTHREAD_LIBS="" PTHREAD_LIBS=""
PTHREAD_CFLAGS="" PTHREAD_CFLAGS=""
@@ -394,65 +244,62 @@ done
fi fi
# Various other checks: # Various other checks:
if test "x$ax_pthread_ok" = "xyes"; then if test "x$ax_pthread_ok" = xyes; then
ax_pthread_save_CFLAGS="$CFLAGS" save_LIBS="$LIBS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS" LIBS="$PTHREAD_LIBS $LIBS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED. # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_CACHE_CHECK([for joinable pthread attribute], AC_MSG_CHECKING([for joinable pthread attribute])
[ax_cv_PTHREAD_JOINABLE_ATTR], attr_name=unknown
[ax_cv_PTHREAD_JOINABLE_ATTR=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>], AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[int attr = $ax_pthread_attr; return attr /* ; */])], [int attr = $attr; return attr /* ; */])],
[ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break], [attr_name=$attr; break],
[]) [])
done done
]) AC_MSG_RESULT([$attr_name])
AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
test "x$ax_pthread_joinable_attr_defined" != "xyes"],
[AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
[$ax_cv_PTHREAD_JOINABLE_ATTR],
[Define to necessary symbol if this constant [Define to necessary symbol if this constant
uses a non-standard name on your system.]) uses a non-standard name on your system.])
ax_pthread_joinable_attr_defined=yes fi
])
AC_CACHE_CHECK([whether more special flags are required for pthreads], AC_MSG_CHECKING([if more special flags are required for pthreads])
[ax_cv_PTHREAD_SPECIAL_FLAGS], flag=no
[ax_cv_PTHREAD_SPECIAL_FLAGS=no case ${host_os} in
case $host_os in aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
osf* | hpux*) flag="-D_REENTRANT";;
solaris*) solaris*)
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" if test "$GCC" = "yes"; then
flag="-D_REENTRANT"
else
# TODO: What about Clang on Solaris?
flag="-mt -D_REENTRANT"
fi
;; ;;
esac esac
]) AC_MSG_RESULT([$flag])
AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ if test "x$flag" != xno; then
test "x$ax_pthread_special_flags_added" != "xyes"], PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
[PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" fi
ax_pthread_special_flags_added=yes])
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
[ax_cv_PTHREAD_PRIO_INHERIT], [ax_cv_PTHREAD_PRIO_INHERIT], [
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
[[int i = PTHREAD_PRIO_INHERIT;]])], [[int i = PTHREAD_PRIO_INHERIT;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no]) [ax_cv_PTHREAD_PRIO_INHERIT=no])
]) ])
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
test "x$ax_pthread_prio_inherit_defined" != "xyes"], [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
ax_pthread_prio_inherit_defined=yes
])
CFLAGS="$ax_pthread_save_CFLAGS" LIBS="$save_LIBS"
LIBS="$ax_pthread_save_LIBS" CFLAGS="$save_CFLAGS"
# More AIX lossage: compile with *_r variant # More AIX lossage: compile with *_r variant
if test "x$GCC" != "xyes"; then if test "x$GCC" != xyes; then
case $host_os in case $host_os in
aix*) aix*)
AS_CASE(["x/$CC"], AS_CASE(["x/$CC"],
@@ -474,7 +321,7 @@ AC_SUBST([PTHREAD_CFLAGS])
AC_SUBST([PTHREAD_CC]) AC_SUBST([PTHREAD_CC])
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test "x$ax_pthread_ok" = "xyes"; then if test x"$ax_pthread_ok" = xyes; then
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
: :
else else
-2
View File
@@ -18,8 +18,6 @@ class Ndpi < Formula
depends_on "libtool" => :build depends_on "libtool" => :build
depends_on "json-c" depends_on "json-c"
head "https://github.com/ntop/nDPI.git", :branch => "dev"
def install def install
system "./autogen.sh" system "./autogen.sh"
system "./configure", "--prefix=#{prefix}" system "./configure", "--prefix=#{prefix}"
+1 -1
View File
@@ -5,7 +5,7 @@
# #
# debian/compat # debian/compat
# We should use at least compatibility version 5 # We should use at least comparibily version 5
# but this requires the whole building process # but this requires the whole building process
# to be remade and this is something we leave # to be remade and this is something we leave
# to when we will have more time # to when we will have more time
+1 -1
View File
@@ -1,4 +1,4 @@
library_includedir=$(includedir)/libndpi-@VERSION@/libndpi library_includedir=$(includedir)/libndpi-1.4/libndpi
library_include_HEADERS = ndpi_api.h \ library_include_HEADERS = ndpi_api.h \
ndpi_define.h \ ndpi_define.h \
+71 -195
View File
@@ -1,7 +1,7 @@
/* /*
* ndpi_api.h * ndpi_api.h
* *
* Copyright (C) 2011-17 - ntop.org * Copyright (C) 2011-16 - ntop.org
* *
* This file is part of nDPI, an open source deep packet inspection * This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH * library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -31,14 +31,6 @@
extern "C" { extern "C" {
#endif #endif
/* The #define below is used for apps that dynamically link with nDPI to make
sure that datastructures and in sync across versions
*/
#define NDPI_API_VERSION 1
#define SIZEOF_ID_STRUCT (sizeof(struct ndpi_id_struct))
#define SIZEOF_FLOW_STRUCT (sizeof(struct ndpi_flow_struct))
#define NDPI_DETECTION_ONLY_IPV4 ( 1 << 0 ) #define NDPI_DETECTION_ONLY_IPV4 ( 1 << 0 )
#define NDPI_DETECTION_ONLY_IPV6 ( 1 << 1 ) #define NDPI_DETECTION_ONLY_IPV6 ( 1 << 1 )
@@ -87,8 +79,7 @@ extern "C" {
void * ndpi_realloc(void *ptr, size_t old_size, size_t new_size); void * ndpi_realloc(void *ptr, size_t old_size, size_t new_size);
char * ndpi_strdup(const char *s); char * ndpi_strdup(const char *s);
void ndpi_free(void *ptr); void ndpi_free(void *ptr);
void * ndpi_flow_malloc(size_t size);
void ndpi_flow_free(void *ptr);
/** /**
* Search the first occurrence of substring -find- in -s- * Search the first occurrence of substring -find- in -s-
@@ -103,18 +94,6 @@ extern "C" {
*/ */
char* ndpi_strnstr(const char *s, const char *find, size_t slen); char* ndpi_strnstr(const char *s, const char *find, size_t slen);
/**
* Same as ndpi_strnstr but case insensitive
*
* @par s = string to parse
* @par find = string to match with -s-
* @par slen = max length to match between -s- and -find-
* @return a pointer to the beginning of the located substring;
* NULL if the substring is not found
*
*/
char* ndpi_strncasestr(const char *s, const char *find, size_t slen);
/** /**
* Returns the nDPI protocol id for IP-based protocol detection * Returns the nDPI protocol id for IP-based protocol detection
@@ -143,7 +122,7 @@ extern "C" {
* @return the initialized detection module * @return the initialized detection module
* *
*/ */
struct ndpi_detection_module_struct *ndpi_init_detection_module(void); struct ndpi_detection_module_struct *ndpi_init_detection_module();
/** /**
* Frees the memory allocated in the specified flow * Frees the memory allocated in the specified flow
@@ -222,28 +201,6 @@ extern "C" {
ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_struct, ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow); struct ndpi_flow_struct *flow);
/**
* Processes an extra packet in order to get more information for a given protocol
* (like SSL getting both client and server certificate even if we already know after
* seeing the client certificate what the protocol is)
*
* @par ndpi_struct = the detection module
* @par flow = pointer to the connection state machine
* @par packet = unsigned char pointer to the Layer 3 (IP header)
* @par packetlen = the length of the packet
* @par current_tick = the current timestamp for the packet
* @par src = pointer to the source subscriber state machine
* @par dst = pointer to the destination subscriber state machine
* @return void
*
*/
void ndpi_process_extra_packet(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
const unsigned char *packet,
const unsigned short packetlen,
const u_int64_t current_tick,
struct ndpi_id_struct *src,
struct ndpi_id_struct *dst);
/** /**
* Processes one packet and returns the ID of the detected protocol. * Processes one packet and returns the ID of the detected protocol.
@@ -268,6 +225,52 @@ extern "C" {
struct ndpi_id_struct *dst); struct ndpi_id_struct *dst);
/**
* Processes one packet of L4 and returns the ID of the detected protocol.
* L3 and L4 packet headers are passed in the arguments while payload
* points to the L4 body.
* This function mimics ndpi_detection_process_packet behaviour.
*
* @par ndpi_struct = the detection module
* @par flow = pointer to the connection state machine
* @par iph = IP packet header for IPv4 or NULL
* @par iph6 = IP packet header for IPv6 or NULL
* @par tcp = TCP packet header for TCP or NULL
* @par udp = UDP packet header for UDP or NULL
* @par src_to_dst_direction = order of src/dst state machines in a flow.
* @par l4_proto = L4 protocol of the packet.
* @par src = pointer to the source subscriber state machine
* @par dst = pointer to the destination subscriber state machine
* @par sport = source port of L4 packet, used for protocol guessing.
* @par dport = destination port of L4 packet, used for protocol guessing.
* @par current_tick_l = the current timestamp for the packet
* @par payload = unsigned char pointer to the Layer 4 (TCP/UDP body)
* @par payload_len = the length of the payload
* @return the detected ID of the protocol
*
* NOTE: in a current implementation flow->src and flow->dst are swapped with
* the src_to_dst_direction flag while ndpi_detection_process_packet does not swap
* these values.
*
*/
ndpi_protocol ndpi_l4_detection_process_packet(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
const struct ndpi_iphdr *iph,
struct ndpi_ipv6hdr *iph6,
struct ndpi_tcphdr *tcp,
struct ndpi_udphdr *udp,
u_int8_t src_to_dst_direction,
u_int8_t l4_proto,
struct ndpi_id_struct *src,
u_int16_t sport,
struct ndpi_id_struct *dst,
u_int16_t dport,
const u_int64_t current_tick_l,
u_int8_t *payload, u_int16_t payload_len);
/** /**
* Get the main protocol of the passed flows for the detected module * Get the main protocol of the passed flows for the detected module
* *
@@ -281,21 +284,6 @@ extern "C" {
struct ndpi_flow_struct *flow); struct ndpi_flow_struct *flow);
/**
* API call that is called internally by ndpi_detection_process_packet or by apps
* that want to avoid calling ndpi_detection_process_packet as they have already
* parsed the packet and thus want to avoid this.
*
*
* @par ndpi_struct = the detection module
* @par flow = the flow given for the detection module
* @par ndpi_selection_bitmask = the protocol selected bitmask
*
*/
void ndpi_check_flow_func(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet);
/** /**
* Query the pointer to the layer 4 packet * Query the pointer to the layer 4 packet
* *
@@ -313,6 +301,20 @@ extern "C" {
u_int8_t *l4_protocol_return, u_int32_t flags); u_int8_t *l4_protocol_return, u_int32_t flags);
#if 0
/**
* returns true if the protocol history of the flow of the last packet given to the detection
* contains the given protocol.
*
* @param ndpi_struct the detection module
* @return 1 if protocol has been found, 0 otherwise
*
*/
u_int8_t ndpi_detection_flow_protocol_history_contains_protocol(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
u_int16_t protocol_id);
#endif
/** /**
* Search and return the protocol based on matched ports * Search and return the protocol based on matched ports
* *
@@ -403,33 +405,20 @@ extern "C" {
u_int16_t master_protocol_id); u_int16_t master_protocol_id);
/**
* Exclude protocol from search
*
* @par ndpi_struct = the detection module
* @par flow = the flow where match the host
* @par master_protocol_id = value of the ID associated to the master protocol detected
*
*/
void ndpi_exclude_protocol(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
u_int16_t master_protocol_id,
const char *_file, const char *_func,int _line);
/** /**
* Check if the string -bigram_to_match- match with a bigram of -automa- * Check if the string -bigram_to_match- match with a bigram of -automa-
* *
* @par ndpi_mod = the detection module * @par ndpi_struct = the detection module
* @par automa = the struct ndpi_automa for the bigram * @par automa = the struct ndpi_automa for the bigram
* @par bigram_to_match = the bigram string to match * @par bigram_to_match = the bigram string to match
* @return 0 * @return 0
* *
*/ */
int ndpi_match_bigram(struct ndpi_detection_module_struct *ndpi_mod, int ndpi_match_bigram(struct ndpi_detection_module_struct *ndpi_struct,
ndpi_automa *automa, ndpi_automa *automa,
char *bigram_to_match); char *bigram_to_match);
/** /**
* Write the protocol name in the buffer -buf- as master_protocol.protocol * Write the protocol name in the buffer -buf- as master_protocol.protocol
* *
@@ -442,79 +431,6 @@ extern "C" {
*/ */
char* ndpi_protocol2name(struct ndpi_detection_module_struct *ndpi_mod, ndpi_protocol proto, char *buf, u_int buf_len); char* ndpi_protocol2name(struct ndpi_detection_module_struct *ndpi_mod, ndpi_protocol proto, char *buf, u_int buf_len);
/**
* Find out if a given category is custom/user-defined
*
* @par category = the category associated to the protocol
* @return 1 if this is a custom user category, 0 otherwise
*
*/
int ndpi_is_custom_category(ndpi_protocol_category_t category);
/**
* Overwrite a protocol category defined by nDPI with the custom category
*
* @par ndpi_mod = the detection module
* @par protoId = the protocol identifier to overwrite
* @par breed = the breed to be associated to the protocol
*
*/
void ndpi_set_proto_breed(struct ndpi_detection_module_struct *ndpi_mod,
u_int16_t protoId, ndpi_protocol_breed_t breed);
/**
* Overwrite a protocol category defined by nDPI with the custom category
*
* @par ndpi_mod = the detection module
* @par protoId = the protocol identifier to overwrite
* @par category = the category associated to the protocol
*
*/
void ndpi_set_proto_category(struct ndpi_detection_module_struct *ndpi_mod,
u_int16_t protoId, ndpi_protocol_category_t protoCategory);
/**
* Check if subprotocols of the specified master protocol are just
* informative (and not real)
*
* @par mod = the detection module
* @par protoId = the (master) protocol identifier to query
* @return 1 = the subprotocol is informative, 0 otherwise.
*
*/
u_int8_t ndpi_is_subprotocol_informative(struct ndpi_detection_module_struct *ndpi_mod,
u_int16_t protoId);
/**
* Get protocol category as string
*
* @par mod = the detection module
* @par category = the category associated to the protocol
* @return the string name of the category
*
*/
const char* ndpi_category_get_name(struct ndpi_detection_module_struct *ndpi_mod,
ndpi_protocol_category_t category);
/**
* Set protocol category string
*
* @par mod = the detection module
* @par category = the category associated to the protocol
* @paw name = the string name of the category
*
*/
void ndpi_category_set_name(struct ndpi_detection_module_struct *ndpi_mod,
ndpi_protocol_category_t category, char *name);
/**
* Get protocol category
*
* @par ndpi_mod = the detection module
* @par proto = the struct ndpi_protocol contain the protocols name
* @return the protocol category
*/
ndpi_protocol_category_t ndpi_get_proto_category(struct ndpi_detection_module_struct *ndpi_mod, ndpi_protocol proto);
/** /**
* Get the protocol name associated to the ID * Get the protocol name associated to the ID
@@ -553,24 +469,13 @@ extern "C" {
* Return the ID of the protocol * Return the ID of the protocol
* *
* @par ndpi_mod = the detection module * @par ndpi_mod = the detection module
* @par proto = the protocol name * @par proto = the ID of the protocol
* @return the ID of the protocol * @return the string name of the breed ID
* *
*/ */
int ndpi_get_protocol_id(struct ndpi_detection_module_struct *ndpi_mod, char *proto); int ndpi_get_protocol_id(struct ndpi_detection_module_struct *ndpi_mod, char *proto);
/**
* Return the ID of the category
*
* @par ndpi_mod = the detection module
* @par proto = the category name
* @return the ID of the category
*
*/
int ndpi_get_category_id(struct ndpi_detection_module_struct *ndpi_mod, char *cat);
/** /**
* Write the list of the supported protocols * Write the list of the supported protocols
* *
@@ -683,7 +588,7 @@ extern "C" {
* @return The requested automata, or NULL if an error occurred * @return The requested automata, or NULL if an error occurred
* *
*/ */
void* ndpi_init_automa(void); void* ndpi_init_automa();
/** /**
@@ -700,18 +605,6 @@ extern "C" {
* *
* @par The automata initialized with ndpi_init_automa(); * @par The automata initialized with ndpi_init_automa();
* @par The (sub)string to search * @par The (sub)string to search
* @par The number associated with this string
* @return 0 in case of no error, or -1 if an error occurred.
*
*/
int ndpi_add_string_value_to_automa(void *_automa, char *str, unsigned long num);
/**
* Add a string to match to an automata. Same as ndpi_add_string_value_to_automa() with num set to 1
*
* @par The automata initialized with ndpi_init_automa();
* @par The (sub)string to search
* @return 0 in case of no error, or -1 if an error occurred. * @return 0 in case of no error, or -1 if an error occurred.
* *
*/ */
@@ -738,28 +631,11 @@ extern "C" {
int ndpi_match_string(void *_automa, char *string_to_match); int ndpi_match_string(void *_automa, char *string_to_match);
/**
* Add a string to match to an automata
*
* @par The automata initialized with ndpi_init_automa();
* @par The (sub)string to search
* @par The id associated with the matched string or 0 id not found.
* @return 0 in case of match, or -1 if no match, or -2 if an error occurred.
*
*/
int ndpi_match_string_id(void *_automa, char *string_to_match, unsigned long *id);
/* Utility functions to set ndpi malloc/free/print wrappers */ /* Utility functions to set ndpi malloc/free/print wrappers */
void set_ndpi_malloc(void* (*__ndpi_malloc)(size_t size)); void set_ndpi_malloc(void* (*__ndpi_malloc)(size_t size));
void set_ndpi_free(void (*__ndpi_free)(void *ptr)); void set_ndpi_free(void (*__ndpi_free)(void *ptr));
void set_ndpi_flow_malloc(void* (*__ndpi_flow_malloc)(size_t size)); void set_ndpi_debug_function(ndpi_debug_function_ptr ndpi_debug_printf);
void set_ndpi_flow_free(void (*__ndpi_flow_free)(void *ptr));
void set_ndpi_debug_function(struct ndpi_detection_module_struct *ndpi_str, ndpi_debug_function_ptr ndpi_debug_printf);
void * ndpi_malloc(size_t size);
void * ndpi_calloc(unsigned long count, size_t size);
void ndpi_free(void *ptr);
u_int8_t ndpi_get_api_version();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@@ -1,6 +1,6 @@
/* /*
* *
* Copyright (C) 2011-17 - ntop.org * Copyright (C) 2011-16 - ntop.org
* *
* This file is part of nDPI, an open source deep packet inspection * This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH * library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -180,66 +180,26 @@
#define NDPI_SOULSEEK_CONNECTION_IP_TICK_TIMEOUT 600 #define NDPI_SOULSEEK_CONNECTION_IP_TICK_TIMEOUT 600
#ifdef NDPI_ENABLE_DEBUG_MESSAGES #ifdef NDPI_ENABLE_DEBUG_MESSAGES
#define NDPI_LOG(proto, m, log_level, args...) \
#define NDPI_LOG(proto, mod, log_level, args...) \
{ \ { \
struct ndpi_detection_module_struct *mod = (struct ndpi_detection_module_struct*) m; \ if(mod != NULL) { \
if(mod != NULL && mod->ndpi_debug_printf != NULL) \ mod->ndpi_debug_print_file=__FILE__; \
(*(mod->ndpi_debug_printf))(proto, mod, log_level, __FILE__, __FUNCTION__, __LINE__, args); \ mod->ndpi_debug_print_function=__FUNCTION__; \
mod->ndpi_debug_print_line=__LINE__; \
mod->ndpi_debug_printf(proto, mod, log_level, args); \
} \
} }
/* We must define NDPI_CURRENT_PROTO before include ndpi_main.h !!! #else /* NDPI_ENABLE_DEBUG_MESSAGES */
*
* #include "ndpi_protocol_ids.h"
* #define NDPI_CURRENT_PROTO NDPI_PROTOCOL_XXXX
* #include "ndpi_api.h"
*
*/
#ifndef NDPI_CURRENT_PROTO
#define NDPI_CURRENT_PROTO NDPI_PROTO_UNKNOWN
#endif
#define NDPI_LOG_ERR(mod, args...) \
if(mod && mod->ndpi_log_level >= NDPI_LOG_ERROR) { \
if(mod != NULL && mod->ndpi_debug_printf != NULL) \
(*(mod->ndpi_debug_printf))(NDPI_CURRENT_PROTO, mod, NDPI_LOG_ERROR , __FILE__, __FUNCTION__, __LINE__, args); \
}
#define NDPI_LOG_INFO(mod, args...) \
if(mod && mod->ndpi_log_level >= NDPI_LOG_TRACE) { \
if(mod != NULL && mod->ndpi_debug_printf != NULL) \
(*(mod->ndpi_debug_printf))(NDPI_CURRENT_PROTO, mod, NDPI_LOG_TRACE , __FILE__, __FUNCTION__, __LINE__, args); \
}
#define NDPI_LOG_DBG(mod, args...) \
if(mod && mod->ndpi_log_level >= NDPI_LOG_DEBUG) { \
if(mod != NULL && mod->ndpi_debug_printf != NULL) \
(*(mod->ndpi_debug_printf))(NDPI_CURRENT_PROTO, mod, NDPI_LOG_DEBUG , __FILE__, __FUNCTION__, __LINE__, args); \
}
#define NDPI_LOG_DBG2(mod, args...) \
if(mod && mod->ndpi_log_level >= NDPI_LOG_DEBUG_EXTRA) { \
if(mod != NULL && mod->ndpi_debug_printf != NULL) \
(*(mod->ndpi_debug_printf))(NDPI_CURRENT_PROTO, mod, NDPI_LOG_DEBUG_EXTRA , __FILE__, __FUNCTION__, __LINE__, args); \
}
#else /* not defined NDPI_ENABLE_DEBUG_MESSAGES */
#ifdef WIN32 #ifdef WIN32
#define NDPI_LOG(...) {} #define NDPI_LOG(...) {}
# define NDPI_LOG_ERR(...) {}
# define NDPI_LOG_INFO(...) {}
# define NDPI_LOG_DBG(...) {}
# define NDPI_LOG_DBG2(...) {}
#else #else
#define NDPI_LOG(proto, mod, log_level, args...) {} #define NDPI_LOG(proto, mod, log_level, args...) {}
# define NDPI_LOG_ERR(mod, args...) {}
# define NDPI_LOG_INFO(mod, args...) {}
# define NDPI_LOG_DBG(mod, args...) {}
# define NDPI_LOG_DBG2(mod, args...) {}
#endif #endif
#endif /* NDPI_ENABLE_DEBUG_MESSAGES */
#define NDPI_EXCLUDE_PROTO(mod,flow) ndpi_exclude_protocol(mod, flow, NDPI_CURRENT_PROTO, __FILE__, __FUNCTION__, __LINE__) #endif /* NDPI_ENABLE_DEBUG_MESSAGES */
/** /**
* macro for getting the string len of a static string * macro for getting the string len of a static string
@@ -252,15 +212,15 @@
#define NDPI_COMPARE_IPV6_ADDRESS_STRUCTS(x,y) \ #define NDPI_COMPARE_IPV6_ADDRESS_STRUCTS(x,y) \
((((u_int64_t *)(x))[0]) < (((u_int64_t *)(y))[0]) || ( (((u_int64_t *)(x))[0]) == (((u_int64_t *)(y))[0]) && (((u_int64_t *)(x))[1]) < (((u_int64_t *)(y))[1])) ) ((((u_int64_t *)(x))[0]) < (((u_int64_t *)(y))[0]) || ( (((u_int64_t *)(x))[0]) == (((u_int64_t *)(y))[0]) && (((u_int64_t *)(x))[1]) < (((u_int64_t *)(y))[1])) )
#define NDPI_NUM_BITS 512 #define NDPI_NUM_BITS 256
#define NDPI_BITS /* 32 */ (sizeof(ndpi_ndpi_mask) * 8 /* number of bits in a byte */) /* bits per mask */ #define NDPI_BITS /* 32 */ (sizeof(ndpi_ndpi_mask) * 8 /* number of bits in a byte */) /* bits per mask */
#define howmanybits(x, y) (((x)+((y)-1))/(y)) #define howmanybits(x, y) (((x)+((y)-1))/(y))
#define NDPI_SET(p, n) ((p)->fds_bits[(n)/NDPI_BITS] |= (1ul << (((u_int32_t)n) % NDPI_BITS))) #define NDPI_SET(p, n) ((p)->fds_bits[(n)/NDPI_BITS] |= (1 << (((u_int32_t)n) % NDPI_BITS)))
#define NDPI_CLR(p, n) ((p)->fds_bits[(n)/NDPI_BITS] &= ~(1ul << (((u_int32_t)n) % NDPI_BITS))) #define NDPI_CLR(p, n) ((p)->fds_bits[(n)/NDPI_BITS] &= ~(1 << (((u_int32_t)n) % NDPI_BITS)))
#define NDPI_ISSET(p, n) ((p)->fds_bits[(n)/NDPI_BITS] & (1ul << (((u_int32_t)n) % NDPI_BITS))) #define NDPI_ISSET(p, n) ((p)->fds_bits[(n)/NDPI_BITS] & (1 << (((u_int32_t)n) % NDPI_BITS)))
#define NDPI_ZERO(p) memset((char *)(p), 0, sizeof(*(p))) #define NDPI_ZERO(p) memset((char *)(p), 0, sizeof(*(p)))
#define NDPI_ONE(p) memset((char *)(p), 0xFF, sizeof(*(p))) #define NDPI_ONE(p) memset((char *)(p), 0xFF, sizeof(*(p)))
@@ -333,8 +293,4 @@
#define NDPI_MAX_DNS_REQUESTS 16 #define NDPI_MAX_DNS_REQUESTS 16
#define NDPI_MAJOR @NDPI_MAJOR@
#define NDPI_MINOR @NDPI_MINOR@
#define NDPI_PATCH @NDPI_PATCH@
#endif /* __NDPI_DEFINE_INCLUDE_FILE__ */ #endif /* __NDPI_DEFINE_INCLUDE_FILE__ */
+2 -9
View File
@@ -24,13 +24,12 @@
#ifndef __NDPI_MAIN_H__ #ifndef __NDPI_MAIN_H__
#define __NDPI_MAIN_H__ #define __NDPI_MAIN_H__
#include "ndpi_config.h"
#include "ndpi_includes.h" #include "ndpi_includes.h"
#include "ndpi_define.h" #include "ndpi_define.h"
#include "ndpi_protocol_ids.h" #include "ndpi_protocol_ids.h"
#include "ndpi_typedefs.h" #include "ndpi_typedefs.h"
#include "ndpi_api.h"
#include "ndpi_protocols.h" #include "ndpi_protocols.h"
#include "ndpi_api.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -81,7 +80,6 @@ extern "C" {
u_int16_t lower_detected_protocol); u_int16_t lower_detected_protocol);
extern void ndpi_set_proto_defaults(struct ndpi_detection_module_struct *ndpi_mod, ndpi_protocol_breed_t protoBreed, u_int16_t protoId, extern void ndpi_set_proto_defaults(struct ndpi_detection_module_struct *ndpi_mod, ndpi_protocol_breed_t protoBreed, u_int16_t protoId,
u_int16_t tcp_alias_protoId[2], u_int16_t udp_alias_protoId[2], char *protoName, u_int16_t tcp_alias_protoId[2], u_int16_t udp_alias_protoId[2], char *protoName,
ndpi_protocol_category_t protoCategory,
ndpi_port_range *tcpDefPorts, ndpi_port_range *udpDefPorts); ndpi_port_range *tcpDefPorts, ndpi_port_range *udpDefPorts);
extern void ndpi_int_reset_packet_protocol(struct ndpi_packet_struct *packet); extern void ndpi_int_reset_packet_protocol(struct ndpi_packet_struct *packet);
@@ -95,11 +93,9 @@ extern "C" {
extern char *ndpi_get_ip_string(struct ndpi_detection_module_struct *ndpi_struct, const ndpi_ip_addr_t * ip); extern char *ndpi_get_ip_string(struct ndpi_detection_module_struct *ndpi_struct, const ndpi_ip_addr_t * ip);
extern char *ndpi_get_packet_src_ip_string(struct ndpi_detection_module_struct *ndpi_struct, const struct ndpi_packet_struct *packet); extern char *ndpi_get_packet_src_ip_string(struct ndpi_detection_module_struct *ndpi_struct, const struct ndpi_packet_struct *packet);
extern char* ndpi_get_proto_by_id(struct ndpi_detection_module_struct *ndpi_mod, u_int id); extern char* ndpi_get_proto_by_id(struct ndpi_detection_module_struct *ndpi_mod, u_int id);
u_int16_t ndpi_get_proto_by_name(struct ndpi_detection_module_struct *ndpi_mod, const char *name);
extern u_int16_t ndpi_guess_protocol_id(struct ndpi_detection_module_struct *ndpi_struct, extern u_int16_t ndpi_guess_protocol_id(struct ndpi_detection_module_struct *ndpi_struct,
u_int8_t proto, u_int16_t sport, u_int16_t dport, u_int8_t proto, u_int16_t sport, u_int16_t dport);
u_int8_t *user_defined_proto);
extern u_int8_t ndpi_is_proto(ndpi_protocol p, u_int16_t proto); extern u_int8_t ndpi_is_proto(ndpi_protocol p, u_int16_t proto);
@@ -107,9 +103,6 @@ extern "C" {
extern int ndpi_get_protocol_id_master_proto(struct ndpi_detection_module_struct *ndpi_struct, u_int16_t protocol_id, extern int ndpi_get_protocol_id_master_proto(struct ndpi_detection_module_struct *ndpi_struct, u_int16_t protocol_id,
u_int16_t** tcp_master_proto, u_int16_t** tcp_master_proto,
u_int16_t** udp_master_proto); u_int16_t** udp_master_proto);
#ifdef NDPI_PROTOCOL_NETBIOS
int ndpi_netbios_name_interpret(char *in, char *out, u_int out_len);
#endif
#ifdef NDPI_ENABLE_DEBUG_MESSAGES #ifdef NDPI_ENABLE_DEBUG_MESSAGES
void ndpi_debug_get_last_log_function_line(struct ndpi_detection_module_struct *ndpi_struct, void ndpi_debug_get_last_log_function_line(struct ndpi_detection_module_struct *ndpi_struct,
+108 -120
View File
@@ -1,8 +1,7 @@
/* /*
* ndpi_protocol_ids.h * ndpi_protocol_ids.h
* *
* Copyright (C) 2011-18 - ntop.org * Copyright (C) 2011-16 - ntop.org
* *
* This file is part of nDPI, an open source deep packet inspection * This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH * library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -31,20 +30,39 @@
#define __NDPI_PROTOCOLS_DEFAULT_H__ #define __NDPI_PROTOCOLS_DEFAULT_H__
#define NDPI_DETECTION_SUPPORT_IPV6 #define NDPI_DETECTION_SUPPORT_IPV6
#define NDPI_PROTOCOL_SIZE 2 #define NDPI_PROTOCOL_HISTORY_SIZE 2
#define NDPI_PROTOCOL_UNKNOWN 0 #define NDPI_PROTOCOL_UNKNOWN 0
#define NDPI_PROTOCOL_NO_MASTER_PROTO NDPI_PROTOCOL_UNKNOWN #define NDPI_PROTOCOL_NO_MASTER_PROTO NDPI_PROTOCOL_UNKNOWN
#define NDPI_PROTOCOL_UNKNOWN 0 #define NDPI_PROTOCOL_IP_VRRP 73
#define NDPI_PROTOCOL_IP_IPSEC 79
#define NDPI_PROTOCOL_IP_GRE 80
#define NDPI_PROTOCOL_IP_ICMP 81
#define NDPI_PROTOCOL_IP_IGMP 82
#define NDPI_PROTOCOL_IP_EGP 83
#define NDPI_PROTOCOL_IP_SCTP 84
#define NDPI_PROTOCOL_IP_OSPF 85
#define NDPI_PROTOCOL_IP_IP_IN_IP 86
#define NDPI_PROTOCOL_IP_ICMPV6 102
#define NDPI_PROTOCOL_HTTP 7
#define NDPI_PROTOCOL_HTTP_DOWNLOAD 60
#define NDPI_PROTOCOL_SSL_NO_CERT 64 /* SSL without certificate (Skype, Ultrasurf?) - ntop.org */
#define NDPI_PROTOCOL_SSL 91
#define NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC 110
#define NDPI_PROTOCOL_HTTP_CONNECT 130
#define NDPI_PROTOCOL_HTTP_PROXY 131
#define NDPI_PROTOCOL_SOCKS 172 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_FTP_CONTROL 1 /* Tomasz Bujlow <tomasz@skatnet.dk> */ #define NDPI_PROTOCOL_FTP_CONTROL 1 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_MAIL_POP 2 #define NDPI_PROTOCOL_MAIL_POP 2
#define NDPI_PROTOCOL_MAIL_SMTP 3 #define NDPI_PROTOCOL_MAIL_SMTP 3
#define NDPI_PROTOCOL_MAIL_IMAP 4 #define NDPI_PROTOCOL_MAIL_IMAP 4
#define NDPI_PROTOCOL_DNS 5 #define NDPI_PROTOCOL_DNS 5
#define NDPI_PROTOCOL_IPP 6 #define NDPI_PROTOCOL_IPP 6
#define NDPI_PROTOCOL_HTTP 7
#define NDPI_PROTOCOL_MDNS 8 #define NDPI_PROTOCOL_MDNS 8
#define NDPI_PROTOCOL_NTP 9 #define NDPI_PROTOCOL_NTP 9
#define NDPI_PROTOCOL_NETBIOS 10 #define NDPI_PROTOCOL_NETBIOS 10
@@ -58,7 +76,7 @@
#define NDPI_PROTOCOL_DHCP 18 #define NDPI_PROTOCOL_DHCP 18
#define NDPI_PROTOCOL_POSTGRES 19 #define NDPI_PROTOCOL_POSTGRES 19
#define NDPI_PROTOCOL_MYSQL 20 #define NDPI_PROTOCOL_MYSQL 20
#define NDPI_PROTOCOL_HOTMAIL 21 #define NDPI_PROTOCOL_TDS 21
#define NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK 22 #define NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK 22
#define NDPI_PROTOCOL_MAIL_POPS 23 #define NDPI_PROTOCOL_MAIL_POPS 23
#define NDPI_PROTOCOL_APPLEJUICE 24 #define NDPI_PROTOCOL_APPLEJUICE 24
@@ -68,7 +86,7 @@
#define NDPI_PROTOCOL_VMWARE 28 #define NDPI_PROTOCOL_VMWARE 28
#define NDPI_PROTOCOL_MAIL_SMTPS 29 #define NDPI_PROTOCOL_MAIL_SMTPS 29
#define NDPI_PROTOCOL_FILETOPIA 30 #define NDPI_PROTOCOL_FILETOPIA 30
#define NDPI_PROTOCOL_UBNTAC2 31 /* Ubiquity UBNT AirControl 2 - Thomas Fjellstrom <thomas+ndpi@fjellstrom.ca> */ #define NDPI_PROTOCOL_IMESH 31
#define NDPI_PROTOCOL_KONTIKI 32 #define NDPI_PROTOCOL_KONTIKI 32
#define NDPI_PROTOCOL_OPENFT 33 #define NDPI_PROTOCOL_OPENFT 33
#define NDPI_PROTOCOL_FASTTRACK 34 #define NDPI_PROTOCOL_FASTTRACK 34
@@ -76,20 +94,9 @@
#define NDPI_PROTOCOL_EDONKEY 36 /* Tomasz Bujlow <tomasz@skatnet.dk> */ #define NDPI_PROTOCOL_EDONKEY 36 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_BITTORRENT 37 #define NDPI_PROTOCOL_BITTORRENT 37
#define NDPI_PROTOCOL_EPP 38 #define NDPI_PROTOCOL_EPP 38
#define NDPI_CONTENT_AVI 39
#define NDPI_CONTENT_FLASH 40
#define NDPI_CONTENT_OGG 41
#define NDPI_CONTENT_MPEG 42
#define NDPI_CONTENT_QUICKTIME 43
#define NDPI_CONTENT_REALMEDIA 44
#define NDPI_CONTENT_WINDOWSMEDIA 45
#define NDPI_CONTENT_MMS 46
#define NDPI_PROTOCOL_XBOX 47 #define NDPI_PROTOCOL_XBOX 47
#define NDPI_PROTOCOL_QQ 48 #define NDPI_PROTOCOL_QQ 48
#define NDPI_PROTOCOL_MOVE 49
/* Free to use */
#define NDPI_PROTOCOL_FREE_A 49
#define NDPI_PROTOCOL_RTSP 50 #define NDPI_PROTOCOL_RTSP 50
#define NDPI_PROTOCOL_MAIL_IMAPS 51 #define NDPI_PROTOCOL_MAIL_IMAPS 51
#define NDPI_PROTOCOL_ICECAST 52 #define NDPI_PROTOCOL_ICECAST 52
@@ -100,38 +107,26 @@
#define NDPI_PROTOCOL_SOPCAST 57 #define NDPI_PROTOCOL_SOPCAST 57
#define NDPI_PROTOCOL_TVANTS 58 #define NDPI_PROTOCOL_TVANTS 58
#define NDPI_PROTOCOL_TVUPLAYER 59 #define NDPI_PROTOCOL_TVUPLAYER 59
#define NDPI_PROTOCOL_HTTP_DOWNLOAD 60
#define NDPI_PROTOCOL_QQLIVE 61 #define NDPI_PROTOCOL_QQLIVE 61
#define NDPI_PROTOCOL_THUNDER 62 #define NDPI_PROTOCOL_THUNDER 62
#define NDPI_PROTOCOL_SOULSEEK 63 #define NDPI_PROTOCOL_SOULSEEK 63
#define NDPI_PROTOCOL_SSL_NO_CERT 64
#define NDPI_PROTOCOL_IRC 65 #define NDPI_PROTOCOL_IRC 65
#define NDPI_PROTOCOL_AYIYA 66 #define NDPI_PROTOCOL_AYIYA 66
#define NDPI_PROTOCOL_UNENCRYPTED_JABBER 67 #define NDPI_PROTOCOL_UNENCRYPED_JABBER 67
#define NDPI_PROTOCOL_MSN 68 #define NDPI_PROTOCOL_MSN 68
#define NDPI_PROTOCOL_OSCAR 69 #define NDPI_PROTOCOL_OSCAR 69
#define NDPI_PROTOCOL_YAHOO 70 #define NDPI_PROTOCOL_YAHOO 70
#define NDPI_PROTOCOL_BATTLEFIELD 71 #define NDPI_PROTOCOL_BATTLEFIELD 71
#define NDPI_PROTOCOL_GOOGLE_PLUS 72 #define NDPI_PROTOCOL_QUAKE 72
#define NDPI_PROTOCOL_IP_VRRP 73
#define NDPI_PROTOCOL_STEAM 74 /* Tomasz Bujlow <tomasz@skatnet.dk> */ #define NDPI_PROTOCOL_STEAM 74 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_HALFLIFE2 75 #define NDPI_PROTOCOL_HALFLIFE2 75
#define NDPI_PROTOCOL_WORLDOFWARCRAFT 76 #define NDPI_PROTOCOL_WORLDOFWARCRAFT 76
#define NDPI_PROTOCOL_TELNET 77 #define NDPI_PROTOCOL_TELNET 77
#define NDPI_PROTOCOL_STUN 78 #define NDPI_PROTOCOL_STUN 78
#define NDPI_PROTOCOL_IP_IPSEC 79
#define NDPI_PROTOCOL_IP_GRE 80
#define NDPI_PROTOCOL_IP_ICMP 81
#define NDPI_PROTOCOL_IP_IGMP 82
#define NDPI_PROTOCOL_IP_EGP 83
#define NDPI_PROTOCOL_IP_SCTP 84
#define NDPI_PROTOCOL_IP_OSPF 85
#define NDPI_PROTOCOL_IP_IP_IN_IP 86
#define NDPI_PROTOCOL_RTP 87 #define NDPI_PROTOCOL_RTP 87
#define NDPI_PROTOCOL_RDP 88 #define NDPI_PROTOCOL_RDP 88
#define NDPI_PROTOCOL_VNC 89 #define NDPI_PROTOCOL_VNC 89
#define NDPI_PROTOCOL_PCANYWHERE 90 #define NDPI_PROTOCOL_PCANYWHERE 90
#define NDPI_PROTOCOL_SSL 91
#define NDPI_PROTOCOL_SSH 92 #define NDPI_PROTOCOL_SSH 92
#define NDPI_PROTOCOL_USENET 93 #define NDPI_PROTOCOL_USENET 93
#define NDPI_PROTOCOL_MGCP 94 #define NDPI_PROTOCOL_MGCP 94
@@ -142,7 +137,6 @@
#define NDPI_PROTOCOL_AIMINI 99 #define NDPI_PROTOCOL_AIMINI 99
#define NDPI_PROTOCOL_SIP 100 #define NDPI_PROTOCOL_SIP 100
#define NDPI_PROTOCOL_TRUPHONE 101 #define NDPI_PROTOCOL_TRUPHONE 101
#define NDPI_PROTOCOL_IP_ICMPV6 102
#define NDPI_PROTOCOL_DHCPV6 103 #define NDPI_PROTOCOL_DHCPV6 103
#define NDPI_PROTOCOL_ARMAGETRON 104 #define NDPI_PROTOCOL_ARMAGETRON 104
#define NDPI_PROTOCOL_CROSSFIRE 105 #define NDPI_PROTOCOL_CROSSFIRE 105
@@ -150,49 +144,29 @@
#define NDPI_PROTOCOL_FIESTA 107 #define NDPI_PROTOCOL_FIESTA 107
#define NDPI_PROTOCOL_FLORENSIA 108 #define NDPI_PROTOCOL_FLORENSIA 108
#define NDPI_PROTOCOL_GUILDWARS 109 #define NDPI_PROTOCOL_GUILDWARS 109
#define NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC 110 /*avoid large declarations in the future*/
#define NDPI_PROTOCOL_KERBEROS 111 #define NDPI_PROTOCOL_KERBEROS 111
#define NDPI_PROTOCOL_LDAP 112 #define NDPI_PROTOCOL_LDAP 112
#define NDPI_PROTOCOL_MAPLESTORY 113 #define NDPI_PROTOCOL_MAPLESTORY 113
#define NDPI_PROTOCOL_MSSQL_TDS 114 #define NDPI_PROTOCOL_MSSQL 114
#define NDPI_PROTOCOL_PPTP 115 #define NDPI_PROTOCOL_PPTP 115
#define NDPI_PROTOCOL_WARCRAFT3 116 #define NDPI_PROTOCOL_WARCRAFT3 116
#define NDPI_PROTOCOL_WORLD_OF_KUNG_FU 117 #define NDPI_PROTOCOL_WORLD_OF_KUNG_FU 117
#define NDPI_PROTOCOL_SLACK 118 #define NDPI_PROTOCOL_MEEBO 118
#define NDPI_PROTOCOL_FACEBOOK 119
#define NDPI_PROTOCOL_TWITTER 120
#define NDPI_PROTOCOL_DROPBOX 121 #define NDPI_PROTOCOL_DROPBOX 121
#define NDPI_PROTOCOL_GMAIL 122
#define NDPI_PROTOCOL_GOOGLE_MAPS 123
#define NDPI_PROTOCOL_YOUTUBE 124
#define NDPI_PROTOCOL_SKYPE 125 #define NDPI_PROTOCOL_SKYPE 125
#define NDPI_PROTOCOL_GOOGLE 126
#define NDPI_PROTOCOL_DCERPC 127 #define NDPI_PROTOCOL_DCERPC 127
#define NDPI_PROTOCOL_NETFLOW 128 #define NDPI_PROTOCOL_NETFLOW 128
#define NDPI_PROTOCOL_SFLOW 129 #define NDPI_PROTOCOL_SFLOW 129
#define NDPI_PROTOCOL_HTTP_CONNECT 130 #define NDPI_PROTOCOL_CITRIX 132
#define NDPI_PROTOCOL_HTTP_PROXY 131 #define NDPI_PROTOCOL_SKYFILE_PREPAID 136
#define NDPI_PROTOCOL_CITRIX 132 /* It includes also the old NDPI_PROTOCOL_CITRIX_ONLINE */ #define NDPI_PROTOCOL_SKYFILE_RUDICS 137
#define NDPI_PROTOCOL_NETFLIX 133 #define NDPI_PROTOCOL_SKYFILE_POSTPAID 138
#define NDPI_PROTOCOL_LASTFM 134 #define NDPI_PROTOCOL_CITRIX_ONLINE 139
#define NDPI_PROTOCOL_WAZE 135
#define NDPI_PROTOCOL_YOUTUBE_UPLOAD 136 /* Upload files to youtube */
#define NDPI_PROTOCOL_ICQ 137
#define NDPI_PROTOCOL_CHECKMK 138
/* Free to use */
#define NDPI_PROTOCOL_FREE_B 139
#define NDPI_PROTOCOL_APPLE 140
#define NDPI_PROTOCOL_WEBEX 141 #define NDPI_PROTOCOL_WEBEX 141
#define NDPI_PROTOCOL_WHATSAPP 142
#define NDPI_PROTOCOL_APPLE_ICLOUD 143
#define NDPI_PROTOCOL_VIBER 144 #define NDPI_PROTOCOL_VIBER 144
#define NDPI_PROTOCOL_APPLE_ITUNES 145
#define NDPI_PROTOCOL_RADIUS 146 #define NDPI_PROTOCOL_RADIUS 146
#define NDPI_PROTOCOL_WINDOWS_UPDATE 147 #define NDPI_SERVICE_WINDOWS_UPDATE 147
#define NDPI_PROTOCOL_TEAMVIEWER 148 /* xplico.org */ #define NDPI_PROTOCOL_TEAMVIEWER 148 /* xplico.org */
#define NDPI_PROTOCOL_TUENTI 149
#define NDPI_PROTOCOL_LOTUS_NOTES 150 #define NDPI_PROTOCOL_LOTUS_NOTES 150
#define NDPI_PROTOCOL_SAP 151 #define NDPI_PROTOCOL_SAP 151
#define NDPI_PROTOCOL_GTP 152 #define NDPI_PROTOCOL_GTP 152
@@ -200,7 +174,6 @@
#define NDPI_PROTOCOL_LLMNR 154 #define NDPI_PROTOCOL_LLMNR 154
#define NDPI_PROTOCOL_REMOTE_SCAN 155 #define NDPI_PROTOCOL_REMOTE_SCAN 155
#define NDPI_PROTOCOL_SPOTIFY 156 #define NDPI_PROTOCOL_SPOTIFY 156
#define NDPI_CONTENT_WEBM 157
#define NDPI_PROTOCOL_H323 158 /* Remy Mudingay <mudingay@ill.fr> */ #define NDPI_PROTOCOL_H323 158 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_OPENVPN 159 /* Remy Mudingay <mudingay@ill.fr> */ #define NDPI_PROTOCOL_OPENVPN 159 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_NOE 160 /* Remy Mudingay <mudingay@ill.fr> */ #define NDPI_PROTOCOL_NOE 160 /* Remy Mudingay <mudingay@ill.fr> */
@@ -215,80 +188,95 @@
#define NDPI_PROTOCOL_UBUNTUONE 169 /* Remy Mudingay <mudingay@ill.fr> */ #define NDPI_PROTOCOL_UBUNTUONE 169 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_WHOIS_DAS 170 #define NDPI_PROTOCOL_WHOIS_DAS 170
#define NDPI_PROTOCOL_COLLECTD 171 #define NDPI_PROTOCOL_COLLECTD 171
#define NDPI_PROTOCOL_SOCKS 172 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_NINTENDO 173
#define NDPI_PROTOCOL_RTMP 174 /* Tomasz Bujlow <tomasz@skatnet.dk> */ #define NDPI_PROTOCOL_RTMP 174 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_FTP_DATA 175 /* Tomasz Bujlow <tomasz@skatnet.dk> */ #define NDPI_PROTOCOL_FTP_DATA 175 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_WIKIPEDIA 176 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_ZMQ 177 #define NDPI_PROTOCOL_ZMQ 177
#define NDPI_PROTOCOL_AMAZON 178 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_EBAY 179 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_CNN 180 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_MEGACO 181 /* Gianluca Costa <g.costa@xplico.org> */ #define NDPI_PROTOCOL_MEGACO 181 /* Gianluca Costa <g.costa@xplico.org> */
#define NDPI_PROTOCOL_REDIS 182 #define NDPI_PROTOCOL_REDIS 182
#define NDPI_PROTOCOL_PANDO 183 /* Tomasz Bujlow <tomasz@skatnet.dk> */ #define NDPI_PROTOCOL_PANDO 183 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_VHUA 184 #define NDPI_PROTOCOL_VHUA 184
#define NDPI_PROTOCOL_TELEGRAM 185 /* Gianluca Costa <g.costa@xplico.org> */ #define NDPI_PROTOCOL_TELEGRAM 185 /* Gianluca Costa <g.costa@xplico.org> */
#define NDPI_PROTOCOL_VEVO 186
#define NDPI_PROTOCOL_PANDORA 187
#define NDPI_PROTOCOL_QUIC 188 /* Andrea Buscarinu <andrea.buscarinu@gmail.com> - Michele Campus <michelecampus5@gmail.com> */ #define NDPI_PROTOCOL_QUIC 188 /* Andrea Buscarinu <andrea.buscarinu@gmail.com> - Michele Campus <michelecampus5@gmail.com> */
#define NDPI_PROTOCOL_WHATSAPP_VOICE 189 #define NDPI_PROTOCOL_WHATSAPP_VOICE 189
#define NDPI_PROTOCOL_EAQ 190
#define NDPI_PROTOCOL_OOKLA 191
#define NDPI_PROTOCOL_AMQP 192
#define NDPI_PROTOCOL_KAKAOTALK 193 /* KakaoTalk Chat (no voice call) */
#define NDPI_PROTOCOL_KAKAOTALK_VOICE 194 /* KakaoTalk Voice */
#define NDPI_PROTOCOL_TWITCH 195 /* Edoardo Dominici <edoaramis@gmail.com> */
#define NDPI_PROTOCOL_QUICKPLAY 196 /* Streaming service used by various services such as hooq.tv */
#define NDPI_PROTOCOL_WECHAT 197
#define NDPI_PROTOCOL_MPEGTS 198
#define NDPI_PROTOCOL_SNAPCHAT 199
#define NDPI_PROTOCOL_SINA 200
#define NDPI_PROTOCOL_HANGOUT 201
#define NDPI_PROTOCOL_IFLIX 202 /* www.vizuamatix.com R&D team & M.Mallawaarachchie <manoj_ws@yahoo.com> */
#define NDPI_PROTOCOL_GITHUB 203
#define NDPI_PROTOCOL_BJNP 204
#define NDPI_PROTOCOL_1KXUN 205
#define NDPI_PROTOCOL_IQIYI 206
#define NDPI_PROTOCOL_SMPP 207 /* Damir Franusic <df@release14.org> */
#define NDPI_PROTOCOL_DNSCRYPT 208
#define NDPI_PROTOCOL_TINC 209 /* William Guglielmo <william@deselmo.com> */
#define NDPI_PROTOCOL_DEEZER 210
#define NDPI_PROTOCOL_INSTAGRAM 211 /* Andrea Buscarinu <andrea.buscarinu@gmail.com> */
#define NDPI_PROTOCOL_MICROSOFT 212
#define NDPI_PROTOCOL_STARCRAFT 213 /* Matteo Bracci <matteobracci1@gmail.com> */ #define NDPI_PROTOCOL_STARCRAFT 213 /* Matteo Bracci <matteobracci1@gmail.com> */
#define NDPI_PROTOCOL_TEREDO 214 #define NDPI_PROTOCOL_TEREDO 214
#define NDPI_PROTOCOL_HOTSPOT_SHIELD 215 #define NDPI_PROTOCOL_HEP 216 /* Sipcapture.org QXIP BV */
#define NDPI_PROTOCOL_HEP 216 /* sipcapture.org QXIP BV */ #define NDPI_PROTOCOL_UBNTAC2 217 /* Ubiquity UBNT AirControl 2 - Thomas Fjellstrom <thomas+ndpi@fjellstrom.ca> */
#define NDPI_PROTOCOL_GOOGLE_DRIVE 217 #define NDPI_PROTOCOL_MS_LYNC 173
#define NDPI_PROTOCOL_OCS 218
#define NDPI_PROTOCOL_OFFICE_365 219
#define NDPI_PROTOCOL_CLOUDFLARE 220
#define NDPI_PROTOCOL_MS_ONE_DRIVE 221 #define NDPI_CONTENT_AVI 39
#define NDPI_CONTENT_FLASH 40
#define NDPI_CONTENT_OGG 41
#define NDPI_CONTENT_MPEG 42
#define NDPI_CONTENT_QUICKTIME 43
#define NDPI_CONTENT_REALMEDIA 44
#define NDPI_CONTENT_WINDOWSMEDIA 45
#define NDPI_CONTENT_MMS 46
#define NDPI_CONTENT_WEBM 157
#define NDPI_SERVICE_FACEBOOK 119
#define NDPI_SERVICE_TWITTER 120
#define NDPI_SERVICE_GMAIL 122
#define NDPI_SERVICE_GOOGLE_MAPS 123
#define NDPI_SERVICE_YOUTUBE 124
#define NDPI_SERVICE_VEVO 186
#define NDPI_SERVICE_GOOGLE 126
#define NDPI_SERVICE_NETFLIX 133
#define NDPI_SERVICE_LASTFM 134
#define NDPI_SERVICE_WAZE 135
#define NDPI_SERVICE_APPLE 140
#define NDPI_SERVICE_WHATSAPP 142
#define NDPI_SERVICE_APPLE_ICLOUD 143
#define NDPI_SERVICE_APPLE_ITUNES 145
#define NDPI_SERVICE_TUENTI 149
#define NDPI_SERVICE_WIKIPEDIA 176 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_MSN NDPI_PROTOCOL_MSN /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_AMAZON 178 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_EBAY 179 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_CNN 180 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_DROPBOX NDPI_PROTOCOL_DROPBOX /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_SKYPE NDPI_PROTOCOL_SKYPE /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_VIBER NDPI_PROTOCOL_VIBER
#define NDPI_SERVICE_YAHOO NDPI_PROTOCOL_YAHOO /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_PANDORA 187
#define NDPI_PROTOCOL_EAQ 190
#define NDPI_SERVICE_TIMMEU 191
#define NDPI_SERVICE_TORCEDOR 192
#define NDPI_SERVICE_KAKAOTALK 193 /* KakaoTalk Chat (no voice call) */
#define NDPI_SERVICE_KAKAOTALK_VOICE 194 /* KakaoTalk Voice */
#define NDPI_SERVICE_TWITCH 195 /* Edoardo Dominici <edoaramis@gmail.com> */
#define NDPI_SERVICE_QUICKPLAY 196 /* Streaming service used by various services such as hooq.tv */
#define NDPI_SERVICE_TIM 197 /* Traffic for tim.com.br and tim.it */
#define NDPI_PROTOCOL_MPEGTS 198
#define NDPI_SERVICE_SNAPCHAT 199
#define NDPI_SERVICE_SIMET 200
#define NDPI_SERVICE_OPENSIGNAL 201
#define NDPI_SERVICE_99TAXI 202
#define NDPI_SERVICE_EASYTAXI 203
#define NDPI_SERVICE_GLOBOTV 204
#define NDPI_SERVICE_TIMSOMDECHAMADA 205
#define NDPI_SERVICE_TIMMENU 206
#define NDPI_SERVICE_TIMPORTASABERTAS 207
#define NDPI_SERVICE_TIMRECARGA 208
#define NDPI_SERVICE_TIMBETA 209
#define NDPI_SERVICE_DEEZER 210
#define NDPI_SERVICE_INSTAGRAM 211 /* Andrea Buscarinu <andrea.buscarinu@gmail.com> */
#define NDPI_SERVICE_MICROSOFT 212
#define NDPI_SERVICE_HOTSPOT_SHIELD 215
#define NDPI_SERVICE_OCS 218
#define NDPI_SERVICE_OFFICE_365 219
#define NDPI_SERVICE_CLOUDFLARE 220
#define NDPI_SERVICE_MS_ONE_DRIVE 221
#define NDPI_PROTOCOL_MQTT 222 #define NDPI_PROTOCOL_MQTT 222
#define NDPI_PROTOCOL_RX 223 #define NDPI_PROTOCOL_RX 223
#define NDPI_PROTOCOL_APPLESTORE 224 #define NDPI_SERVICE_WEIBO 224
#define NDPI_PROTOCOL_OPENDNS 225 #define NDPI_SERVICE_OPENDNS 225
#define NDPI_PROTOCOL_GIT 226 #define NDPI_PROTOCOL_GIT 226
#define NDPI_PROTOCOL_DRDA 227 #define NDPI_PROTOCOL_DRDA 227
#define NDPI_PROTOCOL_PLAYSTORE 228
#define NDPI_PROTOCOL_SOMEIP 229
#define NDPI_PROTOCOL_FIX 230
#define NDPI_PROTOCOL_PLAYSTATION 231
#define NDPI_PROTOCOL_PASTEBIN 232 /* Paulo Angelo <pa@pauloangelo.com> */
#define NDPI_PROTOCOL_LINKEDIN 233 /* Paulo Angelo <pa@pauloangelo.com> */
#define NDPI_PROTOCOL_SOUNDCLOUD 234
#define NDPI_PROTOCOL_CSGO 235 /* Counter-Strike Global Offensive, Dota 2 */
#define NDPI_PROTOCOL_LISP 236
#define NDPI_PROTOCOL_DIAMETER 237
#define NDPI_PROTOCOL_APPLE_PUSH 238
#define NDPI_PROTOCOL_GOOGLE_SERVICES 239
#define NDPI_PROTOCOL_AMAZON_VIDEO 240
#define NDPI_PROTOCOL_GOOGLE_DOCS 241
#define NDPI_PROTOCOL_WHATSAPP_FILES 242 /* Videos, pictures, voice messages... */
/* UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE */ /* UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE */
#define NDPI_LAST_IMPLEMENTED_PROTOCOL NDPI_PROTOCOL_WHATSAPP_FILES #define NDPI_LAST_IMPLEMENTED_PROTOCOL NDPI_PROTOCOL_DRDA
#define NDPI_MAX_SUPPORTED_PROTOCOLS (NDPI_LAST_IMPLEMENTED_PROTOCOL + 1) #define NDPI_MAX_SUPPORTED_PROTOCOLS (NDPI_LAST_IMPLEMENTED_PROTOCOL + 1)
#define NDPI_MAX_NUM_CUSTOM_PROTOCOLS (NDPI_NUM_BITS-NDPI_LAST_IMPLEMENTED_PROTOCOL) #define NDPI_MAX_NUM_CUSTOM_PROTOCOLS (NDPI_NUM_BITS-NDPI_LAST_IMPLEMENTED_PROTOCOL)
+11 -27
View File
@@ -1,7 +1,7 @@
/* /*
* ndpi_protocols.h * ndpi_protocols.h
* *
* Copyright (C) 2011-18 - ntop.org * Copyright (C) 2011-16 - ntop.org
* *
* This file is part of nDPI, an open source deep packet inspection * This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH * library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -44,7 +44,6 @@ ndpi_port_range* ndpi_build_default_ports(ndpi_port_range *ports,
/* TCP/UDP protocols */ /* TCP/UDP protocols */
u_int ndpi_search_tcp_or_udp_raw(struct ndpi_detection_module_struct *ndpi_struct, u_int ndpi_search_tcp_or_udp_raw(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
u_int8_t protocol, u_int8_t protocol,
u_int32_t saddr, u_int32_t daddr, u_int32_t saddr, u_int32_t daddr,
u_int16_t sport, u_int16_t dport); u_int16_t sport, u_int16_t dport);
@@ -52,9 +51,7 @@ u_int ndpi_search_tcp_or_udp_raw(struct ndpi_detection_module_struct *ndpi_struc
void ndpi_search_tcp_or_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_tcp_or_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
/* Applications and other protocols. */ /* Applications and other protocols. */
void ndpi_search_diameter(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_lisp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_edonkey(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_edonkey(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_fasttrack_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_fasttrack_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
@@ -83,6 +80,7 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
void ndpi_search_rtsp_tcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_rtsp_tcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_filetopia_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_filetopia_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_vmware(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_vmware(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_imesh_tcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ssl_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_ssl_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mms_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_mms_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_icecast_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_icecast_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
@@ -128,6 +126,7 @@ void ndpi_search_rdp(struct ndpi_detection_module_struct *ndpi_struct, struct nd
void ndpi_search_snmp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_snmp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_kontiki(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_kontiki(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_syslog(struct ndpi_detection_module_struct*ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_syslog(struct ndpi_detection_module_struct*ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_tds_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_netbios(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_netbios(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mdns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_mdns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ipp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_ipp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
@@ -136,12 +135,12 @@ void ndpi_search_warcraft3(struct ndpi_detection_module_struct *ndpi_struct, str
void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_xdmcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_xdmcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_tftp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_tftp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mssql_tds(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_mssql(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_pptp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_pptp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_stealthnet(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_stealthnet(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_dhcpv6_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_dhcpv6_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_meebo(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_afp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_afp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_checkmk(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_florensia(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_florensia(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_maplestory(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_maplestory(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
@@ -183,6 +182,7 @@ void ndpi_search_pando(struct ndpi_detection_module_struct *ndpi_struct, struct
void ndpi_search_megaco(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_megaco(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_redis(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_redis(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_zmq(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_zmq(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_twitter(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_vhua(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_vhua(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_telegram(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_telegram(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
@@ -193,27 +193,18 @@ void ndpi_search_starcraft(struct ndpi_detection_module_struct *ndpi_struct, str
void ndpi_search_ubntac2(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_ubntac2(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_coap(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_coap(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mqtt (struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_mqtt (struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_someip (struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_rx(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_rx(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_git(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_git(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_drda(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); void ndpi_search_drda(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_bjnp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_smpp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_tinc(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_fix(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_csgo(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
/* --- INIT FUNCTIONS --- */ /* --- INIT FUNCTIONS --- */
void init_diameter_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_afp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_afp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_aimini_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_aimini_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_applejuice_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_applejuice_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_armagetron_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_armagetron_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ayiya_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_ayiya_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_amqp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_battlefield_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_battlefield_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_bgp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_bgp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_bittorrent_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_bittorrent_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_lisp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_teredo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_teredo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ciscovpn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_ciscovpn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_citrix_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_citrix_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -244,6 +235,7 @@ void init_http_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int
void init_http_activesync_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_http_activesync_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_iax_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_iax_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_icecast_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_icecast_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_imesh_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ipp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_ipp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_irc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_irc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_jabber_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_jabber_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -257,12 +249,13 @@ void init_mail_pop_dissector(struct ndpi_detection_module_struct *ndpi_struct, u
void init_mail_smtp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_mail_smtp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_maplestory_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_maplestory_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mdns_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_mdns_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_meebo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_megaco_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_megaco_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mgpc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_mgpc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mms_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_mms_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_msn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_msn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mpegts_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_mpegts_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mssql_tds_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_mssql_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mysql_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_mysql_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_netbios_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_netbios_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_netflow_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_netflow_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -312,6 +305,7 @@ void init_steam_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_in
void init_stun_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_stun_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_syslog_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_syslog_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ssdp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_ssdp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_tds_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_teamspeak_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_teamspeak_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_teamviewer_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_teamviewer_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_telegram_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_telegram_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -321,6 +315,7 @@ void init_thunder_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_
void init_tor_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_tor_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_tvants_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_tvants_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_tvuplayer_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_tvuplayer_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_twitter_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_usenet_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_usenet_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_veohtv_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_veohtv_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_vhua_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_vhua_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -340,18 +335,7 @@ void init_stracraft_dissector(struct ndpi_detection_module_struct *ndpi_struct,
void init_ubntac2_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_ubntac2_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_coap_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_coap_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mqtt_dissector (struct ndpi_detection_module_struct *ndpi_struct,u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_mqtt_dissector (struct ndpi_detection_module_struct *ndpi_struct,u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_someip_dissector (struct ndpi_detection_module_struct *ndpi_struct,u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_rx_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_rx_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_git_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_git_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_hangout_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_drda_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_drda_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_bjnp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_smpp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_tinc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_fix_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_nintendo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_csgo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_checkmk_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_apple_push_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_whatsapp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
#endif /* __NDPI_PROTOCOLS_H__ */ #endif /* __NDPI_PROTOCOLS_H__ */
+57 -186
View File
@@ -29,16 +29,18 @@
#define BT_ANNOUNCE #define BT_ANNOUNCE
#define SNAP_EXT #define SNAP_EXT
/* NDPI_LOG_LEVEL */ /* NDPI_LOG_LEVEL */
typedef enum { typedef enum
{
NDPI_LOG_ERROR, NDPI_LOG_ERROR,
NDPI_LOG_TRACE, NDPI_LOG_TRACE,
NDPI_LOG_DEBUG, NDPI_LOG_DEBUG
NDPI_LOG_DEBUG_EXTRA
} ndpi_log_level_t; } ndpi_log_level_t;
/* NDPI_VISIT */ /* NDPI_VISIT */
typedef enum { typedef enum
{
ndpi_preorder, ndpi_preorder,
ndpi_postorder, ndpi_postorder,
ndpi_endorder, ndpi_endorder,
@@ -46,7 +48,8 @@ typedef enum {
} ndpi_VISIT; } ndpi_VISIT;
/* NDPI_NODE */ /* NDPI_NODE */
typedef struct node_t { typedef struct node_t
{
char *key; char *key;
struct node_t *left, *right; struct node_t *left, *right;
} ndpi_node; } ndpi_node;
@@ -55,7 +58,8 @@ typedef struct node_t {
typedef u_int32_t ndpi_ndpi_mask; typedef u_int32_t ndpi_ndpi_mask;
/* NDPI_PROTO_BITMASK_STRUCT */ /* NDPI_PROTO_BITMASK_STRUCT */
typedef struct ndpi_protocol_bitmask_struct { typedef struct ndpi_protocol_bitmask_struct
{
ndpi_ndpi_mask fds_bits[NDPI_NUM_FDS_BITS]; ndpi_ndpi_mask fds_bits[NDPI_NUM_FDS_BITS];
} ndpi_protocol_bitmask_struct_t; } ndpi_protocol_bitmask_struct_t;
@@ -134,12 +138,14 @@ struct ndpi_snap_extension
} PACK_OFF; } PACK_OFF;
PACK_ON PACK_ON
struct ndpi_llc_header_snap struct ndpi_llc_header
{ {
u_int8_t dsap; u_int8_t dsap;
u_int8_t ssap; u_int8_t ssap;
u_int8_t ctrl; u_int8_t ctrl;
#ifdef SNAP_EXT
struct ndpi_snap_extension snap; struct ndpi_snap_extension snap;
#endif
} PACK_OFF; } PACK_OFF;
/* ++++++++++ RADIO TAP header (for IEEE 802.11) +++++++++++++ */ /* ++++++++++ RADIO TAP header (for IEEE 802.11) +++++++++++++ */
@@ -164,7 +170,7 @@ struct ndpi_wifi_header
u_char trsm[6]; u_char trsm[6];
u_char dest[6]; u_char dest[6];
u_int16_t seq_ctrl; u_int16_t seq_ctrl;
/* u_int64_t ccmp - for data encryption only - check fc.flag */ /* u_int64_t ccmp - for data encription only - check fc.flag */
} PACK_OFF; } PACK_OFF;
/* +++++++++++++++++++++++ MPLS header +++++++++++++++++++++++ */ /* +++++++++++++++++++++++ MPLS header +++++++++++++++++++++++ */
@@ -172,15 +178,7 @@ struct ndpi_wifi_header
PACK_ON PACK_ON
struct ndpi_mpls_header struct ndpi_mpls_header
{ {
/* Before using this strcut to parse an MPLS header, you will need to convert
* the 4-byte data to the correct endianess with ntohl(). */
#if defined(__LITTLE_ENDIAN__)
u_int32_t ttl:8, s:1, exp:3, label:20;
#elif defined(__BIG_ENDIAN__)
u_int32_t label:20, exp:3, s:1, ttl:8; u_int32_t label:20, exp:3, s:1, ttl:8;
#else
# error "Byte order must be defined"
#endif
} PACK_OFF; } PACK_OFF;
/* ++++++++++++++++++++++++ IP header ++++++++++++++++++++++++ */ /* ++++++++++++++++++++++++ IP header ++++++++++++++++++++++++ */
@@ -208,27 +206,34 @@ struct ndpi_iphdr {
/* +++++++++++++++++++++++ IPv6 header +++++++++++++++++++++++ */ /* +++++++++++++++++++++++ IPv6 header +++++++++++++++++++++++ */
/* rfc3542 */ /* rfc3542 */
struct ndpi_in6_addr { struct ndpi_in6_addr
union { {
union
{
u_int8_t u6_addr8[16]; u_int8_t u6_addr8[16];
u_int16_t u6_addr16[8]; u_int16_t u6_addr16[8];
u_int32_t u6_addr32[4]; u_int32_t u6_addr32[4];
} u6_addr; /* 128-bit IP6 address */ } u6_addr; /* 128-bit IP6 address */
}; };
struct ndpi_ip6_hdrctl { PACK_ON
struct ndpi_ipv6hdr
{
union
{
struct ndpi_ip6_hdrctl
{
u_int32_t ip6_un1_flow; u_int32_t ip6_un1_flow;
u_int16_t ip6_un1_plen; u_int16_t ip6_un1_plen;
u_int8_t ip6_un1_nxt; u_int8_t ip6_un1_nxt;
u_int8_t ip6_un1_hlim; u_int8_t ip6_un1_hlim;
}; } ip6_un1;
u_int8_t ip6_un2_vfc;
} ip6_ctlun;
/* PACK_ON */
struct ndpi_ipv6hdr {
struct ndpi_ip6_hdrctl ip6_hdr;
struct ndpi_in6_addr ip6_src; struct ndpi_in6_addr ip6_src;
struct ndpi_in6_addr ip6_dst; struct ndpi_in6_addr ip6_dst;
} /* PACK_OFF */; } PACK_OFF;
/* +++++++++++++++++++++++ TCP header +++++++++++++++++++++++ */ /* +++++++++++++++++++++++ TCP header +++++++++++++++++++++++ */
@@ -281,28 +286,6 @@ typedef union
#endif #endif
} ndpi_ip_addr_t; } ndpi_ip_addr_t;
/* +++++++++++++++++++++++ ICMP header +++++++++++++++++++++++ */
PACK_ON
struct ndpi_icmphdr {
u_int8_t type;/* message type */
u_int8_t code;/* type sub-code */
u_int16_t checksum;
union {
struct {
u_int16_t id;
u_int16_t sequence;
} echo; /* echo datagram */
u_int32_t gateway; /* gateway address */
struct {
u_int16_t _unused;
u_int16_t mtu;
} frag;/* path mtu discovery */
} un;
} PACK_OFF;
/* ************************************************************ */ /* ************************************************************ */
/* ******************* ********************* ****************** */ /* ******************* ********************* ****************** */
/* ************************************************************ */ /* ************************************************************ */
@@ -349,18 +332,6 @@ struct bt_announce { // 192 bytes
}; };
#endif #endif
#ifdef NDPI_PROTOCOL_TINC
#define TINC_CACHE_MAX_SIZE 10
PACK_ON struct tinc_cache_entry {
u_int32_t src_address;
u_int32_t dst_address;
u_int16_t dst_port;
} PACK_OFF;
#endif
typedef enum { typedef enum {
HTTP_METHOD_UNKNOWN = 0, HTTP_METHOD_UNKNOWN = 0,
HTTP_METHOD_OPTIONS, HTTP_METHOD_OPTIONS,
@@ -377,7 +348,7 @@ struct ndpi_id_struct {
/** /**
detected_protocol_bitmask: detected_protocol_bitmask:
access this bitmask to find out whether an id has used skype or not access this bitmask to find out whether an id has used skype or not
if a flag is set here, it will not be reset if a flag is set here, it will not be resetted
to compare this, use: to compare this, use:
**/ **/
NDPI_PROTOCOL_BITMASK detected_protocol_bitmask; NDPI_PROTOCOL_BITMASK detected_protocol_bitmask;
@@ -414,7 +385,7 @@ struct ndpi_id_struct {
#ifdef NDPI_PROTOCOL_ZATTOO #ifdef NDPI_PROTOCOL_ZATTOO
u_int32_t zattoo_ts; u_int32_t zattoo_ts;
#endif #endif
#ifdef NDPI_PROTOCOL_UNENCRYPTED_JABBER #ifdef NDPI_PROTOCOL_UNENCRYPED_JABBER
u_int32_t jabber_stun_or_ft_ts; u_int32_t jabber_stun_or_ft_ts;
#endif #endif
#ifdef NDPI_PROTOCOL_DIRECTCONNECT #ifdef NDPI_PROTOCOL_DIRECTCONNECT
@@ -433,7 +404,7 @@ struct ndpi_id_struct {
u_int16_t bt_port_t[NDPI_BT_PORTS]; u_int16_t bt_port_t[NDPI_BT_PORTS];
u_int16_t bt_port_u[NDPI_BT_PORTS]; u_int16_t bt_port_u[NDPI_BT_PORTS];
#endif #endif
#ifdef NDPI_PROTOCOL_UNENCRYPTED_JABBER #ifdef NDPI_PROTOCOL_UNENCRYPED_JABBER
#define JABBER_MAX_STUN_PORTS 6 #define JABBER_MAX_STUN_PORTS 6
u_int16_t jabber_voice_stun_port[JABBER_MAX_STUN_PORTS]; u_int16_t jabber_voice_stun_port[JABBER_MAX_STUN_PORTS];
u_int16_t jabber_file_transfer_port[2]; u_int16_t jabber_file_transfer_port[2];
@@ -454,7 +425,7 @@ struct ndpi_id_struct {
#ifdef NDPI_PROTOCOL_OSCAR #ifdef NDPI_PROTOCOL_OSCAR
u_int8_t oscar_ssl_session_id[33]; u_int8_t oscar_ssl_session_id[33];
#endif #endif
#ifdef NDPI_PROTOCOL_UNENCRYPTED_JABBER #ifdef NDPI_PROTOCOL_UNENCRYPED_JABBER
u_int8_t jabber_voice_stun_used_ports; u_int8_t jabber_voice_stun_used_ports;
#endif #endif
#ifdef NDPI_PROTOCOL_SIP #ifdef NDPI_PROTOCOL_SIP
@@ -583,7 +554,7 @@ struct ndpi_flow_tcp_struct {
u_int32_t mail_pop_stage:2; u_int32_t mail_pop_stage:2;
#endif #endif
#ifdef NDPI_PROTOCOL_MAIL_IMAP #ifdef NDPI_PROTOCOL_MAIL_IMAP
u_int32_t mail_imap_stage:3, mail_imap_starttls:2; u_int32_t mail_imap_stage:3;
#endif #endif
#ifdef NDPI_PROTOCOL_SKYPE #ifdef NDPI_PROTOCOL_SKYPE
u_int8_t skype_packet_id; u_int8_t skype_packet_id;
@@ -601,9 +572,6 @@ struct ndpi_flow_tcp_struct {
u_int8_t prev_zmq_pkt_len; u_int8_t prev_zmq_pkt_len;
u_char prev_zmq_pkt[10]; u_char prev_zmq_pkt[10];
#endif #endif
#ifdef NDPI_PROTOCOL_PPSTREAM
u_int32_t ppstream_stage:3;
#endif
} }
#ifndef WIN32 #ifndef WIN32
__attribute__ ((__packed__)) __attribute__ ((__packed__))
@@ -683,8 +651,8 @@ struct ndpi_packet_struct {
u_int32_t tick_timestamp; u_int32_t tick_timestamp;
u_int64_t tick_timestamp_l; u_int64_t tick_timestamp_l;
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_SIZE]; u_int16_t detected_protocol_stack[NDPI_PROTOCOL_HISTORY_SIZE];
u_int8_t detected_subprotocol_stack[NDPI_PROTOCOL_SIZE]; u_int8_t detected_subprotocol_stack[NDPI_PROTOCOL_HISTORY_SIZE];
#ifndef WIN32 #ifndef WIN32
@@ -693,7 +661,6 @@ struct ndpi_packet_struct {
u_int16_t protocol_stack_info; u_int16_t protocol_stack_info;
struct ndpi_int_one_line_struct line[NDPI_MAX_PARSE_LINES_PER_PACKET]; struct ndpi_int_one_line_struct line[NDPI_MAX_PARSE_LINES_PER_PACKET];
/* HTTP headers */
struct ndpi_int_one_line_struct host_line; struct ndpi_int_one_line_struct host_line;
struct ndpi_int_one_line_struct forwarded_line; struct ndpi_int_one_line_struct forwarded_line;
struct ndpi_int_one_line_struct referer_line; struct ndpi_int_one_line_struct referer_line;
@@ -709,8 +676,7 @@ struct ndpi_packet_struct {
struct ndpi_int_one_line_struct http_x_session_type; struct ndpi_int_one_line_struct http_x_session_type;
struct ndpi_int_one_line_struct server_line; struct ndpi_int_one_line_struct server_line;
struct ndpi_int_one_line_struct http_method; struct ndpi_int_one_line_struct http_method;
struct ndpi_int_one_line_struct http_response; /* the first "word" in this pointer is the response code in the packet (200, etc) */ struct ndpi_int_one_line_struct http_response;
u_int8_t http_num_headers; /* number of found (valid) header lines in HTTP request or response */
u_int16_t l3_packet_len; u_int16_t l3_packet_len;
u_int16_t l4_packet_len; u_int16_t l4_packet_len;
@@ -750,57 +716,19 @@ typedef struct {
} ndpi_port_range; } ndpi_port_range;
typedef enum { typedef enum {
NDPI_PROTOCOL_SAFE = 0, /* Surely doesn't provide risks for the network. (e.g., a news site) */ NDPI_PROTOCOL_SAFE = 0, /* Safe protocol with encryption */
NDPI_PROTOCOL_ACCEPTABLE, /* Probably doesn't provide risks, but could be malicious (e.g., Dropbox) */ NDPI_PROTOCOL_ACCEPTABLE, /* Ok but not encrypted */
NDPI_PROTOCOL_FUN, /* Pure fun protocol, which may be prohibited by the user policy (e.g., Netflix) */ NDPI_PROTOCOL_FUN, /* Pure fun protocol */
NDPI_PROTOCOL_UNSAFE, /* Probably provides risks, but could be a normal traffic. Unencrypted protocols with clear pass should be here (e.g., telnet) */ NDPI_PROTOCOL_UNSAFE, /* Protocol with a safe version existing what should be used instead */
NDPI_PROTOCOL_POTENTIALLY_DANGEROUS, /* Surely is dangerous (ex. Tor). Be prepared to troubles */ NDPI_PROTOCOL_POTENTIALLY_DANGEROUS, /* Be prepared to troubles */
NDPI_PROTOCOL_TRACKER_ADS, /* Trackers, Advertisements... */ NDPI_PROTOCOL_UNRATED /* No idea */
NDPI_PROTOCOL_UNRATED /* No idea, not implemented or impossible to classify */
} ndpi_protocol_breed_t; } ndpi_protocol_breed_t;
#define NUM_BREEDS (NDPI_PROTOCOL_UNRATED+1) #define NUM_BREEDS (NDPI_PROTOCOL_UNRATED+1)
/* Abstract categories to group the protocols. */
typedef enum {
NDPI_PROTOCOL_CATEGORY_UNSPECIFIED = 0, /* For general services and unknown protocols */
NDPI_PROTOCOL_CATEGORY_MEDIA, /* Multimedia and streaming */
NDPI_PROTOCOL_CATEGORY_VPN, /* Virtual Private Networks */
NDPI_PROTOCOL_CATEGORY_MAIL, /* Protocols to send/receive/sync emails */
NDPI_PROTOCOL_CATEGORY_DATA_TRANSFER, /* AFS/NFS and similar protocols */
NDPI_PROTOCOL_CATEGORY_WEB, /* Web/mobile protocols and services */
NDPI_PROTOCOL_CATEGORY_SOCIAL_NETWORK, /* Social networks */
NDPI_PROTOCOL_CATEGORY_DOWNLOAD_FT, /* Download, FTP, file transfer/sharing */
NDPI_PROTOCOL_CATEGORY_GAME, /* Online games */
NDPI_PROTOCOL_CATEGORY_CHAT, /* Instant messaging */
NDPI_PROTOCOL_CATEGORY_VOIP, /* Real-time communications and conferencing */
NDPI_PROTOCOL_CATEGORY_DATABASE, /* Protocols for database communication */
NDPI_PROTOCOL_CATEGORY_REMOTE_ACCESS, /* Remote access and control */
NDPI_PROTOCOL_CATEGORY_CLOUD, /* Online cloud services */
NDPI_PROTOCOL_CATEGORY_NETWORK, /* Network infrastructure protocols */
NDPI_PROTOCOL_CATEGORY_COLLABORATIVE, /* Software for collaborative development, including Webmail */
NDPI_PROTOCOL_CATEGORY_RPC, /* High level network communication protocols */
NDPI_PROTOCOL_CATEGORY_STREAMING, /* Streaming protocols */
NDPI_PROTOCOL_CATEGORY_SYSTEM_OS, /* System/Operating System level applications */
NDPI_PROTOCOL_CATEGORY_SW_UPDATE, /* Software update */
/* See #define NUM_CUSTOM_CATEGORIES */
NDPI_PROTOCOL_CATEGORY_CUSTOM_1, /* User custom category 1 */
NDPI_PROTOCOL_CATEGORY_CUSTOM_2, /* User custom category 2 */
NDPI_PROTOCOL_CATEGORY_CUSTOM_3, /* User custom category 3 */
NDPI_PROTOCOL_CATEGORY_CUSTOM_4, /* User custom category 4 */
NDPI_PROTOCOL_CATEGORY_CUSTOM_5, /* User custom category 5 */
NDPI_PROTOCOL_NUM_CATEGORIES /*
NOTE: Keep this as last member
Unused as value but useful to getting the number of elements
in this datastructure
*/
} ndpi_protocol_category_t;
/* ntop extensions */ /* ntop extensions */
typedef struct ndpi_proto_defaults { typedef struct ndpi_proto_defaults {
char *protoName; char *protoName;
ndpi_protocol_category_t protoCategory;
u_int16_t protoId, protoIdx; u_int16_t protoId, protoIdx;
u_int16_t master_tcp_protoId[2], master_udp_protoId[2]; /* The main protocols on which this sub-protocol sits on */ u_int16_t master_tcp_protoId[2], master_udp_protoId[2]; /* The main protocols on which this sub-protocol sits on */
ndpi_protocol_breed_t protoBreed; ndpi_protocol_breed_t protoBreed;
@@ -809,7 +737,6 @@ typedef struct ndpi_proto_defaults {
typedef struct ndpi_default_ports_tree_node { typedef struct ndpi_default_ports_tree_node {
ndpi_proto_defaults_t *proto; ndpi_proto_defaults_t *proto;
u_int8_t customUserProto;
u_int16_t default_port; u_int16_t default_port;
} ndpi_default_ports_tree_node_t; } ndpi_default_ports_tree_node_t;
@@ -819,15 +746,13 @@ typedef struct _ndpi_automa {
} ndpi_automa; } ndpi_automa;
typedef struct ndpi_proto { typedef struct ndpi_proto {
u_int16_t master_protocol /* e.g. HTTP */, app_protocol /* e.g. FaceBook */; u_int16_t master_protocol /* e.g. HTTP */, protocol /* e.g. FaceBook */;
} ndpi_protocol; } ndpi_protocol;
#define NDPI_PROTOCOL_NULL { NDPI_PROTOCOL_UNKNOWN , NDPI_PROTOCOL_UNKNOWN } #define NDPI_PROTOCOL_NULL { NDPI_PROTOCOL_UNKNOWN , NDPI_PROTOCOL_UNKNOWN }
#define NUM_CUSTOM_CATEGORIES 5
#define CUSTOM_CATEGORY_LABEL_LEN 32
struct ndpi_detection_module_struct { struct ndpi_detection_module_struct {
NDPI_PROTOCOL_BITMASK detection_bitmask; NDPI_PROTOCOL_BITMASK detection_bitmask;
NDPI_PROTOCOL_BITMASK generic_http_packet_bitmask; NDPI_PROTOCOL_BITMASK generic_http_packet_bitmask;
@@ -837,7 +762,7 @@ struct ndpi_detection_module_struct {
#ifdef NDPI_ENABLE_DEBUG_MESSAGES #ifdef NDPI_ENABLE_DEBUG_MESSAGES
void *user_data; void *user_data;
#endif #endif
char custom_category_labels[NUM_CUSTOM_CATEGORIES][CUSTOM_CATEGORY_LABEL_LEN];
/* callback function buffer */ /* callback function buffer */
struct ndpi_call_function_struct callback_buffer[NDPI_MAX_SUPPORTED_PROTOCOLS + 1]; struct ndpi_call_function_struct callback_buffer[NDPI_MAX_SUPPORTED_PROTOCOLS + 1];
u_int32_t callback_buffer_size; u_int32_t callback_buffer_size;
@@ -856,15 +781,12 @@ struct ndpi_detection_module_struct {
ndpi_default_ports_tree_node_t *tcpRoot, *udpRoot; ndpi_default_ports_tree_node_t *tcpRoot, *udpRoot;
ndpi_log_level_t ndpi_log_level; /* default error */
#ifdef NDPI_ENABLE_DEBUG_MESSAGES #ifdef NDPI_ENABLE_DEBUG_MESSAGES
/* debug callback, only set when debug is used */ /* debug callback, only set when debug is used */
ndpi_debug_function_ptr ndpi_debug_printf; ndpi_debug_function_ptr ndpi_debug_printf;
const char *ndpi_debug_print_file; const char *ndpi_debug_print_file;
const char *ndpi_debug_print_function; const char *ndpi_debug_print_function;
u_int32_t ndpi_debug_print_line; u_int32_t ndpi_debug_print_line;
NDPI_PROTOCOL_BITMASK debug_bitmask;
#endif #endif
/* misc parameters */ /* misc parameters */
@@ -923,21 +845,16 @@ struct ndpi_detection_module_struct {
struct bt_announce *bt_ann; struct bt_announce *bt_ann;
int bt_ann_len; int bt_ann_len;
#endif #endif
#endif
#ifdef NDPI_PROTOCOL_TINC
struct cache *tinc_cache;
#endif #endif
ndpi_proto_defaults_t proto_defaults[NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS]; ndpi_proto_defaults_t proto_defaults[NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS];
u_int8_t http_dont_dissect_response:1, dns_dissect_response:1, u_int8_t http_dont_dissect_response:1, dns_dissect_response:1,
direction_detect_disable:1; /* disable internal detection of packet direction */ direction_detect_disable:1; /* disable internal detection of packet direction */
void *hyperscan; /* Intel Hyperscan */
}; };
struct ndpi_flow_struct { struct ndpi_flow_struct {
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_SIZE]; u_int16_t detected_protocol_stack[NDPI_PROTOCOL_HISTORY_SIZE];
#ifndef WIN32 #ifndef WIN32
__attribute__ ((__packed__)) __attribute__ ((__packed__))
#endif #endif
@@ -946,7 +863,7 @@ struct ndpi_flow_struct {
/* init parameter, internal used to set up timestamp,... */ /* init parameter, internal used to set up timestamp,... */
u_int16_t guessed_protocol_id, guessed_host_protocol_id; u_int16_t guessed_protocol_id, guessed_host_protocol_id;
u_int8_t protocol_id_already_guessed:1, host_already_guessed:1, init_finished:1, setup_packet_direction:1, packet_direction:1, check_extra_packets:1; u_int8_t protocol_id_already_guessed:1, host_already_guessed:1, init_finished:1, setup_packet_direction:1, packet_direction:1;
/* /*
if ndpi_struct->direction_detect_disable == 1 if ndpi_struct->direction_detect_disable == 1
@@ -954,10 +871,6 @@ struct ndpi_flow_struct {
*/ */
u_int32_t next_tcp_seq_nr[2]; u_int32_t next_tcp_seq_nr[2];
u_int8_t max_extra_packets_to_check;
u_int8_t num_extra_packets_checked;
int (*extra_packets_func) (struct ndpi_detection_module_struct *, struct ndpi_flow_struct *flow);
/* /*
the tcp / udp / other l4 value union the tcp / udp / other l4 value union
used to reduce the number of bytes for tcp or udp protocol states used to reduce the number of bytes for tcp or udp protocol states
@@ -974,7 +887,13 @@ struct ndpi_flow_struct {
*/ */
struct ndpi_id_struct *server_id; struct ndpi_id_struct *server_id;
/* HTTP host or DNS query */ /* HTTP host or DNS query */
u_char host_server_name[256]; u_char host_server_name[192];
/* Via HTTP User-Agent */
u_char detected_os[32];
/* Via HTTP X-Forwarded-For */
u_char nat_ip[24];
/* Bittorrent hash */
u_char bittorent_hash[20];
/* /*
This structure below will not not stay inside the protos This structure below will not not stay inside the protos
@@ -986,12 +905,10 @@ struct ndpi_flow_struct {
struct { struct {
ndpi_http_method method; ndpi_http_method method;
char *url, *content_type; char *url, *content_type;
u_int8_t num_request_headers, num_response_headers;
u_int8_t request_version; /* 0=1.0 and 1=1.1. Create an enum for this? */
u_char response_status_code[5]; /* 200, 404, etc. */
} http; } http;
union { union {
/* the only fields useful for nDPI and ntopng */ /* the only fields useful for nDPI and ntopng */
struct { struct {
u_int8_t num_queries, num_answers, reply_code; u_int8_t num_queries, num_answers, reply_code;
@@ -1006,35 +923,6 @@ struct ndpi_flow_struct {
struct { struct {
char client_certificate[48], server_certificate[48]; char client_certificate[48], server_certificate[48];
} ssl; } ssl;
struct {
char client_signature[48], server_signature[48];
} ssh;
struct {
char answer[96];
} mdns;
struct {
char version[96];
} ubntac2;
struct {
/* Via HTTP User-Agent */
u_char detected_os[32];
/* Via HTTP X-Forwarded-For */
u_char nat_ip[24];
} http;
struct {
/* Bittorrent hash */
u_char hash[20];
} bittorrent;
struct {
char fingerprint[48];
char class_ident[48];
} dhcp;
} protos; } protos;
/*** ALL protocol specific 64 bit variables here ***/ /*** ALL protocol specific 64 bit variables here ***/
@@ -1117,22 +1005,6 @@ struct ndpi_flow_struct {
#ifdef NDPI_PROTOCOL_STARCRAFT #ifdef NDPI_PROTOCOL_STARCRAFT
u_int32_t starcraft_udp_stage : 3; // 0-7 u_int32_t starcraft_udp_stage : 3; // 0-7
#endif #endif
#ifdef NDPI_PROTOCOL_OPENVPN
u_int8_t ovpn_session_id[8];
u_int8_t ovpn_counter;
#endif
#ifdef NDPI_PROTOCOL_TINC
u_int8_t tinc_state;
struct tinc_cache_entry tinc_cache_entry;
#endif
#ifdef NDPI_PROTOCOL_CSGO
u_int8_t csgo_strid[18],csgo_state,csgo_s2;
u_int32_t csgo_id2;
#endif
#if defined(NDPI_PROTOCOL_1KXUN) || defined(NDPI_PROTOCOL_IQIYI)
u_int16_t kxun_counter, iqiyi_counter;
#endif
/* internal structures to save functions calls */ /* internal structures to save functions calls */
struct ndpi_packet_struct packet; struct ndpi_packet_struct packet;
@@ -1142,9 +1014,8 @@ struct ndpi_flow_struct {
}; };
typedef struct { typedef struct {
char *string_to_match, *string2_to_match, *pattern_to_match, *proto_name; char *string_to_match, *proto_name;
int protocol_id; int protocol_id;
ndpi_protocol_category_t proto_category;
ndpi_protocol_breed_t protocol_breed; ndpi_protocol_breed_t protocol_breed;
} ndpi_protocol_match; } ndpi_protocol_match;
+1 -13
View File
@@ -24,15 +24,7 @@
#ifndef __NDPI_WIN32_H__ #ifndef __NDPI_WIN32_H__
#define __NDPI_WIN32_H__ #define __NDPI_WIN32_H__
// fix a MinGW build issue "error: multiple storage classes in declaration specifiers" due to MinGW
// defining extern for __forceinline types
#if (defined(__MINGW32__) || defined(__MINGW64__)) && defined(__GNUC__)
#define MINGW_GCC
#define __mingw_forceinline __inline__ __attribute__((__always_inline__,__gnu_inline__))
#endif
#include <winsock2.h> #include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#include <process.h> #include <process.h>
#include <io.h> #include <io.h>
@@ -46,9 +38,7 @@
#define _WS2TCPIP_H_ /* Avoid compilation problems */ #define _WS2TCPIP_H_ /* Avoid compilation problems */
#define IPVERSION 4 /* on *nix it is defined in netinet/ip.h */ extern char* strsep(char **sp, const char *sep);
extern char* strsep(char **sp, char *sep);
typedef unsigned char u_char; typedef unsigned char u_char;
typedef unsigned short u_short; typedef unsigned short u_short;
@@ -71,8 +61,6 @@ typedef unsigned __int64 u_int64_t;
#define gmtime_r(a, b) memcpy(b, gmtime(a), sizeof(struct tm)) #define gmtime_r(a, b) memcpy(b, gmtime(a), sizeof(struct tm))
#define in_addr_t unsigned long
extern unsigned long waitForNextEvent(unsigned long ulDelay /* ms */); extern unsigned long waitForNextEvent(unsigned long ulDelay /* ms */);
#define sleep(a /* sec */) waitForNextEvent(1000*a /* ms */) #define sleep(a /* sec */) waitForNextEvent(1000*a /* ms */)
+10 -26
View File
@@ -1,7 +1,7 @@
lib_LTLIBRARIES = libndpi.la lib_LTLIBRARIES = libndpi.la
CFLAGS += -fPIC -DPIC # --coverage CFLAGS += -fPIC -DPIC
libndpi_la_CPPFLAGS = -I$(top_srcdir)/src/include/ -I$(top_srcdir)/src/lib/third_party/include/ @HS_INC@ libndpi_la_CPPFLAGS = -I$(top_srcdir)/src/include/ -I$(top_srcdir)/src/lib/third_party/include/
libndpi_la_LDFLAGS = -version-info 1:0:0 -export-symbols $(top_srcdir)/libndpi.sym libndpi_la_LDFLAGS = -version-info 1:0:0 -export-symbols $(top_srcdir)/libndpi.sym
libndpi_la_includedir = $(includedir)/libndpi-@VERSION@/libndpi libndpi_la_includedir = $(includedir)/libndpi-@VERSION@/libndpi
@@ -10,37 +10,29 @@ libndpi_la_include_HEADERS = ../include/ndpi_api.h \
../include/ndpi_define.h \ ../include/ndpi_define.h \
../include/ndpi_main.h \ ../include/ndpi_main.h \
../include/ndpi_includes.h \ ../include/ndpi_includes.h \
../include/ndpi_config.h \
../include/ndpi_protocol_ids.h \ ../include/ndpi_protocol_ids.h \
../include/ndpi_protocols.h \ ../include/ndpi_protocols.h \
../include/ndpi_typedefs.h \ ../include/ndpi_typedefs.h
third_party/include/libcache.h
libndpi_la_SOURCES = ndpi_content_match.c.inc \ libndpi_la_SOURCES = ndpi_content_match.c.inc \
ndpi_main.c \ ndpi_main.c \
protocols/afp.c \ protocols/afp.c \
protocols/aimini.c \ protocols/aimini.c \
protocols/applejuice.c \ protocols/applejuice.c \
protocols/apple_push.c \
protocols/armagetron.c \ protocols/armagetron.c \
protocols/ayiya.c \ protocols/ayiya.c \
protocols/amqp.c \
protocols/battlefield.c \ protocols/battlefield.c \
protocols/bgp.c \ protocols/bgp.c \
protocols/bittorrent.c \ protocols/bittorrent.c \
protocols/bjnp.c \
protocols/checkmk.c \
protocols/ciscovpn.c \ protocols/ciscovpn.c \
protocols/citrix.c \ protocols/citrix.c \
protocols/coap.c \ protocols/coap.c \
protocols/collectd.c \ protocols/collectd.c \
protocols/corba.c \ protocols/corba.c \
protocols/crossfire.c \ protocols/crossfire.c \
protocols/csgo.c \
protocols/dcerpc.c \ protocols/dcerpc.c \
protocols/dhcp.c \ protocols/dhcp.c \
protocols/dhcpv6.c \ protocols/dhcpv6.c \
protocols/diameter.c \
protocols/directconnect.c \ protocols/directconnect.c \
protocols/directdownloadlink.c \ protocols/directdownloadlink.c \
protocols/dns.c \ protocols/dns.c \
@@ -51,7 +43,6 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
protocols/edonkey.c \ protocols/edonkey.c \
protocols/fasttrack.c \ protocols/fasttrack.c \
protocols/fiesta.c \ protocols/fiesta.c \
protocols/fix.c \
protocols/filetopia.c \ protocols/filetopia.c \
protocols/florensia.c \ protocols/florensia.c \
protocols/ftp_control.c \ protocols/ftp_control.c \
@@ -60,7 +51,6 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
protocols/gnutella.c \ protocols/gnutella.c \
protocols/gtp.c \ protocols/gtp.c \
protocols/guildwars.c \ protocols/guildwars.c \
protocols/hangout.c \
protocols/h323.c \ protocols/h323.c \
protocols/halflife2_and_mods.c \ protocols/halflife2_and_mods.c \
protocols/hep.c \ protocols/hep.c \
@@ -68,6 +58,7 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
protocols/http.c \ protocols/http.c \
protocols/iax.c \ protocols/iax.c \
protocols/icecast.c \ protocols/icecast.c \
protocols/imesh.c \
protocols/ipp.c \ protocols/ipp.c \
protocols/irc.c \ protocols/irc.c \
protocols/jabber.c \ protocols/jabber.c \
@@ -76,23 +67,22 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
protocols/kontiki.c \ protocols/kontiki.c \
protocols/ldap.c \ protocols/ldap.c \
protocols/lotus_notes.c \ protocols/lotus_notes.c \
protocols/lisp.c \
protocols/mail_imap.c \ protocols/mail_imap.c \
protocols/mail_pop.c \ protocols/mail_pop.c \
protocols/mail_smtp.c \ protocols/mail_smtp.c \
protocols/maplestory.c \ protocols/maplestory.c \
protocols/mdns.c \ protocols/mdns.c \
protocols/meebo.c \
protocols/megaco.c \ protocols/megaco.c \
protocols/mgcp.c \ protocols/mgcp.c \
protocols/mms.c \ protocols/mms.c \
protocols/mpegts.c \ protocols/mpegts.c \
protocols/mqtt.c \ protocols/mqtt.c \
protocols/msn.c \ protocols/msn.c \
protocols/mssql_tds.c \ protocols/mssql.c \
protocols/mysql.c \ protocols/mysql.c \
protocols/netbios.c \ protocols/netbios.c \
protocols/netflow.c \ protocols/netflow.c \
protocols/nintendo.c \
protocols/nfs.c \ protocols/nfs.c \
protocols/noe.c \ protocols/noe.c \
protocols/non_tcp_udp.c \ protocols/non_tcp_udp.c \
@@ -108,6 +98,7 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
protocols/ppstream.c \ protocols/ppstream.c \
protocols/pptp.c \ protocols/pptp.c \
protocols/qq.c \ protocols/qq.c \
protocols/quake.c \
protocols/quic.c \ protocols/quic.c \
protocols/radius.c \ protocols/radius.c \
protocols/rdp.c \ protocols/rdp.c \
@@ -139,6 +130,7 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
protocols/stun.c \ protocols/stun.c \
protocols/syslog.c \ protocols/syslog.c \
protocols/tcp_udp.c \ protocols/tcp_udp.c \
protocols/tds.c \
protocols/teamspeak.c \ protocols/teamspeak.c \
protocols/teamviewer.c \ protocols/teamviewer.c \
protocols/telegram.c \ protocols/telegram.c \
@@ -149,6 +141,7 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
protocols/teredo.c \ protocols/teredo.c \
protocols/tvants.c \ protocols/tvants.c \
protocols/tvuplayer.c \ protocols/tvuplayer.c \
protocols/twitter.c \
protocols/ubntac2.c \ protocols/ubntac2.c \
protocols/usenet.c \ protocols/usenet.c \
protocols/viber.c \ protocols/viber.c \
@@ -164,19 +157,10 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
protocols/yahoo.c \ protocols/yahoo.c \
protocols/zattoo.c \ protocols/zattoo.c \
protocols/zeromq.c \ protocols/zeromq.c \
protocols/smpp.c \
protocols/tinc.c \
protocols/someip.c \
protocols/whatsapp.c \
third_party/include/actypes.h \ third_party/include/actypes.h \
third_party/include/ahocorasick.h \ third_party/include/ahocorasick.h \
third_party/include/ndpi_patricia.h \
third_party/include/node.h \ third_party/include/node.h \
third_party/include/sort.h \ third_party/include/sort.h \
third_party/include/libcache.h \
third_party/src/ahocorasick.c \ third_party/src/ahocorasick.c \
third_party/src/node.c \ third_party/src/node.c \
third_party/src/sort.c \ third_party/src/sort.c
third_party/src/libcache.c
EXTRA_DIST = third_party/src/ndpi_patricia.c
-22
View File
@@ -1,22 +0,0 @@
#
# Simple non-autotools dependent makefile
#
# ./autogen.sh
# cd src/lib
# make -f Makefile.simple
#
CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include
RANLIB=ranlib
OBJECTS = $(patsubst protocols/%.c, protocols/%.o, $(wildcard protocols/*.c)) $(patsubst third_party/src/%.c, third_party/src/%.o, $(wildcard third_party/src/*.c)) ndpi_main.o
HEADERS = $(wildcard ../include/*.h)
libndpi.a: $(OBJECTS)
ar rc $@ $(OBJECTS)
$(RANLIB) $@
%.o: %.c $(HEADERS) Makefile
$(CC) $(CFLAGS) -c $< -o $@
clean:
/bin/rm -f libndpi.a $(OBJECTS)
File diff suppressed because it is too large Load Diff
+650 -1260
View File
File diff suppressed because it is too large Load Diff
+17 -34
View File
@@ -2,7 +2,7 @@
* afp.c * afp.c
* *
* Copyright (C) 2009-2011 by ipoque GmbH * Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-16 - ntop.org * Copyright (C) 2011-15 - ntop.org
* *
* This file is part of nDPI, an open source deep packet inspection * This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH * library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -23,20 +23,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_AFP #ifdef NDPI_PROTOCOL_AFP
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_AFP
#include "ndpi_api.h"
struct afpHeader {
u_int8_t flags, command;
u_int16_t requestId;
u_int32_t dataOffset, length, reserved;
};
static void ndpi_int_afp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_int_afp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AFP, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AFP, NDPI_PROTOCOL_UNKNOWN);
@@ -46,20 +36,8 @@ static void ndpi_int_afp_add_connection(struct ndpi_detection_module_struct *ndp
void ndpi_search_afp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) void ndpi_search_afp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src = flow->src;
NDPI_LOG_DBG(ndpi_struct, "search AFP\n"); // struct ndpi_id_struct *dst = flow->dst;
if (packet->payload_packet_len >= sizeof(struct afpHeader)) {
struct afpHeader *h = (struct afpHeader*)packet->payload;
if(packet->payload_packet_len > 128) {
/*
When we transfer a large data chunk, unless we have observed
the initial connection, we need to discard these packets
as they are not an indication that this flow is not AFP
*/
return;
}
/* /*
* this will detect the OpenSession command of the Data Stream Interface (DSI) protocol * this will detect the OpenSession command of the Data Stream Interface (DSI) protocol
@@ -70,22 +48,27 @@ void ndpi_search_afp(struct ndpi_detection_module_struct *ndpi_struct, struct nd
get_u_int32_t(packet->payload, 8) == htonl(packet->payload_packet_len - 16) && get_u_int32_t(packet->payload, 8) == htonl(packet->payload_packet_len - 16) &&
get_u_int32_t(packet->payload, 12) == 0 && get_u_int16_t(packet->payload, 16) == htons(0x0104)) { get_u_int32_t(packet->payload, 12) == 0 && get_u_int16_t(packet->payload, 16) == htons(0x0104)) {
NDPI_LOG_INFO(ndpi_struct, "found AFP: DSI OpenSession\n"); NDPI_LOG(NDPI_PROTOCOL_AFP, ndpi_struct, NDPI_LOG_DEBUG, "AFP: DSI OpenSession detected.\n");
ndpi_int_afp_add_connection(ndpi_struct, flow); ndpi_int_afp_add_connection(ndpi_struct, flow);
return; return;
} }
if((h->flags <= 1) /*
&& ((h->command >= 1) && (h->command <= 8)) * detection of GetStatus command of DSI protocl
&& (h->reserved == 0) */
&& (packet->payload_packet_len >= (sizeof(struct afpHeader)+ntohl(h->length)))) { if (packet->payload_packet_len >= 18 && get_u_int16_t(packet->payload, 0) == htons(0x0003) &&
NDPI_LOG_INFO(ndpi_struct, "found AFP: DSI\n"); get_u_int16_t(packet->payload, 2) == htons(0x0001) && get_u_int32_t(packet->payload, 4) == 0 &&
get_u_int32_t(packet->payload, 8) == htonl(packet->payload_packet_len - 16) &&
get_u_int32_t(packet->payload, 12) == 0 && get_u_int16_t(packet->payload, 16) == htons(0x0f00)) {
NDPI_LOG(NDPI_PROTOCOL_AFP, ndpi_struct, NDPI_LOG_DEBUG, "AFP: DSI GetStatus detected.\n");
ndpi_int_afp_add_connection(ndpi_struct, flow); ndpi_int_afp_add_connection(ndpi_struct, flow);
return; return;
} }
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
NDPI_LOG(NDPI_PROTOCOL_AFP, ndpi_struct, NDPI_LOG_DEBUG, "AFP excluded.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_AFP);
} }
+37 -37
View File
@@ -23,14 +23,10 @@
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_AIMINI #ifdef NDPI_PROTOCOL_AIMINI
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_AIMINI
#include "ndpi_api.h"
static void ndpi_int_aimini_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow/* , */ static void ndpi_int_aimini_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow/* , */
/* ndpi_protocol_type_t protocol_type */) /* ndpi_protocol_type_t protocol_type */)
@@ -54,40 +50,43 @@ static u_int8_t is_special_aimini_host(struct ndpi_int_one_line_struct host_line
void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG_DBG(ndpi_struct, "search aimini\n");
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "search aimini.\n");
if (packet->udp != NULL) { if (packet->udp != NULL) {
if (flow->l4.udp.aimini_stage == 0) { if (flow->l4.udp.aimini_stage == 0) {
if (packet->payload_packet_len == 64 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010b) { if (packet->payload_packet_len == 64 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010b) {
flow->l4.udp.aimini_stage = 1; flow->l4.udp.aimini_stage = 1;
NDPI_LOG_DBG2(ndpi_struct, "stage = 1\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 1.\n");
return; return;
} }
if (packet->payload_packet_len == 136 if (packet->payload_packet_len == 136
&& (ntohs(get_u_int16_t(packet->payload, 0)) == 0x01c9 || ntohs(get_u_int16_t(packet->payload, 0)) == 0x0165)) { && (ntohs(get_u_int16_t(packet->payload, 0)) == 0x01c9 || ntohs(get_u_int16_t(packet->payload, 0)) == 0x0165)) {
flow->l4.udp.aimini_stage = 4; flow->l4.udp.aimini_stage = 4;
NDPI_LOG_DBG2(ndpi_struct, "stage = 4\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 4.\n");
return; return;
} }
if (packet->payload_packet_len == 88 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101) { if (packet->payload_packet_len == 88 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101) {
flow->l4.udp.aimini_stage = 7; flow->l4.udp.aimini_stage = 7;
NDPI_LOG_DBG2(ndpi_struct, "stage = 7\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 7.\n");
return; return;
} }
if (packet->payload_packet_len == 104 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0102) { if (packet->payload_packet_len == 104 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0102) {
flow->l4.udp.aimini_stage = 10; flow->l4.udp.aimini_stage = 10;
NDPI_LOG_DBG2(ndpi_struct, "stage = 10\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 10.\n");
return; return;
} }
if (packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca) { if (packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca) {
flow->l4.udp.aimini_stage = 13; flow->l4.udp.aimini_stage = 13;
NDPI_LOG_DBG2(ndpi_struct, "stage = 13\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 13.\n");
return; return;
} }
if (packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c) { if (packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c) {
flow->l4.udp.aimini_stage = 16; flow->l4.udp.aimini_stage = 16;
NDPI_LOG_DBG2(ndpi_struct, "stage = 16\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 16.\n");
return; return;
} }
} }
@@ -97,7 +96,7 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
if (flow->l4.udp.aimini_stage == 1 && packet->payload_packet_len > 100 if (flow->l4.udp.aimini_stage == 1 && packet->payload_packet_len > 100
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x0115) { && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0115) {
flow->l4.udp.aimini_stage = 2; flow->l4.udp.aimini_stage = 2;
NDPI_LOG_DBG2(ndpi_struct, "stage = 2\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 2.\n");
return; return;
} }
if (flow->l4.udp.aimini_stage == 2 && if (flow->l4.udp.aimini_stage == 2 &&
@@ -105,14 +104,14 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
(packet->payload_packet_len == 64 && get_u_int16_t(packet->payload, 0) == htons(0x010b)) || (packet->payload_packet_len == 64 && get_u_int16_t(packet->payload, 0) == htons(0x010b)) ||
(packet->payload_packet_len == 88 && get_u_int16_t(packet->payload, 0) == ntohs(0x0115)))) { (packet->payload_packet_len == 88 && get_u_int16_t(packet->payload, 0) == ntohs(0x0115)))) {
flow->l4.udp.aimini_stage = 3; flow->l4.udp.aimini_stage = 3;
NDPI_LOG_DBG2(ndpi_struct, "stage = 3\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 3.\n");
return; return;
} }
if (flow->l4.udp.aimini_stage == 3 if (flow->l4.udp.aimini_stage == 3
&& ((packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c) && ((packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c)
|| (packet->payload_packet_len == 64 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010b) || (packet->payload_packet_len == 64 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010b)
|| (packet->payload_packet_len > 100 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0115))) { || (packet->payload_packet_len > 100 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0115))) {
NDPI_LOG_INFO(ndpi_struct, "found aimini (64, 0x010b), (>300, 0x0115), " NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "found aimini (64, 0x010b), (>300, 0x0115), "
"(16, 0x010c || 64, 0x010b), (16, 0x010c || 64, 0x010b || >100, 0x0115).\n"); "(16, 0x010c || 64, 0x010b), (16, 0x010c || 64, 0x010b || >100, 0x0115).\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow); ndpi_int_aimini_add_connection(ndpi_struct, flow);
return; return;
@@ -123,14 +122,14 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
if (flow->l4.udp.aimini_stage == 4 && packet->payload_packet_len == 136 if (flow->l4.udp.aimini_stage == 4 && packet->payload_packet_len == 136
&& (ntohs(get_u_int16_t(packet->payload, 0)) == 0x01c9 || ntohs(get_u_int16_t(packet->payload, 0)) == 0x0165)) { && (ntohs(get_u_int16_t(packet->payload, 0)) == 0x01c9 || ntohs(get_u_int16_t(packet->payload, 0)) == 0x0165)) {
flow->l4.udp.aimini_stage = 5; flow->l4.udp.aimini_stage = 5;
NDPI_LOG_DBG2(ndpi_struct, "stage = 5\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 5.\n");
return; return;
} }
if (flow->l4.udp.aimini_stage == 5 && (packet->payload_packet_len == 136 if (flow->l4.udp.aimini_stage == 5 && (packet->payload_packet_len == 136
&& (ntohs(get_u_int16_t(packet->payload, 0)) == 0x01c9 && (ntohs(get_u_int16_t(packet->payload, 0)) == 0x01c9
|| ntohs(get_u_int16_t(packet->payload, 0)) == 0x0165))) { || ntohs(get_u_int16_t(packet->payload, 0)) == 0x0165))) {
flow->l4.udp.aimini_stage = 6; flow->l4.udp.aimini_stage = 6;
NDPI_LOG_DBG2(ndpi_struct, "stage = 6\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 6.\n");
return; return;
} }
if (flow->l4.udp.aimini_stage == 6 && ((packet->payload_packet_len == 136 if (flow->l4.udp.aimini_stage == 6 && ((packet->payload_packet_len == 136
@@ -138,7 +137,7 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
|| ntohs(get_u_int16_t(packet->payload, 0)) == 0x01c9)) || ntohs(get_u_int16_t(packet->payload, 0)) == 0x01c9))
|| (packet->payload_packet_len == 32 || (packet->payload_packet_len == 32
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca))) { && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca))) {
NDPI_LOG_INFO(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"found aimini (136, 0x01c9), (136, 0x01c9)," "(136, 0x01c9),(136, 0x01c9 || 32, 0x01ca).\n"); "found aimini (136, 0x01c9), (136, 0x01c9)," "(136, 0x01c9),(136, 0x01c9 || 32, 0x01ca).\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow); ndpi_int_aimini_add_connection(ndpi_struct, flow);
return; return;
@@ -149,18 +148,18 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
if (flow->l4.udp.aimini_stage == 7 && packet->payload_packet_len == 88 if (flow->l4.udp.aimini_stage == 7 && packet->payload_packet_len == 88
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101) { && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101) {
flow->l4.udp.aimini_stage = 8; flow->l4.udp.aimini_stage = 8;
NDPI_LOG_DBG2(ndpi_struct, "stage = 8\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 8.\n");
return; return;
} }
if (flow->l4.udp.aimini_stage == 8 if (flow->l4.udp.aimini_stage == 8
&& (packet->payload_packet_len == 88 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101)) { && (packet->payload_packet_len == 88 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101)) {
flow->l4.udp.aimini_stage = 9; flow->l4.udp.aimini_stage = 9;
NDPI_LOG_DBG2(ndpi_struct, "stage = 9\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 9.\n");
return; return;
} }
if (flow->l4.udp.aimini_stage == 9 if (flow->l4.udp.aimini_stage == 9
&& (packet->payload_packet_len == 88 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101)) { && (packet->payload_packet_len == 88 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101)) {
NDPI_LOG_INFO(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"found aimini (88, 0x0101), (88, 0x0101)," "(88, 0x0101),(88, 0x0101).\n"); "found aimini (88, 0x0101), (88, 0x0101)," "(88, 0x0101),(88, 0x0101).\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow); ndpi_int_aimini_add_connection(ndpi_struct, flow);
return; return;
@@ -171,19 +170,19 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
if (flow->l4.udp.aimini_stage == 10 && packet->payload_packet_len == 104 if (flow->l4.udp.aimini_stage == 10 && packet->payload_packet_len == 104
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x0102) { && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0102) {
flow->l4.udp.aimini_stage = 11; flow->l4.udp.aimini_stage = 11;
NDPI_LOG_DBG2(ndpi_struct, "stage = 11\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 11.\n");
return; return;
} }
if (flow->l4.udp.aimini_stage == 11 if (flow->l4.udp.aimini_stage == 11
&& (packet->payload_packet_len == 104 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0102)) { && (packet->payload_packet_len == 104 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0102)) {
flow->l4.udp.aimini_stage = 12; flow->l4.udp.aimini_stage = 12;
NDPI_LOG_DBG2(ndpi_struct, "stage = 12\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 12.\n");
return; return;
} }
if (flow->l4.udp.aimini_stage == 12 if (flow->l4.udp.aimini_stage == 12
&& ((packet->payload_packet_len == 104 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0102) && ((packet->payload_packet_len == 104 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0102)
|| (packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca))) { || (packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca))) {
NDPI_LOG_INFO(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"found aimini (104, 0x0102), (104, 0x0102), " "(104, 0x0102), (104, 0x0102).\n"); "found aimini (104, 0x0102), (104, 0x0102), " "(104, 0x0102), (104, 0x0102).\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow); ndpi_int_aimini_add_connection(ndpi_struct, flow);
return; return;
@@ -194,20 +193,20 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
if (flow->l4.udp.aimini_stage == 13 && packet->payload_packet_len == 32 if (flow->l4.udp.aimini_stage == 13 && packet->payload_packet_len == 32
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca) { && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca) {
flow->l4.udp.aimini_stage = 14; flow->l4.udp.aimini_stage = 14;
NDPI_LOG_DBG2(ndpi_struct, "stage = 14\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 14.\n");
return; return;
} }
if (flow->l4.udp.aimini_stage == 14 if (flow->l4.udp.aimini_stage == 14
&& ((packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca) && ((packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca)
|| (packet->payload_packet_len == 136 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0166))) { || (packet->payload_packet_len == 136 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0166))) {
flow->l4.udp.aimini_stage = 15; flow->l4.udp.aimini_stage = 15;
NDPI_LOG_DBG2(ndpi_struct, "stage = 15\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 15.\n");
return; return;
} }
if (flow->l4.udp.aimini_stage == 15 if (flow->l4.udp.aimini_stage == 15
&& ((packet->payload_packet_len == 136 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0166) && ((packet->payload_packet_len == 136 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0166)
|| (packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca))) { || (packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca))) {
NDPI_LOG_INFO(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"found aimini (32,0x01ca), (32,0x01ca), (32,0x01ca), ((136, 0x0166)||(32,0x01ca)).\n"); "found aimini (32,0x01ca), (32,0x01ca), (32,0x01ca), ((136, 0x0166)||(32,0x01ca)).\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow); ndpi_int_aimini_add_connection(ndpi_struct, flow);
return; return;
@@ -218,18 +217,18 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
if (flow->l4.udp.aimini_stage == 16 && packet->payload_packet_len == 16 if (flow->l4.udp.aimini_stage == 16 && packet->payload_packet_len == 16
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c) { && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c) {
flow->l4.udp.aimini_stage = 17; flow->l4.udp.aimini_stage = 17;
NDPI_LOG_DBG2(ndpi_struct, "stage = 17\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 17.\n");
return; return;
} }
if (flow->l4.udp.aimini_stage == 17 if (flow->l4.udp.aimini_stage == 17
&& (packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c)) { && (packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c)) {
flow->l4.udp.aimini_stage = 18; flow->l4.udp.aimini_stage = 18;
NDPI_LOG_DBG2(ndpi_struct, "stage = 18\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 18.\n");
return; return;
} }
if (flow->l4.udp.aimini_stage == 18 if (flow->l4.udp.aimini_stage == 18
&& (packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c)) { && (packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c)) {
NDPI_LOG_INFO(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"found aimini (16, 0x010c), (16, 0x010c), (16, 0x010c), (16, 0x010c).\n"); "found aimini (16, 0x010c), (16, 0x010c), (16, 0x010c), (16, 0x010c).\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow); ndpi_int_aimini_add_connection(ndpi_struct, flow);
return; return;
@@ -239,11 +238,11 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
(memcmp(packet->payload, "GET /player/", NDPI_STATICSTRING_LEN("GET /player/")) == 0)) || (memcmp(packet->payload, "GET /player/", NDPI_STATICSTRING_LEN("GET /player/")) == 0)) ||
(packet->payload_packet_len > NDPI_STATICSTRING_LEN("GET /play/?fid=") && (packet->payload_packet_len > NDPI_STATICSTRING_LEN("GET /play/?fid=") &&
(memcmp(packet->payload, "GET /play/?fid=", NDPI_STATICSTRING_LEN("GET /play/?fid=")) == 0))) { (memcmp(packet->payload, "GET /play/?fid=", NDPI_STATICSTRING_LEN("GET /play/?fid=")) == 0))) {
NDPI_LOG_DBG2(ndpi_struct, "HTTP packet detected\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "HTTP packet detected.\n");
ndpi_parse_packet_line_info(ndpi_struct, flow); ndpi_parse_packet_line_info(ndpi_struct, flow);
if (packet->host_line.ptr != NULL && packet->host_line.len > 11 if (packet->host_line.ptr != NULL && packet->host_line.len > 11
&& (memcmp(&packet->host_line.ptr[packet->host_line.len - 11], ".aimini.net", 11) == 0)) { && (memcmp(&packet->host_line.ptr[packet->host_line.len - 11], ".aimini.net", 11) == 0)) {
NDPI_LOG_INFO(ndpi_struct, "found AIMINI HTTP traffic\n"); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "AIMINI HTTP traffic detected.\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow); ndpi_int_aimini_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -256,8 +255,8 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
NDPI_STATICSTRING_LEN("download/")) == 0) { NDPI_STATICSTRING_LEN("download/")) == 0) {
ndpi_parse_packet_line_info(ndpi_struct, flow); ndpi_parse_packet_line_info(ndpi_struct, flow);
if (is_special_aimini_host(packet->host_line) == 1) { if (is_special_aimini_host(packet->host_line) == 1) {
NDPI_LOG_INFO(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"found AIMINI HTTP traffic\n"); "AIMINI HTTP traffic detected.\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow); ndpi_int_aimini_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -267,8 +266,8 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
NDPI_STATICSTRING_LEN("upload/")) == 0) { NDPI_STATICSTRING_LEN("upload/")) == 0) {
ndpi_parse_packet_line_info(ndpi_struct, flow); ndpi_parse_packet_line_info(ndpi_struct, flow);
if (is_special_aimini_host(packet->host_line) == 1) { if (is_special_aimini_host(packet->host_line) == 1) {
NDPI_LOG_INFO(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"found AIMINI HTTP traffic detected.\n"); "AIMINI HTTP traffic detected.\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow); ndpi_int_aimini_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -277,7 +276,8 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
} }
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "exclude aimini.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_AIMINI);
} }
-90
View File
@@ -1,90 +0,0 @@
/*
* amqp.c
*
* Copyright (C) 2011-17 - ntop.org
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_AMQP
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_AMQP
#include "ndpi_api.h"
PACK_ON
struct amqp_header {
u_int8_t ptype;
u_int16_t channel;
u_int32_t length;
u_int16_t class_id, method;
} PACK_OFF;
static void ndpi_int_amqp_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow/* , */
/* ndpi_protocol_type_t protocol_type */) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AMQP, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_amqp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search amqp\n");
if (packet->tcp != NULL) {
if(packet->payload_packet_len > sizeof(struct amqp_header)) {
struct amqp_header *h = (struct amqp_header*)packet->payload;
if(h->ptype <= 3) {
u_int32_t length = htonl(h->length);
if(((length+8) >= packet->payload_packet_len)
&& (length < 32768) /* Upper bound */) {
u_int16_t class_id = htons(h->class_id);
if((class_id >= 10) /* Connection */
&& (class_id <= 110) /* Tunnel */) {
u_int16_t method = htons(h->method);
if(method <= 120 /* Method basic NACK */) {
NDPI_LOG_INFO(ndpi_struct, "found amqp over tcp\n");
ndpi_int_amqp_add_connection(ndpi_struct, flow);
return;
}
}
}
}
}
} else {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
}
void init_amqp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) {
ndpi_set_bitmask_protocol_detection("AMQP", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_AMQP,
ndpi_search_amqp,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
-81
View File
@@ -1,81 +0,0 @@
/*
* apple_push.c
*
* Copyright (C) 2018 by ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_APPLE_PUSH
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_APPLE_PUSH
#include "ndpi_api.h"
static void ndpi_check_apple_push(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet;
/* https://support.apple.com/en-us/HT203609 */
if(((ntohl(packet->iph->saddr) & 0xFF000000 /* 255.0.0.0 */) == 0x11000000 /* 17.0.0.0/8 */)
|| ((ntohl(packet->iph->daddr) & 0xFF000000 /* 255.0.0.0 */) == 0x11000000 /* 17.0.0.0/8 */)) {
u_int16_t apple_push_port = ntohs(5223);
u_int16_t notification_apn_port = ntohs(2195);
u_int16_t apn_feedback_port = ntohs(2196);
if(((packet->tcp->source == apple_push_port) || (packet->tcp->dest == apple_push_port))
|| ((packet->tcp->source == notification_apn_port) || (packet->tcp->dest == notification_apn_port))
|| ((packet->tcp->source == apn_feedback_port) || (packet->tcp->dest == apn_feedback_port))
) {
NDPI_LOG_INFO(ndpi_struct, "found apple_push\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_APPLE_PUSH, NDPI_PROTOCOL_UNKNOWN);
return;
}
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
void ndpi_search_apple_push(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search apple_push\n");
/* skip marked packets */
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_APPLE_PUSH)
ndpi_check_apple_push(ndpi_struct, flow);
}
void init_apple_push_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("APPLE_PUSH", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_APPLE_PUSH,
ndpi_search_apple_push,
NDPI_SELECTION_BITMASK_PROTOCOL_TCP,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+7 -8
View File
@@ -22,14 +22,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_APPLEJUICE #ifdef NDPI_PROTOCOL_APPLEJUICE
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_APPLEJUICE
#include "ndpi_api.h"
static void ndpi_int_applejuice_add_connection(struct ndpi_detection_module_struct *ndpi_struct, static void ndpi_int_applejuice_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) struct ndpi_flow_struct *flow)
@@ -41,18 +37,21 @@ void ndpi_search_applejuice_tcp(struct ndpi_detection_module_struct *ndpi_struct
struct ndpi_flow_struct *flow) struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG_DBG(ndpi_struct, "search applejuice\n"); NDPI_LOG(NDPI_PROTOCOL_APPLEJUICE, ndpi_struct, NDPI_LOG_DEBUG, "search applejuice.\n");
if ((packet->payload_packet_len > 7) && (packet->payload[6] == 0x0d) if ((packet->payload_packet_len > 7) && (packet->payload[6] == 0x0d)
&& (packet->payload[7] == 0x0a) && (packet->payload[7] == 0x0a)
&& (memcmp(packet->payload, "ajprot", 6) == 0)) { && (memcmp(packet->payload, "ajprot", 6) == 0)) {
NDPI_LOG_INFO(ndpi_struct, "found applejuice\n"); NDPI_LOG(NDPI_PROTOCOL_APPLEJUICE, ndpi_struct, NDPI_LOG_DEBUG, "detected applejuice.\n");
ndpi_int_applejuice_add_connection(ndpi_struct, flow); ndpi_int_applejuice_add_connection(ndpi_struct, flow);
return; return;
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_APPLEJUICE, ndpi_struct, NDPI_LOG_DEBUG, "exclude applejuice.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_APPLEJUICE);
} }
+12 -10
View File
@@ -22,26 +22,27 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_ARMAGETRON #ifdef NDPI_PROTOCOL_ARMAGETRON
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_ARMAGETRON
#include "ndpi_api.h"
static void ndpi_int_armagetron_add_connection(struct ndpi_detection_module_struct *ndpi_struct, static void ndpi_int_armagetron_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) struct ndpi_flow_struct *flow)
{ {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_ARMAGETRON, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_ARMAGETRON, NDPI_PROTOCOL_UNKNOWN);
} }
void ndpi_search_armagetron_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) void ndpi_search_armagetron_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG(NDPI_PROTOCOL_ARMAGETRON, ndpi_struct, NDPI_LOG_DEBUG, "search armagetron.\n");
NDPI_LOG_DBG(ndpi_struct, "search armagetron\n");
if (packet->payload_packet_len > 10) { if (packet->payload_packet_len > 10) {
/* login request */ /* login request */
@@ -51,7 +52,7 @@ void ndpi_search_armagetron_udp(struct ndpi_detection_module_struct *ndpi_struct
goto exclude; goto exclude;
if (get_u_int16_t(packet->payload, 6) == htons(0x0008) if (get_u_int16_t(packet->payload, 6) == htons(0x0008)
&& get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == 0) { && get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found armagetron\n"); NDPI_LOG(NDPI_PROTOCOL_ARMAGETRON, ndpi_struct, NDPI_LOG_DEBUG, "detected armagetron.\n");
ndpi_int_armagetron_add_connection(ndpi_struct, flow); ndpi_int_armagetron_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -64,7 +65,7 @@ void ndpi_search_armagetron_udp(struct ndpi_detection_module_struct *ndpi_struct
goto exclude; goto exclude;
if (get_u_int32_t(packet->payload, 6) == htonl(0x00000500) && get_u_int32_t(packet->payload, 6 + 4) == htonl(0x00010000) if (get_u_int32_t(packet->payload, 6) == htonl(0x00000500) && get_u_int32_t(packet->payload, 6 + 4) == htonl(0x00010000)
&& get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == 0) { && get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found armagetron\n"); NDPI_LOG(NDPI_PROTOCOL_ARMAGETRON, ndpi_struct, NDPI_LOG_DEBUG, "detected armagetron.\n");
ndpi_int_armagetron_add_connection(ndpi_struct, flow); ndpi_int_armagetron_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -84,7 +85,7 @@ void ndpi_search_armagetron_udp(struct ndpi_detection_module_struct *ndpi_struct
&& (get_u_int32_t(packet->payload, 6 + 10 + val) == htonl(0x00010000) && (get_u_int32_t(packet->payload, 6 + 10 + val) == htonl(0x00010000)
|| get_u_int32_t(packet->payload, 6 + 10 + val) == htonl(0x00000001)) || get_u_int32_t(packet->payload, 6 + 10 + val) == htonl(0x00000001))
&& get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == 0) { && get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found armagetron\n"); NDPI_LOG(NDPI_PROTOCOL_ARMAGETRON, ndpi_struct, NDPI_LOG_DEBUG, "detected armagetron.\n");
ndpi_int_armagetron_add_connection(ndpi_struct, flow); ndpi_int_armagetron_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -93,7 +94,8 @@ void ndpi_search_armagetron_udp(struct ndpi_detection_module_struct *ndpi_struct
} }
exclude: exclude:
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_ARMAGETRON, ndpi_struct, NDPI_LOG_DEBUG, "exclude armagetron.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_ARMAGETRON);
} }
-7
View File
@@ -43,8 +43,6 @@ static void ndpi_int_ftp_add_connection(struct ndpi_detection_module_struct *ndp
*/ */
#if !defined(WIN32) #if !defined(WIN32)
static inline static inline
#elif defined(MINGW_GCC)
__mingw_forceinline static
#else #else
__forceinline static __forceinline static
#endif #endif
@@ -80,11 +78,8 @@ u_int8_t ndpi_int_check_possible_ftp_command(const struct ndpi_packet_struct *pa
/** /**
* ftp replies are are 3-digit number followed by space or hyphen * ftp replies are are 3-digit number followed by space or hyphen
*/ */
#if !defined(WIN32) #if !defined(WIN32)
static inline static inline
#elif defined(MINGW_GCC)
__mingw_forceinline static
#else #else
__forceinline static __forceinline static
#endif #endif
@@ -113,8 +108,6 @@ u_int8_t ndpi_int_check_possible_ftp_reply(const struct ndpi_packet_struct *pack
*/ */
#if !defined(WIN32) #if !defined(WIN32)
static inline static inline
#elif defined(MINGW_GCC)
__mingw_forceinline static
#else #else
__forceinline static __forceinline static
#endif #endif
+4 -12
View File
@@ -26,14 +26,10 @@
http://tools.ietf.org/html/rfc4891 http://tools.ietf.org/html/rfc4891
*/ */
#include "ndpi_protocol_ids.h"
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_AYIYA #ifdef NDPI_PROTOCOL_AYIYA
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_AYIYA
#include "ndpi_api.h"
struct ayiya { struct ayiya {
u_int8_t flags[3]; u_int8_t flags[3];
u_int8_t next_header; u_int8_t next_header;
@@ -46,8 +42,6 @@ void ndpi_search_ayiya(struct ndpi_detection_module_struct *ndpi_struct, struct
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search AYIYA\n");
if(packet->udp && (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN)) { if(packet->udp && (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN)) {
/* Ayiya is udp based, port 5072 */ /* Ayiya is udp based, port 5072 */
if ((packet->udp->source == htons(5072) || packet->udp->dest == htons(5072)) if ((packet->udp->source == htons(5072) || packet->udp->dest == htons(5072))
@@ -57,19 +51,17 @@ void ndpi_search_ayiya(struct ndpi_detection_module_struct *ndpi_struct, struct
/* FINISH */ /* FINISH */
struct ayiya *a = (struct ayiya*)packet->payload; struct ayiya *a = (struct ayiya*)packet->payload;
u_int32_t epoch = ntohl(a->epoch), now; u_int32_t epoch = ntohl(a->epoch), now;
u_int32_t fiveyears = 86400 * 365 * 5; u_int32_t fireyears = 86400 * 365 * 5;
now = flow->packet.tick_timestamp; now = flow->packet.tick_timestamp;
if((epoch >= (now - fiveyears)) && (epoch <= (now+86400 /* 1 day */))) { if((epoch >= (now - fireyears)) && (epoch <= (now+86400 /* 1 day */)))
NDPI_LOG_INFO(ndpi_struct, "found AYIYA\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AYIYA, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AYIYA, NDPI_PROTOCOL_UNKNOWN);
}
return; return;
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_AYIYA);
} }
} }
+11 -11
View File
@@ -22,13 +22,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_BATTLEFIELD #ifdef NDPI_PROTOCOL_BATTLEFIELD
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_BATTLEFIELD
#include "ndpi_api.h"
static void ndpi_int_battlefield_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_int_battlefield_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
@@ -56,12 +53,12 @@ void ndpi_search_battlefield(struct ndpi_detection_module_struct *ndpi_struct, s
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_BATTLEFIELD) { if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_BATTLEFIELD) {
if (src != NULL && ((u_int32_t) if (src != NULL && ((u_int32_t)
(packet->tick_timestamp - src->battlefield_ts) < ndpi_struct->battlefield_timeout)) { (packet->tick_timestamp - src->battlefield_ts) < ndpi_struct->battlefield_timeout)) {
NDPI_LOG_DBG2(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_BATTLEFIELD, ndpi_struct, NDPI_LOG_DEBUG,
"battlefield : save src connection packet detected\n"); "battlefield : save src connection packet detected\n");
src->battlefield_ts = packet->tick_timestamp; src->battlefield_ts = packet->tick_timestamp;
} else if (dst != NULL && ((u_int32_t) } else if (dst != NULL && ((u_int32_t)
(packet->tick_timestamp - dst->battlefield_ts) < ndpi_struct->battlefield_timeout)) { (packet->tick_timestamp - dst->battlefield_ts) < ndpi_struct->battlefield_timeout)) {
NDPI_LOG_DBG2(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_BATTLEFIELD, ndpi_struct, NDPI_LOG_DEBUG,
"battlefield : save dst connection packet detected\n"); "battlefield : save dst connection packet detected\n");
dst->battlefield_ts = packet->tick_timestamp; dst->battlefield_ts = packet->tick_timestamp;
} }
@@ -77,7 +74,8 @@ void ndpi_search_battlefield(struct ndpi_detection_module_struct *ndpi_struct, s
} }
} else if (flow->l4.udp.battlefield_stage == 2 - packet->packet_direction) { } else if (flow->l4.udp.battlefield_stage == 2 - packet->packet_direction) {
if (packet->payload_packet_len > 8 && get_u_int32_t(packet->payload, 0) == flow->l4.udp.battlefield_msg_id) { if (packet->payload_packet_len > 8 && get_u_int32_t(packet->payload, 0) == flow->l4.udp.battlefield_msg_id) {
NDPI_LOG_INFO(ndpi_struct, "found Battlefield message and reply detected\n"); NDPI_LOG(NDPI_PROTOCOL_BATTLEFIELD, ndpi_struct,
NDPI_LOG_DEBUG, "Battlefield message and reply detected.\n");
ndpi_int_battlefield_add_connection(ndpi_struct, flow); ndpi_int_battlefield_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -93,26 +91,28 @@ void ndpi_search_battlefield(struct ndpi_detection_module_struct *ndpi_struct, s
} else if (flow->l4.udp.battlefield_stage == 4 - packet->packet_direction) { } else if (flow->l4.udp.battlefield_stage == 4 - packet->packet_direction) {
if (packet->payload_packet_len == 7 if (packet->payload_packet_len == 7
&& (packet->payload[0] == 0x02 || packet->payload[packet->payload_packet_len - 1] == 0xe0)) { && (packet->payload[0] == 0x02 || packet->payload[packet->payload_packet_len - 1] == 0xe0)) {
NDPI_LOG_INFO(ndpi_struct, "found Battlefield message and reply detected\n"); NDPI_LOG(NDPI_PROTOCOL_BATTLEFIELD, ndpi_struct, NDPI_LOG_DEBUG,
"Battlefield message and reply detected.\n");
ndpi_int_battlefield_add_connection(ndpi_struct, flow); ndpi_int_battlefield_add_connection(ndpi_struct, flow);
return; return;
} }
} }
if (packet->payload_packet_len == 18 && memcmp(&packet->payload[5], "battlefield2\x00", 13) == 0) { if (packet->payload_packet_len == 18 && memcmp(&packet->payload[5], "battlefield2\x00", 13) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found Battlefield 2 hello packet detected\n"); NDPI_LOG(NDPI_PROTOCOL_BATTLEFIELD, ndpi_struct, NDPI_LOG_DEBUG, "Battlefield 2 hello packet detected.\n");
ndpi_int_battlefield_add_connection(ndpi_struct, flow); ndpi_int_battlefield_add_connection(ndpi_struct, flow);
return; return;
} else if (packet->payload_packet_len > 10 && } else if (packet->payload_packet_len > 10 &&
(memcmp(packet->payload, "\x11\x20\x00\x01\x00\x00\x50\xb9\x10\x11", 10) == 0 (memcmp(packet->payload, "\x11\x20\x00\x01\x00\x00\x50\xb9\x10\x11", 10) == 0
|| memcmp(packet->payload, "\x11\x20\x00\x01\x00\x00\x30\xb9\x10\x11", 10) == 0 || memcmp(packet->payload, "\x11\x20\x00\x01\x00\x00\x30\xb9\x10\x11", 10) == 0
|| memcmp(packet->payload, "\x11\x20\x00\x01\x00\x00\xa0\x98\x00\x11", 10) == 0)) { || memcmp(packet->payload, "\x11\x20\x00\x01\x00\x00\xa0\x98\x00\x11", 10) == 0)) {
NDPI_LOG_INFO(ndpi_struct, "found Battlefield safe pattern detected\n"); NDPI_LOG(NDPI_PROTOCOL_BATTLEFIELD, ndpi_struct, NDPI_LOG_DEBUG, "Battlefield safe pattern detected.\n");
ndpi_int_battlefield_add_connection(ndpi_struct, flow); ndpi_int_battlefield_add_connection(ndpi_struct, flow);
return; return;
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BATTLEFIELD);
return;
} }
+15 -16
View File
@@ -1,7 +1,8 @@
/* /*
* bgp.c * bgp.c
* *
* Copyright (C) 2016 - ntop.org * Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - ntop.org
* *
* This file is part of nDPI, an open source deep packet inspection * This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH * library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -21,14 +22,15 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_BGP #ifdef NDPI_PROTOCOL_BGP
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_BGP
#include "ndpi_api.h"
static void ndpi_int_bgp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BGP, NDPI_PROTOCOL_UNKNOWN);
}
/* this detection also works asymmetrically */ /* this detection also works asymmetrically */
void ndpi_search_bgp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) void ndpi_search_bgp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
@@ -36,23 +38,20 @@ void ndpi_search_bgp(struct ndpi_detection_module_struct *ndpi_struct, struct nd
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
u_int16_t bgp_port = htons(179); u_int16_t bgp_port = htons(179);
NDPI_LOG_DBG(ndpi_struct, "search BGP\n"); if(packet->tcp
&& (packet->payload[18] < 5)
if(packet->tcp) {
if(packet->payload_packet_len > 18
&& packet->payload[18] < 5
&& ((packet->tcp->dest == bgp_port) || (packet->tcp->source == bgp_port)) && ((packet->tcp->dest == bgp_port) || (packet->tcp->source == bgp_port))
&& (packet->payload_packet_len > 18)
&& (get_u_int64_t(packet->payload, 0) == 0xffffffffffffffffULL) && (get_u_int64_t(packet->payload, 0) == 0xffffffffffffffffULL)
&& (get_u_int64_t(packet->payload, 8) == 0xffffffffffffffffULL) && (get_u_int64_t(packet->payload, 8) == 0xffffffffffffffffULL)
&& (ntohs(get_u_int16_t(packet->payload, 16)) <= packet->payload_packet_len)) { && (ntohs(get_u_int16_t(packet->payload, 16)) <= packet->payload_packet_len)
) {
NDPI_LOG_INFO(ndpi_struct, "found BGP\n"); NDPI_LOG(NDPI_PROTOCOL_BGP, ndpi_struct, NDPI_LOG_DEBUG, "BGP detected.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BGP, NDPI_PROTOCOL_UNKNOWN); ndpi_int_bgp_add_connection(ndpi_struct, flow);
return; return;
} }
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BGP);
} }
+41 -32
View File
@@ -2,7 +2,7 @@
* bittorrent.c * bittorrent.c
* *
* Copyright (C) 2009-2011 by ipoque GmbH * Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org * Copyright (C) 2011-15 - ntop.org
* *
* This file is part of nDPI, an open source deep packet inspection * This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH * library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -23,14 +23,8 @@
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_BITTORRENT #ifdef NDPI_PROTOCOL_BITTORRENT
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_BITTORRENT
#include "ndpi_api.h"
#define NDPI_PROTOCOL_UNSAFE_DETECTION 0 #define NDPI_PROTOCOL_UNSAFE_DETECTION 0
#define NDPI_PROTOCOL_SAFE_DETECTION 1 #define NDPI_PROTOCOL_SAFE_DETECTION 1
@@ -63,17 +57,18 @@ static void ndpi_add_connection_as_bittorrent(struct ndpi_detection_module_struc
{ {
if(check_hash) { if(check_hash) {
const char *bt_hash = NULL; /* 20 bytes long */ const char *bt_hash = NULL; /* 20 bytes long */
const char *peer_id = NULL; /* 20 bytes long */
if(bt_offset == -1) { if(bt_offset == -1) {
const char *bt_magic = ndpi_strnstr((const char *)flow->packet.payload, const char *bt_magic = ndpi_strnstr((const char *)flow->packet.payload,
"BitTorrent protocol", flow->packet.payload_packet_len); "BitTorrent protocol", flow->packet.payload_packet_len);
if(bt_magic) if(bt_magic)
bt_hash = &bt_magic[19]; bt_hash = &bt_magic[19], peer_id = &bt_magic[39];
} else } else
bt_hash = (const char*)&flow->packet.payload[28]; bt_hash = (const char*)&flow->packet.payload[28], peer_id = (const char*)&flow->packet.payload[48];
if(bt_hash) memcpy(flow->protos.bittorrent.hash, bt_hash, 20); if(bt_hash) memcpy(flow->bittorent_hash, bt_hash, 20);
} }
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BITTORRENT, NDPI_PROTOCOL_UNKNOWN); ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BITTORRENT, NDPI_PROTOCOL_UNKNOWN);
@@ -93,7 +88,8 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
if(flow->packet_counter == 2 && packet->payload_packet_len > 20) { if(flow->packet_counter == 2 && packet->payload_packet_len > 20) {
if(memcmp(&packet->payload[0], "BitTorrent protocol", 19) == 0) { if(memcmp(&packet->payload[0], "BitTorrent protocol", 19) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found BT: plain\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT,
ndpi_struct, NDPI_LOG_TRACE, "BT: plain BitTorrent protocol detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, 19, 1, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, 19, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION); NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1; return 1;
@@ -104,7 +100,7 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
/* test for match 0x13+"BitTorrent protocol" */ /* test for match 0x13+"BitTorrent protocol" */
if(packet->payload[0] == 0x13) { if(packet->payload[0] == 0x13) {
if(memcmp(&packet->payload[1], "BitTorrent protocol", 19) == 0) { if(memcmp(&packet->payload[1], "BitTorrent protocol", 19) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found BT: plain\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_TRACE, "BT: plain BitTorrent protocol detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, 20, 1, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, 20, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION); NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1; return 1;
@@ -113,7 +109,8 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
} }
if(packet->payload_packet_len > 23 && memcmp(packet->payload, "GET /webseed?info_hash=", 23) == 0) { if(packet->payload_packet_len > 23 && memcmp(packet->payload, "GET /webseed?info_hash=", 23) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found BT: plain webseed\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, "BT: plain webseed BitTorrent protocol detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION); NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
return 1; return 1;
@@ -123,7 +120,8 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
/* no asymmetric detection possible for answer of pattern "GET /data?fid=". */ /* no asymmetric detection possible for answer of pattern "GET /data?fid=". */
if(packet->payload_packet_len > 60 if(packet->payload_packet_len > 60
&& memcmp(packet->payload, "GET /data?fid=", 14) == 0 && memcmp(&packet->payload[54], "&size=", 6) == 0) { && memcmp(packet->payload, "GET /data?fid=", 14) == 0 && memcmp(&packet->payload[54], "&size=", 6) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found BT: plain Bitcomet persistent seed\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, "BT: plain Bitcomet persistent seed protocol detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION); NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
return 1; return 1;
@@ -143,7 +141,8 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
&& ((packet->user_agent_line.len > 8 && memcmp(packet->user_agent_line.ptr, "Azureus ", 8) == 0) && ((packet->user_agent_line.len > 8 && memcmp(packet->user_agent_line.ptr, "Azureus ", 8) == 0)
|| (packet->user_agent_line.len >= 10 && memcmp(packet->user_agent_line.ptr, "BitTorrent", 10) == 0) || (packet->user_agent_line.len >= 10 && memcmp(packet->user_agent_line.ptr, "BitTorrent", 10) == 0)
|| (packet->user_agent_line.len >= 11 && memcmp(packet->user_agent_line.ptr, "BTWebClient", 11) == 0))) { || (packet->user_agent_line.len >= 11 && memcmp(packet->user_agent_line.ptr, "BTWebClient", 11) == 0))) {
NDPI_LOG_INFO(ndpi_struct, "found BT: Azureus /Bittorrent user agent\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, "Azureus /Bittorrent user agent line detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION); NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
return 1; return 1;
@@ -153,7 +152,8 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
&& (packet->user_agent_line.len >= 9 && memcmp(packet->user_agent_line.ptr, "Shareaza ", 9) == 0) && (packet->user_agent_line.len >= 9 && memcmp(packet->user_agent_line.ptr, "Shareaza ", 9) == 0)
&& (packet->parsed_lines > 8 && packet->line[8].ptr != 0 && (packet->parsed_lines > 8 && packet->line[8].ptr != 0
&& packet->line[8].len >= 9 && memcmp(packet->line[8].ptr, "X-Queue: ", 9) == 0)) { && packet->line[8].len >= 9 && memcmp(packet->line[8].ptr, "X-Queue: ", 9) == 0)) {
NDPI_LOG_INFO(ndpi_struct, "found BT: Shareaza detected\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, "Bittorrent Shareaza detected.\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION); NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
return 1; return 1;
@@ -187,7 +187,7 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
&& packet->line[8].ptr != NULL && packet->line[8].ptr != NULL
&& packet->line[8].len > 22 && memcmp(packet->line[8].ptr, "Cache-Control: no-cache", 23) == 0) { && packet->line[8].len > 22 && memcmp(packet->line[8].ptr, "Cache-Control: no-cache", 23) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found BT: Bitcomet LTS\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_TRACE, "Bitcomet LTS detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION); NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1; return 1;
@@ -212,7 +212,7 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
&& packet->line[6].ptr != NULL && packet->line[6].ptr != NULL
&& packet->line[6].len > 21 && memcmp(packet->line[6].ptr, "Connection: Keep-Alive", 22) == 0) { && packet->line[6].len > 21 && memcmp(packet->line[6].ptr, "Connection: Keep-Alive", 22) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found BT: FlashGet\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_TRACE, "FlashGet detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION); NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1; return 1;
@@ -233,7 +233,7 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
&& packet->line[5].ptr != NULL && packet->line[5].ptr != NULL
&& packet->line[5].len > 21 && memcmp(packet->line[5].ptr, "Connection: Keep-Alive", 22) == 0) { && packet->line[5].len > 21 && memcmp(packet->line[5].ptr, "Connection: Keep-Alive", 22) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found BT: FlashGet\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_TRACE, "FlashGet detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION); NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1; return 1;
@@ -251,7 +251,8 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
ptr++; ptr++;
} }
NDPI_LOG_DBG2(ndpi_struct, " BT stat: tracker info hash found\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, " BT stat: tracker info hash found\n");
/* len is > 50, so save operation here */ /* len is > 50, so save operation here */
len -= 10; len -= 10;
@@ -300,7 +301,8 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
} }
} }
NDPI_LOG_INFO(ndpi_struct, "found BT: tracker info hash parsed\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, " BT stat: tracker info hash parsed\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION); NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1; return 1;
@@ -328,7 +330,8 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
/* did not see this pattern anywhere */ /* did not see this pattern anywhere */
if((memcmp(&packet->payload[0], pattern_20_bytes, 20) == 0) if((memcmp(&packet->payload[0], pattern_20_bytes, 20) == 0)
&& (memcmp(&packet->payload[52], pattern_12_bytes, 12) == 0)) { && (memcmp(&packet->payload[52], pattern_12_bytes, 12) == 0)) {
NDPI_LOG_INFO(ndpi_struct, "found BT: Warez - Plain\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, "BT: Warez - Plain BitTorrent protocol detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION); NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1; return 1;
@@ -342,7 +345,9 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
/* haven't fount this pattern anywhere */ /* haven't fount this pattern anywhere */
if(packet->host_line.ptr != NULL if(packet->host_line.ptr != NULL
&& packet->host_line.len >= 9 && memcmp(packet->host_line.ptr, "ip2p.com:", 9) == 0) { && packet->host_line.len >= 9 && memcmp(packet->host_line.ptr, "ip2p.com:", 9) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found BT: Warez - Plain Host: ip2p.com: pattern\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT,
ndpi_struct, NDPI_LOG_TRACE,
"BT: Warez - Plain BitTorrent protocol detected due to Host: ip2p.com: pattern\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION); NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
return 1; return 1;
@@ -366,11 +371,13 @@ static void ndpi_int_search_bittorrent_tcp(struct ndpi_detection_module_struct *
/* exclude stage 0 detection from next run */ /* exclude stage 0 detection from next run */
flow->bittorrent_stage = 1; flow->bittorrent_stage = 1;
if(ndpi_int_search_bittorrent_tcp_zero(ndpi_struct, flow) != 0) { if(ndpi_int_search_bittorrent_tcp_zero(ndpi_struct, flow) != 0) {
NDPI_LOG_DBG2(ndpi_struct, "stage 0 has detected something, returning\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_DEBUG,
"stage 0 has detected something, returning\n");
return; return;
} }
NDPI_LOG_DBG2(ndpi_struct, "stage 0 has no direct detection, fall through\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_DEBUG,
"stage 0 has no direct detection, fall through\n");
} }
return; return;
} }
@@ -378,6 +385,7 @@ static void ndpi_int_search_bittorrent_tcp(struct ndpi_detection_module_struct *
void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
int no_bittorrent = 0;
char *bt_proto = NULL; char *bt_proto = NULL;
/* This is broadcast */ /* This is broadcast */
@@ -386,7 +394,7 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|| (packet->udp || (packet->udp
&& ((ntohs(packet->udp->source) == 3544) /* teredo.c */ && ((ntohs(packet->udp->source) == 3544) /* teredo.c */
|| (ntohs(packet->udp->dest) == 3544))))) { || (ntohs(packet->udp->dest) == 3544))))) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BITTORRENT);
return; return;
} }
@@ -435,8 +443,7 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
/* Heuristic */ /* Heuristic */
bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20); bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20);
goto bittorrent_found; goto bittorrent_found;
/* CSGO/DOTA conflict */ } else if(((v1_version & 0x0f) == 1)
} else if(flow->packet_counter > 8 && ((v1_version & 0x0f) == 1)
&& ((v1_version >> 4) < 5 /* ST_NUM_STATES */) && ((v1_version >> 4) < 5 /* ST_NUM_STATES */)
&& (v1_extension < 3 /* EXT_NUM_EXT */) && (v1_extension < 3 /* EXT_NUM_EXT */)
&& (v1_window_size < 32768 /* 32k */) && (v1_window_size < 32768 /* 32k */)
@@ -473,9 +480,10 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
) { ) {
bittorrent_found: bittorrent_found:
if(bt_proto && (packet->payload_packet_len > 47)) if(bt_proto && (packet->payload_packet_len > 47))
memcpy(flow->protos.bittorrent.hash, &bt_proto[27], 20); memcpy(flow->bittorent_hash, &bt_proto[27], 20);
NDPI_LOG_INFO(ndpi_struct, "found BT: plain\n"); NDPI_LOG(NDPI_PROTOCOL_BITTORRENT,
ndpi_struct, NDPI_LOG_TRACE, "BT: plain BitTorrent protocol detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 0, ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 0,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION); NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return; return;
@@ -484,7 +492,8 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
return; return;
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BITTORRENT);
} }
} }
} }
-67
View File
@@ -1,67 +0,0 @@
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_BJNP
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_BJNP
#include "ndpi_api.h"
static void ndpi_int_bjnp_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
u_int8_t due_to_correlation)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BJNP, NDPI_PROTOCOL_UNKNOWN);
}
static void ndpi_check_bjnp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
u_int32_t payload_len = packet->payload_packet_len;
if(packet->udp != NULL) {
if(payload_len > 4) {
if((memcmp((const char *)packet->payload, "BJNP", 4) == 0)
|| (memcmp((const char *)packet->payload, "BNJB", 4) == 0)
|| (memcmp((const char *)packet->payload, "BJNB", 4) == 0)
|| (memcmp((const char *)packet->payload, "MFNP", 4) == 0)
) {
NDPI_LOG_INFO(ndpi_struct, "found bjnp\n");
ndpi_int_bjnp_add_connection(ndpi_struct, flow, 0);
return;
}
}
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
void ndpi_search_bjnp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search bjnp\n");
/* skip marked packets */
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_BJNP) {
if (packet->tcp_retransmission == 0) {
ndpi_check_bjnp(ndpi_struct, flow);
}
}
}
void init_bjnp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("BJNP", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_BJNP,
ndpi_search_bjnp,
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+7 -15
View File
@@ -29,17 +29,17 @@
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
/*
typedef unsigned char u_int8_t; typedef unsigned char u_int8_t;
typedef unsigned short int u_int16_t; typedef unsigned short int u_int16_t;
typedef unsigned long long int u_int64_t; typedef unsigned long long int u_int64_t;
*/
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
typedef signed long long int i_int64_t;
#include "btlib.h" #include "btlib.h"
int bt_parse_debug = 0; int bt_parse_debug = 0;
@@ -90,7 +90,6 @@ static char *print_id_ip6_p(char *s,const struct bt_nodes6_data *b) {
} }
#if 0
void dump_bt_proto_struct(struct bt_parse_protocol *p) { void dump_bt_proto_struct(struct bt_parse_protocol *p) {
char b20h[128]; char b20h[128];
int i; int i;
@@ -156,9 +155,7 @@ void dump_bt_proto_struct(struct bt_parse_protocol *p) {
if(p->interval) printf("\tinterval\t%d\n",p->interval); if(p->interval) printf("\tinterval\t%d\n",p->interval);
if(p->min_interval) printf("\tmin interval\t%d\n",p->min_interval); if(p->min_interval) printf("\tmin interval\t%d\n",p->min_interval);
} }
#endif
#ifdef BTLIB_DEBUG
static void _print_safe_str(char *msg,char *k,const u_int8_t *s,size_t l) { static void _print_safe_str(char *msg,char *k,const u_int8_t *s,size_t l) {
static const char *th="0123456789abcdef?"; static const char *th="0123456789abcdef?";
char *buf = (char*)ndpi_malloc((size_t)(l*3+2)); char *buf = (char*)ndpi_malloc((size_t)(l*3+2));
@@ -184,13 +181,8 @@ static void _print_safe_str(char *msg,char *k,const u_int8_t *s,size_t l) {
static void print_safe_str(char *msg,bt_parse_data_cb_t *cbd) { static void print_safe_str(char *msg,bt_parse_data_cb_t *cbd) {
_print_safe_str(msg,cbd->buf,cbd->v.s.s,cbd->v.s.l); _print_safe_str(msg,cbd->buf,cbd->v.s.s,cbd->v.s.l);
} }
#define DEBUG_TRACE(cmd) { if(bt_parse_debug) cmd; } #define DEBUG_TRACE(cmd) { if(bt_parse_debug) cmd; }
#else
#define DEBUG_TRACE(cmd) ;
#endif
#define STREQ(a,b) !strcmp(a,b) #define STREQ(a,b) !strcmp(a,b)
@@ -404,20 +396,20 @@ void cb_data(bt_parse_data_cb_t *cbd,int *ret) {
return; return;
} }
if(cbd->buf[0] == 'e') { if(cbd->buf[0] == 'e' && !cbd->buf[0]) {
p->e_msg = s; p->e_msg = s;
p->e_len = cbd->v.s.l; p->e_len = cbd->v.s.l;
return; return;
} }
// DEBUG_TRACE(print_safe_str("UNKNOWN",cbd)); // DEBUG_TRACE(print_safe_str("UKNOWN",cbd));
} }
const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_cb_t *cbd) { const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_cb_t *cbd) {
unsigned int n=0,neg=0; unsigned int n=0,neg=0;
int64_t d = 0; i_int64_t d = 0;
u_int8_t c; register u_int8_t c;
if(*l == 0) return NULL; if(*l == 0) return NULL;
if(cbd->level > BDEC_MAXDEPT) goto bad_data; if(cbd->level > BDEC_MAXDEPT) goto bad_data;
+10 -46
View File
@@ -24,81 +24,44 @@
#define BDEC_MAXDEPT 8 #define BDEC_MAXDEPT 8
#ifdef WIN32
#include "ndpi_win32.h"
#endif
typedef struct b_elem_s { typedef struct b_elem_s {
const u_int8_t *s; const u_int8_t *s;
size_t l; size_t l;
} b_elem_s_t; } b_elem_s_t;
#ifdef WIN32 struct __attribute__ ((__packed__)) bt_nodes_data {
// enable 1 byte packing on Windows
#include <pshpack1.h>
#endif
struct
#ifndef WIN32
__attribute__((__packed__))
#endif
bt_nodes_data {
u_int8_t id[20] ; u_int8_t id[20] ;
u_int32_t ip; u_int32_t ip;
u_int16_t port; u_int16_t port;
}; };
struct struct __attribute__ ((__packed__)) bt_ipv4p {
#ifndef WIN32
__attribute__((__packed__))
#endif
bt_ipv4p {
u_int32_t ip; u_int32_t ip;
u_int16_t port; u_int16_t port;
}; };
struct struct __attribute__ ((__packed__)) bt_ipv4p2 {
#ifndef WIN32
__attribute__((__packed__))
#endif
bt_ipv4p2 {
struct bt_ipv4p d; struct bt_ipv4p d;
u_int8_t pad[2]; u_int8_t pad[2];
}; };
struct struct __attribute__ ((__packed__)) bt_nodes6_data {
#ifndef WIN32
__attribute__((__packed__))
#endif
bt_nodes6_data {
u_int8_t id[20] ; u_int8_t id[20] ;
u_int32_t ip[4]; u_int32_t ip[4];
u_int16_t port; u_int16_t port;
}; };
struct struct __attribute__ ((__packed__)) bt_ipv6p {
#ifndef WIN32
__attribute__((__packed__))
#endif
bt_ipv6p {
u_int32_t ip[4]; u_int32_t ip[4];
u_int16_t port; u_int16_t port;
}; };
struct struct __attribute__ ((__packed__)) bt_ipv6p2 {
#ifndef WIN32
__attribute__((__packed__))
#endif
bt_ipv6p2 {
struct bt_ipv6p d; struct bt_ipv6p d;
u_int8_t pad[3]; u_int8_t pad[3];
}; };
#ifdef WIN32
// disable 1 byte packing
#include <poppack.h>
#endif
/* /*
a.id S r.id S a.id S r.id S
@@ -150,9 +113,9 @@ struct bt_parse_protocol {
struct bt_nodes6_data *nodes6; struct bt_nodes6_data *nodes6;
u_int16_t name_len; u_int16_t name_len;
u_int16_t nn; // nodes num u_int16_t nn; // nodes num
u_int16_t nv; // values num u_int16_t nv; // valuse num
u_int16_t nn6; // nodes6 num u_int16_t nn6; // nodes6 num
u_int16_t nv6; // values6 num u_int16_t nv6; // valuse6 num
u_int16_t port; u_int16_t port;
u_int16_t t_len; u_int16_t t_len;
} r; } r;
@@ -171,7 +134,7 @@ typedef struct bt_parse_data_cb {
int level; int level;
int t; int t;
union { union {
int64_t i; i_int64_t i;
b_elem_s_t s; b_elem_s_t s;
} v; } v;
} bt_parse_data_cb_t; } bt_parse_data_cb_t;
@@ -179,3 +142,4 @@ typedef struct bt_parse_data_cb {
extern int bt_parse_debug; extern int bt_parse_debug;
void dump_bt_proto_struct(struct bt_parse_protocol *p); void dump_bt_proto_struct(struct bt_parse_protocol *p);
const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_cb_t *cbd); const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_cb_t *cbd);
-87
View File
@@ -1,87 +0,0 @@
/*
* checkmk.c
*
* Copyright (C) 2011-17 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_CHECKMK
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_CHECKMK
#include "ndpi_api.h"
static void ndpi_int_checkmk_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CHECKMK, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_checkmk(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
if (packet->payload_packet_len >= 15) {
if(packet->payload_packet_len > 128) {
/*
When we transfer a large data chunk, unless we have observed
the initial connection, we need to discard these packets
as they are not an indication that this flow is not AFP
*/
return;
}
/*
* this will detect the OpenSession command of the Data Stream Interface (DSI) protocol
* which is exclusively used by the Apple Filing Protocol (AFP) on TCP/IP networks
*/
if (packet->payload_packet_len >= 15 && packet->payload_packet_len < 100
&& memcmp(packet->payload, "<<<check_mk>>>", 14) == 0) {
NDPI_LOG(NDPI_PROTOCOL_CHECKMK, ndpi_struct, NDPI_LOG_DEBUG, "Check_MK: Flow detected.\n");
ndpi_int_checkmk_add_connection(ndpi_struct, flow);
return;
}
}
NDPI_LOG(NDPI_PROTOCOL_CHECKMK, ndpi_struct, NDPI_LOG_DEBUG, "Check_MK excluded.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CHECKMK);
}
void init_checkmk_dissector(struct ndpi_detection_module_struct *ndpi_struct,
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("CHECKMK", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_CHECKMK,
ndpi_search_checkmk,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+8 -13
View File
@@ -4,15 +4,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_CISCOVPN #ifdef NDPI_PROTOCOL_CISCOVPN
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_CISCOVPN
#include "ndpi_api.h"
static void ndpi_int_ciscovpn_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_int_ciscovpn_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CISCOVPN, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CISCOVPN, NDPI_PROTOCOL_UNKNOWN);
@@ -25,15 +20,15 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
u_int16_t tdport = 0, tsport = 0; u_int16_t tdport = 0, tsport = 0;
NDPI_LOG_DBG(ndpi_struct, "search CISCOVPN\n"); NDPI_LOG(NDPI_PROTOCOL_CISCOVPN, ndpi_struct, NDPI_LOG_DEBUG, "search CISCOVPN.\n");
if(packet->tcp != NULL) { if(packet->tcp != NULL) {
tsport = ntohs(packet->tcp->source), tdport = ntohs(packet->tcp->dest); tsport = ntohs(packet->tcp->source), tdport = ntohs(packet->tcp->dest);
NDPI_LOG_DBG2(ndpi_struct, "calculated CISCOVPN over tcp ports\n"); NDPI_LOG(NDPI_PROTOCOL_CISCOVPN, ndpi_struct, NDPI_LOG_DEBUG, "calculated CISCOVPN over tcp ports.\n");
} }
if(packet->udp != NULL) { if(packet->udp != NULL) {
usport = ntohs(packet->udp->source), udport = ntohs(packet->udp->dest); usport = ntohs(packet->udp->source), udport = ntohs(packet->udp->dest);
NDPI_LOG_DBG2(ndpi_struct, "calculated CISCOVPN over udp ports\n"); NDPI_LOG(NDPI_PROTOCOL_CISCOVPN, ndpi_struct, NDPI_LOG_DEBUG, "calculated CISCOVPN over udp ports.\n");
} }
if((tdport == 10000 && tsport == 10000) || if((tdport == 10000 && tsport == 10000) ||
@@ -47,9 +42,8 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
{ {
/* This is a good query 17010000*/ /* This is a good query 17010000*/
NDPI_LOG_INFO(ndpi_struct, "found CISCOVPN\n"); NDPI_LOG(NDPI_PROTOCOL_CISCOVPN, ndpi_struct, NDPI_LOG_DEBUG, "found CISCOVPN.\n");
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow); ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
return;
} }
else if( else if(
( (
@@ -65,10 +59,11 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
/* This is a good query fe577e2b */ /* This is a good query fe577e2b */
NDPI_LOG_INFO(ndpi_struct, "found CISCOVPN\n"); NDPI_LOG(NDPI_PROTOCOL_CISCOVPN, ndpi_struct, NDPI_LOG_DEBUG, "found CISCOVPN.\n");
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow); ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
} else { } else {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_CISCOVPN, ndpi_struct, NDPI_LOG_DEBUG, "exclude CISCOVPN.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CISCOVPN);
} }
} }
+9 -12
View File
@@ -21,14 +21,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_CITRIX
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_CITRIX
#include "ndpi_api.h" #include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_CITRIX
/* ************************************ */ /* ************************************ */
@@ -49,25 +45,26 @@ static void ndpi_check_citrix(struct ndpi_detection_module_struct *ndpi_struct,
char citrix_header[] = { 0x07, 0x07, 0x49, 0x43, 0x41, 0x00 }; char citrix_header[] = { 0x07, 0x07, 0x49, 0x43, 0x41, 0x00 };
if(memcmp(packet->payload, citrix_header, sizeof(citrix_header)) == 0) { if(memcmp(packet->payload, citrix_header, sizeof(citrix_header)) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found citrix\n"); NDPI_LOG(NDPI_PROTOCOL_CITRIX, ndpi_struct, NDPI_LOG_DEBUG, "Found citrix.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_PROTOCOL_UNKNOWN);
} }
return; return;
} else if(payload_len > 4) { } else if(payload_len > 4) {
char citrix_header[] = { 0x1a, 0x43, 0x47, 0x50, 0x2f, 0x30, 0x31 }; char citrix_header[] = { 0x1a, 0x43, 0x47, 0x50, 0x2f, 0x30, 0x31 };
if((memcmp(packet->payload, citrix_header, sizeof(citrix_header)) == 0) if((memcmp(packet->payload, citrix_header, sizeof(citrix_header)) == 0)
|| (ndpi_strnstr((const char *)packet->payload, "Citrix.TcpProxyService", payload_len) != NULL)) { || (ndpi_strnstr((const char *)packet->payload, "Citrix.TcpProxyService", payload_len) != NULL)) {
NDPI_LOG_INFO(ndpi_struct, "found citrix\n"); NDPI_LOG(NDPI_PROTOCOL_CITRIX, ndpi_struct, NDPI_LOG_DEBUG, "Found citrix.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_PROTOCOL_UNKNOWN);
} }
return; return;
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CITRIX);
} else if(flow->l4.tcp.citrix_packet_id > 3) { } else if(flow->l4.tcp.citrix_packet_id > 3)
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CITRIX);
}
return; return;
} }
@@ -77,7 +74,7 @@ void ndpi_search_citrix(struct ndpi_detection_module_struct *ndpi_struct, struct
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search citrix\n"); NDPI_LOG(NDPI_PROTOCOL_CITRIX, ndpi_struct, NDPI_LOG_DEBUG, "citrix detection...\n");
/* skip marked packets */ /* skip marked packets */
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_CITRIX) if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_CITRIX)
+10 -12
View File
@@ -21,15 +21,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_COAP #ifdef NDPI_PROTOCOL_COAP
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_COAP
#include "ndpi_api.h"
#define CON 0 #define CON 0
#define NO_CON 1 #define NO_CON 1
#define ACK 2 #define ACK 2
@@ -120,13 +115,15 @@ void ndpi_search_coap (struct ndpi_detection_module_struct *ndpi_struct,
u_int16_t s_port = ntohs(flow->packet.udp->source); u_int16_t s_port = ntohs(flow->packet.udp->source);
u_int16_t d_port = ntohs(flow->packet.udp->dest); u_int16_t d_port = ntohs(flow->packet.udp->dest);
if((!isCoAPport(s_port) && !isCoAPport(d_port)) if((!isCoAPport(s_port) && !isCoAPport(s_port))
|| (packet->payload_packet_len < 4) ) { // header too short || (packet->payload_packet_len < 4) // header too short
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); ) {
NDPI_LOG(NDPI_PROTOCOL_COAP, ndpi_struct, NDPI_LOG_DEBUG, "excluding Coap\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_COAP);
return; return;
} }
NDPI_LOG_DBG2(ndpi_struct, "calculating coap over udp\n"); NDPI_LOG(NDPI_PROTOCOL_COAP, ndpi_struct, NDPI_LOG_DEBUG, "calculating coap over udp.\n");
// check values in header // check values in header
if(h->version == 1) { if(h->version == 1) {
@@ -136,7 +133,7 @@ void ndpi_search_coap (struct ndpi_detection_module_struct *ndpi_struct,
(h->code >= 128 && h->code <= 134) || (h->code >= 140 && h->code <= 143) || (h->code >= 128 && h->code <= 134) || (h->code >= 140 && h->code <= 143) ||
(h->code >= 160 && h->code <= 165)) { (h->code >= 160 && h->code <= 165)) {
NDPI_LOG_INFO(ndpi_struct, "found Coap\n"); NDPI_LOG(NDPI_PROTOCOL_COAP, ndpi_struct, NDPI_LOG_DEBUG, "Coap found...\n");
ndpi_int_coap_add_connection(ndpi_struct,flow); ndpi_int_coap_add_connection(ndpi_struct,flow);
return; return;
} }
@@ -145,7 +142,8 @@ void ndpi_search_coap (struct ndpi_detection_module_struct *ndpi_struct,
} }
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_COAP, ndpi_struct, NDPI_LOG_DEBUG, "Excluding Coap ...\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_COAP);
return; return;
} }
+5 -9
View File
@@ -19,21 +19,16 @@
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_COLLECTD #ifdef NDPI_PROTOCOL_COLLECTD
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_COLLECTD
#include "ndpi_api.h"
void ndpi_search_collectd(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) void ndpi_search_collectd(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
u_int len = 0; u_int len = 0;
NDPI_LOG_DBG(ndpi_struct, "search collectd\n"); NDPI_LOG(NDPI_PROTOCOL_COLLECTD, ndpi_struct, NDPI_LOG_DEBUG, "search collectd.\n");
if (packet->udp == NULL) return; if (packet->udp == NULL) return;
@@ -48,10 +43,11 @@ void ndpi_search_collectd(struct ndpi_detection_module_struct *ndpi_struct, stru
} }
if(len == packet->payload_packet_len) { if(len == packet->payload_packet_len) {
NDPI_LOG_INFO(ndpi_struct, "found COLLECTD\n"); NDPI_LOG(NDPI_PROTOCOL_COLLECTD, ndpi_struct, NDPI_LOG_DEBUG, "found COLLECTD.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_COLLECTD, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_COLLECTD, NDPI_PROTOCOL_UNKNOWN);
} else { } else {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_COLLECTD, ndpi_struct, NDPI_LOG_DEBUG, "exclude COLLECTD.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_COLLECTD);
} }
} }
+6 -9
View File
@@ -18,14 +18,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_CORBA
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_CORBA
#include "ndpi_api.h" #include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_CORBA
static void ndpi_int_corba_add_connection(struct ndpi_detection_module_struct static void ndpi_int_corba_add_connection(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow) *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
@@ -35,17 +31,18 @@ void ndpi_search_corba(struct ndpi_detection_module_struct *ndpi_struct, struct
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search for CORBA\n"); NDPI_LOG(NDPI_PROTOCOL_CORBA, ndpi_struct, NDPI_LOG_DEBUG, "search for CORBA.\n");
if(packet->tcp != NULL) { if(packet->tcp != NULL) {
NDPI_LOG_DBG2(ndpi_struct, "calculating CORBA over tcp\n"); NDPI_LOG(NDPI_PROTOCOL_CORBA, ndpi_struct, NDPI_LOG_DEBUG, "calculating CORBA over tcp.\n");
/* Corba General Inter-ORB Protocol -> GIOP */ /* Corba General Inter-ORB Protocol -> GIOP */
if ((packet->payload_packet_len >= 24 && packet->payload_packet_len <= 144) && if ((packet->payload_packet_len >= 24 && packet->payload_packet_len <= 144) &&
memcmp(packet->payload, "GIOP", 4) == 0) { memcmp(packet->payload, "GIOP", 4) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found corba\n"); NDPI_LOG(NDPI_PROTOCOL_CORBA, ndpi_struct, NDPI_LOG_DEBUG, "found corba.\n");
ndpi_int_corba_add_connection(ndpi_struct, flow); ndpi_int_corba_add_connection(ndpi_struct, flow);
} }
} else { } else {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_CORBA, ndpi_struct, NDPI_LOG_DEBUG, "exclude CORBA.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CORBA);
} }
} }
+14 -12
View File
@@ -21,14 +21,11 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
/* include files */
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_CROSSFIRE #ifdef NDPI_PROTOCOL_CROSSFIRE
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_CROSSFIRE
#include "ndpi_api.h"
static void ndpi_int_crossfire_add_connection(struct ndpi_detection_module_struct *ndpi_struct, static void ndpi_int_crossfire_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow/* , ndpi_protocol_type_t protocol_type */) struct ndpi_flow_struct *flow/* , ndpi_protocol_type_t protocol_type */)
@@ -41,14 +38,18 @@ void ndpi_search_crossfire_tcp_udp(struct ndpi_detection_module_struct *ndpi_str
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search crossfire\n"); // struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG(NDPI_PROTOCOL_CROSSFIRE, ndpi_struct, NDPI_LOG_DEBUG, "search crossfire.\n");
if (packet->udp != 0) { if (packet->udp != 0) {
if (packet->payload_packet_len == 25 if (packet->payload_packet_len == 25 && get_u_int32_t(packet->payload, 0) == ntohl(0xc7d91999)
&& get_u_int32_t(packet->payload, 0) == ntohl(0xc7d91999)
&& get_u_int16_t(packet->payload, 4) == ntohs(0x0200) && get_u_int16_t(packet->payload, 4) == ntohs(0x0200)
&& get_u_int16_t(packet->payload, 22) == ntohs(0x7d00)) { && get_u_int16_t(packet->payload, 22) == ntohs(0x7d00)
NDPI_LOG_INFO(ndpi_struct, "found Crossfire: udp packet\n"); ) {
NDPI_LOG(NDPI_PROTOCOL_CROSSFIRE, ndpi_struct, NDPI_LOG_DEBUG, "Crossfire: found udp packet.\n");
ndpi_int_crossfire_add_connection(ndpi_struct, flow); ndpi_int_crossfire_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -66,7 +67,7 @@ void ndpi_search_crossfire_tcp_udp(struct ndpi_detection_module_struct *ndpi_str
&& (memcmp(packet->host_line.ptr, "crossfire", 9) == 0 && (memcmp(packet->host_line.ptr, "crossfire", 9) == 0
|| memcmp(packet->host_line.ptr, "www.crossfire", 13) == 0)) || memcmp(packet->host_line.ptr, "www.crossfire", 13) == 0))
) { ) {
NDPI_LOG_DBG(ndpi_struct, "found Crossfire: HTTP request\n"); NDPI_LOG(NDPI_PROTOCOL_CROSSFIRE, ndpi_struct, NDPI_LOG_DEBUG, "Crossfire: found HTTP request.\n");
ndpi_int_crossfire_add_connection(ndpi_struct, flow); ndpi_int_crossfire_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -74,7 +75,8 @@ void ndpi_search_crossfire_tcp_udp(struct ndpi_detection_module_struct *ndpi_str
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_CROSSFIRE, ndpi_struct, NDPI_LOG_DEBUG, "exclude crossfire.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CROSSFIRE);
} }
-126
View File
@@ -1,126 +0,0 @@
/*
* csgo.c
*
* Copyright (C) 2016-2017 Vitaly Lavrov <vel21ripn@gmail.com>
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_CSGO
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_CSGO
#include "ndpi_api.h"
void ndpi_search_csgo(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow) {
struct ndpi_packet_struct* packet = &flow->packet;
if (packet->udp != NULL) {
uint32_t w = htonl(get_u_int32_t(packet->payload, 0));
NDPI_LOG_DBG2(ndpi_struct, "CSGO: word %08x\n", w);
if (!flow->csgo_state && packet->payload_packet_len == 23 && w == 0xfffffffful) {
if (!memcmp(packet->payload + 5, "connect0x", 9)) {
flow->csgo_state++;
memcpy(flow->csgo_strid, packet->payload + 5, 18);
NDPI_LOG_DBG2(ndpi_struct, "Found csgo connect0x\n");
return;
}
}
if (flow->csgo_state == 1 && packet->payload_packet_len >= 42 && w == 0xfffffffful) {
if (!memcmp(packet->payload + 24, flow->csgo_strid, 18)) {
flow->csgo_state++;
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
NDPI_LOG_INFO( ndpi_struct, "found csgo connect0x reply\n");
return;
}
}
if (packet->payload_packet_len == 8 && ( w == 0x3a180000 || w == 0x39180000) ) {
NDPI_LOG_INFO( ndpi_struct, "found csgo udp 8b\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
}
if (packet->payload_packet_len >= 36 && w == 0x56533031ul) {
NDPI_LOG_INFO( ndpi_struct, "found csgo udp\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
}
if (packet->payload_packet_len >= 36 && w == 0x01007364) {
uint32_t w2 = htonl(get_u_int32_t(packet->payload, 4));
if (w2 == 0x70696e67) {
NDPI_LOG_INFO( ndpi_struct, "found csgo udp ping\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
}
}
if (flow->csgo_s2 < 3 && (w & 0xffff0000ul) == 0x0d1d0000) {
uint32_t w2 = get_u_int32_t(packet->payload, 2);
if (packet->payload_packet_len == 13) {
if (!flow->csgo_s2) {
flow->csgo_id2 = w2;
flow->csgo_s2 = 1;
NDPI_LOG_DBG2( ndpi_struct, "Found csgo udp 0d1d step1\n");
return;
}
if (flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
NDPI_LOG_DBG2( ndpi_struct, "Found csgo udp 0d1d step1 DUP\n");
return;
}
flow->csgo_s2 = 3;
return;
}
if (packet->payload_packet_len == 15) {
if (flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
NDPI_LOG_INFO( ndpi_struct, "found csgo udp 0d1d\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
}
}
flow->csgo_s2 = 3;
}
if (packet->payload_packet_len >= 140 && (w == 0x02124c6c || w == 0x02125c6c) &&
!memcmp(&packet->payload[3], "lta\000mob\000tpc\000bhj\000bxd\000tae\000urg\000gkh\000", 32)) {
NDPI_LOG_INFO( ndpi_struct, "found csgo dictionary udp\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
}
if (packet->payload_packet_len >= 33 && packet->iph && packet->iph->daddr == 0xffffffff &&
!memcmp(&packet->payload[17], "LanSearch", 9)) {
NDPI_LOG_INFO( ndpi_struct, "found csgo LanSearch udp\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
}
}
if (flow->packet_counter > 20)
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
void init_csgo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("CSGO", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_CSGO,
ndpi_search_csgo,
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+5 -10
View File
@@ -21,14 +21,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_DCERPC
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DCERPC
#include "ndpi_api.h" #include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_DCERPC
static void ndpi_int_dcerpc_add_connection(struct ndpi_detection_module_struct static void ndpi_int_dcerpc_add_connection(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow) *ndpi_struct, struct ndpi_flow_struct *flow)
@@ -40,21 +36,20 @@ void ndpi_search_dcerpc(struct ndpi_detection_module_struct *ndpi_struct, struct
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search DCERPC\n");
if((packet->tcp != NULL) if((packet->tcp != NULL)
&& (packet->payload_packet_len >= 64) && (packet->payload_packet_len >= 64)
&& (packet->payload[0] == 0x05) /* version 5 */ && (packet->payload[0] == 0x05) /* version 5 */
&& (packet->payload[2] < 16) /* Packet type */ && (packet->payload[2] < 16) /* Packet type */
&& (((packet->payload[9]<<8) | packet->payload[8]) == packet->payload_packet_len) /* Packet Length */ && (((packet->payload[9]<<8) | packet->payload[8]) == packet->payload_packet_len) /* Packet Length */
) { ) {
NDPI_LOG_INFO(ndpi_struct, "found DCERPC\n"); NDPI_LOG(NDPI_PROTOCOL_DCERPC, ndpi_struct, NDPI_LOG_DEBUG, "DCERPC match\n");
ndpi_int_dcerpc_add_connection(ndpi_struct, flow); ndpi_int_dcerpc_add_connection(ndpi_struct, flow);
return; return;
} }
if(packet->payload_packet_len>1) if(packet->payload_packet_len>1){
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DCERPC);
}
} }
+15 -106
View File
@@ -1,7 +1,11 @@
/* /*
* dhcp.c * dhcp.c
* *
* Copyright (C) 2016 - ntop.org * Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
* *
* nDPI is free software: you can redistribute it and/or modify * nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
@@ -18,42 +22,11 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_DHCP #ifdef NDPI_PROTOCOL_DHCP
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DHCP
#include "ndpi_api.h"
/* freeradius/src/lib/dhcp.c */
#define DHCP_CHADDR_LEN 16
#define DHCP_SNAME_LEN 64
#define DHCP_FILE_LEN 128
#define DHCP_VEND_LEN 308
#define DHCP_OPTION_MAGIC_NUMBER 0x63825363
typedef struct {
uint8_t msgType;
uint8_t htype;
uint8_t hlen;
uint8_t hops;
uint32_t xid;/* 4 */
uint16_t secs;/* 8 */
uint16_t flags;
uint32_t ciaddr;/* 12 */
uint32_t yiaddr;/* 16 */
uint32_t siaddr;/* 20 */
uint32_t giaddr;/* 24 */
uint8_t chaddr[DHCP_CHADDR_LEN]; /* 28 */
uint8_t sname[DHCP_SNAME_LEN]; /* 44 */
uint8_t file[DHCP_FILE_LEN]; /* 108 */
uint32_t magic; /* 236 */
uint8_t options[DHCP_VEND_LEN];
} dhcp_packet_t;
static void ndpi_int_dhcp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_int_dhcp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DHCP, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DHCP, NDPI_PROTOCOL_UNKNOWN);
@@ -64,89 +37,25 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search DHCP\n"); // struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
/* this detection also works for asymmetric dhcp traffic */ /* this detection also works for asymmetric dhcp traffic */
/*check standard DHCP 0.0.0.0:68 -> 255.255.255.255:67 */ /*check standard DHCP 0.0.0.0:68 -> 255.255.255.255:67 */
if(packet->udp) { if (packet->payload_packet_len >= 244 && (packet->udp->source == htons(67)
dhcp_packet_t *dhcp = (dhcp_packet_t*)packet->payload; || packet->udp->source == htons(68))
if((packet->payload_packet_len >= 244 /* 244 is the offset of options[0] in dhcp_packet_t */)
&& (packet->udp->source == htons(67) || packet->udp->source == htons(68))
&& (packet->udp->dest == htons(67) || packet->udp->dest == htons(68)) && (packet->udp->dest == htons(67) || packet->udp->dest == htons(68))
&& (dhcp->magic == htonl(DHCP_OPTION_MAGIC_NUMBER))) { && get_u_int32_t(packet->payload, 236) == htonl(0x63825363)
u_int i = 0, foundValidMsgType = 0; && get_u_int16_t(packet->payload, 240) == htons(0x3501)) {
u_int dhcp_options_size = ndpi_min(DHCP_VEND_LEN /* maximum size of options in dhcp_packet_t */, NDPI_LOG(NDPI_PROTOCOL_DHCP, ndpi_struct, NDPI_LOG_DEBUG, "DHCP request\n");
packet->payload_packet_len - 244);
while(i + 1 /* for the len */ < dhcp_options_size) {
u_int8_t id = dhcp->options[i];
if(id == 0xFF)
break;
else {
/* Prevent malformed packets to cause out-of-bounds accesses */
u_int8_t len = ndpi_min(dhcp->options[i+1] /* len as found in the packet */,
dhcp_options_size - (i+2) /* 1 for the type and 1 for the value */);
if(len == 0) break;
#ifdef DHCP_DEBUG
NDPI_LOG_DBG2(ndpi_struct, "[DHCP] Id=%d [len=%d]\n", id, len);
#endif
if(id == 53 /* DHCP Message Type */) {
u_int8_t msg_type = dhcp->options[i+2];
if(msg_type <= 8) foundValidMsgType = 1;
} else if(id == 55 /* Parameter Request List / Fingerprint */) {
u_int idx, offset = 0;
for(idx = 0; idx < len && offset < sizeof(flow->protos.dhcp.fingerprint) - 2; idx++) {
snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
sizeof(flow->protos.dhcp.fingerprint) - offset,
"%02X", dhcp->options[i+2+idx] & 0xFF);
offset += 2;
}
flow->protos.dhcp.fingerprint[sizeof(flow->protos.dhcp.fingerprint) - 1] = '\0';
} else if(id == 60 /* Class Identifier */) {
char *name = (char*)&dhcp->options[i+2];
int j = 0;
j = ndpi_min(len, sizeof(flow->protos.dhcp.class_ident)-1);
strncpy((char*)flow->protos.dhcp.class_ident, name, j);
flow->protos.dhcp.class_ident[j] = '\0';
} else if(id == 12 /* Host Name */) {
char *name = (char*)&dhcp->options[i+2];
int j = 0;
#ifdef DHCP_DEBUG
NDPI_LOG_DBG2(ndpi_struct, "[DHCP] '%.*s'\n",name,len);
// while(j < len) { printf( "%c", name[j]); j++; }; printf("\n");
#endif
j = ndpi_min(len, sizeof(flow->host_server_name)-1);
strncpy((char*)flow->host_server_name, name, j);
flow->host_server_name[j] = '\0';
}
i += len + 2;
}
}
//get_u_int16_t(packet->payload, 240) == htons(0x3501)) {
if(foundValidMsgType) {
NDPI_LOG_INFO(ndpi_struct, "found DHCP\n");
ndpi_int_dhcp_add_connection(ndpi_struct, flow); ndpi_int_dhcp_add_connection(ndpi_struct, flow);
}
return; return;
} }
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DHCP);
} }
+9 -9
View File
@@ -22,15 +22,13 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
/* include files */
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_DHCPV6 #ifdef NDPI_PROTOCOL_DHCPV6
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DHCPV6
#include "ndpi_api.h"
static void ndpi_int_dhcpv6_add_connection(struct ndpi_detection_module_struct *ndpi_struct, static void ndpi_int_dhcpv6_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) struct ndpi_flow_struct *flow)
{ {
@@ -42,19 +40,21 @@ void ndpi_search_dhcpv6_udp(struct ndpi_detection_module_struct *ndpi_struct, st
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search DHCPv6\n"); // struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
if (packet->payload_packet_len >= 4 && if (packet->payload_packet_len >= 4 &&
(packet->udp->source == htons(546) || packet->udp->source == htons(547)) && (packet->udp->source == htons(546) || packet->udp->source == htons(547)) &&
(packet->udp->dest == htons(546) || packet->udp->dest == htons(547)) && (packet->udp->dest == htons(546) || packet->udp->dest == htons(547)) &&
packet->payload[0] >= 1 && packet->payload[0] <= 13) { packet->payload[0] >= 1 && packet->payload[0] <= 13) {
NDPI_LOG_INFO(ndpi_struct, "found DHCPv6\n"); NDPI_LOG(NDPI_PROTOCOL_DHCPV6, ndpi_struct, NDPI_LOG_DEBUG, "DHCPv6 detected.\n");
ndpi_int_dhcpv6_add_connection(ndpi_struct, flow); ndpi_int_dhcpv6_add_connection(ndpi_struct, flow);
return; return;
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_DHCPV6, ndpi_struct, NDPI_LOG_DEBUG, "DHCPv6 excluded.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DHCPV6);
} }
-132
View File
@@ -1,132 +0,0 @@
/*
* aimini.c
*
* Copyright (C) 2018 - ntop.org
* Written by Michele Campus - <campus@ntop.org>
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_DIAMETER
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DIAMETER
#include "ndpi_api.h"
// Header Flags possibile values
#define REQUEST 0X80
#define PROXYABLE 0X40
#define ERROR 0X20
#define RETRASM 0X10
typedef enum {
AC = 271,
AS = 274,
CC = 272,
CE = 257,
DW = 280,
DP = 282,
RA = 258,
ST = 275
} com_type_t;
#define DIAM_HEADER_LEN 20
// DIAMETER header
struct diameter_header_t
{
u_int8_t version;
u_int8_t length[3];
u_int8_t flags;
u_int8_t com_code[3];
u_int32_t app_id;
u_int32_t hop_id;
u_int32_t end_id;
};
// Check packet
int is_diameter(struct ndpi_packet_struct *packet, int size_payload)
{
// check param
if(!packet || size_payload == 0) return -1;
// cast to diameter header
struct diameter_header_t *diameter = (struct diameter_header_t *) packet;
// check if the packet is diameter
if(diameter->version == 0x01 &&
(diameter->flags == REQUEST ||
diameter->flags == PROXYABLE ||
diameter->flags == ERROR ||
diameter->flags == RETRASM)) {
u_int16_t com_code = diameter->com_code[2] + (diameter->com_code[1] << 8) + (diameter->com_code[0] << 8);
if(com_code == AC || com_code == AS ||
com_code == CC || com_code == CE ||
com_code == DW || com_code == DP ||
com_code == RA || com_code == ST)
return 0; // OK
}
// wrong packet
return -2;
}
void ndpi_search_diameter(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
// Diameter is on TCP
if(packet->tcp) {
/* Check if it's diameter */
int ret = is_diameter(packet, packet->payload_packet_len);
if(ret != 0) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
else {
NDPI_LOG_INFO(ndpi_struct, "found Diameter\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIAMETER, NDPI_PROTOCOL_UNKNOWN);
}
}
else { // UDP
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
}
void init_diameter_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id,
NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("Diameter", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_DIAMETER, ndpi_search_diameter,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN, ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif /* NDPI_PROTOCOL_DIAMETER */
+83 -46
View File
@@ -23,15 +23,9 @@
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_DIRECTCONNECT #ifdef NDPI_PROTOCOL_DIRECTCONNECT
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DIRECTCONNECT
#include "ndpi_api.h"
//#define NDPI_DEBUG_DIRECTCONNECT //#define NDPI_DEBUG_DIRECTCONNECT
//#define NDPI_DIRECTCONNECT_PORT_DEBUG //#define NDPI_DIRECTCONNECT_PORT_DEBUG
//#define NDPI_DEBUG_DIRECTCONNECT_CONN //#define NDPI_DEBUG_DIRECTCONNECT_CONN
@@ -64,7 +58,9 @@ static u_int16_t parse_binf_message(struct ndpi_detection_module_struct
if (memcmp(&payload[i], "DCTM", 4) == 0) { if (memcmp(&payload[i], "DCTM", 4) == 0) {
if (memcmp(&payload[i + 15], "ADCS", 4) == 0) { if (memcmp(&payload[i + 15], "ADCS", 4) == 0) {
ssl_port = ntohs_ndpi_bytestream_to_number(&payload[i + 25], 5, &bytes_read); ssl_port = ntohs_ndpi_bytestream_to_number(&payload[i + 25], 5, &bytes_read);
NDPI_LOG_DBG2(ndpi_struct, "DC ssl port parsed %d\n", ssl_port); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect ssl port parsed %d", ssl_port);
} }
} }
} else { } else {
@@ -93,11 +89,13 @@ static void ndpi_int_directconnect_add_connection(struct ndpi_detection_module_s
if (packet->tcp != NULL if (packet->tcp != NULL
&& flow->setup_packet_direction != packet->packet_direction && src->detected_directconnect_port == 0) { && flow->setup_packet_direction != packet->packet_direction && src->detected_directconnect_port == 0) {
src->detected_directconnect_port = packet->tcp->source; src->detected_directconnect_port = packet->tcp->source;
NDPI_LOG_DBG2(ndpi_struct, "DC tcp PORT %u for src\n", ntohs(src->detected_directconnect_port)); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect tcp PORT %u for src\n", ntohs(src->detected_directconnect_port));
} }
if (packet->udp != NULL && src->detected_directconnect_udp_port == 0) { if (packet->udp != NULL && src->detected_directconnect_udp_port == 0) {
src->detected_directconnect_udp_port = packet->udp->source; src->detected_directconnect_udp_port = packet->udp->source;
NDPI_LOG_DBG2(ndpi_struct, "DC udp PORT %u for src\n", ntohs(src->detected_directconnect_port)); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect udp PORT %u for src\n", ntohs(src->detected_directconnect_port));
} }
} }
@@ -115,8 +113,8 @@ static void ndpi_int_directconnect_add_connection(struct ndpi_detection_module_s
/* /*
dst->detected_directconnect_port = packet->tcp->dest; dst->detected_directconnect_port = packet->tcp->dest;
NDPI_LOG_DBG2(ndpi_struct, NDPI_LOG (NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
"DC tcp PORT %u for dst\n", NDPI_LOG_DEBUG, "directconnect tcp PORT %u for dst\n",
ntohs (dst->detected_directconnect_port)); ntohs (dst->detected_directconnect_port));
*/ */
} }
@@ -150,12 +148,14 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
if (dst != NULL) { if (dst != NULL) {
dst->detected_directconnect_ssl_port = dst->detected_directconnect_ssl_port =
ntohs_ndpi_bytestream_to_number(&packet->payload[25], 5, &bytes_read); ntohs_ndpi_bytestream_to_number(&packet->payload[25], 5, &bytes_read);
NDPI_LOG_DBG2(ndpi_struct, "DC ssl port parsed %d\n", ntohs(dst->detected_directconnect_ssl_port)); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect ssl port parsed %d", ntohs(dst->detected_directconnect_ssl_port));
} }
if (src != NULL) { if (src != NULL) {
src->detected_directconnect_ssl_port = src->detected_directconnect_ssl_port =
ntohs_ndpi_bytestream_to_number(&packet->payload[25], 5, &bytes_read); ntohs_ndpi_bytestream_to_number(&packet->payload[25], 5, &bytes_read);
NDPI_LOG_DBG2(ndpi_struct, "DC ssl port parsed %d\n", ntohs(src->detected_directconnect_ssl_port)); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect ssl port parsed %d", ntohs(src->detected_directconnect_ssl_port));
} }
@@ -168,13 +168,15 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
if ((u_int32_t) if ((u_int32_t)
(packet->tick_timestamp - (packet->tick_timestamp -
src->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) { src->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
src->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG_INFO(ndpi_struct, "found DC using port %d\n", ntohs(src->detected_directconnect_port));
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN); ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
src->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "marking using dc port\n %d", ntohs(src->detected_directconnect_port));
return; return;
} else { } else {
src->detected_directconnect_port = 0; src->detected_directconnect_port = 0;
NDPI_LOG_DBG2(ndpi_struct, "resetting src port due to timeout\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "resetting src port due to timeout");
return; return;
} }
} }
@@ -182,13 +184,15 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
if ((u_int32_t) if ((u_int32_t)
(packet->tick_timestamp - (packet->tick_timestamp -
src->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) { src->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
src->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG_INFO(ndpi_struct, "found DC using port %d\n", ntohs(src->detected_directconnect_ssl_port));
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN); ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
src->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "marking using dc port\n %d", ntohs(src->detected_directconnect_ssl_port));
return; return;
} else { } else {
src->detected_directconnect_ssl_port = 0; src->detected_directconnect_ssl_port = 0;
NDPI_LOG_DBG2(ndpi_struct, "resetting src port due to timeout\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "resetting src port due to timeout");
return; return;
} }
} }
@@ -200,13 +204,15 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
if ((u_int32_t) if ((u_int32_t)
(packet->tick_timestamp - (packet->tick_timestamp -
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) { dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG_INFO(ndpi_struct, "found DC using port %d\n", ntohs(dst->detected_directconnect_port));
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "marking using dc port\n %d", ntohs(dst->detected_directconnect_port));
return; return;
} else { } else {
dst->detected_directconnect_port = 0; dst->detected_directconnect_port = 0;
NDPI_LOG_DBG(ndpi_struct, "resetting dst port due to timeout\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "resetting dst port due to timeout");
return; return;
} }
} }
@@ -214,13 +220,16 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
if ((u_int32_t) if ((u_int32_t)
(packet->tick_timestamp - (packet->tick_timestamp -
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) { dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG_DBG(ndpi_struct, "found DC using port %d\n", ntohs(dst->detected_directconnect_ssl_port));
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "marking using dc port\n %d", ntohs(dst->detected_directconnect_ssl_port));
return; return;
} else { } else {
dst->detected_directconnect_ssl_port = 0; dst->detected_directconnect_ssl_port = 0;
NDPI_LOG_DBG2(ndpi_struct, "resetting dst port due to timeout\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "resetting dst port due to timeout");
return; return;
} }
} }
@@ -233,7 +242,8 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
if (packet->payload[0] == '$' if (packet->payload[0] == '$'
&& packet->payload[packet->payload_packet_len - 1] == '|' && packet->payload[packet->payload_packet_len - 1] == '|'
&& (memcmp(&packet->payload[1], "Lock ", 5) == 0)) { && (memcmp(&packet->payload[1], "Lock ", 5) == 0)) {
NDPI_LOG_DBG2(ndpi_struct, "maybe first dc connect to hub detected\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "maybe first dc connect to hub detected\n");
flow->directconnect_stage = 1; flow->directconnect_stage = 1;
return; return;
} }
@@ -241,7 +251,8 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
&& packet->payload[0] == '$' && packet->payload[0] == '$'
&& packet->payload[packet->payload_packet_len - 1] == '|' && packet->payload[packet->payload_packet_len - 1] == '|'
&& (memcmp(&packet->payload[1], "MyNick ", 7) == 0)) { && (memcmp(&packet->payload[1], "MyNick ", 7) == 0)) {
NDPI_LOG_DBG2(ndpi_struct, "maybe first dc connect between peers detected\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "maybe first dc connect between peers detected\n");
flow->directconnect_stage = 2; flow->directconnect_stage = 2;
return; return;
} }
@@ -251,13 +262,15 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
/* did not see this pattern in any trace */ /* did not see this pattern in any trace */
if (memcmp(&packet->payload[0], "HSUP ADBAS0", 11) == 0 if (memcmp(&packet->payload[0], "HSUP ADBAS0", 11) == 0
|| memcmp(&packet->payload[0], "HSUP ADBASE", 11) == 0) { || memcmp(&packet->payload[0], "HSUP ADBASE", 11) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found DC HSUP ADBAS0 E\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "found directconnect HSUP ADBAS0 E\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_HUB); ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_HUB);
return; return;
/* did not see this pattern in any trace */ /* did not see this pattern in any trace */
} else if (memcmp(&packet->payload[0], "CSUP ADBAS0", 11) == 0 || } else if (memcmp(&packet->payload[0], "CSUP ADBAS0", 11) == 0 ||
memcmp(&packet->payload[0], "CSUP ADBASE", 11) == 0) { memcmp(&packet->payload[0], "CSUP ADBASE", 11) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found DC CSUP ADBAS0 E\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "found directconnect CSUP ADBAS0 E\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_ADC_PEER); ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_ADC_PEER);
return; return;
@@ -270,14 +283,19 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
/* did not see this pattern in any trace */ /* did not see this pattern in any trace */
if (memcmp(&packet->payload[0], "HSUP ADBAS0", 11) == 0 if (memcmp(&packet->payload[0], "HSUP ADBAS0", 11) == 0
|| memcmp(&packet->payload[0], "HSUP ADBASE", 11) == 0) { || memcmp(&packet->payload[0], "HSUP ADBASE", 11) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found DC HSUP ADBAS E in second packet\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "found directconnect HSUP ADBAS E in second packet\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_HUB); ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_HUB);
return; return;
/* did not see this pattern in any trace */ /* did not see this pattern in any trace */
} else if (memcmp(&packet->payload[0], "CSUP ADBAS0", 11) == 0 || } else if (memcmp(&packet->payload[0], "CSUP ADBAS0", 11) == 0 ||
memcmp(&packet->payload[0], "CSUP ADBASE", 11) == 0) { memcmp(&packet->payload[0], "CSUP ADBASE", 11) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found DC HSUP ADBAS0 E in second packet\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "found directconnect HSUP ADBAS0 E in second packet\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_ADC_PEER); ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_ADC_PEER);
return; return;
} }
@@ -286,11 +304,12 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
if (packet->payload_packet_len > 6) { if (packet->payload_packet_len > 6) {
if ((packet->payload[0] == '$' || packet->payload[0] == '<') if ((packet->payload[0] == '$' || packet->payload[0] == '<')
&& packet->payload[packet->payload_packet_len - 1] == '|') { && packet->payload[packet->payload_packet_len - 1] == '|') {
NDPI_LOG_INFO(ndpi_struct, "found DC second\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct, NDPI_LOG_DEBUG, "second dc detected\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_HUB); ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_HUB);
return; return;
} else { } else {
NDPI_LOG_DBG2(ndpi_struct, "second dc not detected\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct, NDPI_LOG_DEBUG, "second dc not detected\n");
} }
} }
@@ -298,17 +317,23 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
/* get client hello answer or server message */ /* get client hello answer or server message */
if (packet->payload_packet_len > 6) { if (packet->payload_packet_len > 6) {
if (packet->payload[0] == '$' && packet->payload[packet->payload_packet_len - 1] == '|') { if (packet->payload[0] == '$' && packet->payload[packet->payload_packet_len - 1] == '|') {
NDPI_LOG_INFO(ndpi_struct, "found DC between peers\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "second dc between peers detected\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_PEER); ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_PEER);
return; return;
} else { } else {
NDPI_LOG_DBG2(ndpi_struct, "second dc between peers not detected\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "second dc between peers not detected\n");
} }
} }
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DIRECTCONNECT);
} }
@@ -327,13 +352,15 @@ static void ndpi_search_directconnect_udp(struct ndpi_detection_module_struct
(packet->tick_timestamp - (packet->tick_timestamp -
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) { dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG_INFO(ndpi_struct, "found DC using udp port %d\n", ntohs(dst->detected_directconnect_udp_port));
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "marking using dc udp port\n %d", ntohs(dst->detected_directconnect_udp_port));
return; return;
} else { } else {
dst->detected_directconnect_udp_port = 0; dst->detected_directconnect_udp_port = 0;
NDPI_LOG_DBG2(ndpi_struct, "resetting dst udp port due to timeout\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "resetting dst udp port due to timeout");
return; return;
} }
} }
@@ -353,18 +380,23 @@ static void ndpi_search_directconnect_udp(struct ndpi_detection_module_struct
if (packet->payload[pos] == '(') { if (packet->payload[pos] == '(') {
pos = pos - 44; pos = pos - 44;
if (pos > 2 && memcmp(&packet->payload[pos], "TTH:", 4) == 0) { if (pos > 2 && memcmp(&packet->payload[pos], "TTH:", 4) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found DC udp\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct, NDPI_LOG_DEBUG, "dc udp detected\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_PEER); ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_PEER);
return; return;
} }
} }
} }
flow->directconnect_stage++; flow->directconnect_stage++;
if (flow->directconnect_stage < 3)
if (flow->directconnect_stage < 3) {
return; return;
} }
} }
}
if (dst != NULL if (dst != NULL
&& NDPI_COMPARE_PROTOCOL_TO_BITMASK(dst->detected_protocol_bitmask, NDPI_PROTOCOL_DIRECTCONNECT)) { && NDPI_COMPARE_PROTOCOL_TO_BITMASK(dst->detected_protocol_bitmask, NDPI_PROTOCOL_DIRECTCONNECT)) {
if (packet->payload[0] == '$' if (packet->payload[0] == '$'
@@ -379,7 +411,7 @@ static void ndpi_search_directconnect_udp(struct ndpi_detection_module_struct
if (packet->payload[pos] == '(') { if (packet->payload[pos] == '(') {
pos = pos - 44; pos = pos - 44;
if (pos > 2 && memcmp(&packet->payload[pos], "TTH:", 4) == 0) { if (pos > 2 && memcmp(&packet->payload[pos], "TTH:", 4) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found DC udp\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct, NDPI_LOG_DEBUG, "dc udp detected\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_PEER); ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_PEER);
return; return;
} }
@@ -388,11 +420,15 @@ static void ndpi_search_directconnect_udp(struct ndpi_detection_module_struct
flow->directconnect_stage++; flow->directconnect_stage++;
if (flow->directconnect_stage < 3) if (flow->directconnect_stage < 3)
return; return;
} }
} }
} }
NDPI_LOG_DBG(ndpi_struct, "excluded DC at stage %d \n", flow->directconnect_stage); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct, NDPI_LOG_DEBUG,
"excluded at stage %d \n", flow->directconnect_stage);
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DIRECTCONNECT); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DIRECTCONNECT);
@@ -406,7 +442,7 @@ void ndpi_search_directconnect(struct ndpi_detection_module_struct
struct ndpi_id_struct *src = flow->src; struct ndpi_id_struct *src = flow->src;
struct ndpi_id_struct *dst = flow->dst; struct ndpi_id_struct *dst = flow->dst;
NDPI_LOG_DBG(ndpi_struct, "search DC\n");
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_DIRECTCONNECT) { if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_DIRECTCONNECT) {
if (src != NULL && ((u_int32_t) if (src != NULL && ((u_int32_t)
@@ -422,7 +458,8 @@ void ndpi_search_directconnect(struct ndpi_detection_module_struct
dst->directconnect_last_safe_access_time = packet->tick_timestamp; dst->directconnect_last_safe_access_time = packet->tick_timestamp;
} else { } else {
packet->detected_protocol_stack[0] = NDPI_PROTOCOL_UNKNOWN; packet->detected_protocol_stack[0] = NDPI_PROTOCOL_UNKNOWN;
NDPI_LOG_DBG2(ndpi_struct, "skipping as unknown due to timeout\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect: skipping as unknown due to timeout\n");
} }
return; return;
} }
+19 -17
View File
@@ -23,14 +23,9 @@
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK #ifdef NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK
#include "ndpi_api.h"
#ifdef NDPI_DEBUG_DIRECT_DOWNLOAD_LINK #ifdef NDPI_DEBUG_DIRECT_DOWNLOAD_LINK
//#define NDPI_DEBUG_DIRECT_DOWNLOAD_LINK_NOTHING_FOUND //#define NDPI_DEBUG_DIRECT_DOWNLOAD_LINK_NOTHING_FOUND
@@ -57,12 +52,15 @@ static void ndpi_int_direct_download_link_add_connection(struct ndpi_detection_m
u_int8_t search_ddl_domains(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) u_int8_t search_ddl_domains(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
u_int16_t filename_start = 0; u_int16_t filename_start = 0;
u_int8_t i = 1; u_int8_t i = 1;
u_int16_t host_line_len_without_port; u_int16_t host_line_len_without_port;
if (packet->payload_packet_len < 100) { if (packet->payload_packet_len < 100) {
NDPI_LOG_DBG2(ndpi_struct, "DDL: Packet too small\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: Packet too small.\n");
goto end_ddl_nothing_found; goto end_ddl_nothing_found;
} }
@@ -70,10 +68,10 @@ u_int8_t search_ddl_domains(struct ndpi_detection_module_struct *ndpi_struct, st
if (memcmp(packet->payload, "POST ", 5) == 0) { if (memcmp(packet->payload, "POST ", 5) == 0) {
filename_start = 5; // POST filename_start = 5; // POST
NDPI_LOG_DBG2(ndpi_struct, "DDL: POST FOUND\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: POST FOUND\n");
} else if (memcmp(packet->payload, "GET ", 4) == 0) { } else if (memcmp(packet->payload, "GET ", 4) == 0) {
filename_start = 4; // GET filename_start = 4; // GET
NDPI_LOG_DBG2(ndpi_struct, "DDL: GET FOUND\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: GET FOUND\n");
} else { } else {
goto end_ddl_nothing_found; goto end_ddl_nothing_found;
} }
@@ -81,15 +79,16 @@ u_int8_t search_ddl_domains(struct ndpi_detection_module_struct *ndpi_struct, st
ndpi_parse_packet_line_info(ndpi_struct, flow); ndpi_parse_packet_line_info(ndpi_struct, flow);
if (packet->host_line.ptr == NULL) { if (packet->host_line.ptr == NULL) {
NDPI_LOG_DBG2(ndpi_struct, "DDL: NO HOST FOUND\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: NO HOST FOUND\n");
goto end_ddl_nothing_found; goto end_ddl_nothing_found;
} }
NDPI_LOG_DBG2(ndpi_struct, "DDL: Host: found\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: Host: found\n");
if (packet->line[0].len < 9 + filename_start if (packet->line[0].len < 9 + filename_start
|| memcmp(&packet->line[0].ptr[packet->line[0].len - 9], " HTTP/1.", 8) != 0) { || memcmp(&packet->line[0].ptr[packet->line[0].len - 9], " HTTP/1.", 8) != 0) {
NDPI_LOG_DBG2(ndpi_struct, "DDL: PACKET NOT HTTP CONFORM.\nXXX%.*sXXX\n", NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct,
NDPI_LOG_DEBUG, "DDL: PACKET NOT HTTP CONFORM.\nXXX%.*sXXX\n",
8, &packet->line[0].ptr[packet->line[0].len - 9]); 8, &packet->line[0].ptr[packet->line[0].len - 9]);
goto end_ddl_nothing_found; goto end_ddl_nothing_found;
} }
@@ -101,11 +100,11 @@ u_int8_t search_ddl_domains(struct ndpi_detection_module_struct *ndpi_struct, st
i = 2; i = 2;
while (host_line_len_without_port >= i && packet->host_line.ptr[host_line_len_without_port - i] >= '0' while (host_line_len_without_port >= i && packet->host_line.ptr[host_line_len_without_port - i] >= '0'
&& packet->host_line.ptr[host_line_len_without_port - i] <= '9') { && packet->host_line.ptr[host_line_len_without_port - i] <= '9') {
NDPI_LOG_DBG2(ndpi_struct, "DDL: number found\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: number found\n");
i++; i++;
} }
if (host_line_len_without_port >= i && packet->host_line.ptr[host_line_len_without_port - i] == ':') { if (host_line_len_without_port >= i && packet->host_line.ptr[host_line_len_without_port - i] == ':') {
NDPI_LOG_DBG2(ndpi_struct, "DDL: ':' found\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: ':' found\n");
host_line_len_without_port = host_line_len_without_port - i; host_line_len_without_port = host_line_len_without_port - i;
} }
} }
@@ -695,12 +694,12 @@ u_int8_t search_ddl_domains(struct ndpi_detection_module_struct *ndpi_struct, st
*/ */
end_ddl_nothing_found: end_ddl_nothing_found:
NDPI_LOG_DBG2(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG,
"Nothing Found\n"); "Nothing Found\n");
return 0; return 0;
end_ddl_found: end_ddl_found:
NDPI_LOG_INFO(ndpi_struct, "found DIRECT DOWNLOAD LINK\n"); NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: DIRECT DOWNLOAD LINK FOUND\n");
ndpi_int_direct_download_link_add_connection(ndpi_struct, flow); ndpi_int_direct_download_link_add_connection(ndpi_struct, flow);
return 1; return 1;
} }
@@ -710,12 +709,15 @@ void ndpi_search_direct_download_link_tcp(struct ndpi_detection_module_struct *n
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
/* struct ndpi_id_struct *src=ndpi_struct->src; */
/* struct ndpi_id_struct *dst=ndpi_struct->dst; */
/* do not detect again if it is already ddl */ /* do not detect again if it is already ddl */
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK) { if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK) {
if (search_ddl_domains(ndpi_struct, flow) != 0) { if (search_ddl_domains(ndpi_struct, flow) != 0) {
return; return;
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK);
} }
} }
+17 -19
View File
@@ -21,15 +21,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_DNS #ifdef NDPI_PROTOCOL_DNS
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DNS
#include "ndpi_api.h"
#define FLAGS_MASK 0x8000 #define FLAGS_MASK 0x8000
/* #define DNS_DEBUG 1 */ /* #define DNS_DEBUG 1 */
@@ -69,7 +64,7 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
u_int8_t is_query; u_int8_t is_query;
u_int16_t s_port = 0, d_port = 0; u_int16_t s_port = 0, d_port = 0;
NDPI_LOG_DBG(ndpi_struct, "search DNS\n"); NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "search DNS.\n");
if(flow->packet.udp != NULL) { if(flow->packet.udp != NULL) {
s_port = ntohs(flow->packet.udp->source); s_port = ntohs(flow->packet.udp->source);
@@ -80,12 +75,12 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
d_port = ntohs(flow->packet.tcp->dest); d_port = ntohs(flow->packet.tcp->dest);
x = 2; x = 2;
} else { } else {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "exclude DNS.\n");
return; NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DNS);
} }
if((s_port == 53 || d_port == 53 || d_port == 5355) if((s_port == 53 || d_port == 53 || d_port == 5355)
&& (flow->packet.payload_packet_len > sizeof(struct ndpi_dns_packet_header)+x)) { && (flow->packet.payload_packet_len > sizeof(struct ndpi_dns_packet_header))) {
struct ndpi_dns_packet_header dns_header; struct ndpi_dns_packet_header dns_header;
int invalid = 0; int invalid = 0;
@@ -121,7 +116,7 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
x++; x++;
flow->protos.dns.query_type = get16(&x, flow->packet.payload); flow->protos.dns.query_type = get16(&x, flow->packet.payload);
#ifdef DNS_DEBUG #ifdef DNS_DEBUG
NDPI_LOG_DBG2(ndpi_struct, "query_type=%2d\n", flow->protos.dns.query_type); printf("[%s:%d] query_type=%2d\n", __FILE__, __LINE__, flow->protos.dns.query_type);
#endif #endif
break; break;
} else } else
@@ -182,14 +177,15 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
} }
if(invalid) { if(invalid) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "exclude DNS.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DNS);
return; return;
} }
/* extract host name server */ /* extract host name server */
int j = 0, max_len = sizeof(flow->host_server_name)-1, off = sizeof(struct ndpi_dns_packet_header) + 1; int j = 0, max_len = sizeof(flow->host_server_name)-1, off = sizeof(struct ndpi_dns_packet_header) + 1;
while(off < flow->packet.payload_packet_len && flow->packet.payload[off] != '\0') { while(flow->packet.payload[off] != '\0' && off < flow->packet.payload_packet_len) {
flow->host_server_name[j] = flow->packet.payload[off]; flow->host_server_name[j] = flow->packet.payload[off];
if(j < max_len) { if(j < max_len) {
if(flow->host_server_name[j] < ' ') if(flow->host_server_name[j] < ' ')
@@ -201,9 +197,6 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
off++; off++;
} }
if(is_query && ndpi_struct->dns_dissect_response)
return; /* The response will set the verdict */
flow->host_server_name[j] = '\0'; flow->host_server_name[j] = '\0';
flow->protos.dns.num_queries = (u_int8_t)dns_header.num_queries, flow->protos.dns.num_queries = (u_int8_t)dns_header.num_queries,
@@ -216,21 +209,26 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
NDPI_PROTOCOL_DNS); NDPI_PROTOCOL_DNS);
#ifdef DNS_DEBUG #ifdef DNS_DEBUG
NDPI_LOG_DBG2(ndpi_struct, "[num_queries=%d][num_answers=%d][reply_code=%u][rsp_type=%u][host_server_name=%s]\n", printf("[%s:%d] [num_queries=%d][num_answers=%d][reply_code=%u][rsp_type=%u][host_server_name=%s]\n",
__FILE__, __LINE__,
flow->protos.dns.num_queries, flow->protos.dns.num_answers, flow->protos.dns.num_queries, flow->protos.dns.num_answers,
flow->protos.dns.reply_code, flow->protos.dns.rsp_type, flow->host_server_name flow->protos.dns.reply_code, flow->protos.dns.rsp_type, flow->host_server_name
); );
#endif #endif
if(flow->packet.detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) { if(flow->packet.detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
if(is_query && ndpi_struct->dns_dissect_response)
return; /* The response will set the verdict */
/** /**
Do not set the protocol with DNS if ndpi_match_host_subprotocol() has Do not set the protocol with DNS if ndpi_match_host_subprotocol() has
matched a subprotocol matched a subprotocol
**/ **/
NDPI_LOG_INFO(ndpi_struct, "found DNS\n"); NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "found DNS.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, (d_port == 5355) ? NDPI_PROTOCOL_LLMNR : NDPI_PROTOCOL_DNS, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, (d_port == 5355) ? NDPI_PROTOCOL_LLMNR : NDPI_PROTOCOL_DNS, NDPI_PROTOCOL_UNKNOWN);
} else { } else {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "exclude DNS.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DNS);
} }
} }
} }
+47 -41
View File
@@ -22,69 +22,77 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_DOFUS
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DOFUS
#include "ndpi_api.h" #include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_DOFUS
static void ndpi_dofus_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_dofus_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DOFUS, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DOFUS, NDPI_PROTOCOL_UNKNOWN);
NDPI_LOG_INFO(ndpi_struct, "found dofus\n");
} }
void ndpi_search_dofus(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) void ndpi_search_dofus(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG_DBG(ndpi_struct, "search dofus\n");
/* Dofus v 1.x.x */ /* Dofus v 1.x.x */
if (packet->payload_packet_len == 13 && get_u_int16_t(packet->payload, 1) == ntohs(0x0508) if (packet->payload_packet_len == 13 && get_u_int16_t(packet->payload, 1) == ntohs(0x0508)
&& get_u_int16_t(packet->payload, 5) == ntohs(0x04a0) && get_u_int16_t(packet->payload, 5) == ntohs(0x04a0)
&& get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == ntohs(0x0194)) { && get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == ntohs(0x0194)) {
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
ndpi_dofus_add_connection(ndpi_struct, flow); ndpi_dofus_add_connection(ndpi_struct, flow);
return; return;
} }
if (flow->l4.tcp.dofus_stage == 0) { if (flow->l4.tcp.dofus_stage == 0 && packet->payload_packet_len == 3 && memcmp(packet->payload, "HG", 2) == 0
if (packet->payload_packet_len == 3 && memcmp(packet->payload, "HG", 2) == 0 && packet->payload[packet->payload_packet_len - 1] == 0) {
&& packet->payload[packet->payload_packet_len - 1] == 0) flow->l4.tcp.dofus_stage = 1;
goto maybe_dofus; NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "maybe dofus.\n");
return;
if (packet->payload_packet_len == 12 && memcmp(packet->payload, "Af", 2) == 0 }
&& packet->payload[packet->payload_packet_len - 1] == 0) if (flow->l4.tcp.dofus_stage == 0 && packet->payload_packet_len == 35 && memcmp(packet->payload, "HC", 2) == 0
goto maybe_dofus; && packet->payload[packet->payload_packet_len - 1] == 0) {
flow->l4.tcp.dofus_stage = 1;
if (packet->payload_packet_len == 35 && memcmp(packet->payload, "HC", 2) == 0 NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "maybe dofus.\n");
&& packet->payload[packet->payload_packet_len - 1] == 0) return;
goto maybe_dofus; }
if (flow->l4.tcp.dofus_stage == 0 && packet->payload_packet_len > 2 && packet->payload[0] == 'A'
if (packet->payload_packet_len > 2 && packet->payload[0] == 'A'
&& (packet->payload[1] == 'x' || packet->payload[1] == 'X') && (packet->payload[1] == 'x' || packet->payload[1] == 'X')
&& packet->payload[packet->payload_packet_len - 1] == 0) && packet->payload[packet->payload_packet_len - 1] == 0) {
goto maybe_dofus; flow->l4.tcp.dofus_stage = 1;
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "maybe dofus.\n");
if (packet->payload_packet_len > 2 && memcmp(packet->payload, "Ad", 2) return;
&& packet->payload[packet->payload_packet_len - 1] == 0)
goto maybe_dofus;
} }
if (flow->l4.tcp.dofus_stage == 0 && packet->payload_packet_len == 12 && memcmp(packet->payload, "Af", 2) == 0
&& packet->payload[packet->payload_packet_len - 1] == 0) {
flow->l4.tcp.dofus_stage = 1;
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "maybe dofus.\n");
return;
}
if (flow->l4.tcp.dofus_stage == 0 && packet->payload_packet_len > 2 && memcmp(packet->payload, "Ad", 2)
&& packet->payload[packet->payload_packet_len - 1] == 0) {
flow->l4.tcp.dofus_stage = 1;
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "maybe dofus.\n");
return;
}
if (packet->payload_packet_len == 11 && memcmp(packet->payload, "AT", 2) == 0 && packet->payload[10] == 0x00) {
if (flow->l4.tcp.dofus_stage == 1) { if (flow->l4.tcp.dofus_stage == 1) {
if (packet->payload_packet_len == 11 && memcmp(packet->payload, "AT", 2) == 0 NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
&& packet->payload[10] == 0x00) {
ndpi_dofus_add_connection(ndpi_struct, flow); ndpi_dofus_add_connection(ndpi_struct, flow);
return; return;
} }
if (packet->payload_packet_len == 5 }
&& packet->payload[0] == 'A' && packet->payload[4] == 0x00 if (flow->l4.tcp.dofus_stage == 1 && packet->payload_packet_len == 5
&& (packet->payload[1] == 'T' || packet->payload[1] == 'k')) { && packet->payload[0] == 'A' && packet->payload[4] == 0x00 && (packet->payload[1] == 'T'
|| packet->payload[1] == 'k')) {
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus asym.\n");
ndpi_dofus_add_connection(ndpi_struct, flow); ndpi_dofus_add_connection(ndpi_struct, flow);
return; return;
} }
}
/* end Dofus 1.x.x */ /* end Dofus 1.x.x */
@@ -101,6 +109,7 @@ void ndpi_search_dofus(struct ndpi_detection_module_struct *ndpi_struct, struct
if (packet->payload_packet_len == 49 && ntohs(get_u_int16_t(packet->payload, 15)) + 17 != packet->payload_packet_len) { if (packet->payload_packet_len == 49 && ntohs(get_u_int16_t(packet->payload, 15)) + 17 != packet->payload_packet_len) {
goto exclude; goto exclude;
} }
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
ndpi_dofus_add_connection(ndpi_struct, flow); ndpi_dofus_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -111,6 +120,7 @@ void ndpi_search_dofus(struct ndpi_detection_module_struct *ndpi_struct, struct
goto exclude; goto exclude;
len2 = ntohs(get_u_int16_t(packet->payload, 5 + len)); len2 = ntohs(get_u_int16_t(packet->payload, 5 + len));
if (5 + len + 2 + len2 == packet->payload_packet_len) { if (5 + len + 2 + len2 == packet->payload_packet_len) {
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
ndpi_dofus_add_connection(ndpi_struct, flow); ndpi_dofus_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -125,21 +135,17 @@ void ndpi_search_dofus(struct ndpi_detection_module_struct *ndpi_struct, struct
if ((12 + len + 2 + len2 + 1) > packet->payload_packet_len) if ((12 + len + 2 + len2 + 1) > packet->payload_packet_len)
goto exclude; goto exclude;
if (12 + len + 2 + len2 + 1 == packet->payload_packet_len && packet->payload[12 + len + 2 + len2] == 0x01) { if (12 + len + 2 + len2 + 1 == packet->payload_packet_len && packet->payload[12 + len + 2 + len2] == 0x01) {
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
ndpi_dofus_add_connection(ndpi_struct, flow); ndpi_dofus_add_connection(ndpi_struct, flow);
return; return;
} }
} }
exclude: exclude:
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "exclude dofus.\n");
return; NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DOFUS);
maybe_dofus:
flow->l4.tcp.dofus_stage = 1;
NDPI_LOG_DBG2(ndpi_struct, "maybe dofus\n");
return;
} }
void init_dofus_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) void init_dofus_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{ {
ndpi_set_bitmask_protocol_detection("Dofus", ndpi_struct, detection_bitmask, *id, ndpi_set_bitmask_protocol_detection("Dofus", ndpi_struct, detection_bitmask, *id,
+13 -14
View File
@@ -17,13 +17,11 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_DRDA #ifdef NDPI_PROTOCOL_DRDA
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DRDA #define DRDA_PORT 50000
#include "ndpi_api.h"
struct ndpi_drda_hdr { struct ndpi_drda_hdr {
u_int16_t length; u_int16_t length;
@@ -40,21 +38,20 @@ void ndpi_search_drda(struct ndpi_detection_module_struct *ndpi_struct,
{ {
struct ndpi_packet_struct * packet = &flow->packet; struct ndpi_packet_struct * packet = &flow->packet;
u_int16_t payload_len = packet->payload_packet_len; u_int16_t payload_len = packet->payload_packet_len;
u_int count = 0; // prevent integer overflow u_int16_t count = 0;
NDPI_LOG_DBG(ndpi_struct, "search DRDA\n");
if(packet->tcp != NULL) { if(packet->tcp != NULL) {
/* check port */ /* check port */
if(payload_len >= sizeof(struct ndpi_drda_hdr)) { if((ntohs(packet->tcp->source) == DRDA_PORT ||
ntohs(packet->tcp->dest) == DRDA_PORT)) {
struct ndpi_drda_hdr * drda = (struct ndpi_drda_hdr *) packet->payload; struct ndpi_drda_hdr * drda = (struct ndpi_drda_hdr *) packet->payload;
u_int16_t len = ntohs(drda->length); u_int16_t len = ntohs(drda->length);
/* check first header */ /* check first header */
if(len != ntohs(drda->length2) + 6 || if(len - 6 != ntohs(drda->length2) &&
drda->magic != 0xd0) drda->magic != 0xd0)
goto no_drda; goto no_drda;
@@ -62,14 +59,15 @@ void ndpi_search_drda(struct ndpi_detection_module_struct *ndpi_struct,
if(payload_len > len) { if(payload_len > len) {
count = len; count = len;
const u_int8_t * pp = packet->payload + len;
while(count + sizeof(struct ndpi_drda_hdr) < payload_len) while(count < payload_len)
{ {
/* update info */ /* update info */
drda = (struct ndpi_drda_hdr *)(packet->payload + count); drda = (struct ndpi_drda_hdr *) pp;
len = ntohs(drda->length); len = ntohs(drda->length);
if(len != ntohs(drda->length2) + 6 || if(len - 6 != ntohs(drda->length2) &&
drda->magic != 0xd0) drda->magic != 0xd0)
goto no_drda; goto no_drda;
@@ -77,14 +75,15 @@ void ndpi_search_drda(struct ndpi_detection_module_struct *ndpi_struct,
} }
if(count != payload_len) goto no_drda; if(count != payload_len) goto no_drda;
} }
NDPI_LOG_INFO(ndpi_struct, "found DRDA\n"); NDPI_LOG(NDPI_PROTOCOL_DRDA, ndpi_struct, NDPI_LOG_DEBUG, "found DRDA.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DRDA, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DRDA, NDPI_PROTOCOL_UNKNOWN);
return; return;
} }
} }
no_drda: no_drda:
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_DRDA, ndpi_struct, NDPI_LOG_DEBUG, "exclude DRDA.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DRDA);
} }
+5 -8
View File
@@ -21,14 +21,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_DROPBOX
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DROPBOX
#include "ndpi_api.h" #include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_DROPBOX
#define DB_LSP_PORT 17500 #define DB_LSP_PORT 17500
@@ -55,7 +51,7 @@ static void ndpi_check_dropbox(struct ndpi_detection_module_struct *ndpi_struct,
if(payload_len > 2) { if(payload_len > 2) {
if(strncmp((const char *)packet->payload, "{\"host_int\"", 11) == 0) { if(strncmp((const char *)packet->payload, "{\"host_int\"", 11) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found dropbox\n"); NDPI_LOG(NDPI_PROTOCOL_DROPBOX, ndpi_struct, NDPI_LOG_DEBUG, "Found dropbox.\n");
ndpi_int_dropbox_add_connection(ndpi_struct, flow, 0); ndpi_int_dropbox_add_connection(ndpi_struct, flow, 0);
return; return;
} }
@@ -63,14 +59,15 @@ static void ndpi_check_dropbox(struct ndpi_detection_module_struct *ndpi_struct,
} }
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_DROPBOX, ndpi_struct, NDPI_LOG_DEBUG, "exclude dropbox.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DROPBOX);
} }
void ndpi_search_dropbox(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) void ndpi_search_dropbox(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search dropbox\n"); NDPI_LOG(NDPI_PROTOCOL_DROPBOX, ndpi_struct, NDPI_LOG_DEBUG, "dropbox detection...\n");
/* skip marked packets */ /* skip marked packets */
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_DROPBOX) { if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_DROPBOX) {
+15 -22
View File
@@ -24,18 +24,12 @@
http://www.brasilbandalarga.com.br http://www.brasilbandalarga.com.br
*/ */
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_EAQ
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_EAQ
#include "ndpi_api.h" #include "ndpi_api.h"
#define EAQ_DEFAULT_PORT 6000 #define EAQ_DEFAULT_PORT 6000
#define EAQ_DEFAULT_SIZE 16 #define EAQ_DEFAULT_SIZE 16
#ifdef NDPI_PROTOCOL_EAQ
static void ndpi_int_eaq_add_connection(struct ndpi_detection_module_struct *ndpi_struct, static void ndpi_int_eaq_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) { struct ndpi_flow_struct *flow) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_EAQ, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_EAQ, NDPI_PROTOCOL_UNKNOWN);
@@ -46,12 +40,13 @@ void ndpi_search_eaq(struct ndpi_detection_module_struct *ndpi_struct, struct nd
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
u_int16_t sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest); u_int16_t sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
NDPI_LOG_DBG(ndpi_struct, "search eaq\n"); if((packet->payload_packet_len != EAQ_DEFAULT_SIZE)
|| ((sport != EAQ_DEFAULT_PORT) && (dport != EAQ_DEFAULT_PORT))) {
do { exclude_eaq:
if( (packet->payload_packet_len != EAQ_DEFAULT_SIZE) || NDPI_LOG(NDPI_PROTOCOL_EAQ, ndpi_struct, NDPI_LOG_DEBUG, "Exclude eaq.\n");
((sport != EAQ_DEFAULT_PORT) && (dport != EAQ_DEFAULT_PORT)) ) NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_EAQ);
break; return;
}
if(packet->udp != NULL) { if(packet->udp != NULL) {
u_int32_t seq = (packet->payload[0] * 1000) + (packet->payload[1] * 100) + (packet->payload[2] * 10) + packet->payload[3]; u_int32_t seq = (packet->payload[0] * 1000) + (packet->payload[1] * 100) + (packet->payload[2] * 10) + packet->payload[3];
@@ -59,21 +54,19 @@ void ndpi_search_eaq(struct ndpi_detection_module_struct *ndpi_struct, struct nd
if(flow->l4.udp.eaq_pkt_id == 0) if(flow->l4.udp.eaq_pkt_id == 0)
flow->l4.udp.eaq_sequence = seq; flow->l4.udp.eaq_sequence = seq;
else { else {
if( (flow->l4.udp.eaq_sequence != seq) && if((flow->l4.udp.eaq_sequence == seq) || ((flow->l4.udp.eaq_sequence+1) == seq)) {
((flow->l4.udp.eaq_sequence+1) != seq)) break; ; /* Looks good */
} else
goto exclude_eaq;
} }
if(++flow->l4.udp.eaq_pkt_id == 4) { if(++flow->l4.udp.eaq_pkt_id == 4) {
/* We have collected enough packets so we assume it's EAQ */ /* We have collected enough packets so we assume it's EAQ */
NDPI_LOG_INFO(ndpi_struct, "found eaq\n"); NDPI_LOG(NDPI_PROTOCOL_EAQ, ndpi_struct, NDPI_LOG_DEBUG, "found eaq.\n");
ndpi_int_eaq_add_connection(ndpi_struct, flow); ndpi_int_eaq_add_connection(ndpi_struct, flow);
return;
} }
} } else
} while(0); goto exclude_eaq;
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
} }
+9 -13
View File
@@ -23,15 +23,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_EDONKEY
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_EDONKEY
#include "ndpi_api.h" #include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_EDONKEY
static void ndpi_int_edonkey_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { static void ndpi_int_edonkey_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_EDONKEY, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_EDONKEY, NDPI_PROTOCOL_UNKNOWN);
} }
@@ -164,23 +159,24 @@ static void ndpi_check_edonkey(struct ndpi_detection_module_struct *ndpi_struct,
/* Break after 20 packets. */ /* Break after 20 packets. */
if (flow->packet_counter > 20) { if (flow->packet_counter > 20) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "Exclude EDONKEY.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_EDONKEY);
return; return;
} }
/* Check if we so far detected the protocol in the request or not. */ /* Check if we so far detected the protocol in the request or not. */
if (flow->edonkey_stage == 0) { if (flow->edonkey_stage == 0) {
NDPI_LOG_DBG2(ndpi_struct, "EDONKEY stage 0: \n"); NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "EDONKEY stage 0: \n");
if (ndpi_edonkey_payload_check(packet->payload, payload_len)) { if (ndpi_edonkey_payload_check(packet->payload, payload_len)) {
NDPI_LOG_DBG2(ndpi_struct, "Possible EDONKEY request detected, we will look further for the response\n"); NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "Possible EDONKEY request detected, we will look further for the response...\n");
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */ /* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
flow->edonkey_stage = packet->packet_direction + 1; flow->edonkey_stage = packet->packet_direction + 1;
} }
} else { } else {
NDPI_LOG_DBG2(ndpi_struct, "EDONKEY stage %u: \n", flow->edonkey_stage); NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "EDONKEY stage %u: \n", flow->edonkey_stage);
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */ /* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
if ((flow->edonkey_stage - packet->packet_direction) == 1) { if ((flow->edonkey_stage - packet->packet_direction) == 1) {
@@ -189,10 +185,10 @@ static void ndpi_check_edonkey(struct ndpi_detection_module_struct *ndpi_struct,
/* This is a packet in another direction. Check if we find the proper response. */ /* This is a packet in another direction. Check if we find the proper response. */
if ((payload_len == 0) || (ndpi_edonkey_payload_check(packet->payload, payload_len))) { if ((payload_len == 0) || (ndpi_edonkey_payload_check(packet->payload, payload_len))) {
NDPI_LOG_INFO(ndpi_struct, "found EDONKEY\n"); NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "Found EDONKEY.\n");
ndpi_int_edonkey_add_connection(ndpi_struct, flow); ndpi_int_edonkey_add_connection(ndpi_struct, flow);
} else { } else {
NDPI_LOG_DBG2(ndpi_struct, "The reply did not seem to belong to EDONKEY, resetting the stage to 0\n"); NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "The reply did not seem to belong to EDONKEY, resetting the stage to 0...\n");
flow->edonkey_stage = 0; flow->edonkey_stage = 0;
} }
@@ -202,7 +198,7 @@ static void ndpi_check_edonkey(struct ndpi_detection_module_struct *ndpi_struct,
void ndpi_search_edonkey(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { void ndpi_search_edonkey(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search EDONKEY\n"); NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "EDONKEY detection...\n");
/* skip marked packets */ /* skip marked packets */
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_EDONKEY) { if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_EDONKEY) {
+12 -14
View File
@@ -22,13 +22,11 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_FASTTRACK #ifdef NDPI_PROTOCOL_FASTTRACK
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_FASTTRACK
#include "ndpi_api.h"
static void ndpi_int_fasttrack_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_int_fasttrack_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
@@ -41,12 +39,11 @@ void ndpi_search_fasttrack_tcp(struct ndpi_detection_module_struct *ndpi_struct,
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search FASTTRACK\n"); // struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
if ( (packet->payload != NULL) if (packet->payload_packet_len > 6 && ntohs(get_u_int16_t(packet->payload, packet->payload_packet_len - 2)) == 0x0d0a) {
&& (packet->payload_packet_len > 6) NDPI_LOG(NDPI_PROTOCOL_FASTTRACK, ndpi_struct, NDPI_LOG_TRACE, "detected 0d0a at the end of the packet.\n");
&& (ntohs(get_u_int16_t(packet->payload, packet->payload_packet_len - 2)) == 0x0d0a)) {
NDPI_LOG_DBG2(ndpi_struct, "detected 0d0a at the end of the packet\n");
if (memcmp(packet->payload, "GIVE ", 5) == 0 && packet->payload_packet_len >= 8) { if (memcmp(packet->payload, "GIVE ", 5) == 0 && packet->payload_packet_len >= 8) {
u_int16_t i; u_int16_t i;
@@ -57,20 +54,20 @@ void ndpi_search_fasttrack_tcp(struct ndpi_detection_module_struct *ndpi_struct,
} }
} }
NDPI_LOG_INFO(ndpi_struct, "found FASTTRACK\n"); NDPI_LOG(NDPI_PROTOCOL_FASTTRACK, ndpi_struct, NDPI_LOG_TRACE, "FASTTRACK GIVE DETECTED\n");
ndpi_int_fasttrack_add_connection(ndpi_struct, flow); ndpi_int_fasttrack_add_connection(ndpi_struct, flow);
return; return;
} }
if (packet->payload_packet_len > 50 && memcmp(packet->payload, "GET /", 5) == 0) { if (packet->payload_packet_len > 50 && memcmp(packet->payload, "GET /", 5) == 0) {
u_int8_t a = 0; u_int8_t a = 0;
NDPI_LOG_DBG2(ndpi_struct, "detected GET /. \n"); NDPI_LOG(NDPI_PROTOCOL_FASTTRACK, ndpi_struct, NDPI_LOG_TRACE, "detected GET /. \n");
ndpi_parse_packet_line_info(ndpi_struct, flow); ndpi_parse_packet_line_info(ndpi_struct, flow);
for (a = 0; a < packet->parsed_lines; a++) { for (a = 0; a < packet->parsed_lines; a++) {
if ((packet->line[a].len > 17 && memcmp(packet->line[a].ptr, "X-Kazaa-Username: ", 18) == 0) if ((packet->line[a].len > 17 && memcmp(packet->line[a].ptr, "X-Kazaa-Username: ", 18) == 0)
|| (packet->line[a].len > 23 && memcmp(packet->line[a].ptr, "User-Agent: PeerEnabler/", 24) == 0)) { || (packet->line[a].len > 23 && memcmp(packet->line[a].ptr, "User-Agent: PeerEnabler/", 24) == 0)) {
NDPI_LOG_INFO(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_FASTTRACK, ndpi_struct, NDPI_LOG_TRACE,
"found FASTTRACK X-Kazaa-Username: || User-Agent: PeerEnabler/\n"); "detected X-Kazaa-Username: || User-Agent: PeerEnabler/\n");
ndpi_int_fasttrack_add_connection(ndpi_struct, flow); ndpi_int_fasttrack_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -79,7 +76,8 @@ void ndpi_search_fasttrack_tcp(struct ndpi_detection_module_struct *ndpi_struct,
} }
exclude_fasttrack: exclude_fasttrack:
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_FASTTRACK, ndpi_struct, NDPI_LOG_TRACE, "fasttrack/kazaa excluded.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FASTTRACK);
} }
+12 -12
View File
@@ -22,14 +22,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h" /* include files */
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_FIESTA #ifdef NDPI_PROTOCOL_FIESTA
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_FIESTA
#include "ndpi_api.h"
static void ndpi_int_fiesta_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_int_fiesta_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
@@ -40,14 +36,17 @@ void ndpi_search_fiesta(struct ndpi_detection_module_struct *ndpi_struct, struct
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search fiesta\n"); // struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG(NDPI_PROTOCOL_FIESTA, ndpi_struct, NDPI_LOG_DEBUG, "search fiesta.\n");
if (flow->l4.tcp.fiesta_stage == 0 && packet->payload_packet_len == 5 if (flow->l4.tcp.fiesta_stage == 0 && packet->payload_packet_len == 5
&& get_u_int16_t(packet->payload, 0) == ntohs(0x0407) && get_u_int16_t(packet->payload, 0) == ntohs(0x0407)
&& (packet->payload[2] == 0x08) && (packet->payload[2] == 0x08)
&& (packet->payload[4] == 0x00 || packet->payload[4] == 0x01)) { && (packet->payload[4] == 0x00 || packet->payload[4] == 0x01)) {
NDPI_LOG_DBG2(ndpi_struct, "maybe fiesta symmetric, first packet\n"); NDPI_LOG(NDPI_PROTOCOL_FIESTA, ndpi_struct, NDPI_LOG_DEBUG, "maybe fiesta symmetric, first packet.\n");
flow->l4.tcp.fiesta_stage = 1 + packet->packet_direction; flow->l4.tcp.fiesta_stage = 1 + packet->packet_direction;
goto maybe_fiesta; goto maybe_fiesta;
} }
@@ -55,7 +54,7 @@ void ndpi_search_fiesta(struct ndpi_detection_module_struct *ndpi_struct, struct
&& ((packet->payload_packet_len > 1 && packet->payload_packet_len - 1 == packet->payload[0]) && ((packet->payload_packet_len > 1 && packet->payload_packet_len - 1 == packet->payload[0])
|| (packet->payload_packet_len > 3 && packet->payload[0] == 0 || (packet->payload_packet_len > 3 && packet->payload[0] == 0
&& get_l16(packet->payload, 1) == packet->payload_packet_len - 3))) { && get_l16(packet->payload, 1) == packet->payload_packet_len - 3))) {
NDPI_LOG_DBG2(ndpi_struct, "Maybe fiesta\n"); NDPI_LOG(NDPI_PROTOCOL_FIESTA, ndpi_struct, NDPI_LOG_DEBUG, "Maybe fiesta.\n");
goto maybe_fiesta; goto maybe_fiesta;
} }
if (flow->l4.tcp.fiesta_stage == (1 + packet->packet_direction)) { if (flow->l4.tcp.fiesta_stage == (1 + packet->packet_direction)) {
@@ -80,15 +79,16 @@ void ndpi_search_fiesta(struct ndpi_detection_module_struct *ndpi_struct, struct
} }
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_FIESTA, ndpi_struct, NDPI_LOG_DEBUG, "exclude fiesta.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FIESTA);
return; return;
maybe_fiesta: maybe_fiesta:
NDPI_LOG_DBG2(ndpi_struct, "Stage is set to %d\n", flow->l4.tcp.fiesta_stage); NDPI_LOG(NDPI_PROTOCOL_FIESTA, ndpi_struct, NDPI_LOG_DEBUG, "Stage is set to %d.\n", flow->l4.tcp.fiesta_stage);
return; return;
add_fiesta: add_fiesta:
NDPI_LOG_INFO(ndpi_struct, "found fiesta\n"); NDPI_LOG(NDPI_PROTOCOL_FIESTA, ndpi_struct, NDPI_LOG_DEBUG, "detected fiesta.\n");
ndpi_int_fiesta_add_connection(ndpi_struct, flow); ndpi_int_fiesta_add_connection(ndpi_struct, flow);
return; return;
} }
+7 -10
View File
@@ -22,14 +22,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_FILETOPIA #ifdef NDPI_PROTOCOL_FILETOPIA
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_FILETOPIA
#include "ndpi_api.h"
static void ndpi_int_filetopia_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_int_filetopia_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
@@ -40,13 +36,14 @@ void ndpi_search_filetopia_tcp(struct ndpi_detection_module_struct *ndpi_struct,
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search Filetopia\n"); // struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
if (flow->l4.tcp.filetopia_stage == 0) { if (flow->l4.tcp.filetopia_stage == 0) {
if (packet->payload_packet_len >= 50 && packet->payload_packet_len <= 70 if (packet->payload_packet_len >= 50 && packet->payload_packet_len <= 70
&& packet->payload[0] == 0x03 && packet->payload[1] == 0x9a && packet->payload[0] == 0x03 && packet->payload[1] == 0x9a
&& packet->payload[3] == 0x22 && packet->payload[packet->payload_packet_len - 1] == 0x2b) { && packet->payload[3] == 0x22 && packet->payload[packet->payload_packet_len - 1] == 0x2b) {
NDPI_LOG_DBG2(ndpi_struct, "Filetopia stage 1 detected\n"); NDPI_LOG(NDPI_PROTOCOL_FILETOPIA, ndpi_struct, NDPI_LOG_DEBUG, "Filetopia stage 1 detected\n");
flow->l4.tcp.filetopia_stage = 1; flow->l4.tcp.filetopia_stage = 1;
return; return;
} }
@@ -62,7 +59,7 @@ void ndpi_search_filetopia_tcp(struct ndpi_detection_module_struct *ndpi_struct,
} }
} }
NDPI_LOG_DBG2(ndpi_struct, "Filetopia stage 2 detected\n"); NDPI_LOG(NDPI_PROTOCOL_FILETOPIA, ndpi_struct, NDPI_LOG_DEBUG, "Filetopia stage 2 detected\n");
flow->l4.tcp.filetopia_stage = 2; flow->l4.tcp.filetopia_stage = 2;
return; return;
} }
@@ -72,7 +69,7 @@ void ndpi_search_filetopia_tcp(struct ndpi_detection_module_struct *ndpi_struct,
if (packet->payload_packet_len >= 4 && packet->payload_packet_len <= 100 if (packet->payload_packet_len >= 4 && packet->payload_packet_len <= 100
&& packet->payload[0] == 0x03 && packet->payload[1] == 0x9a && packet->payload[0] == 0x03 && packet->payload[1] == 0x9a
&& (packet->payload[3] == 0x22 || packet->payload[3] == 0x23)) { && (packet->payload[3] == 0x22 || packet->payload[3] == 0x23)) {
NDPI_LOG_INFO(ndpi_struct, "found Filetopia\n"); NDPI_LOG(NDPI_PROTOCOL_FILETOPIA, ndpi_struct, NDPI_LOG_DEBUG, "Filetopia detected\n");
ndpi_int_filetopia_add_connection(ndpi_struct, flow); ndpi_int_filetopia_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -80,7 +77,7 @@ void ndpi_search_filetopia_tcp(struct ndpi_detection_module_struct *ndpi_struct,
} }
end_filetopia_nothing_found: end_filetopia_nothing_found:
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FILETOPIA);
} }
-80
View File
@@ -1,80 +0,0 @@
/*
* fix.c
*
* Copyright (C) 2017 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_FIX
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_FIX
#include "ndpi_api.h"
void ndpi_search_fix(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search FIX\n");
if(packet->tcp) {
// 8=
if(packet->payload[0] == 0x38 && packet->payload[1] == 0x3d) {
// FIX.
if(packet->payload[2] == 0x46 &&
packet->payload[3] == 0x49 &&
packet->payload[4] == 0x58 &&
packet->payload[5] == 0x2e) {
NDPI_LOG_INFO(ndpi_struct, "found FIX\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FIX, NDPI_PROTOCOL_UNKNOWN);
return;
}
// 0. 9=
if(packet->payload[2] == 0x4f &&
packet->payload[3] == 0x01 &&
packet->payload[4] == 0x39 &&
packet->payload[5] == 0x3d) {
NDPI_LOG_INFO(ndpi_struct, "found FIX\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FIX, NDPI_PROTOCOL_UNKNOWN);
return;
}
}
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
void init_fix_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("FIX", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_FIX,
ndpi_search_fix,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+20 -18
View File
@@ -22,14 +22,11 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_FLORENSIA #ifdef NDPI_PROTOCOL_FLORENSIA
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_FLORENSIA
#include "ndpi_api.h"
static void ndpi_florensia_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_florensia_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
@@ -40,40 +37,44 @@ void ndpi_search_florensia(struct ndpi_detection_module_struct *ndpi_struct, str
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search florensia\n"); // struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "search florensia.\n");
if (packet->tcp != NULL) { if (packet->tcp != NULL) {
if (packet->payload_packet_len == 5 && get_l16(packet->payload, 0) == packet->payload_packet_len if (packet->payload_packet_len == 5 && get_l16(packet->payload, 0) == packet->payload_packet_len
&& packet->payload[2] == 0x65 && packet->payload[4] == 0xff) { && packet->payload[2] == 0x65 && packet->payload[4] == 0xff) {
if (flow->florensia_stage == 1) { if (flow->florensia_stage == 1) {
NDPI_LOG_INFO(ndpi_struct, "found florensia\n"); NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "found florensia.\n");
ndpi_florensia_add_connection(ndpi_struct, flow); ndpi_florensia_add_connection(ndpi_struct, flow);
return; return;
} }
NDPI_LOG_DBG2(ndpi_struct, "maybe florensia -> stage is set to 1\n"); NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "maybe florensia -> stage is set to 1.\n");
flow->florensia_stage = 1; flow->florensia_stage = 1;
return; return;
} }
if (packet->payload_packet_len > 8 && get_l16(packet->payload, 0) == packet->payload_packet_len if (packet->payload_packet_len > 8 && get_l16(packet->payload, 0) == packet->payload_packet_len
&& get_u_int16_t(packet->payload, 2) == htons(0x0201) && get_u_int32_t(packet->payload, 4) == htonl(0xFFFFFFFF)) { && get_u_int16_t(packet->payload, 2) == htons(0x0201) && get_u_int32_t(packet->payload, 4) == htonl(0xFFFFFFFF)) {
NDPI_LOG_DBG2(ndpi_struct, "maybe florensia -> stage is set to 1\n"); NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "maybe florensia -> stage is set to 1.\n");
flow->florensia_stage = 1; flow->florensia_stage = 1;
return; return;
} }
if (packet->payload_packet_len == 406 && get_l16(packet->payload, 0) == packet->payload_packet_len if (packet->payload_packet_len == 406 && get_l16(packet->payload, 0) == packet->payload_packet_len
&& packet->payload[2] == 0x63) { && packet->payload[2] == 0x63) {
NDPI_LOG_DBG2(ndpi_struct, "maybe florensia -> stage is set to 1\n"); NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "maybe florensia -> stage is set to 1.\n");
flow->florensia_stage = 1; flow->florensia_stage = 1;
return; return;
} }
if (packet->payload_packet_len == 12 && get_l16(packet->payload, 0) == packet->payload_packet_len if (packet->payload_packet_len == 12 && get_l16(packet->payload, 0) == packet->payload_packet_len
&& get_u_int16_t(packet->payload, 2) == htons(0x0301)) { && get_u_int16_t(packet->payload, 2) == htons(0x0301)) {
if (flow->florensia_stage == 1) { if (flow->florensia_stage == 1) {
NDPI_LOG_INFO(ndpi_struct, "found florensia\n"); NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "found florensia.\n");
ndpi_florensia_add_connection(ndpi_struct, flow); ndpi_florensia_add_connection(ndpi_struct, flow);
return; return;
} }
NDPI_LOG_DBG2(ndpi_struct, "maybe florensia -> stage is set to 1\n"); NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "maybe florensia -> stage is set to 1.\n");
flow->florensia_stage = 1; flow->florensia_stage = 1;
return; return;
} }
@@ -81,19 +82,19 @@ void ndpi_search_florensia(struct ndpi_detection_module_struct *ndpi_struct, str
if (flow->florensia_stage == 1) { if (flow->florensia_stage == 1) {
if (packet->payload_packet_len == 8 && get_l16(packet->payload, 0) == packet->payload_packet_len if (packet->payload_packet_len == 8 && get_l16(packet->payload, 0) == packet->payload_packet_len
&& get_u_int16_t(packet->payload, 2) == htons(0x0302) && get_u_int32_t(packet->payload, 4) == htonl(0xFFFFFFFF)) { && get_u_int16_t(packet->payload, 2) == htons(0x0302) && get_u_int32_t(packet->payload, 4) == htonl(0xFFFFFFFF)) {
NDPI_LOG_INFO(ndpi_struct, "found florensia asymmetrically\n"); NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "found florensia asymmetrically.\n");
ndpi_florensia_add_connection(ndpi_struct, flow); ndpi_florensia_add_connection(ndpi_struct, flow);
return; return;
} }
if (packet->payload_packet_len == 24 && get_l16(packet->payload, 0) == packet->payload_packet_len if (packet->payload_packet_len == 24 && get_l16(packet->payload, 0) == packet->payload_packet_len
&& get_u_int16_t(packet->payload, 2) == htons(0x0202) && get_u_int16_t(packet->payload, 2) == htons(0x0202)
&& get_u_int32_t(packet->payload, packet->payload_packet_len - 4) == htonl(0xFFFFFFFF)) { && get_u_int32_t(packet->payload, packet->payload_packet_len - 4) == htonl(0xFFFFFFFF)) {
NDPI_LOG_INFO(ndpi_struct, "found florensia\n"); NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "found florensia.\n");
ndpi_florensia_add_connection(ndpi_struct, flow); ndpi_florensia_add_connection(ndpi_struct, flow);
return; return;
} }
if (flow->packet_counter < 10 && get_l16(packet->payload, 0) == packet->payload_packet_len) { if (flow->packet_counter < 10 && get_l16(packet->payload, 0) == packet->payload_packet_len) {
NDPI_LOG_DBG2(ndpi_struct, "maybe florensia\n"); NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "maybe florensia.\n");
return; return;
} }
} }
@@ -102,19 +103,20 @@ void ndpi_search_florensia(struct ndpi_detection_module_struct *ndpi_struct, str
if (packet->udp != NULL) { if (packet->udp != NULL) {
if (flow->florensia_stage == 0 && packet->payload_packet_len == 6 if (flow->florensia_stage == 0 && packet->payload_packet_len == 6
&& get_u_int16_t(packet->payload, 0) == ntohs(0x0503) && get_u_int32_t(packet->payload, 2) == htonl(0xFFFF0000)) { && get_u_int16_t(packet->payload, 0) == ntohs(0x0503) && get_u_int32_t(packet->payload, 2) == htonl(0xFFFF0000)) {
NDPI_LOG_DBG2(ndpi_struct, "maybe florensia -> stage is set to 1\n"); NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "maybe florensia -> stage is set to 1.\n");
flow->florensia_stage = 1; flow->florensia_stage = 1;
return; return;
} }
if (flow->florensia_stage == 1 && packet->payload_packet_len == 8 if (flow->florensia_stage == 1 && packet->payload_packet_len == 8
&& get_u_int16_t(packet->payload, 0) == ntohs(0x0500) && get_u_int16_t(packet->payload, 4) == htons(0x4191)) { && get_u_int16_t(packet->payload, 0) == ntohs(0x0500) && get_u_int16_t(packet->payload, 4) == htons(0x4191)) {
NDPI_LOG_INFO(ndpi_struct, "found florensia\n"); NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "found florensia.\n");
ndpi_florensia_add_connection(ndpi_struct, flow); ndpi_florensia_add_connection(ndpi_struct, flow);
return; return;
} }
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "exclude florensia.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FLORENSIA);
} }
+13 -19
View File
@@ -1,7 +1,7 @@
/* /*
* ftp_control.c * ftp_control.c
* *
* Copyright (C) 2016 - ntop.org * Copyright (C) 2014 Tomasz Bujlow <tomasz@skatnet.dk>
* *
* This file is part of nDPI, an open source deep packet inspection * This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH * library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -21,14 +21,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_FTP_CONTROL
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_FTP_CONTROL
#include "ndpi_api.h" #include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_FTP_CONTROL
static void ndpi_int_ftp_control_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { static void ndpi_int_ftp_control_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FTP_CONTROL, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FTP_CONTROL, NDPI_PROTOCOL_UNKNOWN);
@@ -939,38 +935,36 @@ static int ndpi_ftp_control_check_response(const u_int8_t *payload, size_t paylo
} }
static void ndpi_check_ftp_control(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { static void ndpi_check_ftp_control(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
u_int32_t payload_len = packet->payload_packet_len; u_int32_t payload_len = packet->payload_packet_len;
/* Check connection over TCP */
if(packet->tcp) {
/* Exclude SMTP, which uses similar commands. */ /* Exclude SMTP, which uses similar commands. */
if (packet->tcp->dest == htons(25) || packet->tcp->source == htons(25)) { if (packet->tcp->dest == htons(25) || packet->tcp->source == htons(25)) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "Exclude FTP_CONTROL.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FTP_CONTROL);
return; return;
} }
/* Break after 20 packets. */ /* Break after 20 packets. */
if (flow->packet_counter > 20) { if (flow->packet_counter > 20) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "Exclude FTP_CONTROL.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FTP_CONTROL);
return; return;
} }
/* Check if we so far detected the protocol in the request or not. */ /* Check if we so far detected the protocol in the request or not. */
if (flow->ftp_control_stage == 0) { if (flow->ftp_control_stage == 0) {
NDPI_LOG_DBG2(ndpi_struct, "FTP_CONTROL stage 0: \n"); NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "FTP_CONTROL stage 0: \n");
if ((payload_len > 0) && ndpi_ftp_control_check_request(packet->payload, payload_len)) { if ((payload_len > 0) && ndpi_ftp_control_check_request(packet->payload, payload_len)) {
NDPI_LOG_DBG2(ndpi_struct, "Possible FTP_CONTROL request detected, we will look further for the response..\n"); NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "Possible FTP_CONTROL request detected, we will look further for the response...\n");
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */ /* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
flow->ftp_control_stage = packet->packet_direction + 1; flow->ftp_control_stage = packet->packet_direction + 1;
} }
} else { } else {
NDPI_LOG_DBG2(ndpi_struct, "FTP_CONTROL stage %u: \n", flow->ftp_control_stage); NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "FTP_CONTROL stage %u: \n", flow->ftp_control_stage);
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */ /* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
if ((flow->ftp_control_stage - packet->packet_direction) == 1) { if ((flow->ftp_control_stage - packet->packet_direction) == 1) {
@@ -979,20 +973,20 @@ static void ndpi_check_ftp_control(struct ndpi_detection_module_struct *ndpi_str
/* This is a packet in another direction. Check if we find the proper response. */ /* This is a packet in another direction. Check if we find the proper response. */
if ((payload_len > 0) && ndpi_ftp_control_check_response(packet->payload, payload_len)) { if ((payload_len > 0) && ndpi_ftp_control_check_response(packet->payload, payload_len)) {
NDPI_LOG_INFO(ndpi_struct, "found FTP_CONTROL\n"); NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "Found FTP_CONTROL.\n");
ndpi_int_ftp_control_add_connection(ndpi_struct, flow); ndpi_int_ftp_control_add_connection(ndpi_struct, flow);
} else { } else {
NDPI_LOG_DBG2(ndpi_struct, "The reply did not seem to belong to FTP_CONTROL, resetting the stage to 0\n"); NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "The reply did not seem to belong to FTP_CONTROL, resetting the stage to 0...\n");
flow->ftp_control_stage = 0; flow->ftp_control_stage = 0;
} }
}
} }
} }
void ndpi_search_ftp_control(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { void ndpi_search_ftp_control(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search FTP_CONTROL\n"); NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "FTP_CONTROL detection...\n");
/* skip marked packets */ /* skip marked packets */
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_FTP_CONTROL) { if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_FTP_CONTROL) {
+11 -15
View File
@@ -1,7 +1,8 @@
/* /*
* ftp_data.c * ftp_data.c
* *
* Copyright (C) 2016 - ntop.org * Copyright (C) 2014 Tomasz Bujlow <tomasz@skatnet.dk>
* Copyright (C) 2014 - ntop.org
* *
* The signature is based on the Libprotoident library. * The signature is based on the Libprotoident library.
* *
@@ -23,14 +24,9 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_FTP_DATA
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_FTP_DATA
#include "ndpi_api.h" #include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_FTP_DATA
static void ndpi_int_ftp_data_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { static void ndpi_int_ftp_data_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FTP_DATA, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FTP_DATA, NDPI_PROTOCOL_UNKNOWN);
} }
@@ -38,13 +34,12 @@ static void ndpi_int_ftp_data_add_connection(struct ndpi_detection_module_struct
static int ndpi_match_ftp_data_port(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { static int ndpi_match_ftp_data_port(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
/* Check connection over TCP */
if(packet->tcp) {
if(packet->tcp->dest == htons(20) || packet->tcp->source == htons(20)) { if(packet->tcp->dest == htons(20) || packet->tcp->source == htons(20)) {
return 1; return 1;
} }
}
return 0; return 0;
} }
static int ndpi_match_ftp_data_directory(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { static int ndpi_match_ftp_data_directory(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
@@ -67,7 +62,7 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
u_int32_t payload_len = packet->payload_packet_len; u_int32_t payload_len = packet->payload_packet_len;
/* A FTP packet is pretty long so 256 is a bit conservative but it should be OK */ /* A FTP packet is pretty long so 256 is a bit consrvative but it should be OK */
if(packet->payload_packet_len < 256) if(packet->payload_packet_len < 256)
return 0; return 0;
@@ -228,21 +223,22 @@ static void ndpi_check_ftp_data(struct ndpi_detection_module_struct *ndpi_struct
|| ndpi_match_ftp_data_port(ndpi_struct, flow) || ndpi_match_ftp_data_port(ndpi_struct, flow)
) )
) { ) {
NDPI_LOG_INFO(ndpi_struct, "found FTP_DATA request\n"); NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "Possible FTP_DATA request detected...\n");
ndpi_int_ftp_data_add_connection(ndpi_struct, flow); ndpi_int_ftp_data_add_connection(ndpi_struct, flow);
} else } else
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FTP_DATA);
} }
void ndpi_search_ftp_data(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { void ndpi_search_ftp_data(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
/* Break after 20 packets. */ /* Break after 20 packets. */
if(flow->packet_counter > 20) { if(flow->packet_counter > 20) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "Exclude FTP_DATA.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FTP_DATA);
return; return;
} }
NDPI_LOG_DBG(ndpi_struct, "search FTP_DATA\n"); NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "FTP_DATA detection...\n");
ndpi_check_ftp_data(ndpi_struct, flow); ndpi_check_ftp_data(ndpi_struct, flow);
} }
+5 -12
View File
@@ -17,16 +17,10 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_GIT
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_GIT
#include <stdlib.h> #include <stdlib.h>
#include "ndpi_api.h" #include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_GIT
#define GIT_PORT 9418 #define GIT_PORT 9418
@@ -35,15 +29,13 @@ void ndpi_search_git(struct ndpi_detection_module_struct *ndpi_struct,
{ {
struct ndpi_packet_struct * packet = &flow->packet; struct ndpi_packet_struct * packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search Git\n");
if((packet->tcp != NULL) && (packet->payload_packet_len > 4)) { if((packet->tcp != NULL) && (packet->payload_packet_len > 4)) {
if((ntohs(packet->tcp->source) == GIT_PORT) if((ntohs(packet->tcp->source) == GIT_PORT)
|| (ntohs(packet->tcp->dest) == GIT_PORT)) { || (ntohs(packet->tcp->dest) == GIT_PORT)) {
const u_int8_t * pp = packet->payload; const u_int8_t * pp = packet->payload;
u_int16_t payload_len = packet->payload_packet_len; u_int16_t payload_len = packet->payload_packet_len;
u_int8_t found_git = 1; u_int8_t found_git = 1;
u_int16_t offset = 0; u_int16_t git_len = 0, offset = 0;
while((offset+4) < payload_len) { while((offset+4) < payload_len) {
char len[5]; char len[5];
@@ -60,14 +52,15 @@ void ndpi_search_git(struct ndpi_detection_module_struct *ndpi_struct,
} }
if(found_git) { if(found_git) {
NDPI_LOG_INFO(ndpi_struct, "found Git\n"); NDPI_LOG(NDPI_PROTOCOL_GIT, ndpi_struct, NDPI_LOG_DEBUG, "found Git.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_GIT, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_GIT, NDPI_PROTOCOL_UNKNOWN);
return; return;
} }
} }
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_GIT, ndpi_struct, NDPI_LOG_DEBUG, "exclude Git.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_GIT);
} }
+52 -38
View File
@@ -22,15 +22,13 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
/* include files */
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_GNUTELLA #ifdef NDPI_PROTOCOL_GNUTELLA
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_GNUTELLA
#include "ndpi_api.h"
static void ndpi_int_gnutella_add_connection(struct ndpi_detection_module_struct *ndpi_struct, static void ndpi_int_gnutella_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow/* , */ struct ndpi_flow_struct *flow/* , */
/* ndpi_protocol_type_t protocol_type */) /* ndpi_protocol_type_t protocol_type */)
@@ -40,21 +38,22 @@ static void ndpi_int_gnutella_add_connection(struct ndpi_detection_module_struct
struct ndpi_id_struct *dst = flow->dst; struct ndpi_id_struct *dst = flow->dst;
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_GNUTELLA, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_GNUTELLA, NDPI_PROTOCOL_UNKNOWN);
NDPI_LOG_INFO(ndpi_struct, "found GNUTELLA\n");
if (src != NULL) { if (src != NULL) {
src->gnutella_ts = packet->tick_timestamp; src->gnutella_ts = packet->tick_timestamp;
if (packet->udp != NULL) { if (packet->udp != NULL) {
if (!src->detected_gnutella_udp_port1) { if (!src->detected_gnutella_udp_port1) {
src->detected_gnutella_udp_port1 = (packet->udp->source); src->detected_gnutella_udp_port1 = (packet->udp->source);
NDPI_LOG_DBG2(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct,
"GNUTELLA UDP PORT1 DETECTED as %u\n", src->detected_gnutella_udp_port1); NDPI_LOG_DEBUG, "GNUTELLA UDP PORT1 DETECTED as %u\n",
src->detected_gnutella_udp_port1);
} else if ((ntohs(packet->udp->source) != src->detected_gnutella_udp_port1) } else if ((ntohs(packet->udp->source) != src->detected_gnutella_udp_port1)
&& !src->detected_gnutella_udp_port2) { && !src->detected_gnutella_udp_port2) {
src->detected_gnutella_udp_port2 = (packet->udp->source); src->detected_gnutella_udp_port2 = (packet->udp->source);
NDPI_LOG_DBG2(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct,
"GNUTELLA UDP PORT2 DETECTED as %u\n", src->detected_gnutella_udp_port2); NDPI_LOG_DEBUG, "GNUTELLA UDP PORT2 DETECTED as %u\n",
src->detected_gnutella_udp_port2);
} }
} }
@@ -72,17 +71,16 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
struct ndpi_id_struct *dst = flow->dst; struct ndpi_id_struct *dst = flow->dst;
u_int16_t c; u_int16_t c;
NDPI_LOG_DBG(ndpi_struct, "search GNUTELLA\n");
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_GNUTELLA) { if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_GNUTELLA) {
if (src != NULL && ((u_int32_t) if (src != NULL && ((u_int32_t)
(packet->tick_timestamp - src->gnutella_ts) < ndpi_struct->gnutella_timeout)) { (packet->tick_timestamp - src->gnutella_ts) < ndpi_struct->gnutella_timeout)) {
NDPI_LOG_DBG2(ndpi_struct, "save src connection packet detected\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct,
NDPI_LOG_DEBUG, "gnutella : save src connection packet detected\n");
src->gnutella_ts = packet->tick_timestamp; src->gnutella_ts = packet->tick_timestamp;
} else if (dst != NULL && ((u_int32_t) } else if (dst != NULL && ((u_int32_t)
(packet->tick_timestamp - dst->gnutella_ts) < ndpi_struct->gnutella_timeout)) { (packet->tick_timestamp - dst->gnutella_ts) < ndpi_struct->gnutella_timeout)) {
NDPI_LOG_DBG2(ndpi_struct, "save dst connection packet detected\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct,
NDPI_LOG_DEBUG, "gnutella : save dst connection packet detected\n");
dst->gnutella_ts = packet->tick_timestamp; dst->gnutella_ts = packet->tick_timestamp;
} }
if (src != NULL && (packet->tick_timestamp - src->gnutella_ts) > ndpi_struct->gnutella_timeout) { if (src != NULL && (packet->tick_timestamp - src->gnutella_ts) > ndpi_struct->gnutella_timeout) {
@@ -104,11 +102,13 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
if (packet->tcp != NULL) { if (packet->tcp != NULL) {
/* this case works asymmetrically */ /* this case works asymmetrically */
if (packet->payload_packet_len > 10 && memcmp(packet->payload, "GNUTELLA/", 9) == 0) { if (packet->payload_packet_len > 10 && memcmp(packet->payload, "GNUTELLA/", 9) == 0) {
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "GNUTELLA DETECTED\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
/* this case works asymmetrically */ /* this case works asymmetrically */
if (packet->payload_packet_len > 17 && memcmp(packet->payload, "GNUTELLA CONNECT/", 17) == 0) { if (packet->payload_packet_len > 17 && memcmp(packet->payload, "GNUTELLA CONNECT/", 17) == 0) {
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "GNUTELLA DETECTED\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -123,6 +123,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|| (packet->line[c].len > 7 && memcmp(packet->line[c].ptr, "X-Queue:", 8) == 0) || (packet->line[c].len > 7 && memcmp(packet->line[c].ptr, "X-Queue:", 8) == 0)
|| (packet->line[c].len > 36 && memcmp(packet->line[c].ptr, || (packet->line[c].len > 36 && memcmp(packet->line[c].ptr,
"Content-Type: application/x-gnutella-", 37) == 0)) { "Content-Type: application/x-gnutella-", 37) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG, "DETECTED GNUTELLA GET.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -134,6 +135,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
&& memcmp(packet->user_agent_line.ptr, "BearShare Lite ", 15) == 0) && memcmp(packet->user_agent_line.ptr, "BearShare Lite ", 15) == 0)
|| (packet->accept_line.ptr != NULL && packet->accept_line.len > 24 || (packet->accept_line.ptr != NULL && packet->accept_line.len > 24
&& memcmp(packet->accept_line.ptr, "application n/x-gnutella", 24) == 0)) { && memcmp(packet->accept_line.ptr, "application n/x-gnutella", 24) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG, "DETECTED GNUTELLA GET.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
} }
@@ -149,7 +151,8 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
} }
if (c < (packet->payload_packet_len - 9) && memcmp(&packet->payload[c], "urn:sha1:", 9) == 0) { if (c < (packet->payload_packet_len - 9) && memcmp(&packet->payload[c], "urn:sha1:", 9) == 0) {
NDPI_LOG_DBG2(ndpi_struct, "detected GET /get/ or GET /uri-res/\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE,
"detected GET /get/ or GET /uri-res/.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
} }
@@ -158,14 +161,14 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
/* answer to this packet is HTTP/1.1 ..... Content-Type: application/x-gnutella-packets, /* answer to this packet is HTTP/1.1 ..... Content-Type: application/x-gnutella-packets,
* it is searched in the upper paragraph. */ * it is searched in the upper paragraph. */
if (packet->payload_packet_len > 30 && memcmp(packet->payload, "HEAD /gnutella/push-proxy?", 26) == 0) { if (packet->payload_packet_len > 30 && memcmp(packet->payload, "HEAD /gnutella/push-proxy?", 26) == 0) {
NDPI_LOG_DBG2(ndpi_struct, "detected HEAD /gnutella/push-proxy?\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "detected HEAD /gnutella/push-proxy?\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
/* haven't found any trace with this pattern */ /* haven't found any trace with this pattern */
if (packet->payload_packet_len == 46 if (packet->payload_packet_len == 46
&& memcmp(packet->payload, "\x50\x55\x53\x48\x20\x67\x75\x69\x64\x3a", 10) == 0) { && memcmp(packet->payload, "\x50\x55\x53\x48\x20\x67\x75\x69\x64\x3a", 10) == 0) {
NDPI_LOG_DBG2(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE,
"detected \x50\x55\x53\x48\x20\x67\x75\x69\x64\x3a\n"); "detected \x50\x55\x53\x48\x20\x67\x75\x69\x64\x3a\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
@@ -186,7 +189,8 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
44) == 0) || (end - c > 10 && memcmp(&packet->payload[c], "\r\nX-Queue:", 10) == 0) 44) == 0) || (end - c > 10 && memcmp(&packet->payload[c], "\r\nX-Queue:", 10) == 0)
|| (end - c > 13 && memcmp(&packet->payload[c], "\r\nX-Features:", 13) == 0)) { || (end - c > 13 && memcmp(&packet->payload[c], "\r\nX-Features:", 13) == 0)) {
NDPI_LOG_DBG2(ndpi_struct, "FOXY :: GNUTELLA GET 2 DETECTED\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA,
ndpi_struct, NDPI_LOG_TRACE, "FOXY :: GNUTELLA GET 2 DETECTED\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -198,8 +202,8 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
if (packet->payload_packet_len > 1 && packet->payload[packet->payload_packet_len - 1] == 0x0a if (packet->payload_packet_len > 1 && packet->payload[packet->payload_packet_len - 1] == 0x0a
&& packet->payload[packet->payload_packet_len - 2] == 0x0a) { && packet->payload[packet->payload_packet_len - 2] == 0x0a) {
if (packet->payload_packet_len > 3 && memcmp(packet->payload, "GIV", 3) == 0) { if (packet->payload_packet_len > 3 && memcmp(packet->payload, "GIV", 3) == 0) {
NDPI_LOG_DBG2(ndpi_struct, "MORPHEUS GIV DETECTED\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "MORPHEUS GIV DETECTED\n");
/* Not Excluding the flow now.. We shall Check the next Packet too for Gnutella Patterns */ /* Not Excludeing the flow now.. We shall Check the next Packet too for Gnutella Patterns */
return; return;
} }
} }
@@ -207,21 +211,21 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
if (packet->payload_packet_len == 46 && get_u_int32_t(packet->payload, 0) == htonl(0x802c0103) && if (packet->payload_packet_len == 46 && get_u_int32_t(packet->payload, 0) == htonl(0x802c0103) &&
get_u_int32_t(packet->payload, 4) == htonl(0x01000300) && get_u_int32_t(packet->payload, 8) == htonl(0x00002000) && get_u_int32_t(packet->payload, 4) == htonl(0x01000300) && get_u_int32_t(packet->payload, 8) == htonl(0x00002000) &&
get_u_int16_t(packet->payload, 12) == htons(0x0034)) { get_u_int16_t(packet->payload, 12) == htons(0x0034)) {
NDPI_LOG_DBG2(ndpi_struct, "detected gnutella len == 46\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "detected gnutella len == 46.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
if (packet->payload_packet_len == 49 && if (packet->payload_packet_len == 49 &&
memcmp(packet->payload, "\x80\x2f\x01\x03\x01\x00\x06\x00\x00\x00\x20\x00\x00\x34\x00\x00\xff\x4d\x6c", memcmp(packet->payload, "\x80\x2f\x01\x03\x01\x00\x06\x00\x00\x00\x20\x00\x00\x34\x00\x00\xff\x4d\x6c",
19) == 0) { 19) == 0) {
NDPI_LOG_DBG2(ndpi_struct, "detected gnutella len == 49\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "detected gnutella len == 49.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
if (packet->payload_packet_len == 89 && memcmp(&packet->payload[43], "\x20\x4d\x6c", 3) == 0 && if (packet->payload_packet_len == 89 && memcmp(&packet->payload[43], "\x20\x4d\x6c", 3) == 0 &&
memcmp(packet->payload, "\x16\x03\x01\x00\x54\x01\x00\x00\x50\x03\x01\x4d\x6c", 13) == 0 && memcmp(packet->payload, "\x16\x03\x01\x00\x54\x01\x00\x00\x50\x03\x01\x4d\x6c", 13) == 0 &&
memcmp(&packet->payload[76], "\x00\x02\x00\x34\x01\x00\x00\x05", 8) == 0) { memcmp(&packet->payload[76], "\x00\x02\x00\x34\x01\x00\x00\x05", 8) == 0) {
NDPI_LOG_DBG2(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE,
"detected gnutella asymmetrically len == 388.\n"); "detected gnutella asymmetrically len == 388.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
@@ -231,7 +235,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
&& get_u_int16_t(packet->payload, 8) == htons(0x4903) && get_u_int16_t(packet->payload, 8) == htons(0x4903)
&& get_u_int16_t(packet->payload, 76) == htons(0x0002) && get_u_int16_t(packet->payload, 76) == htons(0x0002)
&& get_u_int32_t(packet->payload, 78) == htonl(0x00340100)) { && get_u_int32_t(packet->payload, 78) == htonl(0x00340100)) {
NDPI_LOG_DBG2(ndpi_struct, "detected len == 82\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "detected len == 82.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -240,7 +244,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
if (src != NULL && (packet->udp->source == src->detected_gnutella_udp_port1 || if (src != NULL && (packet->udp->source == src->detected_gnutella_udp_port1 ||
packet->udp->source == src->detected_gnutella_udp_port2) && packet->udp->source == src->detected_gnutella_udp_port2) &&
(packet->tick_timestamp - src->gnutella_ts) < ndpi_struct->gnutella_timeout) { (packet->tick_timestamp - src->gnutella_ts) < ndpi_struct->gnutella_timeout) {
NDPI_LOG_DBG2(ndpi_struct, "port based detection\n\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG, "port based detection\n\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
} }
/* observations: /* observations:
@@ -253,7 +257,8 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
&& packet->payload[16] == 0x41 && packet->payload[17] == 0x01 && packet->payload[16] == 0x41 && packet->payload[17] == 0x01
&& packet->payload[18] == 0x00 && packet->payload[19] == 0x00 && packet->payload[18] == 0x00 && packet->payload[19] == 0x00
&& packet->payload[20] == 0x00 && packet->payload[21] == 0x00 && packet->payload[22] == 0x00) { && packet->payload[20] == 0x00 && packet->payload[21] == 0x00 && packet->payload[22] == 0x00) {
NDPI_LOG_DBG2(ndpi_struct, "detected gnutella udp, len = 23\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
"detected gnutella udp, len = 23.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
@@ -262,25 +267,29 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
&& packet->payload[26] == 0x50 && packet->payload[27] == 0x40 && packet->payload[26] == 0x50 && packet->payload[27] == 0x40
&& packet->payload[28] == 0x83 && packet->payload[29] == 0x53 && packet->payload[28] == 0x83 && packet->payload[29] == 0x53
&& packet->payload[30] == 0x43 && packet->payload[31] == 0x50 && packet->payload[32] == 0x41) { && packet->payload[30] == 0x43 && packet->payload[31] == 0x50 && packet->payload[32] == 0x41) {
NDPI_LOG_DBG2(ndpi_struct, "detected gnutella udp, len = 35\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
"detected gnutella udp, len = 35.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
if (packet->payload_packet_len == 32 if (packet->payload_packet_len == 32
&& (memcmp(&packet->payload[16], "\x31\x01\x00\x09\x00\x00\x00\x4c\x49\x4d\x45", 11) == 0)) { && (memcmp(&packet->payload[16], "\x31\x01\x00\x09\x00\x00\x00\x4c\x49\x4d\x45", 11) == 0)) {
NDPI_LOG_DBG2(ndpi_struct, "detected gnutella udp, len = 32\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
"detected gnutella udp, len = 32.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
if (packet->payload_packet_len == 34 && (memcmp(&packet->payload[25], "SCP@", 4) == 0) if (packet->payload_packet_len == 34 && (memcmp(&packet->payload[25], "SCP@", 4) == 0)
&& (memcmp(&packet->payload[30], "DNA@", 4) == 0)) { && (memcmp(&packet->payload[30], "DNA@", 4) == 0)) {
NDPI_LOG_DBG2(ndpi_struct, "detected gnutella udp, len = 34\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
"detected gnutella udp, len = 34.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
if ((packet->payload_packet_len == 73 || packet->payload_packet_len == 96) if ((packet->payload_packet_len == 73 || packet->payload_packet_len == 96)
&& memcmp(&packet->payload[32], "urn:sha1:", 9) == 0) { && memcmp(&packet->payload[32], "urn:sha1:", 9) == 0) {
NDPI_LOG_DBG2(ndpi_struct, "detected gnutella udp, len = 73,96\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
"detected gnutella udp, len = 73,96.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -299,7 +308,8 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
&& (memcmp(&packet->payload[6], "\x01\x01\x5c\x1b\x50\x55\x53\x48\x48\x10", 10) == 0)) && (memcmp(&packet->payload[6], "\x01\x01\x5c\x1b\x50\x55\x53\x48\x48\x10", 10) == 0))
|| (packet->payload_packet_len > 200 && packet->payload_packet_len < 300 && packet->payload[3] == 0x03) || (packet->payload_packet_len > 200 && packet->payload_packet_len < 300 && packet->payload[3] == 0x03)
|| (packet->payload_packet_len > 300 && (packet->payload[3] == 0x01 || packet->payload[3] == 0x03))) { || (packet->payload_packet_len > 300 && (packet->payload[3] == 0x01 || packet->payload[3] == 0x03))) {
NDPI_LOG_DBG2(ndpi_struct, "detected gnutella udp, GND\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
"detected gnutella udp, GND.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -307,13 +317,15 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
if ((packet->payload_packet_len == 32) if ((packet->payload_packet_len == 32)
&& memcmp(&packet->payload[16], "\x31\x01\x00\x09\x00\x00\x00", 7) == 0) { && memcmp(&packet->payload[16], "\x31\x01\x00\x09\x00\x00\x00", 7) == 0) {
NDPI_LOG_DBG2(ndpi_struct, "detected gnutella udp, len = 32 ii\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
"detected gnutella udp, len = 32 ii.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
if ((packet->payload_packet_len == 23) if ((packet->payload_packet_len == 23)
&& memcmp(&packet->payload[16], "\x00\x01\x00\x00\x00\x00\x00", 7) == 0) { && memcmp(&packet->payload[16], "\x00\x01\x00\x00\x00\x00\x00", 7) == 0) {
NDPI_LOG_DBG2(ndpi_struct, "detected gnutella udp, len = 23 ii\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
"detected gnutella udp, len = 23 ii.\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -338,7 +350,8 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
&& flow->l4.tcp.gnutella_msg_id[1] == packet->payload[2] && flow->l4.tcp.gnutella_msg_id[1] == packet->payload[2]
&& flow->l4.tcp.gnutella_msg_id[2] == packet->payload[4] && flow->l4.tcp.gnutella_msg_id[2] == packet->payload[4]
&& NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_GNUTELLA)) { && NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_GNUTELLA)) {
NDPI_LOG_DBG2(ndpi_struct, "GNUTELLA DETECTED due to message ID match (NEONet protocol)\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct,
NDPI_LOG_TRACE, "GNUTELLA DETECTED due to message ID match (NEONet protocol)\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -348,14 +361,15 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
&& flow->l4.tcp.gnutella_msg_id[1] == packet->payload[2] && flow->l4.tcp.gnutella_msg_id[1] == packet->payload[2]
&& flow->l4.tcp.gnutella_msg_id[2] == packet->payload[4] && flow->l4.tcp.gnutella_msg_id[2] == packet->payload[4]
&& NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_GNUTELLA)) { && NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_GNUTELLA)) {
NDPI_LOG_DBG2(ndpi_struct, "GNUTELLA DETECTED due to message ID match (NEONet protocol)\n"); NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct,
NDPI_LOG_TRACE, "GNUTELLA DETECTED due to message ID match (NEONet protocol)\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow); ndpi_int_gnutella_add_connection(ndpi_struct, flow);
return; return;
} }
} }
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_GNUTELLA);
} }
+4 -8
View File
@@ -18,14 +18,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_GTP #ifdef NDPI_PROTOCOL_GTP
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_GTP
#include "ndpi_api.h"
struct gtp_header_generic { struct gtp_header_generic {
u_int8_t flags, message_type; u_int8_t flags, message_type;
u_int16_t message_len; u_int16_t message_len;
@@ -54,7 +50,7 @@ static void ndpi_check_gtp(struct ndpi_detection_module_struct *ndpi_struct, str
u_int16_t message_len = ntohs(gtp->message_len); u_int16_t message_len = ntohs(gtp->message_len);
if(message_len <= (payload_len-sizeof(struct gtp_header_generic))) { if(message_len <= (payload_len-sizeof(struct gtp_header_generic))) {
NDPI_LOG_INFO(ndpi_struct, "found gtp\n"); NDPI_LOG(NDPI_PROTOCOL_GTP, ndpi_struct, NDPI_LOG_DEBUG, "Found gtp.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_GTP, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_GTP, NDPI_PROTOCOL_UNKNOWN);
return; return;
} }
@@ -62,7 +58,7 @@ static void ndpi_check_gtp(struct ndpi_detection_module_struct *ndpi_struct, str
} }
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_GTP);
return; return;
} }
@@ -70,7 +66,7 @@ void ndpi_search_gtp(struct ndpi_detection_module_struct *ndpi_struct, struct nd
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search gtp\n"); NDPI_LOG(NDPI_PROTOCOL_GTP, ndpi_struct, NDPI_LOG_DEBUG, "gtp detection...\n");
/* skip marked packets */ /* skip marked packets */
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_GTP) if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_GTP)
+10 -10
View File
@@ -22,14 +22,10 @@
* *
*/ */
#include "ndpi_protocol_ids.h"
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_GUILDWARS #ifdef NDPI_PROTOCOL_GUILDWARS
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_GUILDWARS
#include "ndpi_api.h"
static void ndpi_int_guildwars_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_int_guildwars_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
@@ -40,30 +36,34 @@ void ndpi_search_guildwars_tcp(struct ndpi_detection_module_struct *ndpi_struct,
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search guildwars\n"); // struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG(NDPI_PROTOCOL_GUILDWARS, ndpi_struct, NDPI_LOG_DEBUG, "search guildwars.\n");
if (packet->payload_packet_len == 64 && get_u_int16_t(packet->payload, 1) == ntohs(0x050c) if (packet->payload_packet_len == 64 && get_u_int16_t(packet->payload, 1) == ntohs(0x050c)
&& memcmp(&packet->payload[50], "@2&P", 4) == 0) { && memcmp(&packet->payload[50], "@2&P", 4) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found GuildWars version 29.350\n"); NDPI_LOG(NDPI_PROTOCOL_GUILDWARS, ndpi_struct, NDPI_LOG_DEBUG, "GuildWars version 29.350: found.\n");
ndpi_int_guildwars_add_connection(ndpi_struct, flow); ndpi_int_guildwars_add_connection(ndpi_struct, flow);
return; return;
} }
if (packet->payload_packet_len == 16 && get_u_int16_t(packet->payload, 1) == ntohs(0x040c) if (packet->payload_packet_len == 16 && get_u_int16_t(packet->payload, 1) == ntohs(0x040c)
&& get_u_int16_t(packet->payload, 4) == ntohs(0xa672) && get_u_int16_t(packet->payload, 4) == ntohs(0xa672)
&& packet->payload[8] == 0x01 && packet->payload[12] == 0x04) { && packet->payload[8] == 0x01 && packet->payload[12] == 0x04) {
NDPI_LOG_INFO(ndpi_struct, "found GuildWars version 29.350\n"); NDPI_LOG(NDPI_PROTOCOL_GUILDWARS, ndpi_struct, NDPI_LOG_DEBUG, "GuildWars version 29.350: found.\n");
ndpi_int_guildwars_add_connection(ndpi_struct, flow); ndpi_int_guildwars_add_connection(ndpi_struct, flow);
return; return;
} }
if (packet->payload_packet_len == 21 && get_u_int16_t(packet->payload, 0) == ntohs(0x0100) if (packet->payload_packet_len == 21 && get_u_int16_t(packet->payload, 0) == ntohs(0x0100)
&& get_u_int32_t(packet->payload, 5) == ntohl(0xf1001000) && get_u_int32_t(packet->payload, 5) == ntohl(0xf1001000)
&& packet->payload[9] == 0x01) { && packet->payload[9] == 0x01) {
NDPI_LOG_INFO(ndpi_struct, "found GuildWars version 216.107.245.50\n"); NDPI_LOG(NDPI_PROTOCOL_GUILDWARS, ndpi_struct, NDPI_LOG_DEBUG, "GuildWars version 216.107.245.50: found.\n");
ndpi_int_guildwars_add_connection(ndpi_struct, flow); ndpi_int_guildwars_add_connection(ndpi_struct, flow);
return; return;
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_GUILDWARS, ndpi_struct, NDPI_LOG_DEBUG, "exclude guildwars.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_GUILDWARS);
} }
+12 -19
View File
@@ -7,15 +7,10 @@
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_H323 #ifdef NDPI_PROTOCOL_H323
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_H323
#include "ndpi_api.h"
struct tpkt { struct tpkt {
u_int8_t version, reserved; u_int8_t version, reserved;
u_int16_t len; u_int16_t len;
@@ -26,10 +21,10 @@ void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct n
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
u_int16_t dport = 0, sport = 0; u_int16_t dport = 0, sport = 0;
NDPI_LOG_DBG(ndpi_struct, "search H323\n"); NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "search H323.\n");
if(packet->tcp != NULL) { if(packet->tcp != NULL) {
NDPI_LOG_DBG2(ndpi_struct, "calculated dport over tcp\n"); NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "calculated dport over tcp.\n");
/* H323 */ /* H323 */
if(packet->payload_packet_len >= 3 if(packet->payload_packet_len >= 3
@@ -49,7 +44,6 @@ void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct n
/* ISO 8073/X.224 */ /* ISO 8073/X.224 */
if((packet->payload[5] == 0xE0 /* CC Connect Request */) if((packet->payload[5] == 0xE0 /* CC Connect Request */)
|| (packet->payload[5] == 0xD0 /* CC Connect Confirm */)) { || (packet->payload[5] == 0xD0 /* CC Connect Confirm */)) {
NDPI_LOG_INFO(ndpi_struct, "found RDP\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_RDP, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_RDP, NDPI_PROTOCOL_UNKNOWN);
return; return;
} }
@@ -58,24 +52,23 @@ void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct n
flow->l4.tcp.h323_valid_packets++; flow->l4.tcp.h323_valid_packets++;
if(flow->l4.tcp.h323_valid_packets >= 2) { if(flow->l4.tcp.h323_valid_packets >= 2) {
NDPI_LOG_INFO(ndpi_struct, "found H323 broadcast\n"); NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "found H323 broadcast.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_PROTOCOL_UNKNOWN);
} }
} else { } else {
/* This is not H.323 */ /* This is not H.323 */
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_H323);
return;
} }
} }
} else if(packet->udp != NULL) { } else if(packet->udp != NULL) {
sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest); sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
NDPI_LOG_DBG2(ndpi_struct, "calculated dport over udp\n"); NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "calculated dport over udp.\n");
if(packet->payload_packet_len >= 6 && packet->payload[0] == 0x80 && packet->payload[1] == 0x08 && if(packet->payload_packet_len >= 5 && packet->payload[0] == 0x80 && packet->payload[1] == 0x08 &&
(packet->payload[2] == 0xe7 || packet->payload[2] == 0x26) && (packet->payload[2] == 0xe7 || packet->payload[2] == 0x26) &&
packet->payload[4] == 0x00 && packet->payload[5] == 0x00) packet->payload[4] == 0x00 && packet->payload[5] == 0x00)
{ {
NDPI_LOG_INFO(ndpi_struct, "found H323 broadcast\n"); NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "found H323 broadcast.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_PROTOCOL_UNKNOWN);
return; return;
} }
@@ -84,19 +77,19 @@ void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct n
{ {
if(packet->payload[0] == 0x16 && packet->payload[1] == 0x80 && packet->payload[4] == 0x06 && packet->payload[5] == 0x00) if(packet->payload[0] == 0x16 && packet->payload[1] == 0x80 && packet->payload[4] == 0x06 && packet->payload[5] == 0x00)
{ {
NDPI_LOG_INFO(ndpi_struct, "found H323 broadcast\n"); NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "found H323 broadcast.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_PROTOCOL_UNKNOWN);
return; return;
} }
else if(packet->payload_packet_len >= 20 && packet->payload_packet_len <= 117) else if(packet->payload_packet_len >= 20 || packet->payload_packet_len <= 117)
{ {
NDPI_LOG_INFO(ndpi_struct, "found H323 broadcast\n"); NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "found H323 broadcast.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_PROTOCOL_UNKNOWN);
return; return;
} }
else else
{ {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_H323);
return; return;
} }
} }
+7 -10
View File
@@ -23,14 +23,9 @@
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_HALFLIFE2 #ifdef NDPI_PROTOCOL_HALFLIFE2
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_HALFLIFE2
#include "ndpi_api.h"
static void ndpi_int_halflife2_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_int_halflife2_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
@@ -41,14 +36,15 @@ void ndpi_search_halflife2(struct ndpi_detection_module_struct *ndpi_struct, str
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search halflife2\n"); // struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
if (flow->l4.udp.halflife2_stage == 0) { if (flow->l4.udp.halflife2_stage == 0) {
if (packet->payload_packet_len >= 20 if (packet->payload_packet_len >= 20
&& get_u_int32_t(packet->payload, 0) == 0xFFFFFFFF && get_u_int32_t(packet->payload, 0) == 0xFFFFFFFF
&& get_u_int32_t(packet->payload, packet->payload_packet_len - 4) == htonl(0x30303000)) { && get_u_int32_t(packet->payload, packet->payload_packet_len - 4) == htonl(0x30303000)) {
flow->l4.udp.halflife2_stage = 1 + packet->packet_direction; flow->l4.udp.halflife2_stage = 1 + packet->packet_direction;
NDPI_LOG_DBG2(ndpi_struct, NDPI_LOG(NDPI_PROTOCOL_HALFLIFE2, ndpi_struct, NDPI_LOG_DEBUG,
"halflife2 client req detected, waiting for server reply\n"); "halflife2 client req detected, waiting for server reply\n");
return; return;
} }
@@ -57,12 +53,13 @@ void ndpi_search_halflife2(struct ndpi_detection_module_struct *ndpi_struct, str
&& get_u_int32_t(packet->payload, 0) == 0xFFFFFFFF && get_u_int32_t(packet->payload, 0) == 0xFFFFFFFF
&& get_u_int32_t(packet->payload, packet->payload_packet_len - 4) == htonl(0x30303000)) { && get_u_int32_t(packet->payload, packet->payload_packet_len - 4) == htonl(0x30303000)) {
ndpi_int_halflife2_add_connection(ndpi_struct, flow); ndpi_int_halflife2_add_connection(ndpi_struct, flow);
NDPI_LOG_INFO(ndpi_struct, "found halflife2\n"); NDPI_LOG(NDPI_PROTOCOL_HALFLIFE2, ndpi_struct, NDPI_LOG_DEBUG, "halflife2 server reply detected\n");
return; return;
} }
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_HALFLIFE2);
} }
-112
View File
@@ -1,112 +0,0 @@
/*
* hangout.c
*
* Copyright (C) 2012-16 - ntop.org
*
* This module is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This module is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License.
* If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_HANGOUT
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_HANGOUT
#include "ndpi_api.h"
/* https://support.google.com/a/answer/1279090?hl=en */
#define HANGOUT_UDP_LOW_PORT 19302
#define HANGOUT_UDP_HIGH_PORT 19309
#define HANGOUT_TCP_LOW_PORT 19305
#define HANGOUT_TCP_HIGH_PORT 19309
/* ***************************************************************** */
static u_int8_t isHangoutUDPPort(u_int16_t port) {
if((port >= HANGOUT_UDP_LOW_PORT) && (port <= HANGOUT_UDP_HIGH_PORT))
return(1);
else
return(0);
}
/* ***************************************************************** */
static u_int8_t isHangoutTCPPort(u_int16_t port) {
if((port >= HANGOUT_TCP_LOW_PORT) && (port <= HANGOUT_TCP_HIGH_PORT))
return(1);
else
return(0);
}
/* ******************************************* */
static u_int8_t google_ptree_match(struct ndpi_detection_module_struct *ndpi_struct, struct in_addr *pin) {
return((ndpi_network_ptree_match(ndpi_struct, pin) == NDPI_PROTOCOL_GOOGLE) ? 1 : 0);
}
/* ******************************************* */
static u_int8_t is_google_flow(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet;
if(packet->iph) {
if(google_ptree_match(ndpi_struct, (struct in_addr *)&packet->iph->saddr)
|| google_ptree_match(ndpi_struct, (struct in_addr *)&packet->iph->daddr)) {
return(1);
}
}
return(0);
}
/* ***************************************************************** */
void ndpi_search_hangout(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct * packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search Hangout\n");
if((packet->payload_packet_len > 24) && is_google_flow(ndpi_struct, flow)) {
if(
((packet->udp != NULL) && (isHangoutUDPPort(ntohs(packet->udp->source)) || isHangoutUDPPort(ntohs(packet->udp->dest))))
||
((packet->tcp != NULL) && (isHangoutTCPPort(ntohs(packet->tcp->source)) || isHangoutTCPPort(ntohs(packet->tcp->dest))))) {
NDPI_LOG_INFO(ndpi_struct, "found Hangout\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_HANGOUT, NDPI_PROTOCOL_UNKNOWN);
return;
}
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
/* ***************************************************************** */
void init_hangout_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id,
NDPI_PROTOCOL_BITMASK *detection_bitmask) {
ndpi_set_bitmask_protocol_detection("GoogleHangout", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_HANGOUT,
ndpi_search_hangout,
NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif /* NDPI_PROTOCOL_HANGOUT */
+5 -10
View File
@@ -24,15 +24,9 @@
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_HEP #ifdef NDPI_PROTOCOL_HEP
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_HEP
#include "ndpi_api.h"
static void ndpi_int_hep_add_connection(struct ndpi_detection_module_struct static void ndpi_int_hep_add_connection(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow) *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
@@ -45,16 +39,17 @@ void ndpi_search_hep(struct ndpi_detection_module_struct *ndpi_struct, struct nd
const u_int8_t *packet_payload = packet->payload; const u_int8_t *packet_payload = packet->payload;
u_int32_t payload_len = packet->payload_packet_len; u_int32_t payload_len = packet->payload_packet_len;
NDPI_LOG_DBG(ndpi_struct, "searching HEP\n"); NDPI_LOG(NDPI_PROTOCOL_HEP, ndpi_struct, NDPI_LOG_DEBUG, "searching for HEP.\n");
if (payload_len > 10) { if (payload_len > 10) {
if (memcmp(packet_payload, "HEP3", 4) == 0) { if (memcmp(packet_payload, "HEP3", 4) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found HEP3\n"); NDPI_LOG(NDPI_PROTOCOL_HEP, ndpi_struct, NDPI_LOG_DEBUG, "found HEP3.\n");
ndpi_int_hep_add_connection(ndpi_struct, flow); ndpi_int_hep_add_connection(ndpi_struct, flow);
return; return;
} }
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_HEP, ndpi_struct, NDPI_LOG_DEBUG, "exclude HEP.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_HEP);
} }
+410 -340
View File
File diff suppressed because it is too large Load Diff
+5 -10
View File
@@ -24,14 +24,8 @@
#include "ndpi_protocol_ids.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC #ifdef NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC
#include "ndpi_api.h"
static void ndpi_int_activesync_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_int_activesync_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC, NDPI_PROTOCOL_HTTP); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC, NDPI_PROTOCOL_HTTP);
@@ -41,19 +35,20 @@ void ndpi_search_activesync(struct ndpi_detection_module_struct *ndpi_struct, st
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search activesync\n");
if (packet->tcp != NULL) { if (packet->tcp != NULL) {
if (packet->payload_packet_len > 150 if (packet->payload_packet_len > 150
&& ((memcmp(packet->payload, "OPTIONS /Microsoft-Server-ActiveSync?", 37) == 0) && ((memcmp(packet->payload, "OPTIONS /Microsoft-Server-ActiveSync?", 37) == 0)
|| (memcmp(packet->payload, "POST /Microsoft-Server-ActiveSync?", 34) == 0))) { || (memcmp(packet->payload, "POST /Microsoft-Server-ActiveSync?", 34) == 0))) {
ndpi_int_activesync_add_connection(ndpi_struct, flow); ndpi_int_activesync_add_connection(ndpi_struct, flow);
NDPI_LOG_INFO(ndpi_struct, "found ActiveSync \n"); NDPI_LOG(NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC, ndpi_struct, NDPI_LOG_DEBUG,
" flow marked as ActiveSync \n");
return; return;
} }
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_LOG(NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC, ndpi_struct, NDPI_LOG_DEBUG, "exclude activesync\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC);
} }
+7 -9
View File
@@ -23,15 +23,10 @@
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_IAX #ifdef NDPI_PROTOCOL_IAX
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_IAX
#include "ndpi_api.h"
#define NDPI_IAX_MAX_INFORMATION_ELEMENTS 15 #define NDPI_IAX_MAX_INFORMATION_ELEMENTS 15
static void ndpi_int_iax_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) static void ndpi_int_iax_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
@@ -63,7 +58,7 @@ static void ndpi_search_setup_iax(struct ndpi_detection_module_struct *ndpi_stru
&& packet->payload[11] <= 15) { && packet->payload[11] <= 15) {
if (packet->payload_packet_len == 12) { if (packet->payload_packet_len == 12) {
NDPI_LOG_INFO(ndpi_struct, "found IAX\n"); NDPI_LOG(NDPI_PROTOCOL_IAX, ndpi_struct, NDPI_LOG_DEBUG, "found IAX.\n");
ndpi_int_iax_add_connection(ndpi_struct, flow); ndpi_int_iax_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -71,7 +66,7 @@ static void ndpi_search_setup_iax(struct ndpi_detection_module_struct *ndpi_stru
for (i = 0; i < NDPI_IAX_MAX_INFORMATION_ELEMENTS; i++) { for (i = 0; i < NDPI_IAX_MAX_INFORMATION_ELEMENTS; i++) {
packet_len = packet_len + 2 + packet->payload[packet_len + 1]; packet_len = packet_len + 2 + packet->payload[packet_len + 1];
if (packet_len == packet->payload_packet_len) { if (packet_len == packet->payload_packet_len) {
NDPI_LOG_INFO(ndpi_struct, "found IAX\n"); NDPI_LOG(NDPI_PROTOCOL_IAX, ndpi_struct, NDPI_LOG_DEBUG, "found IAX.\n");
ndpi_int_iax_add_connection(ndpi_struct, flow); ndpi_int_iax_add_connection(ndpi_struct, flow);
return; return;
} }
@@ -82,13 +77,16 @@ static void ndpi_search_setup_iax(struct ndpi_detection_module_struct *ndpi_stru
} }
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_IAX);
} }
void ndpi_search_iax(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) void ndpi_search_iax(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_flow_struct *flow=ndpi_struct->flow;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
if(packet->udp if(packet->udp
&& (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN)) && (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN))

Some files were not shown because too many files have changed in this diff Show More