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 18731 2013-02-28 15:59:53Z 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
00153 typedef struct fbUDPConnSpec_st {
00155 fbSession_t *session;
00157 void *ctx;
00159 union {
00160 struct sockaddr so;
00161 struct sockaddr_in ip4;
00162 struct sockaddr_in6 ip6;
00163 } peer;
00165 size_t peerlen;
00167 struct fbUDPConnSpec_st *next;
00169 struct fbUDPConnSpec_st *prev;
00171 time_t last_seen;
00173 uint32_t obdomain;
00175 gboolean reject;
00176 } fbUDPConnSpec_t;
00177
00178
00184 struct fbTemplate_st {
00186 fbInfoModel_t *model;
00188 int ref_count;
00190 uint16_t ie_count;
00195 uint16_t scope_count;
00202 uint16_t ie_len;
00208 uint16_t ie_internal_len;
00213 uint16_t tmpl_len;
00215 gboolean is_varlen;
00217 fbInfoElement_t **ie_ary;
00219 GHashTable *indices;
00221 uint16_t *off_cache;
00223 gboolean active;
00224 };
00225
00232 void fBufRewind(
00233 fBuf_t *fbuf);
00234
00246 gboolean fBufAppendTemplate(
00247 fBuf_t *fbuf,
00248 uint16_t tmpl_id,
00249 fbTemplate_t *tmpl,
00250 gboolean revoked,
00251 GError **err);
00252
00253 #if HAVE_SPREAD
00254
00260 void fBufSetExportGroups(
00261 fBuf_t *fbuf,
00262 char **groups,
00263 int num_groups,
00264 GError **err);
00265
00266
00267 #endif
00268
00274 void fBufRemoveTemplateTcplan(
00275 fBuf_t *fbuf,
00276 fbTemplate_t *tmpl);
00277
00282 void fBufSetSession(
00283 fBuf_t *fbuf,
00284 fbSession_t *session);
00285
00286
00294 uint32_t fbInfoElementHash(
00295 fbInfoElement_t *ie);
00296
00305 gboolean fbInfoElementEqual(
00306 const fbInfoElement_t *a,
00307 const fbInfoElement_t *b);
00308
00316 void fbInfoElementDebug(
00317 gboolean tmpl,
00318 fbInfoElement_t *ie);
00319
00327 const fbInfoElement_t *fbInfoModelGetElement(
00328 fbInfoModel_t *model,
00329 fbInfoElement_t *ex_ie);
00330
00339 gboolean fbInfoElementCopyToTemplate(
00340 fbInfoModel_t *model,
00341 fbInfoElement_t *ex_ie,
00342 fbInfoElement_t *tmpl_ie);
00343
00354 gboolean fbInfoElementCopyToTemplateByName(
00355 fbInfoModel_t *model,
00356 const char *name,
00357 uint16_t len_override,
00358 fbInfoElement_t *tmpl_ie);
00359
00367 void fbTemplateRetain(
00368 fbTemplate_t *tmpl);
00369
00377 void fbTemplateRelease(
00378 fbTemplate_t *tmpl);
00379
00387 void fbTemplateFree(
00388 fbTemplate_t *tmpl);
00389
00398 void fbTemplateDebug(
00399 const char *label,
00400 uint16_t tid,
00401 fbTemplate_t *tmpl);
00402
00409 fbNewTemplateCallback_fn fbSessionTemplateCallback(
00410 fbSession_t *session);
00417 fbSession_t *fbSessionClone(
00418 fbSession_t *base);
00419
00427 uint32_t fbSessionGetSequence(
00428 fbSession_t *session);
00429
00437 void fbSessionSetSequence(
00438 fbSession_t *session,
00439 uint32_t sequence);
00440
00448 void fbSessionSetTemplateBuffer(
00449 fbSession_t *session,
00450 fBuf_t *fbuf);
00451
00459 fbInfoModel_t *fbSessionGetInfoModel(
00460 fbSession_t *session);
00461
00462 #if HAVE_SPREAD
00463
00467 void fbSessionSetGroupParams(
00468 fbSession_t *session,
00469 sp_groupname_t *groups,
00470 int num_groups);
00471
00477 void fbSessionSetPrivateGroup(
00478 fbSession_t *session,
00479 char *group,
00480 char *privgroup);
00481
00486 void fbSessionSetGroup(
00487 fbSession_t *session,
00488 char *group);
00489
00494 unsigned int fbSessionGetGroupOffset(
00495 fbSession_t *session,
00496 char *group);
00497
00502 unsigned int fbSessionGetGroup(
00503 fbSession_t *session);
00504 #endif
00505
00513 gboolean fbConnSpecLookupAI(
00514 fbConnSpec_t *spec,
00515 gboolean passive,
00516 GError **err);
00517
00526 gboolean fbConnSpecInitTLS(
00527 fbConnSpec_t *spec,
00528 gboolean passive,
00529 GError **err);
00530
00538 fbConnSpec_t *fbConnSpecCopy(
00539 fbConnSpec_t *spec);
00540
00548 void fbConnSpecFree(
00549 fbConnSpec_t *spec);
00550
00551 #if HAVE_SPREAD
00552
00559 fbSpreadSpec_t *fbConnSpreadCopy(
00560 fbSpreadParams_t *spec);
00561
00569 void fbConnSpreadFree(
00570 fbSpreadSpec_t *spec);
00571
00580 const char * fbConnSpreadError(
00581 int err );
00582
00583
00593 void fbExporterSetGroupsToSend(
00594 fbExporter_t *exporter,
00595 char **groups,
00596 int num_groups);
00597
00598
00608 gboolean fbExporterCheckGroups(
00609 fbExporter_t *exporter,
00610 char **groups,
00611 int num_groups);
00612
00613
00614 #endif
00615
00623 uint16_t fbExporterGetMTU(
00624 fbExporter_t *exporter);
00625
00635 gboolean fbExportMessage(
00636 fbExporter_t *exporter,
00637 uint8_t *msgbase,
00638 size_t msglen,
00639 GError **err);
00640
00648 void fbExporterFree(
00649 fbExporter_t *exporter);
00650
00658 void fbCollectorRemoveListenerLastBuf(
00659 fBuf_t *fbuf,
00660 fbCollector_t *collector);
00661
00672 fbCollector_t *fbCollectorAllocSocket(
00673 fbListener_t *listener,
00674 void *ctx,
00675 int fd,
00676 struct sockaddr *peer,
00677 size_t peerlen);
00678
00690 fbCollector_t *fbCollectorAllocTLS(
00691 fbListener_t *listener,
00692 void *ctx,
00693 int fd,
00694 struct sockaddr *peer,
00695 size_t peerlen,
00696 GError **err);
00697
00707 gboolean fbCollectMessage(
00708 fbCollector_t *collector,
00709 uint8_t *msgbase,
00710 size_t *msglen,
00711 GError **err);
00712
00720 int fbCollectorGetFD(
00721 fbCollector_t *collector);
00722
00730 void fbCollectorFree(
00731 fbCollector_t *collector);
00732
00740 gboolean fbCollectorHasTranslator(
00741 fbCollector_t *collector);
00742
00743
00744 #if HAVE_SPREAD
00745
00752 gboolean fbCollectorTestGroupMembership(
00753 fbCollector_t *collector,
00754 int group_offset);
00755
00756 #endif
00757
00765 void fbListenerAppFree(
00766 fbListener_t *listener,
00767 void *ctx);
00768
00776 void fbListenerRemoveLastBuf(
00777 fBuf_t *fbuf,
00778 fbListener_t *listener);
00779
00787 void fbListenerRemove(
00788 fbListener_t *listener,
00789 int fd);
00790
00798 fbConnSpec_t *fbListenerGetConnSpec(
00799 fbListener_t *listener);
00800
00807 void fbCollectorInterruptSocket(
00808 fbCollector_t *collector);
00809
00814 gboolean fbListenerCallAppInit(
00815 fbListener_t *listener,
00816 fbUDPConnSpec_t *spec,
00817 GError **err);
00818
00824 fbSession_t *fbListenerSetPeerSession(
00825 fbListener_t *listener,
00826 fbSession_t *session);
00827
00828 #endif