Merge pull request #848 from aouinizied/dev
nDPI 3.2 support in python cffi bindings
This commit is contained in:
+19
-20
@@ -1,7 +1,25 @@
|
|||||||
nDPI Python bindings
|
nDPI Python bindings
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
This directory contains the Python3 bindings for nDPI. We provide both ctypes and cffi based bindings.
|
This directory contains the Python3 bindings for nDPI. We provide both cffi and ctypes based bindings.
|
||||||
|
|
||||||
|
**cffi bindings**
|
||||||
|
|
||||||
|
Files:
|
||||||
|
|
||||||
|
* ndpi.py
|
||||||
|
|
||||||
|
Example (using `nfstream <https://github.com/aouinizied/nfstream>`_ package):
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
pip3 install nfstream
|
||||||
|
python3 flow_printer.py <interface>
|
||||||
|
python3 flow_printer.py <pcap_file>
|
||||||
|
|
||||||
|
Code courtesy:
|
||||||
|
|
||||||
|
* Zied Aouini
|
||||||
|
|
||||||
**ctypes bindings**
|
**ctypes bindings**
|
||||||
|
|
||||||
@@ -23,22 +41,3 @@ Code courtesy:
|
|||||||
|
|
||||||
* Massimo Puddu
|
* Massimo Puddu
|
||||||
* Zied Aouini
|
* Zied Aouini
|
||||||
|
|
||||||
**cffi bindings**
|
|
||||||
|
|
||||||
Files:
|
|
||||||
|
|
||||||
* ndpi.py
|
|
||||||
|
|
||||||
|
|
||||||
Example (using NFStream package):
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
pip3 install nfstream
|
|
||||||
python3 flow_printer.py <interface>
|
|
||||||
python3 flow_printer.py <pcap_file>
|
|
||||||
|
|
||||||
Code courtesy:
|
|
||||||
|
|
||||||
* Zied Aouini
|
|
||||||
+824
-746
File diff suppressed because it is too large
Load Diff
@@ -78,6 +78,25 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
u_int32_t ndpi_detection_get_sizeof_ndpi_id_struct(void);
|
u_int32_t ndpi_detection_get_sizeof_ndpi_id_struct(void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the size of the flow tcp struct
|
||||||
|
*
|
||||||
|
* @return the size of the flow tcp struct
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_tcp_struct(void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the size of the flow udp struct
|
||||||
|
*
|
||||||
|
* @return the size of the flow udp struct
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_udp_struct(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nDPI personal allocation and free functions
|
* nDPI personal allocation and free functions
|
||||||
**/
|
**/
|
||||||
|
|||||||
@@ -712,11 +712,7 @@ struct ndpi_flow_tcp_struct {
|
|||||||
|
|
||||||
/* NDPI_PROTOCOL_NEST_LOG_SINK */
|
/* NDPI_PROTOCOL_NEST_LOG_SINK */
|
||||||
u_int8_t nest_log_sink_matches;
|
u_int8_t nest_log_sink_matches;
|
||||||
}
|
};
|
||||||
#ifndef WIN32
|
|
||||||
__attribute__ ((__packed__))
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
/* ************************************************** */
|
/* ************************************************** */
|
||||||
|
|
||||||
@@ -771,11 +767,7 @@ struct ndpi_flow_udp_struct {
|
|||||||
/* NDPI_PROTOCOL_WIREGUARD */
|
/* NDPI_PROTOCOL_WIREGUARD */
|
||||||
u_int8_t wireguard_stage;
|
u_int8_t wireguard_stage;
|
||||||
u_int32_t wireguard_peer_index[2];
|
u_int32_t wireguard_peer_index[2];
|
||||||
}
|
};
|
||||||
#ifndef WIN32
|
|
||||||
__attribute__ ((__packed__))
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
/* ************************************************** */
|
/* ************************************************** */
|
||||||
|
|
||||||
@@ -799,10 +791,6 @@ struct ndpi_packet_struct {
|
|||||||
|
|
||||||
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_SIZE];
|
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_SIZE];
|
||||||
u_int8_t detected_subprotocol_stack[NDPI_PROTOCOL_SIZE];
|
u_int8_t detected_subprotocol_stack[NDPI_PROTOCOL_SIZE];
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
__attribute__ ((__packed__))
|
|
||||||
#endif
|
|
||||||
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];
|
||||||
@@ -1145,9 +1133,6 @@ typedef enum {
|
|||||||
|
|
||||||
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_SIZE];
|
||||||
#ifndef WIN32
|
|
||||||
__attribute__ ((__packed__))
|
|
||||||
#endif
|
|
||||||
u_int16_t protocol_stack_info;
|
u_int16_t protocol_stack_info;
|
||||||
|
|
||||||
/* init parameter, internal used to set up timestamp,... */
|
/* init parameter, internal used to set up timestamp,... */
|
||||||
|
|||||||
@@ -165,6 +165,14 @@ u_int32_t ndpi_detection_get_sizeof_ndpi_id_struct(void) { return(sizeof(struct
|
|||||||
|
|
||||||
/* *********************************************************************************** */
|
/* *********************************************************************************** */
|
||||||
|
|
||||||
|
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_tcp_struct(void) { return(sizeof(struct ndpi_flow_tcp_struct)); }
|
||||||
|
|
||||||
|
/* *********************************************************************************** */
|
||||||
|
|
||||||
|
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_udp_struct(void) { return(sizeof(struct ndpi_flow_udp_struct)); }
|
||||||
|
|
||||||
|
/* *********************************************************************************** */
|
||||||
|
|
||||||
char * ndpi_get_proto_by_id(struct ndpi_detection_module_struct *ndpi_str, u_int id) {
|
char * ndpi_get_proto_by_id(struct ndpi_detection_module_struct *ndpi_str, u_int id) {
|
||||||
return((id >= ndpi_str->ndpi_num_supported_protocols) ? NULL : ndpi_str->proto_defaults[id].protoName);
|
return((id >= ndpi_str->ndpi_num_supported_protocols) ? NULL : ndpi_str->proto_defaults[id].protoName);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user