00001
00061 #ifndef _FB_PRIVATE_H_
00062 #define _FB_PRIVATE_H_
00063 #include <fixbuf/public.h>
00064
00065 #if HAVE_SPREAD
00066 #include <sp.h>
00067 #include <pthread.h>
00068 #endif
00069
00070 #ident "$Id: private.h 16940 2011-04-22 20:09:20Z ecoff_svn $"
00071
00084 #define IPFIX_ENTERPRISE_BIT 0x8000
00085
00087 #define IPFIX_REVERSE_PEN 29305
00088
00091 #define FB_MSGLEN_MAX 65535
00092
00093 #ifdef HAVE_SPREAD
00094
00095 typedef struct sp_groupname_st
00096 {
00097 char name[MAX_GROUP_NAME];
00098 } sp_groupname_t;
00099
00100 #define FB_SPREAD_NUM_GROUPS 16
00101 #define FB_SPREAD_MTU 8192
00102
00103 typedef struct fbSpreadSpec_st {
00106 fbSession_t *session;
00109 char * daemon;
00111 sp_groupname_t *groups;
00113 int num_groups;
00115 sp_groupname_t *groups_to_send;
00116 int num_groups_to_send;
00118 mailbox mbox;
00120 char privgroup[MAX_GROUP_NAME + 2];
00122 pthread_mutex_t write_lock;
00124 pthread_t recv_thread;
00126 mailbox recv_mbox;
00128 char recv_privgroup[MAX_GROUP_NAME + 2];
00130 GError *recv_err;
00132 int recv_exit;
00134 int recv_max_groups;
00136 int recv_num_groups;
00138 sp_groupname_t *recv_groups;
00140 int recv_max;
00142 char *recv_mess;
00143 } fbSpreadSpec_t;
00144
00145 #endif
00146
00152 struct fbTemplate_st {
00154 fbInfoModel_t *model;
00156 int ref_count;
00158 uint16_t ie_count;
00163 uint16_t scope_count;
00170 uint16_t ie_len;
00176 uint16_t ie_internal_len;
00181 uint16_t tmpl_len;
00183 gboolean is_varlen;
00185 fbInfoElement_t **ie_ary;
00187 GHashTable *indices;
00189 uint16_t *off_cache;
00191 gboolean active;
00192 };
00193
00200 void fBufRewind(
00201 fBuf_t *fbuf);
00202
00214 gboolean fBufAppendTemplate(
00215 fBuf_t *fbuf,
00216 uint16_t tmpl_id,
00217 fbTemplate_t *tmpl,
00218 gboolean revoke,
00219 GError **err);
00220
00221 #if HAVE_SPREAD
00222
00228 void fBufSetExportGroups(
00229 fBuf_t *fbuf,
00230 char **groups,
00231 int num_groups,
00232 GError **err);
00233
00234
00235 #endif
00236
00242 void fBufRemoveTemplateTcplan(
00243 fBuf_t *fbuf,
00244 fbTemplate_t *tmpl);
00252 uint32_t fbInfoElementHash(
00253 fbInfoElement_t *ie);
00254
00263 gboolean fbInfoElementEqual(
00264 const fbInfoElement_t *a,
00265 const fbInfoElement_t *b);
00266
00274 void fbInfoElementDebug(
00275 gboolean tmpl,
00276 fbInfoElement_t *ie);
00277
00285 const fbInfoElement_t *fbInfoModelGetElement(
00286 fbInfoModel_t *model,
00287 fbInfoElement_t *ex_ie);
00288
00297 gboolean fbInfoElementCopyToTemplate(
00298 fbInfoModel_t *model,
00299 fbInfoElement_t *ex_ie,
00300 fbInfoElement_t *tmpl_ie);
00301
00312 gboolean fbInfoElementCopyToTemplateByName(
00313 fbInfoModel_t *model,
00314 const char *name,
00315 uint16_t len_override,
00316 fbInfoElement_t *tmpl_ie);
00317
00325 void fbTemplateRetain(
00326 fbTemplate_t *tmpl);
00327
00335 void fbTemplateRelease(
00336 fbTemplate_t *tmpl);
00337
00345 void fbTemplateFree(
00346 fbTemplate_t *tmpl);
00347
00356 void fbTemplateDebug(
00357 const char *label,
00358 uint16_t tid,
00359 fbTemplate_t *tmpl);
00360
00367 fbNewTemplateCallback_fn fbSessionTemplateCallback(
00368 fbSession_t *session);
00375 fbSession_t *fbSessionClone(
00376 fbSession_t *base);
00377
00385 uint32_t fbSessionGetSequence(
00386 fbSession_t *session);
00387
00395 void fbSessionSetSequence(
00396 fbSession_t *session,
00397 uint32_t sequence);
00398
00406 void fbSessionSetTemplateBuffer(
00407 fbSession_t *session,
00408 fBuf_t *fbuf);
00409
00417 fbInfoModel_t *fbSessionGetInfoModel(
00418 fbSession_t *session);
00419
00420 #if HAVE_SPREAD
00421
00425 void fbSessionSetGroupParams(
00426 fbSession_t *session,
00427 sp_groupname_t *groups,
00428 int num_groups);
00429
00435 void fbSessionSetPrivateGroup(
00436 fbSession_t *session,
00437 char *group,
00438 char *privgroup);
00439
00444 void fbSessionSetGroup(
00445 fbSession_t *session,
00446 char *group);
00447
00452 unsigned int fbSessionGetGroupOffset(
00453 fbSession_t *session,
00454 char *group);
00455
00460 unsigned int fbSessionGetGroup(
00461 fbSession_t *session);
00462 #endif
00463
00471 gboolean fbConnSpecLookupAI(
00472 fbConnSpec_t *spec,
00473 gboolean passive,
00474 GError **err);
00475
00484 gboolean fbConnSpecInitTLS(
00485 fbConnSpec_t *spec,
00486 gboolean passive,
00487 GError **err);
00488
00496 fbConnSpec_t *fbConnSpecCopy(
00497 fbConnSpec_t *spec);
00498
00506 void fbConnSpecFree(
00507 fbConnSpec_t *spec);
00508
00509 #if HAVE_SPREAD
00510
00517 fbSpreadSpec_t *fbConnSpreadCopy(
00518 fbSpreadParams_t *spec);
00519
00527 void fbConnSpreadFree(
00528 fbSpreadSpec_t *spec);
00529
00538 const char * fbConnSpreadError(
00539 int err );
00540
00541
00551 void fbExporterSetGroupsToSend(
00552 fbExporter_t *exporter,
00553 char **groups,
00554 int num_groups);
00555
00556
00566 gboolean fbExporterCheckGroups(
00567 fbExporter_t *exporter,
00568 char **groups,
00569 int num_groups);
00570
00571
00572 #endif
00573
00581 uint16_t fbExporterGetMTU(
00582 fbExporter_t *exporter);
00583
00593 gboolean fbExportMessage(
00594 fbExporter_t *exporter,
00595 uint8_t *msgbase,
00596 size_t msglen,
00597 GError **err);
00598
00606 void fbExporterFree(
00607 fbExporter_t *exporter);
00608
00616 void fbCollectorRemoveListenerLastBuf(
00617 fBuf_t *fbuf,
00618 fbCollector_t *collector);
00619
00630 fbCollector_t *fbCollectorAllocSocket(
00631 fbListener_t *listener,
00632 void *ctx,
00633 int fd,
00634 struct sockaddr *peer,
00635 size_t peerlen);
00636
00648 fbCollector_t *fbCollectorAllocTLS(
00649 fbListener_t *listener,
00650 void *ctx,
00651 int fd,
00652 struct sockaddr *peer,
00653 size_t peerlen,
00654 GError **err);
00655
00665 gboolean fbCollectMessage(
00666 fbCollector_t *collector,
00667 uint8_t *msgbase,
00668 size_t *msglen,
00669 GError **err);
00670
00678 int fbCollectorGetFD(
00679 fbCollector_t *collector);
00680
00688 void fbCollectorFree(
00689 fbCollector_t *collector);
00690
00698 gboolean fbCollectorHasTranslator(
00699 fbCollector_t *collector);
00700
00701
00702 #if HAVE_SPREAD
00703
00710 gboolean fbCollectorTestGroupMembership(
00711 fbCollector_t *collector,
00712 int group_offset);
00713
00714 #endif
00715
00723 void fbListenerAppFree(
00724 fbListener_t *listener,
00725 void *ctx);
00726
00734 void fbListenerRemoveLastBuf(
00735 fBuf_t *fbuf,
00736 fbListener_t *listener);
00737
00745 void fbListenerRemove(
00746 fbListener_t *listener,
00747 int fd);
00748
00756 fbConnSpec_t *fbListenerGetConnSpec(
00757 fbListener_t *listener);
00758
00765 void fbCollectorInterruptSocket(
00766 fbCollector_t *collector);
00767 #endif