1 /* 2 * Copyright (c) 2008 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_CONSTANTS_H 18 #define NMSG_CONSTANTS_H 19 20 /*! \file nmsg/constants.h 21 * \brief Nmsg constants. 22 */ 23 24 /** 25 * Four-octet magic sequence seen at the beginning of a serialized NMSG. 26 */ 27 #define NMSG_MAGIC {'N', 'M', 'S', 'G'} 28 29 /** 30 * Current version number of the NMSG serialization format. With the 31 * introduction of #NMSG_LIBRARY_VERSION, #NMSG_PROTOCOL_VERSION was 32 * introduced to disambiguate version constants. It is assumed 33 * #NMSG_VERSION will be deprecated and removed in a future release. 34 */ 35 #define NMSG_VERSION 2U 36 #define NMSG_PROTOCOL_VERSION NMSG_VERSION 37 38 /** 39 * Number of octets in an NMSG header (magic + version). 40 */ 41 #define NMSG_HDRSZ 6 42 43 /** 44 * Number of octets in an NMSG header (magic + version + length). 45 */ 46 #define NMSG_HDRLSZ_V2 10 47 48 /** 49 * Number of octets in the NMSG v1 header length field. 50 */ 51 #define NMSG_LENHDRSZ_V1 2 52 53 /** 54 * Number of octets in the NMSG v2 header length field. 55 */ 56 #define NMSG_LENHDRSZ_V2 4 57 58 /** 59 * Maximum number of octets in an NMSG payload header. 60 */ 61 #define NMSG_PAYHDRSZ 64 62 63 /** 64 * Minimum number of octets that an nmsg wbuf must hold. 65 */ 66 #define NMSG_WBUFSZ_MIN 512 67 68 /** 69 * Maximum number of octets that an nmsg wbuf can hold. 70 */ 71 #define NMSG_WBUFSZ_MAX 1048576 72 73 /** 74 * Number of octets that an nmsg wbuf destined for transport over a jumbo 75 * frame Ethernet should hold. 76 */ 77 #define NMSG_WBUFSZ_JUMBO 8192 78 79 /** 80 * Number of octets that an nmsg wbuf destined for transport over an 81 * Ethernet should hold. 82 */ 83 #define NMSG_WBUFSZ_ETHER 1280 84 85 /** 86 * Number of octets than an nmsg rbuf must hold. Since an nmsg stream is 87 * delimited by length fields, the worst case amount of storage needed is 88 * twice the maximum length of an nmsg container. 89 */ 90 #define NMSG_RBUFSZ (2 * NMSG_WBUFSZ_MAX) 91 92 /** 93 * Number of milliseconds to wait for data on an nmsg socket before 94 * returning nmsg_res_again. 95 */ 96 #define NMSG_RBUF_TIMEOUT 500 97 98 /** 99 * Default libpcap snap length when reading from a live interface. 100 */ 101 #define NMSG_DEFAULT_SNAPLEN 1522 102 103 /** 104 * Maximize size of an IP datagram. 105 */ 106 #define NMSG_IPSZ_MAX 65536 107 108 /* NMSG flags */ 109 110 /** 111 * NMSG container is zlib compressed. 112 */ 113 #define NMSG_FLAG_ZLIB 0x01 114 115 /** 116 * NMSG container is fragmented. 117 */ 118 #define NMSG_FLAG_FRAGMENT 0x02 119 120 #endif 121