nmsg 1.1.2
msgmod.h
Go to the documentation of this file.
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
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
143nmsg_msgmod_init(nmsg_msgmod_t mod, void **clos);
144
158nmsg_msgmod_fini(nmsg_msgmod_t mod, void **clos);
159
186nmsg_msgmod_pres_to_payload(nmsg_msgmod_t mod, void *clos, const char *pres);
187
208nmsg_msgmod_pres_to_payload_finalize(nmsg_msgmod_t mod, void *clos, uint8_t **pbuf,
209 size_t *sz);
210
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
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 *
327
336unsigned
337nmsg_msgmod_vname_to_vid(const char *vname);
338
342unsigned
344
350unsigned
352
353#endif /* NMSG_MSGMOD_H */
nmsg_res nmsg_msgmod_fini(nmsg_msgmod_t mod, void **clos)
Finalize a mesage module.
const char * nmsg_msgmod_msgtype_to_mname(unsigned vid, unsigned msgtype)
Convert a vendor ID / message type ID tuple to the human-readable form of the message type.
nmsg_msgmod_t nmsg_msgmod_lookup_byname(const char *vname, const char *mname)
Determine which nmsg_msgmod is responsible for a given vid/msgtype tuple, if any.
const char * nmsg_msgmod_vid_to_vname(unsigned vid)
Convert a numeric vendor ID to its human-readable name.
nmsg_res nmsg_msgmod_pres_to_payload_finalize(nmsg_msgmod_t mod, void *clos, uint8_t **pbuf, size_t *sz)
After a call to nmsg_msgmod_pres_to_payload() returns nmsg_res_pbuf_ready, this function will return ...
nmsg_res nmsg_msgmod_pkt_to_payload(struct nmsg_msgmod *mod, void *clos, nmsg_pcap_t pcap, nmsg_message_t *m)
Read a raw packet and optionally convert it to an NMSG payload.
nmsg_msgmod_t nmsg_msgmod_lookup(unsigned vid, unsigned msgtype)
Determine which nmsg_msgmod is responsible for a given vid/msgtype tuple, if any.
nmsg_res nmsg_msgmod_init(nmsg_msgmod_t mod, void **clos)
Initialize a message module.
nmsg_res nmsg_msgmod_pres_to_payload(nmsg_msgmod_t mod, void *clos, const char *pres)
Convert a presentation format line to an NMSG payload.
unsigned nmsg_msgmod_get_max_vid(void)
Return the maximum vendor ID.
unsigned nmsg_msgmod_vname_to_vid(const char *vname)
Convert a human-readable vendor name to its numeric ID.
unsigned nmsg_msgmod_get_max_msgtype(unsigned vid)
Return the maximum message type registered to a vendor ID.
nmsg_msgmod_field_type
Enum mapping protocol buffer schema types to nmsg-specific types for "transparent" modules.
Definition msgmod.h:72
@ nmsg_msgmod_ft_ip
Protobuf byte array.
Definition msgmod.h:95
@ nmsg_msgmod_ft_uint16
Protobuf uint32.
Definition msgmod.h:98
@ nmsg_msgmod_ft_mlstring
Protobuf byte array.
Definition msgmod.h:89
@ nmsg_msgmod_ft_uint64
Protobuf uint64.
Definition msgmod.h:104
@ nmsg_msgmod_ft_double
Protobuf double.
Definition msgmod.h:116
@ nmsg_msgmod_ft_string
Protobuf byte array.
Definition msgmod.h:83
@ nmsg_msgmod_ft_bool
Protobuf bool.
Definition msgmod.h:119
@ nmsg_msgmod_ft_int16
Protobuf int32.
Definition msgmod.h:107
@ nmsg_msgmod_ft_int32
Protobuf int32.
Definition msgmod.h:110
@ nmsg_msgmod_ft_int64
Protobuf int64.
Definition msgmod.h:113
@ nmsg_msgmod_ft_bytes
Protobuf byte array.
Definition msgmod.h:77
@ nmsg_msgmod_ft_uint32
Protobuf uint32.
Definition msgmod.h:101
@ nmsg_msgmod_ft_enum
Protobuf enum.
Definition msgmod.h:74
nmsg_res nmsg_msgmod_ipdg_to_payload(nmsg_msgmod_t mod, void *clos, const struct nmsg_ipdg *dg, uint8_t **pbuf, size_t *sz)
Convert an IP datagram to an NMSG payload.
unsigned nmsg_msgmod_mname_to_msgtype(unsigned vid, const char *mname)
Convert the human-readable name of a message type to a message type ID.
nmsg_res
nmsg result code
Definition res.h:25
Parsed IP datagram.
Definition ipdg.h:31