00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00062 #ifndef _YAF_CORE_H_
00063 #define _YAF_CORE_H_
00064
00065 #include <yaf/autoinc.h>
00066 #include <fixbuf/public.h>
00067
00073 #define YAF_ERROR_DOMAIN (g_quark_from_string("certYAFError"))
00074
00075 #define YAF_ERROR_HEADER 1
00076
00077 #define YAF_ERROR_ARGUMENT 2
00078
00079 #define YAF_ERROR_IO 3
00080
00081 #define YAF_ERROR_IPFIX 4
00082
00083 #define YAF_ERROR_IMPL 5
00084
00085 #define YAF_ERROR_INTERNAL 6
00086
00087 #define YAF_ERROR_LIMIT 7
00088
00089 #define YAF_ERROR_EOF 8
00090
00091 #define YAF_ERROR_ALIGNMENT 9
00092
00093
00094
00099 #define YAF_FLOW_ACTIVE 0
00100
00101 #define YAF_END_IDLE 1
00102
00103 #define YAF_END_ACTIVE 2
00104
00105 #define YAF_END_CLOSED 3
00106
00107 #define YAF_END_FORCED 4
00108
00109 #define YAF_END_RESOURCE 5
00110
00112 #define YAF_END_MASK 0x7f
00113
00115 #define YAF_ENDF_ISCONT 0x80
00116
00118 #define YAF_IP_ICMP 1
00119
00120 #define YAF_IP_TCP 6
00121
00122 #define YAF_IP_UDP 17
00123
00128 typedef struct yfFlowKey_st {
00130 uint16_t sp;
00132 uint16_t dp;
00134 uint8_t proto;
00136 uint8_t version;
00140 #if YAF_ENABLE_DAG_SEPARATE_INTERFACES
00141 uint8_t dagIf;
00142 #endif
00143
00144 union {
00145 struct {
00147 uint32_t sip;
00149 uint32_t dip;
00150 } v4;
00151 struct {
00153 uint8_t sip[16];
00155 uint8_t dip[16];
00156 } v6;
00157 } addr;
00158 } yfFlowKey_t;
00159
00160
00165 typedef struct yfFlowVal_st {
00167 uint64_t oct;
00169 uint64_t pkt;
00170 # if YAF_ENABLE_PAYLOAD
00171
00172 uint32_t paylen;
00174 uint8_t *payload;
00175 # endif
00176
00177 uint32_t isn;
00179 uint8_t iflags;
00181 uint8_t uflags;
00183 uint16_t tag;
00184 # if YAF_ENABLE_ENTROPY
00185
00186 uint8_t entropy;
00188 uint8_t entpad[7];
00189 # endif
00190 } yfFlowVal_t;
00191
00198 typedef struct yfFlow_st {
00200 uint64_t stime;
00202 uint64_t etime;
00207 int32_t rdtime;
00209 uint8_t reason;
00210 #if YAF_ENABLE_APPLABEL
00211
00212 uint16_t appLabel;
00213 #endif
00214
00215 yfFlowVal_t val;
00217 yfFlowVal_t rval;
00219 yfFlowKey_t key;
00220 } yfFlow_t;
00221
00222
00223
00232 void yfAlignmentCheck(void);
00233
00234
00243 void yfFlowPrepare(
00244 yfFlow_t *flow);
00245
00253 void yfFlowCleanup(
00254 yfFlow_t *flow);
00255
00267 fBuf_t *yfWriterForFile(
00268 const char *path,
00269 uint32_t domain,
00270 GError **err);
00271
00285 fBuf_t *yfWriterForFP(
00286 FILE *fp,
00287 uint32_t domain,
00288 GError **err);
00289
00299 fBuf_t *yfWriterForSpec(
00300 fbConnSpec_t *spec,
00301 uint32_t domain,
00302 GError **err);
00303
00316 gboolean yfWriteFlow(
00317 void *yfContext,
00318 yfFlow_t *flow,
00319 GError **err);
00320
00333 gboolean yfWriterClose(
00334 fBuf_t *fbuf,
00335 gboolean flush,
00336 GError **err);
00337
00342 void yfWriterExportPayload(
00343 gboolean payload_mode);
00344
00349 void yfWriterExportMappedV6(
00350 gboolean map_mode);
00351
00364 fBuf_t *yfReaderForFP(
00365 fBuf_t *fbuf,
00366 FILE *fp,
00367 GError **err);
00368
00385 fbListener_t *yfListenerForSpec(
00386 fbConnSpec_t *spec,
00387 fbListenerAppInit_fn appinit,
00388 fbListenerAppFree_fn appfree,
00389 GError **err);
00390
00406 gboolean yfReadFlow(
00407 fBuf_t *fbuf,
00408 yfFlow_t *flow,
00409 GError **err);
00410
00429 gboolean yfReadFlowExtended(
00430 fBuf_t *fbuf,
00431 yfFlow_t *flow,
00432 GError **err);
00433
00441 void yfPrintString(
00442 GString *rstr,
00443 yfFlow_t *flow);
00444
00452 void yfPrintDelimitedString(
00453 GString *rstr,
00454 yfFlow_t *flow);
00455
00465 gboolean yfPrint(
00466 FILE *out,
00467 yfFlow_t *flow,
00468 GError **err);
00469
00479 gboolean yfPrintDelimited(
00480 FILE *out,
00481 yfFlow_t *flow,
00482 GError **err);
00483
00484 #endif