aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/afp.c
diff options
context:
space:
mode:
authorLuca <deri@ntop.org>2015-07-01 17:40:14 +0200
committerLuca <deri@ntop.org>2015-07-01 17:40:14 +0200
commit60884f9047882863d27f7e8f5fb760897c599800 (patch)
tree2b09f2ec1a551b59a98baee790c858fb3e038ffe /src/lib/protocols/afp.c
parent49ea23530f876930896dc5aa6a84ef6219589171 (diff)
Split former protocol into upper and lower protocol
Diffstat (limited to 'src/lib/protocols/afp.c')
-rw-r--r--src/lib/protocols/afp.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/src/lib/protocols/afp.c b/src/lib/protocols/afp.c
index 5eb7862b4..2ed7b5ccc 100644
--- a/src/lib/protocols/afp.c
+++ b/src/lib/protocols/afp.c
@@ -29,7 +29,7 @@
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_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AFP, NDPI_PROTOCOL_UNKNOWN);
}
@@ -37,39 +37,38 @@ void ndpi_search_afp(struct ndpi_detection_module_struct *ndpi_struct, struct nd
{
struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src = flow->src;
-// struct ndpi_id_struct *dst = flow->dst;
+ // struct ndpi_id_struct *dst = flow->dst;
+ /*
+ * 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 >= 22 && get_u_int16_t(packet->payload, 0) == htons(0x0004) &&
+ 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(0x0104)) {
- /*
- * 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 >= 22 && get_u_int16_t(packet->payload, 0) == htons(0x0004) &&
- 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(0x0104)) {
+ NDPI_LOG(NDPI_PROTOCOL_AFP, ndpi_struct, NDPI_LOG_DEBUG, "AFP: DSI OpenSession detected.\n");
+ ndpi_int_afp_add_connection(ndpi_struct, flow);
+ return;
+ }
- NDPI_LOG(NDPI_PROTOCOL_AFP, ndpi_struct, NDPI_LOG_DEBUG, "AFP: DSI OpenSession detected.\n");
- ndpi_int_afp_add_connection(ndpi_struct, flow);
- return;
- }
+ /*
+ * detection of GetStatus command of DSI protocl
+ */
+ if (packet->payload_packet_len >= 18 && get_u_int16_t(packet->payload, 0) == htons(0x0003) &&
+ 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)) {
- /*
- * detection of GetStatus command of DSI protocl
- */
- if (packet->payload_packet_len >= 18 && get_u_int16_t(packet->payload, 0) == htons(0x0003) &&
- 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);
+ return;
+ }
- NDPI_LOG(NDPI_PROTOCOL_AFP, ndpi_struct, NDPI_LOG_DEBUG, "AFP: DSI GetStatus detected.\n");
- ndpi_int_afp_add_connection(ndpi_struct, flow);
- return;
- }
-
- 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);
+ 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);
}
#endif