Documentation ¶
Overview ¶
Package generates masks for u32 iptables module to match Romana entities.
Index ¶
- func IPNETtoUint(ipnet *net.IPNet) uint
- func IPtoBig(ip net.IP) *big.Int
- type U32
- func (u *U32) Addr(addr net.IP) *U32
- func (u *U32) MatchDst() string
- func (u *U32) MatchEndpoint() *U32
- func (u *U32) MatchEndpointId(endpointId uint) *U32
- func (u *U32) MatchHost() *U32
- func (u *U32) MatchHostId(hostId uint) *U32
- func (u *U32) MatchNet() *U32
- func (u *U32) MatchNetId(netId uint) *U32
- func (u *U32) MatchSegment() *U32
- func (u *U32) MatchSegmentId(segmentId uint) *U32
- func (u *U32) MatchSrc() string
- func (u *U32) MatchTenant() *U32
- func (u *U32) MatchTenantId(tenantId uint) *U32
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IPNETtoUint ¶
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
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 (*U32) Addr ¶
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 ¶
MatchDst renders u32 expression to match destination IP address in IPv4 packet.
func (*U32) MatchEndpoint ¶
MatchEndpoint configures u32 facility to match Endpoint bits of IP address provided by Addr() method.
func (*U32) MatchEndpointId ¶
MatchEndpointId configures u32 facility to match provided value against Endpoint bits of an address.
func (*U32) MatchHost ¶
MatchHost configures u32 facility to match Host bits of IP address provided by Addr() method.
func (*U32) MatchHostId ¶
MatchHostId configures u32 facility to match provided value against Host bits of an address.
func (*U32) MatchNet ¶
MatchNet configures u32 facility to match Net bits of IP address provided by Addr() method.
func (*U32) MatchNetId ¶
MatchEndpointId configures u32 facility to match provided value against Net bits of an address.
func (*U32) MatchSegment ¶
MatchSegment configures u32 facility to match Segment bits of IP address provided by Addr() method.
func (*U32) MatchSegmentId ¶
MatchSegmentId configures u32 facility to match provided value against Segment bits of an address.
func (*U32) MatchTenant ¶
MatchTenant configures u32 facility to match Tenant bits of IP address provided by Addr() method.
func (*U32) MatchTenantId ¶
MatchTenantId configures u32 facility to match provided value against Tenant bits of an address.