private.h
Go to the documentation of this file.
1/*
2 * Copyright 2006-2023 Carnegie Mellon University
3 * See license information in LICENSE.txt.
4 */
15/*
16 * ------------------------------------------------------------------------
17 * Authors: Brian Trammell
18 * ------------------------------------------------------------------------
19 */
20
21#ifndef _FB_PRIVATE_H_
22#define _FB_PRIVATE_H_
23#include <fixbuf/public.h>
24
25
27#define IPFIX_ENTERPRISE_BIT 0x8000
28
31#define FB_MSGLEN_MAX 65535
32
34#define FB_SSL_ERR_BUFSIZ 512
35
42typedef struct fbUDPConnSpec_st {
46 void *ctx;
48 union {
49 struct sockaddr so;
50 struct sockaddr_in ip4;
51 struct sockaddr_in6 ip6;
54 size_t peerlen;
60 time_t last_seen;
62 uint32_t obdomain;
64 gboolean reject;
66
67
74/* TODO...add a way to say if this field is this value, it highlights these
75 * records...thus removing app label spec...or screw it and leave it specific
76 */
79 uint16_t tid;
80 uint16_t appLabel;
81 uint16_t parentTid;
82 uint8_t padding[2];
90
91
96typedef struct fbElementPositions_st {
98 uint16_t count;
100 uint16_t *positions;
102
114 GHashTable *indices;
116 uint16_t *off_cache;
120 uint16_t ie_count;
125 uint16_t scope_count;
132 uint16_t ie_len;
143 uint16_t tmpl_len;
147 gboolean is_varlen;
155 gboolean active;
165 void *tmpl_ctx;
173 void *app_ctx;
174
187};
188
195void
197 fBuf_t *fbuf);
198
210gboolean
212 fBuf_t *fbuf,
213 uint16_t tmpl_id,
214 const fbTemplate_t *tmpl,
215 gboolean revoked,
216 GError **err);
217
223void
225 fBuf_t *fbuf,
226 const fbTemplate_t *tmpl);
227
232void
234 fBuf_t *fbuf,
235 fbSession_t *session);
236
241uint16_t
243 const fBuf_t *fbuf);
244
245
250uint16_t
252 const fBuf_t *fbuf);
253
261uint32_t
263 const fbInfoElement_t *ie);
264
273gboolean
275 const fbInfoElement_t *a,
276 const fbInfoElement_t *b);
277
285void
287 gboolean tmpl,
288 const fbInfoElement_t *ie);
289
297const fbInfoElement_t *
299 const fbInfoModel_t *model,
300 const fbInfoElement_t *ex_ie);
301
320gboolean
322 fbInfoModel_t *model,
323 const fbInfoElement_t *ex_ie,
324 fbTemplateField_t *tmpl_ie,
325 GError **err);
326
344gboolean
346 const fbInfoModel_t *model,
347 const fbInfoElementSpec_t *spec,
348 fbTemplateField_t *tmpl_ie,
349 GError **err);
350
369gboolean
371 const fbInfoModel_t *model,
372 const fbInfoElementSpecId_t *spec,
373 fbTemplateField_t *tmpl_ie,
374 GError **err);
375
384const fbInfoElement_t *
386 fbInfoModel_t *model,
387 const fbInfoElement_t *ex_ie);
388
399 fbInfoModel_t *model,
400 gboolean internal,
401 GError **err);
402
408gboolean
410 const fbTemplate_t *tmpl);
411
412
420void
422 fbTemplate_t *tmpl);
423
431void
433 fbTemplate_t *tmpl);
434
443void
445 const char *label,
446 uint16_t tid,
447 const fbTemplate_t *tmpl);
448
462 const fbTemplateInfoRecord_t *mdRec,
463 unsigned int mdRecVersion,
464 GError **err);
465
475void
477 const fbTemplateInfo_t *mdInfo,
479 const fbTemplate_t *stlTemplate,
480 uint16_t stlTid);
481
488void
490 fbTemplateInfo_t *mdInfo,
491 uint16_t tid);
492
500void
503
510void
513
526gboolean
528 fbInfoModel_t *model,
529 fbTemplate_t **tmplinfo_v3_tmpl,
530 fbTemplate_t **bl_ie_metadata_tmpl,
531 GError **err);
532
541 const fbSession_t *session);
542
550void *
552 const fbSession_t *session);
553
562 const fbSession_t *base);
563
571uint32_t
573 const fbSession_t *session);
574
582void
584 fbSession_t *session,
585 uint32_t sequence);
586
594void
596 fbSession_t *session,
597 fBuf_t *fbuf);
598
635gboolean
637 const fbSession_t *session,
638 uint16_t ext_tid,
639 uint16_t *int_tid,
640 fbTemplate_t **ext_tmpl,
641 fbTemplate_t **int_tmpl,
642 GError **err);
643
653void
655 fbSession_t *session,
656 gboolean disabled);
657
665void
667 fbSession_t *session,
668 fbCollector_t *collector);
669
676void
678 fbSession_t *session);
679
686void
688 fbSession_t *session);
689
696int
698 fbSession_t *session);
699
706int
708 fbSession_t *session);
709
717void
719 fbSession_t *session,
720 fbTemplateInfo_t *mdInfo);
721
732gboolean
734 fbSession_t *session,
735 GError **err);
736
750 fbSession_t *session,
751 uint16_t *tid,
752 GError **err);
753
769gboolean
771 fbSession_t *session,
772 GError **err);
773
787 fbSession_t *session,
788 uint16_t *tid,
789 GError **err);
790
799gboolean
801 fbConnSpec_t *spec,
802 gboolean passive,
803 GError **err);
804
813gboolean
815 fbConnSpec_t *spec,
816 gboolean passive,
817 GError **err);
818
828 const fbConnSpec_t *spec);
829
837void
839 fbConnSpec_t *spec);
840
848uint16_t
850 const fbExporter_t *exporter);
851
861gboolean
863 fbExporter_t *exporter,
864 uint8_t *msgbase,
865 size_t msglen,
866 GError **err);
867
875void
877 fbExporter_t *exporter);
878
886void
888 fBuf_t *fbuf,
889 fbCollector_t *collector);
890
904 fbListener_t *listener,
905 void *ctx,
906 int fd,
907 struct sockaddr *peer,
908 size_t peerlen,
909 GError **err);
910
924 fbListener_t *listener,
925 void *ctx,
926 int fd,
927 struct sockaddr *peer,
928 size_t peerlen,
929 GError **err);
930
940gboolean
942 fbCollector_t *collector,
943 uint8_t *msgbase,
944 size_t *msglen,
945 GError **err);
946
954int
956 const fbCollector_t *collector);
957
964void
966 fbCollector_t *collector,
967 int fd);
968
976void
978 fbCollector_t *collector);
979
987gboolean
989 fbCollector_t *collector);
990
991
1005gboolean
1007 uint8_t *hdr,
1008 size_t b_len,
1009 size_t *m_len,
1010 GError **err);
1011
1019void
1021 fbListener_t *listener,
1022 void *ctx);
1023
1031void
1033 fBuf_t *fbuf,
1034 fbListener_t *listener);
1035
1043void
1045 fbListener_t *listener,
1046 int fd);
1047
1057 const fbListener_t *listener);
1058
1065void
1067 fbCollector_t *collector);
1068
1073gboolean
1075 fbListener_t *listener,
1076 fbUDPConnSpec_t *spec,
1077 GError **err);
1078
1086 fbListener_t *listener,
1087 fbSession_t *session);
1088
1089
1090#endif /* _FB_PRIVATE_H_ */
1091
1092/*
1093 * @DISTRIBUTION_STATEMENT_BEGIN@
1094 * @DISTRIBUTION_STATEMENT_END@
1095 */
gboolean fbSessionAddInternalRfc5610Template(fbSession_t *session, GError **err)
fbSessionAddInternalRfc5610Template
fbElementPositions_t stl
Index positions of the FB_SUB_TMPL_LIST elements.
Definition: private.h:182
gboolean fbSessionAddInternalTemplateInfoTemplate(fbSession_t *session, GError **err)
fbSessionAddInternalTemplateInfoTemplate
void * tmpl_ctx
Template context.
Definition: private.h:165
void fbTemplateInfoFillRecord(const fbTemplateInfo_t *mdInfo, fbTemplateInfoRecord_t *mdRec, const fbTemplate_t *stlTemplate, uint16_t stlTid)
fbTemplateInfoFillRecord
fbVarfield_t name
Template name.
Definition: private.h:84
void fbSessionSetCollector(fbSession_t *session, fbCollector_t *collector)
fbSessionSetCollector
fbTemplateField_t ** ie_ary
Ordered array of pointers to information elements in this template.
Definition: private.h:112
uint16_t * positions
The list of positions; resized as needed.
Definition: private.h:100
fbNewTemplateCallback_fn fbSessionGetNewTemplateCallback(const fbSession_t *session)
Returns the callback function for a given session.
struct fbUDPConnSpec_st * next
link to next one in list
Definition: private.h:56
uint16_t tid
Template ID.
Definition: private.h:79
fbSession_t * fbSessionClone(const fbSession_t *base)
fbSessionClone
void * ctx
application context.
Definition: private.h:46
void fbTemplateDebug(const char *label, uint16_t tid, const fbTemplate_t *tmpl)
fbTemplateDebug
void fbSessionClearIntTmplTableFlag(fbSession_t *session)
fbSessionClearIntTmplTableFlag
uint16_t fbExporterGetMTU(const fbExporter_t *exporter)
fbExporterGetMTU
gboolean fBufAppendTemplate(fBuf_t *fbuf, uint16_t tmpl_id, const fbTemplate_t *tmpl, gboolean revoked, GError **err)
fBufAppendTemplate
void fBufRewind(fBuf_t *fbuf)
fBufRewind
fbCollector_t * fbCollectorAllocSocket(fbListener_t *listener, void *ctx, int fd, struct sockaddr *peer, size_t peerlen, GError **err)
fbCollectorAllocSocket
gboolean fbInfoElementEqual(const fbInfoElement_t *a, const fbInfoElement_t *b)
fbInfoElementEqual
int fbSessionExtTmplTableFlagIsSet(fbSession_t *session)
fbSessionExtTmplTableFlagIsSet
void fbTemplateRelease(fbTemplate_t *tmpl)
fbTemplateRelease
fbVarfield_t description
Template description (optional)
Definition: private.h:86
const fbInfoElement_t * fbInfoModelGetElement(const fbInfoModel_t *model, const fbInfoElement_t *ex_ie)
fbInfoModelGetElement
gboolean reject
reject flag
Definition: private.h:64
fbConnSpec_t * fbListenerGetConnSpec(const fbListener_t *listener)
fbListenerGetConnSpec
struct fbElementPositions_st fbElementPositions_t
fbElementPositions_t supports a variable-sized array that is used to store the index positions of a p...
size_t peerlen
size of peer
Definition: private.h:54
GHashTable * indices
Map of information element to index in ie_ary.
Definition: private.h:114
void * fbSessionGetNewTemplateCallbackAppCtx(const fbSession_t *session)
Returns the callback function's application context for a given session.
fbConnSpec_t * fbConnSpecCopy(const fbConnSpec_t *spec)
fbConnSpecCopy
void fbListenerRemoveLastBuf(fBuf_t *fbuf, fbListener_t *listener)
fbListenerRemoveLastBuf
uint16_t * off_cache
Field offset cache.
Definition: private.h:116
void fBufSetSession(fBuf_t *fbuf, fbSession_t *session)
fBufSetSession
void fbSessionSaveTemplateInfo(fbSession_t *session, fbTemplateInfo_t *mdInfo)
fbSessionSaveTemplateInfo
gboolean fbConnSpecInitTLS(fbConnSpec_t *spec, gboolean passive, GError **err)
fbConnSpecInitTLS
struct fbUDPConnSpec_st * prev
doubly linked to timeout faster
Definition: private.h:58
void fbSessionClearExtTmplTableFlag(fbSession_t *session)
fbSessionClearExtTmplTableFlag
void fbCollectorInterruptSocket(fbCollector_t *collector)
Interrupt the socket for a given collector to stop it from reading more data.
gboolean fbInfoElementCopyToTemplateByIdent(const fbInfoModel_t *model, const fbInfoElementSpecId_t *spec, fbTemplateField_t *tmpl_ie, GError **err)
fbInfoElementCopyToTemplateByIdent
uint16_t tmpl_len
Total length of the template record or options template record defining this template.
Definition: private.h:143
gboolean fbTemplateAllocTemplateInfoTemplates(fbInfoModel_t *model, fbTemplate_t **tmplinfo_v3_tmpl, fbTemplate_t **bl_ie_metadata_tmpl, GError **err)
Allocates new Templates to describe records that hold TemplateInfo.
gboolean fbConnSpecLookupAI(fbConnSpec_t *spec, gboolean passive, GError **err)
fbConnSpecLookupAI
void fbTemplateInfoRecordClear(fbTemplateInfoRecord_t *mdRec)
Clears any list data used by a fbTemplateInfoRecord_t.
gboolean fbSessionGetTemplatePair(const fbSession_t *session, uint16_t ext_tid, uint16_t *int_tid, fbTemplate_t **ext_tmpl, fbTemplate_t **int_tmpl, GError **err)
Checks for a template pair and finds the associated external and internal templates.
gboolean default_length
TRUE if any field was created using an fbInfoElementSpec_t with a defaulted length.
Definition: private.h:160
void fbTemplateInfoRecordInit(fbTemplateInfoRecord_t *mdRec)
fbTemplateInfoRecordInit
fbTemplate_t * fbInfoElementAllocTypeTemplate2(fbInfoModel_t *model, gboolean internal, GError **err)
fbInfoElementAllocTypeTemplate2
void fbTemplateRetain(fbTemplate_t *tmpl)
fbTemplateRetain
uint32_t fbSessionGetSequence(const fbSession_t *session)
fbSessionGetSequence
void * app_ctx
The application's Context pointer for the ctx_free function.
Definition: private.h:173
gboolean fbCollectMessageBuffer(uint8_t *hdr, size_t b_len, size_t *m_len, GError **err)
fbCollectMessageBuffer
uint16_t ie_count
Count of information elements in template.
Definition: private.h:120
struct fbUDPConnSpec_st fbUDPConnSpec_t
An UDP Connection specifier.
uint16_t count
The length of the array of positions.
Definition: private.h:98
gboolean fbCollectMessage(fbCollector_t *collector, uint8_t *msgbase, size_t *msglen, GError **err)
fbCollectMessage
gboolean is_varlen
TRUE if this template contains any variable length IEs.
Definition: private.h:147
fbCollector_t * fbCollectorAllocTLS(fbListener_t *listener, void *ctx, int fd, struct sockaddr *peer, size_t peerlen, GError **err)
fbCollectorAllocTLS
void fbSessionSetTemplatePairsDisabled(fbSession_t *session, gboolean disabled)
Sets the flag on a Session that says whether the template-pairs lookup table should be ignored.
gboolean fbCollectorHasTranslator(fbCollector_t *collector)
fbCollectorHasTranslator
int fbSessionIntTmplTableFlagIsSet(fbSession_t *session)
fbSessionIntTmplTableFlagIsSet
union fbUDPConnSpec_st::@0 peer
key to this conn spec
gboolean fbInfoElementCopyToTemplate(fbInfoModel_t *model, const fbInfoElement_t *ex_ie, fbTemplateField_t *tmpl_ie, GError **err)
fbInfoElementCopyToTemplate
int ref_count
Reference count.
Definition: private.h:118
uint32_t obdomain
with peer address this is the key
Definition: private.h:62
void fbTemplateInfoSetTemplateId(fbTemplateInfo_t *mdInfo, uint16_t tid)
fbTemplateInfoSetTemplateId
gboolean fbInfoModelIsTemplateElementType(const fbTemplate_t *tmpl)
fbInfoModelIsTemplateElementType
fbElementPositions_t bl
Index positions of the FB_BASIC_LIST elements.
Definition: private.h:178
void fbInfoElementDebug(gboolean tmpl, const fbInfoElement_t *ie)
fbInfoElementDebug
uint16_t ie_internal_len
Total length required to store this template in memory.
Definition: private.h:138
gboolean active
TRUE if this template has been activated (is no longer mutable).
Definition: private.h:155
uint16_t ie_len
Total length of information elements in records described by this template.
Definition: private.h:132
void fbSessionSetSequence(fbSession_t *session, uint32_t sequence)
fbSessionSetSequence
void fbCollectorSetFD(fbCollector_t *collector, int fd)
fbCollectorSetFD
gboolean contains_list
TRUE if this template contains any structured data (lists).
Definition: private.h:151
void fbListenerAppFree(fbListener_t *listener, void *ctx)
fbListenerAppFree
fbElementPositions_t stml
Index positions of the FB_SUB_TMPL_MULTI_LIST elements.
Definition: private.h:186
fbSubTemplateList_t blInfoList
List of PEN, IE num pairs.
Definition: private.h:88
fbSession_t * fbListenerSetPeerSession(fbListener_t *listener, fbSession_t *session)
Set the session on the fbuf and listener.
fbInfoModel_t * model
Information model (for looking up information elements by spec)
Definition: private.h:110
gboolean fbExportMessage(fbExporter_t *exporter, uint8_t *msgbase, size_t msglen, GError **err)
fbExportMessage
uint16_t scope_count
Count of scope information elements in template.
Definition: private.h:125
void fbCollectorRemoveListenerLastBuf(fBuf_t *fbuf, fbCollector_t *collector)
fbCollectorRemoveListenerLastBuf
uint16_t fBufGetExportTemplate(const fBuf_t *fbuf)
fBufGetExportTemplate
fbTemplate_t * fbSessionGetInternalTemplateInfoTemplate(fbSession_t *session, uint16_t *tid, GError **err)
fbSessionGetInternalTemplateInfoTemplate
gboolean fbListenerCallAppInit(fbListener_t *listener, fbUDPConnSpec_t *spec, GError **err)
call appinit from UDP
void fbExporterFree(fbExporter_t *exporter)
fbExporterFree
fbTemplateCtxFree_fn ctx_free
Callback to free the ctx pointer when template is freed.
Definition: private.h:169
void fbCollectorFree(fbCollector_t *collector)
fbCollectorFree
time_t last_seen
last seen time
Definition: private.h:60
uint32_t fbInfoElementHash(const fbInfoElement_t *ie)
fbInfoElementHash
void fBufRemoveTemplateTcplan(fBuf_t *fbuf, const fbTemplate_t *tmpl)
fBufRemoveTemplateTcplan
fbSession_t * session
pointer to the session for this peer address
Definition: private.h:44
int fbCollectorGetFD(const fbCollector_t *collector)
fbCollectorGetFD
gboolean fbInfoElementCopyToTemplateByName(const fbInfoModel_t *model, const fbInfoElementSpec_t *spec, fbTemplateField_t *tmpl_ie, GError **err)
fbInfoElementCopyToTemplateByName
const fbInfoElement_t * fbInfoModelAddAlienElement(fbInfoModel_t *model, const fbInfoElement_t *ex_ie)
fbInfoModelAddAlienElement
void fbSessionSetTemplateBuffer(fbSession_t *session, fBuf_t *fbuf)
fbSessionSetTemplateBuffer
uint16_t fBufGetInternalTemplate(const fBuf_t *fbuf)
fBufGetInternalTemplate
void fbListenerRemove(fbListener_t *listener, int fd)
fbListenerRemove
void fbConnSpecFree(fbConnSpec_t *spec)
fbConnSpecFree
fbTemplate_t * fbSessionGetInternalRfc5610Template(fbSession_t *session, uint16_t *tid, GError **err)
fbSessionGetInternalRfc5610Template
fbTemplateInfo_t * fbTemplateInfoCreateFromRecord(const fbTemplateInfoRecord_t *mdRec, unsigned int mdRecVersion, GError **err)
fbTemplateInfoCreateFromRecord
struct fbTemplateInfoRecord_st fbTemplateInfoRecord_t
TemplateInfo options record structure.
fbElementPositions_t supports a variable-sized array that is used to store the index positions of a p...
Definition: private.h:96
An IPFIX template or options template structure.
Definition: private.h:108
TemplateInfo options record structure.
Definition: private.h:77
An UDP Connection specifier.
Definition: private.h:42
Fixbuf IPFIX protocol library public interface.
void(* fbTemplateCtxFree_fn)(void *tmpl_ctx, void *app_ctx)
A callback function that is called when a template is freed.
Definition: public.h:2142
struct fbExporter_st fbExporter_t
IPFIX Exporting Process endpoint.
Definition: public.h:2077
void(* fbNewTemplateCallback_fn)(fbSession_t *session, uint16_t tid, fbTemplate_t *tmpl, void *app_ctx, void **tmpl_ctx, fbTemplateCtxFree_fn *tmpl_ctx_free_fn)
A callback function that will be called when the session receives a new external template.
Definition: public.h:2170
struct fbListener_st fbListener_t
IPFIX Collecting Process session listener.
Definition: public.h:2094
struct fbInfoModel_st fbInfoModel_t
An IPFIX information model.
Definition: public.h:164
struct fbTemplateInfo_st fbTemplateInfo_t
fbTemplateInfo_t describes an fbTemplate_t.
Definition: public.h:1782
struct fbSession_st fbSession_t
An IPFIX Transport Session state container.
Definition: public.h:1711
struct fBuf_st fBuf_t
An IPFIX message buffer.
Definition: public.h:139
struct fbCollector_st fbCollector_t
IPFIX Collecting Process endpoint.
Definition: public.h:2086
Connection specifier.
Definition: public.h:1747
A single IPFIX Information Element definition.
Definition: public.h:809
A single IPFIX Information Element specification.
Definition: public.h:1606
A single IPFIX Information Element specification using the element's numeric identifier and private e...
Definition: public.h:1660
fbSubTemplateList_t provides the internal representation of an fbInfoElement_t of type subTemplateLis...
Definition: public.h:2603
fbTemplateField_t represents an fbInfoElement_t that has been added to an fbTemplate_t.
Definition: public.h:1056
A variable-length field value.
Definition: public.h:147