38 static const char rcsid[] __attribute__((used)) =
"$Id: flowmon-input-tcp.c 928 2013-01-16 08:32:47Z 255519 $";
61 #include <sys/socket.h>
62 #include <arpa/inet.h>
65 #include <netinet/if_ether.h>
66 #include <netinet/ip.h>
67 #include <netinet/ip6.h>
68 #include <netinet/tcp.h>
70 #include <flowmonexp/plugin_input_filter.h>
72 #define _ETH_P_8021AD 0x88A8
73 #define _ETH_P_8021QINQ 0x9100
74 #define _ETH_P_8021QINQ_DOUBLE 0x9200
75 #define _ETH_P_8021QINQ_TRIPPLE 0x9300
78 #define VLAN_ID_MASK 0xFF0F
81 #define MPLS_STACK_MASK 0xFF7F
97 static plugin_desc_t pcap_desc = {
99 "input filter plugin that stores size of TCP SYN packet",
122 return(
sizeof(uint16_t));
129 record_universal_get(dst,&pr->
syn_size, 0,
sizeof(uint16_t), len, to_network_byte_order);
136 record_universal_get_txt_num(dst, &pr->
syn_size, 0,
sizeof(uint16_t), len);
143 record_universal_get(dst,&pr->
tcp_win_size, 0,
sizeof(uint16_t), len, to_network_byte_order);
150 record_universal_get_txt_num(dst, &pr->
tcp_win_size, 0,
sizeof(uint16_t), len);
163 getter_add(getter_list,
"SYN_SIZE",
sizeof(uint16_t), retval, &value_syn_ok, &value_length, &value_fill_syn_size, &value_fill_syn_size_txt);
164 getter_add(getter_list,
"TCP_WIN_SIZE",
sizeof(uint16_t), retval, &value_win_ok, &value_length, &value_fill_win_size, &value_fill_win_size_txt);
173 unsigned char* next_hdr = data;
176 if (caplen < ETH_HLEN) {
180 eth = (
struct ethhdr*) data;
181 ethtype = ntohs (eth->h_proto);
184 next_hdr += ETH_HLEN;
185 link_len += ETH_HLEN;
206 ethtype = ntohs (*(uint16_t *) (next_hdr + 2));
214 case ETH_P_MPLS_MC: {
222 switch(*(uint8_t *) (next_hdr +
MPLS_HLEN) >> 4) {
228 ethtype = ETH_P_IPV6;
257 if(record->l4.protocol == 6 && (record->l4.tcp_flags & 0x02 )){
274 if (record->l3.protocol == 4) {
275 uint8_t hlen = ((
struct ip*) packet)->ip_hl*4;
278 }
else if (record->l3.protocol == 6) {
280 if (((
struct ip6_hdr*) packet)->ip6_nxt != 6) {
290 r->
tcp_win_size = htons(((
struct tcphdr*) packet)->window);