nmsg 1.1.1
msgmod.h
1/*
2 * Copyright (c) 2023 DomainTools LLC
3 * Copyright (c) 2008-2015 by Farsight Security, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef NMSG_MSGMOD_H
19#define NMSG_MSGMOD_H
20
72typedef enum {
74 nmsg_msgmod_ft_enum,
75
77 nmsg_msgmod_ft_bytes,
78
83 nmsg_msgmod_ft_string,
84
89 nmsg_msgmod_ft_mlstring,
90
95 nmsg_msgmod_ft_ip,
96
98 nmsg_msgmod_ft_uint16,
99
101 nmsg_msgmod_ft_uint32,
102
104 nmsg_msgmod_ft_uint64,
105
107 nmsg_msgmod_ft_int16,
108
110 nmsg_msgmod_ft_int32,
111
113 nmsg_msgmod_ft_int64,
114
116 nmsg_msgmod_ft_double,
117
119 nmsg_msgmod_ft_bool,
120} nmsg_msgmod_field_type;
121
122#define NMSG_MSGMOD_FIELD_REPEATED 0x01 /*%< field is repeated */
123#define NMSG_MSGMOD_FIELD_REQUIRED 0x02 /*%< field is required */
124#define NMSG_MSGMOD_FIELD_HIDDEN 0x04 /*%< hide field from the message API */
125#define NMSG_MSGMOD_FIELD_NOPRINT 0x08 /*%< don't print the field */
126#define NMSG_MSGMOD_FIELD_FORMAT_RAW 0x10 /*%< treat format return value as is */
127
142nmsg_res
143nmsg_msgmod_init(nmsg_msgmod_t mod, void **clos);
144
157nmsg_res
158nmsg_msgmod_fini(nmsg_msgmod_t mod, void **clos);
159
185nmsg_res
186nmsg_msgmod_pres_to_payload(nmsg_msgmod_t mod, void *clos, const char *pres);
187
207nmsg_res
208nmsg_msgmod_pres_to_payload_finalize(nmsg_msgmod_t mod, void *clos, uint8_t **pbuf,
209 size_t *sz);
210
232nmsg_res
233nmsg_msgmod_ipdg_to_payload(nmsg_msgmod_t mod, void *clos,
234 const struct nmsg_ipdg *dg,
235 uint8_t **pbuf, size_t *sz);
236
258nmsg_res
259nmsg_msgmod_pkt_to_payload(struct nmsg_msgmod *mod, void *clos,
260 nmsg_pcap_t pcap, nmsg_message_t *m);
261
273nmsg_msgmod_t
274nmsg_msgmod_lookup(unsigned vid, unsigned msgtype);
275
287nmsg_msgmod_t
288nmsg_msgmod_lookup_byname(const char *vname, const char *mname);
289
300unsigned
301nmsg_msgmod_mname_to_msgtype(unsigned vid, const char *mname);
302
314const char *
315nmsg_msgmod_msgtype_to_mname(unsigned vid, unsigned msgtype);
316
325const char *
326nmsg_msgmod_vid_to_vname(unsigned vid);
327
336unsigned
337nmsg_msgmod_vname_to_vid(const char *vname);
338
342unsigned
343nmsg_msgmod_get_max_vid(void);
344
350unsigned
351nmsg_msgmod_get_max_msgtype(unsigned vid);
352
353#endif /* NMSG_MSGMOD_H */