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 #ifdef 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;
229  /* Callback to free the ctx pointer when template is freed */
230  fbTemplateCtxFree_fn ctx_free;
231 };
232 
239 void fBufRewind(
240  fBuf_t *fbuf);
241 
253 gboolean fBufAppendTemplate(
254  fBuf_t *fbuf,
255  uint16_t tmpl_id,
256  fbTemplate_t *tmpl,
257  gboolean revoked,
258  GError **err);
259 
260 #if HAVE_SPREAD
261 
267 void fBufSetExportGroups(
268  fBuf_t *fbuf,
269  char **groups,
270  int num_groups,
271  GError **err);
272 
273 
274 #endif
275 
282  fBuf_t *fbuf,
283  fbTemplate_t *tmpl);
284 
289 void fBufSetSession(
290  fBuf_t *fbuf,
291  fbSession_t *session);
292 
293 
301 uint32_t fbInfoElementHash(
302  fbInfoElement_t *ie);
303 
312 gboolean fbInfoElementEqual(
313  const fbInfoElement_t *a,
314  const fbInfoElement_t *b);
315 
323 void fbInfoElementDebug(
324  gboolean tmpl,
325  fbInfoElement_t *ie);
326 
335  fbInfoModel_t *model,
336  fbInfoElement_t *ex_ie);
337 
347  fbInfoModel_t *model,
348  fbInfoElement_t *ex_ie,
349  fbInfoElement_t *tmpl_ie);
350 
362  fbInfoModel_t *model,
363  const char *name,
364  uint16_t len_override,
365  fbInfoElement_t *tmpl_ie);
366 
374 void fbTemplateRetain(
375  fbTemplate_t *tmpl);
376 
384 void fbTemplateRelease(
385  fbTemplate_t *tmpl);
386 
394 void fbTemplateFree(
395  fbTemplate_t *tmpl);
396 
405 void fbTemplateDebug(
406  const char *label,
407  uint16_t tid,
408  fbTemplate_t *tmpl);
409 
417  fbSession_t *session);
418 
426  fbSession_t *session);
427 
435  fbSession_t *base);
436 
444 uint32_t fbSessionGetSequence(
445  fbSession_t *session);
446 
455  fbSession_t *session,
456  uint32_t sequence);
457 
466  fbSession_t *session,
467  fBuf_t *fbuf);
468 
469 #if HAVE_SPREAD
470 
474 void fbSessionSetGroupParams(
475  fbSession_t *session,
476  sp_groupname_t *groups,
477  int num_groups);
478 
484 void fbSessionSetPrivateGroup(
485  fbSession_t *session,
486  char *group,
487  char *privgroup);
488 
493 void fbSessionSetGroup(
494  fbSession_t *session,
495  char *group);
496 
501 unsigned int fbSessionGetGroupOffset(
502  fbSession_t *session,
503  char *group);
504 
509 unsigned int fbSessionGetGroup(
510  fbSession_t *session);
511 #endif
512 
520 gboolean fbConnSpecLookupAI(
521  fbConnSpec_t *spec,
522  gboolean passive,
523  GError **err);
524 
533 gboolean fbConnSpecInitTLS(
534  fbConnSpec_t *spec,
535  gboolean passive,
536  GError **err);
537 
546  fbConnSpec_t *spec);
547 
555 void fbConnSpecFree(
556  fbConnSpec_t *spec);
557 
558 #if HAVE_SPREAD
559 
566 fbSpreadSpec_t *fbConnSpreadCopy(
567  fbSpreadParams_t *spec);
568 
576 void fbConnSpreadFree(
577  fbSpreadSpec_t *spec);
578 
587 const char * fbConnSpreadError(
588  int err );
589 
590 
600 void fbExporterSetGroupsToSend(
601  fbExporter_t *exporter,
602  char **groups,
603  int num_groups);
604 
605 
615 gboolean fbExporterCheckGroups(
616  fbExporter_t *exporter,
617  char **groups,
618  int num_groups);
619 
620 
621 #endif /* HAVE_SPREAD */
622 
630 uint16_t fbExporterGetMTU(
631  fbExporter_t *exporter);
632 
642 gboolean fbExportMessage(
643  fbExporter_t *exporter,
644  uint8_t *msgbase,
645  size_t msglen,
646  GError **err);
647 
655 void fbExporterFree(
656  fbExporter_t *exporter);
657 
666  fBuf_t *fbuf,
667  fbCollector_t *collector);
668 
680  fbListener_t *listener,
681  void *ctx,
682  int fd,
683  struct sockaddr *peer,
684  size_t peerlen);
685 
698  fbListener_t *listener,
699  void *ctx,
700  int fd,
701  struct sockaddr *peer,
702  size_t peerlen,
703  GError **err);
704 
714 gboolean fbCollectMessage(
715  fbCollector_t *collector,
716  uint8_t *msgbase,
717  size_t *msglen,
718  GError **err);
719 
727 int fbCollectorGetFD(
728  fbCollector_t *collector);
729 
737 void fbCollectorFree(
738  fbCollector_t *collector);
739 
747 gboolean fbCollectorHasTranslator(
748  fbCollector_t *collector);
749 
750 
751 #if HAVE_SPREAD
752 
759 gboolean fbCollectorTestGroupMembership(
760  fbCollector_t *collector,
761  int group_offset);
762 
763 #endif
764 
772 void fbListenerAppFree(
773  fbListener_t *listener,
774  void *ctx);
775 
784  fBuf_t *fbuf,
785  fbListener_t *listener);
786 
794 void fbListenerRemove(
795  fbListener_t *listener,
796  int fd);
797 
806  fbListener_t *listener);
807 
815  fbCollector_t *collector);
816 
821 gboolean fbListenerCallAppInit(
822  fbListener_t *listener,
823  fbUDPConnSpec_t *spec,
824  GError **err);
825 
832  fbListener_t *listener,
833  fbSession_t *session);
834 
835 #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:1323
struct fbExporter_st fbExporter_t
IPFIX Exporting Process endpoint.
Definition: public.h:1313
int fbCollectorGetFD(fbCollector_t *collector)
fbCollectorGetFD
struct fbSession_st fbSession_t
An IPFIX Transport Session state container.
Definition: public.h:1215
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:1332
void(* fbTemplateCtxFree_fn)(void *ctx)
A callback function that is called when a template is freed.
Definition: public.h:1429
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:1454
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:1417
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:768
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 fbInfoElementEqual(const fbInfoElement_t *a, const fbInfoElement_t *b)
fbInfoElementEqual
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:1251
struct fBuf_st fBuf_t
An IPFIX message buffer.
Definition: public.h:742
void fbTemplateFree(fbTemplate_t *tmpl)
fbTemplateFree
A single IPFIX Information Element definition.
Definition: public.h:1077
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
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