nmsg  1.0.1
msgmod.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015 by Farsight Security, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef NMSG_MSGMOD_H
18 #define NMSG_MSGMOD_H
19 
71 typedef enum {
74 
77 
83 
89 
95 
98 
101 
104 
107 
110 
113 
116 
120 
121 #define NMSG_MSGMOD_FIELD_REPEATED 0x01 /*%< field is repeated */
122 #define NMSG_MSGMOD_FIELD_REQUIRED 0x02 /*%< field is required */
123 #define NMSG_MSGMOD_FIELD_HIDDEN 0x04 /*%< hide field from the message API */
124 #define NMSG_MSGMOD_FIELD_NOPRINT 0x08 /*%< don't print the field */
125 
140 nmsg_res
141 nmsg_msgmod_init(nmsg_msgmod_t mod, void **clos);
142 
155 nmsg_res
156 nmsg_msgmod_fini(nmsg_msgmod_t mod, void **clos);
157 
183 nmsg_res
184 nmsg_msgmod_pres_to_payload(nmsg_msgmod_t mod, void *clos, const char *pres);
185 
205 nmsg_res
206 nmsg_msgmod_pres_to_payload_finalize(nmsg_msgmod_t mod, void *clos, uint8_t **pbuf,
207  size_t *sz);
208 
230 nmsg_res
231 nmsg_msgmod_ipdg_to_payload(nmsg_msgmod_t mod, void *clos,
232  const struct nmsg_ipdg *dg,
233  uint8_t **pbuf, size_t *sz);
234 
256 nmsg_res
257 nmsg_msgmod_pkt_to_payload(struct nmsg_msgmod *mod, void *clos,
258  nmsg_pcap_t pcap, nmsg_message_t *m);
259 
271 nmsg_msgmod_t
272 nmsg_msgmod_lookup(unsigned vid, unsigned msgtype);
273 
285 nmsg_msgmod_t
286 nmsg_msgmod_lookup_byname(const char *vname, const char *mname);
287 
298 unsigned
299 nmsg_msgmod_mname_to_msgtype(unsigned vid, const char *mname);
300 
312 const char *
313 nmsg_msgmod_msgtype_to_mname(unsigned vid, unsigned msgtype);
314 
323 const char *
324 nmsg_msgmod_vid_to_vname(unsigned vid);
325 
334 unsigned
335 nmsg_msgmod_vname_to_vid(const char *vname);
336 
340 unsigned
342 
348 unsigned
349 nmsg_msgmod_get_max_msgtype(unsigned vid);
350 
351 #endif /* NMSG_MSGMOD_H */
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 result code
Definition: res.h:25
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.
nmsg_res nmsg_msgmod_init(nmsg_msgmod_t mod, void **clos)
Initialize a message module.
unsigned nmsg_msgmod_vname_to_vid(const char *vname)
Convert a human-readable vendor name to its numeric ID.
Protobuf enum.
Definition: msgmod.h:73
Protobuf uint64.
Definition: msgmod.h:103
Protobuf byte array.
Definition: msgmod.h:76
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.
Parsed IP datagram.
Definition: ipdg.h:31
Protobuf int32.
Definition: msgmod.h:109
Protobuf byte array.
Definition: msgmod.h:94
Protobuf byte array.
Definition: msgmod.h:82
Protobuf int32.
Definition: msgmod.h:106
nmsg_msgmod_field_type
Enum mapping protocol buffer schema types to nmsg-specific types for "transparent" modules...
Definition: msgmod.h:71
Protobuf int64.
Definition: msgmod.h:112
Protobuf byte array.
Definition: msgmod.h:88
Protobuf uint32.
Definition: msgmod.h:100
Protobuf double.
Definition: msgmod.h:115
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...
const char * nmsg_msgmod_vid_to_vname(unsigned vid)
Convert a numeric vendor ID to its human-readable name.
nmsg_res nmsg_msgmod_fini(nmsg_msgmod_t mod, void **clos)
Finalize a mesage module.
unsigned nmsg_msgmod_get_max_msgtype(unsigned vid)
Return the maximum message type registered to a vendor ID.
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. ...
Protobuf uint32.
Definition: msgmod.h:97
Protobuf bool.
Definition: msgmod.h:118
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. ...
unsigned nmsg_msgmod_get_max_vid(void)
Return the maximum vendor ID.
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.