Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arne Øslebø
mapi
Commits
7d223639
Commit
7d223639
authored
Mar 20, 2008
by
Browse files
Added basic support for POS protocol.
git-svn-id:
file:///home/svn/mapi/trunk@1394
8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent
bcf18b6c
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/trackflib/dc.c
View file @
7d223639
...
...
@@ -6,6 +6,7 @@
#include <sys/shm.h>
#include <string.h>
#include <errno.h>
#include "mapidflib.h"
#include "mapidlib.h"
#include "mapidevices.h"
...
...
@@ -17,8 +18,7 @@
#include "acsmx2.h"
#include "mapi_errors.h"
#include <stdio.h>
#include <stdlib.h>
#include <pcap.h>
#include <netinet/in.h>
#include <net/ethernet.h>
#include <netinet/ip.h>
...
...
@@ -35,7 +35,6 @@
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <time.h>
...
...
@@ -192,6 +191,10 @@ static int dc_process(mapidflib_function_instance_t *instance,
struct
list
**
dclist
=
((
struct
mapid_dc
*
)
instance
->
internal_data
)
->
dclist
;
uint16_t
ethertype
;
struct
ether_header
*
ep
=
NULL
;
struct
pos_header
{
uint16_t
af
;
uint16_t
cf
;
}
*
pp
=
NULL
;
struct
iphdr
*
iph
=
NULL
;
struct
tcphdr
*
tcph
=
NULL
;
struct
udphdr
*
udph
=
NULL
;
...
...
@@ -211,28 +214,48 @@ static int dc_process(mapidflib_function_instance_t *instance,
if
(
pkt_color
!=
0
&&
pkt_color
!=
DC_COLOR
)
{
return
0
;
}
p
=
pkt
;
// lay the Ethernet header struct over the packet data
ep
=
(
struct
ether_header
*
)
p
;
switch
(
instance
->
hwinfo
->
link_type
)
{
case
DLT_EN10MB
:
// lay the Ethernet header struct over the packet data
ep
=
(
struct
ether_header
*
)
p
;
// skip ethernet header
p
+=
sizeof
(
struct
ether_header
);
len
-=
sizeof
(
struct
ether_header
);
// skip ethernet header
p
+=
sizeof
(
struct
ether_header
);
len
-=
sizeof
(
struct
ether_header
);
ethertype
=
ntohs
(
ep
->
ether_type
);
ethertype
=
ntohs
(
ep
->
ether_type
);
if
(
ethertype
==
ETHERTYPE_8021Q
)
{
vlan_header
=
(
struct
vlan_802q_header
*
)
p
;
ethertype
=
ntohs
(
vlan_header
->
ether_type
);
p
+=
sizeof
(
struct
vlan_802q_header
);
}
if
(
ethertype
==
ETHERTYPE_8021Q
)
{
vlan_header
=
(
struct
vlan_802q_header
*
)
p
;
ethertype
=
ntohs
(
vlan_header
->
ether_type
);
p
+=
sizeof
(
struct
vlan_802q_header
);
}
if
(
ethertype
==
MPLS_MASK
)
{
p
+=
4
;
}
else
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
}
break
;
case
DLT_CHDLC
:
pp
=
(
struct
pos_header
*
)
p
;
if
(
ethertype
==
MPLS_MASK
)
{
p
+=
4
;
}
else
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
p
+=
sizeof
(
struct
pos_header
);
len
-=
sizeof
(
struct
pos_header
);
ethertype
=
ntohs
(
pp
->
cf
);
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
}
break
;
default:
//DEBUG_CMD(Debug_Message("Link layer not supported"));
return
0
;
}
// IP header struct over the packet data;
...
...
src/trackflib/edonkey.c
View file @
7d223639
...
...
@@ -7,6 +7,7 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "mapidflib.h"
#include "mapidlib.h"
#include "mapidevices.h"
...
...
@@ -15,6 +16,8 @@
#include "debug.h"
#include "mapiipc.h"
#include "mstring.h"
#include <pcap.h>
#include <netinet/in.h>
#include <net/ethernet.h>
#include <netinet/ip.h>
...
...
@@ -277,6 +280,10 @@ static int edonkey_process(mapidflib_function_instance_t *instance,
struct
list
**
edonkeylist
=
((
struct
mapid_edonkey
*
)
instance
->
internal_data
)
->
edonkeylist
;
uint16_t
ethertype
;
struct
ether_header
*
ep
=
NULL
;
struct
pos_header
{
uint16_t
af
;
uint16_t
cf
;
}
*
pp
=
NULL
;
struct
iphdr
*
iph
=
NULL
;
struct
tcphdr
*
tcph
=
NULL
;
struct
udphdr
*
udph
=
NULL
;
...
...
@@ -303,27 +310,47 @@ static int edonkey_process(mapidflib_function_instance_t *instance,
p
=
pkt
;
// lay the Ethernet header struct over the packet data
ep
=
(
struct
ether_header
*
)
p
;
ether_len
=
sizeof
(
struct
ether_header
);
switch
(
instance
->
hwinfo
->
link_type
)
{
case
DLT_EN10MB
:
// lay the Ethernet header struct over the packet data
ep
=
(
struct
ether_header
*
)
p
;
ether_len
=
sizeof
(
struct
ether_header
);
// skip ethernet header
p
+=
sizeof
(
struct
ether_header
);
len
-=
sizeof
(
struct
ether_header
);
// skip ethernet header
p
+=
sizeof
(
struct
ether_header
);
len
-=
sizeof
(
struct
ether_header
);
ethertype
=
ntohs
(
ep
->
ether_type
);
ethertype
=
ntohs
(
ep
->
ether_type
);
if
(
ethertype
==
ETHERTYPE_8021Q
)
{
vlan_header
=
(
struct
vlan_802q_header
*
)
p
;
ethertype
=
ntohs
(
vlan_header
->
ether_type
);
p
+=
sizeof
(
struct
vlan_802q_header
);
}
if
(
ethertype
==
ETHERTYPE_8021Q
)
{
vlan_header
=
(
struct
vlan_802q_header
*
)
p
;
ethertype
=
ntohs
(
vlan_header
->
ether_type
);
p
+=
sizeof
(
struct
vlan_802q_header
);
}
if
(
ethertype
==
MPLS_MASK
)
{
p
+=
4
;
}
else
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
}
break
;
case
DLT_CHDLC
:
pp
=
(
struct
pos_header
*
)
p
;
ether_len
=
sizeof
(
struct
pos_header
);
if
(
ethertype
==
MPLS_MASK
)
{
p
+=
4
;
}
else
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
p
+=
sizeof
(
struct
pos_header
);
len
-=
sizeof
(
struct
pos_header
);
ethertype
=
ntohs
(
pp
->
cf
);
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
}
break
;
default:
//DEBUG_CMD(Debug_Message("Link layer not supported"));
return
0
;
}
// IP header struct over the packet data;
...
...
src/trackflib/gnutella.c
View file @
7d223639
...
...
@@ -6,6 +6,7 @@
#include <sys/shm.h>
#include <string.h>
#include <errno.h>
#include "mapidflib.h"
#include "mapidlib.h"
#include "mapidevices.h"
...
...
@@ -17,8 +18,7 @@
#include "acsmx2.h"
#include "mapi_errors.h"
#include <stdio.h>
#include <stdlib.h>
#include <pcap.h>
#include <netinet/in.h>
#include <net/ethernet.h>
#include <netinet/ip.h>
...
...
@@ -35,7 +35,6 @@
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <time.h>
...
...
@@ -177,6 +176,10 @@ static int gnutella_process(mapidflib_function_instance_t *instance,
struct
list
**
gnulist
=
((
struct
mapid_gnutella
*
)
instance
->
internal_data
)
->
gnulist
;
uint16_t
ethertype
;
struct
ether_header
*
ep
=
NULL
;
struct
pos_header
{
uint16_t
af
;
uint16_t
cf
;
}
*
pp
=
NULL
;
struct
iphdr
*
iph
=
NULL
;
struct
tcphdr
*
tcph
=
NULL
;
struct
udphdr
*
udph
=
NULL
;
...
...
@@ -199,26 +202,45 @@ static int gnutella_process(mapidflib_function_instance_t *instance,
p
=
pkt
;
// lay the Ethernet header struct over the packet data
ep
=
(
struct
ether_header
*
)
p
;
switch
(
instance
->
hwinfo
->
link_type
)
{
case
DLT_EN10MB
:
// lay the Ethernet header struct over the packet data
ep
=
(
struct
ether_header
*
)
p
;
// skip ethernet header
p
+=
sizeof
(
struct
ether_header
);
len
-=
sizeof
(
struct
ether_header
);
// skip ethernet header
p
+=
sizeof
(
struct
ether_header
);
len
-=
sizeof
(
struct
ether_header
);
ethertype
=
ntohs
(
ep
->
ether_type
);
ethertype
=
ntohs
(
ep
->
ether_type
);
if
(
ethertype
==
ETHERTYPE_8021Q
)
{
vlan_header
=
(
struct
vlan_802q_header
*
)
p
;
ethertype
=
ntohs
(
vlan_header
->
ether_type
);
p
+=
sizeof
(
struct
vlan_802q_header
);
}
if
(
ethertype
==
MPLS_MASK
)
{
p
+=
4
;
}
else
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
if
(
ethertype
==
ETHERTYPE_8021Q
)
{
vlan_header
=
(
struct
vlan_802q_header
*
)
p
;
ethertype
=
ntohs
(
vlan_header
->
ether_type
);
p
+=
sizeof
(
struct
vlan_802q_header
);
}
if
(
ethertype
==
MPLS_MASK
)
{
p
+=
4
;
}
else
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
}
break
;
case
DLT_CHDLC
:
pp
=
(
struct
pos_header
*
)
p
;
p
+=
sizeof
(
struct
pos_header
);
len
-=
sizeof
(
struct
pos_header
);
ethertype
=
ntohs
(
pp
->
cf
);
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
}
break
;
default:
//DEBUG_CMD(Debug_Message("Link layer not supported"));
return
0
;
}
// IP header struct over the packet data;
...
...
src/trackflib/gridftp.c
View file @
7d223639
...
...
@@ -6,6 +6,7 @@
#include <sys/shm.h>
#include <string.h>
#include <errno.h>
#include "mapidflib.h"
#include "mapidlib.h"
#include "mapidevices.h"
...
...
@@ -14,8 +15,8 @@
#include "debug.h"
#include "mapiipc.h"
#include "mstring.h"
#include <stdio.h>
#include <
stdlib
.h>
#include <
pcap
.h>
#include <netinet/in.h>
#include <net/ethernet.h>
#include <netinet/ip.h>
...
...
@@ -32,7 +33,6 @@
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <time.h>
...
...
@@ -101,6 +101,10 @@ static int gridftp_process(mapidflib_function_instance_t *instance,
struct
list
**
cntlist
=
((
struct
mapid_ftp
*
)
instance
->
internal_data
)
->
cntlist
;
uint16_t
ethertype
;
struct
ether_header
*
ep
=
NULL
;
struct
pos_header
{
uint16_t
af
;
uint16_t
cf
;
}
*
pp
=
NULL
;
struct
iphdr
*
iph
=
NULL
;
struct
tcphdr
*
tcph
=
NULL
;
...
...
@@ -119,26 +123,45 @@ static int gridftp_process(mapidflib_function_instance_t *instance,
}
p
=
pkt
;
// lay the Ethernet header struct over the packet data
ep
=
(
struct
ether_header
*
)
p
;
switch
(
instance
->
hwinfo
->
link_type
)
{
case
DLT_EN10MB
:
// lay the Ethernet header struct over the packet data
ep
=
(
struct
ether_header
*
)
p
;
// skip ethernet header
p
+=
sizeof
(
struct
ether_header
);
len
-=
sizeof
(
struct
ether_header
);
// skip ethernet header
p
+=
sizeof
(
struct
ether_header
);
len
-=
sizeof
(
struct
ether_header
);
ethertype
=
ntohs
(
ep
->
ether_type
);
if
(
ethertype
==
ETHERTYPE_8021Q
)
{
vlan_header
=
(
struct
vlan_802q_header
*
)
p
;
ethertype
=
ntohs
(
vlan_header
->
ether_type
);
p
+=
sizeof
(
struct
vlan_802q_header
);
}
ethertype
=
ntohs
(
ep
->
ether_type
);
if
(
ethertype
==
MPLS_MASK
)
{
p
+=
4
;
}
else
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
if
(
ethertype
==
ETHERTYPE_8021Q
)
{
vlan_header
=
(
struct
vlan_802q_header
*
)
p
;
ethertype
=
ntohs
(
vlan_header
->
ether_type
);
p
+=
sizeof
(
struct
vlan_802q_header
);
}
if
(
ethertype
==
MPLS_MASK
)
{
p
+=
4
;
}
else
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
}
break
;
case
DLT_CHDLC
:
pp
=
(
struct
pos_header
*
)
p
;
p
+=
sizeof
(
struct
pos_header
);
len
-=
sizeof
(
struct
pos_header
);
ethertype
=
ntohs
(
pp
->
cf
);
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
}
break
;
default:
//DEBUG_CMD(Debug_Message("Link layer not supported"));
return
0
;
}
// IP header struct over the packet data;
...
...
src/trackflib/irc.c
View file @
7d223639
...
...
@@ -6,6 +6,7 @@
#include <sys/shm.h>
#include <string.h>
#include <errno.h>
#include "mapidflib.h"
#include "mapidlib.h"
#include "mapidevices.h"
...
...
@@ -14,8 +15,8 @@
#include "debug.h"
#include "mapiipc.h"
#include "mstring.h"
#include <stdio.h>
#include <
stdlib
.h>
#include <
pcap
.h>
#include <netinet/in.h>
#include <net/ethernet.h>
#include <netinet/ip.h>
...
...
@@ -32,7 +33,6 @@
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <time.h>
...
...
@@ -132,6 +132,10 @@ static int irc_process(mapidflib_function_instance_t *instance,
struct
list
**
irclist
=
((
struct
mapid_irc
*
)
instance
->
internal_data
)
->
irclist
;
uint16_t
ethertype
;
struct
ether_header
*
ep
=
NULL
;
struct
pos_header
{
uint16_t
af
;
uint16_t
cf
;
}
*
pp
=
NULL
;
struct
iphdr
*
iph
=
NULL
;
struct
tcphdr
*
tcph
=
NULL
;
struct
udphdr
*
udph
=
NULL
;
...
...
@@ -148,26 +152,45 @@ static int irc_process(mapidflib_function_instance_t *instance,
p
=
pkt
;
// lay the Ethernet header struct over the packet data
ep
=
(
struct
ether_header
*
)
p
;
switch
(
instance
->
hwinfo
->
link_type
)
{
case
DLT_EN10MB
:
// lay the Ethernet header struct over the packet data
ep
=
(
struct
ether_header
*
)
p
;
// skip ethernet header
p
+=
sizeof
(
struct
ether_header
);
len
-=
sizeof
(
struct
ether_header
);
// skip ethernet header
p
+=
sizeof
(
struct
ether_header
);
len
-=
sizeof
(
struct
ether_header
);
ethertype
=
ntohs
(
ep
->
ether_type
);
ethertype
=
ntohs
(
ep
->
ether_type
);
if
(
ethertype
==
ETHERTYPE_8021Q
)
{
vlan_header
=
(
struct
vlan_802q_header
*
)
p
;
ethertype
=
ntohs
(
vlan_header
->
ether_type
);
p
+=
sizeof
(
struct
vlan_802q_header
);
}
if
(
ethertype
==
ETHERTYPE_8021Q
)
{
vlan_header
=
(
struct
vlan_802q_header
*
)
p
;
ethertype
=
ntohs
(
vlan_header
->
ether_type
);
p
+=
sizeof
(
struct
vlan_802q_header
);
}
if
(
ethertype
==
MPLS_MASK
)
{
p
+=
4
;
}
else
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
}
break
;
case
DLT_CHDLC
:
pp
=
(
struct
pos_header
*
)
p
;
if
(
ethertype
==
MPLS_MASK
)
{
p
+=
4
;
}
else
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
p
+=
sizeof
(
struct
pos_header
);
len
-=
sizeof
(
struct
pos_header
);
ethertype
=
ntohs
(
pp
->
cf
);
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
}
break
;
default:
//DEBUG_CMD(Debug_Message("Link layer not supported"));
return
0
;
}
// IP header struct over the packet data;
...
...
src/trackflib/skype.c
View file @
7d223639
...
...
@@ -6,6 +6,7 @@
#include <sys/shm.h>
#include <string.h>
#include <errno.h>
#include "mapidflib.h"
#include "mapidlib.h"
#include "mapidevices.h"
...
...
@@ -14,8 +15,8 @@
#include "debug.h"
#include "mapiipc.h"
#include "mstring.h"
#include <stdio.h>
#include <
stdlib
.h>
#include <
pcap
.h>
#include <netinet/in.h>
#include <net/ethernet.h>
#include <netinet/ip.h>
...
...
@@ -32,7 +33,6 @@
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/time.h>
...
...
@@ -272,6 +272,10 @@ static int trackskype_process(mapidflib_function_instance_t *instance,
struct
list
**
cntlist
=
((
struct
mapid_skype
*
)
instance
->
internal_data
)
->
cntlist
;
uint16_t
ethertype
;
struct
ether_header
*
ep
=
NULL
;
struct
pos_header
{
uint16_t
af
;
uint16_t
cf
;
}
*
pp
=
NULL
;
struct
iphdr
*
iph
=
NULL
;
struct
tcphdr
*
tcph
=
NULL
;
struct
udphdr
*
udph
=
NULL
;
...
...
@@ -293,28 +297,48 @@ static int trackskype_process(mapidflib_function_instance_t *instance,
if
(
pkt_color
!=
0
&&
pkt_color
!=
SKYPE_COLOR
)
{
return
0
;
}
p
=
pkt
;
// lay the Ethernet header struct over the packet data
ep
=
(
struct
ether_header
*
)
p
;
switch
(
instance
->
hwinfo
->
link_type
)
{
case
DLT_EN10MB
:
// lay the Ethernet header struct over the packet data
ep
=
(
struct
ether_header
*
)
p
;
// skip ethernet header
p
+=
sizeof
(
struct
ether_header
);
len
-=
sizeof
(
struct
ether_header
);
// skip ethernet header
p
+=
sizeof
(
struct
ether_header
);
len
-=
sizeof
(
struct
ether_header
);
ethertype
=
ntohs
(
ep
->
ether_type
);
if
(
ethertype
==
ETHERTYPE_8021Q
)
{
vlan_header
=
(
struct
vlan_802q_header
*
)
p
;
ethertype
=
ntohs
(
vlan_header
->
ether_type
);
p
+=
sizeof
(
struct
vlan_802q_header
);
}
ethertype
=
ntohs
(
ep
->
ether_type
);
if
(
ethertype
==
MPLS_MASK
)
{
p
+=
4
;
}
else
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
if
(
ethertype
==
ETHERTYPE_8021Q
)
{
vlan_header
=
(
struct
vlan_802q_header
*
)
p
;
ethertype
=
ntohs
(
vlan_header
->
ether_type
);
p
+=
sizeof
(
struct
vlan_802q_header
);
}
if
(
ethertype
==
MPLS_MASK
)
{
p
+=
4
;
}
else
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
}
break
;
case
DLT_CHDLC
:
pp
=
(
struct
pos_header
*
)
p
;
p
+=
sizeof
(
struct
pos_header
);
len
-=
sizeof
(
struct
pos_header
);
ethertype
=
ntohs
(
pp
->
cf
);
if
(
ethertype
!=
ETHERTYPE_IP
)
{
return
0
;
}
break
;
default:
//DEBUG_CMD(Debug_Message("Link layer not supported"));
return
0
;
}
// IP header struct over the packet data;
...
...
src/trackflib/torrent.c
View file @
7d223639
...
...
@@ -18,8 +18,7 @@
#include "acsmx2.h"
#include "mapi_errors.h"
#include <stdio.h>
#include <stdlib.h>
#include <pcap.h>
#include <netinet/in.h>
#include <net/ethernet.h>
#include <netinet/ip.h>
...
...
@@ -36,7 +35,6 @@
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <time.h>
...
...
@@ -220,6 +218,10 @@ static int torrent_process(mapidflib_function_instance_t *instance,
struct
list
**
torlist
=
((
struct
mapid_torrent
*
)
instance
->
internal_data
)
->
torlist
;
uint16_t
ethertype
;
struct
ether_header
*
ep
=
NULL
;
struct
pos_header
{
uint16_t
af
;
uint16_t
cf
;
}
*
pp
=
NULL
;
struct
iphdr
*
iph
=
NULL
;
struct
tcphdr
*
tcph
=
NULL
;
struct
udphdr
*
udph
=
NULL
;
...
...
@@ -235,7 +237,7 @@ static int torrent_process(mapidflib_function_instance_t *instance,
int
i
=
0
;
int
ether_len
=
0
,
ip_len
=
0
,
tcp_len
=
0
,
udp_len
=
0
;
int
ip_len
=
0
,
tcp_len
=
0
,
udp_len
=
0
;
int
pkt_color
=
pkt_head
->
color
;
...
...
@@ -244,29 +246,99 @@ static int torrent_process(mapidflib_function_instance_t *instance,
}
p
=
pkt
;
/*
typedef struct flags {
uint8_t iface:2;
uint8_t vlen:1;