Fix CMake to reference unit test in correct dir
[ric-app/mc.git] / sidecars / listener / mcl.h
1 // vim: ts=4 sw=4 noet:
2 /*
3  --------------------------------------------------------------------------------
4         Copyright (c) 2018-2019 AT&T Intellectual Property.
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10            http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17  --------------------------------------------------------------------------------
18
19 /*
20         Mnemonic:       mcl.h
21         Abstract:       Header file for the mc listener library.
22         Date:           22 August 2019
23         Author:         E. Scott Daniels
24         
25 */
26
27 #ifndef mcl_h
28 #define mcl_h
29
30 #include <rmr/rmr.h>
31 #include <rmr/rmr_symtab.h>
32
33 // ------- public constants and structs -------------------------------------------------------------------
34
35 #define MCL_LEN_SIZE 8          // number of bytes the length has in both short and extended header
36 #define MCL_DELIM_SIZE  4       // number of bytes in extended header delimiter
37 #define MCL_TSTAMP_SIZE 16      // number of bytes in extended header timestamp
38 #define MCL_EXHDR_SIZE  (MCL_DELIM_SIZE+MCL_LEN_SIZE+MCL_TSTAMP_SIZE)   // total size of extended header
39
40 #define MCL_DELIM               "@MCL"          // delimeter to synch msgs in fifo
41
42 #define MCL_TSTAMP_OFF  (MCL_DELIM_SIZE+MCL_LEN_SIZE)                                   // offsets in header
43 #define MCL_LEN_OFF             MCL_DELIM_SIZE
44
45 #define MCL_NOWAIT      0       // do not wait for RMR route table to arrive
46 #define MCL_WAIT        1       // block reader start until RMR route table is initialised
47
48 // ---- rdc definitions ----------------------------------------------------------------------------------
49 #define LOG_CRIT        0
50 #define LOG_ERR         1
51 #define LOG_WARN        2
52 #define LOG_INFO        3
53 #define LOG_STAT        4               // stats messages go to stdout
54
55
56 //------------ prototypes --------------------------------------------------------------
57 extern void mcl_fifo_fanout( void* ctx, int report, int long_hdrs );
58 extern int mcl_fifo_one( void* ctx, const char* payload, int plen, int mtype );
59 extern rmr_mbuf_t* mcl_get_msg( void* vctx, rmr_mbuf_t* msg, int timeout );
60 extern  void* mcl_mk_context( const char* dir );
61 extern int mcl_fifo_read1( void* vctx, int mtype, char* ubuf, int ublen, int long_hdr );
62 extern int mcl_fifo_tsread1( void* vctx, int mtype, char* ubuf, int ublen, int long_hdr, char* timestamp );
63 extern int mcl_set_sigh( );
64 extern int mcl_start_listening( void* vctx, char* port, int wait4ready );
65
66 // ---- these can be used by external programmes, but it liekely doesn't make sense to do so ----
67 extern void logit( int level, char* fmt, ... );
68 extern void* rdc_init( char* sdir, char* fdir, char* suffix, char* dsuffix );
69 extern void* rdc_init_buf( int mtype, char* uheader, int uhlen, void* capture_buf );
70 extern void rdc_close( void* rdl_ctx );
71 extern void rdc_set_freq( void* rdl_ctx, int freq );
72 extern int rdc_write( void* rdl_ctx, void* rdc_buffer, char* payload, int len );
73
74
75 #endif