1 /**
2  *@internal
3  *
4  ** private.h
5  ** fixbuf IPFIX Implementation Private Interface
6  **
7  ** ------------------------------------------------------------------------
8  ** Copyright (C) 2006-2019 Carnegie Mellon University. All Rights Reserved.
9  ** ------------------------------------------------------------------------
10  ** Authors: Brian Trammell
11  ** ------------------------------------------------------------------------
12  ** @OPENSOURCE_LICENSE_START@
13  ** libfixbuf 2.0
14  **
15  ** Copyright 2018-2019 Carnegie Mellon University. All Rights Reserved.
16  **
17  ** NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE
18  ** ENGINEERING INSTITUTE MATERIAL IS FURNISHED ON AN "AS-IS"
19  ** BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND,
20  ** EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT
21  ** LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY,
22  ** EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE
23  ** MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF
24  ** ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR
25  ** COPYRIGHT INFRINGEMENT.
26  **
27  ** Released under a GNU-Lesser GPL 3.0-style license, please see
28  ** LICENSE.txt or contact permission@sei.cmu.edu for full terms.
29  **
30  ** [DISTRIBUTION STATEMENT A] This material has been approved for
31  ** public release and unlimited distribution.  Please see Copyright
32  ** notice for non-US Government use and distribution.
33  **
34  ** Carnegie Mellon(R) and CERT(R) are registered in the U.S. Patent
35  ** and Trademark Office by Carnegie Mellon University.
36  **
37  ** DM18-0325
38  ** @OPENSOURCE_LICENSE_END@
39  ** ------------------------------------------------------------------------
40  */
41 
42 #ifndef _FB_PRIVATE_H_
43 #define _FB_PRIVATE_H_
44 #include <fixbuf/public.h>
45 
46 #if HAVE_SPREAD
47 #include <sp.h>
48 #include <pthread.h>
49 #endif
50 
51 
52 /**
53  * @file
54  *
55  * fixbuf IPFIX protocol library private interface. These calls and structures
56  * are intended for the use of libfixbuf modules, and as such are not
57  * documented or guaranteed to remain stable in any way. Applications using
58  * these calls and structures may have to be modified to track changes to this
59  * interface across minor version releases of fixbuf.
60  */
61 
62 
63 /** define the bit in ID's that marks the Enterprise ID's */
64 #define IPFIX_ENTERPRISE_BIT    0x8000
65 
66 /** definition of the max-size of an fbuf_t buffer, or the
67     default/only size */
68 #define FB_MSGLEN_MAX       65535
69 
70 #if HAVE_SPREAD
71 
72 /**
73  * sp_groupname_t
74  */
75 typedef struct sp_groupname_st
76 {
77     char    name[MAX_GROUP_NAME];
78 } sp_groupname_t;
79 
80 /** maximum number of groups supported */
81 #define FB_SPREAD_NUM_GROUPS    16
82 
83 /** maximum size of expected message */
84 #define FB_SPREAD_MTU           8192
85 
86 /**
87  * fbSpreadSpec_t
88  */
89 typedef struct fbSpreadSpec_st {
90     /** pointer to the session, this MUST be set to a valid session before
91     *   the spec is passed to fbExporterAllocSpread. */
92     fbSession_t     *session;
93     /** pointer to the daemon host address, in Spread format.  Must be set
94     *   before the spec is passed to fbExporterAllocSpread */
95     char *          daemon;
96     /** pointer to array of group names, must have at least one, and
97      * must be null term array */
98     sp_groupname_t  *groups;
99     /** number of groups in groups */
100     int             num_groups;
101     /** groups to send to */
102     sp_groupname_t  *groups_to_send;
103     int             num_groups_to_send;
104     /** the mailbox for the connection */
105     mailbox         mbox;
106     /** the connection private name */
107     char            privgroup[MAX_GROUP_NAME + 2];
108     /** Spread write lock */
109     pthread_mutex_t write_lock;
110     /** the receiver thread */
111     pthread_t       recv_thread;
112     /** the receiver's mailbox */
113     mailbox         recv_mbox;
114     /** the connection private name for the receiver */
115     char            recv_privgroup[MAX_GROUP_NAME + 2];
116     /** GError for thread errors, set by receiver, read by main */
117     GError          *recv_err;
118     /** flag to tell the thread to exit */
119     int             recv_exit;
120     /** max size of group name array */
121     int             recv_max_groups;
122     /** actual size of group name array */
123     int             recv_num_groups;
124     /** groups array for SP_receive */
125     sp_groupname_t  *recv_groups;
126     /** length of message buffer */
127     int             recv_max;
128     /** message buffer for receive */
129     char            *recv_mess;
130 } fbSpreadSpec_t;
131 
132 #endif /* HAVE_SPREAD */
133 
134 /**
135  * An UDP Connection specifier.  These are managed by the
136  * collector.  The collector creates one fbUDPConnSpec_t
137  * per "UDP session." A UDP session is defined by a unique
138  * IP and observation domain."
139  */
140 typedef struct fbUDPConnSpec_st {
141     /** pointer to the session for this peer address */
142     fbSession_t             *session;
143     /** application context. Created and owned by the app */
144     void                    *ctx;
145     /** key to this conn spec */
146     union {
147         struct sockaddr      so;
148         struct sockaddr_in   ip4;
149         struct sockaddr_in6  ip6;
150     } peer;
151     /** size of peer */
152     size_t                   peerlen;
153     /** link to next one in list */
154     struct fbUDPConnSpec_st  *next;
155     /** doubly linked to timeout faster */
156     struct fbUDPConnSpec_st  *prev;
157     /** last seen time */
158     time_t                   last_seen;
159     /** with peer address this is the key */
160     uint32_t                 obdomain;
161     /** reject flag */
162     gboolean                 reject;
163 } fbUDPConnSpec_t;
164 
165 
166 #ifdef DEFINE_TEMPLATE_METADATA_SPEC
167 /* Template metadata template */
168 static fbInfoElementSpec_t template_metadata_spec[] = {
169     {"templateId",                             2, 0 },
170     {"paddingOctets",                          6, 1 },
171     {"templateName",                           FB_IE_VARLEN, 0 },
172     {"templateDescription",                    FB_IE_VARLEN, 0 },
173     /* {"templateInformationElementList",         FB_IE_VARLEN, 0 }, */
174     FB_IESPEC_NULL
175 };
176 #endif
177 
178 /**
179  * Template metadata options record structure
180  *
181  */
182 typedef struct fbTemplateOptRec_st {
183     /** Template ID */
184     uint16_t       template_id;
185     uint8_t        template_padding[6];
186     /** Template name */
187     fbVarfield_t   template_name;
188     /** Template description (optional) */
189     fbVarfield_t   template_description;
190     /** List of PEN, IE num pairs */
191     /* fbSubTemplateList_t info_element_list; */
192 } fbTemplateOptRec_t;
193 
194 /**
195  * An IPFIX template or options template structure. Part of the private
196  * interface. Applications should use the fbTemplate calls defined in public.h
197  * to manipulate templates instead of accessing this structure directly.
198  */
199 struct fbTemplate_st {
200     /** Information model (for looking up information elements by spec) */
201     fbInfoModel_t       *model;
202     /** Reference count */
203     int                 ref_count;
204     /** Count of information elements in template. */
205     uint16_t            ie_count;
206     /**
207      * Count of scope information elements in template. If sie_count
208      * is greater than 0, this template is an options template.
209      */
210     uint16_t            scope_count;
211     /**
212      * Total length of information elements in records described by
213      * this template. If the is_varlen flag is set, this represents the
214      * minimum length of the information elements in the record
215      * (i.e. with each variable length IE's length set to 0).
216      */
217     uint16_t            ie_len;
218     /**
219      * Total length required to store this template in memory.
220      * Uses sizeof(fbVarfield_t), sizeof(fbBasicList_t), etc instead of 0
221      * as done with ie_len
222      */
223     uint16_t            ie_internal_len;
224     /**
225      * Total length of the template record or options template record
226      * defining this template. Used during template input and output.
227      */
228     uint16_t            tmpl_len;
229     /** Set to TRUE if this template contains any variable length IEs. */
230     gboolean            is_varlen;
231     /** Ordered array of pointers to information elements in this template. */
232     fbInfoElement_t     **ie_ary;
233     /** Map of information element to index in ie_ary. */
234     GHashTable          *indices;
235     /** Field offset cache. For internal use by the transcoder. */
236     uint16_t            *off_cache;
237     /** TRUE if this template has been activated (is no longer mutable) */
238     gboolean            active;
239     /**
240      * TRUE if any field was created using an fbInfoElementSpec_t
241      * with a defaulted length
242      */
243     gboolean            default_length;
244 
245     fbTemplateOptRec_t  *metadata_rec;
246     /**
247      * Template context. Created and owned by the application
248      * when the listener calls the fbNewTemplateCallback_fn.
249      */
250     void                *tmpl_ctx;
251     /**
252      * Callback to free the ctx pointer when template is freed
253      */
254     fbTemplateCtxFree_fn ctx_free;
255     /**
256      * The application's Context pointer for the ctx_free function.
257      */
258     void                *app_ctx;
259 };
260 
261 /**
262  * fBufRewind
263  *
264  * @param fbuf
265  *
266  */
267 void                fBufRewind(
268     fBuf_t              *fbuf);
269 
270 /**
271  * fBufAppendTemplate
272  *
273  * @param fbuf
274  * @param tmpl_id
275  * @param tmpl
276  * @param revoked
277  * @param err
278  *
279  * @return TRUE on success, FALSE on error
280  */
281 gboolean            fBufAppendTemplate(
282     fBuf_t              *fbuf,
283     uint16_t            tmpl_id,
284     fbTemplate_t        *tmpl,
285     gboolean            revoked,
286     GError              **err);
287 
288 #if HAVE_SPREAD
289 /**
290  * fBufSetExportGroups
291  *
292  *
293  *
294  */
295 void                fBufSetExportGroups(
296     fBuf_t              *fbuf,
297     char                **groups,
298     int                 num_groups,
299     GError              **err);
300 
301 
302 #endif
303 
304 /**
305  * fBufRemoveTemplateTcplan
306  *
307  *
308  */
309 void fBufRemoveTemplateTcplan(
310     fBuf_t         *fbuf,
311     fbTemplate_t   *tmpl);
312 
313 /**
314  * fBufSetSession
315  *
316  */
317 void         fBufSetSession(
318     fBuf_t          *fbuf,
319     fbSession_t     *session);
320 
321 /**
322  * fBufGetExportTemplate
323  *
324  */
325 uint16_t        fBufGetExportTemplate(
326     fBuf_t          *fbuf);
327 
328 
329 /**
330  * fBufGetInternalTemplate
331  *
332  */
333 uint16_t       fBufGetInternalTemplate(
334     fBuf_t         *fbuf);
335 
336 /**
337  * fbInfoElementHash
338  *
339  * @param ie
340  *
341  *
342  */
343 uint32_t            fbInfoElementHash(
344     fbInfoElement_t     *ie);
345 
346 /**
347  * fbInfoElementEqual
348  *
349  * @param a
350  * @param b
351  *
352  *
353  */
354 gboolean            fbInfoElementEqual(
355     const fbInfoElement_t   *a,
356     const fbInfoElement_t   *b);
357 
358 /**
359  *fbInfoElementDebug
360  *
361  * @param tmpl
362  * @param ie
363  *
364  */
365 void                fbInfoElementDebug(
366     gboolean            tmpl,
367     fbInfoElement_t     *ie);
368 
369 /**
370  * fbInfoModelGetElement
371  *
372  * @param model
373  * @param ex_ie
374  *
375  */
376 const fbInfoElement_t     *fbInfoModelGetElement(
377     fbInfoModel_t       *model,
378     fbInfoElement_t     *ex_ie);
379 
380 /**
381  * fbInfoElementCopyToTemplate
382  *
383  * @param model
384  * @param ex_ie
385  * @param tmpl_ie
386  *
387  */
388 gboolean            fbInfoElementCopyToTemplate(
389     fbInfoModel_t       *model,
390     fbInfoElement_t     *ex_ie,
391     fbInfoElement_t     *tmpl_ie);
392 
393 /**
394  * fbInfoElementCopyToTemplateByName
395  *
396  * @param model
397  * @param name
398  * @param len_override
399  * @param tmpl_ie
400  *
401  *
402  */
403 gboolean            fbInfoElementCopyToTemplateByName(
404     fbInfoModel_t       *model,
405     const char          *name,
406     uint16_t            len_override,
407     fbInfoElement_t     *tmpl_ie);
408 
409 /**
410  * fbInfoModelAddAlienElement
411  *
412  * @param model
413  * @param ex_ie
414  * @return info_elemnt
415  *
416  */
417 const fbInfoElement_t     *fbInfoModelAddAlienElement(
418     fbInfoModel_t       *model,
419     fbInfoElement_t     *ex_ie);
420 
421 /**
422  * fbInfoElementAllocTypeTemplate2
423  *
424  * @param model
425  * @param internal
426  * @param err
427  * @return tmpl
428  */
429 fbTemplate_t        *fbInfoElementAllocTypeTemplate2(
430     fbInfoModel_t       *model,
431     gboolean            internal,
432     GError              **err);
433 
434 /**
435  * fbTemplateRetain
436  *
437  * @param tmpl
438  *
439  *
440  */
441 void                fbTemplateRetain(
442     fbTemplate_t        *tmpl);
443 
444 /**
445  * fbTemplateRelease
446  *
447  *
448  * @param tmpl
449  *
450  */
451 void                fbTemplateRelease(
452     fbTemplate_t        *tmpl);
453 
454 /**
455  * fbTemplateFree
456  *
457  * @param tmpl
458  *
459  *
460  */
461 void                fbTemplateFree(
462     fbTemplate_t        *tmpl);
463 
464 /**
465  * fbTemplateDebug
466  *
467  * @param label
468  * @param tid
469  * @param tmpl
470  *
471  */
472 void                fbTemplateDebug(
473     const char          *label,
474     uint16_t            tid,
475     fbTemplate_t        *tmpl);
476 
477 /**
478  * Allocates a new Template to describe a record that holds Template Metadata.
479  * This is, the template_metadata_spec.
480  *
481  * When `internal` is TRUE the padding is included; otherwise it is not.
482  *
483  * @param model
484  * @param internal
485  * @param err
486  * @returns The new template or NULL.
487  */
488 fbTemplate_t        *fbTemplateAllocTemplateMetadataTmpl(
489     fbInfoModel_t      *model,
490     gboolean            internal,
491     GError            **err);
492 
493 /**
494  * Sets the metadata_rec member of `tmpl` to a newly allocated
495  * fbTemplateOptRec_t, and sets its template ID, name, and description to the
496  * given parameters.
497  *
498  * Frees any metadata_rec that already existed on the template.
499  *
500  * @param tmpl
501  * @param tid
502  * @param name          Should not be NULL
503  * @param description   May be NULL
504  */
505 void                fbTemplateAddMetadataRecord(
506     fbTemplate_t        *tmpl,
507     uint16_t             tid,
508     const char          *name,
509     const char          *description);
510 
511 /**
512  * Returns the callback function for a given session
513  *
514  * @param session
515  * @return the callback function variable in the session
516  */
517 fbNewTemplateCallback_fn fbSessionNewTemplateCallback(
518     fbSession_t     *session);
519 
520 /**
521  * Return the callback function's application context for a given
522  * session
523  *
524  * @param session
525  * @return the Application context pointer added to the session
526  */
527 void *fbSessionNewTemplateCallbackAppCtx(
528     fbSession_t *session);
529 
530 /**
531  * fbSessionClone
532  *
533  * @param base
534  *
535  */
536 fbSession_t         *fbSessionClone(
537     fbSession_t         *base);
538 
539 /**
540  * fbSessionGetSequence
541  *
542  * @param session
543  *
544  *
545  */
546 uint32_t            fbSessionGetSequence(
547     fbSession_t         *session);
548 
549 /**
550  * fbSessionSetSequence
551  *
552  * @param session
553  * @param sequence
554  *
555  */
556 void                fbSessionSetSequence(
557     fbSession_t         *session,
558     uint32_t            sequence);
559 
560 /**
561  * fbSessionSetTemplateBuffer
562  *
563  * @param session
564  * @param fbuf
565  *
566  */
567 void                fbSessionSetTemplateBuffer(
568     fbSession_t         *session,
569     fBuf_t              *fbuf);
570 
571 /**
572  * fbSessionSetCollector
573  *
574  * @param session
575  * @param collector
576  *
577  */
578 void fbSessionSetCollector(
579     fbSession_t        *session,
580     fbCollector_t      *collector);
581 
582 #if HAVE_SPREAD
583 /**
584  * fbSessionSetGroupParams
585  *
586  */
587 void fbSessionSetGroupParams(
588     fbSession_t     *session,
589     sp_groupname_t  *groups,
590     unsigned int     num_groups);
591 
592 /**
593  * fbSessionSetPrivateGroup
594  *
595  *
596  */
597 void fbSessionSetPrivateGroup(
598     fbSession_t       *session,
599     char              *group,
600     char              *privgroup);
601 
602 /**
603  * fbSessionSetGroup
604  *
605  */
606 void                fbSessionSetGroup(
607     fbSession_t         *session,
608     char                *group);
609 
610 /**
611  * fbSessionGetGroupOffset
612  *
613  */
614 unsigned int fbSessionGetGroupOffset(
615     fbSession_t     *session,
616     char            *group);
617 
618 /**
619  * fbSessionGetGroup
620  *
621  * @param session
622  *
623  */
624 unsigned int       fbSessionGetGroup(
625     fbSession_t      *session);
626 #endif
627 
628 /**
629  * fbSessionClearIntTmplTableFlag
630  *
631  * @param session
632  *
633  */
634 void fbSessionClearIntTmplTableFlag(
635     fbSession_t        *session);
636 
637 /**
638  * fbSessionClearExtTmplTableFlag
639  *
640  * @param session
641  *
642  */
643 void fbSessionClearExtTmplTableFlag(
644     fbSession_t        *session);
645 
646 /**
647  * fbSessionIntTmplTableFlagIsSet
648  *
649  * @param session
650  *
651  */
652 int fbSessionIntTmplTableFlagIsSet(
653     fbSession_t        *session);
654 
655 /**
656  * fbSessionExtTmplTableFlagIsSet
657  *
658  * @param session
659  *
660  */
661 int fbSessionExtTmplTableFlagIsSet(
662     fbSession_t        *session);
663 
664 /**
665  * fbConnSpecLookupAI
666  *
667  * @param spec
668  * @param passive
669  * @param err
670  *
671  */
672 gboolean            fbConnSpecLookupAI(
673     fbConnSpec_t        *spec,
674     gboolean            passive,
675     GError              **err);
676 
677 /**
678  * fbConnSpecInitTLS
679  *
680  * @param spec
681  * @param passive
682  * @param err
683  *
684  */
685 gboolean            fbConnSpecInitTLS(
686     fbConnSpec_t        *spec,
687     gboolean            passive,
688     GError              **err);
689 
690 /**
691  * fbConnSpecCopy
692  *
693  * @param spec
694  *
695  *
696  */
697 fbConnSpec_t        *fbConnSpecCopy(
698     fbConnSpec_t        *spec);
699 
700 /**
701  * fbConnSpecFree
702  *
703  * @param spec
704  *
705  *
706  */
707 void                fbConnSpecFree(
708     fbConnSpec_t        *spec);
709 
710 #if HAVE_SPREAD
711 /**
712  * fbConnSpreadCopy
713  *
714  * @param spec
715  *
716  *
717  */
718 fbSpreadSpec_t        *fbConnSpreadCopy(
719     fbSpreadParams_t        *spec);
720 
721 /**
722  * fbConnSpreadFree
723  *
724  * @param spec
725  *
726  *
727  */
728 void                fbConnSpreadFree(
729     fbSpreadSpec_t        *spec);
730 
731 /**
732  * fbConnSpreadError
733  *
734  * Return a string message for the given Spread error code
735  *
736  * @param err the spread error code
737  * @return the text message
738  */
739 const char * fbConnSpreadError(
740     int err );
741 
742 
743 /**
744  * fbExporterSetGroupToSend
745  *
746  * @param exporter
747  * @param groups
748  * @param num_groups of groups in above group list
749  *
750  */
751 
752 void fbExporterSetGroupsToSend(
753     fbExporter_t      *exporter,
754     char              **groups,
755     int               num_groups);
756 
757 
758 /**
759  * fbExporterCheckGroups
760  *
761  * @param exporter
762  * @param groups
763  * @param num_groups of groups in above group list
764  * @return TRUE if group is in subscribed group list
765  *
766  */
767 gboolean fbExporterCheckGroups(
768     fbExporter_t      *exporter,
769     char              **groups,
770     int                num_groups);
771 
772 
773 #endif /* HAVE_SPREAD */
774 
775 /**
776  * fbExporterGetMTU
777  *
778  * @param exporter
779  *
780  *
781  */
782 uint16_t            fbExporterGetMTU(
783     fbExporter_t        *exporter);
784 
785 /**
786  * fbExportMessage
787  *
788  * @param exporter
789  * @param msgbase
790  * @param msglen
791  * @param err
792  *
793  */
794 gboolean            fbExportMessage(
795     fbExporter_t        *exporter,
796     uint8_t             *msgbase,
797     size_t              msglen,
798     GError              **err);
799 
800 /**
801  * fbExporterFree
802  *
803  * @param exporter
804  *
805  *
806  */
807 void                fbExporterFree(
808     fbExporter_t       *exporter);
809 
810 /**
811  * fbCollectorRemoveListenerLastBuf
812  *
813  * @param fbuf
814  * @param collector
815  *
816  */
817 void fbCollectorRemoveListenerLastBuf(
818     fBuf_t             *fbuf,
819     fbCollector_t      *collector);
820 
821 /**
822  * fbCollectorAllocSocket
823  *
824  * @param listener
825  * @param ctx
826  * @param fd
827  * @param peer
828  * @param peerlen
829  * @param err
830  *
831  */
832 fbCollector_t       *fbCollectorAllocSocket(
833     fbListener_t        *listener,
834     void                *ctx,
835     int                 fd,
836     struct sockaddr     *peer,
837     size_t              peerlen,
838     GError              **err);
839 
840 /**
841  * fbCollectorAllocTLS
842  *
843  * @param listener
844  * @param ctx
845  * @param fd
846  * @param peer
847  * @param peerlen
848  * @param err
849  *
850  */
851 fbCollector_t       *fbCollectorAllocTLS(
852     fbListener_t        *listener,
853     void                *ctx,
854     int                 fd,
855     struct sockaddr     *peer,
856     size_t              peerlen,
857     GError              **err);
858 
859 /**
860  * fbCollectMessage
861  *
862  * @param collector
863  * @param msgbase
864  * @param msglen
865  * @param err
866  *
867  */
868 gboolean            fbCollectMessage(
869     fbCollector_t       *collector,
870     uint8_t             *msgbase,
871     size_t              *msglen,
872     GError              **err);
873 
874 /**
875  * fbCollectorGetFD
876  *
877  * @param collector
878  *
879  *
880  */
881 int                 fbCollectorGetFD(
882     fbCollector_t       *collector);
883 
884 /**
885  * fbCollectorSetFD
886  *
887  *
888  *
889  */
890 void             fbCollectorSetFD(
891     fbCollector_t   *collector,
892     int              fd);
893 
894 /**
895  * fbCollectorFree
896  *
897  * @param collector
898  *
899  *
900  */
901 void                fbCollectorFree(
902     fbCollector_t       *collector);
903 
904 /**
905  * fbCollectorHasTranslator
906  *
907  * @param collector
908  *
909  *
910  */
911 gboolean        fbCollectorHasTranslator(
912     fbCollector_t   *collector);
913 
914 
915 /**
916  * fbCollectMessageBuffer
917  *
918  * used for applications that manage their own connection, file reading, etc.
919  *
920  * @param hdr
921  * @param b_len
922  * @param m_len
923  * @param err
924  *
925  * @return TRUE/FALSE
926  *
927  */
928 gboolean fbCollectMessageBuffer(
929     uint8_t                     *hdr,
930     size_t                      b_len,
931     size_t                      *m_len,
932     GError                      **err);
933 
934 
935 #if HAVE_SPREAD
936 /**
937  * fbCollectorTestGroupMembership
938  *
939  * @param collector
940  * @param group_offset
941  *
942  */
943 gboolean       fbCollectorTestGroupMembership(
944     fbCollector_t       *collector,
945     int                 group_offset);
946 
947 #endif
948 
949 /**
950  * fbListenerAppFree
951  *
952  * @param listener
953  * @param ctx
954  *
955  */
956 void fbListenerAppFree(
957     fbListener_t   *listener,
958     void           *ctx);
959 
960 /**
961  * fbListenerRemoveLastBuf
962  *
963  * @param fbuf
964  * @param listener
965  *
966  */
967 void fbListenerRemoveLastBuf(
968     fBuf_t         *fbuf,
969     fbListener_t   *listener);
970 
971 /**
972  * fbListenerRemove
973  *
974  * @param listener
975  * @param fd
976  *
977  */
978 void fbListenerRemove(
979     fbListener_t        *listener,
980     int                 fd);
981 
982 /**
983  * fbListenerGetConnSpec
984  *
985  * @param listener
986  *
987  *
988  */
989 fbConnSpec_t        *fbListenerGetConnSpec(
990     fbListener_t        *listener);
991 
992 /**
993  * Interrupt the socket for a given collector to stop it from reading
994  * more data
995  *
996  * @param collector pointer to the collector to stop reading from
997  */
998 void fbCollectorInterruptSocket(
999     fbCollector_t   *collector);
1000 
1001 /**
1002  * call appinit from UDP
1003  *
1004  */
1005 gboolean fbListenerCallAppInit(
1006     fbListener_t       *listener,
1007     fbUDPConnSpec_t    *spec,
1008     GError             **err);
1009 
1010 /**
1011  * Set the session on the fbuf and listener.
1012  *
1013  */
1014 
1015 fbSession_t *fbListenerSetPeerSession(
1016     fbListener_t        *listener,
1017     fbSession_t         *session);
1018 
1019 #endif
1020