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;
00138 union {
00139 struct {
00141 uint32_t sip;
00143 uint32_t dip;
00144 } v4;
00145 struct {
00147 uint8_t sip[16];
00149 uint8_t dip[16];
00150 } v6;
00151 } addr;
00152 } yfFlowKey_t;
00153
00154
00159 typedef struct yfFlowVal_st {
00161 uint64_t oct;
00163 uint64_t pkt;
00164 # if YAF_ENABLE_PAYLOAD
00165
00166 uint32_t paylen;
00168 uint8_t *payload;
00169 # endif
00170
00171 uint32_t isn;
00173 uint8_t iflags;
00175 uint8_t uflags;
00177 uint16_t tag;
00178 # if YAF_ENABLE_ENTROPY
00179
00180 uint8_t entropy;
00182 uint8_t entpad[7];
00183 # endif
00184 } yfFlowVal_t;
00185
00192 typedef struct yfFlow_st {
00194 uint64_t stime;
00196 uint64_t etime;
00201 int32_t rdtime;
00203 uint8_t reason;
00204 #if YAF_ENABLE_APPLABEL
00205
00206 uint16_t appLabel;
00207 #endif
00208
00209 yfFlowVal_t val;
00211 yfFlowVal_t rval;
00213 yfFlowKey_t key;
00214 } yfFlow_t;
00215
00216
00225 void yfAlignmentCheck(void);
00226
00227
00236 void yfFlowPrepare(
00237 yfFlow_t *flow);
00238
00246 void yfFlowCleanup(
00247 yfFlow_t *flow);
00248
00260 fBuf_t *yfWriterForFile(
00261 const char *path,
00262 uint32_t domain,
00263 GError **err);
00264
00278 fBuf_t *yfWriterForFP(
00279 FILE *fp,
00280 uint32_t domain,
00281 GError **err);
00282
00292 fBuf_t *yfWriterForSpec(
00293 fbConnSpec_t *spec,
00294 uint32_t domain,
00295 GError **err);
00296
00308 gboolean yfWriteFlow(
00309 fBuf_t *fbuf,
00310 yfFlow_t *flow,
00311 GError **err);
00312
00325 gboolean yfWriterClose(
00326 fBuf_t *fbuf,
00327 gboolean flush,
00328 GError **err);
00329
00334 void yfWriterExportPayload(
00335 gboolean payload_mode);
00336
00341 void yfWriterExportMappedV6(
00342 gboolean map_mode);
00343
00356 fBuf_t *yfReaderForFP(
00357 fBuf_t *fbuf,
00358 FILE *fp,
00359 GError **err);
00360
00377 fbListener_t *yfListenerForSpec(
00378 fbConnSpec_t *spec,
00379 fbListenerAppInit_fn appinit,
00380 fbListenerAppFree_fn appfree,
00381 GError **err);
00382
00398 gboolean yfReadFlow(
00399 fBuf_t *fbuf,
00400 yfFlow_t *flow,
00401 GError **err);
00402
00421 gboolean yfReadFlowExtended(
00422 fBuf_t *fbuf,
00423 yfFlow_t *flow,
00424 GError **err);
00425
00433 void yfPrintString(
00434 GString *rstr,
00435 yfFlow_t *flow);
00436
00444 void yfPrintDelimitedString(
00445 GString *rstr,
00446 yfFlow_t *flow);
00447
00457 gboolean yfPrint(
00458 FILE *out,
00459 yfFlow_t *flow,
00460 GError **err);
00461
00471 gboolean yfPrintDelimited(
00472 FILE *out,
00473 yfFlow_t *flow,
00474 GError **err);
00475
00476 #endif