nmsg  0.9.0
msgmod.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2012 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 
64 #include <nmsg.h>
65 
73 typedef enum {
76 
79 
85 
91 
97 
100 
103 
106 
109 
112 
115 
118 
122 
123 #define NMSG_MSGMOD_FIELD_REPEATED 0x01 /*%< field is repeated */
124 #define NMSG_MSGMOD_FIELD_REQUIRED 0x02 /*%< field is required */
125 #define NMSG_MSGMOD_FIELD_HIDDEN 0x04 /*%< hide field from the message API */
126 #define NMSG_MSGMOD_FIELD_NOPRINT 0x08 /*%< don't print the field */
127 
142 nmsg_res
143 nmsg_msgmod_init(nmsg_msgmod_t mod, void **clos);
144 
157 nmsg_res
158 nmsg_msgmod_fini(nmsg_msgmod_t mod, void **clos);
159 
185 nmsg_res
186 nmsg_msgmod_pres_to_payload(nmsg_msgmod_t mod, void *clos, const char *pres);
187 
207 nmsg_res
208 nmsg_msgmod_pres_to_payload_finalize(nmsg_msgmod_t mod, void *clos, uint8_t **pbuf,
209  size_t *sz);
210 
232 nmsg_res
233 nmsg_msgmod_ipdg_to_payload(nmsg_msgmod_t mod, void *clos,
234  const struct nmsg_ipdg *dg,
235  uint8_t **pbuf, size_t *sz);
236 
258 nmsg_res
259 nmsg_msgmod_pkt_to_payload(struct nmsg_msgmod *mod, void *clos,
260  nmsg_pcap_t pcap, nmsg_message_t *m);
261 
273 nmsg_msgmod_t
274 nmsg_msgmod_lookup(unsigned vid, unsigned msgtype);
275 
287 nmsg_msgmod_t
288 nmsg_msgmod_lookup_byname(const char *vname, const char *mname);
289 
300 unsigned
301 nmsg_msgmod_mname_to_msgtype(unsigned vid, const char *mname);
302 
314 const char *
315 nmsg_msgmod_msgtype_to_mname(unsigned vid, unsigned msgtype);
316 
325 const char *
326 nmsg_msgmod_vid_to_vname(unsigned vid);
327 
336 unsigned
337 nmsg_msgmod_vname_to_vid(const char *vname);
338 
342 unsigned
344 
350 unsigned
351 nmsg_msgmod_get_max_msgtype(unsigned vid);
352 
353 #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:75
Base nmsg support header.
Protobuf uint64.
Definition: msgmod.h:105
Protobuf byte array.
Definition: msgmod.h:78
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:34
Protobuf int32.
Definition: msgmod.h:111
Protobuf byte array.
Definition: msgmod.h:96
Protobuf byte array.
Definition: msgmod.h:84
Protobuf int32.
Definition: msgmod.h:108
nmsg_msgmod_field_type
Enum mapping protocol buffer schema types to nmsg-specific types for "transparent" modules...
Definition: msgmod.h:73
Protobuf int64.
Definition: msgmod.h:114
Protobuf byte array.
Definition: msgmod.h:90
Protobuf uint32.
Definition: msgmod.h:102
Protobuf double.
Definition: msgmod.h:117
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:99
Protobuf bool.
Definition: msgmod.h:120
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.