00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00030 #ifndef _YAF_DECODE_H_
00031 #define _YAF_DECODE_H_
00032
00033 #include <yaf/autoinc.h>
00034 #include <yaf/yafcore.h>
00035
00037 typedef struct yfIPFragInfo_st {
00039 uint32_t ipid;
00041 uint16_t offset;
00043 uint16_t iphlen;
00048 uint16_t l4hlen;
00053 uint8_t frag;
00057 uint8_t more;
00058 } yfIPFragInfo_t;
00059
00061 #define YF_MPLS_LABEL_COUNT_MAX 10
00062
00064 typedef struct yfL2Info_st {
00066 uint8_t smac[6];
00068 uint8_t dmac[6];
00070 uint16_t vlan_tag;
00072 uint32_t mpls_count;
00074 uint32_t mpls_label[YF_MPLS_LABEL_COUNT_MAX];
00075 } yfL2Info_t;
00076
00078 typedef struct yfTCPInfo_st {
00080 uint32_t seq;
00082 uint8_t flags;
00083 } yfTCPInfo_t;
00084
00086 typedef struct yfPBuf_st {
00088 uint64_t ptime;
00090 yfFlowKey_t key;
00092 uint16_t iplen;
00094 uint16_t ifnum;
00096 yfTCPInfo_t tcpinfo;
00098 yfL2Info_t l2info;
00100 size_t paylen;
00104 uint8_t payload[1];
00105 } yfPBuf_t;
00106
00108 #define YF_PBUFLEN_NOL2INFO offsetof(yfPBuf_t, l2info)
00109
00111 #define YF_PBUFLEN_NOPAYLOAD offsetof(yfPBuf_t, paylen)
00112
00114 #define YF_PBUFLEN_BASE offsetof(yfPBuf_t, payload)
00115
00116 struct yfDecodeCtx_st;
00118 typedef struct yfDecodeCtx_st yfDecodeCtx_t;
00119
00121 #define YF_TYPE_IPv4 0x0800
00122
00123 #define YF_TYPE_IPv6 0x86DD
00124
00128 #define YF_TYPE_IPANY 0x0000
00129
00131 #define YF_PROTO_IP6_HOP 0
00132
00133 #define YF_PROTO_ICMP 1
00134
00135 #define YF_PROTO_TCP 6
00136
00137 #define YF_PROTO_UDP 17
00138
00139 #define YF_PROTO_IP6_ROUTE 43
00140
00141 #define YF_PROTO_IP6_FRAG 44
00142
00143 #define YF_PROTO_GRE 47
00144
00145 #define YF_PROTO_ICMP6 58
00146
00147 #define YF_PROTO_IP6_DOPT 60
00148
00150 #define YF_TF_FIN 0x01
00151
00152 #define YF_TF_SYN 0x02
00153
00154 #define YF_TF_RST 0x04
00155
00156 #define YF_TF_PSH 0x08
00157
00158 #define YF_TF_ACK 0x10
00159
00160 #define YF_TF_URG 0x20
00161
00162 #define YF_TF_ECE 0x40
00163
00164 #define YF_TF_CWR 0x80
00165
00184 yfDecodeCtx_t *yfDecodeCtxAlloc(
00185 int datalink,
00186 uint16_t reqtype,
00187 gboolean gremode);
00188
00194 void yfDecodeCtxFree(
00195 yfDecodeCtx_t *ctx);
00196
00232 gboolean yfDecodeToPBuf(
00233 yfDecodeCtx_t *ctx,
00234 uint64_t ptime,
00235 size_t caplen,
00236 const uint8_t *pkt,
00237 yfIPFragInfo_t *fraginfo,
00238 size_t pbuflen,
00239 yfPBuf_t *pbuf);
00240
00249 uint64_t yfDecodeTimeval(
00250 const struct timeval *tv);
00251
00260 uint64_t yfDecodeTimeNTP(
00261 uint64_t ntp);
00262
00269 void yfDecodeDumpStats(
00270 yfDecodeCtx_t *ctx);
00271
00272
00273 #endif