00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00257 #ifndef _FB_PUBLIC_H_
00258 #define _FB_PUBLIC_H_
00259 #include <fixbuf/autoinc.h>
00260
00261 #ident "$Id: public.h 12404 2008-09-04 21:16:48Z inacio_svn $"
00262
00263
00264
00265
00266
00268 #define FB_ERROR_DOMAIN g_quark_from_string("fixbufError")
00269
00270 #define FB_ERROR_TMPL 1
00271
00275 #define FB_ERROR_EOM 2
00276
00281 #define FB_ERROR_EOF 3
00282
00286 #define FB_ERROR_IPFIX 4
00287
00292 #define FB_ERROR_BUFSZ 5
00293
00294 #define FB_ERROR_IMPL 6
00295
00296 #define FB_ERROR_IO 7
00297
00301 #define FB_ERROR_NLREAD 8
00302
00307 #define FB_ERROR_NLWRITE 9
00308
00311 #define FB_ERROR_NOELEMENT 10
00312
00315 #define FB_ERROR_CONN 11
00316
00320 #define FB_ERROR_NETFLOWV9 12
00321
00324 #define FB_ERROR_TRANSMISC 13
00325
00326
00327
00328
00329
00330 struct fBuf_st;
00336 typedef struct fBuf_st fBuf_t;
00337
00344 typedef struct fbVarfield_st {
00346 size_t len;
00353 uint8_t *buf;
00354 } fbVarfield_t;
00355
00356 struct fbInfoModel_st;
00361 typedef struct fbInfoModel_st fbInfoModel_t;
00362
00368 #define FB_IE_INIT(_name_, _ent_, _num_, _len_, _flags_) \
00369 { {.name = _name_}, 0, _ent_, _num_, _len_, _flags_ }
00370
00376 #define FB_IE_NULL \
00377 { {.name = NULL}, 0, 0, 0, 0, 0 }
00378
00383 #define FB_IE_F_NONE 0x00000000
00384
00389 #define FB_IE_F_ENDIAN 0x00000001
00390
00400 #define FB_IE_F_REVERSIBLE 0x00000040
00401
00409 #define FB_IE_F_ALIEN 0x00000080
00410
00414 #define FB_IE_VARLEN 65535
00415
00423 #define FB_IE_PEN_REVERSE 29305
00424
00433 #define FB_IE_VENDOR_BIT_REVERSE 0x4000
00434
00440 #define FB_IE_REVERSE_STR "reverse"
00441
00443 #define FB_IE_REVERSE_STRLEN 7
00444
00453 typedef struct fbInfoElement_st {
00455 union {
00461 const struct fbInfoElement_st *canon;
00466 char *name;
00467 }
00468 ref;
00469
00475 uint32_t midx;
00477 uint32_t ent;
00482 uint16_t num;
00484 uint16_t len;
00486 uint32_t flags;
00487 } fbInfoElement_t;
00488
00493 #define FB_TID_AUTO 0
00494
00498 #define FB_TID_TS 2
00499
00503 #define FB_TID_OTS 3
00504
00508 #define FB_TID_MIN_DATA 256
00509
00510 struct fbTemplate_st;
00516 typedef struct fbTemplate_st fbTemplate_t;
00517
00523 #define FB_IESPEC_NULL { NULL, 0, 0 }
00524
00530 typedef struct fbInfoElementSpec_st {
00532 char *name;
00537 uint16_t len_override;
00544 uint32_t flags;
00545 } fbInfoElementSpec_t;
00546
00547 struct fbSession_st;
00554 typedef struct fbSession_st fbSession_t;
00555
00557 typedef enum fbTransport_en {
00562 FB_SCTP,
00564 FB_TCP,
00566 FB_UDP,
00572 FB_DTLS_SCTP,
00577 FB_TLS_TCP,
00583 FB_DTLS_UDP,
00584 } fbTransport_t;
00585
00590 typedef struct fbConnSpec_st {
00592 fbTransport_t transport;
00594 char *host;
00596 char *svc;
00598 char *ssl_ca_file;
00600 char *ssl_cert_file;
00602 char *ssl_key_file;
00604 char *ssl_key_pass;
00609 void *vai;
00614 void *vssl_ctx;
00615 } fbConnSpec_t;
00616
00620 #define FB_CONNSPEC_INIT { FB_SCTP, NULL, NULL, \
00621 NULL, NULL, NULL, NULL, \
00622 NULL, NULL }
00623
00624 struct fbExporter_st;
00630 typedef struct fbExporter_st fbExporter_t;
00631
00632 struct fbCollector_st;
00640 typedef struct fbCollector_st fbCollector_t;
00641
00642 struct fbListener_st;
00649 typedef struct fbListener_st fbListener_t;
00650
00660 typedef gboolean (*fbListenerAppInit_fn) (
00661 fbListener_t *listener,
00662 void **ctx,
00663 int fd,
00664 struct sockaddr *peer,
00665 size_t peerlen,
00666 GError **err);
00667
00672 typedef void (*fbListenerAppFree_fn) (
00673 void *ctx);
00674
00675
00676
00677
00678
00679
00680
00697 gboolean fBufSetInternalTemplate(
00698 fBuf_t *fbuf,
00699 uint16_t int_tid,
00700 GError **err);
00701
00719 gboolean fBufSetExportTemplate(
00720 fBuf_t *fbuf,
00721 uint16_t ext_tid,
00722 GError **err);
00723
00738 void fBufSetAutomaticMode(
00739 fBuf_t *fbuf,
00740 gboolean automatic);
00741
00749 fbSession_t *fBufGetSession(
00750 fBuf_t *fbuf);
00751
00760 void fBufFree(
00761 fBuf_t *fbuf);
00762
00774 fBuf_t *fBufAllocForExport(
00775 fbSession_t *session,
00776 fbExporter_t *exporter);
00777
00787 fbExporter_t *fBufGetExporter(
00788 fBuf_t *fbuf);
00789
00800 void fBufSetExporter(
00801 fBuf_t *fbuf,
00802 fbExporter_t *exporter);
00803
00827 gboolean fBufAppend(
00828 fBuf_t *fbuf,
00829 uint8_t *recbase,
00830 size_t recsize,
00831 GError **err);
00832
00842 gboolean fBufEmit(
00843 fBuf_t *fbuf,
00844 GError **err);
00845
00857 void fBufSetExportTime(
00858 fBuf_t *fbuf,
00859 uint32_t extime);
00860
00872 fBuf_t *fBufAllocForCollection(
00873 fbSession_t *session,
00874 fbCollector_t *collector);
00875
00885 fbCollector_t *fBufGetCollector(
00886 fBuf_t *fbuf);
00887
00898 void fBufSetCollector(
00899 fBuf_t *fbuf,
00900 fbCollector_t *collector);
00901
00931 gboolean fBufNext(
00932 fBuf_t *fbuf,
00933 uint8_t *recbase,
00934 size_t *recsize,
00935 GError **err);
00936
00950 gboolean fBufNextMessage(
00951 fBuf_t *fbuf,
00952 GError **err);
00953
00961 uint32_t fBufGetExportTime(
00962 fBuf_t *fbuf);
00963
00983 fbTemplate_t *fBufGetCollectionTemplate(
00984 fBuf_t *fbuf,
00985 uint16_t *ext_tid);
00986
01005 fbTemplate_t *fBufNextCollectionTemplate(
01006 fBuf_t *fbuf,
01007 uint16_t *ext_tid,
01008 GError **err);
01009
01021 fbInfoModel_t *fbInfoModelAlloc();
01022
01031 void fbInfoModelFree(
01032 fbInfoModel_t *model);
01033
01048 void fbInfoModelAddElement(
01049 fbInfoModel_t *model,
01050 fbInfoElement_t *ie);
01051
01066 void fbInfoModelAddElementArray(
01067 fbInfoModel_t *model,
01068 fbInfoElement_t *ie);
01069
01081 const fbInfoElement_t *fbInfoModelGetElementByName(
01082 fbInfoModel_t *model,
01083 const char *name);
01084
01085
01103 fbTemplate_t *fbTemplateAlloc(
01104 fbInfoModel_t *model);
01105
01122 gboolean fbTemplateAppend(
01123 fbTemplate_t *tmpl,
01124 fbInfoElement_t *ex_ie,
01125 GError **err);
01126
01142 gboolean fbTemplateAppendSpec(
01143 fbTemplate_t *tmpl,
01144 fbInfoElementSpec_t *spec,
01145 uint32_t flags,
01146 GError **err);
01147
01165 gboolean fbTemplateAppendSpecArray(
01166 fbTemplate_t *tmpl,
01167 fbInfoElementSpec_t *spec,
01168 uint32_t flags,
01169 GError **err);
01170
01178 uint32_t fbTemplateCountElements(
01179 fbTemplate_t *tmpl);
01180
01190 void fbTemplateSetOptionsScope(
01191 fbTemplate_t *tmpl,
01192 uint16_t scope_count);
01193
01201 uint32_t fbTemplateGetOptionsScope(
01202 fbTemplate_t *tmpl);
01203
01215 gboolean fbTemplateContainsElement(
01216 fbTemplate_t *tmpl,
01217 const fbInfoElement_t *ex_ie);
01218
01228 gboolean fbTemplateContainsElementByName(
01229 fbTemplate_t *tmpl,
01230 fbInfoElementSpec_t *spec);
01231
01241 gboolean fbTemplateContainsAllElementsByName(
01242 fbTemplate_t *tmpl,
01243 fbInfoElementSpec_t *spec);
01244
01252 void fbTemplateFreeUnused(
01253 fbTemplate_t *tmpl);
01254
01267 fbSession_t *fbSessionAlloc(
01268 fbInfoModel_t *model);
01269
01279 void fbSessionFree(
01280 fbSession_t *session);
01281
01294 void fbSessionResetExternal(
01295 fbSession_t *session);
01296
01312 void fbSessionSetDomain(
01313 fbSession_t *session,
01314 uint32_t domain);
01315
01323 uint32_t fbSessionGetDomain(
01324 fbSession_t *session);
01325
01338 gboolean fbSessionExportTemplate(
01339 fbSession_t *session,
01340 uint16_t tid,
01341 GError **err);
01342
01354 gboolean fbSessionExportTemplates(
01355 fbSession_t *session,
01356 GError **err);
01357
01373 uint16_t fbSessionAddTemplate(
01374 fbSession_t *session,
01375 gboolean internal,
01376 uint16_t tid,
01377 fbTemplate_t *tmpl,
01378 GError **err);
01379
01392 gboolean fbSessionRemoveTemplate(
01393 fbSession_t *session,
01394 gboolean internal,
01395 uint16_t tid,
01396 GError **err);
01397
01409 fbTemplate_t *fbSessionGetTemplate(
01410 fbSession_t *session,
01411 gboolean internal,
01412 uint16_t tid,
01413 GError **err);
01414
01425 fbExporter_t *fbExporterAllocNet(
01426 fbConnSpec_t *spec);
01427
01438 fbExporter_t *fbExporterAllocFile(
01439 const char *path);
01440
01448 fbExporter_t *fbExporterAllocFP(
01449 FILE *fp);
01450
01463 void fbExporterSetStream(
01464 fbExporter_t *exporter,
01465 int sctp_stream);
01466
01479 void fbExporterAutoStream(
01480 fbExporter_t *exporter);
01481
01489 void fbExporterClose(
01490 fbExporter_t *exporter);
01491
01503 fbCollector_t *fbCollectorAllocFile(
01504 void *ctx,
01505 const char *path,
01506 GError **err);
01507
01517 fbCollector_t *fbCollectorAllocFP(
01518 void *ctx,
01519 FILE *fp);
01520
01531 void *fbCollectorGetContext(
01532 fbCollector_t *collector);
01533
01544 void fbCollectorClose(
01545 fbCollector_t *collector);
01546
01547
01548
01571 fbListener_t *fbListenerAlloc(
01572 fbConnSpec_t *spec,
01573 fbSession_t *session,
01574 fbListenerAppInit_fn appinit,
01575 fbListenerAppFree_fn appfree,
01576 GError **err);
01577
01585 void fbListenerFree(
01586 fbListener_t *listener);
01587
01609 fBuf_t *fbListenerWait(
01610 fbListener_t *listener,
01611 GError **err);
01612
01620 void fbListenerInterrupt(
01621 fbListener_t *listener);
01622
01623
01639 gboolean fbListenerGetCollector(
01640 fbListener_t *listener,
01641 fbCollector_t **collector,
01642 GError **err);
01643
01644
01645
01646
01662 gboolean fbCollectorClearTranslator(
01663 fbCollector_t *collector,
01664 GError **err);
01665
01666
01682 gboolean fbCollectorSetNetflowV9Translator(
01683 fbCollector_t *collector,
01684 GError **err);
01685
01686
01687 #endif