// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || netbsd || openbsd package routebsd import ( "syscall" "testing" ) func TestFetchRIBMessages(t *testing.T) { for _, typ := range []int{syscall.NET_RT_DUMP, syscall.NET_RT_IFLIST} { ms, err := FetchRIBMessages(typ, 0) if err != nil { t.Error(typ, err) continue } ss, err := msgs(ms).validate() if err != nil { t.Error(typ, err) continue } for _, s := range ss { t.Log(typ, s) } } } func TestParseRIBWithFuzz(t *testing.T) { for _, fuzz := range []string{ "0\x00\x05\x050000000000000000" + "00000000000000000000" + "00000000000000000000" + "00000000000000000000" + "0000000000000\x02000000" + "00000000", "\x02\x00\x05\f0000000000000000" + "0\x0200000000000000", "\x02\x00\x05\x100000000000000\x1200" + "0\x00\xff\x00", "\x02\x00\x05\f0000000000000000" + "0\x12000\x00\x02\x0000", "\x00\x00\x00\x01\x00", "00000", } { parseRIB([]byte(fuzz)) } }