private.h
Go to the documentation of this file.
1 
61 #ifndef _FB_PRIVATE_H_
62 #define _FB_PRIVATE_H_
63 #include <fixbuf/public.h>
64 
65 #if HAVE_SPREAD
66 #include <sp.h>
67 #include <pthread.h>
68 #endif
69 
70 #ident "$Id$"
71 
84 #define IPFIX_ENTERPRISE_BIT 0x8000
85 
87 #define IPFIX_REVERSE_PEN 29305
88 
91 #define FB_MSGLEN_MAX 65535
92 
93 #if HAVE_SPREAD
94 
95 typedef struct sp_groupname_st
96 {
97  char name[MAX_GROUP_NAME];
98 } sp_groupname_t;
99 
100 #define FB_SPREAD_NUM_GROUPS 16
101 #define FB_SPREAD_MTU 8192
102 
103 typedef struct fbSpreadSpec_st {
106  fbSession_t *session;
109  char * daemon;
111  sp_groupname_t *groups;
113  int num_groups;
115  sp_groupname_t *groups_to_send;
116  int num_groups_to_send;
118  mailbox mbox;
120  char privgroup[MAX_GROUP_NAME + 2];
122  pthread_mutex_t write_lock;
124  pthread_t recv_thread;
126  mailbox recv_mbox;
128  char recv_privgroup[MAX_GROUP_NAME + 2];
130  GError *recv_err;
132  int recv_exit;
134  int recv_max_groups;
136  int recv_num_groups;
138  sp_groupname_t *recv_groups;
140  int recv_max;
142  char *recv_mess;
143 } fbSpreadSpec_t;
144 
145 #endif /* HAVE_SPREAD */
146 
153 typedef struct fbUDPConnSpec_st {
157  void *ctx;
159  union {
160  struct sockaddr so;
161  struct sockaddr_in ip4;
162  struct sockaddr_in6 ip6;
163  } peer;
165  size_t peerlen;
171  time_t last_seen;
173  uint32_t obdomain;
175  gboolean reject;
177 
178 
190  uint16_t ie_count;
195  uint16_t scope_count;
202  uint16_t ie_len;
208  uint16_t ie_internal_len;
213  uint16_t tmpl_len;
215  gboolean is_varlen;
219  GHashTable *indices;
221  uint16_t *off_cache;
223  gboolean active;
228  void *ctx;
233 };
234 
241 void fBufRewind(
242  fBuf_t *fbuf);
243 
255 gboolean fBufAppendTemplate(
256  fBuf_t *fbuf,
257  uint16_t tmpl_id,
258  fbTemplate_t *tmpl,
259  gboolean revoked,
260  GError **err);
261 
262 #if HAVE_SPREAD
263 
269 void fBufSetExportGroups(
270  fBuf_t *fbuf,
271  char **groups,
272  int num_groups,
273  GError **err);
274 
275 
276 #endif
277 
284  fBuf_t *fbuf,
285  fbTemplate_t *tmpl);
286 
291 void fBufSetSession(
292  fBuf_t *fbuf,
293  fbSession_t *session);
294 
295 
303 uint32_t fbInfoElementHash(
304  fbInfoElement_t *ie);
305 
314 gboolean fbInfoElementEqual(
315  const fbInfoElement_t *a,
316  const fbInfoElement_t *b);
317 
325 void fbInfoElementDebug(
326  gboolean tmpl,
327  fbInfoElement_t *ie);
328 
337  fbInfoModel_t *model,
338  fbInfoElement_t *ex_ie);
339 
349  fbInfoModel_t *model,
350  fbInfoElement_t *ex_ie,
351  fbInfoElement_t *tmpl_ie);
352 
364  fbInfoModel_t *model,
365  const char *name,
366  uint16_t len_override,
367  fbInfoElement_t *tmpl_ie);
368 
376 void fbTemplateRetain(
377  fbTemplate_t *tmpl);
378 
386 void fbTemplateRelease(
387  fbTemplate_t *tmpl);
388 
396 void fbTemplateFree(
397  fbTemplate_t *tmpl);
398 
407 void fbTemplateDebug(
408  const char *label,
409  uint16_t tid,
410  fbTemplate_t *tmpl);
411 
419  fbSession_t *session);
420 
428  fbSession_t *session);
429 
437  fbSession_t *base);
438 
446 uint32_t fbSessionGetSequence(
447  fbSession_t *session);
448 
457  fbSession_t *session,
458  uint32_t sequence);
459 
468  fbSession_t *session,
469  fBuf_t *fbuf);
470 
479  fbSession_t *session,
480  fbCollector_t *collector);
481 
482 #if HAVE_SPREAD
483 
487 void fbSessionSetGroupParams(
488  fbSession_t *session,
489  sp_groupname_t *groups,
490  int num_groups);
491 
497 void fbSessionSetPrivateGroup(
498  fbSession_t *session,
499  char *group,
500  char *privgroup);
501 
506 void fbSessionSetGroup(
507  fbSession_t *session,
508  char *group);
509 
514 unsigned int fbSessionGetGroupOffset(
515  fbSession_t *session,
516  char *group);
517 
522 unsigned int fbSessionGetGroup(
523  fbSession_t *session);
524 #endif
525 
526 void fbSessionClearIntTmplTableFlag(
527  fbSession_t *session);
528 
529 void fbSessionClearExtTmplTableFlag(
530  fbSession_t *session);
531 
532 int fbSessionIntTmplTableFlagIsSet(
533  fbSession_t *session);
534 
535 int fbSessionExtTmplTableFlagIsSet(
536  fbSession_t *session);
545 gboolean fbConnSpecLookupAI(
546  fbConnSpec_t *spec,
547  gboolean passive,
548  GError **err);
549 
558 gboolean fbConnSpecInitTLS(
559  fbConnSpec_t *spec,
560  gboolean passive,
561  GError **err);
562 
571  fbConnSpec_t *spec);
572 
580 void fbConnSpecFree(
581  fbConnSpec_t *spec);
582 
583 #if HAVE_SPREAD
584 
591 fbSpreadSpec_t *fbConnSpreadCopy(
592  fbSpreadParams_t *spec);
593 
601 void fbConnSpreadFree(
602  fbSpreadSpec_t *spec);
603 
612 const char * fbConnSpreadError(
613  int err );
614 
615 
625 void fbExporterSetGroupsToSend(
626  fbExporter_t *exporter,
627  char **groups,
628  int num_groups);
629 
630 
640 gboolean fbExporterCheckGroups(
641  fbExporter_t *exporter,
642  char **groups,
643  int num_groups);
644 
645 
646 #endif /* HAVE_SPREAD */
647 
655 uint16_t fbExporterGetMTU(
656  fbExporter_t *exporter);
657 
667 gboolean fbExportMessage(
668  fbExporter_t *exporter,
669  uint8_t *msgbase,
670  size_t msglen,
671  GError **err);
672 
680 void fbExporterFree(
681  fbExporter_t *exporter);
682 
691  fBuf_t *fbuf,
692  fbCollector_t *collector);
693 
705  fbListener_t *listener,
706  void *ctx,
707  int fd,
708  struct sockaddr *peer,
709  size_t peerlen);
710 
723  fbListener_t *listener,
724  void *ctx,
725  int fd,
726  struct sockaddr *peer,
727  size_t peerlen,
728  GError **err);
729 
739 gboolean fbCollectMessage(
740  fbCollector_t *collector,
741  uint8_t *msgbase,
742  size_t *msglen,
743  GError **err);
744 
752 int fbCollectorGetFD(
753  fbCollector_t *collector);
754 
761 void fbCollectorSetFD(
762  fbCollector_t *collector,
763  int fd);
764 
772 void fbCollectorFree(
773  fbCollector_t *collector);
774 
782 gboolean fbCollectorHasTranslator(
783  fbCollector_t *collector);
784 
785 
799 gboolean fbCollectMessageBuffer(
800  uint8_t *hdr,
801  size_t b_len,
802  size_t *m_len,
803  GError **err);
804 
805 
806 #if HAVE_SPREAD
807 
814 gboolean fbCollectorTestGroupMembership(
815  fbCollector_t *collector,
816  int group_offset);
817 
818 #endif
819 
827 void fbListenerAppFree(
828  fbListener_t *listener,
829  void *ctx);
830 
839  fBuf_t *fbuf,
840  fbListener_t *listener);
841 
849 void fbListenerRemove(
850  fbListener_t *listener,
851  int fd);
852 
861  fbListener_t *listener);
862 
870  fbCollector_t *collector);
871 
876 gboolean fbListenerCallAppInit(
877  fbListener_t *listener,
878  fbUDPConnSpec_t *spec,
879  GError **err);
880 
887  fbListener_t *listener,
888  fbSession_t *session);
889 
890 #endif
gboolean reject
reject flag
Definition: private.h:175
gboolean fbCollectMessage(fbCollector_t *collector, uint8_t *msgbase, size_t *msglen, GError **err)
fbCollectMessage
void fbTemplateRelease(fbTemplate_t *tmpl)
fbTemplateRelease
fbSession_t * fbListenerSetPeerSession(fbListener_t *listener, fbSession_t *session)
Set the session on the fbuf and listener.
void fbCollectorInterruptSocket(fbCollector_t *collector)
Interrupt the socket for a given collector to stop it from reading more data.
gboolean fbInfoElementCopyToTemplateByName(fbInfoModel_t *model, const char *name, uint16_t len_override, fbInfoElement_t *tmpl_ie)
fbInfoElementCopyToTemplateByName
void * ctx
application context.
Definition: private.h:157
struct fbUDPConnSpec_st * prev
doubly linked to timeout faster
Definition: private.h:169
fbTemplateCtxCallback_fn fbSessionTemplateCtxCallback(fbSession_t *session)
Return the ctx callback function for a given session.
const fbInfoElement_t * fbInfoModelGetElement(fbInfoModel_t *model, fbInfoElement_t *ex_ie)
fbInfoModelGetElement
void * ctx
Template context.
Definition: private.h:228
size_t peerlen
size of peer
Definition: private.h:165
struct fbCollector_st fbCollector_t
IPFIX Collecting Process endpoint.
Definition: public.h:1501
struct fbExporter_st fbExporter_t
IPFIX Exporting Process endpoint.
Definition: public.h:1491
int fbCollectorGetFD(fbCollector_t *collector)
fbCollectorGetFD
struct fbSession_st fbSession_t
An IPFIX Transport Session state container.
Definition: public.h:1393
fbCollector_t * fbCollectorAllocSocket(fbListener_t *listener, void *ctx, int fd, struct sockaddr *peer, size_t peerlen)
fbCollectorAllocSocket
struct fbListener_st fbListener_t
IPFIX Collecting Process session listener.
Definition: public.h:1510
void(* fbTemplateCtxFree_fn)(void *ctx)
A callback function that is called when a template is freed.
Definition: public.h:1584
uint32_t fbInfoElementHash(fbInfoElement_t *ie)
fbInfoElementHash
gboolean active
TRUE if this template has been activated (is no longer mutable)
Definition: private.h:223
gboolean fbListenerCallAppInit(fbListener_t *listener, fbUDPConnSpec_t *spec, GError **err)
call appinit from UDP
time_t last_seen
last seen time
Definition: private.h:171
uint16_t ie_count
Count of information elements in template.
Definition: private.h:190
fbInfoModel_t * model
Information model (for looking up information elements by spec)
Definition: private.h:186
gboolean fBufAppendTemplate(fBuf_t *fbuf, uint16_t tmpl_id, fbTemplate_t *tmpl, gboolean revoked, GError **err)
fBufAppendTemplate
fbNewTemplateCallback_fn fbSessionTemplateCallback(fbSession_t *session)
Returns the callback function for a given session.
An UDP Connection specifier.
Definition: private.h:153
void fbCollectorRemoveListenerLastBuf(fBuf_t *fbuf, fbCollector_t *collector)
fbCollectorRemoveListenerLastBuf
gboolean fbConnSpecInitTLS(fbConnSpec_t *spec, gboolean passive, GError **err)
fbConnSpecInitTLS
uint16_t ie_internal_len
Total length required to store this template in a data structure.
Definition: private.h:208
struct fbUDPConnSpec_st * next
link to next one in list
Definition: private.h:167
Fixbuf IPFIX protocol library public interface.
void fbTemplateRetain(fbTemplate_t *tmpl)
fbTemplateRetain
void fbListenerRemove(fbListener_t *listener, int fd)
fbListenerRemove
void(* fbTemplateCtxCallback_fn)(fbSession_t *session, uint16_t tid, fbTemplate_t *tmpl, void **ctx, fbTemplateCtxFree_fn *fn)
A new callback function that will be called when the session receives a new external template...
Definition: public.h:1609
gboolean fbConnSpecLookupAI(fbConnSpec_t *spec, gboolean passive, GError **err)
fbConnSpecLookupAI
gboolean fbExportMessage(fbExporter_t *exporter, uint8_t *msgbase, size_t msglen, GError **err)
fbExportMessage
int ref_count
Reference count.
Definition: private.h:188
uint32_t obdomain
with peer address this is the key
Definition: private.h:173
void fbTemplateDebug(const char *label, uint16_t tid, fbTemplate_t *tmpl)
fbTemplateDebug
void fbCollectorFree(fbCollector_t *collector)
fbCollectorFree
fbSession_t * fbSessionClone(fbSession_t *base)
fbSessionClone
void(* fbNewTemplateCallback_fn)(fbSession_t *session, uint16_t tid, fbTemplate_t *tmpl)
The callback function to be called when the session receives a new external template from the connect...
Definition: public.h:1572
uint16_t tmpl_len
Total length of the template record or options template record defining this template.
Definition: private.h:213
struct fbInfoModel_st fbInfoModel_t
An IPFIX information model.
Definition: public.h:927
gboolean fbCollectorHasTranslator(fbCollector_t *collector)
fbCollectorHasTranslator
void fbListenerAppFree(fbListener_t *listener, void *ctx)
fbListenerAppFree
uint16_t ie_len
Total length of information elements in records described by this template.
Definition: private.h:202
void fbConnSpecFree(fbConnSpec_t *spec)
fbConnSpecFree
uint16_t * off_cache
Field offset cache.
Definition: private.h:221
void fBufRewind(fBuf_t *fbuf)
fBufRewind
void fbListenerRemoveLastBuf(fBuf_t *fbuf, fbListener_t *listener)
fbListenerRemoveLastBuf
GHashTable * indices
Map of information element to index in ie_ary.
Definition: private.h:219
void fbSessionSetTemplateBuffer(fbSession_t *session, fBuf_t *fbuf)
fbSessionSetTemplateBuffer
gboolean is_varlen
Set to TRUE if this template contains any variable length IEs.
Definition: private.h:215
void fbExporterFree(fbExporter_t *exporter)
fbExporterFree
gboolean fbCollectMessageBuffer(uint8_t *hdr, size_t b_len, size_t *m_len, GError **err)
fbCollectMessageBuffer
gboolean fbInfoElementEqual(const fbInfoElement_t *a, const fbInfoElement_t *b)
fbInfoElementEqual
void fbCollectorSetFD(fbCollector_t *collector, int fd)
fbCollectorSetFD
gboolean fbInfoElementCopyToTemplate(fbInfoModel_t *model, fbInfoElement_t *ex_ie, fbInfoElement_t *tmpl_ie)
fbInfoElementCopyToTemplate
uint32_t fbSessionGetSequence(fbSession_t *session)
fbSessionGetSequence
uint16_t fbExporterGetMTU(fbExporter_t *exporter)
fbExporterGetMTU
An IPFIX template or options template structure.
Definition: private.h:184
fbConnSpec_t * fbConnSpecCopy(fbConnSpec_t *spec)
fbConnSpecCopy
void fbInfoElementDebug(gboolean tmpl, fbInfoElement_t *ie)
fbInfoElementDebug
union fbUDPConnSpec_st::@0 peer
key to this conn spec
fbInfoElement_t ** ie_ary
Ordered array of pointers to information elements in this template.
Definition: private.h:217
fbCollector_t * fbCollectorAllocTLS(fbListener_t *listener, void *ctx, int fd, struct sockaddr *peer, size_t peerlen, GError **err)
fbCollectorAllocTLS
Connection specifier.
Definition: public.h:1429
void fbSessionSetCollector(fbSession_t *session, fbCollector_t *collector)
fbSessionSetCollector
struct fBuf_st fBuf_t
An IPFIX message buffer.
Definition: public.h:901
void fbTemplateFree(fbTemplate_t *tmpl)
fbTemplateFree
A single IPFIX Information Element definition.
Definition: public.h:1255
uint16_t scope_count
Count of scope information elements in template.
Definition: private.h:195
fbConnSpec_t * fbListenerGetConnSpec(fbListener_t *listener)
fbListenerGetConnSpec
void fBufSetSession(fBuf_t *fbuf, fbSession_t *session)
fBufSetSession
fbTemplateCtxFree_fn ctx_free
Callback to free the ctx pointer when template is freed.
Definition: private.h:232
struct fbUDPConnSpec_st fbUDPConnSpec_t
An UDP Connection specifier.
void fbSessionSetSequence(fbSession_t *session, uint32_t sequence)
fbSessionSetSequence
fbSession_t * session
pointer to the session for this peer address
Definition: private.h:155
void fBufRemoveTemplateTcplan(fBuf_t *fbuf, fbTemplate_t *tmpl)
fBufRemoveTemplateTcplan