u32

package
v1.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package generates masks for u32 iptables module to match Romana entities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPNETtoUint

func IPNETtoUint(ipnet *net.IPNet) uint

IPNETtoUint attempts to convert CIDR into uint which is useful for MatchNetId method It takes provided cidr e.g. "10.0.0.0/8" in net.IPnet format and shifts it to the right to produce 10 as uint. For example "100.112.0.0/12" converts to binary as Address: 100.112.0.0 01100100.0111 0000.00000000.00000000 Netmask: 255.240.0.0 = 12 11111111.1111 0000.00000000.00000000 this function will shift binary representation of the address to the right to preserving only bits protected by leading 1 in a netmask e.g. 01100100.0111 0000.00000000.00000000 >> 01100100.0111 = 1607

func IPtoBig

func IPtoBig(ip net.IP) *big.Int

IPtoBig is a convinience method that produces big.Int from net.IP

Types

type U32

type U32 struct {
	// contains filtered or unexported fields
}

U32 provides facilities for generating expressions for iptables u32 module. The expressions can then be used to match romana entities encoded in an IP address.

func New

func New(net firewall.NetConfig) *U32

Creates new u32 facility

func (*U32) Addr

func (u *U32) Addr(addr net.IP) *U32

Pre loads u32 facility with an IP address. The address would be parsed and used as a source of romana bits for functions like u32.MatchHost(). Note: Addr() is useful when user has an IP address and wants to generate an expression that matches parts of this address. If user wants to match arbitrary bits he should use u32.Match*Id(uint) functions.

func (*U32) MatchDst

func (u *U32) MatchDst() string

MatchDst renders u32 expression to match destination IP address in IPv4 packet.

func (*U32) MatchEndpoint

func (u *U32) MatchEndpoint() *U32

MatchEndpoint configures u32 facility to match Endpoint bits of IP address provided by Addr() method.

func (*U32) MatchEndpointId

func (u *U32) MatchEndpointId(endpointId uint) *U32

MatchEndpointId configures u32 facility to match provided value against Endpoint bits of an address.

func (*U32) MatchHost

func (u *U32) MatchHost() *U32

MatchHost configures u32 facility to match Host bits of IP address provided by Addr() method.

func (*U32) MatchHostId

func (u *U32) MatchHostId(hostId uint) *U32

MatchHostId configures u32 facility to match provided value against Host bits of an address.

func (*U32) MatchNet

func (u *U32) MatchNet() *U32

MatchNet configures u32 facility to match Net bits of IP address provided by Addr() method.

func (*U32) MatchNetId

func (u *U32) MatchNetId(netId uint) *U32

MatchEndpointId configures u32 facility to match provided value against Net bits of an address.

func (*U32) MatchSegment

func (u *U32) MatchSegment() *U32

MatchSegment configures u32 facility to match Segment bits of IP address provided by Addr() method.

func (*U32) MatchSegmentId

func (u *U32) MatchSegmentId(segmentId uint) *U32

MatchSegmentId configures u32 facility to match provided value against Segment bits of an address.

func (*U32) MatchSrc

func (u *U32) MatchSrc() string

MatchSrc renders u32 expression to match source IP address in IPv4 packet.

func (*U32) MatchTenant

func (u *U32) MatchTenant() *U32

MatchTenant configures u32 facility to match Tenant bits of IP address provided by Addr() method.

func (*U32) MatchTenantId

func (u *U32) MatchTenantId(tenantId uint) *U32

MatchTenantId configures u32 facility to match provided value against Tenant bits of an address.

Jump to

Keyboard shortcuts

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