File: nmsg.go

package info (click to toggle)
golang-github-farsightsec-go-nmsg 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 500 kB
  • sloc: sh: 21; makefile: 3
file content (42 lines) | stat: -rw-r--r-- 1,064 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Copyright (c) 2017 by Farsight Security, Inc.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package nmsg

/*
#cgo pkg-config: libnmsg
#cgo LDFLAGS: -lnmsg
#include <nmsg.h>

int nmsg_wbufsiz_min = NMSG_WBUFSZ_MIN;
int nmsg_wbufsiz_max = NMSG_WBUFSZ_MAX;
int nmsg_wbufsiz_ether = NMSG_WBUFSZ_ETHER;
int nmsg_wbufsiz_jumbo = NMSG_WBUFSZ_JUMBO;
*/
import "C"

func init() {
	if C.nmsg_init() != C.nmsg_res_success {
		panic("failed to initialize nmsg library")
	}
}

// Buffer Size constants from libnmsg
var (
	BufferSizeMax   = int(C.nmsg_wbufsiz_max)
	BufferSizeMin   = int(C.nmsg_wbufsiz_min)
	BufferSizeEther = int(C.nmsg_wbufsiz_ether)
	BufferSizeJumbo = int(C.nmsg_wbufsiz_jumbo)
)

// SetDebug sets the debug print level for the nmsg library.
// Debugging messages are sent to stderr. Higher debug values
// increase verbosity.
func SetDebug(debug int) {
	C.nmsg_set_debug(C.int(debug))
}