utils

package
v0.0.0-...-24e3e83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright © 2020 GUILLAUME FOURNIER

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Char6ToEth

func Char6ToEth(ethChar [6]byte) string

Char6ToEth - Transforms an int64 representation of an IPv4 into a string

func DecodeDNS

func DecodeDNS(domain [kernel.DNSMaxLength]byte) string

DecodeDNS - Returns the domain name from its kernel representation

func EncodeDNS

func EncodeDNS(name string) ([kernel.DNSMaxLength]byte, error)

EncodeDNS - Returns the DNS packet representation of a domain name

func GetCgroupFromPid

func GetCgroupFromPid(pid uint32) uint64

GetCgroupFromPid - Returns the cgroup of a process

func GetCommFromPid

func GetCommFromPid(pid uint32) string

GetCommFromPid - Returns the comm of a process

func GetHostByteOrder

func GetHostByteOrder() binary.ByteOrder

GetHostByteOrder - Returns the host byte order

func GetMntnsFromPid

func GetMntnsFromPid(pid uint32) uint64

GetMntnsFromPid - Returns the mount namespace of a process

func GetNetnsFromPid

func GetNetnsFromPid(pid uint32) uint64

GetNetnsFromPid - Returns the network namespace of a process

func GetPidnsFromPid

func GetPidnsFromPid(pid uint32) uint64

GetPidnsFromPid - Returns the pid namespace of a process

func GetPpid

func GetPpid(pid uint32) uint32

GetPpid is a fallback to read the parent PID from /proc. Some kernel versions, like 4.13.0 return 0 getting the parent PID from the current task, so we need to use this fallback to have the parent PID in any kernel.

func GetUsernsFromPid

func GetUsernsFromPid(pid uint32) uint64

GetUsernsFromPid - Returns the user namespace of a process

func InterfaceToBytes

func InterfaceToBytes(data interface{}, byteOrder binary.ByteOrder) ([]byte, error)

InterfaceToBytes - Tranforms an interface into a C bytes array

func Uint64ToIPv4

func Uint64ToIPv4(ipUint uint64) string

Uint64ToIPv4 - Transforms an uint64 representation of an IPv4 into a string

func Uint64sToIPv6

func Uint64sToIPv6(ipUints [2]uint64) string

Uint64sToIPv6 - Transforms an [2]uint64 representation of an IPv6 into a string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL