Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f561e14271 | ||
|
|
a6c56b5682 | ||
|
|
e5546eb988 | ||
|
|
3577072b12 | ||
|
|
5b03443693 | ||
|
|
8af18763cc | ||
|
|
840dab894f | ||
|
|
df7015f3a5 | ||
|
|
8547b50be7 | ||
|
|
7090ef838c | ||
|
|
950f5db3dd | ||
|
|
8eaf0cefa1 | ||
|
|
8b1f8636d1 | ||
|
|
1b5c90cfbe | ||
|
|
33e0be73f7 | ||
|
|
6e62367b56 | ||
|
|
d6176ff668 | ||
|
|
2831d64f6a | ||
|
|
a4532a4999 | ||
|
|
3caac691d5 | ||
|
|
c9f32ee76d | ||
|
|
a488c9b7dc | ||
|
|
3e53577936 | ||
|
|
a0980228ef | ||
|
|
6e6b623057 | ||
|
|
159e6228fe | ||
|
|
cf07c92538 | ||
|
|
23e08c93b6 | ||
|
|
169aa11adc | ||
|
|
7e38a4f790 | ||
|
|
4f72b954da | ||
|
|
5dbe705dd3 | ||
|
|
2155dd9153 | ||
|
|
f7e95b4ee8 | ||
|
|
36adc23507 | ||
|
|
2ee871f5e6 | ||
|
|
39d7738042 | ||
|
|
75993242b0 | ||
|
|
83d5a46ec4 | ||
|
|
7f197d12dd | ||
|
|
d273b67fd7 | ||
|
|
aefd16647e | ||
|
|
98d1c762cd | ||
|
|
2476c3c1b6 | ||
|
|
ed830d2474 | ||
|
|
8bcafff569 | ||
|
|
9b91623d57 | ||
|
|
27d66f6845 | ||
|
|
b10e526364 | ||
|
|
cf26e8429e | ||
|
|
094ddc2048 | ||
|
|
25a4569e67 | ||
|
|
47f922fa7b | ||
|
|
82c244b04f | ||
|
|
f80f0eedc0 | ||
|
|
1b162234f0 | ||
|
|
3ac47a5104 | ||
|
|
b2f0558080 | ||
|
|
50624b390e | ||
|
|
1dd93590e4 | ||
|
|
662ef2f65b | ||
|
|
83104eb8b6 | ||
|
|
cd2a328cc5 | ||
|
|
f255b10524 | ||
|
|
4ba6ba70c5 | ||
|
|
0827a6bf8b | ||
|
|
4348109931 | ||
|
|
59097a2d30 | ||
|
|
b129487636 | ||
|
|
2c014c5693 | ||
|
|
80fa0b5f98 | ||
|
|
688d7c33e4 | ||
|
|
b0f3852fed | ||
|
|
cd595caf8d | ||
|
|
c115903fbb | ||
|
|
807db80afc | ||
|
|
8939a72ea8 | ||
|
|
baae16ec2f | ||
|
|
41b40ddf18 | ||
|
|
8cc2b04f3c | ||
|
|
98b3268bfb | ||
|
|
f575959cd2 | ||
|
|
c2002cd48f | ||
|
|
9fb5981128 | ||
|
|
1a4e57e736 | ||
|
|
d6f7dd9c08 | ||
|
|
4176fd5068 | ||
|
|
1808519b5b | ||
|
|
83b1b34c18 | ||
|
|
b4d535e184 | ||
|
|
f7e9264c36 | ||
|
|
d4d4f2a17c | ||
|
|
d3d6a95da7 | ||
|
|
8a6a8ea07e | ||
|
|
ecb048a7bc | ||
|
|
8e8445e02f | ||
|
|
0e3248b0f7 | ||
|
|
0e8756ab46 | ||
|
|
b2bc6039da | ||
|
|
22beb7714d | ||
|
|
299b9435d0 | ||
|
|
31478703c2 | ||
|
|
a1367a9d39 | ||
|
|
7dc20134c0 | ||
|
|
63c97753a1 | ||
|
|
5515c3a109 | ||
|
|
5547ef06b3 | ||
|
|
65b39240aa | ||
|
|
449e06df77 | ||
|
|
c4885fe260 | ||
|
|
5a8aa3d72d | ||
|
|
7ad04a2184 | ||
|
|
d8ed5b1005 | ||
|
|
93ceb14302 | ||
|
|
0326442faf | ||
|
|
89f1e663fa | ||
|
|
5e2f75f5f0 | ||
|
|
7cab6efcd5 | ||
|
|
d79c5ffc24 | ||
|
|
3ba3a08141 | ||
|
|
1d4eeaa328 | ||
|
|
b1f6ac1a84 | ||
|
|
a90b97bc10 | ||
|
|
f336f1a340 | ||
|
|
fbfe3e004c | ||
|
|
9a809bf673 | ||
|
|
baa761a2e2 | ||
|
|
ad401c4192 | ||
|
|
5ebc85e705 | ||
|
|
b021f5bce1 | ||
|
|
5f1131cae2 | ||
|
|
f664aee00b | ||
|
|
01649f097c | ||
|
|
abf5bea425 | ||
|
|
6ca6d96821 | ||
|
|
e6b594a626 | ||
|
|
c15f2bda97 | ||
|
|
41c720d951 | ||
|
|
be52d4e9ad | ||
|
|
7ec3af2156 | ||
|
|
bab373f992 | ||
|
|
55d1362924 | ||
|
|
6e85b93442 | ||
|
|
2e13e44b9c | ||
|
|
0b72c2fce3 | ||
|
|
6d7f5552de | ||
|
|
c5bc91145f | ||
|
|
cfa9a79f67 | ||
|
|
d66e473a2c | ||
|
|
9bfab472e4 | ||
|
|
1a605e2b77 | ||
|
|
5c39d65f8f | ||
|
|
5bf6be7eb8 | ||
|
|
e857c5fb41 | ||
|
|
4a1ced3709 | ||
|
|
dbb9724c4e | ||
|
|
100062a156 | ||
|
|
a40507b8b2 | ||
|
|
592b769f67 | ||
|
|
5b8d566a79 | ||
|
|
7235c9a73a | ||
|
|
8395bdac97 | ||
|
|
e2119896db | ||
|
|
68f1653dec | ||
|
|
30d29f7ac3 | ||
|
|
117e61c34b | ||
|
|
412cb2e6e8 | ||
|
|
b11390429c | ||
|
|
5a08303c43 | ||
|
|
5fef520d0e | ||
|
|
6edece628e | ||
|
|
be749e75a5 | ||
|
|
ac5cb53066 | ||
|
|
684c924587 | ||
|
|
090dc752bd | ||
|
|
348159dc3a | ||
|
|
d4ca57884b | ||
|
|
8ec2867433 | ||
|
|
0aa5ebde5d | ||
|
|
6029510ee7 | ||
|
|
7d39ba2124 | ||
|
|
ae959f2d78 | ||
|
|
968085c965 | ||
|
|
62a65aa4cc | ||
|
|
bc7f0b3686 | ||
|
|
87b49c5249 | ||
|
|
ef1a84fb39 | ||
|
|
c46af1291a | ||
|
|
f3f83f2eee | ||
|
|
d9bef8fa46 | ||
|
|
af3086fb82 | ||
|
|
e0366a9965 | ||
|
|
88d47399b5 | ||
|
|
05912a49ae | ||
|
|
b462a0845f | ||
|
|
39dc99443c | ||
|
|
c2f51cf7ab | ||
|
|
9c4a446c76 | ||
|
|
e49c9f36e8 | ||
|
|
1467ad68d4 | ||
|
|
9a4634adbb | ||
|
|
984eedc5ea | ||
|
|
7bf508df0a | ||
|
|
5570e6cbee | ||
|
|
3e529dd042 | ||
|
|
2049e3d655 | ||
|
|
2d72e2a2ae | ||
|
|
67aa9f2350 | ||
|
|
a5268b1137 | ||
|
|
6b5f640849 | ||
|
|
1b5b38a3ba | ||
|
|
e1b5b54c4c | ||
|
|
22b7b407c3 | ||
|
|
284bb21d61 | ||
|
|
f6eebb9c81 | ||
|
|
b08fbe46c0 | ||
|
|
4a751f9d05 | ||
|
|
c5c417e526 | ||
|
|
46284e1537 | ||
|
|
694bc039e8 | ||
|
|
d21dbee102 | ||
|
|
2b9f8f6a89 | ||
|
|
61f8f56719 | ||
|
|
d67d3eed3c | ||
|
|
4829222e73 | ||
|
|
554278e678 | ||
|
|
b1ecc45e4f | ||
|
|
d17ea73273 | ||
|
|
07b1a93026 | ||
|
|
98dcfd8393 | ||
|
|
e1efee8594 | ||
|
|
993605d4f3 | ||
|
|
904210e87c | ||
|
|
50e26ca400 | ||
|
|
c723f7e668 | ||
|
|
1a20029c82 | ||
|
|
26bd42a71c | ||
|
|
601f7f59ff | ||
|
|
b39eb67836 | ||
|
|
cb6aabbf19 | ||
|
|
b89a2dce6f | ||
|
|
97a57ac68d | ||
|
|
a487a58884 | ||
|
|
ccfe37870c | ||
|
|
867acf717a | ||
|
|
6f27a48721 | ||
|
|
185cd4fb30 | ||
|
|
73b3ee51d1 | ||
|
|
b579408711 | ||
|
|
ec0e6f98d4 | ||
|
|
b4b682a4bf | ||
|
|
167732cae4 | ||
|
|
2b128a2f1b | ||
|
|
f4bba23ba7 | ||
|
|
724d182939 | ||
|
|
ebb6d4499a | ||
|
|
b2282a49b5 | ||
|
|
a044178b47 | ||
|
|
a874e7869c | ||
|
|
cef42b4050 | ||
|
|
0a2cbe4926 | ||
|
|
99c9f1d36b | ||
|
|
0091f35e02 | ||
|
|
f2730f06a0 | ||
|
|
5271233774 | ||
|
|
5da83360aa | ||
|
|
cd26942edf | ||
|
|
8a7dc10f51 | ||
|
|
c2bbe79a3e | ||
|
|
e6dc092b73 | ||
|
|
5c1954012b | ||
|
|
21567e8686 | ||
|
|
1af3d571d9 | ||
|
|
442adce51d | ||
|
|
3f5e4cb7ee | ||
|
|
4c6f9d5c25 | ||
|
|
a43244e493 | ||
|
|
5c2fa2d2e7 | ||
|
|
aa6167bb42 | ||
|
|
205b82f6ba | ||
|
|
a03a343723 | ||
|
|
92d19ae2ed | ||
|
|
32d02836f0 | ||
|
|
4030b52ecb | ||
|
|
064b50df81 | ||
|
|
af5021d571 | ||
|
|
e1b905124f | ||
|
|
6cae3a7dce | ||
|
|
d4a16d9e55 | ||
|
|
6c2c885176 | ||
|
|
43f18ddb0f | ||
|
|
b9a2511ea8 | ||
|
|
c96507b7a4 | ||
|
|
e2f2111637 | ||
|
|
9a94c34b91 | ||
|
|
6581579d37 | ||
|
|
4cc54cceb5 | ||
|
|
a9c01ded17 | ||
|
|
cbc08f7e50 | ||
|
|
45582194cf | ||
|
|
56b6c7ed93 | ||
|
|
c1db9a830d | ||
|
|
4c5de9ef8e | ||
|
|
3a21152f4c | ||
|
|
b97e3ee51a | ||
|
|
2b0809f3dc | ||
|
|
29cd6ef994 | ||
|
|
d8b2189cc3 | ||
|
|
3a8c2d0b6f | ||
|
|
eed3ba5d1e | ||
|
|
bc68949c76 | ||
|
|
e4ef2d8140 | ||
|
|
0659f9b592 | ||
|
|
0390c8ccfb | ||
|
|
281ba768ec | ||
|
|
806fae6596 | ||
|
|
65359e53d8 | ||
|
|
92b1b46fa6 | ||
|
|
760d468aca | ||
|
|
6a5b380bc7 | ||
|
|
689d3e7602 | ||
|
|
4300208642 | ||
|
|
149818671d | ||
|
|
dc1f005823 | ||
|
|
eeb6f9334a | ||
|
|
3add72c686 | ||
|
|
5de6a96af5 | ||
|
|
1e014aa95b | ||
|
|
9962eb1f08 | ||
|
|
6bc35b92d3 | ||
|
|
40aaa05456 | ||
|
|
e17f62d261 | ||
|
|
65cde78f6d | ||
|
|
9a5402518c | ||
|
|
11fc826e52 | ||
|
|
249b5d6783 | ||
|
|
7a2dcf0f9f | ||
|
|
710d528215 | ||
|
|
ce0a3e858a | ||
|
|
d178bec60e | ||
|
|
fba88e225f | ||
|
|
7bac815938 | ||
|
|
18916e682f | ||
|
|
fbe1fb285d | ||
|
|
04014d73d9 | ||
|
|
1aa10f5211 | ||
|
|
35fe91116a | ||
|
|
fa34be1a00 | ||
|
|
7bb615a262 | ||
|
|
c51f88e62a | ||
|
|
120e3473f8 | ||
|
|
4a5407feb7 | ||
|
|
d332370298 | ||
|
|
d5b15c498b | ||
|
|
66e93da6f5 | ||
|
|
f8fed9be7e | ||
|
|
3dbb97413c | ||
|
|
47f9f54b89 | ||
|
|
e89ce717ba | ||
|
|
0645625585 | ||
|
|
e115e0b89e | ||
|
|
6a7ad10ae0 | ||
|
|
5a2f556ff7 | ||
|
|
b0e0b29201 | ||
|
|
616b6ce4d5 | ||
|
|
6a27b6262d | ||
|
|
940c185c5d | ||
|
|
f831f30556 | ||
|
|
fd93036b79 | ||
|
|
889cdbff3c | ||
|
|
a787287bfa | ||
|
|
c2c92b2e9b | ||
|
|
e68aeb69eb | ||
|
|
846f457db4 | ||
|
|
35ab1b5d1c | ||
|
|
76e1bed466 | ||
|
|
100acbbe7b | ||
|
|
66044578c2 | ||
|
|
eb92c6b676 | ||
|
|
af04f78bd7 | ||
|
|
b35c1ab696 | ||
|
|
5c1c8b80e2 | ||
|
|
787ca096e6 | ||
|
|
363b38ceb0 | ||
|
|
e2cfc96577 | ||
|
|
b16769ddbe | ||
|
|
ffbe5d1e22 | ||
|
|
1d2e67d38c | ||
|
|
b6eecd7d0c | ||
|
|
b229b89c78 | ||
|
|
b161a6d7f7 | ||
|
|
799e39227c | ||
|
|
38820ec916 | ||
|
|
be1ee30fa8 | ||
|
|
beb069df64 | ||
|
|
9941045468 | ||
|
|
8fa2d8f0d6 | ||
|
|
a3d32d9d80 | ||
|
|
bf35300817 | ||
|
|
ff9af3166f | ||
|
|
8805d8523b | ||
|
|
0610ae2d21 | ||
|
|
5972fca190 | ||
|
|
9f8fedb3b1 | ||
|
|
048ab4b5d3 | ||
|
|
8aa1d770f0 | ||
|
|
4e6dda6361 | ||
|
|
e44834e0c5 | ||
|
|
1a3ee31865 | ||
|
|
721af38aed | ||
|
|
2ac04dba4d | ||
|
|
e7fbcc690b | ||
|
|
f4ce6a8023 | ||
|
|
773dbf4ef2 | ||
|
|
5486dcd1f9 | ||
|
|
61f0eb062e | ||
|
|
b68f197fea | ||
|
|
39e475b4ea | ||
|
|
f5b8855fed | ||
|
|
03e8111e1b | ||
|
|
e26b64a0fc | ||
|
|
8b1aa4a7bd | ||
|
|
b2b36be6cf | ||
|
|
7d82948bd1 | ||
|
|
f7515514bd | ||
|
|
12a3d80f71 | ||
|
|
ef69a1610a | ||
|
|
483eb63408 | ||
|
|
b019dcd11a | ||
|
|
163945f4b4 | ||
|
|
22ee439215 | ||
|
|
582f5e0f72 | ||
|
|
5f672dfb42 | ||
|
|
6f31ae722e | ||
|
|
cc5167c09a | ||
|
|
c6eb41b7bf | ||
|
|
eeef26ae59 | ||
|
|
d53b655c32 | ||
|
|
be81d33495 | ||
|
|
035a290ab5 | ||
|
|
c041a723c1 | ||
|
|
45ca2ace0b | ||
|
|
424fbb710c | ||
|
|
169a8fb97f | ||
|
|
098812d3cc | ||
|
|
4eb5297a79 | ||
|
|
c52c738408 | ||
|
|
797eb2c3ca | ||
|
|
d9a2d9a6bd | ||
|
|
4da4db1e73 | ||
|
|
4c23c3fec9 | ||
|
|
2ab1faf05a | ||
|
|
f670eefd84 | ||
|
|
4e1c301b2a | ||
|
|
b25e3e0917 | ||
|
|
f571d7ed3a | ||
|
|
9abbef7e05 | ||
|
|
1fbe25f91e | ||
|
|
19ad081bb1 | ||
|
|
911be714e5 | ||
|
|
f51fef6027 | ||
|
|
8761e3a869 | ||
|
|
b9a1eba152 | ||
|
|
1e19b689c4 | ||
|
|
0f94a46f86 | ||
|
|
d9659617e9 | ||
|
|
edf0b2fbfe | ||
|
|
61c8dca469 | ||
|
|
d86e504779 | ||
|
|
3d6b4d4dff | ||
|
|
45bcb9927d | ||
|
|
612a07f420 | ||
|
|
d129abcde0 | ||
|
|
6fad364daa | ||
|
|
dc7a85ee76 | ||
|
|
26aec8714e | ||
|
|
65f61fd5b1 | ||
|
|
57ad066e66 | ||
|
|
2a2a0d4aeb | ||
|
|
1082a234fe | ||
|
|
141bb48d76 | ||
|
|
85bb227b45 | ||
|
|
2005979f46 | ||
|
|
48a206a434 | ||
|
|
3a6d2c7c5f | ||
|
|
800ad1737c | ||
|
|
c7eb8d1082 | ||
|
|
4564b973df | ||
|
|
2586618c1b | ||
|
|
7758bc821e | ||
|
|
78f7f19359 | ||
|
|
04e45f503b | ||
|
|
58e97c966c | ||
|
|
e3d15ef4e7 | ||
|
|
61f1ace43f | ||
|
|
087ca9d0d5 | ||
|
|
002b8b04e9 | ||
|
|
6f0232763c | ||
|
|
8169b35fa6 | ||
|
|
097ba22a59 | ||
|
|
78ebb3445a | ||
|
|
b8fb5fb403 | ||
|
|
93f01e614f | ||
|
|
e9f00a4e8a | ||
|
|
7d0397a8fb | ||
|
|
2682ab6791 | ||
|
|
b60e82c702 | ||
|
|
bac82eeb8e | ||
|
|
94c134318b | ||
|
|
6fd334dcd7 | ||
|
|
df6b71c5ea | ||
|
|
4c467d7cad | ||
|
|
db794beb84 | ||
|
|
3b95cd9a11 | ||
|
|
bbe4717075 | ||
|
|
2c47dca086 | ||
|
|
a17553cbf1 | ||
|
|
7e8e243e68 | ||
|
|
cf470ec038 | ||
|
|
016623decb | ||
|
|
a0a8c0294d | ||
|
|
9fe92f6145 | ||
|
|
9f3804444e | ||
|
|
67ac0b431c | ||
|
|
1f807a1348 | ||
|
|
bf778d6df1 | ||
|
|
f8a9faf2fa | ||
|
|
054f8376e4 | ||
|
|
d601b0ce20 | ||
|
|
730c8d6879 | ||
|
|
dbb3d8280e | ||
|
|
36956ebf68 | ||
|
|
3c8d5bb788 | ||
|
|
9e9b64a7e7 | ||
|
|
0a73a9bd9c | ||
|
|
d9addc9245 | ||
|
|
6b4b7a9083 | ||
|
|
afcf567538 | ||
|
|
2b67b3bc81 | ||
|
|
3cd6456349 | ||
|
|
c10052764b | ||
|
|
2ae4db34b0 | ||
|
|
9ddaccbae0 | ||
|
|
f7ca670ce0 | ||
|
|
ce3493952b | ||
|
|
ac8aaf0e08 | ||
|
|
3ceb19a9c6 | ||
|
|
95974b0d24 | ||
|
|
ba3bf6c3d9 | ||
|
|
7300e88cdb | ||
|
|
7364fcc7df | ||
|
|
562b90d93c | ||
|
|
210602476f | ||
|
|
58e37f8130 | ||
|
|
b6802767aa | ||
|
|
76f7454049 | ||
|
|
fb687b7217 | ||
|
|
b34d418b57 | ||
|
|
45f8f72bae | ||
|
|
11ca0a01d3 | ||
|
|
5f4bbe311e | ||
|
|
305e310f0a | ||
|
|
ed35c466ae | ||
|
|
48341094a3 | ||
|
|
fb73ab95ea | ||
|
|
9c4f80449b | ||
|
|
dc88cc4e64 | ||
|
|
bee9090a92 | ||
|
|
d1bf5d2bb6 | ||
|
|
9c2eba2009 | ||
|
|
44271e7bb8 | ||
|
|
5e399498c3 | ||
|
|
3bfa021760 | ||
|
|
7853c4a90b | ||
|
|
e7613a3851 | ||
|
|
b34e9bf42a | ||
|
|
6e1341c148 | ||
|
|
92cac451c8 | ||
|
|
0e04068952 | ||
|
|
0a06b3b208 | ||
|
|
8bccfa5b10 | ||
|
|
5e1e6a48a4 | ||
|
|
4981005572 | ||
|
|
9e207f7f24 | ||
|
|
5ec1b685d8 | ||
|
|
c41571879b | ||
|
|
62a5f2350b | ||
|
|
82f10ddc6a | ||
|
|
4fa76bee78 | ||
|
|
384dee1f95 | ||
|
|
3e5033ff13 | ||
|
|
01ac65eee4 | ||
|
|
da80bd8bb4 | ||
|
|
470901dc58 | ||
|
|
32e6a79e9c | ||
|
|
d1f0b56adc | ||
|
|
77fc4be458 | ||
|
|
3dec8d1880 | ||
|
|
b102caf482 | ||
|
|
7ec9e78e4d | ||
|
|
b6237bc39d | ||
|
|
54935e4aa3 | ||
|
|
18b9addc85 | ||
|
|
abdccaa8eb | ||
|
|
a93c83fe6b | ||
|
|
4fe8d350a2 | ||
|
|
72e3930e08 | ||
|
|
31140c8da7 | ||
|
|
47bb46176b | ||
|
|
0e49eb1d17 | ||
|
|
87717dd77f | ||
|
|
6fb81f146e | ||
|
|
ff6b193821 | ||
|
|
96623c0e4f | ||
|
|
0f089bd49a | ||
|
|
b318d191a5 | ||
|
|
d0665bb301 | ||
|
|
adbba69988 | ||
|
|
539ab241cd | ||
|
|
f18b7c5e14 | ||
|
|
19324f2904 | ||
|
|
6c83cd627f | ||
|
|
ed09d78ed9 | ||
|
|
0b7a392b30 | ||
|
|
2379443ef5 | ||
|
|
8c50b9692e | ||
|
|
787be6ec08 | ||
|
|
72efa329db | ||
|
|
a79b338208 | ||
|
|
08b2899676 | ||
|
|
074e489fe3 | ||
|
|
f8badefa90 | ||
|
|
d113f8db5a | ||
|
|
db36040fe1 | ||
|
|
f0c1688b1b | ||
|
|
67d3c9e9c8 | ||
|
|
ac664940da | ||
|
|
8eb0829267 | ||
|
|
f8ecdc004f | ||
|
|
c088672632 | ||
|
|
552076a36c | ||
|
|
a0fe6665b2 | ||
|
|
b05907f592 | ||
|
|
bae6a09a7c | ||
|
|
8bc1ed7d86 | ||
|
|
9935cb0e3b | ||
|
|
594f7074f7 | ||
|
|
a6c9d33c09 | ||
|
|
e0e1ed6936 | ||
|
|
7fb4b42092 | ||
|
|
1b3055faef | ||
|
|
cf905d0c7f | ||
|
|
f084bbb6d0 | ||
|
|
a2843084d6 | ||
|
|
3d23ee0e23 | ||
|
|
92718c4def | ||
|
|
e1d3a8ea7d | ||
|
|
2f7a9bb789 | ||
|
|
ef2cb860a3 | ||
|
|
1e37916156 | ||
|
|
f3fb445166 | ||
|
|
ac55d8dd8b | ||
|
|
f517a6a373 | ||
|
|
ccdcf9d82b | ||
|
|
b7863e2dc2 | ||
|
|
6edb280cc7 | ||
|
|
32847fcfd0 | ||
|
|
69bdc44441 | ||
|
|
4d58e55781 | ||
|
|
90843a4228 | ||
|
|
d233459195 | ||
|
|
6dab2b8c62 | ||
|
|
86893a2984 | ||
|
|
3618f066bb | ||
|
|
5c149e0363 | ||
|
|
22e03ee98a | ||
|
|
18901ca4d6 | ||
|
|
d5f77e92f7 | ||
|
|
d139c31972 | ||
|
|
53550d8bb4 | ||
|
|
356f9914cc | ||
|
|
6e57c4618e | ||
|
|
9b0bef50de | ||
|
|
c957a12742 | ||
|
|
1b9aa2ab71 | ||
|
|
1d17ece9ce | ||
|
|
34ce35dcfa | ||
|
|
f66cfca2a9 | ||
|
|
7c1e8ba2bf | ||
|
|
e23446389c | ||
|
|
8cb6172e4b | ||
|
|
d427647ce7 | ||
|
|
8a4c15ecf5 | ||
|
|
1be9194734 | ||
|
|
792d2fc79a | ||
|
|
5386aede36 | ||
|
|
4e1317cd0f | ||
|
|
9ee6442004 | ||
|
|
6f84b85358 | ||
|
|
d7548e72b2 | ||
|
|
7964e11c7f | ||
|
|
a4d0af1f96 | ||
|
|
282bc16243 | ||
|
|
4ba106a525 | ||
|
|
1d54092c7d | ||
|
|
4b50045ecd | ||
|
|
a6e715f574 | ||
|
|
18f5362a34 | ||
|
|
a71f525a2b | ||
|
|
efae85de84 | ||
|
|
da811fbdd0 | ||
|
|
d7a2515093 | ||
|
|
885cc3864e | ||
|
|
c22d3d3cae | ||
|
|
fb3fc0c6de | ||
|
|
624f61193c | ||
|
|
5a37ee9976 | ||
|
|
6a63ea46a4 | ||
|
|
f437fac412 | ||
|
|
afea67e303 | ||
|
|
3d46f3df61 | ||
|
|
697617622c | ||
|
|
7e9e3903d8 | ||
|
|
7b66fcff37 | ||
|
|
40b219c397 | ||
|
|
b5e74ee3f1 | ||
|
|
6f95182751 | ||
|
|
41d7430442 | ||
|
|
aa86387ba9 | ||
|
|
2a1f44610f | ||
|
|
4704f48daa | ||
|
|
8dacc91d51 | ||
|
|
a594273989 | ||
|
|
d9264e415c | ||
|
|
b3df389bd6 | ||
|
|
2998b78797 | ||
|
|
46a526ce26 | ||
|
|
95fffec172 | ||
|
|
323912371e | ||
|
|
3213d2205a | ||
|
|
3dde80ed0f | ||
|
|
6f428c03e2 | ||
|
|
2d5d39db7b | ||
|
|
28806f3187 | ||
|
|
5349d33abf | ||
|
|
a499da00ba | ||
|
|
a4d9c8cc3b | ||
|
|
27d09c33ce | ||
|
|
5b86186e85 | ||
|
|
3b399f62f4 | ||
|
|
7c511fb2f2 | ||
|
|
4370781b49 | ||
|
|
1cf4926b4e | ||
|
|
7ae06a114d | ||
|
|
8321b2fa66 | ||
|
|
ba966634f5 | ||
|
|
dd12757493 | ||
|
|
7ea37edfbf | ||
|
|
462368f959 | ||
|
|
73833e0ef0 | ||
|
|
7d699ade0c | ||
|
|
bc52b8f310 | ||
|
|
ecb8d117ac | ||
|
|
ead8c4933e | ||
|
|
20374b542d | ||
|
|
6df31099c2 | ||
|
|
b7e2d8f019 | ||
|
|
80a35226c5 | ||
|
|
e025d696f6 | ||
|
|
245ca20eea | ||
|
|
8f60ad8874 | ||
|
|
d18a1edb67 | ||
|
|
a8050635fa | ||
|
|
33fa1989bc | ||
|
|
7d3ab6d0b4 | ||
|
|
237102b5f2 | ||
|
|
407b4fd1d5 | ||
|
|
882cbd8b4e | ||
|
|
4c3d9788dd | ||
|
|
59c65118e1 | ||
|
|
84976ed5dc | ||
|
|
15ccb70ae6 | ||
|
|
e1481f3a90 | ||
|
|
01413c8d9f | ||
|
|
392a14241f | ||
|
|
16a5c6995c | ||
|
|
c7334e7c56 | ||
|
|
cc4ceb88a0 | ||
|
|
7ee464709b | ||
|
|
ee5e7449ac | ||
|
|
278a067d43 | ||
|
|
e9f7df081f | ||
|
|
d0b83a7196 | ||
|
|
bc48b770de | ||
|
|
e7cb3d324a | ||
|
|
0f3222e489 | ||
|
|
a08a0077e6 | ||
|
|
5336aecde7 | ||
|
|
a2c51a586e | ||
|
|
3aa506eb1b | ||
|
|
60e7e19dab | ||
|
|
1b2702df24 | ||
|
|
6d37ee2970 | ||
|
|
2aa007fbad | ||
|
|
bfded90875 | ||
|
|
e0c6d80c09 | ||
|
|
237de95285 | ||
|
|
357d8c98a3 | ||
|
|
5f40394501 | ||
|
|
41c6d2d031 | ||
|
|
d2c355bdb0 | ||
|
|
6f3d5a7b33 | ||
|
|
34491f4be1 | ||
|
|
34e0a74c07 | ||
|
|
587f156557 | ||
|
|
f04c3c6acb | ||
|
|
80171b7c54 | ||
|
|
cb68d4d00a | ||
|
|
98ef945d2e | ||
|
|
12b47fece0 | ||
|
|
bfb44934b7 | ||
|
|
08ca34f5d0 | ||
|
|
a46c12c014 | ||
|
|
d24093c4a6 | ||
|
|
ec034da5c9 | ||
|
|
d5b9e4ccd5 | ||
|
|
169c837613 | ||
|
|
33f38dd437 | ||
|
|
bd7004ecd7 | ||
|
|
8babee0efb | ||
|
|
a407da79a9 | ||
|
|
8399afa607 | ||
|
|
68091c7cdb | ||
|
|
e62be406ce | ||
|
|
dd3a79dac2 | ||
|
|
a4f170604c | ||
|
|
349e0b6fd2 | ||
|
|
78eceb43a1 | ||
|
|
0cd8d939f1 | ||
|
|
9fa2c7404f | ||
|
|
8cd0a8838a | ||
|
|
d92ffa6771 | ||
|
|
63cab68a96 | ||
|
|
f6eb2724e2 | ||
|
|
fc6980e0c9 | ||
|
|
7a95a21e09 | ||
|
|
8edd628973 | ||
|
|
50e7e959fe | ||
|
|
b5f70d02b2 | ||
|
|
76c2fb3de7 | ||
|
|
27ea5c0026 | ||
|
|
59d0af33b8 | ||
|
|
25631a25f7 | ||
|
|
ac9b4f8135 | ||
|
|
46694ece47 | ||
|
|
74b016c8b6 | ||
|
|
7242b08609 | ||
|
|
ee0954c8cb | ||
|
|
fd9f4753bb | ||
|
|
dc9ad66fe2 | ||
|
|
247acce949 | ||
|
|
91b2e0bff2 | ||
|
|
17ad351386 | ||
|
|
72eafff843 | ||
|
|
4ec03b7e87 | ||
|
|
88d466e58e | ||
|
|
cf2c59b1d7 | ||
|
|
93f02c08dc | ||
|
|
efac255821 | ||
|
|
06515b43d8 | ||
|
|
0e436e66de | ||
|
|
3f2eec75c7 | ||
|
|
6519a1e326 | ||
|
|
a2ff20990c | ||
|
|
0a6d43c5f6 | ||
|
|
64a368dd8e | ||
|
|
1dc03d5741 | ||
|
|
e5c2fee022 | ||
|
|
00bfba1d77 | ||
|
|
76c963a70c | ||
|
|
f78f6b59cc | ||
|
|
faf3c81be3 | ||
|
|
a994722bb1 | ||
|
|
b383475282 | ||
|
|
ce7866a6a6 | ||
|
|
0dfd6d3986 | ||
|
|
50757e7afe | ||
|
|
df64a1069e | ||
|
|
9450226675 | ||
|
|
8f8052735c | ||
|
|
aa6640e1c0 | ||
|
|
5f1b82d696 | ||
|
|
19e96f7dd2 | ||
|
|
591d6df489 | ||
|
|
8fe318495f | ||
|
|
569c055389 | ||
|
|
26ce076f61 | ||
|
|
07c7d63d44 | ||
|
|
0a4c8e2959 | ||
|
|
5352c34ba5 | ||
|
|
41fcb7b1c1 | ||
|
|
a0bef995b6 | ||
|
|
d6b5d8e2c2 | ||
|
|
449742e69d | ||
|
|
bc786b48fa | ||
|
|
506b4e5f81 | ||
|
|
8365b127f2 | ||
|
|
471ea81594 | ||
|
|
b0ac39fe28 | ||
|
|
aced1e9673 | ||
|
|
e37be3b43d | ||
|
|
6648d19239 | ||
|
|
8d8a204519 | ||
|
|
2ab10ec9b7 | ||
|
|
0ce34f341e | ||
|
|
0d68f8ab5d | ||
|
|
3ea5f2f0a6 | ||
|
|
912c160ad3 | ||
|
|
d9745a2e2c | ||
|
|
deb96d83d3 | ||
|
|
e5f3d21f81 | ||
|
|
eb49f15453 | ||
|
|
5165102f81 | ||
|
|
d215d6d861 | ||
|
|
0739b577d4 | ||
|
|
c62e8dadb6 | ||
|
|
e29bd2270f | ||
|
|
aa4bdebf40 | ||
|
|
5f460c95cc | ||
|
|
73358d5ec2 | ||
|
|
e98108a8be | ||
|
|
5af906ad83 | ||
|
|
1d711d849d | ||
|
|
0b7af2dbbc | ||
|
|
9d1e99ad0a | ||
|
|
f948e76c45 | ||
|
|
e3e8b5c6e4 | ||
|
|
e4f4cfb1de | ||
|
|
085d7f0ed4 | ||
|
|
f3105f6c81 | ||
|
|
5c55b970c6 | ||
|
|
cad7e541b6 | ||
|
|
312c7ce1af | ||
|
|
c354ff85a6 | ||
|
|
fc12541e8a | ||
|
|
e178653f48 | ||
|
|
05f2eb6270 | ||
|
|
0307c85bd3 | ||
|
|
71ed576e18 | ||
|
|
2f347a33d8 | ||
|
|
436af982fd | ||
|
|
1dd0c912c7 | ||
|
|
824c5f82d3 | ||
|
|
5266c726f2 | ||
|
|
a4b22a612e | ||
|
|
e222345c85 | ||
|
|
2b30cc8f2c | ||
|
|
dc1d7bf47f | ||
|
|
f5d6cd511e | ||
|
|
09c137b27a | ||
|
|
151f74d596 | ||
|
|
2ac44376cb | ||
|
|
7f807b81fe | ||
|
|
60884f9047 | ||
|
|
49ea23530f | ||
|
|
07ebed7fae | ||
|
|
857020c475 | ||
|
|
68af5c221d | ||
|
|
4089227863 | ||
|
|
a968718b52 | ||
|
|
83d46d02d4 | ||
|
|
32cdefb7d7 | ||
|
|
8da7af7b7b | ||
|
|
276a35d36d | ||
|
|
7e28cc0981 | ||
|
|
40292a737a | ||
|
|
8d5dda9d33 | ||
|
|
1d9d0b89ab | ||
|
|
dd834c0eeb | ||
|
|
1d698899f6 | ||
|
|
9bb99ed01d | ||
|
|
ce94b7e545 | ||
|
|
53c0b81dad | ||
|
|
2be84d4d64 | ||
|
|
806c1a48d5 | ||
|
|
4f691de0b5 | ||
|
|
37912b6045 | ||
|
|
d04979402c | ||
|
|
8a2493c26a | ||
|
|
b2816d72da | ||
|
|
9d361ec772 | ||
|
|
5b62fa3464 | ||
|
|
92e813cca4 | ||
|
|
a7b7254ac0 | ||
|
|
23048378d8 | ||
|
|
b16ff0a3dc | ||
|
|
f97fe9a7b5 | ||
|
|
85db524a35 | ||
|
|
031f1709f2 | ||
|
|
7391fe0c5e | ||
|
|
984eca8a27 | ||
|
|
8b321fda41 | ||
|
|
702a9d0867 | ||
|
|
20740e1b68 | ||
|
|
c4adefe75b | ||
|
|
11fb7e1796 | ||
|
|
12f89fff49 | ||
|
|
f3bb7fb9c2 | ||
|
|
72b205f5c1 | ||
|
|
4ce9dec54e |
+14
@@ -10,8 +10,13 @@
|
||||
*.la
|
||||
.libs
|
||||
.dirstamp
|
||||
.autotools
|
||||
.cproject
|
||||
.project
|
||||
.settings
|
||||
stamp-h1
|
||||
/configure
|
||||
/configure.ac
|
||||
/config.guess
|
||||
/config.h
|
||||
/config.h.in
|
||||
@@ -35,3 +40,12 @@ stamp-h1
|
||||
/m4/ltsugar.m4
|
||||
/m4/ltversion.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
|
||||
|
||||
+31
-4
@@ -1,16 +1,30 @@
|
||||
language: c
|
||||
|
||||
os:
|
||||
- osx
|
||||
- linux
|
||||
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
# osx use always clang for build...
|
||||
- os: osx
|
||||
compiler: gcc
|
||||
|
||||
install:
|
||||
- sudo apt-get update || true
|
||||
- sudo apt-get install build-essential
|
||||
- sudo apt-get install libpcap-dev libtool autoconf automake autogen
|
||||
#macos
|
||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update; fi
|
||||
#linux
|
||||
- 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:
|
||||
- ./autogen.sh
|
||||
# - lcov --directory . --zerocounters
|
||||
|
||||
script:
|
||||
- ./configure
|
||||
@@ -19,4 +33,17 @@ script:
|
||||
after_script:
|
||||
- cd tests
|
||||
- ./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
|
||||
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
# CHANGELOG
|
||||
|
||||
|
||||
#### 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
|
||||
@@ -1,16 +0,0 @@
|
||||
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
@@ -1,6 +1,6 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = src/lib example
|
||||
SUBDIRS = src/lib example tests
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libndpi.pc
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
# What is nDPI ?
|
||||
![ntop][ntopng_logo] ![ntop][ntop_logo]
|
||||
# nDPI
|
||||
|
||||
nDPI is an open source GPLv3 library for deep-packet inspection. Based on OpenDPI it includes ntop extensions. We have tried to push them into the OpenDPI source tree but nobody answered emails so we have decided to create mour own source tree
|
||||
[](https://travis-ci.org/ntop/nDPI)
|
||||
|
||||
# How To Compile nDPI
|
||||
## What is nDPI ?
|
||||
|
||||
nDPI is an open source LGPLv3 library for deep-packet inspection. Based on OpenDPI it includes ntop extensions. We have tried to push them into the OpenDPI source tree but nobody answered emails so we have decided to create our own source tree
|
||||
|
||||
### How To Compile nDPI
|
||||
|
||||
In order to compile this library do
|
||||
|
||||
@@ -10,17 +15,21 @@ In order to compile this library do
|
||||
- ./configure
|
||||
- make
|
||||
|
||||
To run tests do additionally:
|
||||
|
||||
- cd tests; ./do.sh
|
||||
|
||||
Please note that the pre-requisites for compilation include:
|
||||
- GNU tools (autogen, automake, autoconf, libtool)
|
||||
- GNU C compiler (gcc)
|
||||
|
||||
# How To Add A New Protocol Dissector
|
||||
### How To Add A New Protocol Dissector
|
||||
|
||||
The entire procedure of adding new protocols in detail:
|
||||
|
||||
1. Add new protocol together with its unique ID to: src/include/ndpi_protocols_osdpi.h
|
||||
1. Add new protocol together with its unique ID to: src/include/ndpi_protocol_ids.h
|
||||
2. Create a new protocol in: src/lib/protocols/
|
||||
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).
|
||||
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).
|
||||
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
|
||||
6. Add a new entry in ndpi_set_protocol_detection_bitmask2 in: src/lib/ndpi_main.c
|
||||
@@ -29,9 +38,25 @@ The entire procedure of adding new protocols in detail:
|
||||
9. ./autogen.sh
|
||||
10. ./configure
|
||||
11. make
|
||||
12. make check
|
||||
|
||||
# Creating A Source File Tar Ball
|
||||
### 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
|
||||
|
||||
If you want to distribute a source tar file of nDPI do:
|
||||
|
||||
- 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
|
||||
|
||||
[ntop_logo]: https://camo.githubusercontent.com/58e2a1ecfff62d8ecc9d74633bd1013f26e06cba/687474703a2f2f7777772e6e746f702e6f72672f77702d636f6e74656e742f75706c6f6164732f323031352f30352f6e746f702e706e67
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
rerequisites for Compilation
|
||||
Prerequisites for Compilation
|
||||
-----------------------------
|
||||
|
||||
Prerequisites
|
||||
- GNU autotools/libtool
|
||||
- libpcap or PF_RING (optional but recommended)
|
||||
- apt-get install libjson-c-dev (for JSON support)
|
||||
|
||||
On Ubuntu/Debian
|
||||
- apt-get install build-essential
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ TCP 172.16.253.130:2021 <-> 75.147.140.249:443 [VLAN: 0][proto: 91/SSL][28 pkts/
|
||||
TCP 172.16.253.130:2077 <-> 77.247.181.163:443 [VLAN: 0][proto: 91/SSL][136 pkts/94329 bytes][SSL client: www.fk4pprq42hsvl2wey.com]
|
||||
|
||||
It can be detected by analyzing the SSL client certificate and checking the name that does not match to a real host in
|
||||
addition of begin a bit weird. As doing DNS resolution is not a task for nDPI we let applications do and then recognize
|
||||
addition of being a bit weird. As doing DNS resolution is not a task for nDPI we let applications do and then recognize
|
||||
SSL-tunnelled connections.
|
||||
|
||||
See http://www.netresec.com/?page=Blog&month=2013-04&post=Detecting-TOR-Communication-in-Network-Traffic
|
||||
|
||||
+9
-3
@@ -1,11 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
NDPI_MAJOR="2"
|
||||
NDPI_MINOR="2"
|
||||
NDPI_PATCH="0"
|
||||
NDPI_VERSION_SHORT="$NDPI_MAJOR.$NDPI_MINOR.$NDPI_PATCH"
|
||||
|
||||
/bin/rm -f configure config.h config.h.in src/lib/Makefile.in
|
||||
|
||||
AUTOCONF=$(which autoconf)
|
||||
AUTOMAKE=$(which automake)
|
||||
LIBTOOL=$(which libtool)
|
||||
LIBTOOLIZE=$(which libtoolize)
|
||||
AUTORECONF=$(which autoreconf)
|
||||
|
||||
if test -z $AUTOCONF; then
|
||||
@@ -18,8 +23,8 @@ if test -z $AUTOMAKE; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if test -z $LIBTOOL; then
|
||||
echo "libtool is missing: please install it and try again"
|
||||
if test -z $LIBTOOL && test -z $LIBTOOLIZE ; then
|
||||
echo "libtool and libtoolize is missing: please install it and try again"
|
||||
exit
|
||||
fi
|
||||
|
||||
@@ -28,5 +33,6 @@ if test -z $AUTORECONF; then
|
||||
exit
|
||||
fi
|
||||
|
||||
cat configure.seed | sed "s/@NDPI_MAJOR@/$NDPI_MAJOR/g" | sed "s/@NDPI_MINOR@/$NDPI_MINOR/g" | sed "s/@NDPI_PATCH@/$NDPI_PATCH/g" | sed "s/@NDPI_VERSION_SHORT@/$NDPI_VERSION_SHORT/g" > configure.ac
|
||||
autoreconf -ivf
|
||||
./configure
|
||||
./configure $*
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
AC_INIT([libndpi], [1.6.0])
|
||||
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AM_INIT_AUTOMAKE([foreign subdir-objects])
|
||||
|
||||
LT_INIT
|
||||
|
||||
AC_PROG_CC
|
||||
AX_PTHREAD
|
||||
|
||||
if test -d ".git"; then :
|
||||
GIT_TAG=`git log -1 --format=%h`
|
||||
GIT_DATE=`git log -1 --format=%cd`
|
||||
#
|
||||
# On CentOS 6 `git rev-list HEAD --count` does not work
|
||||
#
|
||||
#
|
||||
GIT_NUM=`git log --pretty=oneline | wc -l`
|
||||
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
|
||||
GIT_RELEASE="${PACKAGE_VERSION}-${GIT_BRANCH}-${GIT_NUM}-${GIT_TAG}"
|
||||
else
|
||||
GIT_RELEASE="${PACKAGE_VERSION}"
|
||||
GIT_DATE=`date`
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(NDPI_GIT_RELEASE, "${GIT_RELEASE}", [GIT Release])
|
||||
AC_DEFINE_UNQUOTED(NDPI_GIT_DATE, "${GIT_DATE}", [Last GIT change])
|
||||
|
||||
AC_CHECK_HEADERS([netinet/in.h stdint.h stdlib.h string.h unistd.h])
|
||||
|
||||
PCAP_HOME=$HOME/PF_RING/userland
|
||||
|
||||
if test -d $PCAP_HOME; then :
|
||||
echo -n ""
|
||||
else
|
||||
PCAP_HOME=`pwd`/../../PF_RING/userland
|
||||
fi
|
||||
SHORT_MACHINE=`uname -m | cut -b1-3`
|
||||
if test $SHORT_MACHINE = "arm"; then
|
||||
LIBNUMA=""
|
||||
else
|
||||
LIBNUMA="-lnuma"
|
||||
fi
|
||||
|
||||
if test -f $PCAP_HOME/libpcap/libpcap.a; then :
|
||||
echo "Using libpcap from $PCAP_HOME"
|
||||
PCAP_INC="-I $PCAP_HOME/libpcap"
|
||||
PCAP_LIB="$PCAP_HOME/libpcap/libpcap.a $PCAP_HOME/lib/libpfring.a $LIBNUMA"
|
||||
|
||||
AC_CHECK_LIB([rt], [clock_gettime], [PCAP_LIB="$PCAP_LIB -lrt"])
|
||||
AC_CHECK_LIB([nl], [nl_handle_alloc], [PCAP_LIB="$PCAP_LIB -lnl"])
|
||||
else
|
||||
AC_CHECK_LIB([pcap], [pcap_open_live], [PCAP_LIB="-lpcap"])
|
||||
|
||||
if test $ac_cv_lib_pcap_pcap_open_live = "no"; then :
|
||||
echo ""
|
||||
echo "ERROR: Missing libpcap(-dev) library required to compile the example application"
|
||||
echo "ERROR: Please install it and try again"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
PKG_CONFIG=$(which pkg-config)
|
||||
|
||||
if test -d /usr/local/include/json-c/; then :
|
||||
CFLAGS="$CFLAGS -I/usr/local/include/json-c/"
|
||||
LDFLAGS="$LDFLAGS -L/usr/local/lib -ljson-c"
|
||||
else
|
||||
if ! test -z "$PKG_CONFIG"; then :
|
||||
CFLAGS="$CFLAGS $(pkg-config --cflags json-c)"
|
||||
LDFLAGS="$LDFLAGS $(pkg-config --libs json-c)"
|
||||
fi
|
||||
fi
|
||||
|
||||
OLD_LIBS=$LIBS
|
||||
LIBS="-L/opt/napatech3/lib $LIBS"
|
||||
AC_CHECK_LIB([ntapi],
|
||||
[NT_Init],
|
||||
[PCAP_LIB="$PCAP_LIB -L/opt/napatech3/lib -lntapi"],
|
||||
[], [] )
|
||||
LIBS=$OLD_LIBS
|
||||
|
||||
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(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 libndpi.pc])
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
AC_SUBST(GIT_RELEASE)
|
||||
AC_SUBST(SVN_DATE)
|
||||
AC_SUBST(JSON_C_LIB)
|
||||
AC_SUBST(PCAP_INC)
|
||||
AC_SUBST(PCAP_LIB)
|
||||
AC_SUBST(HAVE_PTHREAD_SETAFFINITY_NP)
|
||||
|
||||
AC_OUTPUT
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
AC_INIT([libndpi], [@NDPI_VERSION_SHORT@])
|
||||
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AM_INIT_AUTOMAKE([foreign subdir-objects])
|
||||
|
||||
LT_INIT
|
||||
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
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 :
|
||||
GIT_TAG=`git log -1 --format=%h`
|
||||
GIT_DATE=`git log -1 --format=%cd`
|
||||
#
|
||||
# On CentOS 6 `git rev-list HEAD --count` does not work
|
||||
#
|
||||
#
|
||||
GIT_NUM=`git log --pretty=oneline | wc -l | tr -d '[[:space:]]'`
|
||||
GIT_RELEASE="${PACKAGE_VERSION}-${GIT_NUM}-${GIT_TAG}"
|
||||
else
|
||||
GIT_RELEASE="${PACKAGE_VERSION}"
|
||||
GIT_DATE=`date`
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(NDPI_GIT_RELEASE, "${GIT_RELEASE}", [GIT Release])
|
||||
AC_DEFINE_UNQUOTED(NDPI_GIT_DATE, "${GIT_DATE}", [Last GIT change])
|
||||
|
||||
AC_CHECK_HEADERS([netinet/in.h stdint.h stdlib.h string.h unistd.h])
|
||||
|
||||
PCAP_HOME=$HOME/PF_RING/userland
|
||||
|
||||
if test -d $PCAP_HOME; then :
|
||||
echo -n ""
|
||||
else
|
||||
PCAP_HOME=`pwd`/../../PF_RING/userland
|
||||
fi
|
||||
SHORT_MACHINE=`uname -m | cut -b1-3`
|
||||
if test $SHORT_MACHINE = "arm"; then
|
||||
LIBNUMA=""
|
||||
else
|
||||
AC_CHECK_LIB([numa], [numa_available], [LIBNUMA="-lnuma"])
|
||||
fi
|
||||
|
||||
if test -f $PCAP_HOME/libpcap/libpcap.a; then :
|
||||
echo "Using libpcap from $PCAP_HOME"
|
||||
PCAP_INC="-I $PCAP_HOME/libpcap"
|
||||
PCAP_LIB="$PCAP_HOME/libpcap/libpcap.a $PCAP_HOME/lib/libpfring.a $LIBNUMA `$PCAP_HOME/lib/pfring_config --libs`"
|
||||
|
||||
AC_CHECK_LIB([rt], [clock_gettime], [PCAP_LIB="$PCAP_LIB -lrt"])
|
||||
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
|
||||
AC_CHECK_LIB([pcap], [pcap_open_live], [PCAP_LIB="-lpcap"])
|
||||
|
||||
if test $ac_cv_lib_pcap_pcap_open_live = "no"; then :
|
||||
echo ""
|
||||
echo "ERROR: Missing libpcap(-dev) library required to compile the example application"
|
||||
echo "ERROR: Please install it and try again"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl> https://github.com/json-c/json-c
|
||||
AC_ARG_ENABLE([json-c],
|
||||
AS_HELP_STRING([--disable-json-c], [Disable json-c support]))
|
||||
|
||||
AS_IF([test "x$enable_json_c" != "xno"], [
|
||||
PKG_CONFIG_PATH=/usr/local/share/pkgconfig:$PKG_CONFIG_PATH
|
||||
pkg-config --exists json-c
|
||||
AS_IF([test "$?" == "0"],
|
||||
[
|
||||
CFLAGS="$CFLAGS $(pkg-config --cflags 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]))
|
||||
],
|
||||
[
|
||||
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_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_HEADERS(config.h)
|
||||
AC_SUBST(GIT_RELEASE)
|
||||
AC_SUBST(NDPI_MAJOR)
|
||||
AC_SUBST(NDPI_MINOR)
|
||||
AC_SUBST(NDPI_PATCH)
|
||||
AC_SUBST(SVN_DATE)
|
||||
AC_SUBST(JSON_C_LIB)
|
||||
AC_SUBST(PCAP_INC)
|
||||
AC_SUBST(PCAP_LIB)
|
||||
AC_SUBST(DL_LIB)
|
||||
AC_SUBST(HAVE_PTHREAD_SETAFFINITY_NP)
|
||||
|
||||
AC_OUTPUT
|
||||
Binary file not shown.
Binary file not shown.
+4
-4
@@ -1,12 +1,12 @@
|
||||
bin_PROGRAMS = ndpiReader
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src/include @PCAP_INC@
|
||||
AM_CFLAGS = @PTHREAD_CFLAGS@
|
||||
AM_CFLAGS = @PTHREAD_CFLAGS@ # --coverage
|
||||
|
||||
LDADD = $(top_builddir)/src/lib/libndpi.la @JSON_C_LIB@ @PTHREAD_LIBS@ @PCAP_LIB@
|
||||
AM_LDFLAGS = -static
|
||||
LDADD = $(top_builddir)/src/lib/libndpi.la @JSON_C_LIB@ @PTHREAD_LIBS@ @PCAP_LIB@ @DL_LIB@ -lm
|
||||
AM_LDFLAGS = -static @DL_LIB@
|
||||
|
||||
ndpiReader_SOURCES = ndpiReader.c
|
||||
ndpiReader_SOURCES = ndpiReader.c ndpi_util.c ndpi_util.h uthash.h
|
||||
|
||||
ndpiReader.o: ndpiReader.c
|
||||
|
||||
|
||||
+2510
-1119
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,961 @@
|
||||
/*
|
||||
* ndpi_util.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 <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h> /* winsock.h is included automatically */
|
||||
#include <process.h>
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#ifndef ETH_P_IP
|
||||
#define ETH_P_IP 0x0800 /* IPv4 */
|
||||
#endif
|
||||
|
||||
#ifndef ETH_P_IPv6
|
||||
#define ETH_P_IPV6 0x86dd /* IPv6 */
|
||||
#endif
|
||||
|
||||
#define SLARP 0x8035 /* Cisco Slarp */
|
||||
#define CISCO_D_PROTO 0x2000 /* Cisco Discovery Protocol */
|
||||
|
||||
#define VLAN 0x8100
|
||||
#define MPLS_UNI 0x8847
|
||||
#define MPLS_MULTI 0x8848
|
||||
#define PPPoE 0x8864
|
||||
#define SNAP 0xaa
|
||||
#define BSTP 0x42 /* Bridge Spanning Tree Protocol */
|
||||
|
||||
/* mask for FCF */
|
||||
#define WIFI_DATA 0x2 /* 0000 0010 */
|
||||
#define FCF_TYPE(fc) (((fc) >> 2) & 0x3) /* 0000 0011 = 0x3 */
|
||||
#define FCF_SUBTYPE(fc) (((fc) >> 4) & 0xF) /* 0000 1111 = 0xF */
|
||||
#define FCF_TO_DS(fc) ((fc) & 0x0100)
|
||||
#define FCF_FROM_DS(fc) ((fc) & 0x0200)
|
||||
|
||||
/* mask for Bad FCF presence */
|
||||
#define BAD_FCS 0x50 /* 0101 0000 */
|
||||
|
||||
#define GTP_U_V1_PORT 2152
|
||||
#define TZSP_PORT 37008
|
||||
|
||||
#ifndef DLT_LINUX_SLL
|
||||
#define DLT_LINUX_SLL 113
|
||||
#endif
|
||||
|
||||
#include "ndpi_main.h"
|
||||
#include "ndpi_util.h"
|
||||
|
||||
/* ***************************************************** */
|
||||
|
||||
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->src_id) { ndpi_free(flow->src_id); flow->src_id = NULL; }
|
||||
if(flow->dst_id) { ndpi_free(flow->dst_id); flow->dst_id = NULL; }
|
||||
}
|
||||
|
||||
/* ***************************************************** */
|
||||
|
||||
extern u_int32_t current_ndpi_memory, max_ndpi_memory;
|
||||
|
||||
/**
|
||||
* @brief malloc wrapper function
|
||||
*/
|
||||
static void *malloc_wrapper(size_t size) {
|
||||
current_ndpi_memory += size;
|
||||
|
||||
if(current_ndpi_memory > max_ndpi_memory)
|
||||
max_ndpi_memory = current_ndpi_memory;
|
||||
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
/* ***************************************************** */
|
||||
|
||||
/**
|
||||
* @brief free wrapper function
|
||||
*/
|
||||
static void free_wrapper(void *freeable) {
|
||||
free(freeable);
|
||||
}
|
||||
|
||||
/* ***************************************************** */
|
||||
|
||||
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_flow_malloc(NULL), set_ndpi_flow_free(NULL);
|
||||
/* TODO: just needed here to init ndpi malloc wrapper */
|
||||
struct ndpi_detection_module_struct * module = ndpi_init_detection_module();
|
||||
|
||||
struct ndpi_workflow * workflow = ndpi_calloc(1, sizeof(struct ndpi_workflow));
|
||||
|
||||
workflow->pcap_handle = pcap_handle;
|
||||
workflow->prefs = *prefs;
|
||||
workflow->ndpi_struct = module;
|
||||
|
||||
if(workflow->ndpi_struct == NULL) {
|
||||
NDPI_LOG(0, NULL, NDPI_LOG_ERROR, "global structure initialization failed\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
workflow->ndpi_flows_root = ndpi_calloc(workflow->prefs.num_roots, sizeof(void *));
|
||||
return workflow;
|
||||
}
|
||||
|
||||
/* ***************************************************** */
|
||||
|
||||
void ndpi_flow_info_freer(void *node) {
|
||||
struct ndpi_flow_info *flow = (struct ndpi_flow_info*)node;
|
||||
|
||||
ndpi_free_flow_info_half(flow);
|
||||
ndpi_free(flow);
|
||||
}
|
||||
|
||||
/* ***************************************************** */
|
||||
|
||||
void ndpi_workflow_free(struct ndpi_workflow * workflow) {
|
||||
int i;
|
||||
|
||||
for(i=0; i<workflow->prefs.num_roots; i++)
|
||||
ndpi_tdestroy(workflow->ndpi_flows_root[i], ndpi_flow_info_freer);
|
||||
|
||||
ndpi_exit_detection_module(workflow->ndpi_struct);
|
||||
free(workflow->ndpi_flows_root);
|
||||
free(workflow);
|
||||
}
|
||||
|
||||
/* ***************************************************** */
|
||||
|
||||
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 *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->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);
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
/* ***************************************************** */
|
||||
|
||||
static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow,
|
||||
const u_int8_t version,
|
||||
u_int16_t vlan_id,
|
||||
const struct ndpi_iphdr *iph,
|
||||
const struct ndpi_ipv6hdr *iph6,
|
||||
u_int16_t ip_offset,
|
||||
u_int16_t ipsize,
|
||||
u_int16_t l4_packet_len,
|
||||
struct ndpi_tcphdr **tcph,
|
||||
struct ndpi_udphdr **udph,
|
||||
u_int16_t *sport, u_int16_t *dport,
|
||||
struct ndpi_id_struct **src,
|
||||
struct ndpi_id_struct **dst,
|
||||
u_int8_t *proto,
|
||||
u_int8_t **payload,
|
||||
u_int16_t *payload_len,
|
||||
u_int8_t *src_to_dst_direction) {
|
||||
u_int32_t idx, l4_offset, hashval;
|
||||
struct ndpi_flow_info flow;
|
||||
void *ret;
|
||||
u_int8_t *l3, *l4;
|
||||
|
||||
/*
|
||||
Note: to keep things simple (ndpiReader is just a demo app)
|
||||
we handle IPv6 a-la-IPv4.
|
||||
*/
|
||||
if(version == IPVERSION) {
|
||||
if(ipsize < 20)
|
||||
return NULL;
|
||||
|
||||
if((iph->ihl * 4) > ipsize || ipsize < ntohs(iph->tot_len)
|
||||
/* || (iph->frag_off & htons(0x1FFF)) != 0 */)
|
||||
return NULL;
|
||||
|
||||
l4_offset = iph->ihl * 4;
|
||||
l3 = (u_int8_t*)iph;
|
||||
} else {
|
||||
l4_offset = sizeof(struct ndpi_ipv6hdr);
|
||||
l3 = (u_int8_t*)iph6;
|
||||
}
|
||||
|
||||
if(l4_packet_len < 64)
|
||||
workflow->stats.packet_len[0]++;
|
||||
else if(l4_packet_len >= 64 && l4_packet_len < 128)
|
||||
workflow->stats.packet_len[1]++;
|
||||
else if(l4_packet_len >= 128 && l4_packet_len < 256)
|
||||
workflow->stats.packet_len[2]++;
|
||||
else if(l4_packet_len >= 256 && l4_packet_len < 1024)
|
||||
workflow->stats.packet_len[3]++;
|
||||
else if(l4_packet_len >= 1024 && l4_packet_len < 1500)
|
||||
workflow->stats.packet_len[4]++;
|
||||
else if(l4_packet_len >= 1500)
|
||||
workflow->stats.packet_len[5]++;
|
||||
|
||||
if(l4_packet_len > workflow->stats.max_packet_len)
|
||||
workflow->stats.max_packet_len = l4_packet_len;
|
||||
|
||||
*proto = iph->protocol;
|
||||
l4 = ((u_int8_t *) l3 + l4_offset);
|
||||
|
||||
if(iph->protocol == IPPROTO_TCP && l4_packet_len >= 20) {
|
||||
u_int tcp_len;
|
||||
|
||||
// tcp
|
||||
workflow->stats.tcp_count++;
|
||||
*tcph = (struct ndpi_tcphdr *)l4;
|
||||
*sport = ntohs((*tcph)->source), *dport = ntohs((*tcph)->dest);
|
||||
tcp_len = ndpi_min(4*(*tcph)->doff, l4_packet_len);
|
||||
*payload = &l4[tcp_len];
|
||||
*payload_len = ndpi_max(0, l4_packet_len-4*(*tcph)->doff);
|
||||
} else if(iph->protocol == IPPROTO_UDP && l4_packet_len >= 8) {
|
||||
// udp
|
||||
|
||||
workflow->stats.udp_count++;
|
||||
*udph = (struct ndpi_udphdr *)l4;
|
||||
*sport = ntohs((*udph)->source), *dport = ntohs((*udph)->dest);
|
||||
*payload = &l4[sizeof(struct ndpi_udphdr)];
|
||||
*payload_len = ndpi_max(0, l4_packet_len-sizeof(struct ndpi_udphdr));
|
||||
} else {
|
||||
// non tcp/udp protocols
|
||||
*sport = *dport = 0;
|
||||
}
|
||||
|
||||
flow.protocol = iph->protocol, flow.vlan_id = vlan_id;
|
||||
flow.src_ip = iph->saddr, flow.dst_ip = iph->daddr;
|
||||
flow.src_port = htons(*sport), flow.dst_port = htons(*dport);
|
||||
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;
|
||||
ret = ndpi_tfind(&flow, &workflow->ndpi_flows_root[idx], ndpi_workflow_node_cmp);
|
||||
|
||||
if(ret == NULL) {
|
||||
if(workflow->stats.ndpi_flow_count == workflow->prefs.max_ndpi_flows) {
|
||||
NDPI_LOG(0, workflow->ndpi_struct, NDPI_LOG_ERROR,
|
||||
"maximum flow count (%u) has been exceeded\n",
|
||||
workflow->prefs.max_ndpi_flows);
|
||||
exit(-1);
|
||||
} else {
|
||||
struct ndpi_flow_info *newflow = (struct ndpi_flow_info*)malloc(sizeof(struct ndpi_flow_info));
|
||||
|
||||
if(newflow == NULL) {
|
||||
NDPI_LOG(0, workflow->ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(1): not enough memory\n", __FUNCTION__);
|
||||
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) {
|
||||
NDPI_LOG(0, workflow->ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(2): not enough memory\n", __FUNCTION__);
|
||||
free(newflow);
|
||||
return(NULL);
|
||||
} else
|
||||
memset(newflow->ndpi_flow, 0, SIZEOF_FLOW_STRUCT);
|
||||
|
||||
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__);
|
||||
free(newflow);
|
||||
return(NULL);
|
||||
} else
|
||||
memset(newflow->src_id, 0, SIZEOF_ID_STRUCT);
|
||||
|
||||
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__);
|
||||
free(newflow);
|
||||
return(NULL);
|
||||
} else
|
||||
memset(newflow->dst_id, 0, SIZEOF_ID_STRUCT);
|
||||
|
||||
ndpi_tsearch(newflow, &workflow->ndpi_flows_root[idx], ndpi_workflow_node_cmp); /* Add */
|
||||
workflow->stats.ndpi_flow_count++;
|
||||
|
||||
*src = newflow->src_id, *dst = newflow->dst_id;
|
||||
|
||||
return newflow;
|
||||
}
|
||||
} else {
|
||||
struct ndpi_flow_info *flow = *(struct ndpi_flow_info**)ret;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/* ****************************************************** */
|
||||
|
||||
static struct ndpi_flow_info *get_ndpi_flow_info6(struct ndpi_workflow * workflow,
|
||||
u_int16_t vlan_id,
|
||||
const struct ndpi_ipv6hdr *iph6,
|
||||
u_int16_t ip_offset,
|
||||
struct ndpi_tcphdr **tcph,
|
||||
struct ndpi_udphdr **udph,
|
||||
u_int16_t *sport, u_int16_t *dport,
|
||||
struct ndpi_id_struct **src,
|
||||
struct ndpi_id_struct **dst,
|
||||
u_int8_t *proto,
|
||||
u_int8_t **payload,
|
||||
u_int16_t *payload_len,
|
||||
u_int8_t *src_to_dst_direction) {
|
||||
struct ndpi_iphdr iph;
|
||||
|
||||
memset(&iph, 0, sizeof(iph));
|
||||
iph.version = IPVERSION;
|
||||
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.protocol = iph6->ip6_ctlun.ip6_un1.ip6_un1_nxt;
|
||||
|
||||
if(iph.protocol == IPPROTO_DSTOPTS /* IPv6 destination option */) {
|
||||
u_int8_t *options = (u_int8_t*)iph6 + sizeof(const struct ndpi_ipv6hdr);
|
||||
|
||||
iph.protocol = options[0];
|
||||
}
|
||||
|
||||
return(get_ndpi_flow_info(workflow, 6, vlan_id, &iph, iph6, ip_offset,
|
||||
sizeof(struct ndpi_ipv6hdr),
|
||||
ntohs(iph6->ip6_ctlun.ip6_un1.ip6_un1_plen),
|
||||
tcph, udph, sport, dport,
|
||||
src, dst, proto, payload, payload_len, src_to_dst_direction));
|
||||
}
|
||||
|
||||
/* ****************************************************** */
|
||||
|
||||
void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow) {
|
||||
if(!flow->ndpi_flow) return;
|
||||
|
||||
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,
|
||||
u_int16_t vlan_id,
|
||||
const struct ndpi_iphdr *iph,
|
||||
struct ndpi_ipv6hdr *iph6,
|
||||
u_int16_t ip_offset,
|
||||
u_int16_t ipsize, u_int16_t rawsize) {
|
||||
struct ndpi_id_struct *src, *dst;
|
||||
struct ndpi_flow_info *flow = NULL;
|
||||
struct ndpi_flow_struct *ndpi_flow = NULL;
|
||||
u_int8_t proto;
|
||||
struct ndpi_tcphdr *tcph = NULL;
|
||||
struct ndpi_udphdr *udph = NULL;
|
||||
u_int16_t sport, dport, payload_len;
|
||||
u_int8_t *payload;
|
||||
u_int8_t src_to_dst_direction = 1;
|
||||
struct ndpi_proto nproto = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN };
|
||||
|
||||
if(iph)
|
||||
flow = get_ndpi_flow_info(workflow, IPVERSION, vlan_id, iph, NULL,
|
||||
ip_offset, ipsize,
|
||||
ntohs(iph->tot_len) - (iph->ihl * 4),
|
||||
&tcph, &udph, &sport, &dport,
|
||||
&src, &dst, &proto,
|
||||
&payload, &payload_len, &src_to_dst_direction);
|
||||
else
|
||||
flow = get_ndpi_flow_info6(workflow, vlan_id, iph6, ip_offset,
|
||||
&tcph, &udph, &sport, &dport,
|
||||
&src, &dst, &proto,
|
||||
&payload, &payload_len, &src_to_dst_direction);
|
||||
|
||||
if(flow != NULL) {
|
||||
workflow->stats.ip_packet_count++;
|
||||
workflow->stats.total_wire_bytes += rawsize + 24 /* CRC etc */,
|
||||
workflow->stats.total_ip_bytes += rawsize;
|
||||
ndpi_flow = flow->ndpi_flow;
|
||||
|
||||
if(src_to_dst_direction)
|
||||
flow->src2dst_packets++, flow->src2dst_bytes += rawsize;
|
||||
else
|
||||
flow->dst2src_packets++, flow->dst2src_bytes += rawsize;
|
||||
|
||||
flow->last_seen = time;
|
||||
} else { // flow is NULL
|
||||
workflow->stats.total_discarded_bytes++;
|
||||
return(nproto);
|
||||
}
|
||||
|
||||
/* Protocol already detected */
|
||||
if(flow->detection_completed) {
|
||||
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,
|
||||
iph ? (uint8_t *)iph : (uint8_t *)iph6,
|
||||
ipsize, time, src, dst);
|
||||
|
||||
if((flow->detected_protocol.app_protocol != NDPI_PROTOCOL_UNKNOWN)
|
||||
|| ((proto == IPPROTO_UDP) && ((flow->src2dst_packets + flow->dst2src_packets) > 8))
|
||||
|| ((proto == IPPROTO_TCP) && ((flow->src2dst_packets + flow->dst2src_packets) > 10))) {
|
||||
/* New protocol detected or give up */
|
||||
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)
|
||||
flow->detected_protocol = ndpi_detection_giveup(workflow->ndpi_struct,
|
||||
flow->ndpi_flow);
|
||||
process_ndpi_collected_info(workflow, flow);
|
||||
}
|
||||
|
||||
return(flow->detected_protocol);
|
||||
}
|
||||
|
||||
/* ****************************************************** */
|
||||
|
||||
struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
|
||||
const struct pcap_pkthdr *header,
|
||||
const u_char *packet) {
|
||||
/*
|
||||
* Declare pointers to packet headers
|
||||
*/
|
||||
/* --- Ethernet header --- */
|
||||
const struct ndpi_ethhdr *ethernet;
|
||||
/* --- LLC header --- */
|
||||
const struct ndpi_llc_header_snap *llc;
|
||||
|
||||
/* --- Cisco HDLC header --- */
|
||||
const struct ndpi_chdlc *chdlc;
|
||||
|
||||
/* --- Radio Tap header --- */
|
||||
const struct ndpi_radiotap_header *radiotap;
|
||||
/* --- Wifi header --- */
|
||||
const struct ndpi_wifi_header *wifi;
|
||||
|
||||
/* --- MPLS header --- */
|
||||
struct ndpi_mpls_header *mpls;
|
||||
|
||||
/** --- IP header --- **/
|
||||
struct ndpi_iphdr *iph;
|
||||
/** --- IPv6 header --- **/
|
||||
struct ndpi_ipv6hdr *iph6;
|
||||
|
||||
struct ndpi_proto nproto = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN };
|
||||
|
||||
/* lengths and offsets */
|
||||
u_int16_t eth_offset = 0;
|
||||
u_int16_t radio_len;
|
||||
u_int16_t fc;
|
||||
u_int16_t type = 0;
|
||||
int wifi_len = 0;
|
||||
int pyld_eth_len = 0;
|
||||
int check;
|
||||
u_int64_t time;
|
||||
u_int16_t ip_offset = 0, ip_len;
|
||||
u_int16_t frag_off = 0, vlan_id = 0;
|
||||
u_int8_t proto = 0;
|
||||
u_int32_t label;
|
||||
|
||||
/* counters */
|
||||
u_int8_t vlan_packet = 0;
|
||||
|
||||
/* Increment raw packet counter */
|
||||
workflow->stats.raw_packet_count++;
|
||||
|
||||
/* setting time */
|
||||
time = ((uint64_t) header->ts.tv_sec) * TICK_RESOLUTION + header->ts.tv_usec / (1000000 / TICK_RESOLUTION);
|
||||
|
||||
/* safety check */
|
||||
if(workflow->last_time > time) {
|
||||
/* printf("\nWARNING: timestamp bug in the pcap file (ts delta: %llu, repairing)\n", ndpi_thread_info[thread_id].last_time - time); */
|
||||
time = workflow->last_time;
|
||||
}
|
||||
/* update last time value */
|
||||
workflow->last_time = time;
|
||||
|
||||
/*** check Data Link type ***/
|
||||
const int datalink_type = pcap_datalink(workflow->pcap_handle);
|
||||
|
||||
datalink_check:
|
||||
switch(datalink_type) {
|
||||
case DLT_NULL:
|
||||
if(ntohl(*((u_int32_t*)&packet[eth_offset])) == 2)
|
||||
type = ETH_P_IP;
|
||||
else
|
||||
type = ETH_P_IPV6;
|
||||
|
||||
ip_offset = 4 + eth_offset;
|
||||
break;
|
||||
|
||||
/* Cisco PPP in HDLC-like framing - 50 */
|
||||
case DLT_PPP_SERIAL:
|
||||
chdlc = (struct ndpi_chdlc *) &packet[eth_offset];
|
||||
ip_offset = sizeof(struct ndpi_chdlc); /* CHDLC_OFF = 4 */
|
||||
type = ntohs(chdlc->proto_code);
|
||||
break;
|
||||
|
||||
/* Cisco PPP - 9 or 104 */
|
||||
case DLT_C_HDLC:
|
||||
case DLT_PPP:
|
||||
chdlc = (struct ndpi_chdlc *) &packet[eth_offset];
|
||||
ip_offset = sizeof(struct ndpi_chdlc); /* CHDLC_OFF = 4 */
|
||||
type = ntohs(chdlc->proto_code);
|
||||
break;
|
||||
|
||||
/* IEEE 802.3 Ethernet - 1 */
|
||||
case DLT_EN10MB:
|
||||
ethernet = (struct ndpi_ethhdr *) &packet[eth_offset];
|
||||
ip_offset = sizeof(struct ndpi_ethhdr) + eth_offset;
|
||||
check = ntohs(ethernet->h_proto);
|
||||
|
||||
if(check <= 1500)
|
||||
pyld_eth_len = check;
|
||||
else if (check >= 1536)
|
||||
type = check;
|
||||
|
||||
if(pyld_eth_len != 0) {
|
||||
llc = (struct ndpi_llc_header_snap *)(&packet[ip_offset]);
|
||||
/* check for LLC layer with SNAP extension */
|
||||
if(llc->dsap == SNAP || llc->ssap == SNAP) {
|
||||
type = llc->snap.proto_ID;
|
||||
ip_offset += + 8;
|
||||
}
|
||||
/* No SNAP extension - Spanning Tree pkt must be discarted */
|
||||
else if(llc->dsap == BSTP || llc->ssap == BSTP) {
|
||||
goto v4_warning;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* Linux Cooked Capture - 113 */
|
||||
case DLT_LINUX_SLL:
|
||||
type = (packet[eth_offset+14] << 8) + packet[eth_offset+15];
|
||||
ip_offset = 16 + eth_offset;
|
||||
break;
|
||||
|
||||
/* Radiotap link-layer - 127 */
|
||||
case DLT_IEEE802_11_RADIO:
|
||||
radiotap = (struct ndpi_radiotap_header *) &packet[eth_offset];
|
||||
radio_len = radiotap->len;
|
||||
|
||||
/* Check Bad FCS presence */
|
||||
if((radiotap->flags & BAD_FCS) == BAD_FCS) {
|
||||
workflow->stats.total_discarded_bytes += header->len;
|
||||
return(nproto);
|
||||
}
|
||||
|
||||
/* Calculate 802.11 header length (variable) */
|
||||
wifi = (struct ndpi_wifi_header*)( packet + eth_offset + radio_len);
|
||||
fc = wifi->fc;
|
||||
|
||||
/* check wifi data presence */
|
||||
if(FCF_TYPE(fc) == WIFI_DATA) {
|
||||
if((FCF_TO_DS(fc) && FCF_FROM_DS(fc) == 0x0) ||
|
||||
(FCF_TO_DS(fc) == 0x0 && FCF_FROM_DS(fc)))
|
||||
wifi_len = 26; /* + 4 byte fcs */
|
||||
} else /* no data frames */
|
||||
break;
|
||||
|
||||
/* Check ether_type from LLC */
|
||||
llc = (struct ndpi_llc_header_snap*)(packet + eth_offset + wifi_len + radio_len);
|
||||
if(llc->dsap == SNAP)
|
||||
type = ntohs(llc->snap.proto_ID);
|
||||
|
||||
/* Set IP header offset */
|
||||
ip_offset = wifi_len + radio_len + sizeof(struct ndpi_llc_header_snap) + eth_offset;
|
||||
break;
|
||||
|
||||
case DLT_RAW:
|
||||
ip_offset = eth_offset = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* printf("Unknown datalink %d\n", datalink_type); */
|
||||
return(nproto);
|
||||
}
|
||||
|
||||
/* check ether type */
|
||||
switch(type) {
|
||||
case VLAN:
|
||||
vlan_id = ((packet[ip_offset] << 8) + packet[ip_offset+1]) & 0xFFF;
|
||||
type = (packet[ip_offset+2] << 8) + packet[ip_offset+3];
|
||||
ip_offset += 4;
|
||||
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;
|
||||
case MPLS_UNI:
|
||||
case MPLS_MULTI:
|
||||
mpls = (struct ndpi_mpls_header *) &packet[ip_offset];
|
||||
label = ntohl(mpls->label);
|
||||
/* label = ntohl(*((u_int32_t*)&packet[ip_offset])); */
|
||||
workflow->stats.mpls_count++;
|
||||
type = ETH_P_IP, ip_offset += 4;
|
||||
|
||||
while((label & 0x100) != 0x100) {
|
||||
ip_offset += 4;
|
||||
label = ntohl(mpls->label);
|
||||
}
|
||||
break;
|
||||
case PPPoE:
|
||||
workflow->stats.pppoe_count++;
|
||||
type = ETH_P_IP;
|
||||
ip_offset += 8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
workflow->stats.vlan_count += vlan_packet;
|
||||
|
||||
iph_check:
|
||||
/* Check and set IP header size and total packet length */
|
||||
iph = (struct ndpi_iphdr *) &packet[ip_offset];
|
||||
|
||||
/* just work on Ethernet packets that contain IP */
|
||||
if(type == ETH_P_IP && header->caplen >= ip_offset) {
|
||||
frag_off = ntohs(iph->frag_off);
|
||||
|
||||
proto = iph->protocol;
|
||||
if(header->caplen < header->len) {
|
||||
static u_int8_t cap_warning_used = 0;
|
||||
|
||||
if(cap_warning_used == 0) {
|
||||
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");
|
||||
cap_warning_used = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(iph->version == IPVERSION) {
|
||||
ip_len = ((u_int16_t)iph->ihl * 4);
|
||||
iph6 = NULL;
|
||||
|
||||
if(iph->protocol == IPPROTO_IPV6) {
|
||||
ip_offset += ip_len;
|
||||
goto iph_check;
|
||||
}
|
||||
|
||||
if((frag_off & 0x1FFF) != 0) {
|
||||
static u_int8_t ipv4_frags_warning_used = 0;
|
||||
workflow->stats.fragmented_count++;
|
||||
|
||||
if(ipv4_frags_warning_used == 0) {
|
||||
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");
|
||||
ipv4_frags_warning_used = 1;
|
||||
}
|
||||
|
||||
workflow->stats.total_discarded_bytes += header->len;
|
||||
return(nproto);
|
||||
}
|
||||
} else if(iph->version == 6) {
|
||||
iph6 = (struct ndpi_ipv6hdr *)&packet[ip_offset];
|
||||
proto = iph6->ip6_ctlun.ip6_un1.ip6_un1_nxt;
|
||||
ip_len = sizeof(struct ndpi_ipv6hdr);
|
||||
|
||||
if(proto == IPPROTO_DSTOPTS /* IPv6 destination option */) {
|
||||
|
||||
u_int8_t *options = (u_int8_t*)&packet[ip_offset+ip_len];
|
||||
proto = options[0];
|
||||
ip_len += 8 * (options[1] + 1);
|
||||
}
|
||||
iph = NULL;
|
||||
|
||||
} else {
|
||||
static u_int8_t ipv4_warning_used = 0;
|
||||
|
||||
v4_warning:
|
||||
if(ipv4_warning_used == 0) {
|
||||
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");
|
||||
ipv4_warning_used = 1;
|
||||
}
|
||||
workflow->stats.total_discarded_bytes += header->len;
|
||||
return(nproto);
|
||||
}
|
||||
|
||||
if(workflow->prefs.decode_tunnels && (proto == IPPROTO_UDP)) {
|
||||
struct ndpi_udphdr *udp = (struct ndpi_udphdr *)&packet[ip_offset+ip_len];
|
||||
u_int16_t sport = ntohs(udp->source), dport = ntohs(udp->dest);
|
||||
|
||||
if((sport == GTP_U_V1_PORT) || (dport == GTP_U_V1_PORT)) {
|
||||
/* Check if it's GTPv1 */
|
||||
u_int offset = ip_offset+ip_len+sizeof(struct ndpi_udphdr);
|
||||
u_int8_t flags = packet[offset];
|
||||
u_int8_t message_type = packet[offset+1];
|
||||
|
||||
if((((flags & 0xE0) >> 5) == 1 /* GTPv1 */) &&
|
||||
(message_type == 0xFF /* T-PDU */)) {
|
||||
|
||||
ip_offset = ip_offset+ip_len+sizeof(struct ndpi_udphdr)+8; /* GTPv1 header len */
|
||||
if(flags & 0x04) ip_offset += 1; /* next_ext_header is present */
|
||||
if(flags & 0x02) ip_offset += 4; /* sequence_number is present (it also includes next_ext_header and pdu_number) */
|
||||
if(flags & 0x01) ip_offset += 1; /* pdu_number is present */
|
||||
|
||||
iph = (struct ndpi_iphdr *) &packet[ip_offset];
|
||||
|
||||
if(iph->version != IPVERSION) {
|
||||
// printf("WARNING: not good (packet_id=%u)!\n", (unsigned int)workflow->stats.raw_packet_count);
|
||||
goto v4_warning;
|
||||
}
|
||||
}
|
||||
} else if((sport == TZSP_PORT) || (dport == TZSP_PORT)) {
|
||||
/* https://en.wikipedia.org/wiki/TZSP */
|
||||
u_int offset = ip_offset+ip_len+sizeof(struct ndpi_udphdr);
|
||||
u_int8_t version = packet[offset];
|
||||
u_int8_t type = packet[offset+1];
|
||||
u_int16_t encapsulates = ntohs(*((u_int16_t*)&packet[offset+2]));
|
||||
|
||||
if((version == 1) && (type == 0) && (encapsulates == 1)) {
|
||||
u_int8_t stop = 0;
|
||||
|
||||
offset += 4;
|
||||
|
||||
while((!stop) && (offset < header->caplen)) {
|
||||
u_int8_t tag_type = packet[offset];
|
||||
u_int8_t tag_len;
|
||||
|
||||
switch(tag_type) {
|
||||
case 0: /* PADDING Tag */
|
||||
tag_len = 1;
|
||||
break;
|
||||
case 1: /* END Tag */
|
||||
tag_len = 1, stop = 1;
|
||||
break;
|
||||
default:
|
||||
tag_len = packet[offset+1];
|
||||
break;
|
||||
}
|
||||
|
||||
offset += tag_len;
|
||||
|
||||
if(offset >= header->caplen)
|
||||
return(nproto); /* Invalid packet */
|
||||
else {
|
||||
eth_offset = offset;
|
||||
goto datalink_check;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* process the packet */
|
||||
return(packet_processing(workflow, time, vlan_id, iph, iph6,
|
||||
ip_offset, header->caplen - ip_offset, header->caplen));
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* ndpi_util.h
|
||||
*
|
||||
* Copyright (C) 2011-16 - 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This module contains routines to help setup a simple nDPI program.
|
||||
*
|
||||
* If you concern about performance or have to integrate nDPI in your
|
||||
* application, you could need to reimplement them yourself.
|
||||
*
|
||||
* WARNING: this API is unstable! Use it at your own risk!
|
||||
*/
|
||||
#ifndef __NDPI_UTIL_H__
|
||||
#define __NDPI_UTIL_H__
|
||||
|
||||
#include <pcap.h>
|
||||
|
||||
#define MAX_NUM_READER_THREADS 16
|
||||
#define IDLE_SCAN_PERIOD 10 /* msec (use TICK_RESOLUTION = 1000) */
|
||||
#define MAX_IDLE_TIME 30000
|
||||
#define IDLE_SCAN_BUDGET 1024
|
||||
#define NUM_ROOTS 512
|
||||
#define MAX_EXTRA_PACKETS_TO_CHECK 7
|
||||
#define MAX_NDPI_FLOWS 200000000
|
||||
#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
|
||||
typedef struct ndpi_flow_info {
|
||||
u_int32_t hashval;
|
||||
u_int32_t src_ip;
|
||||
u_int32_t dst_ip;
|
||||
u_int16_t src_port;
|
||||
u_int16_t dst_port;
|
||||
u_int8_t detection_completed, protocol, bidirectional, check_extra_packets;
|
||||
u_int16_t vlan_id;
|
||||
struct ndpi_flow_struct *ndpi_flow;
|
||||
char src_name[48], dst_name[48];
|
||||
u_int8_t ip_version;
|
||||
u_int64_t last_seen;
|
||||
u_int64_t src2dst_bytes, dst2src_bytes;
|
||||
u_int32_t src2dst_packets, dst2src_packets;
|
||||
|
||||
// result only, not used for flow identification
|
||||
ndpi_protocol detected_protocol;
|
||||
|
||||
char info[96];
|
||||
char host_server_name[192];
|
||||
char bittorent_hash[41];
|
||||
|
||||
struct {
|
||||
char client_info[48], server_info[48];
|
||||
} ssh_ssl;
|
||||
|
||||
void *src_id, *dst_id;
|
||||
} ndpi_flow_info_t;
|
||||
|
||||
|
||||
// flow statistics info
|
||||
typedef struct ndpi_stats {
|
||||
u_int32_t guessed_flow_protocols;
|
||||
u_int64_t raw_packet_count;
|
||||
u_int64_t ip_packet_count;
|
||||
u_int64_t total_wire_bytes, total_ip_bytes, total_discarded_bytes;
|
||||
u_int64_t protocol_counter[NDPI_MAX_SUPPORTED_PROTOCOLS + NDPI_MAX_NUM_CUSTOM_PROTOCOLS + 1];
|
||||
u_int64_t protocol_counter_bytes[NDPI_MAX_SUPPORTED_PROTOCOLS + NDPI_MAX_NUM_CUSTOM_PROTOCOLS + 1];
|
||||
u_int32_t protocol_flows[NDPI_MAX_SUPPORTED_PROTOCOLS + NDPI_MAX_NUM_CUSTOM_PROTOCOLS + 1];
|
||||
u_int32_t ndpi_flow_count;
|
||||
u_int64_t tcp_count, udp_count;
|
||||
u_int64_t mpls_count, pppoe_count, vlan_count, fragmented_count;
|
||||
u_int64_t packet_len[6];
|
||||
u_int16_t max_packet_len;
|
||||
} ndpi_stats_t;
|
||||
|
||||
|
||||
// flow preferences
|
||||
typedef struct ndpi_workflow_prefs {
|
||||
u_int8_t decode_tunnels;
|
||||
u_int8_t quiet_mode;
|
||||
u_int32_t num_roots;
|
||||
u_int32_t max_ndpi_flows;
|
||||
} ndpi_workflow_prefs_t;
|
||||
|
||||
struct ndpi_workflow;
|
||||
|
||||
/** workflow, flow, user data */
|
||||
typedef void (*ndpi_workflow_callback_ptr) (struct ndpi_workflow *, struct ndpi_flow_info *, void *);
|
||||
|
||||
|
||||
// workflow main structure
|
||||
typedef struct ndpi_workflow {
|
||||
u_int64_t last_time;
|
||||
|
||||
struct ndpi_workflow_prefs prefs;
|
||||
struct ndpi_stats stats;
|
||||
|
||||
ndpi_workflow_callback_ptr __flow_detected_callback;
|
||||
void * __flow_detected_udata;
|
||||
ndpi_workflow_callback_ptr __flow_giveup_callback;
|
||||
void * __flow_giveup_udata;
|
||||
|
||||
/* outside referencies */
|
||||
pcap_t *pcap_handle;
|
||||
|
||||
/* allocated by prefs */
|
||||
void **ndpi_flows_root;
|
||||
struct ndpi_detection_module_struct *ndpi_struct;
|
||||
u_int32_t num_allocated_flows;
|
||||
} ndpi_workflow_t;
|
||||
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
/* workflow main free function */
|
||||
void ndpi_workflow_free(struct ndpi_workflow * workflow);
|
||||
|
||||
|
||||
/** Free flow_info ndpi support structures but not the flow_info itself
|
||||
*
|
||||
* TODO remove! Half freeing things is bad!
|
||||
*/
|
||||
void ndpi_free_flow_info_half(struct ndpi_flow_info *flow);
|
||||
|
||||
|
||||
/* Process a packet and update the workflow */
|
||||
struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
|
||||
const struct pcap_pkthdr *header,
|
||||
const u_char *packet);
|
||||
|
||||
|
||||
/* flow callbacks for complete detected flow
|
||||
(ndpi_flow_info will be freed right after) */
|
||||
static inline void ndpi_workflow_set_flow_detected_callback(struct ndpi_workflow * workflow, ndpi_workflow_callback_ptr callback, void * udata) {
|
||||
workflow->__flow_detected_callback = callback;
|
||||
workflow->__flow_detected_udata = udata;
|
||||
}
|
||||
|
||||
/* flow callbacks for sufficient detected flow
|
||||
(ndpi_flow_info will be freed right after) */
|
||||
static inline void ndpi_workflow_set_flow_giveup_callback(struct ndpi_workflow * workflow, ndpi_workflow_callback_ptr callback, void * udata) {
|
||||
workflow->__flow_giveup_callback = callback;
|
||||
workflow->__flow_giveup_udata = udata;
|
||||
}
|
||||
|
||||
/* compare two nodes in workflow */
|
||||
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);
|
||||
#endif
|
||||
+7
-1
@@ -10,9 +10,15 @@ tcp:3000@ntop
|
||||
# Format:
|
||||
# host:"<value>",host:"<value>",.....@<subproto>
|
||||
|
||||
host:"googlesyndacation.com"@Google
|
||||
host:"googlesyndication.com"@Google
|
||||
host:"venere.com"@Venere
|
||||
host:"kataweb.it",host:"repubblica.it"@Repubblica
|
||||
host:"ntop"@ntop
|
||||
# IP based Subprotocols
|
||||
# Format:
|
||||
# ip:<value>,ip:<value>,.....@<subproto>
|
||||
|
||||
ip:213.75.170.11@CustomProtocol
|
||||
|
||||
|
||||
|
||||
|
||||
+1096
File diff suppressed because it is too large
Load Diff
+34
@@ -1,6 +1,9 @@
|
||||
ndpi_dump_protocols
|
||||
ndpi_strnstr
|
||||
ndpi_detection_giveup
|
||||
ndpi_get_proto_name
|
||||
ndpi_free
|
||||
ndpi_flow_free
|
||||
ndpi_guess_undetected_protocol
|
||||
ndpi_tfind
|
||||
ndpi_tsearch
|
||||
@@ -10,6 +13,7 @@ ndpi_detection_get_sizeof_ndpi_flow_struct
|
||||
ndpi_load_protocols_file
|
||||
ndpi_tdestroy
|
||||
ndpi_exit_detection_module
|
||||
ndpi_l4_detection_process_packet
|
||||
ndpi_detection_process_packet
|
||||
ndpi_twalk
|
||||
ndpi_tdelete
|
||||
@@ -25,3 +29,33 @@ ndpi_get_http_content_type
|
||||
ndpi_free_flow
|
||||
ndpi_get_proto_breed
|
||||
ndpi_get_proto_breed_name
|
||||
ndpi_get_proto_by_id
|
||||
ndpi_get_proto_by_name
|
||||
ndpi_get_protocol_id_master_proto
|
||||
ndpi_guess_protocol_id
|
||||
ndpi_protocol2name
|
||||
ndpi_get_lower_proto
|
||||
ndpi_is_proto
|
||||
ndpi_malloc
|
||||
ndpi_calloc
|
||||
ndpi_set_detected_protocol
|
||||
ndpi_match_string_subprotocol
|
||||
ndpi_init_automa
|
||||
ndpi_free_automa
|
||||
ndpi_add_string_value_to_automa
|
||||
ndpi_add_string_to_automa
|
||||
ndpi_finalize_automa
|
||||
ndpi_match_string
|
||||
ndpi_match_string_id
|
||||
set_ndpi_malloc
|
||||
set_ndpi_flow_malloc
|
||||
set_ndpi_free
|
||||
set_ndpi_flow_free
|
||||
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
|
||||
+270
-117
@@ -19,10 +19,10 @@
|
||||
# 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,
|
||||
# but also link it with them as well. e.g. you should link with
|
||||
# but also to link with them as well. For example, you might link with
|
||||
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
|
||||
#
|
||||
# If you are only building threads programs, you may wish to use these
|
||||
# If you are only building threaded programs, you may wish to use these
|
||||
# variables in your default LIBS, CFLAGS, and CC:
|
||||
#
|
||||
# LIBS="$PTHREAD_LIBS $LIBS"
|
||||
@@ -30,8 +30,8 @@
|
||||
# CC="$PTHREAD_CC"
|
||||
#
|
||||
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
|
||||
# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
|
||||
# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
||||
# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
|
||||
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
||||
#
|
||||
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
|
||||
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
|
||||
@@ -82,35 +82,40 @@
|
||||
# modified version of the Autoconf Macro, you may extend this special
|
||||
# exception to the GPL to apply to your modified version as well.
|
||||
|
||||
#serial 21
|
||||
#serial 23
|
||||
|
||||
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
|
||||
AC_DEFUN([AX_PTHREAD], [
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([AC_PROG_SED])
|
||||
AC_LANG_PUSH([C])
|
||||
ax_pthread_ok=no
|
||||
|
||||
# We used to check for pthread.h first, but this fails if pthread.h
|
||||
# requires special compiler flags (e.g. on True64 or Sequent).
|
||||
# requires special compiler flags (e.g. on Tru64 or Sequent).
|
||||
# It gets checked for in the link test anyway.
|
||||
|
||||
# First of all, check if the user has set any of the PTHREAD_LIBS,
|
||||
# etcetera environment variables, and if threads linking works using
|
||||
# them:
|
||||
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
|
||||
save_CFLAGS="$CFLAGS"
|
||||
if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
|
||||
ax_pthread_save_CC="$CC"
|
||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
||||
ax_pthread_save_LIBS="$LIBS"
|
||||
AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
|
||||
AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
|
||||
AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
|
||||
AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
|
||||
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_CFLAGS=""
|
||||
fi
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
CC="$ax_pthread_save_CC"
|
||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
||||
LIBS="$ax_pthread_save_LIBS"
|
||||
fi
|
||||
|
||||
# We must check for the threads library under a number of different
|
||||
@@ -123,7 +128,7 @@ fi
|
||||
# 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.
|
||||
|
||||
ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
|
||||
ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
|
||||
|
||||
# The ordering *is* (sometimes) important. Some notes on the
|
||||
# individual items follow:
|
||||
@@ -132,82 +137,225 @@ ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mt
|
||||
# none: in case threads are in libc; should be tried before -Kthread and
|
||||
# other compiler flags to prevent continual compiler warnings
|
||||
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
||||
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
||||
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
||||
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
|
||||
# -pthreads: Solaris/gcc
|
||||
# -mthreads: Mingw32/gcc, Lynx/gcc
|
||||
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
|
||||
# (Note: HP C rejects this with "bad form for `-t' option")
|
||||
# -pthreads: Solaris/gcc (Note: HP C also rejects)
|
||||
# -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
|
||||
# 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
|
||||
# pthread: Linux, etcetera
|
||||
# --thread-safe: KAI C++
|
||||
# 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*)
|
||||
|
||||
# On Solaris (at least, for some versions), libc contains stubbed
|
||||
# (non-functional) versions of the pthreads routines, so link-based
|
||||
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
|
||||
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
||||
# a function called by this macro, so we could check for that, but
|
||||
# who knows whether they'll stub that too in a future libc.) So,
|
||||
# we'll just look for -pthreads and -lpthread first:
|
||||
# tests will erroneously succeed. (N.B.: The stubs are missing
|
||||
# pthread_cleanup_push, or rather a function called by this macro,
|
||||
# so we could check for that, but who knows whether they'll stub
|
||||
# that too in a future libc.) So we'll check first for the
|
||||
# standard Solaris way of linking pthreads (-mt -lpthread).
|
||||
|
||||
ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
|
||||
;;
|
||||
|
||||
darwin*)
|
||||
ax_pthread_flags="-pthread $ax_pthread_flags"
|
||||
ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags"
|
||||
;;
|
||||
esac
|
||||
|
||||
# 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.
|
||||
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
|
||||
|
||||
AC_MSG_CHECKING([if compiler needs -Werror to reject unknown 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"
|
||||
AS_IF([test "x$GCC" = "xyes"],
|
||||
[ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"])
|
||||
|
||||
if test x"$ax_pthread_ok" = xno; then
|
||||
for flag in $ax_pthread_flags; do
|
||||
# The presence of a feature test macro requesting re-entrant function
|
||||
# definitions is, on some systems, a strong hint that pthreads support is
|
||||
# correctly enabled
|
||||
|
||||
case $flag in
|
||||
case $host_os 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)
|
||||
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 $flag])
|
||||
PTHREAD_CFLAGS="$flag"
|
||||
AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
|
||||
PTHREAD_CFLAGS="$ax_pthread_try_flag"
|
||||
;;
|
||||
|
||||
pthread-config)
|
||||
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
|
||||
if test x"$ax_pthread_config" = xno; then continue; fi
|
||||
AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
|
||||
PTHREAD_CFLAGS="`pthread-config --cflags`"
|
||||
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_CHECKING([for the pthreads library -l$flag])
|
||||
PTHREAD_LIBS="-l$flag"
|
||||
AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
|
||||
PTHREAD_LIBS="-l$ax_pthread_try_flag"
|
||||
;;
|
||||
esac
|
||||
|
||||
save_LIBS="$LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
||||
ax_pthread_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
|
||||
|
||||
# Check for various functions. We must include pthread.h,
|
||||
# since some functions may be macros. (On the Sequent, we
|
||||
@@ -218,7 +366,11 @@ for flag in $ax_pthread_flags; do
|
||||
# pthread_cleanup_push because it is one of the few pthread
|
||||
# functions on Solaris that doesn't have a non-functional libc stub.
|
||||
# We try pthread_create on general principles.
|
||||
|
||||
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 *start_routine(void *a) { return a; }],
|
||||
[pthread_t th; pthread_attr_t attr;
|
||||
@@ -227,16 +379,14 @@ for flag in $ax_pthread_flags; do
|
||||
pthread_attr_init(&attr);
|
||||
pthread_cleanup_push(routine, 0);
|
||||
pthread_cleanup_pop(0) /* ; */])],
|
||||
[ax_pthread_ok=yes],
|
||||
[])
|
||||
[ax_pthread_ok=yes],
|
||||
[])
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
||||
LIBS="$ax_pthread_save_LIBS"
|
||||
|
||||
AC_MSG_RESULT([$ax_pthread_ok])
|
||||
if test "x$ax_pthread_ok" = xyes; then
|
||||
break;
|
||||
fi
|
||||
AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
|
||||
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
@@ -244,71 +394,74 @@ done
|
||||
fi
|
||||
|
||||
# Various other checks:
|
||||
if test "x$ax_pthread_ok" = xyes; then
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
if test "x$ax_pthread_ok" = "xyes"; then
|
||||
ax_pthread_save_CFLAGS="$CFLAGS"
|
||||
ax_pthread_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
|
||||
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
|
||||
AC_MSG_CHECKING([for joinable pthread attribute])
|
||||
attr_name=unknown
|
||||
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
|
||||
[int attr = $attr; return attr /* ; */])],
|
||||
[attr_name=$attr; break],
|
||||
[])
|
||||
done
|
||||
AC_MSG_RESULT([$attr_name])
|
||||
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
|
||||
AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
|
||||
[Define to necessary symbol if this constant
|
||||
uses a non-standard name on your system.])
|
||||
fi
|
||||
AC_CACHE_CHECK([for joinable pthread attribute],
|
||||
[ax_cv_PTHREAD_JOINABLE_ATTR],
|
||||
[ax_cv_PTHREAD_JOINABLE_ATTR=unknown
|
||||
for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
|
||||
[int attr = $ax_pthread_attr; return attr /* ; */])],
|
||||
[ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
|
||||
[])
|
||||
done
|
||||
])
|
||||
AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
|
||||
test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
|
||||
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
|
||||
uses a non-standard name on your system.])
|
||||
ax_pthread_joinable_attr_defined=yes
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([if more special flags are required for pthreads])
|
||||
flag=no
|
||||
case ${host_os} in
|
||||
aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
|
||||
osf* | hpux*) flag="-D_REENTRANT";;
|
||||
solaris*)
|
||||
if test "$GCC" = "yes"; then
|
||||
flag="-D_REENTRANT"
|
||||
else
|
||||
# TODO: What about Clang on Solaris?
|
||||
flag="-mt -D_REENTRANT"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
AC_MSG_RESULT([$flag])
|
||||
if test "x$flag" != xno; then
|
||||
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
|
||||
fi
|
||||
AC_CACHE_CHECK([whether more special flags are required for pthreads],
|
||||
[ax_cv_PTHREAD_SPECIAL_FLAGS],
|
||||
[ax_cv_PTHREAD_SPECIAL_FLAGS=no
|
||||
case $host_os in
|
||||
solaris*)
|
||||
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
|
||||
;;
|
||||
esac
|
||||
])
|
||||
AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
|
||||
test "x$ax_pthread_special_flags_added" != "xyes"],
|
||||
[PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
|
||||
ax_pthread_special_flags_added=yes])
|
||||
|
||||
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT], [
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
|
||||
[[int i = PTHREAD_PRIO_INHERIT;]])],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT=no])
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
|
||||
[[int i = PTHREAD_PRIO_INHERIT;]])],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
|
||||
[ax_cv_PTHREAD_PRIO_INHERIT=no])
|
||||
])
|
||||
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
|
||||
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])
|
||||
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.])
|
||||
ax_pthread_prio_inherit_defined=yes
|
||||
])
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
CFLAGS="$ax_pthread_save_CFLAGS"
|
||||
LIBS="$ax_pthread_save_LIBS"
|
||||
|
||||
# More AIX lossage: compile with *_r variant
|
||||
if test "x$GCC" != xyes; then
|
||||
if test "x$GCC" != "xyes"; then
|
||||
case $host_os in
|
||||
aix*)
|
||||
AS_CASE(["x/$CC"],
|
||||
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
|
||||
[#handle absolute path differently from PATH based program lookup
|
||||
AS_CASE(["x$CC"],
|
||||
[x/*],
|
||||
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
|
||||
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
|
||||
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
|
||||
[#handle absolute path differently from PATH based program lookup
|
||||
AS_CASE(["x$CC"],
|
||||
[x/*],
|
||||
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
|
||||
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@@ -321,7 +474,7 @@ AC_SUBST([PTHREAD_CFLAGS])
|
||||
AC_SUBST([PTHREAD_CC])
|
||||
|
||||
# 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])
|
||||
:
|
||||
else
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
This package is a GPL implementation of an iptables and netfilter module for
|
||||
nDPI integration into the Linux kernel.
|
||||
|
||||
https://github.com/ewildgoose/ndpi-netfilter
|
||||
@@ -1,9 +1,16 @@
|
||||
require "formula"
|
||||
|
||||
class Ndpi < Formula
|
||||
desc "Deep Packet Inspection (DPI) library"
|
||||
homepage "http://www.ntop.org/products/ndpi/"
|
||||
url "https://downloads.sourceforge.net/project/ntop/nDPI/libndpi-1.5.1.tar.gz"
|
||||
sha1 "0a6ed585545ab6611f3f0ac9efd9eb36bb5481dd"
|
||||
url "https://downloads.sourceforge.net/project/ntop/nDPI/nDPI-1.8.tgz"
|
||||
sha256 "f490137a7387b69d0d55e990f2150b86d7b5eaae870e5326e8c2f18c17412443"
|
||||
|
||||
bottle do
|
||||
cellar :any
|
||||
sha256 "05053767fc3c70557745c348c7352e7c2716c040ca54c5cf8d5306167c878fcb" => :el_capitan
|
||||
sha256 "34c0269039a0079820eeed862daa28158d9291f73f640a9415da60746d69a662" => :yosemite
|
||||
sha256 "a2af4dc62c24313593b3a20e45ca9d2d49f8efc0ea5e52fd064001ea441b93e4" => :mavericks
|
||||
sha256 "1bb200268a4d9df9bbe5d33bc773ee3bcf4b5d4fa00c76a040f16318438c284f" => :mountain_lion
|
||||
end
|
||||
|
||||
depends_on "autoconf" => :build
|
||||
depends_on "automake" => :build
|
||||
@@ -11,13 +18,16 @@ class Ndpi < Formula
|
||||
depends_on "libtool" => :build
|
||||
depends_on "json-c"
|
||||
|
||||
head "https://github.com/ntop/nDPI.git", :branch => "dev"
|
||||
|
||||
def install
|
||||
system "./configure","--prefix=#{prefix}"
|
||||
system "./autogen.sh"
|
||||
system "./configure", "--prefix=#{prefix}"
|
||||
system "make"
|
||||
system "make", "install"
|
||||
end
|
||||
|
||||
test do
|
||||
system "#{bin}/ndpiReader","-h"
|
||||
system "#{bin}/ndpiReader", "-i", test_fixtures("test.pcap")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#
|
||||
# debian/compat
|
||||
# We should use at least comparibily version 5
|
||||
# We should use at least compatibility version 5
|
||||
# but this requires the whole building process
|
||||
# to be remade and this is something we leave
|
||||
# to when we will have more time
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
|
||||
library_includedir=$(includedir)/libndpi-1.4/libndpi
|
||||
library_includedir=$(includedir)/libndpi-@VERSION@/libndpi
|
||||
|
||||
library_include_HEADERS = ndpi_api.h \
|
||||
ndpi_debug_functions.h \
|
||||
ndpi_define.h \
|
||||
ndpi_macros.h \
|
||||
ndpi_protocols_osdpi.h \
|
||||
ndpi_public_functions.h
|
||||
ndpi_define.h \
|
||||
ndpi_typedefs.h \
|
||||
ndpi_main.h \
|
||||
ndpi_protocol_ids.h \
|
||||
ndpi_protocols.h \
|
||||
ndpi_win32.h \
|
||||
ndpi_includes.h
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* linux_compat.h
|
||||
*
|
||||
* 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
|
||||
* 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_LINUX_COMPAT_H__
|
||||
#define __NDPI_LINUX_COMPAT_H__
|
||||
|
||||
#include "ndpi_define.h"
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#include <machine/endian.h>
|
||||
|
||||
#if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#ifndef __LITTLE_ENDIAN__
|
||||
#define __LITTLE_ENDIAN__ 1
|
||||
#endif
|
||||
#else
|
||||
#ifndef __BIG_ENDIAN__
|
||||
#define __BIG_ENDIAN__ 1
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#pragma pack(push, 1) /* push current alignment to stack */
|
||||
#pragma pack(1) /* set alignment to 1 byte boundary */
|
||||
|
||||
#pragma pack(pop) /* restore original alignment from stack */
|
||||
|
||||
struct ndpi_ethhdr {
|
||||
u_char h_dest[6]; /* destination eth addr */
|
||||
u_char h_source[6]; /* source ether addr */
|
||||
u_int16_t h_proto; /* packet type ID field */
|
||||
};
|
||||
|
||||
struct ndpi_80211q {
|
||||
u_int16_t vlanId;
|
||||
u_int16_t protoType;
|
||||
};
|
||||
|
||||
struct ndpi_iphdr {
|
||||
#if defined(__LITTLE_ENDIAN__)
|
||||
u_int8_t ihl:4, version:4;
|
||||
#elif defined(__BIG_ENDIAN__)
|
||||
u_int8_t version:4, ihl:4;
|
||||
#else
|
||||
# error "Byte order must be defined"
|
||||
#endif
|
||||
u_int8_t tos;
|
||||
u_int16_t tot_len;
|
||||
u_int16_t id;
|
||||
u_int16_t frag_off;
|
||||
u_int8_t ttl;
|
||||
u_int8_t protocol;
|
||||
u_int16_t check;
|
||||
u_int32_t saddr;
|
||||
u_int32_t daddr;
|
||||
};
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned long u_long;
|
||||
typedef u_char u_int8_t;
|
||||
typedef u_short u_int16_t;
|
||||
typedef uint u_int32_t;
|
||||
|
||||
#define _WS2TCPIP_H_ /* Avoid compilation problems */
|
||||
#define HAVE_SIN6_LEN
|
||||
|
||||
|
||||
/* IPv6 address */
|
||||
/* Already defined in WS2tcpip.h */
|
||||
struct ndpi_win_in6_addr
|
||||
{
|
||||
union
|
||||
{
|
||||
u_int8_t u6_addr8[16];
|
||||
u_int16_t u6_addr16[8];
|
||||
u_int32_t u6_addr32[4];
|
||||
} in6_u;
|
||||
#ifdef s6_addr
|
||||
#undef s6_addr
|
||||
#endif
|
||||
|
||||
#ifdef s6_addr16
|
||||
#undef s6_addr16
|
||||
#endif
|
||||
|
||||
#ifdef s6_addr32
|
||||
#undef s6_addr32
|
||||
#endif
|
||||
|
||||
#define s6_addr in6_u.u6_addr8
|
||||
// #define s6_addr16 in6_u.u6_addr16
|
||||
// #define s6_addr32 in6_u.u6_addr32
|
||||
|
||||
};
|
||||
|
||||
#define in6_addr win_in6_addr
|
||||
|
||||
/* Generic extension header. */
|
||||
struct ndpi_ip6_ext
|
||||
{
|
||||
u_int8_t ip6e_nxt; /* next header. */
|
||||
u_int8_t ip6e_len; /* length in units of 8 octets. */
|
||||
};
|
||||
|
||||
#define s6_addr16 __u6_addr.__u6_addr16
|
||||
#define s6_addr32 __u6_addr.__u6_addr32
|
||||
#else
|
||||
#ifndef __KERNEL__
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
struct ndpi_in6_addr {
|
||||
union {
|
||||
u_int8_t __u6_addr8[16];
|
||||
u_int16_t __u6_addr16[8];
|
||||
u_int32_t __u6_addr32[4];
|
||||
} __u6_addr; /* 128-bit IP6 address */
|
||||
};
|
||||
|
||||
struct ndpi_ip6_hdr {
|
||||
union {
|
||||
struct ndpi_ip6_hdrctl {
|
||||
u_int32_t ip6_un1_flow;
|
||||
u_int16_t ip6_un1_plen;
|
||||
u_int8_t ip6_un1_nxt;
|
||||
u_int8_t ip6_un1_hlim;
|
||||
} ip6_un1;
|
||||
u_int8_t ip6_un2_vfc;
|
||||
} ip6_ctlun;
|
||||
struct ndpi_in6_addr ip6_src;
|
||||
struct ndpi_in6_addr ip6_dst;
|
||||
};
|
||||
|
||||
struct ndpi_tcphdr {
|
||||
u_int16_t source;
|
||||
u_int16_t dest;
|
||||
u_int32_t seq;
|
||||
u_int32_t ack_seq;
|
||||
#if defined(__LITTLE_ENDIAN__)
|
||||
u_int16_t res1:4, doff:4, fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1;
|
||||
#elif defined(__BIG_ENDIAN__)
|
||||
u_int16_t doff:4, res1:4, cwr:1, ece:1, urg:1, ack:1, psh:1, rst:1, syn:1, fin:1;
|
||||
#else
|
||||
# error "Byte order must be defined"
|
||||
#endif
|
||||
u_int16_t window;
|
||||
u_int16_t check;
|
||||
u_int16_t urg_ptr;
|
||||
};
|
||||
|
||||
struct ndpi_udphdr {
|
||||
u_int16_t source;
|
||||
u_int16_t dest;
|
||||
u_int16_t len;
|
||||
u_int16_t check;
|
||||
};
|
||||
|
||||
#endif
|
||||
+631
-154
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
* ndpi_api.h
|
||||
*
|
||||
* Copyright (C) 2011-15 - ntop.org
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* 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
|
||||
@@ -23,8 +22,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __NDPI_PUBLIC_FUNCTIONS_H__
|
||||
#define __NDPI_PUBLIC_FUNCTIONS_H__
|
||||
#ifndef __NDPI_API_H__
|
||||
#define __NDPI_API_H__
|
||||
|
||||
#include "ndpi_main.h"
|
||||
|
||||
@@ -32,184 +31,161 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#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_IPV6 ( 1 << 1 )
|
||||
|
||||
#define ADD_TO_DETECTION_BITMASK 1
|
||||
#define NO_ADD_TO_DETECTION_BITMASK 0
|
||||
#define SAVE_DETECTION_BITMASK_AS_UNKNOWN 1
|
||||
#define NO_SAVE_DETECTION_BITMASK_AS_UNKNOWN 0
|
||||
|
||||
|
||||
/**
|
||||
* This function returns the size of the flow struct
|
||||
* Check if a string is encoded with punycode
|
||||
* ( https://tools.ietf.org/html/rfc3492 )
|
||||
*
|
||||
* @par buff = pointer to the string to ckeck
|
||||
* @par len = len of the string
|
||||
* @return 1 if the string is punycoded;
|
||||
* else 0
|
||||
*
|
||||
*/
|
||||
int check_punycode_string(char * buff , int len);
|
||||
|
||||
|
||||
/**
|
||||
* Get the size of the flow struct
|
||||
*
|
||||
* @return the size of the flow struct
|
||||
*
|
||||
*/
|
||||
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_struct(void);
|
||||
|
||||
|
||||
/**
|
||||
* This function returns the size of the id struct
|
||||
* Get the size of the id struct
|
||||
*
|
||||
* @return the size of the id struct
|
||||
*
|
||||
*/
|
||||
u_int32_t ndpi_detection_get_sizeof_ndpi_id_struct(void);
|
||||
|
||||
|
||||
/* Public malloc/free */
|
||||
void* ndpi_malloc(unsigned long size);
|
||||
void* ndpi_calloc(unsigned long count, unsigned long size);
|
||||
void ndpi_free(void *ptr);
|
||||
void *ndpi_realloc(void *ptr, size_t old_size, size_t new_size);
|
||||
char *ndpi_strdup(const char *s);
|
||||
/*
|
||||
* Find the first occurrence of find in s, where the search is limited to the
|
||||
* first slen characters of s.
|
||||
/**
|
||||
* nDPI personal allocation and free functions
|
||||
**/
|
||||
void * ndpi_malloc(size_t size);
|
||||
void * ndpi_calloc(unsigned long count, size_t size);
|
||||
void * ndpi_realloc(void *ptr, size_t old_size, size_t new_size);
|
||||
char * ndpi_strdup(const char *s);
|
||||
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-
|
||||
* The search is limited to the first -slen- characters of the string
|
||||
*
|
||||
* @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_strnstr(const char *s, const char *find, size_t slen);
|
||||
|
||||
/**
|
||||
* This function returns the nDPI protocol id for IP-based protocol detection
|
||||
* 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
|
||||
*
|
||||
* @par ndpi_struct = the struct created for the protocol detection
|
||||
* @par pin = IP host address (MUST BE in network byte order):
|
||||
* See man(7) ip for details
|
||||
* @return the nDPI protocol ID
|
||||
*
|
||||
*/
|
||||
u_int16_t ndpi_network_ptree_match(struct ndpi_detection_module_struct *ndpi_struct, struct in_addr *pin);
|
||||
|
||||
/**
|
||||
* Same as ndpi_network_ptree_match
|
||||
*/
|
||||
u_int16_t ndpi_host_ptree_match(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t host);
|
||||
|
||||
/**
|
||||
* This function returns a new initialized detection module.
|
||||
* @param ticks_per_second the timestamp resolution per second (like 1000 for millisecond resolution)
|
||||
* @param ndpi_malloc function pointer to a memory allocator
|
||||
* @param ndpi_debug_printf a function pointer to a debug output function, use NULL in productive envionments
|
||||
* @return the initialized detection module
|
||||
* Init single protocol match
|
||||
*
|
||||
* @par ndpi_mod = the struct created for the protocol detection
|
||||
* @par match = the struct passed to match the protocol
|
||||
*
|
||||
*/
|
||||
struct ndpi_detection_module_struct *ndpi_init_detection_module(u_int32_t ticks_per_second,
|
||||
void* (*__ndpi_malloc)(unsigned long size),
|
||||
void (*__ndpi_free)(void *ptr),
|
||||
ndpi_debug_function_ptr ndpi_debug_printf);
|
||||
void ndpi_init_protocol_match(struct ndpi_detection_module_struct *ndpi_mod, ndpi_protocol_match *match);
|
||||
|
||||
|
||||
/**
|
||||
* This function frees the memory allocated in the specified flow
|
||||
* @param flow to free
|
||||
* Returns a new initialized detection module
|
||||
*
|
||||
* @return the initialized detection module
|
||||
*
|
||||
*/
|
||||
struct ndpi_detection_module_struct *ndpi_init_detection_module(void);
|
||||
|
||||
/**
|
||||
* Frees the memory allocated in the specified flow
|
||||
*
|
||||
* @par flow = the flow to deallocate
|
||||
*
|
||||
*/
|
||||
void ndpi_free_flow(struct ndpi_flow_struct *flow);
|
||||
|
||||
|
||||
/**
|
||||
* This function enables cache support in nDPI used for some protocol such as Skype
|
||||
* @param cache host name
|
||||
* @param cache port
|
||||
* Enables cache support.
|
||||
* In nDPI is used for some protocol (i.e. Skype)
|
||||
*
|
||||
* @par ndpi_mod = the struct created for the protocol detection
|
||||
* @par host = string for the host name
|
||||
* @par port = unsigned int for the port number
|
||||
*
|
||||
*/
|
||||
void ndpi_enable_cache(struct ndpi_detection_module_struct *ndpi_mod, char* host, u_int port);
|
||||
|
||||
/**
|
||||
* This function destroys the detection module
|
||||
* @param ndpi_struct the to clearing detection module
|
||||
* @param ndpi_free function pointer to a memory free function
|
||||
*/
|
||||
void
|
||||
ndpi_exit_detection_module(struct ndpi_detection_module_struct
|
||||
*ndpi_struct, void (*ndpi_free) (void *ptr));
|
||||
|
||||
/**
|
||||
* This function sets the protocol bitmask2
|
||||
* @param ndpi_struct the detection module
|
||||
* @param detection_bitmask the protocol bitmask
|
||||
*/
|
||||
void
|
||||
ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
const NDPI_PROTOCOL_BITMASK * detection_bitmask);
|
||||
/**
|
||||
* This function will processes one packet and returns the ID of the detected protocol.
|
||||
* This is the main packet processing function.
|
||||
* Destroys the detection module
|
||||
*
|
||||
* @param ndpi_struct the detection module
|
||||
* @param flow void pointer to the connection state machine
|
||||
* @param packet the packet as unsigned char pointer with the length of packetlen. the pointer must point to the Layer 3 (IP header)
|
||||
* @param packetlen the length of the packet
|
||||
* @param current_tick the current timestamp for the packet
|
||||
* @param src void pointer to the source subscriber state machine
|
||||
* @param dst void pointer to the destination subscriber state machine
|
||||
* @return returns the detected ID of the protocol
|
||||
*/
|
||||
unsigned int
|
||||
ndpi_detection_process_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);
|
||||
|
||||
#define NDPI_DETECTION_ONLY_IPV4 ( 1 << 0 )
|
||||
#define NDPI_DETECTION_ONLY_IPV6 ( 1 << 1 )
|
||||
|
||||
/**
|
||||
* query the pointer to the layer 4 packet
|
||||
* @par ndpi_struct = the struct to clearing for the detection module
|
||||
*
|
||||
* @param l3 pointer to the layer 3 data
|
||||
* @param l3_len length of the layer 3 data
|
||||
* @param l4_return filled with the pointer the layer 4 data if return value == 0, undefined otherwise
|
||||
* @param l4_len_return filled with the length of the layer 4 data if return value == 0, undefined otherwise
|
||||
* @param l4_protocol_return filled with the protocol of the layer 4 data if return value == 0, undefined otherwise
|
||||
* @param flags limit operation on ipv4 or ipv6 packets, possible values are NDPI_DETECTION_ONLY_IPV4 or NDPI_DETECTION_ONLY_IPV6; 0 means any
|
||||
* @return 0 if correct layer 4 data could be found, != 0 otherwise
|
||||
*/
|
||||
u_int8_t ndpi_detection_get_l4(const u_int8_t * l3, u_int16_t l3_len, const u_int8_t ** l4_return, u_int16_t * l4_len_return,
|
||||
u_int8_t * l4_protocol_return, u_int32_t flags);
|
||||
void ndpi_exit_detection_module(struct ndpi_detection_module_struct *ndpi_struct);
|
||||
|
||||
|
||||
/**
|
||||
* returns the real protocol for the flow of the last packet given to the detection.
|
||||
* if no real protocol could be found, the unknown protocol will be returned.
|
||||
* Sets a single protocol bitmask
|
||||
* This function does not increment the index of the callback_buffer
|
||||
*
|
||||
* @param ndpi_struct the detection module
|
||||
* @return the protocol id of the last real protocol found in the protocol history of the flow
|
||||
*/
|
||||
u_int16_t ndpi_detection_get_real_protocol_of_flow(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
|
||||
/**
|
||||
* returns true if the protocol history of the flow of the last packet given to the detection
|
||||
* contains the given protocol.
|
||||
* @par label = string for the protocol name
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par detection_bitmask = the protocol bitmask
|
||||
* @par idx = the index of the callback_buffer
|
||||
* @par func = function pointer of the protocol search
|
||||
* @par ndpi_selection_bitmask = the protocol selected bitmask
|
||||
* @par b_save_bitmask_unknow = if set as "true" save the detection bitmask as unknow
|
||||
* @par b_add_detection_bitmask = if set as "true" add the protocol bitmask to the detection bitmask
|
||||
*
|
||||
* @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);
|
||||
unsigned int ndpi_find_port_based_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int8_t proto, u_int32_t shost, u_int16_t sport, u_int32_t dhost, u_int16_t dport);
|
||||
unsigned int ndpi_guess_undetected_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int8_t proto, u_int32_t shost, u_int16_t sport, u_int32_t dhost, u_int16_t dport);
|
||||
int ndpi_match_string_subprotocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow, char *string_to_match, u_int string_to_match_len);
|
||||
int ndpi_match_content_subprotocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
char *string_to_match, u_int string_to_match_len);
|
||||
int ndpi_match_bigram(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
ndpi_automa *automa, char *bigram_to_match);
|
||||
char* ndpi_get_proto_name(struct ndpi_detection_module_struct *mod, u_int16_t proto_id);
|
||||
ndpi_protocol_breed_t ndpi_get_proto_breed(struct ndpi_detection_module_struct *ndpi_struct, u_int16_t proto);
|
||||
char* ndpi_get_proto_breed_name(struct ndpi_detection_module_struct *ndpi_struct, ndpi_protocol_breed_t breed_id);
|
||||
int ndpi_get_protocol_id(struct ndpi_detection_module_struct *ndpi_mod, char *proto);
|
||||
void ndpi_dump_protocols(struct ndpi_detection_module_struct *mod);
|
||||
int matchStringProtocol(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow,
|
||||
char *string_to_match, u_int string_to_match_len);
|
||||
|
||||
int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_mod, char* path);
|
||||
u_int ndpi_get_num_supported_protocols(struct ndpi_detection_module_struct *ndpi_mod);
|
||||
char* ndpi_revision(void);
|
||||
void ndpi_set_automa(struct ndpi_detection_module_struct *ndpi_struct, void* automa);
|
||||
|
||||
#define ADD_TO_DETECTION_BITMASK 1
|
||||
#define NO_ADD_TO_DETECTION_BITMASK 0
|
||||
#define SAVE_DETECTION_BITMASK_AS_UNKNOWN 1
|
||||
#define NO_SAVE_DETECTION_BITMASK_AS_UNKNOWN 0
|
||||
|
||||
/**
|
||||
* This function sets a single protocol bitmask
|
||||
* @param label Protocol name
|
||||
* @param ndpi_struct the detection module
|
||||
* @param detection_bitmask the protocol bitmask
|
||||
* @param idx the index of the callback_buffer
|
||||
* @param func void function point of the protocol search
|
||||
* @param ndpi_selection_bitmask the protocol selected bitmask
|
||||
* @param b_save_bitmask_unknow set true if you want save the detection bitmask as unknow
|
||||
* @param b_add_detection_bitmask set true if you want add the protocol bitmask to the detection bitmask
|
||||
* NB: this function does not increment the index of the callback_buffer
|
||||
*/
|
||||
void ndpi_set_bitmask_protocol_detection(char * label, struct ndpi_detection_module_struct *ndpi_struct,
|
||||
const NDPI_PROTOCOL_BITMASK * detection_bitmask,
|
||||
void ndpi_set_bitmask_protocol_detection(char *label, struct ndpi_detection_module_struct *ndpi_struct,
|
||||
const NDPI_PROTOCOL_BITMASK *detection_bitmask,
|
||||
const u_int32_t idx,
|
||||
u_int16_t ndpi_protocol_id,
|
||||
void (*func) (struct ndpi_detection_module_struct *, struct ndpi_flow_struct *flow),
|
||||
@@ -217,26 +193,527 @@ extern "C" {
|
||||
u_int8_t b_save_bitmask_unknow,
|
||||
u_int8_t b_add_detection_bitmask);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the protocol bitmask2
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par detection_bitmask = the protocol bitmask to set
|
||||
*
|
||||
*/
|
||||
void ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
const NDPI_PROTOCOL_BITMASK * detection_bitmask);
|
||||
|
||||
|
||||
/**
|
||||
* Function to be called before we give up with detection for a given flow.
|
||||
* This function reduces the NDPI_UNKNOWN_PROTOCOL detection
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par flow = the flow given for the detection module
|
||||
* @return the detected protocol even if the flow is not completed;
|
||||
*
|
||||
*/
|
||||
ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
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.
|
||||
* This is the MAIN PACKET PROCESSING FUNCTION.
|
||||
*
|
||||
* @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 the detected ID of the protocol
|
||||
*
|
||||
*/
|
||||
ndpi_protocol ndpi_detection_process_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);
|
||||
|
||||
|
||||
/**
|
||||
* Get the main protocol of the passed flows for the detected module
|
||||
*
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par flow = the flow given for the detection module
|
||||
* @return the ID of the master protocol detected
|
||||
*
|
||||
*/
|
||||
u_int16_t ndpi_get_flow_masterprotocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow);
|
||||
|
||||
|
||||
/**
|
||||
* Query the pointer to the layer 4 packet
|
||||
*
|
||||
* @par l3 = pointer to the layer 3 data
|
||||
* @par l3_len = length of the layer 3 data
|
||||
* @par l4_return = address to the pointer of the layer 4 data if return value == 0, else undefined
|
||||
* @par l4_len_return = length of the layer 4 data if return value == 0, else undefined
|
||||
* @par l4_protocol_return = protocol of the layer 4 data if return value == 0, undefined otherwise
|
||||
* @par flags = limit operation on ipv4 or ipv6 packets. Possible values: NDPI_DETECTION_ONLY_IPV4 - NDPI_DETECTION_ONLY_IPV6 - 0 (any)
|
||||
* @return 0 if layer 4 data could be found correctly;
|
||||
else != 0
|
||||
*
|
||||
*/
|
||||
u_int8_t ndpi_detection_get_l4(const u_int8_t *l3, u_int16_t l3_len, const u_int8_t **l4_return, u_int16_t *l4_len_return,
|
||||
u_int8_t *l4_protocol_return, u_int32_t flags);
|
||||
|
||||
|
||||
/**
|
||||
* Search and return the protocol based on matched ports
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par shost = source address in host byte order
|
||||
* @par sport = source port number
|
||||
* @par dhost = destination address in host byte order
|
||||
* @par dport = destination port number
|
||||
* @return the struct ndpi_protocol that match the port base protocol
|
||||
*
|
||||
*/
|
||||
ndpi_protocol ndpi_find_port_based_protocol(struct ndpi_detection_module_struct *ndpi_struct/* , u_int8_t proto */,
|
||||
u_int32_t shost,
|
||||
u_int16_t sport,
|
||||
u_int32_t dhost,
|
||||
u_int16_t dport);
|
||||
|
||||
|
||||
/**
|
||||
* Search and return the protocol guessed that is undetected
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par proto = the l4 protocol number
|
||||
* @par shost = source address in host byte order
|
||||
* @par sport = source port number
|
||||
* @par dhost = destination address in host byte order
|
||||
* @par dport = destination port number
|
||||
* @return the struct ndpi_protocol that match the port base protocol
|
||||
*
|
||||
*/
|
||||
ndpi_protocol ndpi_guess_undetected_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int8_t proto,
|
||||
u_int32_t shost,
|
||||
u_int16_t sport,
|
||||
u_int32_t dhost,
|
||||
u_int16_t dport);
|
||||
|
||||
|
||||
/**
|
||||
* Check if the string passed match with a protocol
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par string_to_match = the string to match
|
||||
* @par string_to_match_len = the length of the string
|
||||
* @par is_host_match = value of the second field of struct ndpi_automa
|
||||
* @return the ID of the matched subprotocol
|
||||
*
|
||||
*/
|
||||
int ndpi_match_string_subprotocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
char *string_to_match,
|
||||
u_int string_to_match_len,
|
||||
u_int8_t is_host_match);
|
||||
|
||||
|
||||
/**
|
||||
* Check if the host passed match with a protocol
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par flow = the flow where match the host
|
||||
* @par string_to_match = the string to match
|
||||
* @par string_to_match_len = the length of the string
|
||||
* @par master_protocol_id = value of the ID associated to the master protocol detected
|
||||
* @return the ID of the matched subprotocol
|
||||
*
|
||||
*/
|
||||
int ndpi_match_host_subprotocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
char *string_to_match,
|
||||
u_int string_to_match_len,
|
||||
u_int16_t master_protocol_id);
|
||||
|
||||
|
||||
/**
|
||||
* Check if the string content passed match with a protocol
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par flow = the flow where match the host
|
||||
* @par string_to_match = the string to match
|
||||
* @par string_to_match_len = the length of the string
|
||||
* @par master_protocol_id = value of the ID associated to the master protocol detected
|
||||
* @return the ID of the matched subprotocol
|
||||
*
|
||||
*/
|
||||
int ndpi_match_content_subprotocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
char *string_to_match,
|
||||
u_int string_to_match_len,
|
||||
u_int16_t master_protocol_id);
|
||||
|
||||
|
||||
/**
|
||||
* Check if the string -bigram_to_match- match with a bigram of -automa-
|
||||
*
|
||||
* @par ndpi_mod = the detection module
|
||||
* @par automa = the struct ndpi_automa for the bigram
|
||||
* @par bigram_to_match = the bigram string to match
|
||||
* @return 0
|
||||
*
|
||||
*/
|
||||
int ndpi_match_bigram(struct ndpi_detection_module_struct *ndpi_mod,
|
||||
ndpi_automa *automa,
|
||||
char *bigram_to_match);
|
||||
|
||||
/**
|
||||
* Write the protocol name in the buffer -buf- as master_protocol.protocol
|
||||
*
|
||||
* @par ndpi_mod = the detection module
|
||||
* @par proto = the struct ndpi_protocol contain the protocols name
|
||||
* @par buf = the buffer to write the name of the protocols
|
||||
* @par buf_len = the length of the buffer
|
||||
* @return the buffer contains the master_protocol and protocol name
|
||||
*
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @par mod = the detection module
|
||||
* @par proto_id = the ID of the protocol
|
||||
* @return the buffer contains the master_protocol and protocol name
|
||||
*
|
||||
*/
|
||||
char* ndpi_get_proto_name(struct ndpi_detection_module_struct *mod, u_int16_t proto_id);
|
||||
|
||||
|
||||
/**
|
||||
* Return the protocol breed ID associated to the protocol
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par proto = the ID of the protocol
|
||||
* @return the breed ID associated to the protocol
|
||||
*
|
||||
*/
|
||||
ndpi_protocol_breed_t ndpi_get_proto_breed(struct ndpi_detection_module_struct *ndpi_struct, u_int16_t proto);
|
||||
|
||||
|
||||
/**
|
||||
* Return the string name of the protocol breed
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par breed_id = the breed ID associated to the protocol
|
||||
* @return the string name of the breed ID
|
||||
*
|
||||
*/
|
||||
char* ndpi_get_proto_breed_name(struct ndpi_detection_module_struct *ndpi_struct, ndpi_protocol_breed_t breed_id);
|
||||
|
||||
|
||||
/**
|
||||
* Return the ID of the protocol
|
||||
*
|
||||
* @par ndpi_mod = the detection module
|
||||
* @par proto = 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);
|
||||
|
||||
|
||||
/**
|
||||
* Write the list of the supported protocols
|
||||
*
|
||||
* @par ndpi_mod = the detection module
|
||||
*/
|
||||
void ndpi_dump_protocols(struct ndpi_detection_module_struct *mod);
|
||||
|
||||
|
||||
/**
|
||||
* Read a file and load the protocols
|
||||
*
|
||||
* Format: <tcp|udp>:<port>,<tcp|udp>:<port>,.....@<proto>
|
||||
*
|
||||
* Example:
|
||||
* tcp:80,tcp:3128@HTTP
|
||||
* udp:139@NETBIOS
|
||||
*
|
||||
* @par ndpi_mod = the detection module
|
||||
* @par path = the path of the file
|
||||
* @return 0 if the file is loaded correctly;
|
||||
* -1 else
|
||||
*
|
||||
*/
|
||||
int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_mod, char* path);
|
||||
|
||||
|
||||
/**
|
||||
* Get the total number of the supported protocols
|
||||
*
|
||||
* @par ndpi_mod = the detection module
|
||||
* @return the number of protocols
|
||||
*
|
||||
*/
|
||||
u_int ndpi_get_num_supported_protocols(struct ndpi_detection_module_struct *ndpi_mod);
|
||||
|
||||
|
||||
/**
|
||||
* Get the nDPI version release
|
||||
*
|
||||
* @return the NDPI_GIT_RELEASE
|
||||
*
|
||||
*/
|
||||
char* ndpi_revision(void);
|
||||
|
||||
|
||||
/**
|
||||
* Set the automa for the protocol search
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par automa = the automa to match
|
||||
*
|
||||
*/
|
||||
void ndpi_set_automa(struct ndpi_detection_module_struct *ndpi_struct, void* automa);
|
||||
|
||||
|
||||
#ifdef NDPI_PROTOCOL_HTTP
|
||||
/*
|
||||
API used to retrieve information for HTTP flows
|
||||
/**
|
||||
* Retrieve information for HTTP flows
|
||||
*
|
||||
* @par ndpi_mod = the detection module
|
||||
* @par flow = the detected flow
|
||||
* @return the HTTP method information about the flow
|
||||
*
|
||||
*/
|
||||
ndpi_http_method ndpi_get_http_method(struct ndpi_detection_module_struct *ndpi_mod,
|
||||
struct ndpi_flow_struct *flow);
|
||||
|
||||
char* ndpi_get_http_url(struct ndpi_detection_module_struct *ndpi_mod,
|
||||
struct ndpi_flow_struct *flow);
|
||||
|
||||
char* ndpi_get_http_content_type(struct ndpi_detection_module_struct *ndpi_mod,
|
||||
struct ndpi_flow_struct *flow);
|
||||
ndpi_http_method ndpi_get_http_method(struct ndpi_detection_module_struct *ndpi_mod, struct ndpi_flow_struct *flow);
|
||||
|
||||
|
||||
/**
|
||||
* Get the HTTP url
|
||||
*
|
||||
* @par ndpi_mod = the detection module
|
||||
* @par flow = the detected flow
|
||||
* @return the HTTP method information about the flow
|
||||
*
|
||||
*/
|
||||
char* ndpi_get_http_url(struct ndpi_detection_module_struct *ndpi_mod, struct ndpi_flow_struct *flow);
|
||||
|
||||
|
||||
/**
|
||||
* Get the HTTP content-type
|
||||
*
|
||||
* @par ndpi_mod = the detection module
|
||||
* @par flow = the detected flow
|
||||
* @return the HTTP method information about the flow
|
||||
*
|
||||
*/
|
||||
char* ndpi_get_http_content_type(struct ndpi_detection_module_struct *ndpi_mod, struct ndpi_flow_struct *flow);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NDPI_PROTOCOL_TOR
|
||||
/**
|
||||
* Check if the flow could be detected as TOR protocol
|
||||
*
|
||||
* @par ndpi_struct = the detection module
|
||||
* @par flow = the detected flow
|
||||
* @par certificate = the ssl certificate
|
||||
* @return 1 if the flow is TOR;
|
||||
* 0 else
|
||||
*
|
||||
*/
|
||||
int ndpi_is_ssl_tor(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow, char *certificate);
|
||||
#endif
|
||||
|
||||
/* Wrappers functions */
|
||||
/**
|
||||
* Init Aho-Corasick automata
|
||||
*
|
||||
* @return The requested automata, or NULL if an error occurred
|
||||
*
|
||||
*/
|
||||
void* ndpi_init_automa(void);
|
||||
|
||||
|
||||
/**
|
||||
* Free Aho-Corasick automata allocated with ndpi_init_automa();
|
||||
*
|
||||
* @par The automata initialized with ndpi_init_automa();
|
||||
*
|
||||
*/
|
||||
void ndpi_free_automa(void *_automa);
|
||||
|
||||
|
||||
/**
|
||||
* Add a string to match to an automata
|
||||
*
|
||||
* @par The automata initialized with ndpi_init_automa();
|
||||
* @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.
|
||||
*
|
||||
*/
|
||||
int ndpi_add_string_to_automa(void *_automa, char *str);
|
||||
|
||||
|
||||
/**
|
||||
* Finalize the automa (necessary before start searching)
|
||||
*
|
||||
* @par The automata initialized with ndpi_init_automa();
|
||||
*
|
||||
*/
|
||||
void ndpi_finalize_automa(void *_automa);
|
||||
|
||||
|
||||
/**
|
||||
* Add a string to match to an automata
|
||||
*
|
||||
* @par The automata initialized with ndpi_init_automa();
|
||||
* @par The (sub)string to search
|
||||
* @return 0 in case of match, or -1 if no match, or -2 if an error occurred.
|
||||
*
|
||||
*/
|
||||
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 */
|
||||
void set_ndpi_malloc(void* (*__ndpi_malloc)(size_t size));
|
||||
void set_ndpi_free(void (*__ndpi_free)(void *ptr));
|
||||
void set_ndpi_flow_malloc(void* (*__ndpi_flow_malloc)(size_t size));
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __NDPI_API_H__ */
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (C) 2011-15 - ntop.org
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* 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
|
||||
@@ -42,15 +41,22 @@
|
||||
#endif/* BYTE_ORDER */
|
||||
#endif/* __OPENBSD__ */
|
||||
|
||||
#if 0
|
||||
#ifndef NDPI_ENABLE_DEBUG_MESSAGES
|
||||
#define NDPI_ENABLE_DEBUG_MESSAGES
|
||||
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#ifndef __LITTLE_ENDIAN__
|
||||
#define __LITTLE_ENDIAN__
|
||||
#endif
|
||||
#else
|
||||
#ifndef __BIG_ENDIAN__
|
||||
#define __BIG_ENDIAN__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef __LITTLE_ENDIAN__
|
||||
#define __LITTLE_ENDIAN__ 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !(defined(__LITTLE_ENDIAN__) || defined(__BIG_ENDIAN__))
|
||||
#if defined(__mips__)
|
||||
@@ -59,13 +65,6 @@
|
||||
#define __BIG_ENDIAN__
|
||||
#endif
|
||||
|
||||
/* Kernel modules */
|
||||
#if defined(__LITTLE_ENDIAN)
|
||||
#define __LITTLE_ENDIAN__
|
||||
#endif
|
||||
#if defined(__BIG_ENDIAN)
|
||||
#define __BIG_ENDIAN__
|
||||
#endif
|
||||
/* Everything else */
|
||||
#if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__))
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
@@ -77,7 +76,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
#define NDPI_USE_ASYMMETRIC_DETECTION 0
|
||||
#define NDPI_USE_ASYMMETRIC_DETECTION 0
|
||||
#define NDPI_SELECTION_BITMASK_PROTOCOL_SIZE u_int32_t
|
||||
|
||||
#define NDPI_SELECTION_BITMASK_PROTOCOL_IP (1<<0)
|
||||
@@ -160,51 +159,43 @@
|
||||
/* TODO: rebuild all memory areas to have a more aligned memory block here */
|
||||
|
||||
/* DEFINITION OF MAX LINE NUMBERS FOR line parse algorithm */
|
||||
#define NDPI_MAX_PARSE_LINES_PER_PACKET 64
|
||||
#define NDPI_MAX_PARSE_LINES_PER_PACKET 64
|
||||
|
||||
#define MAX_PACKET_COUNTER 65000
|
||||
#define MAX_DEFAULT_PORTS 5
|
||||
|
||||
/**********************
|
||||
* detection features *
|
||||
**********************/
|
||||
#define NDPI_SELECT_DETECTION_WITH_REAL_PROTOCOL ( 1 << 0 )
|
||||
|
||||
#define NDPI_DIRECTCONNECT_CONNECTION_IP_TICK_TIMEOUT 600
|
||||
#define NDPI_IRC_CONNECTION_TIMEOUT 120
|
||||
#define NDPI_GNUTELLA_CONNECTION_TIMEOUT 60
|
||||
#define NDPI_BATTLEFIELD_CONNECTION_TIMEOUT 60
|
||||
#define NDPI_THUNDER_CONNECTION_TIMEOUT 30
|
||||
#define NDPI_RTSP_CONNECTION_TIMEOUT 5
|
||||
#define NDPI_TVANTS_CONNECTION_TIMEOUT 5
|
||||
#define NDPI_YAHOO_DETECT_HTTP_CONNECTIONS 1
|
||||
#define NDPI_YAHOO_LAN_VIDEO_TIMEOUT 30
|
||||
#define NDPI_GNUTELLA_CONNECTION_TIMEOUT 60
|
||||
#define NDPI_BATTLEFIELD_CONNECTION_TIMEOUT 60
|
||||
#define NDPI_THUNDER_CONNECTION_TIMEOUT 30
|
||||
#define NDPI_RTSP_CONNECTION_TIMEOUT 5
|
||||
#define NDPI_TVANTS_CONNECTION_TIMEOUT 5
|
||||
#define NDPI_YAHOO_DETECT_HTTP_CONNECTIONS 1
|
||||
#define NDPI_YAHOO_LAN_VIDEO_TIMEOUT 30
|
||||
#define NDPI_ZATTOO_CONNECTION_TIMEOUT 120
|
||||
#define NDPI_ZATTOO_FLASH_TIMEOUT 5
|
||||
#define NDPI_JABBER_STUN_TIMEOUT 30
|
||||
#define NDPI_JABBER_FT_TIMEOUT 5
|
||||
#define NDPI_ZATTOO_FLASH_TIMEOUT 5
|
||||
#define NDPI_JABBER_STUN_TIMEOUT 30
|
||||
#define NDPI_JABBER_FT_TIMEOUT 5
|
||||
#define NDPI_SOULSEEK_CONNECTION_IP_TICK_TIMEOUT 600
|
||||
|
||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||
|
||||
#define NDPI_LOG(proto, mod, log_level, args...) \
|
||||
{ \
|
||||
if(mod != NULL) { \
|
||||
mod->ndpi_debug_print_file=__FILE__; \
|
||||
mod->ndpi_debug_print_function=__FUNCTION__; \
|
||||
mod->ndpi_debug_print_line=__LINE__; \
|
||||
mod->ndpi_debug_printf(proto, mod, log_level, args); \
|
||||
} \
|
||||
#define NDPI_LOG(proto, m, log_level, args...) \
|
||||
{ \
|
||||
struct ndpi_detection_module_struct *mod = (struct ndpi_detection_module_struct*) m; \
|
||||
if(mod != NULL) { \
|
||||
mod->ndpi_debug_print_file=__FILE__; \
|
||||
mod->ndpi_debug_print_function=__FUNCTION__; \
|
||||
mod->ndpi_debug_print_line=__LINE__; \
|
||||
(*(mod->ndpi_debug_printf))(proto, mod, log_level, args); \
|
||||
} \
|
||||
}
|
||||
|
||||
#else /* NDPI_ENABLE_DEBUG_MESSAGES */
|
||||
|
||||
#if defined(WIN32)
|
||||
#ifdef WIN32
|
||||
#define NDPI_LOG(...) {}
|
||||
#else
|
||||
#define NDPI_LOG(proto, mod, log_level, args...) {}
|
||||
#endif
|
||||
|
||||
#endif /* NDPI_ENABLE_DEBUG_MESSAGES */
|
||||
|
||||
/**
|
||||
@@ -218,27 +209,22 @@
|
||||
#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])) )
|
||||
|
||||
#if !defined(__KERNEL__) && !defined(NDPI_IPTABLES_EXT)
|
||||
#define NDPI_NUM_BITS 256
|
||||
#else
|
||||
/* custom protocols not supported */
|
||||
#define NDPI_NUM_BITS 192
|
||||
#endif
|
||||
|
||||
#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 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] &= ~(1 << (((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_SET(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] &= ~(1ul << (((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_ZERO(p) memset((char *)(p), 0, sizeof(*(p)))
|
||||
#define NDPI_ONE(p) memset((char *)(p), 0xFF, sizeof(*(p)))
|
||||
|
||||
#define NDPI_NUM_FDS_BITS howmanybits(NDPI_NUM_BITS, NDPI_BITS)
|
||||
|
||||
#define NDPI_PROTOCOL_BITMASK ndpi_protocol_bitmask_struct_t
|
||||
|
||||
|
||||
#define NDPI_BITMASK_ADD(a,b) NDPI_SET(&a,b)
|
||||
#define NDPI_BITMASK_DEL(a,b) NDPI_CLR(&a,b)
|
||||
#define NDPI_BITMASK_RESET(a) NDPI_ZERO(&a)
|
||||
@@ -246,7 +232,7 @@
|
||||
#define NDPI_BITMASK_SET(a, b) { memcpy(&a, &b, sizeof(NDPI_PROTOCOL_BITMASK)); }
|
||||
|
||||
/* this is a very very tricky macro *g*,
|
||||
* the compiler will remove all shifts here if the protocol is static...
|
||||
* the compiler will remove all shifts here if the protocol is static...
|
||||
*/
|
||||
#define NDPI_ADD_PROTOCOL_TO_BITMASK(bmask,value) NDPI_SET(&bmask,value)
|
||||
#define NDPI_DEL_PROTOCOL_FROM_BITMASK(bmask,value) NDPI_CLR(&bmask,value)
|
||||
@@ -289,21 +275,23 @@
|
||||
#define get_l32(X,O) get_u_int32_t(X,O)
|
||||
#elif defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN)
|
||||
/* convert the bytes from big to little endian */
|
||||
#ifndef __KERNEL__
|
||||
# define get_l16(X,O) bswap_16(get_u_int16_t(X,O))
|
||||
# define get_l32(X,O) bswap_32(get_u_int32_t(X,O))
|
||||
#else
|
||||
# define get_l16(X,O) __cpu_to_le16(get_u_int16_t(X,O))
|
||||
# define get_l32(X,O) __cpu_to_le32(get_u_int32_t(X,O))
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#error "__BYTE_ORDER MUST BE DEFINED !"
|
||||
|
||||
#endif /* __BYTE_ORDER */
|
||||
|
||||
/* define memory callback function */
|
||||
#define match_first_bytes(payload,st) (memcmp((payload),(st),(sizeof(st)-1))==0)
|
||||
|
||||
#if defined(WIN32) && !defined(snprintf)
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#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__ */
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* ndpi_includes.h
|
||||
*
|
||||
* Copyright (C) 2011-16 - 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_INCLUDES_H__
|
||||
#define __NDPI_INCLUDES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include "ndpi_win32.h"
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <pthread.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/udp.h>
|
||||
|
||||
#if !defined __APPLE__ && !defined __FreeBSD__ && !defined __NetBSD__ && !defined __OpenBSD__
|
||||
#include <endian.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
#if defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
|
||||
#include <netinet/in.h>
|
||||
|
||||
#if defined __NetBSD__ || defined __OpenBSD__
|
||||
#include <netinet/in_systm.h>
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#include <pthread.h>
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* Win32 */
|
||||
|
||||
#endif /* __NDPI_INCLUDES_H__ */
|
||||
+86
-109
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
* ndpi_main.h
|
||||
*
|
||||
* Copyright (C) 2011-15 - ntop.org
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-16 - 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
|
||||
@@ -22,135 +21,113 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __NDPI_MAIN_INCLUDE_FILE__
|
||||
#define __NDPI_MAIN_INCLUDE_FILE__
|
||||
#ifndef __NDPI_MAIN_H__
|
||||
#define __NDPI_MAIN_H__
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#ifndef WIN32
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef __KERNEL__
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if !defined __APPLE__ && !defined __FreeBSD__ && !defined __NetBSD__ && !defined __OpenBSD__
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#include <endian.h>
|
||||
#include <byteswap.h>
|
||||
#else
|
||||
#include <asm/byteorder.h>
|
||||
#include <linux/ctype.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* default includes */
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#include <sys/param.h>
|
||||
#include <limits.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "ndpi_win32.h"
|
||||
#include "ndpi_unix.h"
|
||||
#include "ndpi_includes.h"
|
||||
#include "ndpi_define.h"
|
||||
#include "ndpi_protocol_ids.h"
|
||||
#include "ndpi_typedefs.h"
|
||||
#include "ndpi_api.h"
|
||||
#include "ndpi_protocols.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void *ndpi_tdelete(const void * __restrict, void ** __restrict,
|
||||
int (*)(const void *, const void *));
|
||||
void *ndpi_tfind(const void *, void *, int (*)(const void *, const void *));
|
||||
void *ndpi_tsearch(const void *, void**, int (*)(const void *, const void *));
|
||||
void ndpi_twalk(const void *, void (*)(const void *, ndpi_VISIT, int, void*), void *user_data);
|
||||
void ndpi_tdestroy(void *vrootp, void (*freefct)(void *));
|
||||
void *ndpi_tdelete(const void * __restrict, void ** __restrict,
|
||||
int (*)(const void *, const void *));
|
||||
void *ndpi_tfind(const void *, void *, int (*)(const void *, const void *));
|
||||
void *ndpi_tsearch(const void *, void**, int (*)(const void *, const void *));
|
||||
void ndpi_twalk(const void *, void (*)(const void *, ndpi_VISIT, int, void*), void *user_data);
|
||||
void ndpi_tdestroy(void *vrootp, void (*freefct)(void *));
|
||||
|
||||
int NDPI_BITMASK_COMPARE(NDPI_PROTOCOL_BITMASK a, NDPI_PROTOCOL_BITMASK b);
|
||||
int NDPI_BITMASK_IS_EMPTY(NDPI_PROTOCOL_BITMASK a);
|
||||
void NDPI_DUMP_BITMASK(NDPI_PROTOCOL_BITMASK a);
|
||||
int NDPI_BITMASK_COMPARE(NDPI_PROTOCOL_BITMASK a, NDPI_PROTOCOL_BITMASK b);
|
||||
int NDPI_BITMASK_IS_EMPTY(NDPI_PROTOCOL_BITMASK a);
|
||||
void NDPI_DUMP_BITMASK(NDPI_PROTOCOL_BITMASK a);
|
||||
|
||||
extern u_int8_t ndpi_net_match(u_int32_t ip_to_check,
|
||||
u_int32_t net,
|
||||
u_int32_t num_bits);
|
||||
extern u_int8_t ndpi_net_match(u_int32_t ip_to_check,
|
||||
u_int32_t net,
|
||||
u_int32_t num_bits);
|
||||
|
||||
extern u_int8_t ndpi_ips_match(u_int32_t src, u_int32_t dst,
|
||||
u_int32_t net, u_int32_t num_bits);
|
||||
extern u_int8_t ndpi_ips_match(u_int32_t src, u_int32_t dst,
|
||||
u_int32_t net, u_int32_t num_bits);
|
||||
|
||||
u_int16_t ntohs_ndpi_bytestream_to_number(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
|
||||
u_int16_t ntohs_ndpi_bytestream_to_number(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
|
||||
|
||||
u_int32_t ndpi_bytestream_to_number(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
|
||||
u_int64_t ndpi_bytestream_to_number64(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
|
||||
u_int32_t ndpi_bytestream_dec_or_hex_to_number(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
|
||||
u_int64_t ndpi_bytestream_dec_or_hex_to_number64(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
|
||||
u_int32_t ndpi_bytestream_to_ipv4(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
|
||||
u_int32_t ndpi_bytestream_to_number(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
|
||||
u_int64_t ndpi_bytestream_to_number64(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
|
||||
u_int32_t ndpi_bytestream_dec_or_hex_to_number(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
|
||||
u_int64_t ndpi_bytestream_dec_or_hex_to_number64(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
|
||||
u_int32_t ndpi_bytestream_to_ipv4(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
|
||||
|
||||
|
||||
void ndpi_int_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
u_int16_t detected_protocol, ndpi_protocol_type_t protocol_type);
|
||||
void ndpi_set_detected_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
u_int16_t upper_detected_protocol,
|
||||
u_int16_t lower_detected_protocol);
|
||||
|
||||
extern void ndpi_parse_packet_line_info(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
extern void ndpi_parse_packet_line_info_any(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
|
||||
/* function to parse a packet which has line based information into a line based structure
|
||||
* this function will also set some well known line pointers like:
|
||||
* - host, user agent, empty line,....
|
||||
*/
|
||||
extern void ndpi_parse_packet_line_info(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
extern void ndpi_parse_packet_line_info_any(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
extern u_int16_t ndpi_check_for_email_address(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow, u_int16_t counter);
|
||||
extern void ndpi_int_change_packet_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
u_int16_t detected_protocol, ndpi_protocol_type_t protocol_type);
|
||||
extern void ndpi_int_change_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
u_int16_t detected_protocol,
|
||||
ndpi_protocol_type_t protocol_type);
|
||||
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,
|
||||
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_protocol(struct ndpi_flow_struct *flow);
|
||||
extern int ndpi_packet_src_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t * ip);
|
||||
extern int ndpi_packet_dst_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t * ip);
|
||||
extern void ndpi_packet_src_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_addr_t * ip);
|
||||
extern void ndpi_packet_dst_ip_get(const struct ndpi_packet_struct *packet, 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_proto_by_id(struct ndpi_detection_module_struct *ndpi_mod, u_int id);
|
||||
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);
|
||||
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** udp_master_proto);
|
||||
extern u_int16_t ndpi_check_for_email_address(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow, u_int16_t counter);
|
||||
|
||||
extern u_int8_t ndpi_net_match(u_int32_t ip_to_check,
|
||||
u_int32_t net,
|
||||
u_int32_t num_bits);
|
||||
extern void ndpi_int_change_packet_protocol(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow,
|
||||
u_int16_t upper_detected_protocol,
|
||||
u_int16_t lower_detected_protocol);
|
||||
extern void ndpi_int_change_protocol(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow,
|
||||
u_int16_t upper_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,
|
||||
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);
|
||||
|
||||
extern u_int8_t ndpi_ips_match(u_int32_t src, u_int32_t dst,
|
||||
u_int32_t net, u_int32_t num_bits);
|
||||
extern void ndpi_int_reset_packet_protocol(struct ndpi_packet_struct *packet);
|
||||
extern void ndpi_int_reset_protocol(struct ndpi_flow_struct *flow);
|
||||
|
||||
extern int ndpi_packet_src_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t * ip);
|
||||
extern int ndpi_packet_dst_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t * ip);
|
||||
extern void ndpi_packet_src_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_addr_t * ip);
|
||||
extern void ndpi_packet_dst_ip_get(const struct ndpi_packet_struct *packet, 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_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,
|
||||
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_int16_t ndpi_get_lower_proto(ndpi_protocol p);
|
||||
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** 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
|
||||
void ndpi_debug_get_last_log_function_line(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
const char **file, const char **func, u_int32_t * line);
|
||||
#endif
|
||||
|
||||
#include "ndpi_api.h"
|
||||
/** Checks when the @p payload starts with the string literal @p str.
|
||||
* When the string is larger than the payload, check fails.
|
||||
* @return non-zero if check succeeded
|
||||
*/
|
||||
int ndpi_match_prefix(const u_int8_t *payload, size_t payload_len,
|
||||
const char *str, size_t str_len);
|
||||
|
||||
#endif /* __NDPI_MAIN_INCLUDE_FILE__ */
|
||||
/* version of ndpi_match_prefix with string literal */
|
||||
#define ndpi_match_strprefix(payload, payload_len, str) \
|
||||
ndpi_match_prefix((payload), (payload_len), (str), (sizeof(str)-1))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __NDPI_MAIN_H__ */
|
||||
|
||||
+248
-208
@@ -1,8 +1,8 @@
|
||||
|
||||
/*
|
||||
* ndpi_protocol_ids.h
|
||||
*
|
||||
* Copyright (C) 2011-15 - ntop.org
|
||||
* Copyright (C) 2009-11 - ipoque GmbH
|
||||
* 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
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __NDPI_API_INCLUDE_FILE__
|
||||
#ifndef __NDPI_API_H__
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,214 +31,254 @@
|
||||
#define __NDPI_PROTOCOLS_DEFAULT_H__
|
||||
|
||||
#define NDPI_DETECTION_SUPPORT_IPV6
|
||||
#define NDPI_PROTOCOL_HISTORY_SIZE 3
|
||||
#define NDPI_PROTOCOL_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_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_UNKNOWN 0
|
||||
#define NDPI_PROTOCOL_FTP_CONTROL 1 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_MAIL_POP 2
|
||||
#define NDPI_PROTOCOL_MAIL_SMTP 3
|
||||
#define NDPI_PROTOCOL_MAIL_IMAP 4
|
||||
#define NDPI_PROTOCOL_DNS 5
|
||||
#define NDPI_PROTOCOL_IPP 6
|
||||
#define NDPI_PROTOCOL_HTTP 7
|
||||
#define NDPI_PROTOCOL_MDNS 8
|
||||
#define NDPI_PROTOCOL_NTP 9
|
||||
#define NDPI_PROTOCOL_NETBIOS 10
|
||||
#define NDPI_PROTOCOL_NFS 11
|
||||
#define NDPI_PROTOCOL_SSDP 12
|
||||
#define NDPI_PROTOCOL_BGP 13
|
||||
#define NDPI_PROTOCOL_SNMP 14
|
||||
#define NDPI_PROTOCOL_XDMCP 15
|
||||
#define NDPI_PROTOCOL_SMB 16
|
||||
#define NDPI_PROTOCOL_SYSLOG 17
|
||||
#define NDPI_PROTOCOL_DHCP 18
|
||||
#define NDPI_PROTOCOL_POSTGRES 19
|
||||
#define NDPI_PROTOCOL_MYSQL 20
|
||||
#define NDPI_PROTOCOL_HOTMAIL 21
|
||||
#define NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK 22
|
||||
#define NDPI_PROTOCOL_MAIL_POPS 23
|
||||
#define NDPI_PROTOCOL_APPLEJUICE 24
|
||||
#define NDPI_PROTOCOL_DIRECTCONNECT 25
|
||||
#define NDPI_PROTOCOL_SOCRATES 26
|
||||
#define NDPI_PROTOCOL_COAP 27
|
||||
#define NDPI_PROTOCOL_VMWARE 28
|
||||
#define NDPI_PROTOCOL_MAIL_SMTPS 29
|
||||
#define NDPI_PROTOCOL_FILETOPIA 30
|
||||
#define NDPI_PROTOCOL_UBNTAC2 31 /* Ubiquity UBNT AirControl 2 - Thomas Fjellstrom <thomas+ndpi@fjellstrom.ca> */
|
||||
#define NDPI_PROTOCOL_KONTIKI 32
|
||||
#define NDPI_PROTOCOL_OPENFT 33
|
||||
#define NDPI_PROTOCOL_FASTTRACK 34
|
||||
#define NDPI_PROTOCOL_GNUTELLA 35
|
||||
#define NDPI_PROTOCOL_EDONKEY 36 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_BITTORRENT 37
|
||||
#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_QQ 48
|
||||
#define NDPI_PROTOCOL_MOVE 49
|
||||
#define NDPI_PROTOCOL_RTSP 50
|
||||
#define NDPI_PROTOCOL_MAIL_IMAPS 51
|
||||
#define NDPI_PROTOCOL_ICECAST 52
|
||||
#define NDPI_PROTOCOL_PPLIVE 53 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_PPSTREAM 54
|
||||
#define NDPI_PROTOCOL_ZATTOO 55
|
||||
#define NDPI_PROTOCOL_SHOUTCAST 56
|
||||
#define NDPI_PROTOCOL_SOPCAST 57
|
||||
#define NDPI_PROTOCOL_TVANTS 58
|
||||
#define NDPI_PROTOCOL_TVUPLAYER 59
|
||||
#define NDPI_PROTOCOL_HTTP_DOWNLOAD 60
|
||||
#define NDPI_PROTOCOL_QQLIVE 61
|
||||
#define NDPI_PROTOCOL_THUNDER 62
|
||||
#define NDPI_PROTOCOL_SOULSEEK 63
|
||||
#define NDPI_PROTOCOL_SSL_NO_CERT 64
|
||||
#define NDPI_PROTOCOL_IRC 65
|
||||
#define NDPI_PROTOCOL_AYIYA 66
|
||||
#define NDPI_PROTOCOL_UNENCRYPTED_JABBER 67
|
||||
#define NDPI_PROTOCOL_MSN 68
|
||||
#define NDPI_PROTOCOL_OSCAR 69
|
||||
#define NDPI_PROTOCOL_YAHOO 70
|
||||
#define NDPI_PROTOCOL_BATTLEFIELD 71
|
||||
#define NDPI_PROTOCOL_QUAKE 72
|
||||
#define NDPI_PROTOCOL_IP_VRRP 73
|
||||
#define NDPI_PROTOCOL_STEAM 74 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_HALFLIFE2 75
|
||||
#define NDPI_PROTOCOL_WORLDOFWARCRAFT 76
|
||||
#define NDPI_PROTOCOL_TELNET 77
|
||||
#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_RDP 88
|
||||
#define NDPI_PROTOCOL_VNC 89
|
||||
#define NDPI_PROTOCOL_PCANYWHERE 90
|
||||
#define NDPI_PROTOCOL_SSL 91
|
||||
#define NDPI_PROTOCOL_SSH 92
|
||||
#define NDPI_PROTOCOL_USENET 93
|
||||
#define NDPI_PROTOCOL_MGCP 94
|
||||
#define NDPI_PROTOCOL_IAX 95
|
||||
#define NDPI_PROTOCOL_TFTP 96
|
||||
#define NDPI_PROTOCOL_AFP 97
|
||||
#define NDPI_PROTOCOL_STEALTHNET 98
|
||||
#define NDPI_PROTOCOL_AIMINI 99
|
||||
#define NDPI_PROTOCOL_SIP 100
|
||||
#define NDPI_PROTOCOL_TRUPHONE 101
|
||||
#define NDPI_PROTOCOL_IP_ICMPV6 102
|
||||
#define NDPI_PROTOCOL_DHCPV6 103
|
||||
#define NDPI_PROTOCOL_ARMAGETRON 104
|
||||
#define NDPI_PROTOCOL_CROSSFIRE 105
|
||||
#define NDPI_PROTOCOL_DOFUS 106
|
||||
#define NDPI_PROTOCOL_FIESTA 107
|
||||
#define NDPI_PROTOCOL_FLORENSIA 108
|
||||
#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_LDAP 112
|
||||
#define NDPI_PROTOCOL_MAPLESTORY 113
|
||||
#define NDPI_PROTOCOL_MSSQL_TDS 114
|
||||
#define NDPI_PROTOCOL_PPTP 115
|
||||
#define NDPI_PROTOCOL_WARCRAFT3 116
|
||||
#define NDPI_PROTOCOL_WORLD_OF_KUNG_FU 117
|
||||
#define NDPI_PROTOCOL_SLACK 118
|
||||
#define NDPI_PROTOCOL_FACEBOOK 119
|
||||
#define NDPI_PROTOCOL_TWITTER 120
|
||||
#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_GOOGLE 126
|
||||
#define NDPI_PROTOCOL_DCERPC 127
|
||||
#define NDPI_PROTOCOL_NETFLOW 128
|
||||
#define NDPI_PROTOCOL_SFLOW 129
|
||||
#define NDPI_PROTOCOL_HTTP_CONNECT 130
|
||||
#define NDPI_PROTOCOL_HTTP_PROXY 131
|
||||
#define NDPI_PROTOCOL_CITRIX 132
|
||||
#define NDPI_PROTOCOL_NETFLIX 133
|
||||
#define NDPI_PROTOCOL_LASTFM 134
|
||||
#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
|
||||
#define NDPI_PROTOCOL_CITRIX_ONLINE 139
|
||||
#define NDPI_PROTOCOL_APPLE 140
|
||||
#define NDPI_PROTOCOL_WEBEX 141
|
||||
#define NDPI_PROTOCOL_WHATSAPP 142
|
||||
#define NDPI_PROTOCOL_APPLE_ICLOUD 143
|
||||
#define NDPI_PROTOCOL_VIBER 144
|
||||
#define NDPI_PROTOCOL_APPLE_ITUNES 145
|
||||
#define NDPI_PROTOCOL_RADIUS 146
|
||||
#define NDPI_PROTOCOL_WINDOWS_UPDATE 147
|
||||
#define NDPI_PROTOCOL_TEAMVIEWER 148 /* xplico.org */
|
||||
#define NDPI_PROTOCOL_TUENTI 149
|
||||
#define NDPI_PROTOCOL_LOTUS_NOTES 150
|
||||
#define NDPI_PROTOCOL_SAP 151
|
||||
#define NDPI_PROTOCOL_GTP 152
|
||||
#define NDPI_PROTOCOL_UPNP 153
|
||||
#define NDPI_PROTOCOL_LLMNR 154
|
||||
#define NDPI_PROTOCOL_REMOTE_SCAN 155
|
||||
#define NDPI_PROTOCOL_SPOTIFY 156
|
||||
#define NDPI_CONTENT_WEBM 157
|
||||
#define NDPI_PROTOCOL_H323 158 /* 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_CISCOVPN 161 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_TEAMSPEAK 162 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_TOR 163 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_SKINNY 164 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_RTCP 165 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_RSYNC 166 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_ORACLE 167 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_CORBA 168 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_UBUNTUONE 169 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_WHOIS_DAS 170
|
||||
#define NDPI_PROTOCOL_COLLECTD 171
|
||||
#define NDPI_PROTOCOL_SOCKS 172 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
/* The Lync protocol is now skype for business and this the old id 173 can now be recycled */
|
||||
#define NDPI_PROTOCOL_NINTENDO 173
|
||||
#define NDPI_PROTOCOL_RTMP 174 /* 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_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_REDIS 182
|
||||
#define NDPI_PROTOCOL_PANDO 183 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_VHUA 184
|
||||
#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_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_TEREDO 214
|
||||
#define NDPI_PROTOCOL_HOTSPOT_SHIELD 215
|
||||
#define NDPI_PROTOCOL_HEP 216 /* sipcapture.org QXIP BV */
|
||||
#define NDPI_PROTOCOL_GOOGLE_DRIVE 217
|
||||
#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_PROTOCOL_MQTT 222
|
||||
#define NDPI_PROTOCOL_RX 223
|
||||
#define NDPI_PROTOCOL_APPLESTORE 224
|
||||
#define NDPI_PROTOCOL_OPENDNS 225
|
||||
#define NDPI_PROTOCOL_GIT 226
|
||||
#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_HTTP 7
|
||||
#define NDPI_PROTOCOL_HTTP_APPLICATION_VEOHTV 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_SOCKS5 172 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_SOCKS4 173 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
/* UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE */
|
||||
#define NDPI_LAST_IMPLEMENTED_PROTOCOL NDPI_PROTOCOL_LISP
|
||||
|
||||
#define NDPI_PROTOCOL_FTP_CONTROL 1 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_MAIL_POP 2
|
||||
#define NDPI_PROTOCOL_MAIL_SMTP 3
|
||||
#define NDPI_PROTOCOL_MAIL_IMAP 4
|
||||
#define NDPI_PROTOCOL_DNS 5
|
||||
#define NDPI_PROTOCOL_IPP 6
|
||||
#define NDPI_PROTOCOL_MDNS 8
|
||||
#define NDPI_PROTOCOL_NTP 9
|
||||
#define NDPI_PROTOCOL_NETBIOS 10
|
||||
#define NDPI_PROTOCOL_NFS 11
|
||||
#define NDPI_PROTOCOL_SSDP 12
|
||||
#define NDPI_PROTOCOL_BGP 13
|
||||
#define NDPI_PROTOCOL_SNMP 14
|
||||
#define NDPI_PROTOCOL_XDMCP 15
|
||||
#define NDPI_PROTOCOL_SMB 16
|
||||
#define NDPI_PROTOCOL_SYSLOG 17
|
||||
#define NDPI_PROTOCOL_DHCP 18
|
||||
#define NDPI_PROTOCOL_POSTGRES 19
|
||||
#define NDPI_PROTOCOL_MYSQL 20
|
||||
#define NDPI_PROTOCOL_TDS 21
|
||||
#define NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK 22
|
||||
#define NDPI_PROTOCOL_MAIL_POPS 23
|
||||
#define NDPI_PROTOCOL_APPLEJUICE 24
|
||||
#define NDPI_PROTOCOL_DIRECTCONNECT 25
|
||||
#define NDPI_PROTOCOL_SOCRATES 26
|
||||
#define NDPI_PROTOCOL_WINMX 27
|
||||
#define NDPI_PROTOCOL_VMWARE 28
|
||||
#define NDPI_PROTOCOL_MAIL_SMTPS 29
|
||||
#define NDPI_PROTOCOL_FILETOPIA 30
|
||||
#define NDPI_PROTOCOL_IMESH 31
|
||||
#define NDPI_PROTOCOL_KONTIKI 32
|
||||
#define NDPI_PROTOCOL_OPENFT 33
|
||||
#define NDPI_PROTOCOL_FASTTRACK 34
|
||||
#define NDPI_PROTOCOL_GNUTELLA 35
|
||||
#define NDPI_PROTOCOL_EDONKEY 36 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_BITTORRENT 37
|
||||
#define NDPI_PROTOCOL_EPP 38
|
||||
#define NDPI_PROTOCOL_XBOX 47
|
||||
#define NDPI_PROTOCOL_QQ 48
|
||||
#define NDPI_PROTOCOL_MOVE 49
|
||||
#define NDPI_PROTOCOL_RTSP 50
|
||||
#define NDPI_PROTOCOL_MAIL_IMAPS 51
|
||||
#define NDPI_PROTOCOL_ICECAST 52
|
||||
#define NDPI_PROTOCOL_PPLIVE 53 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_PPSTREAM 54
|
||||
#define NDPI_PROTOCOL_ZATTOO 55
|
||||
#define NDPI_PROTOCOL_SHOUTCAST 56
|
||||
#define NDPI_PROTOCOL_SOPCAST 57
|
||||
#define NDPI_PROTOCOL_TVANTS 58
|
||||
#define NDPI_PROTOCOL_TVUPLAYER 59
|
||||
#define NDPI_PROTOCOL_QQLIVE 61
|
||||
#define NDPI_PROTOCOL_THUNDER 62
|
||||
#define NDPI_PROTOCOL_SOULSEEK 63
|
||||
#define NDPI_PROTOCOL_IRC 65
|
||||
#define NDPI_PROTOCOL_AYIYA 66
|
||||
#define NDPI_PROTOCOL_UNENCRYPED_JABBER 67
|
||||
#define NDPI_PROTOCOL_MSN 68
|
||||
#define NDPI_PROTOCOL_OSCAR 69
|
||||
#define NDPI_PROTOCOL_YAHOO 70
|
||||
#define NDPI_PROTOCOL_BATTLEFIELD 71
|
||||
#define NDPI_PROTOCOL_QUAKE 72
|
||||
#define NDPI_PROTOCOL_STEAM 74 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_HALFLIFE2 75
|
||||
#define NDPI_PROTOCOL_WORLDOFWARCRAFT 76
|
||||
#define NDPI_PROTOCOL_TELNET 77
|
||||
#define NDPI_PROTOCOL_STUN 78
|
||||
#define NDPI_PROTOCOL_RTP 87
|
||||
#define NDPI_PROTOCOL_RDP 88
|
||||
#define NDPI_PROTOCOL_VNC 89
|
||||
#define NDPI_PROTOCOL_PCANYWHERE 90
|
||||
#define NDPI_PROTOCOL_SSH 92
|
||||
#define NDPI_PROTOCOL_USENET 93
|
||||
#define NDPI_PROTOCOL_MGCP 94
|
||||
#define NDPI_PROTOCOL_IAX 95
|
||||
#define NDPI_PROTOCOL_TFTP 96
|
||||
#define NDPI_PROTOCOL_AFP 97
|
||||
#define NDPI_PROTOCOL_STEALTHNET 98
|
||||
#define NDPI_PROTOCOL_AIMINI 99
|
||||
#define NDPI_PROTOCOL_SIP 100
|
||||
#define NDPI_PROTOCOL_TRUPHONE 101
|
||||
#define NDPI_PROTOCOL_DHCPV6 103
|
||||
#define NDPI_PROTOCOL_ARMAGETRON 104
|
||||
#define NDPI_PROTOCOL_CROSSFIRE 105
|
||||
#define NDPI_PROTOCOL_DOFUS 106
|
||||
#define NDPI_PROTOCOL_FIESTA 107
|
||||
#define NDPI_PROTOCOL_FLORENSIA 108
|
||||
#define NDPI_PROTOCOL_GUILDWARS 109
|
||||
#define NDPI_PROTOCOL_KERBEROS 111
|
||||
#define NDPI_PROTOCOL_LDAP 112
|
||||
#define NDPI_PROTOCOL_MAPLESTORY 113
|
||||
#define NDPI_PROTOCOL_MSSQL 114
|
||||
#define NDPI_PROTOCOL_PPTP 115
|
||||
#define NDPI_PROTOCOL_WARCRAFT3 116
|
||||
#define NDPI_PROTOCOL_WORLD_OF_KUNG_FU 117
|
||||
#define NDPI_PROTOCOL_MEEBO 118
|
||||
#define NDPI_PROTOCOL_DROPBOX 121
|
||||
#define NDPI_PROTOCOL_SKYPE 125
|
||||
#define NDPI_PROTOCOL_DCERPC 127
|
||||
#define NDPI_PROTOCOL_NETFLOW 128
|
||||
#define NDPI_PROTOCOL_SFLOW 129
|
||||
#define NDPI_PROTOCOL_CITRIX 132
|
||||
#define NDPI_PROTOCOL_SKYFILE_PREPAID 136
|
||||
#define NDPI_PROTOCOL_SKYFILE_RUDICS 137
|
||||
#define NDPI_PROTOCOL_SKYFILE_POSTPAID 138
|
||||
#define NDPI_PROTOCOL_CITRIX_ONLINE 139
|
||||
#define NDPI_PROTOCOL_WEBEX 141
|
||||
#define NDPI_PROTOCOL_VIBER 144
|
||||
#define NDPI_PROTOCOL_RADIUS 146
|
||||
#define NDPI_PROTOCOL_WINDOWS_UPDATE 147 /* Thierry Laurion */
|
||||
#define NDPI_PROTOCOL_TEAMVIEWER 148 /* xplico.org */
|
||||
#define NDPI_PROTOCOL_LOTUS_NOTES 150
|
||||
#define NDPI_PROTOCOL_SAP 151
|
||||
#define NDPI_PROTOCOL_GTP 152
|
||||
#define NDPI_PROTOCOL_UPNP 153
|
||||
#define NDPI_PROTOCOL_LLMNR 154
|
||||
#define NDPI_PROTOCOL_REMOTE_SCAN 155
|
||||
#define NDPI_PROTOCOL_SPOTIFY 156
|
||||
#define NDPI_PROTOCOL_H323 158 /* 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_CISCOVPN 161 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_TEAMSPEAK 162 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_TOR 163 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_SKINNY 164 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_RTCP 165 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_RSYNC 166 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_ORACLE 167 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_CORBA 168 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_UBUNTUONE 169 /* Remy Mudingay <mudingay@ill.fr> */
|
||||
#define NDPI_PROTOCOL_WHOIS_DAS 170
|
||||
#define NDPI_PROTOCOL_COLLECTD 171
|
||||
#define NDPI_PROTOCOL_RTMP 174 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_FTP_DATA 175 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_ZMQ 177
|
||||
#define NDPI_PROTOCOL_MEGACO 181 /* Gianluca Costa <g.costa@xplico.org> */
|
||||
#define NDPI_PROTOCOL_REDIS 182
|
||||
#define NDPI_PROTOCOL_PANDO 183 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_PROTOCOL_VHUA 184
|
||||
#define NDPI_PROTOCOL_TELEGRAM 185 /* Gianluca Costa <g.costa@xplico.org> */
|
||||
#define NDPI_PROTOCOL_QUIC 188 /* Andrea Buscarinu <andrea.buscarinu@gmail.com> - Michele Campus <michelecampus5@gmail.com> */
|
||||
|
||||
|
||||
#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_GROOVESHARK 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 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_SERVICE_YAHOO NDPI_PROTOCOL_YAHOO /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||
#define NDPI_SERVICE_PANDORA 187
|
||||
|
||||
/* UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE (NDPI_PROTOCOL_QUIC) */
|
||||
#define NDPI_LAST_IMPLEMENTED_PROTOCOL 188
|
||||
|
||||
#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_SUPPORTED_PROTOCOLS (NDPI_LAST_IMPLEMENTED_PROTOCOL + 1)
|
||||
#define NDPI_MAX_NUM_CUSTOM_PROTOCOLS (NDPI_NUM_BITS-NDPI_LAST_IMPLEMENTED_PROTOCOL)
|
||||
#endif
|
||||
|
||||
+188
-16
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
* ndpi_protocols.h
|
||||
*
|
||||
* Copyright (C) 2011-15 - ntop.org
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-16 - 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
|
||||
@@ -23,14 +22,29 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __NDPI_PROTOCOLS_INCLUDE_FILE__
|
||||
#define __NDPI_PROTOCOLS_INCLUDE_FILE__
|
||||
#ifndef __NDPI_PROTOCOLS_H__
|
||||
#define __NDPI_PROTOCOLS_H__
|
||||
|
||||
#include "ndpi_main.h"
|
||||
|
||||
|
||||
ndpi_port_range* ndpi_build_default_ports_range(ndpi_port_range *ports,
|
||||
u_int16_t portA_low, u_int16_t portA_high,
|
||||
u_int16_t portB_low, u_int16_t portB_high,
|
||||
u_int16_t portC_low, u_int16_t portC_high,
|
||||
u_int16_t portD_low, u_int16_t portD_high,
|
||||
u_int16_t portE_low, u_int16_t portE_high);
|
||||
|
||||
ndpi_port_range* ndpi_build_default_ports(ndpi_port_range *ports,
|
||||
u_int16_t portA,
|
||||
u_int16_t portB,
|
||||
u_int16_t portC,
|
||||
u_int16_t portD,
|
||||
u_int16_t portE);
|
||||
|
||||
/* TCP/UDP protocols */
|
||||
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_int32_t saddr, u_int32_t daddr,
|
||||
u_int16_t sport, u_int16_t dport);
|
||||
@@ -39,14 +53,10 @@ void ndpi_search_tcp_or_udp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|
||||
/* Applications and other protocols. */
|
||||
void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_bittorrent_init(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t size,u_int32_t timeout);
|
||||
void ndpi_bittorrent_done(struct ndpi_detection_module_struct *ndpi_struct);
|
||||
int ndpi_bittorrent_gc(struct hash_ip4p_table *ht,int key,time_t now);
|
||||
|
||||
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_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_winmx_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_directconnect(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_applejuice_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_i23v5(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
@@ -58,6 +68,7 @@ void ndpi_search_oscar(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_irc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_sip(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_hep(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_direct_download_link_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mail_pop_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mail_imap_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
@@ -71,7 +82,6 @@ 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_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_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_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);
|
||||
@@ -117,7 +127,6 @@ 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_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_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_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);
|
||||
@@ -126,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_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_mssql(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_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_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_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_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);
|
||||
@@ -142,7 +151,6 @@ void ndpi_search_crossfire_tcp_udp(struct ndpi_detection_module_struct *ndpi_str
|
||||
void ndpi_search_guildwars_tcp(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);
|
||||
void ndpi_search_dropbox(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_skype(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_citrix(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_dcerpc(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_netflow(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
@@ -174,9 +182,173 @@ 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_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_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_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_eaq(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_kakaotalk_voice(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_mpegts(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||
void ndpi_search_starcraft(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_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_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_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 --- */
|
||||
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_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_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_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_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_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_corba_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_crossfire_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_dcerpc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_dhcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_dhcpv6_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_directconnect_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_dns_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);
|
||||
void init_directdownloadlink_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_dropbox_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_eaq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_edonkey_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_fasttrack_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_fiesta_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_filetopia_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_florensia_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_ftp_control_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_ftp_data_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_gnutella_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_gtp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_guildwars_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_h323_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_halflife2_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_http_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_icecast_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_jabber_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_kakaotalk_voice_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_kerberos_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_kontiki_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_ldap_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_lotus_notes_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_mail_imap_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_mail_pop_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_mdns_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_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_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_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_netflow_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_nfs_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_noe_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_non_tcp_udp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_ntp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_openft_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_openvpn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_oracle_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_oscar_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_pando_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_pcanywhere_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_postgres_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_pplive_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_ppstream_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_pptp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_qq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_quake_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_quic_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_radius_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_rdp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_redis_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_rsync_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_rtcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_rtmp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_rtp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_rtsp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_sflow_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_shoutcast_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_sip_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_hep_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_skinny_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_skype_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_smb_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_snmp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_socrates_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_sopcast_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_soulseek_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_socks_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_spotify_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_ssh_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_ssl_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_starcraft_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_stealthnet_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_steam_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_ssdp_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_telegram_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_telnet_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_tftp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_thunder_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_tvuplayer_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_vhua_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_viber_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_vmware_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_vnc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_warcraft3_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_whois_das_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_world_of_warcraft_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_world_of_kung_fu_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_xbox_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_xdmcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_yahoo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_zattoo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_zmq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||
void init_stracraft_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_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_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_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);
|
||||
|
||||
#endif /* __NDPI_PROTOCOLS_INCLUDE_FILE__ */
|
||||
#endif /* __NDPI_PROTOCOLS_H__ */
|
||||
|
||||
+508
-205
File diff suppressed because it is too large
Load Diff
+1
-11
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
* ndpi_unix.h
|
||||
*
|
||||
* Copyright (C) 2011-15 - ntop.org
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-16 - 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
|
||||
@@ -25,8 +24,6 @@
|
||||
#ifndef __NDPI_UNIX_INCLUDE_FILE__
|
||||
#define __NDPI_UNIX_INCLUDE_FILE__
|
||||
|
||||
#include "linux_compat.h"
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#include <netinet/in.h>
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
@@ -38,16 +35,9 @@
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef __KERNEL__
|
||||
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/udp.h>
|
||||
#else
|
||||
#include <linux/ip.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/udp.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __NDPI_UNIX_INCLUDE_FILE__ */
|
||||
|
||||
+30
-23
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
* ndpi_win32.h
|
||||
*
|
||||
* Copyright (C) 2011-15 - ntop.org
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-16 - 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
|
||||
@@ -22,36 +21,44 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __NDPI_WIN32_INCLUDE_FILE__
|
||||
#define __NDPI_WIN32_INCLUDE_FILE__
|
||||
#ifndef __NDPI_WIN32_H__
|
||||
#define __NDPI_WIN32_H__
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Winsock2.h> /* winsock.h is included automatically */
|
||||
// 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 <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <process.h>
|
||||
#include <io.h>
|
||||
#include <getopt.h> /* getopt from: http://www.pwilson.net/sample.html. */
|
||||
#include <process.h> /* for getpid() and the exec..() family */
|
||||
#include <getopt.h> /* getopt from: http://www.pwilson.net/sample.html. */
|
||||
#include <process.h> /* for getpid() and the exec..() family */
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
#define snprintf _snprintf
|
||||
|
||||
extern char* strsep(char **stringp, const char *delim);
|
||||
#define _WS2TCPIP_H_ /* Avoid compilation problems */
|
||||
|
||||
#define IPVERSION 4 /* on *nix it is defined in netinet/ip.h */
|
||||
|
||||
extern char* strsep(char **sp, char *sep);
|
||||
|
||||
#define __attribute__(x)
|
||||
#include <stdint.h>
|
||||
#ifndef __GNUC__
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned long u_long;
|
||||
#endif
|
||||
typedef u_char u_int8_t;
|
||||
typedef u_short u_int16_t;
|
||||
typedef unsigned int u_int32_t;
|
||||
typedef unsigned __int64 u_int64_t;
|
||||
|
||||
typedef u_char u_int8_t;
|
||||
typedef u_short u_int16_t;
|
||||
typedef uint u_int32_t;
|
||||
typedef uint u_int;
|
||||
typedef unsigned __int64 u_int64_t;
|
||||
|
||||
#define pthread_t HANDLE
|
||||
#define pthread_mutex_t HANDLE
|
||||
@@ -62,12 +69,12 @@ typedef unsigned __int64 u_int64_t;
|
||||
#define pthread_rwlock_unlock pthread_mutex_unlock
|
||||
#define pthread_rwlock_destroy pthread_mutex_destroy
|
||||
|
||||
#define gmtime_r(a, b) gmtime(a) /* Already thread safe on windows */
|
||||
#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 */);
|
||||
|
||||
#define sleep(a /* sec */) waitForNextEvent(1000*a /* ms */)
|
||||
|
||||
#endif /* Win32 */
|
||||
|
||||
#endif /* __NDPI_WIN32_INCLUDE_FILE__ */
|
||||
#endif /* __NDPI_WIN32_H__ */
|
||||
|
||||
+34
-15
@@ -1,20 +1,18 @@
|
||||
lib_LTLIBRARIES = libndpi.la
|
||||
|
||||
CFLAGS += -fPIC -DPIC
|
||||
CFLAGS += -fPIC -DPIC # --coverage
|
||||
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_includedir = $(includedir)/libndpi-@VERSION@/libndpi
|
||||
|
||||
libndpi_la_include_HEADERS = ../include/ndpi_api.h \
|
||||
../include/linux_compat.h \
|
||||
../include/ndpi_define.h \
|
||||
../include/ndpi_main.h \
|
||||
../include/ndpi_includes.h \
|
||||
../include/ndpi_protocol_ids.h \
|
||||
../include/ndpi_protocols.h \
|
||||
../include/ndpi_typedefs.h \
|
||||
../include/ndpi_unix.h \
|
||||
../include/ndpi_win32.h
|
||||
../include/ndpi_typedefs.h
|
||||
|
||||
libndpi_la_SOURCES = ndpi_content_match.c.inc \
|
||||
ndpi_main.c \
|
||||
@@ -23,14 +21,19 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
|
||||
protocols/applejuice.c \
|
||||
protocols/armagetron.c \
|
||||
protocols/ayiya.c \
|
||||
protocols/amqp.c \
|
||||
protocols/battlefield.c \
|
||||
protocols/bgp.c \
|
||||
protocols/bittorrent.c \
|
||||
protocols/bjnp.c \
|
||||
protocols/checkmk.c \
|
||||
protocols/ciscovpn.c \
|
||||
protocols/citrix.c \
|
||||
protocols/coap.c \
|
||||
protocols/collectd.c \
|
||||
protocols/corba.c \
|
||||
protocols/crossfire.c \
|
||||
protocols/csgo.c \
|
||||
protocols/dcerpc.c \
|
||||
protocols/dhcp.c \
|
||||
protocols/dhcpv6.c \
|
||||
@@ -38,45 +41,54 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
|
||||
protocols/directdownloadlink.c \
|
||||
protocols/dns.c \
|
||||
protocols/dofus.c \
|
||||
protocols/drda.c \
|
||||
protocols/dropbox.c \
|
||||
protocols/eaq.c \
|
||||
protocols/edonkey.c \
|
||||
protocols/fasttrack.c \
|
||||
protocols/fiesta.c \
|
||||
protocols/fix.c \
|
||||
protocols/filetopia.c \
|
||||
protocols/florensia.c \
|
||||
protocols/ftp_control.c \
|
||||
protocols/ftp_data.c \
|
||||
protocols/git.c \
|
||||
protocols/gnutella.c \
|
||||
protocols/gtp.c \
|
||||
protocols/guildwars.c \
|
||||
protocols/hangout.c \
|
||||
protocols/h323.c \
|
||||
protocols/halflife2_and_mods.c \
|
||||
protocols/hep.c \
|
||||
protocols/http_activesync.c \
|
||||
protocols/http.c \
|
||||
protocols/iax.c \
|
||||
protocols/icecast.c \
|
||||
protocols/imesh.c \
|
||||
protocols/ipp.c \
|
||||
protocols/irc.c \
|
||||
protocols/jabber.c \
|
||||
protocols/kakaotalk_voice.c \
|
||||
protocols/kerberos.c \
|
||||
protocols/kontiki.c \
|
||||
protocols/ldap.c \
|
||||
protocols/lotus_notes.c \
|
||||
protocols/lisp.c \
|
||||
protocols/mail_imap.c \
|
||||
protocols/mail_pop.c \
|
||||
protocols/mail_smtp.c \
|
||||
protocols/maplestory.c \
|
||||
protocols/mdns.c \
|
||||
protocols/meebo.c \
|
||||
protocols/megaco.c \
|
||||
protocols/mgcp.c \
|
||||
protocols/mms.c \
|
||||
protocols/mpegts.c \
|
||||
protocols/mqtt.c \
|
||||
protocols/msn.c \
|
||||
protocols/mssql.c \
|
||||
protocols/mssql_tds.c \
|
||||
protocols/mysql.c \
|
||||
protocols/netbios.c \
|
||||
protocols/netflow.c \
|
||||
protocols/nintendo.c \
|
||||
protocols/nfs.c \
|
||||
protocols/noe.c \
|
||||
protocols/non_tcp_udp.c \
|
||||
@@ -102,6 +114,7 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
|
||||
protocols/rtmp.c \
|
||||
protocols/rtp.c \
|
||||
protocols/rtsp.c \
|
||||
protocols/rx.c \
|
||||
protocols/sflow.c \
|
||||
protocols/shoutcast.c \
|
||||
protocols/sip.c \
|
||||
@@ -109,8 +122,7 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
|
||||
protocols/skype.c \
|
||||
protocols/smb.c \
|
||||
protocols/snmp.c \
|
||||
protocols/socks4.c \
|
||||
protocols/socks5.c \
|
||||
protocols/socks45.c \
|
||||
protocols/socrates.c \
|
||||
protocols/sopcast.c \
|
||||
protocols/soulseek.c \
|
||||
@@ -118,12 +130,12 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
|
||||
protocols/ssdp.c \
|
||||
protocols/ssh.c \
|
||||
protocols/ssl.c \
|
||||
protocols/starcraft.c \
|
||||
protocols/stealthnet.c \
|
||||
protocols/steam.c \
|
||||
protocols/stun.c \
|
||||
protocols/syslog.c \
|
||||
protocols/tcp_udp.c \
|
||||
protocols/tds.c \
|
||||
protocols/teamspeak.c \
|
||||
protocols/teamviewer.c \
|
||||
protocols/telegram.c \
|
||||
@@ -131,18 +143,17 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
|
||||
protocols/tftp.c \
|
||||
protocols/thunder.c \
|
||||
protocols/tor.c \
|
||||
protocols/teredo.c \
|
||||
protocols/tvants.c \
|
||||
protocols/tvuplayer.c \
|
||||
protocols/twitter.c \
|
||||
protocols/ubntac2.c \
|
||||
protocols/usenet.c \
|
||||
protocols/veohtv.c \
|
||||
protocols/viber.c \
|
||||
protocols/vhua.c \
|
||||
protocols/vmware.c \
|
||||
protocols/vnc.c \
|
||||
protocols/warcraft3.c \
|
||||
protocols/whoisdas.c \
|
||||
protocols/winmx.c \
|
||||
protocols/world_of_kung_fu.c \
|
||||
protocols/world_of_warcraft.c \
|
||||
protocols/xbox.c \
|
||||
@@ -150,10 +161,18 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
|
||||
protocols/yahoo.c \
|
||||
protocols/zattoo.c \
|
||||
protocols/zeromq.c \
|
||||
protocols/smpp.c \
|
||||
protocols/tinc.c \
|
||||
protocols/someip.c \
|
||||
third_party/include/actypes.h \
|
||||
third_party/include/ahocorasick.h \
|
||||
third_party/include/ndpi_patricia.h \
|
||||
third_party/include/node.h \
|
||||
third_party/include/sort.h \
|
||||
third_party/include/libcache.h \
|
||||
third_party/src/ahocorasick.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
|
||||
|
||||
+8362
-7324
File diff suppressed because it is too large
Load Diff
+2040
-2739
File diff suppressed because it is too large
Load Diff
+55
-31
@@ -2,7 +2,7 @@
|
||||
* afp.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-15 - ntop.org
|
||||
* Copyright (C) 2011-16 - 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
|
||||
@@ -23,53 +23,77 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ndpi_protocols.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_AFP
|
||||
|
||||
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)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_AFP, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AFP, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
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_id_struct *src = flow->src;
|
||||
// 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)) {
|
||||
if (packet->payload_packet_len >= sizeof(struct afpHeader)) {
|
||||
struct afpHeader *h = (struct afpHeader*)packet->payload;
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_AFP, ndpi_struct, NDPI_LOG_DEBUG, "AFP: DSI OpenSession detected.\n");
|
||||
ndpi_int_afp_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)) {
|
||||
/*
|
||||
* 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 GetStatus 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;
|
||||
}
|
||||
|
||||
if((h->flags <= 1)
|
||||
&& ((h->command >= 1) && (h->command <= 8))
|
||||
&& (h->reserved == 0)
|
||||
&& (packet->payload_packet_len >= (sizeof(struct afpHeader)+ntohl(h->length)))) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_AFP, ndpi_struct, NDPI_LOG_DEBUG, "AFP: DSI 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);
|
||||
}
|
||||
|
||||
|
||||
void init_afp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("AFP", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_AFP,
|
||||
ndpi_search_afp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+26
-12
@@ -28,10 +28,10 @@
|
||||
#ifdef NDPI_PROTOCOL_AIMINI
|
||||
|
||||
|
||||
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)
|
||||
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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_AIMINI, protocol_type);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AIMINI, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
|| (packet->payload_packet_len > 100 && ntohs(get_u_int16_t(packet->payload, 0)) == 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");
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca))) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"found aimini (136, 0x01c9), (136, 0x01c9)," "(136, 0x01c9),(136, 0x01c9 || 32, 0x01ca).\n");
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
&& (packet->payload_packet_len == 88 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"found aimini (88, 0x0101), (88, 0x0101)," "(88, 0x0101),(88, 0x0101).\n");
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
|| (packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca))) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"found aimini (104, 0x0102), (104, 0x0102), " "(104, 0x0102), (104, 0x0102).\n");
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
|| (packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca))) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"found aimini (32,0x01ca), (32,0x01ca), (32,0x01ca), ((136, 0x0166)||(32,0x01ca)).\n");
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
&& (packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"found aimini (16, 0x010c), (16, 0x010c), (16, 0x010c), (16, 0x010c).\n");
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
} else if (packet->tcp != NULL) {
|
||||
@@ -243,7 +243,7 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
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)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "AIMINI HTTP traffic detected.\n");
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -257,7 +257,7 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
if (is_special_aimini_host(packet->host_line) == 1) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"AIMINI HTTP traffic detected.\n");
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -268,7 +268,7 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
if (is_special_aimini_host(packet->host_line) == 1) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"AIMINI HTTP traffic detected.\n");
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_int_aimini_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -280,4 +280,18 @@ void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_AIMINI);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void init_aimini_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Aimini", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_AIMINI,
|
||||
ndpi_search_aimini,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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_protocols.h"
|
||||
#ifdef NDPI_PROTOCOL_AMQP
|
||||
|
||||
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(NDPI_PROTOCOL_AMQP, ndpi_struct, NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_AMQP, ndpi_struct, NDPI_LOG_DEBUG, "found amqp over tcp. \n");
|
||||
ndpi_int_amqp_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
@@ -30,7 +30,7 @@
|
||||
static void ndpi_int_applejuice_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_APPLEJUICE, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_APPLEJUICE, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_applejuice_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
@@ -54,4 +54,17 @@ void ndpi_search_applejuice_tcp(struct ndpi_detection_module_struct *ndpi_struct
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_APPLEJUICE);
|
||||
}
|
||||
|
||||
|
||||
void init_applejuice_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("AppleJuice", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_APPLEJUICE,
|
||||
ndpi_search_applejuice_tcp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,9 +23,8 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* include files */
|
||||
#include "ndpi_protocols.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_ARMAGETRON
|
||||
|
||||
|
||||
@@ -33,7 +32,7 @@ static void ndpi_int_armagetron_add_connection(struct ndpi_detection_module_stru
|
||||
struct ndpi_flow_struct *flow)
|
||||
{
|
||||
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_ARMAGETRON, NDPI_REAL_PROTOCOL);
|
||||
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)
|
||||
@@ -99,4 +98,19 @@ void ndpi_search_armagetron_udp(struct ndpi_detection_module_struct *ndpi_struct
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_ARMAGETRON);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void init_armagetron_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Armagetron", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_ARMAGETRON,
|
||||
ndpi_search_armagetron_udp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
static void ndpi_int_flash_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FLASH, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FLASH);
|
||||
}
|
||||
|
||||
void ndpi_search_flash(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
static void ndpi_int_ftp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FTP, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FTP);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,6 +43,8 @@ static void ndpi_int_ftp_add_connection(struct ndpi_detection_module_struct *ndp
|
||||
*/
|
||||
#if !defined(WIN32)
|
||||
static inline
|
||||
#elif defined(MINGW_GCC)
|
||||
__mingw_forceinline static
|
||||
#else
|
||||
__forceinline static
|
||||
#endif
|
||||
@@ -78,8 +80,11 @@ 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
|
||||
*/
|
||||
|
||||
#if !defined(WIN32)
|
||||
static inline
|
||||
#elif defined(MINGW_GCC)
|
||||
__mingw_forceinline static
|
||||
#else
|
||||
__forceinline static
|
||||
#endif
|
||||
@@ -108,6 +113,8 @@ u_int8_t ndpi_int_check_possible_ftp_reply(const struct ndpi_packet_struct *pack
|
||||
*/
|
||||
#if !defined(WIN32)
|
||||
static inline
|
||||
#elif defined(MINGW_GCC)
|
||||
__mingw_forceinline static
|
||||
#else
|
||||
__forceinline static
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@ static void ndpi_int_manolito_add_connection(struct
|
||||
struct ndpi_id_struct *src = flow->src;
|
||||
struct ndpi_id_struct *dst = flow->dst;
|
||||
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_MANOLITO, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MANOLITO);
|
||||
|
||||
|
||||
if (src != NULL) {
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
static void ndpi_int_popo_add_connection(struct ndpi_detection_module_struct
|
||||
*ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_POPO, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_POPO);
|
||||
}
|
||||
|
||||
void ndpi_search_popo_tcp_udp(struct ndpi_detection_module_struct
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
#ifdef NDPI_PROTOCOL_SECONDLIFE
|
||||
|
||||
static void ndpi_int_secondlife_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 */)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_SECONDLIFE, protocol_type);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_SECONDLIFE, protocol_type);
|
||||
}
|
||||
|
||||
void ndpi_search_secondlife(struct ndpi_detection_module_struct
|
||||
@@ -92,25 +92,25 @@ void ndpi_search_secondlife(struct ndpi_detection_module_struct
|
||||
if (packet->payload_packet_len == 46
|
||||
&& memcmp(packet->payload, "\x40\x00\x00\x00\x01\x00\xff\xff\x00\x03", 10) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG, "Second Life 0xffff0003 detected.\n");
|
||||
ndpi_int_secondlife_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_secondlife_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len == 54
|
||||
&& memcmp(packet->payload, "\x40\x00\x00\x00\x01\x00\xff\xff\x00\x52", 10) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG, "Second Life 0xffff0052 detected.\n");
|
||||
ndpi_int_secondlife_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_secondlife_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len == 58
|
||||
&& memcmp(packet->payload, "\x40\x00\x00\x00\x01\x00\xff\xff\x00\xa9", 10) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG, "Second Life 0xffff00a9 detected.\n");
|
||||
ndpi_int_secondlife_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_secondlife_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len > 54 && memcmp(packet->payload, "\x40\x00\x00\x00\x01\x00\x08", 7) == 0 &&
|
||||
get_u_int32_t(packet->payload, packet->payload_packet_len - 4) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG, "Second Life 0x08 detected.\n");
|
||||
ndpi_int_secondlife_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_secondlife_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,12 +51,12 @@ void ndpi_search_ayiya(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
/* FINISH */
|
||||
struct ayiya *a = (struct ayiya*)packet->payload;
|
||||
u_int32_t epoch = ntohl(a->epoch), now;
|
||||
u_int32_t fireyears = 86400 * 365 * 5;
|
||||
u_int32_t fiveyears = 86400 * 365 * 5;
|
||||
|
||||
now = flow->packet.tick_timestamp;
|
||||
|
||||
if((epoch >= (now - fireyears)) && (epoch <= (now+86400 /* 1 day */)))
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_AYIYA, NDPI_REAL_PROTOCOL);
|
||||
if((epoch >= (now - fiveyears)) && (epoch <= (now+86400 /* 1 day */)))
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AYIYA, NDPI_PROTOCOL_UNKNOWN);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -64,4 +64,18 @@ void ndpi_search_ayiya(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_AYIYA);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_ayiya_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Ayiya", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_AYIYA,
|
||||
ndpi_search_ayiya,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,7 @@ static void ndpi_int_battlefield_add_connection(struct ndpi_detection_module_str
|
||||
struct ndpi_id_struct *src = flow->src;
|
||||
struct ndpi_id_struct *dst = flow->dst;
|
||||
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_BATTLEFIELD, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BATTLEFIELD, NDPI_PROTOCOL_UNKNOWN);
|
||||
|
||||
if (src != NULL) {
|
||||
src->battlefield_ts = packet->tick_timestamp;
|
||||
@@ -115,4 +115,16 @@ void ndpi_search_battlefield(struct ndpi_detection_module_struct *ndpi_struct, s
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void init_battlefield_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("BattleField", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_BATTLEFIELD,
|
||||
ndpi_search_battlefield,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+32
-26
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
* bgp.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-15 - ntop.org
|
||||
* Copyright (C) 2016 - 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
|
||||
@@ -21,37 +20,44 @@
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ndpi_protocols.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_BGP
|
||||
|
||||
|
||||
static void ndpi_int_bgp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_BGP, NDPI_REAL_PROTOCOL);
|
||||
}
|
||||
|
||||
/* this detection also works asymmetrically */
|
||||
void ndpi_search_bgp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
// struct ndpi_id_struct *src=ndpi_struct->src;
|
||||
// struct ndpi_id_struct *dst=ndpi_struct->dst;
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int16_t bgp_port = htons(179);
|
||||
|
||||
if (packet->payload_packet_len > 18 &&
|
||||
get_u_int64_t(packet->payload, 0) == 0xffffffffffffffffULL &&
|
||||
get_u_int64_t(packet->payload, 8) == 0xffffffffffffffffULL &&
|
||||
ntohs(get_u_int16_t(packet->payload, 16)) <= packet->payload_packet_len &&
|
||||
(packet->tcp->dest == htons(179) || packet->tcp->source == htons(179))
|
||||
&& packet->payload[18] < 5) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_BGP, ndpi_struct, NDPI_LOG_DEBUG, "BGP detected.\n");
|
||||
ndpi_int_bgp_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BGP);
|
||||
if(packet->tcp) {
|
||||
if(packet->payload_packet_len > 18
|
||||
&& packet->payload[18] < 5
|
||||
&& ((packet->tcp->dest == bgp_port) || (packet->tcp->source == bgp_port))
|
||||
&& (get_u_int64_t(packet->payload, 0) == 0xffffffffffffffffULL)
|
||||
&& (get_u_int64_t(packet->payload, 8) == 0xffffffffffffffffULL)
|
||||
&& (ntohs(get_u_int16_t(packet->payload, 16)) <= packet->payload_packet_len)) {
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* exclude BGP */
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BGP);
|
||||
}
|
||||
|
||||
|
||||
void init_bgp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("BGP", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_BGP,
|
||||
ndpi_search_bgp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+160
-126
@@ -25,118 +25,141 @@
|
||||
|
||||
#include "ndpi_protocols.h"
|
||||
#ifdef NDPI_PROTOCOL_BITTORRENT
|
||||
#define NDPI_PROTOCOL_UNSAFE_DETECTION 0
|
||||
#define NDPI_PROTOCOL_SAFE_DETECTION 1
|
||||
#define NDPI_PROTOCOL_UNSAFE_DETECTION 0
|
||||
#define NDPI_PROTOCOL_SAFE_DETECTION 1
|
||||
|
||||
#define NDPI_PROTOCOL_PLAIN_DETECTION 0
|
||||
#define NDPI_PROTOCOL_WEBSEED_DETECTION 2
|
||||
|
||||
|
||||
struct ndpi_utp_hdr {
|
||||
u_int8_t h_version:4, h_type:4, next_extension;
|
||||
u_int16_t connection_id;
|
||||
u_int32_t ts_usec, tdiff_usec, window_size;
|
||||
u_int16_t sequence_nr, ack_nr;
|
||||
};
|
||||
|
||||
static u_int8_t is_utp_pkt(const u_int8_t *payload, u_int payload_len) {
|
||||
struct ndpi_utp_hdr *h = (struct ndpi_utp_hdr*)payload;
|
||||
|
||||
if(payload_len < sizeof(struct ndpi_utp_hdr)) return(0);
|
||||
if(h->h_version != 1) return(0);
|
||||
if(h->h_type > 4) return(0);
|
||||
if(h->next_extension > 2) return(0);
|
||||
if(ntohl(h->window_size) > 65565) return(0);
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
#define NDPI_PROTOCOL_PLAIN_DETECTION 0
|
||||
#define NDPI_PROTOCOL_WEBSEED_DETECTION 2
|
||||
static void ndpi_add_connection_as_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow,
|
||||
const u_int8_t save_detection, const u_int8_t encrypted_connection,
|
||||
ndpi_protocol_type_t protocol_type)
|
||||
int bt_offset, int check_hash,
|
||||
const u_int8_t save_detection, const u_int8_t encrypted_connection)
|
||||
{
|
||||
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BITTORRENT, protocol_type);
|
||||
if(check_hash) {
|
||||
const char *bt_hash = NULL; /* 20 bytes long */
|
||||
|
||||
if(bt_offset == -1) {
|
||||
const char *bt_magic = ndpi_strnstr((const char *)flow->packet.payload,
|
||||
"BitTorrent protocol", flow->packet.payload_packet_len);
|
||||
|
||||
if(bt_magic)
|
||||
bt_hash = &bt_magic[19];
|
||||
} else
|
||||
bt_hash = (const char*)&flow->packet.payload[28];
|
||||
|
||||
if(bt_hash) memcpy(flow->protos.bittorrent.hash, bt_hash, 20);
|
||||
}
|
||||
|
||||
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BITTORRENT, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module_struct
|
||||
*ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
// struct ndpi_id_struct *src = flow->src;
|
||||
// struct ndpi_id_struct *dst = flow->dst;
|
||||
|
||||
u_int16_t a = 0;
|
||||
|
||||
if (packet->payload_packet_len == 1 && packet->payload[0] == 0x13) {
|
||||
if(packet->payload_packet_len == 1 && packet->payload[0] == 0x13) {
|
||||
/* reset stage back to 0 so we will see the next packet here too */
|
||||
flow->bittorrent_stage = 0;
|
||||
return 0;
|
||||
}
|
||||
if (flow->packet_counter == 2 && packet->payload_packet_len > 20) {
|
||||
|
||||
if (memcmp(&packet->payload[0], "BitTorrent protocol", 19) == 0) {
|
||||
if(flow->packet_counter == 2 && packet->payload_packet_len > 20) {
|
||||
if(memcmp(&packet->payload[0], "BitTorrent protocol", 19) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT,
|
||||
ndpi_struct, NDPI_LOG_TRACE, "BT: plain BitTorrent protocol detected\n");
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||
NDPI_REAL_PROTOCOL);
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, 19, 1,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (packet->payload_packet_len > 20) {
|
||||
if(packet->payload_packet_len > 20) {
|
||||
/* test for match 0x13+"BitTorrent protocol" */
|
||||
if (packet->payload[0] == 0x13) {
|
||||
if (memcmp(&packet->payload[1], "BitTorrent protocol", 19) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT,
|
||||
ndpi_struct, NDPI_LOG_TRACE, "BT: plain BitTorrent protocol detected\n");
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||
NDPI_REAL_PROTOCOL);
|
||||
if(packet->payload[0] == 0x13) {
|
||||
if(memcmp(&packet->payload[1], "BitTorrent protocol", 19) == 0) {
|
||||
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_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
|
||||
NDPI_LOG_TRACE, "BT: plain webseed BitTorrent protocol detected\n");
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION,
|
||||
NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
|
||||
return 1;
|
||||
}
|
||||
/* seen Azureus as server for webseed, possibly other servers existing, to implement */
|
||||
/* is Server: hypertracker Bittorrent? */
|
||||
/* 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) {
|
||||
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,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION,
|
||||
NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (packet->payload_packet_len > 90 && (memcmp(packet->payload, "GET ", 4) == 0
|
||||
if(packet->payload_packet_len > 90 && (memcmp(packet->payload, "GET ", 4) == 0
|
||||
|| memcmp(packet->payload, "POST ", 5) == 0)) {
|
||||
const u_int8_t *ptr = &packet->payload[4];
|
||||
u_int16_t len = packet->payload_packet_len - 4;
|
||||
a = 0;
|
||||
|
||||
|
||||
/* parse complete get packet here into line structure elements */
|
||||
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||
/* answer to this pattern is HTTP....Server: hypertracker */
|
||||
if (packet->user_agent_line.ptr != NULL
|
||||
if(packet->user_agent_line.ptr != NULL
|
||||
&& ((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 >= 11 && memcmp(packet->user_agent_line.ptr, "BTWebClient", 11) == 0))) {
|
||||
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,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION,
|
||||
NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (packet->user_agent_line.ptr != NULL
|
||||
&& (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->line[8].len >= 9 && memcmp(packet->line[8].ptr, "X-Queue: ", 9) == 0)) {
|
||||
if(packet->user_agent_line.ptr != NULL
|
||||
&& (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->line[8].len >= 9 && memcmp(packet->line[8].ptr, "X-Queue: ", 9) == 0)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
|
||||
NDPI_LOG_TRACE, "Bittorrent Shareaza detected.\n");
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION,
|
||||
NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* this is a self built client, not possible to catch asymmetrically */
|
||||
if ((packet->parsed_lines == 10 || (packet->parsed_lines == 11 && packet->line[11].len == 0))
|
||||
if((packet->parsed_lines == 10 || (packet->parsed_lines == 11 && packet->line[11].len == 0))
|
||||
&& packet->user_agent_line.ptr != NULL
|
||||
&& packet->user_agent_line.len > 12
|
||||
&& memcmp(packet->user_agent_line.ptr, "Mozilla/4.0 ",
|
||||
@@ -164,15 +187,13 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
|
||||
&& packet->line[8].len > 22 && memcmp(packet->line[8].ptr, "Cache-Control: no-cache", 23) == 0) {
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_TRACE, "Bitcomet LTS detected\n");
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||
NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
|
||||
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/* FlashGet pattern */
|
||||
if (packet->parsed_lines == 8
|
||||
if(packet->parsed_lines == 8
|
||||
&& packet->user_agent_line.ptr != NULL
|
||||
&& packet->user_agent_line.len > (sizeof("Mozilla/4.0 (compatible; MSIE 6.0;") - 1)
|
||||
&& memcmp(packet->user_agent_line.ptr, "Mozilla/4.0 (compatible; MSIE 6.0;",
|
||||
@@ -191,13 +212,12 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
|
||||
&& packet->line[6].len > 21 && memcmp(packet->line[6].ptr, "Connection: Keep-Alive", 22) == 0) {
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_TRACE, "FlashGet detected\n");
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||
NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
|
||||
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
|
||||
return 1;
|
||||
|
||||
}
|
||||
if (packet->parsed_lines == 7
|
||||
|
||||
if(packet->parsed_lines == 7
|
||||
&& packet->user_agent_line.ptr != NULL
|
||||
&& packet->user_agent_line.len > (sizeof("Mozilla/4.0 (compatible; MSIE 6.0;") - 1)
|
||||
&& memcmp(packet->user_agent_line.ptr, "Mozilla/4.0 (compatible; MSIE 6.0;",
|
||||
@@ -213,19 +233,17 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
|
||||
&& packet->line[5].len > 21 && memcmp(packet->line[5].ptr, "Connection: Keep-Alive", 22) == 0) {
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_TRACE, "FlashGet detected\n");
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||
NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
|
||||
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/* answer to this pattern is not possible to implement asymmetrically */
|
||||
while (1) {
|
||||
if (len < 50 || ptr[0] == 0x0d) {
|
||||
if(len < 50 || ptr[0] == 0x0d) {
|
||||
goto ndpi_end_bt_tracker_check;
|
||||
}
|
||||
if (memcmp(ptr, "info_hash=", 10) == 0) {
|
||||
if(memcmp(ptr, "info_hash=", 10) == 0) {
|
||||
break;
|
||||
}
|
||||
len--;
|
||||
@@ -241,40 +259,40 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
|
||||
|
||||
/* parse bt hash */
|
||||
for (a = 0; a < 20; a++) {
|
||||
if (len < 3) {
|
||||
if(len < 3) {
|
||||
goto ndpi_end_bt_tracker_check;
|
||||
}
|
||||
if (*ptr == '%') {
|
||||
if(*ptr == '%') {
|
||||
u_int8_t x1 = 0xFF;
|
||||
u_int8_t x2 = 0xFF;
|
||||
|
||||
|
||||
if (ptr[1] >= '0' && ptr[1] <= '9') {
|
||||
if(ptr[1] >= '0' && ptr[1] <= '9') {
|
||||
x1 = ptr[1] - '0';
|
||||
}
|
||||
if (ptr[1] >= 'a' && ptr[1] <= 'f') {
|
||||
if(ptr[1] >= 'a' && ptr[1] <= 'f') {
|
||||
x1 = 10 + ptr[1] - 'a';
|
||||
}
|
||||
if (ptr[1] >= 'A' && ptr[1] <= 'F') {
|
||||
if(ptr[1] >= 'A' && ptr[1] <= 'F') {
|
||||
x1 = 10 + ptr[1] - 'A';
|
||||
}
|
||||
|
||||
if (ptr[2] >= '0' && ptr[2] <= '9') {
|
||||
if(ptr[2] >= '0' && ptr[2] <= '9') {
|
||||
x2 = ptr[2] - '0';
|
||||
}
|
||||
if (ptr[2] >= 'a' && ptr[2] <= 'f') {
|
||||
if(ptr[2] >= 'a' && ptr[2] <= 'f') {
|
||||
x2 = 10 + ptr[2] - 'a';
|
||||
}
|
||||
if (ptr[2] >= 'A' && ptr[2] <= 'F') {
|
||||
if(ptr[2] >= 'A' && ptr[2] <= 'F') {
|
||||
x2 = 10 + ptr[2] - 'A';
|
||||
}
|
||||
|
||||
if (x1 == 0xFF || x2 == 0xFF) {
|
||||
if(x1 == 0xFF || x2 == 0xFF) {
|
||||
goto ndpi_end_bt_tracker_check;
|
||||
}
|
||||
ptr += 3;
|
||||
len -= 3;
|
||||
} else if (*ptr >= 32 && *ptr < 127) {
|
||||
} else if(*ptr >= 32 && *ptr < 127) {
|
||||
ptr++;
|
||||
len--;
|
||||
} else {
|
||||
@@ -284,15 +302,14 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
|
||||
|
||||
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,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||
NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ndpi_end_bt_tracker_check:
|
||||
|
||||
if (packet->payload_packet_len == 80) {
|
||||
if(packet->payload_packet_len == 80) {
|
||||
/* Warez 80 Bytes Packet
|
||||
* +----------------+---------------+-----------------+-----------------+
|
||||
* |20 BytesPattern | 32 Bytes Value| 12 BytesPattern | 16 Bytes Data |
|
||||
@@ -310,30 +327,28 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
|
||||
};
|
||||
|
||||
/* 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)) {
|
||||
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,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||
NDPI_REAL_PROTOCOL);
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
else if (packet->payload_packet_len > 50) {
|
||||
if (memcmp(packet->payload, "GET", 3) == 0) {
|
||||
else if(packet->payload_packet_len > 50) {
|
||||
if(memcmp(packet->payload, "GET", 3) == 0) {
|
||||
|
||||
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||
/* 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) {
|
||||
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,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION,
|
||||
NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -345,17 +360,16 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module
|
||||
/*Search for BitTorrent commands*/
|
||||
static void ndpi_int_search_bittorrent_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
if (packet->payload_packet_len == 0) {
|
||||
if(packet->payload_packet_len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (flow->bittorrent_stage == 0 && packet->payload_packet_len != 0) {
|
||||
if(flow->bittorrent_stage == 0 && packet->payload_packet_len != 0) {
|
||||
/* exclude stage 0 detection from next run */
|
||||
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(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"stage 0 has detected something, returning\n");
|
||||
return;
|
||||
@@ -370,16 +384,22 @@ 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)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
char *bt_proto = NULL;
|
||||
|
||||
/* This is broadcast */
|
||||
if(packet->iph
|
||||
&& ((packet->iph->saddr == 0xFFFFFFFF) || (packet->iph->daddr == 0xFFFFFFFF)))
|
||||
&& (((packet->iph->saddr == 0xFFFFFFFF) || (packet->iph->daddr == 0xFFFFFFFF))
|
||||
|| (packet->udp
|
||||
&& ((ntohs(packet->udp->source) == 3544) /* teredo.c */
|
||||
|| (ntohs(packet->udp->dest) == 3544))))) {
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BITTORRENT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_BITTORRENT) {
|
||||
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_BITTORRENT) {
|
||||
/* check for tcp retransmission here */
|
||||
|
||||
if ((packet->tcp != NULL)
|
||||
if((packet->tcp != NULL)
|
||||
&& (packet->tcp_retransmission == 0 || packet->num_retried_bytes)) {
|
||||
ndpi_int_search_bittorrent_tcp(ndpi_struct, flow);
|
||||
}
|
||||
@@ -398,9 +418,8 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|
||||
if(packet->payload_packet_len >= 23 /* min header size */) {
|
||||
if(strncmp((const char*)packet->payload, bt_search, strlen(bt_search)) == 0) {
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||
NDPI_REAL_PROTOCOL);
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
|
||||
return;
|
||||
} else {
|
||||
/* Check if this is protocol v0 */
|
||||
@@ -412,34 +431,32 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
u_int8_t v1_extension = packet->payload[1];
|
||||
u_int32_t v1_window_size = *((u_int32_t*)&packet->payload[12]);
|
||||
|
||||
if((packet->payload[0]== 0x60)
|
||||
if(is_utp_pkt(packet->payload, packet->payload_packet_len))
|
||||
goto bittorrent_found;
|
||||
else if((packet->payload[0]== 0x60)
|
||||
&& (packet->payload[1]== 0x0)
|
||||
&& (packet->payload[2]== 0x0)
|
||||
&& (packet->payload[3]== 0x0)
|
||||
&& (packet->payload[4]== 0x0)) {
|
||||
/* Heuristic */
|
||||
bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20);
|
||||
goto bittorrent_found;
|
||||
} else if(((v1_version & 0x0f) == 1)
|
||||
/* CSGO/DOTA conflict */
|
||||
} else if(flow->packet_counter > 8 && ((v1_version & 0x0f) == 1)
|
||||
&& ((v1_version >> 4) < 5 /* ST_NUM_STATES */)
|
||||
&& (v1_extension < 3 /* EXT_NUM_EXT */)
|
||||
&& (v1_window_size < 32768 /* 32k */)
|
||||
) {
|
||||
bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20);
|
||||
goto bittorrent_found;
|
||||
} else if((v0_flags < 6 /* ST_NUM_STATES */)
|
||||
&& (v0_extension < 3 /* EXT_NUM_EXT */)) {
|
||||
} else if((v0_flags < 6 /* ST_NUM_STATES */) && (v0_extension < 3 /* EXT_NUM_EXT */)) {
|
||||
u_int32_t ts = ntohl(*((u_int32_t*)&(packet->payload[4])));
|
||||
u_int32_t now;
|
||||
|
||||
#ifndef __KERNEL__
|
||||
now = (u_int32_t)time(NULL);
|
||||
#else
|
||||
struct timespec t;
|
||||
|
||||
getnstimeofday(&t);
|
||||
now = t.tv_sec;
|
||||
#endif
|
||||
|
||||
if((ts < (now+86400)) && (ts > (now-86400))) {
|
||||
bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20);
|
||||
goto bittorrent_found;
|
||||
}
|
||||
}
|
||||
@@ -449,24 +466,28 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
flow->bittorrent_stage++;
|
||||
|
||||
if(flow->bittorrent_stage < 10) {
|
||||
if(packet->payload_packet_len > 19 /* min size */) {
|
||||
if(ndpi_strnstr((const char *)packet->payload, ":target20:", packet->payload_packet_len)
|
||||
|| ndpi_strnstr((const char *)packet->payload, ":find_node1:", packet->payload_packet_len)
|
||||
|| ndpi_strnstr((const char *)packet->payload, "d1:ad2:id20:", packet->payload_packet_len)
|
||||
|| ndpi_strnstr((const char *)packet->payload, ":info_hash20:", packet->payload_packet_len)
|
||||
|| ndpi_strnstr((const char *)packet->payload, ":filter64", packet->payload_packet_len)
|
||||
|| ndpi_strnstr((const char *)packet->payload, "d1:rd2:id20:", packet->payload_packet_len)
|
||||
|| ndpi_strnstr((const char *)packet->payload, "BitTorrent protocol", packet->payload_packet_len)
|
||||
) {
|
||||
bittorrent_found:
|
||||
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT,
|
||||
ndpi_struct, NDPI_LOG_TRACE, "BT: plain BitTorrent protocol detected\n");
|
||||
ndpi_add_connection_as_bittorrent(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||
NDPI_REAL_PROTOCOL);
|
||||
return;
|
||||
/* We have detected bittorrent but we need to wait until we get a hash */
|
||||
|
||||
if(packet->payload_packet_len > 19 /* min size */) {
|
||||
if(ndpi_strnstr((const char *)packet->payload, ":target20:", packet->payload_packet_len)
|
||||
|| ndpi_strnstr((const char *)packet->payload, ":find_node1:", packet->payload_packet_len)
|
||||
|| ndpi_strnstr((const char *)packet->payload, "d1:ad2:id20:", packet->payload_packet_len)
|
||||
|| ndpi_strnstr((const char *)packet->payload, ":info_hash20:", packet->payload_packet_len)
|
||||
|| ndpi_strnstr((const char *)packet->payload, ":filter64", packet->payload_packet_len)
|
||||
|| ndpi_strnstr((const char *)packet->payload, "d1:rd2:id20:", packet->payload_packet_len)
|
||||
|| (bt_proto = ndpi_strnstr((const char *)packet->payload, "BitTorrent protocol", packet->payload_packet_len))
|
||||
) {
|
||||
bittorrent_found:
|
||||
if(bt_proto && (packet->payload_packet_len > 47))
|
||||
memcpy(flow->protos.bittorrent.hash, &bt_proto[27], 20);
|
||||
|
||||
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_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -475,4 +496,17 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_bittorrent_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("BitTorrent", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_BITTORRENT,
|
||||
ndpi_search_bittorrent,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_BJNP
|
||||
|
||||
|
||||
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(NDPI_PROTOCOL_BJNP, ndpi_struct, NDPI_LOG_DEBUG, "Found bjnp.\n");
|
||||
ndpi_int_bjnp_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_BJNP, ndpi_struct, NDPI_LOG_DEBUG, "exclude bjnp.\n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BJNP);
|
||||
}
|
||||
|
||||
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(NDPI_PROTOCOL_BJNP, ndpi_struct, NDPI_LOG_DEBUG, "bjnp detection...\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
|
||||
@@ -42,8 +42,6 @@ typedef signed long long int i_int64_t;
|
||||
|
||||
#include "btlib.h"
|
||||
|
||||
#ifndef __KERNEL__
|
||||
|
||||
int bt_parse_debug = 0;
|
||||
|
||||
static char *printXb(char *s,const u_int8_t *b,int l) {
|
||||
@@ -183,11 +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) {
|
||||
_print_safe_str(msg,cbd->buf,cbd->v.s.s,cbd->v.s.l);
|
||||
}
|
||||
#define DEBUG_TRACE(cmd) { if(bt_parse_debug) cmd; }
|
||||
#else
|
||||
#define DEBUG_TRACE(cmd,args...)
|
||||
#endif /* __KERNEL */
|
||||
|
||||
#define DEBUG_TRACE(cmd) { if(bt_parse_debug) cmd; }
|
||||
#define STREQ(a,b) !strcmp(a,b)
|
||||
|
||||
|
||||
@@ -401,12 +396,12 @@ void cb_data(bt_parse_data_cb_t *cbd,int *ret) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(cbd->buf[0] == 'e' && !cbd->buf[0]) {
|
||||
if(cbd->buf[0] == 'e') {
|
||||
p->e_msg = s;
|
||||
p->e_len = cbd->v.s.l;
|
||||
return;
|
||||
}
|
||||
// DEBUG_TRACE(print_safe_str("UKNOWN",cbd));
|
||||
// DEBUG_TRACE(print_safe_str("UNKNOWN",cbd));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+47
-13
@@ -24,44 +24,81 @@
|
||||
|
||||
#define BDEC_MAXDEPT 8
|
||||
|
||||
#ifdef WIN32
|
||||
#include "ndpi_win32.h"
|
||||
#endif
|
||||
|
||||
typedef struct b_elem_s {
|
||||
const u_int8_t *s;
|
||||
size_t l;
|
||||
} b_elem_s_t;
|
||||
|
||||
struct __attribute__ ((__packed__)) bt_nodes_data {
|
||||
u_int8_t id[20] ;
|
||||
#ifdef WIN32
|
||||
// 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_int32_t ip;
|
||||
u_int16_t port;
|
||||
};
|
||||
|
||||
struct __attribute__ ((__packed__)) bt_ipv4p {
|
||||
struct
|
||||
#ifndef WIN32
|
||||
__attribute__((__packed__))
|
||||
#endif
|
||||
bt_ipv4p {
|
||||
u_int32_t ip;
|
||||
u_int16_t port;
|
||||
};
|
||||
|
||||
struct __attribute__ ((__packed__)) bt_ipv4p2 {
|
||||
struct
|
||||
#ifndef WIN32
|
||||
__attribute__((__packed__))
|
||||
#endif
|
||||
bt_ipv4p2 {
|
||||
struct bt_ipv4p d;
|
||||
u_int8_t pad[2];
|
||||
};
|
||||
|
||||
struct __attribute__ ((__packed__)) bt_nodes6_data {
|
||||
u_int8_t id[20] ;
|
||||
struct
|
||||
#ifndef WIN32
|
||||
__attribute__((__packed__))
|
||||
#endif
|
||||
bt_nodes6_data {
|
||||
u_int8_t id[20];
|
||||
u_int32_t ip[4];
|
||||
u_int16_t port;
|
||||
};
|
||||
|
||||
struct __attribute__ ((__packed__)) bt_ipv6p {
|
||||
struct
|
||||
#ifndef WIN32
|
||||
__attribute__((__packed__))
|
||||
#endif
|
||||
bt_ipv6p {
|
||||
u_int32_t ip[4];
|
||||
u_int16_t port;
|
||||
};
|
||||
|
||||
struct __attribute__ ((__packed__)) bt_ipv6p2 {
|
||||
struct
|
||||
#ifndef WIN32
|
||||
__attribute__((__packed__))
|
||||
#endif
|
||||
bt_ipv6p2 {
|
||||
struct bt_ipv6p d;
|
||||
u_int8_t pad[3];
|
||||
};
|
||||
|
||||
#ifdef WIN32
|
||||
// disable 1 byte packing
|
||||
#include <poppack.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
a.id S r.id S
|
||||
@@ -113,9 +150,9 @@ struct bt_parse_protocol {
|
||||
struct bt_nodes6_data *nodes6;
|
||||
u_int16_t name_len;
|
||||
u_int16_t nn; // nodes num
|
||||
u_int16_t nv; // valuse num
|
||||
u_int16_t nv; // values num
|
||||
u_int16_t nn6; // nodes6 num
|
||||
u_int16_t nv6; // valuse6 num
|
||||
u_int16_t nv6; // values6 num
|
||||
u_int16_t port;
|
||||
u_int16_t t_len;
|
||||
} r;
|
||||
@@ -139,9 +176,6 @@ typedef struct bt_parse_data_cb {
|
||||
} v;
|
||||
} bt_parse_data_cb_t;
|
||||
|
||||
#ifndef __KERNEL__
|
||||
extern int bt_parse_debug;
|
||||
void dump_bt_proto_struct(struct bt_parse_protocol *p);
|
||||
#endif
|
||||
const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_cb_t *cbd);
|
||||
|
||||
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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_protocols.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_CHECKMK
|
||||
|
||||
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
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
static void ndpi_int_ciscovpn_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_CISCOVPN, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CISCOVPN, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -67,4 +67,17 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void init_ciscovpn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("CiscoVPN", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_CISCOVPN,
|
||||
ndpi_search_ciscovpn,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+14
-11
@@ -33,14 +33,6 @@ static void ndpi_check_citrix(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
#if 0
|
||||
printf("[len=%u][%02X %02X %02X %02X]\n", payload_len,
|
||||
packet->payload[0] & 0xFF,
|
||||
packet->payload[1] & 0xFF,
|
||||
packet->payload[2] & 0xFF,
|
||||
packet->payload[3] & 0xFF);
|
||||
#endif
|
||||
|
||||
if(packet->tcp != NULL) {
|
||||
flow->l4.tcp.citrix_packet_id++;
|
||||
|
||||
@@ -54,7 +46,7 @@ static void ndpi_check_citrix(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
if(memcmp(packet->payload, citrix_header, sizeof(citrix_header)) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_CITRIX, ndpi_struct, NDPI_LOG_DEBUG, "Found citrix.\n");
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -64,13 +56,12 @@ static void ndpi_check_citrix(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
if((memcmp(packet->payload, citrix_header, sizeof(citrix_header)) == 0)
|
||||
|| (ndpi_strnstr((const char *)packet->payload, "Citrix.TcpProxyService", payload_len) != NULL)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_CITRIX, ndpi_struct, NDPI_LOG_DEBUG, "Found citrix.\n");
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CITRIX);
|
||||
} else if(flow->l4.tcp.citrix_packet_id > 3)
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CITRIX);
|
||||
@@ -90,4 +81,16 @@ void ndpi_search_citrix(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
ndpi_check_citrix(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
void init_citrix_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Citrix", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_CITRIX,
|
||||
ndpi_search_citrix,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* coap.c
|
||||
*
|
||||
* Copyright (C) 2016 Sorin Zamfir <sorin.zamfir@yahoo.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_protocols.h"
|
||||
#ifdef NDPI_PROTOCOL_COAP
|
||||
|
||||
#define CON 0
|
||||
#define NO_CON 1
|
||||
#define ACK 2
|
||||
#define RST 3
|
||||
|
||||
struct ndpi_coap_hdr
|
||||
{
|
||||
#if defined(__BIG_ENDIAN__)
|
||||
u_int8_t version:2, type:2, tkl:4;
|
||||
#elif defined(__LITTLE_ENDIAN__)
|
||||
u_int8_t tkl:4, type:2, version:2;
|
||||
#endif
|
||||
u_int8_t code;
|
||||
u_int16_t message_id; //if needed, remember to convert in host number
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
VALUE OF -CODE- FIELD
|
||||
|
||||
[0] = "Empty",
|
||||
[1] = "GET",
|
||||
[2] = "POST",
|
||||
[3] = "PUT",
|
||||
[4] = "DELETE",
|
||||
[65] = "2.01 Created",
|
||||
[66] = "2.02 Deleted",
|
||||
[67] = "2.03 Valid",
|
||||
[68] = "2.04 Changed",
|
||||
[69] = "2.05 Content",
|
||||
[128] = "4.00 Bad Request",
|
||||
[129] = "4.01 Unauthorized",
|
||||
[130] = "4.02 Bad Option",
|
||||
[131] = "4.03 Forbidden",
|
||||
[132] = "4.04 Not Found",
|
||||
[133] = "4.05 Method Not Allowed",
|
||||
[134] = "4.06 Not Acceptable",
|
||||
[140] = "4.12 Precondition Failed",
|
||||
[141] = "4.13 Request Entity Too Large",
|
||||
[143] = "4.15 Unsupported Content-Format",
|
||||
[160] = "5.00 Internal Server Error",
|
||||
[161] = "5.01 Not Implemented",
|
||||
[162] = "5.02 Bad Gateway",
|
||||
[163] = "5.03 Service Unavailable",
|
||||
[164] = "5.04 Gateway Timeout",
|
||||
[165] = "5.05 Proxying Not Supported"
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* Entry point when protocol is identified.
|
||||
*/
|
||||
static void ndpi_int_coap_add_connection (struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_set_detected_protocol(ndpi_struct,flow,NDPI_PROTOCOL_COAP,NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the default port is acceptable
|
||||
*
|
||||
* UDP Port 5683 (mandatory)
|
||||
* UDP Ports 61616-61631 compressed 6lowPAN
|
||||
*/
|
||||
static int isCoAPport(u_int16_t port) {
|
||||
if((port == 5683)
|
||||
|| ((port >= 61616) && (port <= 61631)))
|
||||
return(1);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dissector function that searches CoAP headers
|
||||
*/
|
||||
void ndpi_search_coap (struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
struct ndpi_coap_hdr * h = (struct ndpi_coap_hdr*) packet->payload;
|
||||
|
||||
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
|
||||
// search for udp packet
|
||||
if(packet->udp != NULL) {
|
||||
u_int16_t s_port = ntohs(flow->packet.udp->source);
|
||||
u_int16_t d_port = ntohs(flow->packet.udp->dest);
|
||||
|
||||
if((!isCoAPport(s_port) && !isCoAPport(d_port))
|
||||
|| (packet->payload_packet_len < 4) // header too short
|
||||
) {
|
||||
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;
|
||||
}
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_COAP, ndpi_struct, NDPI_LOG_DEBUG, "calculating coap over udp.\n");
|
||||
|
||||
// check values in header
|
||||
if(h->version == 1) {
|
||||
if(h->type == CON || h->type == NO_CON || h->type == ACK || h->type == RST ) {
|
||||
if(h->tkl == 0 || h->tkl < 8) {
|
||||
if((h->code >= 0 && h->code <= 5) || (h->code >= 65 && h->code <= 69) ||
|
||||
(h->code >= 128 && h->code <= 134) || (h->code >= 140 && h->code <= 143) ||
|
||||
(h->code >= 160 && h->code <= 165)) {
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_COAP, ndpi_struct, NDPI_LOG_DEBUG, "Coap found...\n");
|
||||
ndpi_int_coap_add_connection(ndpi_struct,flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for the ndpi library
|
||||
*/
|
||||
void init_coap_dissector (struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection ("COAP", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_COAP,
|
||||
ndpi_search_coap,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN, ADD_TO_DETECTION_BITMASK);
|
||||
*id +=1;
|
||||
}
|
||||
|
||||
|
||||
#endif // NDPI_PROTOCOL_COAP
|
||||
@@ -44,10 +44,11 @@ void ndpi_search_collectd(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
|
||||
if(len == packet->payload_packet_len) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_COLLECTD, ndpi_struct, NDPI_LOG_DEBUG, "found COLLECTD.\n");
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_COLLECTD, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_COLLECTD, NDPI_PROTOCOL_UNKNOWN);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
static void ndpi_int_corba_add_connection(struct ndpi_detection_module_struct
|
||||
*ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_CORBA, NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CORBA, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
void ndpi_search_corba(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
@@ -45,4 +45,16 @@ void ndpi_search_corba(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CORBA);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_corba_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Corba", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_CORBA,
|
||||
ndpi_search_corba,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -22,17 +22,16 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* include files */
|
||||
#include "ndpi_protocols.h"
|
||||
#ifdef NDPI_PROTOCOL_CROSSFIRE
|
||||
|
||||
|
||||
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 */)
|
||||
{
|
||||
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_CROSSFIRE, protocol_type);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CROSSFIRE, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_crossfire_tcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -51,7 +50,7 @@ void ndpi_search_crossfire_tcp_udp(struct ndpi_detection_module_struct *ndpi_str
|
||||
&& get_u_int16_t(packet->payload, 22) == ntohs(0x7d00)
|
||||
) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_CROSSFIRE, ndpi_struct, NDPI_LOG_DEBUG, "Crossfire: found udp packet.\n");
|
||||
ndpi_int_crossfire_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_crossfire_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,7 +68,7 @@ void ndpi_search_crossfire_tcp_udp(struct ndpi_detection_module_struct *ndpi_str
|
||||
|| memcmp(packet->host_line.ptr, "www.crossfire", 13) == 0))
|
||||
) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_CROSSFIRE, ndpi_struct, NDPI_LOG_DEBUG, "Crossfire: found HTTP request.\n");
|
||||
ndpi_int_crossfire_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_int_crossfire_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -81,5 +80,15 @@ void ndpi_search_crossfire_tcp_udp(struct ndpi_detection_module_struct *ndpi_str
|
||||
}
|
||||
|
||||
|
||||
void init_crossfire_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Crossfire", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_CROSSFIRE,
|
||||
ndpi_search_crossfire_tcp_udp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 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_api.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_CSGO
|
||||
|
||||
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(NDPI_PROTOCOL_CSGO, ndpi_struct, NDPI_LOG_DEBUG, "CSGO: word %08x\n", w);
|
||||
|
||||
if (!flow->csgo_state && packet->payload_packet_len == 23 && w == 0xfffffffful) {
|
||||
if (!memcmp(packet->payload + 5, "connect0x", 9)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_CSGO, ndpi_struct, NDPI_LOG_DEBUG, "Found csgo connect0x.\n");
|
||||
flow->csgo_state++;
|
||||
memcpy(flow->csgo_strid, packet->payload + 5, 18);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (flow->csgo_state == 1 && packet->payload_packet_len >= 42 && w == 0xfffffffful) {
|
||||
if (!memcmp(packet->payload + 24, flow->csgo_strid, 18)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_CSGO, ndpi_struct, NDPI_LOG_DEBUG, "Found csgo connect0x reply.\n");
|
||||
flow->csgo_state++;
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (packet->payload_packet_len == 8 && ( w == 0x3a180000 || w == 0x39180000) ) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_CSGO, ndpi_struct, NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_CSGO, ndpi_struct, NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_CSGO, ndpi_struct, NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_CSGO, ndpi_struct, NDPI_LOG_DEBUG, "Found csgo udp 0d1d step1.\n");
|
||||
return;
|
||||
}
|
||||
if (flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_CSGO, ndpi_struct, NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_CSGO, ndpi_struct, NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_CSGO, ndpi_struct, NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_CSGO, ndpi_struct, NDPI_LOG_DEBUG, "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_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CSGO);
|
||||
}
|
||||
|
||||
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
|
||||
@@ -18,7 +18,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -29,26 +29,39 @@
|
||||
static void ndpi_int_dcerpc_add_connection(struct ndpi_detection_module_struct
|
||||
*ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DCERPC, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DCERPC, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_dcerpc(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
|
||||
if((packet->tcp != NULL)
|
||||
&& (packet->payload_packet_len > 64)
|
||||
&& ((ntohs(packet->tcp->source) == 135) || (ntohs(packet->tcp->dest) == 135))
|
||||
if((packet->tcp != NULL)
|
||||
&& (packet->payload_packet_len >= 64)
|
||||
&& (packet->payload[0] == 0x05) /* version 5 */
|
||||
&& (packet->payload[2] < 16) /* Packet type */
|
||||
) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_DCERPC, ndpi_struct, NDPI_LOG_DEBUG, "DCERPC match\n");
|
||||
&& (((packet->payload[9]<<8) | packet->payload[8]) == packet->payload_packet_len) /* Packet Length */
|
||||
) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_DCERPC, ndpi_struct, NDPI_LOG_DEBUG, "DCERPC match\n");
|
||||
ndpi_int_dcerpc_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DCERPC);
|
||||
if(packet->payload_packet_len>1){
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DCERPC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_dcerpc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("DCE_RPC", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_DCERPC,
|
||||
ndpi_search_dcerpc,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+120
-23
@@ -1,11 +1,7 @@
|
||||
/*
|
||||
* dhcp.c
|
||||
*
|
||||
* 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
|
||||
* Copyright (C) 2016 - 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
|
||||
@@ -19,7 +15,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -27,34 +23,135 @@
|
||||
|
||||
#ifdef NDPI_PROTOCOL_DHCP
|
||||
|
||||
/* 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)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DHCP, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DHCP, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
// struct ndpi_id_struct *src=ndpi_struct->src;
|
||||
// struct ndpi_id_struct *dst=ndpi_struct->dst;
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
/* this detection also works for asymmetric dhcp traffic */
|
||||
// struct ndpi_id_struct *src=ndpi_struct->src;
|
||||
// struct ndpi_id_struct *dst=ndpi_struct->dst;
|
||||
|
||||
/*check standard DHCP 0.0.0.0:68 -> 255.255.255.255:67 */
|
||||
if (packet->payload_packet_len >= 244 && (packet->udp->source == htons(67)
|
||||
|| packet->udp->source == htons(68))
|
||||
&& (packet->udp->dest == htons(67) || packet->udp->dest == htons(68))
|
||||
&& get_u_int32_t(packet->payload, 236) == htonl(0x63825363)
|
||||
&& get_u_int16_t(packet->payload, 240) == htons(0x3501)) {
|
||||
/* this detection also works for asymmetric dhcp traffic */
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_DHCP, ndpi_struct, NDPI_LOG_DEBUG, "DHCP request\n");
|
||||
/*check standard DHCP 0.0.0.0:68 -> 255.255.255.255:67 */
|
||||
if(packet->udp) {
|
||||
dhcp_packet_t *dhcp = (dhcp_packet_t*)packet->payload;
|
||||
|
||||
ndpi_int_dhcp_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
if((packet->payload_packet_len >= 244)
|
||||
&& (packet->udp->source == htons(67) || packet->udp->source == htons(68))
|
||||
&& (packet->udp->dest == htons(67) || packet->udp->dest == htons(68))
|
||||
&& (dhcp->magic == htonl(DHCP_OPTION_MAGIC_NUMBER))) {
|
||||
int i = 0, foundValidMsgType = 0;
|
||||
|
||||
while(i < DHCP_VEND_LEN) {
|
||||
u_int8_t id = dhcp->options[i];
|
||||
|
||||
if(id == 0xFF)
|
||||
break;
|
||||
else {
|
||||
u_int8_t len = dhcp->options[i+1];
|
||||
|
||||
if(len == 0) break;
|
||||
|
||||
#ifdef DHCP_DEBUG
|
||||
printf("[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,
|
||||
hex_len = ndpi_min(len * 2, sizeof(flow->protos.dhcp.fingerprint));
|
||||
|
||||
for(idx=0; idx<len; idx++) {
|
||||
snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
|
||||
sizeof(flow->protos.dhcp.fingerprint)-offset-1,
|
||||
"%02X", dhcp->options[i+2+idx] & 0xFF);
|
||||
offset += 2;
|
||||
}
|
||||
} 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
|
||||
printf("[DHCP] ");
|
||||
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(NDPI_PROTOCOL_DHCP, ndpi_struct, NDPI_LOG_DEBUG, "DHCP found\n");
|
||||
ndpi_int_dhcp_add_connection(ndpi_struct, flow);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DHCP);
|
||||
}
|
||||
|
||||
|
||||
void init_dhcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("DHCP", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_DHCP,
|
||||
ndpi_search_dhcp_udp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DHCP);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,7 @@ static void ndpi_int_dhcpv6_add_connection(struct ndpi_detection_module_struct *
|
||||
struct ndpi_flow_struct *flow)
|
||||
{
|
||||
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DHCPV6, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DHCPV6, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_dhcpv6_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -57,4 +57,16 @@ void ndpi_search_dhcpv6_udp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DHCPV6);
|
||||
}
|
||||
|
||||
|
||||
void init_dhcpv6_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("DHCPV6", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_DHCPV6,
|
||||
ndpi_search_dhcpv6_udp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V6_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -81,7 +81,7 @@ static void ndpi_int_directconnect_add_connection(struct ndpi_detection_module_s
|
||||
struct ndpi_id_struct *src = flow->src;
|
||||
struct ndpi_id_struct *dst = flow->dst;
|
||||
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
|
||||
|
||||
if (src != NULL) {
|
||||
src->directconnect_last_safe_access_time = packet->tick_timestamp;
|
||||
@@ -168,7 +168,7 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
|
||||
if ((u_int32_t)
|
||||
(packet->tick_timestamp -
|
||||
src->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
|
||||
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_REAL_PROTOCOL);
|
||||
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));
|
||||
@@ -184,7 +184,7 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
|
||||
if ((u_int32_t)
|
||||
(packet->tick_timestamp -
|
||||
src->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
|
||||
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_REAL_PROTOCOL);
|
||||
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));
|
||||
@@ -204,7 +204,7 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
|
||||
if ((u_int32_t)
|
||||
(packet->tick_timestamp -
|
||||
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_REAL_PROTOCOL);
|
||||
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));
|
||||
@@ -220,7 +220,7 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
|
||||
if ((u_int32_t)
|
||||
(packet->tick_timestamp -
|
||||
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_REAL_PROTOCOL);
|
||||
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));
|
||||
@@ -352,7 +352,7 @@ static void ndpi_search_directconnect_udp(struct ndpi_detection_module_struct
|
||||
(packet->tick_timestamp -
|
||||
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
|
||||
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_REAL_PROTOCOL);
|
||||
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));
|
||||
@@ -471,4 +471,17 @@ void ndpi_search_directconnect(struct ndpi_detection_module_struct
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_directconnect_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("DirectConnect", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_DIRECTCONNECT,
|
||||
ndpi_search_directconnect,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@ static void ndpi_int_direct_download_link_add_connection(struct ndpi_detection_m
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, NDPI_PROTOCOL_UNKNOWN);
|
||||
|
||||
flow->l4.tcp.ddlink_server_direction = packet->packet_direction;
|
||||
}
|
||||
@@ -709,23 +709,10 @@ void ndpi_search_direct_download_link_tcp(struct ndpi_detection_module_struct *n
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
// struct ndpi_id_struct *src=ndpi_struct->src;
|
||||
// struct ndpi_id_struct *dst=ndpi_struct->dst;
|
||||
#if 0
|
||||
if (ndpi_struct->direct_download_link_counter_callback != NULL) {
|
||||
if (packet->detected_protocol == NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK) {
|
||||
/* skip packets not requests from the client to the server */
|
||||
if (packet->packet_direction == flow->l4.tcp.ddlink_server_direction) {
|
||||
search_ddl_domains(ndpi_struct, flow); // do the detection again in order to get the URL in keep alive streams
|
||||
} else {
|
||||
// just count the packet
|
||||
ndpi_struct->direct_download_link_counter_callback(flow->hash_id_number, packet->l3_packet_len);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
// do not detect again if it is already ddl
|
||||
/* 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 */
|
||||
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK) {
|
||||
if (search_ddl_domains(ndpi_struct, flow) != 0) {
|
||||
return;
|
||||
@@ -734,4 +721,16 @@ void ndpi_search_direct_download_link_tcp(struct ndpi_detection_module_struct *n
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void init_directdownloadlink_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Direct_Download_Link", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK,
|
||||
ndpi_search_direct_download_link_tcp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
+172
-223
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* dns.c
|
||||
*
|
||||
* Copyright (C) 2012-15 - ntop.org
|
||||
* Copyright (C) 2012-16 - 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
|
||||
@@ -21,11 +21,26 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ndpi_protocols.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_DNS
|
||||
|
||||
#define FLAGS_MASK 0x8000
|
||||
|
||||
/* #define DNS_DEBUG 1 */
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
static u_int16_t get16(int *i, const u_int8_t *payload) {
|
||||
u_int16_t v = *(u_int16_t*)&payload[*i];
|
||||
|
||||
(*i) += 2;
|
||||
|
||||
return(ntohs(v));
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
static u_int getNameLength(u_int i, const u_int8_t *payload, u_int payloadLen) {
|
||||
if(payload[i] == 0x00)
|
||||
return(1);
|
||||
@@ -34,267 +49,201 @@ static u_int getNameLength(u_int i, const u_int8_t *payload, u_int payloadLen) {
|
||||
else {
|
||||
u_int8_t len = payload[i];
|
||||
u_int8_t off = len + 1;
|
||||
|
||||
|
||||
if(off == 0) /* Bad packet */
|
||||
return(0);
|
||||
else
|
||||
return(off + getNameLength(i+off, payload, payloadLen));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
static char* ndpi_intoa_v4(unsigned int addr, char* buf, u_short bufLen) {
|
||||
char *cp, *retStr;
|
||||
uint byte;
|
||||
int n;
|
||||
|
||||
cp = &buf[bufLen];
|
||||
*--cp = '\0';
|
||||
|
||||
n = 4;
|
||||
do {
|
||||
byte = addr & 0xff;
|
||||
*--cp = byte % 10 + '0';
|
||||
byte /= 10;
|
||||
if(byte > 0) {
|
||||
*--cp = byte % 10 + '0';
|
||||
byte /= 10;
|
||||
if(byte > 0)
|
||||
*--cp = byte + '0';
|
||||
}
|
||||
*--cp = '.';
|
||||
addr >>= 8;
|
||||
} while (--n > 0);
|
||||
|
||||
/* Convert the string to lowercase */
|
||||
retStr = (char*)(cp+1);
|
||||
|
||||
return(retStr);
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
static u_int16_t get16(int *i, const u_int8_t *payload) {
|
||||
u_int16_t v = *(u_int16_t*)&payload[*i];
|
||||
|
||||
(*i) += 2;
|
||||
|
||||
return(ntohs(v));
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
|
||||
struct dns_packet_header {
|
||||
u_int16_t transaction_id, flags, num_queries, answer_rrs, authority_rrs, additional_rrs;
|
||||
} __attribute__((packed));
|
||||
|
||||
void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int16_t dport = 0, sport = 0;
|
||||
void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
int x;
|
||||
u_int8_t is_query;
|
||||
u_int16_t s_port = 0, d_port = 0;
|
||||
|
||||
#define NDPI_MAX_DNS_REQUESTS 16
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "search DNS.\n");
|
||||
|
||||
if (packet->udp != NULL) {
|
||||
sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
|
||||
NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "calculated dport over UDP.\n");
|
||||
} else if(packet->tcp != NULL) {
|
||||
sport = ntohs(packet->tcp->source), dport = ntohs(packet->tcp->dest);
|
||||
NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "calculated dport over tcp.\n");
|
||||
|
||||
if(flow->packet.udp != NULL) {
|
||||
s_port = ntohs(flow->packet.udp->source);
|
||||
d_port = ntohs(flow->packet.udp->dest);
|
||||
x = 0;
|
||||
} else if(flow->packet.tcp != NULL) /* pkt size > 512 bytes */ {
|
||||
s_port = ntohs(flow->packet.tcp->source);
|
||||
d_port = ntohs(flow->packet.tcp->dest);
|
||||
x = 2;
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
if(((dport == 53) || (sport == 53) || (dport == 5355))
|
||||
&& (packet->payload_packet_len > sizeof(struct dns_packet_header))) {
|
||||
int i = packet->tcp ? 2 : 0;
|
||||
struct dns_packet_header header, *dns = (struct dns_packet_header*)&packet->payload[i];
|
||||
u_int8_t is_query, ret_code, is_dns = 0;
|
||||
u_int32_t a_record[NDPI_MAX_DNS_REQUESTS] = { 0 }, query_offset, num_a_records = 0;
|
||||
if((s_port == 53 || d_port == 53 || d_port == 5355)
|
||||
&& (flow->packet.payload_packet_len > sizeof(struct ndpi_dns_packet_header)+x)) {
|
||||
struct ndpi_dns_packet_header dns_header;
|
||||
int invalid = 0;
|
||||
|
||||
header.flags = ntohs(dns->flags);
|
||||
header.transaction_id = ntohs(dns->transaction_id);
|
||||
header.num_queries = ntohs(dns->num_queries);
|
||||
header.answer_rrs = ntohs(dns->answer_rrs);
|
||||
header.authority_rrs = ntohs(dns->authority_rrs);
|
||||
header.additional_rrs = ntohs(dns->additional_rrs);
|
||||
is_query = (header.flags & 0x8000) ? 0 : 1;
|
||||
ret_code = is_query ? 0 : (header.flags & 0x0F);
|
||||
i += sizeof(struct dns_packet_header);
|
||||
query_offset = i;
|
||||
memcpy(&dns_header, (struct ndpi_dns_packet_header*) &flow->packet.payload[x], sizeof(struct ndpi_dns_packet_header));
|
||||
dns_header.tr_id = ntohs(dns_header.tr_id);
|
||||
dns_header.flags = ntohs(dns_header.flags);
|
||||
dns_header.num_queries = ntohs(dns_header.num_queries);
|
||||
dns_header.num_answers = ntohs(dns_header.num_answers);
|
||||
dns_header.authority_rrs = ntohs(dns_header.authority_rrs);
|
||||
dns_header.additional_rrs = ntohs(dns_header.additional_rrs);
|
||||
x += sizeof(struct ndpi_dns_packet_header);
|
||||
|
||||
if(is_query) {
|
||||
/* DNS Request */
|
||||
if((header.num_queries > 0) && (header.num_queries <= NDPI_MAX_DNS_REQUESTS)
|
||||
&& (((header.flags & 0x2800) == 0x2800 /* Dynamic DNS Update */)
|
||||
|| ((header.answer_rrs == 0) && (header.authority_rrs == 0)))) {
|
||||
/* This is a good query */
|
||||
is_dns = 1;
|
||||
/* 0x0000 QUERY */
|
||||
if((dns_header.flags & FLAGS_MASK) == 0x0000)
|
||||
is_query = 1;
|
||||
/* 0x8000 RESPONSE */
|
||||
else if((dns_header.flags & FLAGS_MASK) == 0x8000)
|
||||
is_query = 0;
|
||||
else
|
||||
invalid = 1;
|
||||
|
||||
if(header.num_queries > 0) {
|
||||
while(i < packet->payload_packet_len) {
|
||||
if(packet->payload[i] == '\0') {
|
||||
i++;
|
||||
flow->protos.dns.query_type = get16(&i, packet->payload);
|
||||
if(!invalid) {
|
||||
if(is_query) {
|
||||
/* DNS Request */
|
||||
if((dns_header.num_queries > 0) && (dns_header.num_queries <= NDPI_MAX_DNS_REQUESTS)
|
||||
&& (((dns_header.flags & 0x2800) == 0x2800 /* Dynamic DNS Update */)
|
||||
|| ((dns_header.num_answers == 0) && (dns_header.authority_rrs == 0)))) {
|
||||
/* This is a good query */
|
||||
|
||||
if(dns_header.num_queries > 0) {
|
||||
while(x < flow->packet.payload_packet_len) {
|
||||
if(flow->packet.payload[x] == '\0') {
|
||||
x++;
|
||||
flow->protos.dns.query_type = get16(&x, flow->packet.payload);
|
||||
#ifdef DNS_DEBUG
|
||||
printf("[%s:%d] query_type=%2d\n", __FILE__, __LINE__, flow->protos.dns.query_type);
|
||||
#endif
|
||||
break;
|
||||
} else
|
||||
i++;
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* DNS Reply */
|
||||
|
||||
flow->server_id = flow->dst;
|
||||
|
||||
if((header.num_queries <= NDPI_MAX_DNS_REQUESTS) /* Don't assume that num_queries must be zero */
|
||||
&& (((header.answer_rrs > 0) && (header.answer_rrs <= NDPI_MAX_DNS_REQUESTS))
|
||||
|| ((header.authority_rrs > 0) && (header.authority_rrs <= NDPI_MAX_DNS_REQUESTS))
|
||||
|| ((header.additional_rrs > 0) && (header.additional_rrs <= NDPI_MAX_DNS_REQUESTS)))
|
||||
) {
|
||||
/* This is a good reply */
|
||||
is_dns = 1;
|
||||
|
||||
i++;
|
||||
|
||||
if(packet->payload[i] != '\0') {
|
||||
while((i < packet->payload_packet_len)
|
||||
&& (packet->payload[i] != '\0')) {
|
||||
i++;
|
||||
}
|
||||
} else
|
||||
invalid = 1;
|
||||
|
||||
} else {
|
||||
/* DNS Reply */
|
||||
|
||||
flow->protos.dns.reply_code = dns_header.flags & 0x0F;
|
||||
|
||||
if((dns_header.num_queries > 0) && (dns_header.num_queries <= NDPI_MAX_DNS_REQUESTS) /* Don't assume that num_queries must be zero */
|
||||
&& (((dns_header.num_answers > 0) && (dns_header.num_answers <= NDPI_MAX_DNS_REQUESTS))
|
||||
|| ((dns_header.authority_rrs > 0) && (dns_header.authority_rrs <= NDPI_MAX_DNS_REQUESTS))
|
||||
|| ((dns_header.additional_rrs > 0) && (dns_header.additional_rrs <= NDPI_MAX_DNS_REQUESTS)))
|
||||
) {
|
||||
/* This is a good reply */
|
||||
if(ndpi_struct->dns_dissect_response) {
|
||||
x++;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
i += 4;
|
||||
|
||||
if(header.answer_rrs > 0) {
|
||||
u_int16_t rsp_type /*, rsp_class */;
|
||||
u_int16_t num;
|
||||
|
||||
for(num = 0; num < header.answer_rrs; num++) {
|
||||
u_int16_t data_len;
|
||||
|
||||
if((i+6) >= packet->payload_packet_len) {
|
||||
break;
|
||||
if(flow->packet.payload[x] != '\0') {
|
||||
while((x < flow->packet.payload_packet_len)
|
||||
&& (flow->packet.payload[x] != '\0')) {
|
||||
x++;
|
||||
}
|
||||
|
||||
x++;
|
||||
}
|
||||
|
||||
if((data_len = getNameLength(i, packet->payload, packet->payload_packet_len)) == 0) {
|
||||
break;
|
||||
} else
|
||||
i += data_len;
|
||||
|
||||
rsp_type = get16(&i, packet->payload);
|
||||
// rsp_class = get16(&i, packet->payload);
|
||||
x += 4;
|
||||
|
||||
i += 4;
|
||||
data_len = get16(&i, packet->payload);
|
||||
if(dns_header.num_answers > 0) {
|
||||
u_int16_t rsp_type;
|
||||
u_int16_t num;
|
||||
|
||||
if((data_len <= 1) || (data_len > (packet->payload_packet_len-i))) {
|
||||
break;
|
||||
}
|
||||
for(num = 0; num < dns_header.num_answers; num++) {
|
||||
u_int16_t data_len;
|
||||
|
||||
if((x+6) >= flow->packet.payload_packet_len) {
|
||||
break;
|
||||
}
|
||||
|
||||
flow->protos.dns.rsp_type = rsp_type;
|
||||
|
||||
if(rsp_type == 1 /* A */) {
|
||||
if(data_len == 4) {
|
||||
u_int32_t v = ntohl(*((u_int32_t*)&packet->payload[i]));
|
||||
|
||||
if(num_a_records < (NDPI_MAX_DNS_REQUESTS-1))
|
||||
a_record[num_a_records++] = v;
|
||||
else
|
||||
break; /* One record is enough */
|
||||
if((data_len = getNameLength(x, flow->packet.payload, flow->packet.payload_packet_len)) == 0) {
|
||||
break;
|
||||
} else
|
||||
x += data_len;
|
||||
|
||||
rsp_type = get16(&x, flow->packet.payload);
|
||||
flow->protos.dns.rsp_type = rsp_type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(data_len == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
i += data_len;
|
||||
} /* for */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((header.num_queries <= NDPI_MAX_DNS_REQUESTS)
|
||||
&& ((header.answer_rrs == 0)
|
||||
|| (header.authority_rrs == 0)
|
||||
|| (header.additional_rrs == 0))
|
||||
&& (ret_code != 0 /* 0 == OK */)
|
||||
) {
|
||||
/* This is a good reply */
|
||||
is_dns = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_dns) {
|
||||
int j = 0;
|
||||
|
||||
flow->protos.dns.num_queries = (u_int8_t)header.num_queries,
|
||||
flow->protos.dns.num_answers = (u_int8_t)(header.answer_rrs+header.authority_rrs+header.additional_rrs),
|
||||
flow->protos.dns.ret_code = ret_code;
|
||||
|
||||
i = query_offset+1;
|
||||
|
||||
while((i < packet->payload_packet_len)
|
||||
&& (j < (sizeof(flow->host_server_name)-1))
|
||||
&& (packet->payload[i] != '\0')) {
|
||||
flow->host_server_name[j] = tolower(packet->payload[i]);
|
||||
if(flow->host_server_name[j] < ' ')
|
||||
flow->host_server_name[j] = '.';
|
||||
j++, i++;
|
||||
if(invalid) {
|
||||
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;
|
||||
}
|
||||
|
||||
if(a_record[0] != 0) {
|
||||
char a_buf[32];
|
||||
int i;
|
||||
/* extract host name server */
|
||||
int j = 0, max_len = sizeof(flow->host_server_name)-1, off = sizeof(struct ndpi_dns_packet_header) + 1;
|
||||
|
||||
for(i=0; i<num_a_records; i++) {
|
||||
j += snprintf((char*)&flow->host_server_name[j], sizeof(flow->host_server_name)-1-j, "%s%s",
|
||||
(i == 0) ? "@" : ";",
|
||||
ndpi_intoa_v4(a_record[i], a_buf, sizeof(a_buf)));
|
||||
}
|
||||
while(off < flow->packet.payload_packet_len && flow->packet.payload[off] != '\0') {
|
||||
flow->host_server_name[j] = flow->packet.payload[off];
|
||||
if(j < max_len) {
|
||||
if(flow->host_server_name[j] < ' ')
|
||||
flow->host_server_name[j] = '.';
|
||||
j++;
|
||||
} else
|
||||
break;
|
||||
|
||||
off++;
|
||||
}
|
||||
|
||||
|
||||
if(is_query && ndpi_struct->dns_dissect_response)
|
||||
return; /* The response will set the verdict */
|
||||
|
||||
flow->host_server_name[j] = '\0';
|
||||
|
||||
if(j > 0) {
|
||||
#ifdef DEBUG
|
||||
printf("==> %s\n", flow->host_server_name);
|
||||
flow->protos.dns.num_queries = (u_int8_t)dns_header.num_queries,
|
||||
flow->protos.dns.num_answers = (u_int8_t) (dns_header.num_answers + dns_header.authority_rrs + dns_header.additional_rrs);
|
||||
|
||||
if(j > 0)
|
||||
ndpi_match_host_subprotocol(ndpi_struct, flow,
|
||||
(char *)flow->host_server_name,
|
||||
strlen((const char*)flow->host_server_name),
|
||||
NDPI_PROTOCOL_DNS);
|
||||
|
||||
#ifdef DNS_DEBUG
|
||||
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.reply_code, flow->protos.dns.rsp_type, flow->host_server_name
|
||||
);
|
||||
#endif
|
||||
|
||||
if(ndpi_struct->match_dns_host_names)
|
||||
ndpi_match_string_subprotocol(ndpi_struct, flow,
|
||||
(char *)flow->host_server_name,
|
||||
strlen((const char*)flow->host_server_name));
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
memcpy(&flow->protos.dns.query_type, &packet->payload[i], 2);
|
||||
flow->protos.dns.query_type = ntohs(flow->protos.dns.query_type), i += 2;
|
||||
|
||||
memcpy(&flow->protos.dns.query_class, &packet->payload[i], 2);
|
||||
flow->protos.dns.query_class = ntohs(flow->protos.dns.query_class), i += 2;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("%s [type=%04X][class=%04X]\n", flow->host_server_name, flow->protos.dns.query_type, flow->protos.dns.query_class);
|
||||
#endif
|
||||
|
||||
if(packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
|
||||
/*
|
||||
Do not set the protocol with DNS if ndpi_match_string_subprotocol() has
|
||||
|
||||
if(flow->packet.detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
|
||||
/**
|
||||
Do not set the protocol with DNS if ndpi_match_host_subprotocol() has
|
||||
matched a subprotocol
|
||||
*/
|
||||
**/
|
||||
NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "found DNS.\n");
|
||||
ndpi_int_add_connection(ndpi_struct, flow, (dport == 5355) ? NDPI_PROTOCOL_LLMNR : NDPI_PROTOCOL_DNS, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, (d_port == 5355) ? NDPI_PROTOCOL_LLMNR : NDPI_PROTOCOL_DNS, NDPI_PROTOCOL_UNKNOWN);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
flow->protos.dns.bad_packet = 1;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init_dns_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("DNS", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_DNS,
|
||||
ndpi_search_dns,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+117
-106
@@ -30,120 +30,131 @@
|
||||
|
||||
static void ndpi_dofus_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DOFUS, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DOFUS, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
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_id_struct *src=ndpi_struct->src;
|
||||
// struct ndpi_id_struct *dst=ndpi_struct->dst;
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
// struct ndpi_id_struct *src=ndpi_struct->src;
|
||||
// struct ndpi_id_struct *dst=ndpi_struct->dst;
|
||||
|
||||
|
||||
/* Dofus v 1.x.x */
|
||||
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, 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);
|
||||
return;
|
||||
}
|
||||
if (flow->l4.tcp.dofus_stage == 0 && packet->payload_packet_len == 3 && memcmp(packet->payload, "HG", 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 == 35 && memcmp(packet->payload, "HC", 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 && packet->payload[0] == 'A'
|
||||
&& (packet->payload[1] == 'x' || packet->payload[1] == 'X')
|
||||
&& 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 == 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) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
|
||||
ndpi_dofus_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (flow->l4.tcp.dofus_stage == 1 && packet->payload_packet_len == 5
|
||||
&& 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);
|
||||
return;
|
||||
}
|
||||
/* end Dofus 1.x.x */
|
||||
/* Dofus v 1.x.x */
|
||||
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, 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);
|
||||
return;
|
||||
}
|
||||
if (flow->l4.tcp.dofus_stage == 0 && packet->payload_packet_len == 3 && memcmp(packet->payload, "HG", 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 == 35 && memcmp(packet->payload, "HC", 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 && packet->payload[0] == 'A'
|
||||
&& (packet->payload[1] == 'x' || packet->payload[1] == 'X')
|
||||
&& 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 == 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) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
|
||||
ndpi_dofus_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (flow->l4.tcp.dofus_stage == 1 && packet->payload_packet_len == 5
|
||||
&& 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);
|
||||
return;
|
||||
}
|
||||
/* end Dofus 1.x.x */
|
||||
|
||||
|
||||
/* Dofus 2.0 */
|
||||
if ((packet->payload_packet_len == 11 || packet->payload_packet_len == 13 || packet->payload_packet_len == 49)
|
||||
&& get_u_int32_t(packet->payload, 0) == ntohl(0x00050800)
|
||||
&& get_u_int16_t(packet->payload, 4) == ntohs(0x0005)
|
||||
&& get_u_int16_t(packet->payload, 8) == ntohs(0x0005)
|
||||
&& packet->payload[10] == 0x18) {
|
||||
if (packet->payload_packet_len == 13
|
||||
&& get_u_int16_t(packet->payload, packet->payload_packet_len - 2) != ntohs(0x0194)) {
|
||||
goto exclude;
|
||||
}
|
||||
if (packet->payload_packet_len == 49 && ntohs(get_u_int16_t(packet->payload, 15)) + 17 != packet->payload_packet_len) {
|
||||
goto exclude;
|
||||
}
|
||||
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
|
||||
ndpi_dofus_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len >= 41 && get_u_int16_t(packet->payload, 0) == ntohs(0x01b9) && packet->payload[2] == 0x26) {
|
||||
u_int16_t len, len2;
|
||||
len = ntohs(get_u_int16_t(packet->payload, 3));
|
||||
if ((len + 5 + 2) > packet->payload_packet_len)
|
||||
goto exclude;
|
||||
len2 = ntohs(get_u_int16_t(packet->payload, 5 + 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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (packet->payload_packet_len == 56
|
||||
&& memcmp(packet->payload, "\x00\x11\x35\x02\x03\x00\x93\x96\x01\x00", 10) == 0) {
|
||||
u_int16_t len, len2;
|
||||
len = ntohs(get_u_int16_t(packet->payload, 10));
|
||||
if ((len + 12 + 2) > packet->payload_packet_len)
|
||||
goto exclude;
|
||||
len2 = ntohs(get_u_int16_t(packet->payload, 12 + len));
|
||||
if ((12 + len + 2 + len2 + 1) > packet->payload_packet_len)
|
||||
goto exclude;
|
||||
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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
exclude:
|
||||
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "exclude dofus.\n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DOFUS);
|
||||
/* Dofus 2.0 */
|
||||
if ((packet->payload_packet_len == 11 || packet->payload_packet_len == 13 || packet->payload_packet_len == 49)
|
||||
&& get_u_int32_t(packet->payload, 0) == ntohl(0x00050800)
|
||||
&& get_u_int16_t(packet->payload, 4) == ntohs(0x0005)
|
||||
&& get_u_int16_t(packet->payload, 8) == ntohs(0x0005)
|
||||
&& packet->payload[10] == 0x18) {
|
||||
if (packet->payload_packet_len == 13
|
||||
&& get_u_int16_t(packet->payload, packet->payload_packet_len - 2) != ntohs(0x0194)) {
|
||||
goto exclude;
|
||||
}
|
||||
if (packet->payload_packet_len == 49 && ntohs(get_u_int16_t(packet->payload, 15)) + 17 != packet->payload_packet_len) {
|
||||
goto exclude;
|
||||
}
|
||||
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
|
||||
ndpi_dofus_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len >= 41 && get_u_int16_t(packet->payload, 0) == ntohs(0x01b9) && packet->payload[2] == 0x26) {
|
||||
u_int16_t len, len2;
|
||||
len = ntohs(get_u_int16_t(packet->payload, 3));
|
||||
if ((len + 5 + 2) > packet->payload_packet_len)
|
||||
goto exclude;
|
||||
len2 = ntohs(get_u_int16_t(packet->payload, 5 + 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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (packet->payload_packet_len == 56
|
||||
&& memcmp(packet->payload, "\x00\x11\x35\x02\x03\x00\x93\x96\x01\x00", 10) == 0) {
|
||||
u_int16_t len, len2;
|
||||
len = ntohs(get_u_int16_t(packet->payload, 10));
|
||||
if ((len + 12 + 2) > packet->payload_packet_len)
|
||||
goto exclude;
|
||||
len2 = ntohs(get_u_int16_t(packet->payload, 12 + len));
|
||||
if ((12 + len + 2 + len2 + 1) > packet->payload_packet_len)
|
||||
goto exclude;
|
||||
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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
exclude:
|
||||
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "exclude dofus.\n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DOFUS);
|
||||
}
|
||||
|
||||
|
||||
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_PROTOCOL_DOFUS,
|
||||
ndpi_search_dofus,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* drda.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_api.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_DRDA
|
||||
|
||||
struct ndpi_drda_hdr {
|
||||
u_int16_t length;
|
||||
u_int8_t magic;
|
||||
u_int8_t format;
|
||||
u_int16_t correlID;
|
||||
u_int16_t length2;
|
||||
u_int16_t code_pnt;
|
||||
};
|
||||
|
||||
|
||||
void ndpi_search_drda(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct * packet = &flow->packet;
|
||||
u_int16_t payload_len = packet->payload_packet_len;
|
||||
u_int count = 0; // prevent integer overflow
|
||||
|
||||
if(packet->tcp != NULL) {
|
||||
|
||||
/* check port */
|
||||
if(payload_len >= sizeof(struct ndpi_drda_hdr)) {
|
||||
|
||||
struct ndpi_drda_hdr * drda = (struct ndpi_drda_hdr *) packet->payload;
|
||||
|
||||
u_int16_t len = ntohs(drda->length);
|
||||
|
||||
/* check first header */
|
||||
if(len != ntohs(drda->length2) + 6 ||
|
||||
drda->magic != 0xd0)
|
||||
goto no_drda;
|
||||
|
||||
/* check if there are more drda headers */
|
||||
if(payload_len > len) {
|
||||
|
||||
count = len;
|
||||
|
||||
while(count + sizeof(struct ndpi_drda_hdr) < payload_len)
|
||||
{
|
||||
/* update info */
|
||||
drda = (struct ndpi_drda_hdr *)(packet->payload + count);
|
||||
len = ntohs(drda->length);
|
||||
|
||||
if(len != ntohs(drda->length2) + 6 ||
|
||||
drda->magic != 0xd0)
|
||||
goto no_drda;
|
||||
|
||||
count += len;
|
||||
}
|
||||
if(count != payload_len) goto no_drda;
|
||||
}
|
||||
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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
no_drda:
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/* ***************************************************************** */
|
||||
|
||||
|
||||
void init_drda_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id,
|
||||
NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("DRDA", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_DRDA,
|
||||
ndpi_search_drda,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_TCP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif /* NDPI_PROTOCOL_DRDA */
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* dropbox.c
|
||||
*
|
||||
* Copyright (C) 2011-13 by ntop.org
|
||||
* Copyright (C) 2012-16 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
|
||||
@@ -25,13 +25,15 @@
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_DROPBOX
|
||||
|
||||
#define DB_LSP_PORT 17500
|
||||
|
||||
|
||||
static void ndpi_int_dropbox_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
u_int8_t due_to_correlation)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_DROPBOX,
|
||||
due_to_correlation ? NDPI_CORRELATED_PROTOCOL : NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DROPBOX, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,12 +44,13 @@ static void ndpi_check_dropbox(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
if(packet->udp != NULL) {
|
||||
u_int16_t dropbox_port = htons(17500);
|
||||
u_int16_t dropbox_port = htons(DB_LSP_PORT);
|
||||
|
||||
if((packet->udp->source == dropbox_port)
|
||||
&& (packet->udp->dest == dropbox_port)) {
|
||||
if(payload_len > 2) {
|
||||
if(strncmp((const char *)packet->payload, "{\"", 2) == 0) {
|
||||
if(strncmp((const char *)packet->payload, "{\"host_int\"", 11) == 0) {
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_DROPBOX, ndpi_struct, NDPI_LOG_DEBUG, "Found dropbox.\n");
|
||||
ndpi_int_dropbox_add_connection(ndpi_struct, flow, 0);
|
||||
return;
|
||||
@@ -74,4 +77,18 @@ void ndpi_search_dropbox(struct ndpi_detection_module_struct *ndpi_struct, struc
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_dropbox_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("DROPBOX", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_DROPBOX,
|
||||
ndpi_search_dropbox,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* eaq.c
|
||||
*
|
||||
* Copyright (C) 2015 - 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
EAQ: Entitade Aferidora da Qualidade de Banda Larga
|
||||
|
||||
http://www.brasilbandalarga.com.br
|
||||
*/
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#define EAQ_DEFAULT_PORT 6000
|
||||
#define EAQ_DEFAULT_SIZE 16
|
||||
|
||||
#ifdef NDPI_PROTOCOL_EAQ
|
||||
static void ndpi_int_eaq_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow) {
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_EAQ, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
void ndpi_search_eaq(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
u_int16_t sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
|
||||
|
||||
if((packet->payload_packet_len != EAQ_DEFAULT_SIZE)
|
||||
|| ((sport != EAQ_DEFAULT_PORT) && (dport != EAQ_DEFAULT_PORT))) {
|
||||
exclude_eaq:
|
||||
NDPI_LOG(NDPI_PROTOCOL_EAQ, ndpi_struct, NDPI_LOG_DEBUG, "Exclude eaq.\n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_EAQ);
|
||||
return;
|
||||
}
|
||||
|
||||
if(packet->udp != NULL) {
|
||||
u_int32_t seq = (packet->payload[0] * 1000) + (packet->payload[1] * 100) + (packet->payload[2] * 10) + packet->payload[3];
|
||||
|
||||
if(flow->l4.udp.eaq_pkt_id == 0)
|
||||
flow->l4.udp.eaq_sequence = seq;
|
||||
else {
|
||||
if((flow->l4.udp.eaq_sequence == seq) || ((flow->l4.udp.eaq_sequence+1) == seq)) {
|
||||
; /* Looks good */
|
||||
} else
|
||||
goto exclude_eaq;
|
||||
}
|
||||
|
||||
if(++flow->l4.udp.eaq_pkt_id == 4) {
|
||||
/* We have collected enough packets so we assume it's EAQ */
|
||||
NDPI_LOG(NDPI_PROTOCOL_EAQ, ndpi_struct, NDPI_LOG_DEBUG, "found eaq.\n");
|
||||
ndpi_int_eaq_add_connection(ndpi_struct, flow);
|
||||
}
|
||||
} else
|
||||
goto exclude_eaq;
|
||||
}
|
||||
|
||||
|
||||
void init_eaq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("EAQ", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_EAQ,
|
||||
ndpi_search_eaq,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#ifdef NDPI_PROTOCOL_EDONKEY
|
||||
static void ndpi_int_edonkey_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_EDONKEY, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_EDONKEY, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
static int ndpi_edonkey_payload_check(const u_int8_t *data, u_int32_t len) {
|
||||
@@ -208,4 +208,17 @@ void ndpi_search_edonkey(struct ndpi_detection_module_struct *ndpi_struct, struc
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_edonkey_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("eDonkey", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_EDONKEY,
|
||||
ndpi_search_edonkey,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
static void ndpi_int_fasttrack_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FASTTRACK, NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FASTTRACK, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,9 @@ void ndpi_search_fasttrack_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
// struct ndpi_id_struct *src=ndpi_struct->src;
|
||||
// struct ndpi_id_struct *dst=ndpi_struct->dst;
|
||||
|
||||
if (packet->payload_packet_len > 6 && ntohs(get_u_int16_t(packet->payload, packet->payload_packet_len - 2)) == 0x0d0a) {
|
||||
if ( (packet->payload != NULL)
|
||||
&& (packet->payload_packet_len > 6)
|
||||
&& (ntohs(get_u_int16_t(packet->payload, packet->payload_packet_len - 2)) == 0x0d0a)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_FASTTRACK, ndpi_struct, NDPI_LOG_TRACE, "detected 0d0a at the end of the packet.\n");
|
||||
|
||||
if (memcmp(packet->payload, "GIVE ", 5) == 0 && packet->payload_packet_len >= 8) {
|
||||
@@ -79,4 +81,18 @@ void ndpi_search_fasttrack_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
void init_fasttrack_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("FastTrack", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_FASTTRACK,
|
||||
ndpi_search_fasttrack_tcp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* include files */
|
||||
#include "ndpi_protocols.h"
|
||||
#ifdef NDPI_PROTOCOL_FIESTA
|
||||
@@ -31,7 +29,7 @@
|
||||
|
||||
static void ndpi_int_fiesta_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FIESTA, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FIESTA, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_fiesta(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -94,4 +92,17 @@ void ndpi_search_fiesta(struct ndpi_detection_module_struct *ndpi_struct, struct
|
||||
ndpi_int_fiesta_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void init_fiesta_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Fiesta", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_FIESTA,
|
||||
ndpi_search_fiesta,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
static void ndpi_int_filetopia_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FILETOPIA, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FILETOPIA, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_filetopia_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -80,4 +80,16 @@ void ndpi_search_filetopia_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FILETOPIA);
|
||||
}
|
||||
|
||||
|
||||
void init_filetopia_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Filetopia", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_FILETOPIA,
|
||||
ndpi_search_filetopia_tcp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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_protocols.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_FIX
|
||||
|
||||
void ndpi_search_fix(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
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(NDPI_PROTOCOL_FIX, ndpi_struct, NDPI_LOG_DEBUG, "FIX detected.\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(NDPI_PROTOCOL_FIX, ndpi_struct, NDPI_LOG_DEBUG, "FIX detected.\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FIX, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* exclude FIX */
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FIX);
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
static void ndpi_florensia_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FLORENSIA, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FLORENSIA, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_florensia(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -119,4 +119,17 @@ void ndpi_search_florensia(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FLORENSIA);
|
||||
}
|
||||
|
||||
|
||||
void init_florensia_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Florensia", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_FLORENSIA,
|
||||
ndpi_search_florensia,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+283
-266
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
* ftp_data.c
|
||||
*
|
||||
* Copyright (C) 2014 Tomasz Bujlow <tomasz@skatnet.dk>
|
||||
* Copyright (C) 2014 - ntop.org
|
||||
* Copyright (C) 2016 - ntop.org
|
||||
*
|
||||
* The signature is based on the Libprotoident library.
|
||||
*
|
||||
@@ -28,18 +27,19 @@
|
||||
|
||||
#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) {
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FTP_DATA, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FTP_DATA, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if(packet->tcp->dest == htons(20) || packet->tcp->source == htons(20)) {
|
||||
return 1;
|
||||
/* Check connection over TCP */
|
||||
if(packet->tcp) {
|
||||
if(packet->tcp->dest == htons(20) || packet->tcp->source == htons(20)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static int ndpi_match_ftp_data_directory(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
@@ -56,18 +56,18 @@ static int ndpi_match_ftp_data_directory(struct ndpi_detection_module_struct *nd
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static int ndpi_match_file_header(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;
|
||||
|
||||
/* A FTP packet is pretty long so 256 is a bit consrvative but it should be OK */
|
||||
/* A FTP packet is pretty long so 256 is a bit conservative but it should be OK */
|
||||
if(packet->payload_packet_len < 256)
|
||||
return 0;
|
||||
|
||||
/* RIFF is a meta-format for storing AVI and WAV files */
|
||||
if(match_first_bytes(packet->payload, "RIFF"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "RIFF"))
|
||||
return 1;
|
||||
|
||||
/* MZ is a .exe file */
|
||||
@@ -75,7 +75,7 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
|
||||
return 1;
|
||||
|
||||
/* Ogg files */
|
||||
if(match_first_bytes(packet->payload, "OggS"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "OggS"))
|
||||
return 1;
|
||||
|
||||
/* ZIP files */
|
||||
@@ -87,7 +87,7 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
|
||||
return 1;
|
||||
|
||||
/* RAR files */
|
||||
if(match_first_bytes(packet->payload, "Rar!"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "Rar!"))
|
||||
return 1;
|
||||
|
||||
/* EBML */
|
||||
@@ -99,7 +99,7 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
|
||||
return 1;
|
||||
|
||||
/* GIF */
|
||||
if(match_first_bytes(packet->payload, "GIF8"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "GIF8"))
|
||||
return 1;
|
||||
|
||||
/* PHP scripts */
|
||||
@@ -111,7 +111,7 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
|
||||
return 1;
|
||||
|
||||
/* PDFs */
|
||||
if(match_first_bytes(packet->payload, "%PDF"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "%PDF"))
|
||||
return 1;
|
||||
|
||||
/* PNG */
|
||||
@@ -119,7 +119,7 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
|
||||
return 1;
|
||||
|
||||
/* HTML */
|
||||
if(match_first_bytes(packet->payload, "<htm"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "<htm"))
|
||||
return 1;
|
||||
if((packet->payload[0] == 0x0a) && (packet->payload[1] == '<') && (packet->payload[2] == '!') && (packet->payload[3] == 'D'))
|
||||
return 1;
|
||||
@@ -133,17 +133,17 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
|
||||
return 1;
|
||||
|
||||
/* XML */
|
||||
if(match_first_bytes(packet->payload, "<!DO"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "<!DO"))
|
||||
return 1;
|
||||
|
||||
/* FLAC */
|
||||
if(match_first_bytes(packet->payload, "fLaC"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "fLaC"))
|
||||
return 1;
|
||||
|
||||
/* MP3 */
|
||||
if((packet->payload[0] == 'I') && (packet->payload[1] == 'D') && (packet->payload[2] == '3') && (packet->payload[3] == 0x03))
|
||||
return 1;
|
||||
if(match_first_bytes(packet->payload, "\xff\xfb\x90\xc0"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "\xff\xfb\x90\xc0"))
|
||||
return 1;
|
||||
|
||||
/* RPM */
|
||||
@@ -151,7 +151,7 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
|
||||
return 1;
|
||||
|
||||
/* Wz Patch */
|
||||
if(match_first_bytes(packet->payload, "WzPa"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "WzPa"))
|
||||
return 1;
|
||||
|
||||
/* Flash Video */
|
||||
@@ -159,7 +159,7 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
|
||||
return 1;
|
||||
|
||||
/* .BKF (Microsoft Tape Format) */
|
||||
if(match_first_bytes(packet->payload, "TAPE"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "TAPE"))
|
||||
return 1;
|
||||
|
||||
/* MS Office Doc file - this is unpleasantly geeky */
|
||||
@@ -175,23 +175,23 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
|
||||
return 1;
|
||||
|
||||
/* ar archive, typically .deb files */
|
||||
if(match_first_bytes(packet->payload, "!<ar"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "!<ar"))
|
||||
return 1;
|
||||
|
||||
/* Raw XML (skip jabber-like traffic as this is not FTP but unencrypted jabber) */
|
||||
if((match_first_bytes(packet->payload, "<?xm"))
|
||||
if((ndpi_match_strprefix(packet->payload, payload_len, "<?xm"))
|
||||
&& (ndpi_strnstr((const char *)packet->payload, "jabber", packet->payload_packet_len) == NULL))
|
||||
return 1;
|
||||
|
||||
if(match_first_bytes(packet->payload, "<iq "))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "<iq "))
|
||||
return 1;
|
||||
|
||||
/* SPF */
|
||||
if(match_first_bytes(packet->payload, "SPFI"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "SPFI"))
|
||||
return 1;
|
||||
|
||||
/* ABIF - Applied Biosystems */
|
||||
if(match_first_bytes(packet->payload, "ABIF"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, "ABIF"))
|
||||
return 1;
|
||||
|
||||
/* bzip2 - other digits are also possible instead of 9 */
|
||||
@@ -204,11 +204,11 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
|
||||
return 1;
|
||||
if((packet->payload[0] == '<') && (packet->payload[1] == 'C') && (packet->payload[2] == 'F'))
|
||||
return 1;
|
||||
if(match_first_bytes(packet->payload, ".tem"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, ".tem"))
|
||||
return 1;
|
||||
if(match_first_bytes(packet->payload, ".ite"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, ".ite"))
|
||||
return 1;
|
||||
if(match_first_bytes(packet->payload, ".lef"))
|
||||
if(ndpi_match_strprefix(packet->payload, payload_len, ".lef"))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
@@ -216,41 +216,20 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
|
||||
|
||||
static void ndpi_check_ftp_data(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;
|
||||
|
||||
/* Check if we so far detected the protocol in the request or not. */
|
||||
if(flow->ftp_data_stage == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "FTP_DATA stage 0: \n");
|
||||
|
||||
if((payload_len > 0) && (ndpi_match_file_header(ndpi_struct, flow) || ndpi_match_ftp_data_directory(ndpi_struct, flow) || ndpi_match_ftp_data_port(ndpi_struct, flow))) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "Possible FTP_DATA 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. */
|
||||
flow->ftp_data_stage = packet->packet_direction + 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "FTP_DATA stage %u: \n", flow->ftp_data_stage);
|
||||
|
||||
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
|
||||
if((flow->ftp_data_stage - packet->packet_direction) == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This is a packet in another direction. Check if we find the proper response. */
|
||||
if(payload_len == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "Found FTP_DATA.\n");
|
||||
ndpi_int_ftp_data_add_connection(ndpi_struct, flow);
|
||||
} else {
|
||||
NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "The reply did not seem to belong to FTP_DATA, resetting the stage to 0...\n");
|
||||
flow->ftp_data_stage = 0;
|
||||
}
|
||||
|
||||
}
|
||||
if((packet->payload_packet_len > 0)
|
||||
&& (ndpi_match_file_header(ndpi_struct, flow)
|
||||
|| ndpi_match_ftp_data_directory(ndpi_struct, flow)
|
||||
|| ndpi_match_ftp_data_port(ndpi_struct, flow)
|
||||
)
|
||||
) {
|
||||
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);
|
||||
} else
|
||||
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) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
/* Break after 20 packets. */
|
||||
if(flow->packet_counter > 20) {
|
||||
@@ -259,17 +238,21 @@ void ndpi_search_ftp_data(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
return;
|
||||
}
|
||||
|
||||
/* skip marked or retransmitted packets */
|
||||
if(packet->tcp_retransmission != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(packet->detected_protocol_stack[0] == NDPI_PROTOCOL_FTP_DATA) {
|
||||
return;
|
||||
}
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "FTP_DATA detection...\n");
|
||||
ndpi_check_ftp_data(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
void init_ftp_data_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("FTP_DATA", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_FTP_DATA,
|
||||
ndpi_search_ftp_data,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* git.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 <stdlib.h>
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_GIT
|
||||
|
||||
#define GIT_PORT 9418
|
||||
|
||||
void ndpi_search_git(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct * packet = &flow->packet;
|
||||
|
||||
if((packet->tcp != NULL) && (packet->payload_packet_len > 4)) {
|
||||
if((ntohs(packet->tcp->source) == GIT_PORT)
|
||||
|| (ntohs(packet->tcp->dest) == GIT_PORT)) {
|
||||
const u_int8_t * pp = packet->payload;
|
||||
u_int16_t payload_len = packet->payload_packet_len;
|
||||
u_int8_t found_git = 1;
|
||||
u_int16_t offset = 0;
|
||||
|
||||
while((offset+4) < payload_len) {
|
||||
char len[5];
|
||||
u_int32_t git_pkt_len;
|
||||
|
||||
memcpy(&len, &pp[offset], 4), len[4] = 0;
|
||||
git_pkt_len = atoi(len);
|
||||
|
||||
if((payload_len < git_pkt_len) || (git_pkt_len == 0 /* Bad */)) {
|
||||
found_git = 0;
|
||||
break;
|
||||
} else
|
||||
offset += git_pkt_len, payload_len -= git_pkt_len;
|
||||
}
|
||||
|
||||
if(found_git) {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/* ***************************************************************** */
|
||||
|
||||
|
||||
void init_git_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id,
|
||||
NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Git", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_GIT,
|
||||
ndpi_search_git,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_TCP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif /* NDPI_PROTOCOL_GIT */
|
||||
@@ -30,15 +30,14 @@
|
||||
#ifdef NDPI_PROTOCOL_GNUTELLA
|
||||
|
||||
static void ndpi_int_gnutella_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 */)
|
||||
{
|
||||
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
struct ndpi_id_struct *src = flow->src;
|
||||
struct ndpi_id_struct *dst = flow->dst;
|
||||
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_GNUTELLA, protocol_type);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_GNUTELLA, NDPI_PROTOCOL_UNKNOWN);
|
||||
|
||||
if (src != NULL) {
|
||||
src->gnutella_ts = packet->tick_timestamp;
|
||||
@@ -104,13 +103,13 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
/* this case works asymmetrically */
|
||||
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_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
/* this case works asymmetrically */
|
||||
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_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,7 +124,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
|| (packet->line[c].len > 36 && memcmp(packet->line[c].ptr,
|
||||
"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_CORRELATED_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -137,7 +136,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
|| (packet->accept_line.ptr != NULL && packet->accept_line.len > 24
|
||||
&& 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_CORRELATED_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -154,7 +153,7 @@ 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) {
|
||||
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_CORRELATED_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -163,7 +162,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
* it is searched in the upper paragraph. */
|
||||
if (packet->payload_packet_len > 30 && memcmp(packet->payload, "HEAD /gnutella/push-proxy?", 26) == 0) {
|
||||
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_CORRELATED_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
/* haven't found any trace with this pattern */
|
||||
@@ -171,7 +170,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
&& memcmp(packet->payload, "\x50\x55\x53\x48\x20\x67\x75\x69\x64\x3a", 10) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE,
|
||||
"detected \x50\x55\x53\x48\x20\x67\x75\x69\x64\x3a\n");
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
/* haven't found any trace with this pattern */
|
||||
@@ -192,7 +191,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
|
||||
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_CORRELATED_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -204,7 +203,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
&& packet->payload[packet->payload_packet_len - 2] == 0x0a) {
|
||||
if (packet->payload_packet_len > 3 && memcmp(packet->payload, "GIV", 3) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "MORPHEUS GIV DETECTED\n");
|
||||
/* Not Excludeing the flow now.. We shall Check the next Packet too for Gnutella Patterns */
|
||||
/* Not Excluding the flow now.. We shall Check the next Packet too for Gnutella Patterns */
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -213,14 +212,14 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
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)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "detected gnutella len == 46.\n");
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
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",
|
||||
19) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "detected gnutella len == 49.\n");
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len == 89 && memcmp(&packet->payload[43], "\x20\x4d\x6c", 3) == 0 &&
|
||||
@@ -228,7 +227,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
memcmp(&packet->payload[76], "\x00\x02\x00\x34\x01\x00\x00\x05", 8) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE,
|
||||
"detected gnutella asymmetrically len == 388.\n");
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
} else if (packet->payload_packet_len == 82) {
|
||||
if (get_u_int32_t(packet->payload, 0) == htonl(0x16030100)
|
||||
@@ -237,7 +236,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
&& get_u_int16_t(packet->payload, 76) == htons(0x0002)
|
||||
&& get_u_int32_t(packet->payload, 78) == htonl(0x00340100)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "detected len == 82.\n");
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -246,7 +245,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
packet->udp->source == src->detected_gnutella_udp_port2) &&
|
||||
(packet->tick_timestamp - src->gnutella_ts) < ndpi_struct->gnutella_timeout) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG, "port based detection\n\n");
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
}
|
||||
/* observations:
|
||||
* all the following patterns send out many packets which are the only ones of their flows,
|
||||
@@ -260,7 +259,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
&& packet->payload[20] == 0x00 && packet->payload[21] == 0x00 && packet->payload[22] == 0x00) {
|
||||
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_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -270,32 +269,32 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
&& packet->payload[30] == 0x43 && packet->payload[31] == 0x50 && packet->payload[32] == 0x41) {
|
||||
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_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len == 32
|
||||
&& (memcmp(&packet->payload[16], "\x31\x01\x00\x09\x00\x00\x00\x4c\x49\x4d\x45", 11) == 0)) {
|
||||
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_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len == 34 && (memcmp(&packet->payload[25], "SCP@", 4) == 0)
|
||||
&& (memcmp(&packet->payload[30], "DNA@", 4) == 0)) {
|
||||
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_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if ((packet->payload_packet_len == 73 || packet->payload_packet_len == 96)
|
||||
&& memcmp(&packet->payload[32], "urn:sha1:", 9) == 0) {
|
||||
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_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
if (memcmp(packet->payload, "GND", 3) == 0) {
|
||||
if (packet->payload_packet_len >= 3 && memcmp(packet->payload, "GND", 3) == 0) {
|
||||
if ((packet->payload_packet_len == 8 && (memcmp(&packet->payload[6], "\x01\x00", 2) == 0))
|
||||
|| (packet->payload_packet_len == 11 && (memcmp(&packet->payload[6], "\x01\x01\x08\x50\x49", 5)
|
||||
== 0)) || (packet->payload_packet_len == 17
|
||||
@@ -311,7 +310,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
|| (packet->payload_packet_len > 300 && (packet->payload[3] == 0x01 || packet->payload[3] == 0x03))) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"detected gnutella udp, GND.\n");
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -320,14 +319,14 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
&& memcmp(&packet->payload[16], "\x31\x01\x00\x09\x00\x00\x00", 7) == 0) {
|
||||
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_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
if ((packet->payload_packet_len == 23)
|
||||
&& memcmp(&packet->payload[16], "\x00\x01\x00\x00\x00\x00\x00", 7) == 0) {
|
||||
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_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -353,7 +352,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
&& NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_GNUTELLA)) {
|
||||
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_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
} else if (flow->l4.tcp.gnutella_stage == 2 - packet->packet_direction) {
|
||||
@@ -364,7 +363,7 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
&& NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_GNUTELLA)) {
|
||||
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_REAL_PROTOCOL);
|
||||
ndpi_int_gnutella_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -372,4 +371,19 @@ void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_GNUTELLA);
|
||||
}
|
||||
|
||||
|
||||
void init_gnutella_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Gnutella", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_GNUTELLA,
|
||||
ndpi_search_gnutella,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+14
-10
@@ -18,7 +18,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_GTP
|
||||
@@ -35,14 +34,6 @@ static void ndpi_check_gtp(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
// const u_int8_t *packet_payload = packet->payload;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
#if 0
|
||||
printf("[len=%u][%02X %02X %02X %02X]\n", payload_len,
|
||||
packet->payload[0] & 0xFF,
|
||||
packet->payload[1] & 0xFF,
|
||||
packet->payload[2] & 0xFF,
|
||||
packet->payload[3] & 0xFF);
|
||||
#endif
|
||||
|
||||
if((packet->udp != NULL) && (payload_len > sizeof(struct gtp_header_generic))) {
|
||||
u_int32_t gtp_u = ntohs(2152);
|
||||
u_int32_t gtp_c = ntohs(2123);
|
||||
@@ -60,7 +51,7 @@ static void ndpi_check_gtp(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
|
||||
if(message_len <= (payload_len-sizeof(struct gtp_header_generic))) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_GTP, ndpi_struct, NDPI_LOG_DEBUG, "Found gtp.\n");
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_GTP, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_GTP, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -82,4 +73,17 @@ void ndpi_search_gtp(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
ndpi_check_gtp(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
void init_gtp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("GTP", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_GTP,
|
||||
ndpi_search_gtp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,15 +23,13 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* include files */
|
||||
#include "ndpi_protocols.h"
|
||||
#ifdef NDPI_PROTOCOL_GUILDWARS
|
||||
|
||||
|
||||
static void ndpi_int_guildwars_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_GUILDWARS, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_GUILDWARS, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_guildwars_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -68,4 +66,17 @@ void ndpi_search_guildwars_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_GUILDWARS);
|
||||
}
|
||||
|
||||
|
||||
void init_guildwars_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Guildwars", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_GUILDWARS,
|
||||
ndpi_search_guildwars_tcp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,7 +27,8 @@ void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct n
|
||||
NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "calculated dport over tcp.\n");
|
||||
|
||||
/* H323 */
|
||||
if((packet->payload[0] == 0x03)
|
||||
if(packet->payload_packet_len >= 3
|
||||
&& (packet->payload[0] == 0x03)
|
||||
&& (packet->payload[1] == 0x00)
|
||||
&& (packet->payload[2] == 0x00)) {
|
||||
struct tpkt *t = (struct tpkt*)packet->payload;
|
||||
@@ -43,7 +44,7 @@ void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct n
|
||||
/* ISO 8073/X.224 */
|
||||
if((packet->payload[5] == 0xE0 /* CC Connect Request */)
|
||||
|| (packet->payload[5] == 0xD0 /* CC Connect Confirm */)) {
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_RDP, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_RDP, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +53,7 @@ void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct n
|
||||
|
||||
if(flow->l4.tcp.h323_valid_packets >= 2) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "found H323 broadcast.\n");
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
} else {
|
||||
/* This is not H.323 */
|
||||
@@ -63,11 +64,12 @@ void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct n
|
||||
sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
|
||||
NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "calculated dport over udp.\n");
|
||||
|
||||
if(packet->payload[0] == 0x80 && packet->payload[1] == 0x08 && (packet->payload[2] == 0xe7 || packet->payload[2] == 0x26) &&
|
||||
if(packet->payload_packet_len >= 6 && packet->payload[0] == 0x80 && packet->payload[1] == 0x08 &&
|
||||
(packet->payload[2] == 0xe7 || packet->payload[2] == 0x26) &&
|
||||
packet->payload[4] == 0x00 && packet->payload[5] == 0x00)
|
||||
{
|
||||
NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "found H323 broadcast.\n");
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
/* H323 */
|
||||
@@ -76,13 +78,13 @@ 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)
|
||||
{
|
||||
NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "found H323 broadcast.\n");
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_PROTOCOL_UNKNOWN);
|
||||
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(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "found H323 broadcast.\n");
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -94,4 +96,17 @@ void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct n
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void init_h323_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("H323", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_H323,
|
||||
ndpi_search_h323,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
static void ndpi_int_halflife2_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HALFLIFE2, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_HALFLIFE2, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_halflife2(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -62,4 +62,17 @@ void ndpi_search_halflife2(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_HALFLIFE2);
|
||||
}
|
||||
|
||||
|
||||
void init_halflife2_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("HalfLife2", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_HALFLIFE2,
|
||||
ndpi_search_halflife2,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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_api.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_HANGOUT
|
||||
|
||||
/* 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;
|
||||
|
||||
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(NDPI_PROTOCOL_HANGOUT, ndpi_struct, NDPI_LOG_DEBUG, "Found Hangout.\n");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_HANGOUT, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_HANGOUT, ndpi_struct, NDPI_LOG_DEBUG, "No Hangout.\n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_HANGOUT);
|
||||
}
|
||||
|
||||
/* ***************************************************************** */
|
||||
|
||||
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 */
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* hep.c
|
||||
*
|
||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||
* Copyright (C) 2011-15 - ntop.org
|
||||
* Copyright (C) 2011-15 - QXIP BV
|
||||
*
|
||||
* 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_protocols.h"
|
||||
#ifdef NDPI_PROTOCOL_HEP
|
||||
|
||||
static void ndpi_int_hep_add_connection(struct ndpi_detection_module_struct
|
||||
*ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_HEP, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_hep(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
const u_int8_t *packet_payload = packet->payload;
|
||||
u_int32_t payload_len = packet->payload_packet_len;
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_HEP, ndpi_struct, NDPI_LOG_DEBUG, "searching for HEP.\n");
|
||||
if (payload_len > 10) {
|
||||
if (memcmp(packet_payload, "HEP3", 4) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_HEP, ndpi_struct, NDPI_LOG_DEBUG, "found HEP3.\n");
|
||||
ndpi_int_hep_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
void init_hep_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("HEP", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_HEP,
|
||||
ndpi_search_hep,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
+484
-417
File diff suppressed because it is too large
Load Diff
@@ -28,7 +28,7 @@
|
||||
#ifdef NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC
|
||||
static void ndpi_int_activesync_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC, NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC, NDPI_PROTOCOL_HTTP);
|
||||
}
|
||||
|
||||
void ndpi_search_activesync(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -51,4 +51,18 @@ void ndpi_search_activesync(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void init_http_activesync_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("HTTP_Application_ActiveSync", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC,
|
||||
ndpi_search_activesync,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+16
-1
@@ -24,13 +24,14 @@
|
||||
|
||||
|
||||
#include "ndpi_protocols.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_IAX
|
||||
|
||||
#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)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_IAX, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_IAX, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
static void ndpi_search_setup_iax(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -91,4 +92,18 @@ void ndpi_search_iax(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
&& (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN))
|
||||
ndpi_search_setup_iax(ndpi_struct, flow);
|
||||
}
|
||||
|
||||
|
||||
void init_iax_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("IAX", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_IAX,
|
||||
ndpi_search_iax,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
static void ndpi_int_icecast_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_ICECAST, NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_ICECAST, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_icecast_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -88,4 +88,18 @@ void ndpi_search_icecast_tcp(struct ndpi_detection_module_struct *ndpi_struct, s
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_ICECAST);
|
||||
NDPI_LOG(NDPI_PROTOCOL_ICECAST, ndpi_struct, NDPI_LOG_DEBUG, "Icecast excluded.\n");
|
||||
}
|
||||
|
||||
|
||||
void init_icecast_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("IceCast", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_ICECAST,
|
||||
ndpi_search_icecast_tcp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,294 +0,0 @@
|
||||
/*
|
||||
* imesh.c
|
||||
*
|
||||
* 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
|
||||
* 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_api.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_IMESH
|
||||
|
||||
|
||||
static void ndpi_int_imesh_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow, ndpi_protocol_type_t protocol_type)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_IMESH, protocol_type);
|
||||
}
|
||||
|
||||
|
||||
void ndpi_search_imesh_tcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
if (packet->udp != NULL) {
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "UDP FOUND\n");
|
||||
|
||||
// this is the login packet
|
||||
if (packet->payload_packet_len == 28 && (get_u_int32_t(packet->payload, 0)) == htonl(0x02000000) &&
|
||||
get_u_int32_t(packet->payload, 24) == 0 &&
|
||||
(packet->udp->dest == htons(1864) || packet->udp->source == htons(1864))) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "iMesh Login detected\n");
|
||||
ndpi_int_imesh_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len == 36) {
|
||||
if (get_u_int32_t(packet->payload, 0) == htonl(0x02000000) && packet->payload[4] != 0 &&
|
||||
packet->payload[5] == 0 && get_u_int16_t(packet->payload, 6) == htons(0x0083) &&
|
||||
get_u_int32_t(packet->payload, 24) == htonl(0x40000000) &&
|
||||
(packet->payload[packet->payload_packet_len - 1] == packet->payload[packet->payload_packet_len - 5] ||
|
||||
packet->payload[packet->payload_packet_len - 1] - 1 == packet->payload[packet->payload_packet_len - 5]
|
||||
|| packet->payload[packet->payload_packet_len - 1] ==
|
||||
packet->payload[packet->payload_packet_len - 5] - 1)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "iMesh detected\n");
|
||||
ndpi_int_imesh_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
return;
|
||||
}
|
||||
if (get_u_int16_t(packet->payload, 0) == htons(0x0200) && get_u_int16_t(packet->payload, 2) != 0 &&
|
||||
get_u_int32_t(packet->payload, 4) == htonl(0x02000083) && get_u_int32_t(packet->payload, 24) == htonl(0x40000000) &&
|
||||
(packet->payload[packet->payload_packet_len - 1] == packet->payload[packet->payload_packet_len - 5] ||
|
||||
packet->payload[packet->payload_packet_len - 1] - 1 == packet->payload[packet->payload_packet_len - 5]
|
||||
|| packet->payload[packet->payload_packet_len - 1] ==
|
||||
packet->payload[packet->payload_packet_len - 5] - 1)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "iMesh detected\n");
|
||||
ndpi_int_imesh_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (packet->payload_packet_len == 24 && get_u_int16_t(packet->payload, 0) == htons(0x0200)
|
||||
&& get_u_int16_t(packet->payload, 2) != 0 && get_u_int32_t(packet->payload, 4) == htonl(0x03000084) &&
|
||||
(packet->payload[packet->payload_packet_len - 1] == packet->payload[packet->payload_packet_len - 5] ||
|
||||
packet->payload[packet->payload_packet_len - 1] - 1 == packet->payload[packet->payload_packet_len - 5] ||
|
||||
packet->payload[packet->payload_packet_len - 1] == packet->payload[packet->payload_packet_len - 5] - 1)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "iMesh detected\n");
|
||||
ndpi_int_imesh_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len == 32 && get_u_int32_t(packet->payload, 0) == htonl(0x02000000) &&
|
||||
get_u_int16_t(packet->payload, 21) == 0 && get_u_int16_t(packet->payload, 26) == htons(0x0100)) {
|
||||
if (get_u_int32_t(packet->payload, 4) == htonl(0x00000081) && packet->payload[11] == packet->payload[15] &&
|
||||
get_l16(packet->payload, 24) == htons(packet->udp->source)) {
|
||||
/* packet->payload[28] = source address */
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "iMesh detected\n");
|
||||
ndpi_int_imesh_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
return;
|
||||
}
|
||||
if (get_u_int32_t(packet->payload, 4) == htonl(0x01000082)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "iMesh detected\n");
|
||||
ndpi_int_imesh_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "iMesh UDP packetlen: %d\n",
|
||||
packet->payload_packet_len);
|
||||
|
||||
}
|
||||
|
||||
if (packet->tcp != NULL) {
|
||||
if (packet->payload_packet_len == 64 && get_u_int32_t(packet->payload, 0) == htonl(0x40000000) &&
|
||||
get_u_int32_t(packet->payload, 4) == 0 && get_u_int32_t(packet->payload, 8) == htonl(0x0000fcff) &&
|
||||
get_u_int32_t(packet->payload, 12) == htonl(0x04800100) && get_u_int32_t(packet->payload, 45) == htonl(0xff020000) &&
|
||||
get_u_int16_t(packet->payload, 49) == htons(0x001a)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "found imesh.\n");
|
||||
ndpi_int_imesh_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len == 95 && get_u_int32_t(packet->payload, 0) == htonl(0x5f000000) &&
|
||||
get_u_int16_t(packet->payload, 4) == 0 && get_u_int16_t(packet->payload, 7) == htons(0x0004) &&
|
||||
get_u_int32_t(packet->payload, 20) == 0 && get_u_int32_t(packet->payload, 28) == htonl(0xc8000400) &&
|
||||
packet->payload[9] == 0x80 && get_u_int32_t(packet->payload, 10) == get_u_int32_t(packet->payload, 24)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "found imesh.\n");
|
||||
ndpi_int_imesh_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
return;
|
||||
}
|
||||
if (packet->payload_packet_len == 28 && get_u_int32_t(packet->payload, 0) == htonl(0x1c000000) &&
|
||||
get_u_int16_t(packet->payload, 10) == htons(0xfcff) && get_u_int32_t(packet->payload, 12) == htonl(0x07801800) &&
|
||||
(get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == htons(0x1900) ||
|
||||
get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == htons(0x1a00))) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "found imesh.\n");
|
||||
ndpi_int_imesh_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
return;
|
||||
}
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "TCP FOUND :: Payload %u\n",
|
||||
packet->payload_packet_len);
|
||||
|
||||
if (packet->actual_payload_len == 0) {
|
||||
return;
|
||||
}
|
||||
if ((packet->actual_payload_len == 8 || packet->payload_packet_len == 10) /* PATTERN:: 04 00 00 00 00 00 00 00 [00 00] */
|
||||
&&get_u_int32_t(packet->payload, 0) == htonl(0x04000000)
|
||||
&& get_u_int32_t(packet->payload, 4) == 0) {
|
||||
flow->l4.tcp.imesh_stage += 2;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
} else if (packet->actual_payload_len == 10 /* PATTERN:: ?? ?? 04|00 00 64|00 00 */
|
||||
&& (packet->payload[2] == 0x04 || packet->payload[2] == 0x00)
|
||||
&& packet->payload[3] == 0x00 && (packet->payload[4] == 0x00 || packet->payload[4] == 0x64)
|
||||
&& packet->payload[5] == 0x00
|
||||
&& (packet->payload[2] != packet->payload[4]) /* We do not want that the packet is ?? ?? 00 00 00 00 */
|
||||
) {
|
||||
flow->l4.tcp.imesh_stage += 2;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
} else if (packet->actual_payload_len == 2 && packet->payload[0] == 0x06 && packet->payload[1] == 0x00) {
|
||||
flow->l4.tcp.imesh_stage++;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
} else if (packet->actual_payload_len == 10 /* PATTERN:: 06 00 04|00 00 01|00 00 01|00 00 ?? 00 */
|
||||
&& packet->payload[0] == 0x06
|
||||
&& packet->payload[1] == 0x00 && (packet->payload[2] == 0x04 || packet->payload[2] == 0x00)
|
||||
&& packet->payload[3] == 0x00 && (packet->payload[4] == 0x00 || packet->payload[4] == 0x01)
|
||||
&& packet->payload[5] == 0x00 && (packet->payload[6] == 0x01 || packet->payload[6] == 0x00)
|
||||
&& packet->payload[7] == 0x00 && packet->payload[9] == 0x00
|
||||
&& (packet->payload[2] || packet->payload[4] || packet->payload[6]) /* We do not want that the packet is all 06 00 00 ... */
|
||||
) {
|
||||
flow->l4.tcp.imesh_stage += 2;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
} else if (packet->actual_payload_len == 24 && packet->payload[0] == 0x06 // PATTERN :: 06 00 12 00 00 00 34 00 00
|
||||
&& packet->payload[1] == 0x00
|
||||
&& packet->payload[2] == 0x12
|
||||
&& packet->payload[3] == 0x00
|
||||
&& packet->payload[4] == 0x00
|
||||
&& packet->payload[5] == 0x00
|
||||
&& packet->payload[6] == 0x34 && packet->payload[7] == 0x00 && packet->payload[8] == 0x00) {
|
||||
flow->l4.tcp.imesh_stage += 2;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
} else if (packet->actual_payload_len == 8 /* PATTERN:: 06|00 00 02 00 00 00 33 00 */
|
||||
&& (packet->payload[0] == 0x06 || packet->payload[0] == 0x00)
|
||||
&& packet->payload[1] == 0x00
|
||||
&& packet->payload[2] == 0x02
|
||||
&& packet->payload[3] == 0x00
|
||||
&& packet->payload[4] == 0x00
|
||||
&& packet->payload[5] == 0x00 && packet->payload[6] == 0x33 && packet->payload[7] == 0x00) {
|
||||
flow->l4.tcp.imesh_stage += 2;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
} else if (packet->payload_packet_len == 6 /* PATTERN:: 02 00 00 00 33 00 */
|
||||
&& packet->payload[0] == 0x02
|
||||
&& packet->payload[1] == 0x00
|
||||
&& packet->payload[2] == 0x00
|
||||
&& packet->payload[3] == 0x00 && packet->payload[4] == 0x33 && packet->payload[5] == 0x00) {
|
||||
flow->l4.tcp.imesh_stage += 2;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
} else if (packet->actual_payload_len == 12 && packet->payload[0] == 0x06 // PATTERN : 06 00 06 00 00 00 64 00
|
||||
&& packet->payload[1] == 0x00
|
||||
&& packet->payload[2] == 0x06
|
||||
&& packet->payload[3] == 0x00
|
||||
&& packet->payload[4] == 0x00
|
||||
&& packet->payload[5] == 0x00 && packet->payload[6] == 0x64 && packet->payload[7] == 0x00) {
|
||||
flow->l4.tcp.imesh_stage += 2;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
} else if (packet->actual_payload_len == 10 /* PATTERN:: 06 00 04|01 00 00 00 01|00 00 ?? 00 */
|
||||
&& packet->payload[0] == 0x06
|
||||
&& packet->payload[1] == 0x00 && (packet->payload[2] == 0x04 || packet->payload[2] == 0x01)
|
||||
&& packet->payload[3] == 0x00
|
||||
&& packet->payload[4] == 0x00
|
||||
&& packet->payload[5] == 0x00 && (packet->payload[6] == 0x01 || packet->payload[6] == 0x00)
|
||||
&& packet->payload[7] == 0x00
|
||||
/* && packet->payload[8]==0x00 */
|
||||
&& packet->payload[9] == 0x00) {
|
||||
flow->l4.tcp.imesh_stage += 2;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
} else if ((packet->actual_payload_len == 64 || packet->actual_payload_len == 52 /* PATTERN:: [len] 00 00 00 00 */
|
||||
|| packet->actual_payload_len == 95)
|
||||
&& get_u_int16_t(packet->payload, 0) == (packet->actual_payload_len)
|
||||
&& packet->payload[1] == 0x00 && packet->payload[2] == 0x00
|
||||
&& packet->payload[3] == 0x00 && packet->payload[4] == 0x00) {
|
||||
flow->l4.tcp.imesh_stage += 2;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
} else if (packet->actual_payload_len == 6 && packet->payload[0] == 0x06 // PATTERN : 06 00 04|6c 00|01 00 00
|
||||
&& packet->payload[1] == 0x00 && (packet->payload[2] == 0x04 || packet->payload[2] == 0x6c)
|
||||
&& (packet->payload[3] == 0x00 || packet->payload[3] == 0x01)
|
||||
&& packet->payload[4] == 0x00 && packet->payload[5] == 0x00) {
|
||||
|
||||
flow->l4.tcp.imesh_stage += 2;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
} else if (packet->actual_payload_len == 6 /* PATTERN:: [len] ?? ee 00 00 00 */
|
||||
&& get_u_int16_t(packet->payload, 0) == (packet->actual_payload_len)
|
||||
&& packet->payload[2] == 0xee
|
||||
&& packet->payload[3] == 0x00 && packet->payload[4] == 0x00 && packet->payload[5] == 0x00) {
|
||||
flow->l4.tcp.imesh_stage += 2;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
} else if (packet->actual_payload_len == 10 /* PATTERN:: 06 00 00 00 00 00 00 00 */
|
||||
&& packet->payload[0] == 0x06
|
||||
&& packet->payload[1] == 0x00
|
||||
&& packet->payload[2] == 0x00
|
||||
&& packet->payload[3] == 0x00
|
||||
&& packet->payload[4] == 0x00
|
||||
&& packet->payload[5] == 0x00 && packet->payload[6] == 0x00 && packet->payload[7] == 0x00) {
|
||||
flow->l4.tcp.imesh_stage += 2;
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"IMESH FOUND :: Payload %u\n", packet->actual_payload_len);
|
||||
}
|
||||
|
||||
|
||||
/* http login */
|
||||
if (packet->payload_packet_len > NDPI_STATICSTRING_LEN("POST /registration") &&
|
||||
memcmp(packet->payload, "POST /registration", NDPI_STATICSTRING_LEN("POST /registration")) == 0) {
|
||||
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||
if (packet->parsed_lines > 6 &&
|
||||
packet->host_line.ptr != NULL &&
|
||||
packet->host_line.len == NDPI_STATICSTRING_LEN("login.bearshare.com") &&
|
||||
packet->line[1].ptr != NULL &&
|
||||
packet->line[1].len == NDPI_STATICSTRING_LEN("Authorization: Basic Og==") &&
|
||||
packet->line[4].ptr != NULL &&
|
||||
packet->line[4].len == NDPI_STATICSTRING_LEN("Accept-Encoding: identity") &&
|
||||
memcmp(packet->line[1].ptr, "Authorization: Basic Og==",
|
||||
NDPI_STATICSTRING_LEN("Authorization: Basic Og==")) == 0 &&
|
||||
memcmp(packet->host_line.ptr, "login.bearshare.com",
|
||||
NDPI_STATICSTRING_LEN("login.bearshare.com")) == 0 &&
|
||||
memcmp(packet->line[4].ptr, "Accept-Encoding: identity",
|
||||
NDPI_STATICSTRING_LEN("Accept-Encoding: identity")) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "iMesh Login detected\n");
|
||||
ndpi_int_imesh_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*give one packet tolerance for detection */
|
||||
if((flow->l4.tcp.imesh_stage >= 4)
|
||||
&& (flow->l4.tcp.seen_syn && flow->l4.tcp.seen_syn_ack && flow->l4.tcp.seen_ack) /* We have seen the 3-way handshake */)
|
||||
{
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "found imesh.\n");
|
||||
ndpi_int_imesh_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((flow->packet_counter < 5) || packet->actual_payload_len == 0) {
|
||||
return;
|
||||
}
|
||||
//imesh_not_found_end:
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_IMESH);
|
||||
NDPI_LOG(NDPI_PROTOCOL_IMESH, ndpi_struct, NDPI_LOG_DEBUG, "iMesh excluded at stage %d\n",
|
||||
packet->tcp != NULL ? flow->l4.tcp.imesh_stage : 0);
|
||||
|
||||
}
|
||||
#endif
|
||||
+18
-4
@@ -24,12 +24,13 @@
|
||||
|
||||
|
||||
#include "ndpi_protocols.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_IPP
|
||||
|
||||
static void ndpi_int_ipp_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 */)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_IPP, protocol_type);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_IPP, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_ipp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -90,7 +91,7 @@ void ndpi_search_ipp(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
}
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_IPP, ndpi_struct, NDPI_LOG_DEBUG, "found ipp\n");
|
||||
ndpi_int_ipp_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_ipp_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -101,7 +102,7 @@ void ndpi_search_ipp(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
if (packet->content_line.ptr != NULL && packet->content_line.len > 14
|
||||
&& memcmp(packet->content_line.ptr, "application/ipp", 15) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_IPP, ndpi_struct, NDPI_LOG_DEBUG, "found ipp via POST ... application/ipp.\n");
|
||||
ndpi_int_ipp_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_int_ipp_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -109,4 +110,17 @@ void ndpi_search_ipp(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_IPP);
|
||||
}
|
||||
|
||||
|
||||
void init_ipp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("IPP", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_IPP,
|
||||
ndpi_search_ipp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+21
-5
@@ -35,12 +35,15 @@
|
||||
|
||||
static void ndpi_int_irc_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_IRC, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_IRC, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if !defined(WIN32)
|
||||
static inline
|
||||
#elif defined(MINGW_GCC)
|
||||
__mingw_forceinline static
|
||||
#else
|
||||
__forceinline static
|
||||
#endif
|
||||
@@ -141,14 +144,14 @@ static u_int8_t ndpi_check_for_IRC_traces(const u_int8_t * ptr, u_int16_t len)
|
||||
}
|
||||
|
||||
|
||||
u_int8_t ndpi_search_irc_ssl_detect_ninty_percent_but_very_fast(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
u_int8_t ndpi_search_irc_ssl_detect_ninety_percent_but_very_fast(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_IRC, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"called ndpi_search_irc_ssl_detect_ninty_percent_but_very_fast\n");
|
||||
"called ndpi_search_irc_ssl_detect_ninety_percent_but_very_fast\n");
|
||||
|
||||
/* case 1: len 1460, len 1460, len 1176 several times in one direction, than len = 4, 4096, 8192 in the other direction */
|
||||
if (packet->payload_packet_len == 1460
|
||||
@@ -475,7 +478,7 @@ void ndpi_search_irc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struc
|
||||
}
|
||||
}
|
||||
if (flow->detected_protocol_stack[0] != NDPI_PROTOCOL_IRC &&
|
||||
ndpi_search_irc_ssl_detect_ninty_percent_but_very_fast(ndpi_struct, flow) != 0) {
|
||||
ndpi_search_irc_ssl_detect_ninety_percent_but_very_fast(ndpi_struct, flow) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -585,7 +588,7 @@ void ndpi_search_irc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struc
|
||||
if (memcmp(packet->payload, "POST ", 5) == 0) {
|
||||
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||
if (packet->parsed_lines) {
|
||||
u_int16_t http_header_len = (packet->line[packet->parsed_lines - 1].ptr - packet->payload) + 2;
|
||||
u_int16_t http_header_len = (u_int16_t)((packet->line[packet->parsed_lines - 1].ptr - packet->payload) + 2);
|
||||
if (packet->payload_packet_len > http_header_len) {
|
||||
http_content_ptr_len = packet->payload_packet_len - http_header_len;
|
||||
}
|
||||
@@ -801,4 +804,17 @@ void ndpi_search_irc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struc
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_irc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("IRC", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_IRC,
|
||||
ndpi_search_irc_tcp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+47
-35
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_UNENCRYPED_JABBER
|
||||
#ifdef NDPI_PROTOCOL_UNENCRYPTED_JABBER
|
||||
struct jabber_string {
|
||||
char *string;
|
||||
u_int ndpi_protocol;
|
||||
@@ -41,9 +41,9 @@ static struct jabber_string jabber_strings[] = {
|
||||
|
||||
static void ndpi_int_jabber_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
u_int32_t protocol, ndpi_protocol_type_t protocol_type)
|
||||
u_int32_t protocol)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, protocol, protocol_type);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, protocol, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
static void check_content_type_and_change_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
@@ -56,7 +56,7 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
|
||||
|
||||
for(i=0; jabber_strings[i].string != NULL; i++) {
|
||||
if(ndpi_strnstr((const char*)&packet->payload[x], jabber_strings[i].string, left) != NULL) {
|
||||
ndpi_int_jabber_add_connection(ndpi_struct, flow, jabber_strings[i].ndpi_protocol, NDPI_CORRELATED_PROTOCOL);
|
||||
ndpi_int_jabber_add_connection(ndpi_struct, flow, jabber_strings[i].ndpi_protocol);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -70,19 +70,19 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|
||||
u_int16_t x;
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_TRACE, "JABBER detection....\n");
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_TRACE, "JABBER detection....\n");
|
||||
|
||||
/* search for jabber file transfer */
|
||||
/* this part is working asymmetrically */
|
||||
if (packet->tcp != NULL && packet->tcp->syn != 0 && packet->payload_packet_len == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "check jabber syn\n");
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "check jabber syn\n");
|
||||
if (src != NULL && src->jabber_file_transfer_port[0] != 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"src jabber ft port set, ports are: %u, %u\n", ntohs(src->jabber_file_transfer_port[0]),
|
||||
ntohs(src->jabber_file_transfer_port[1]));
|
||||
if (((u_int32_t)
|
||||
(packet->tick_timestamp - src->jabber_stun_or_ft_ts)) >= ndpi_struct->jabber_file_transfer_timeout) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct,
|
||||
NDPI_LOG_DEBUG, "JABBER src stun timeout %u %u\n", src->jabber_stun_or_ft_ts,
|
||||
packet->tick_timestamp);
|
||||
src->jabber_file_transfer_port[0] = 0;
|
||||
@@ -91,20 +91,20 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|| src->jabber_file_transfer_port[0] == packet->tcp->source
|
||||
|| src->jabber_file_transfer_port[1] == packet->tcp->dest
|
||||
|| src->jabber_file_transfer_port[1] == packet->tcp->source) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"found jabber file transfer.\n");
|
||||
|
||||
ndpi_int_jabber_add_connection(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_UNENCRYPED_JABBER, NDPI_CORRELATED_PROTOCOL);
|
||||
NDPI_PROTOCOL_UNENCRYPTED_JABBER);
|
||||
}
|
||||
}
|
||||
if (dst != NULL && dst->jabber_file_transfer_port[0] != 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"dst jabber ft port set, ports are: %u, %u\n", ntohs(dst->jabber_file_transfer_port[0]),
|
||||
ntohs(dst->jabber_file_transfer_port[1]));
|
||||
if (((u_int32_t)
|
||||
(packet->tick_timestamp - dst->jabber_stun_or_ft_ts)) >= ndpi_struct->jabber_file_transfer_timeout) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct,
|
||||
NDPI_LOG_DEBUG, "JABBER dst stun timeout %u %u\n", dst->jabber_stun_or_ft_ts,
|
||||
packet->tick_timestamp);
|
||||
dst->jabber_file_transfer_port[0] = 0;
|
||||
@@ -113,11 +113,11 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|| dst->jabber_file_transfer_port[0] == packet->tcp->source
|
||||
|| dst->jabber_file_transfer_port[1] == packet->tcp->dest
|
||||
|| dst->jabber_file_transfer_port[1] == packet->tcp->source) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"found jabber file transfer.\n");
|
||||
|
||||
ndpi_int_jabber_add_connection(ndpi_struct, flow,
|
||||
NDPI_PROTOCOL_UNENCRYPED_JABBER, NDPI_CORRELATED_PROTOCOL);
|
||||
NDPI_PROTOCOL_UNENCRYPTED_JABBER);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -129,23 +129,23 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|
||||
|
||||
/* this part parses a packet and searches for port=. it works asymmetrically. */
|
||||
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNENCRYPED_JABBER) {
|
||||
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNENCRYPTED_JABBER) {
|
||||
u_int16_t lastlen;
|
||||
u_int16_t j_port = 0;
|
||||
/* check for google jabber voip connections ... */
|
||||
/* need big packet */
|
||||
if (packet->payload_packet_len < 100) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "packet too small, return.\n");
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "packet too small, return.\n");
|
||||
return;
|
||||
}
|
||||
/* need message to or type for file-transfer */
|
||||
if (memcmp(packet->payload, "<iq from=\"", 8) == 0 || memcmp(packet->payload, "<iq from=\'", 8) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "JABBER <iq from=\".\n");
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "JABBER <iq from=\".\n");
|
||||
lastlen = packet->payload_packet_len - 11;
|
||||
for (x = 10; x < lastlen; x++) {
|
||||
if (packet->payload[x] == 'p') {
|
||||
if (memcmp(&packet->payload[x], "port=", 5) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "port=\n");
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "port=\n");
|
||||
if (src != NULL) {
|
||||
src->jabber_stun_or_ft_ts = packet->tick_timestamp;
|
||||
}
|
||||
@@ -155,16 +155,16 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
}
|
||||
x += 6;
|
||||
j_port = ntohs_ndpi_bytestream_to_number(&packet->payload[x], packet->payload_packet_len, &x);
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct,
|
||||
NDPI_LOG_DEBUG, "JABBER port : %u\n", ntohs(j_port));
|
||||
if (src != NULL) {
|
||||
if (src->jabber_file_transfer_port[0] == 0 || src->jabber_file_transfer_port[0] == j_port) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct,
|
||||
NDPI_LOG_DEBUG, "src->jabber_file_transfer_port[0] = j_port = %u;\n",
|
||||
ntohs(j_port));
|
||||
src->jabber_file_transfer_port[0] = j_port;
|
||||
} else {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct,
|
||||
NDPI_LOG_DEBUG, "src->jabber_file_transfer_port[1] = j_port = %u;\n",
|
||||
ntohs(j_port));
|
||||
src->jabber_file_transfer_port[1] = j_port;
|
||||
@@ -172,12 +172,12 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
}
|
||||
if (dst != NULL) {
|
||||
if (dst->jabber_file_transfer_port[0] == 0 || dst->jabber_file_transfer_port[0] == j_port) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct,
|
||||
NDPI_LOG_DEBUG, "dst->jabber_file_transfer_port[0] = j_port = %u;\n",
|
||||
ntohs(j_port));
|
||||
dst->jabber_file_transfer_port[0] = j_port;
|
||||
} else {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct,
|
||||
NDPI_LOG_DEBUG, "dst->jabber_file_transfer_port[1] = j_port = %u;\n",
|
||||
ntohs(j_port));
|
||||
dst->jabber_file_transfer_port[1] = j_port;
|
||||
@@ -191,7 +191,7 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|
||||
} else if (memcmp(packet->payload, "<iq to=\"", 8) == 0 || memcmp(packet->payload, "<iq to=\'", 8) == 0
|
||||
|| memcmp(packet->payload, "<iq type=", 9) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "JABBER <iq to=\"/type=\"\n");
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "JABBER <iq to=\"/type=\"\n");
|
||||
lastlen = packet->payload_packet_len - 21;
|
||||
for (x = 8; x < lastlen; x++) {
|
||||
/* invalid character */
|
||||
@@ -199,7 +199,7 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
return;
|
||||
}
|
||||
if (packet->payload[x] == '@') {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "JABBER @\n");
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "JABBER @\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
for (; x < lastlen; x++) {
|
||||
if (packet->payload[x] == 'p') {
|
||||
if (memcmp(&packet->payload[x], "port=", 5) == 0) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "port=\n");
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG, "port=\n");
|
||||
if (src != NULL) {
|
||||
src->jabber_stun_or_ft_ts = packet->tick_timestamp;
|
||||
}
|
||||
@@ -222,7 +222,7 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|
||||
x += 6;
|
||||
j_port = ntohs_ndpi_bytestream_to_number(&packet->payload[x], packet->payload_packet_len, &x);
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct,
|
||||
NDPI_LOG_DEBUG, "JABBER port : %u\n", ntohs(j_port));
|
||||
|
||||
if (src != NULL && src->jabber_voice_stun_used_ports < JABBER_MAX_STUN_PORTS - 1) {
|
||||
@@ -232,11 +232,11 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
} else {
|
||||
if (src->jabber_file_transfer_port[0] == 0
|
||||
|| src->jabber_file_transfer_port[0] == j_port) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"src->jabber_file_transfer_port[0] = j_port = %u;\n", ntohs(j_port));
|
||||
src->jabber_file_transfer_port[0] = j_port;
|
||||
} else {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct,
|
||||
NDPI_LOG_DEBUG, "src->jabber_file_transfer_port[1] = j_port = %u;\n",
|
||||
ntohs(j_port));
|
||||
src->jabber_file_transfer_port[1] = j_port;
|
||||
@@ -251,11 +251,11 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
} else {
|
||||
if (dst->jabber_file_transfer_port[0] == 0
|
||||
|| dst->jabber_file_transfer_port[0] == j_port) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_DEBUG,
|
||||
"dst->jabber_file_transfer_port[0] = j_port = %u;\n", ntohs(j_port));
|
||||
dst->jabber_file_transfer_port[0] = j_port;
|
||||
} else {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct,
|
||||
NDPI_LOG_DEBUG, "dst->jabber_file_transfer_port[1] = j_port = %u;\n",
|
||||
ntohs(j_port));
|
||||
dst->jabber_file_transfer_port[1] = j_port;
|
||||
@@ -282,7 +282,7 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
|| ndpi_strnstr((const char *)&packet->payload[13], "xmlns:stream=\"http://etherx.jabber.org/streams\"", start)) {
|
||||
|
||||
/* Protocol family */
|
||||
ndpi_int_jabber_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_UNENCRYPED_JABBER, NDPI_REAL_PROTOCOL);
|
||||
ndpi_int_jabber_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_UNENCRYPTED_JABBER);
|
||||
|
||||
/* search for subprotocols */
|
||||
check_content_type_and_change_protocol(ndpi_struct, flow, 13);
|
||||
@@ -291,17 +291,29 @@ void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, st
|
||||
}
|
||||
|
||||
if (flow->packet_counter < 3) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct,
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct,
|
||||
NDPI_LOG_DEBUG, "packet_counter: %u\n", flow->packet_counter);
|
||||
return;
|
||||
}
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPED_JABBER, ndpi_struct, NDPI_LOG_TRACE, "JABBER Excluded.\n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_UNENCRYPED_JABBER);
|
||||
NDPI_LOG(NDPI_PROTOCOL_UNENCRYPTED_JABBER, ndpi_struct, NDPI_LOG_TRACE, "JABBER Excluded.\n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_UNENCRYPTED_JABBER);
|
||||
|
||||
#ifdef NDPI_PROTOCOL_TRUPHONE
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_TRUPHONE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void init_jabber_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Unencrypted_Jabber", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_UNENCRYPTED_JABBER,
|
||||
ndpi_search_jabber_tcp,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* kakaotalk_voice.c
|
||||
*
|
||||
* Copyright (C) 2015 - 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
KakaoTalk (call only)
|
||||
|
||||
http://www.kakao.com/services/talk/voices
|
||||
*/
|
||||
#include "ndpi_api.h"
|
||||
|
||||
|
||||
#ifdef NDPI_PROTOCOL_KAKAOTALK_VOICE
|
||||
void ndpi_search_kakaotalk_voice(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
if(packet->iph
|
||||
&& packet->udp
|
||||
&& (packet->payload_packet_len >= 4)
|
||||
) {
|
||||
if((packet->payload[0] == 0x81)
|
||||
|| (packet->payload[1] == 0xC8)
|
||||
|| (packet->payload[2] == 0x00)
|
||||
|| (packet->payload[3] == 0x0C)) {
|
||||
/* Looks good so far */
|
||||
|
||||
/*
|
||||
inetnum: 1.201.0.0 - 1.201.255.255
|
||||
netname: KINXINC-KR
|
||||
*/
|
||||
|
||||
if(((ntohl(packet->iph->saddr) & 0xFFFF0000 /* 255.255.0.0 */) == 0x01C90000 /* 1.201.0.0/16 */)
|
||||
|| ((ntohl(packet->iph->daddr) & 0xFFFF0000 /* 255.255.0.0 */) == 0x01C90000 /* 1.201.0.0/16 */)) {
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_KAKAOTALK_VOICE, NDPI_PROTOCOL_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_KAKAOTALK_VOICE, ndpi_struct, NDPI_LOG_DEBUG, "Exclude kakaotalk_voice.\n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_KAKAOTALK_VOICE);
|
||||
}
|
||||
|
||||
|
||||
void init_kakaotalk_voice_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("KakaoTalk_Voice", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_KAKAOTALK_VOICE,
|
||||
ndpi_search_kakaotalk_voice,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -23,16 +23,14 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* include files */
|
||||
|
||||
#include "ndpi_protocols.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_KERBEROS
|
||||
|
||||
static void ndpi_int_kerberos_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_KERBEROS, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_KERBEROS, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,15 +66,21 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_KERBEROS, ndpi_struct, NDPI_LOG_DEBUG, "no KERBEROS detected.\n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_KERBEROS);
|
||||
}
|
||||
|
||||
|
||||
void init_kerberos_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Kerberos", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_KERBEROS,
|
||||
ndpi_search_kerberos,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,12 +24,13 @@
|
||||
|
||||
|
||||
#include "ndpi_protocols.h"
|
||||
|
||||
#ifdef NDPI_PROTOCOL_KONTIKI
|
||||
|
||||
static void ndpi_int_kontiki_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_KONTIKI, NDPI_REAL_PROTOCOL);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_KONTIKI, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_kontiki(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
@@ -62,4 +63,17 @@ void ndpi_search_kontiki(struct ndpi_detection_module_struct *ndpi_struct, struc
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_KONTIKI);
|
||||
}
|
||||
|
||||
|
||||
void init_kontiki_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||
{
|
||||
ndpi_set_bitmask_protocol_detection("Kontiki", ndpi_struct, detection_bitmask, *id,
|
||||
NDPI_PROTOCOL_KONTIKI,
|
||||
ndpi_search_kontiki,
|
||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
|
||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||
ADD_TO_DETECTION_BITMASK);
|
||||
|
||||
*id += 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user