nmsg  0.9.0
res.c
1 /*
2  * Copyright (c) 2009, 2010, 2012, 2013 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 #include "private.h"
18 
19 static const char *res_strings[] = {
20  [nmsg_res_success] = "success",
21  [nmsg_res_failure] = "generic failure",
22  [nmsg_res_eof] = "end of file",
23  [nmsg_res_memfail] = "memory allocation failed",
24  [nmsg_res_magic_mismatch] = "incorrect magic number in NMSG header",
25  [nmsg_res_version_mismatch] = "incorrect version number in NMSG header",
26  [nmsg_res_pbuf_ready] = "pbuf payload ready",
27  [nmsg_res_notimpl] = "function not implemented",
28  [nmsg_res_stop] = "stop condition reached",
29  [nmsg_res_again] = "call should be repeated again",
30  [nmsg_res_parse_error] = "parse error",
31  [nmsg_res_pcap_error] = "libpcap error",
32  [nmsg_res_read_failure] = "read failure",
33  [nmsg_res_container_full] = "NMSG container is full",
34  [nmsg_res_container_overfull] = "NMSG container is overfull",
35  [nmsg_res_errno] = "consult errno"
36 };
37 
38 static const char *res_unknown = "(unknown libnmsg result code)";
39 
40 const char *
42  if (val >= nmsg_res_success &&
43  val <= sizeof(res_strings) / sizeof(char *) &&
44  res_strings[val] != NULL)
45  {
46  return (res_strings[val]);
47  }
48  return (res_unknown);
49 }
nmsg_res
nmsg result code
Definition: res.h:25
success
Definition: res.h:26
nmsg header magic incorrect
Definition: res.h:30
out of memory
Definition: res.h:29
caller should try again
Definition: res.h:35
read failure
Definition: res.h:38
processing should stop
Definition: res.h:34
const char * nmsg_res_lookup(enum nmsg_res val)
Look up a result code by value.
Definition: res.c:41
module lacks a function
Definition: res.h:33
generic failure
Definition: res.h:27
a pbuf is ready to be written
Definition: res.h:32
unable to parse input
Definition: res.h:36
libpcap error
Definition: res.h:37
nmsg header version incorrect
Definition: res.h:31
end of file
Definition: res.h:28