unix: create types_illumos.go

create a new types_illumos.go for illumos specific constants
and structs, bring in those needed for wireguard-go

Signed-off-by: David Anderson <danderson@tailscale.com>
Signed-off-by: Nahum Shalman <nahamu@gmail.com>
This commit is contained in:
Nahum Shalman
2021-03-16 15:55:53 +00:00
parent 77fc1eacc6
commit 3003e04e7e
3 changed files with 88 additions and 1 deletions

View File

@@ -199,7 +199,7 @@ illumos_amd64)
mksyscall="go run mksyscall_solaris.go"
mkerrors=
mksysnum=
mktypes=
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
*)
echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2

47
unix/types_illumos.go Normal file
View File

@@ -0,0 +1,47 @@
// Copyright 2021 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 ignore
// +build ignore
/*
Input to cgo -godefs. See README.md
*/
package unix
/*
#include <net/if.h>
#include <sys/sockio.h>
#include <sys/stropts.h>
// Many illumos distributions ship a 3rd party tun/tap driver
// from https://github.com/kaizawa/tuntap
// It supports a pair of IOCTLs defined at
// https://github.com/kaizawa/tuntap/blob/master/if_tun.h#L91-L93
#define TUNNEWPPA (('T'<<16) | 0x0001)
#define TUNSETPPA (('T'<<16) | 0x0002)
*/
import "C"
const (
TUNNEWPPA = C.TUNNEWPPA
TUNSETPPA = C.TUNSETPPA
// sys/stropts.h:
I_STR = C.I_STR
I_POP = C.I_POP
I_PUSH = C.I_PUSH
I_PLINK = C.I_PLINK
I_PUNLINK = C.I_PUNLINK
// sys/sockio.h:
IF_UNITSEL = C.IF_UNITSEL
)
type strbuf C.struct_strbuf
type strioctl C.struct_strioctl
type lifreq C.struct_lifreq

View File

@@ -0,0 +1,40 @@
// cgo -godefs types_illumos.go | go run mkpost.go
// Code generated by the command above; see README.md. DO NOT EDIT.
//go:build amd64 && illumos
// +build amd64,illumos
package unix
const (
TUNNEWPPA = 0x540001
TUNSETPPA = 0x540002
I_STR = 0x5308
I_POP = 0x5303
I_PUSH = 0x5302
I_PLINK = 0x5316
I_PUNLINK = 0x5317
IF_UNITSEL = -0x7ffb8cca
)
type strbuf struct {
Maxlen int32
Len int32
Buf *int8
}
type strioctl struct {
Cmd int32
Timout int32
Len int32
Dp *int8
}
type lifreq struct {
Name [32]int8
Lifru1 [4]byte
Type uint32
Lifru [336]byte
}