natplugin

package
v2.1.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IdentityMapping

type IdentityMapping struct {
	IP       net.IP
	Port     uint16
	Protocol renderer.ProtocolType
	VrfID    uint32
}

IdentityMapping represents a single identity mapping.

func (*IdentityMapping) Equals

func (im *IdentityMapping) Equals(im2 *IdentityMapping) bool

Equals compares this identity mapping with <im2>.

func (*IdentityMapping) String

func (im *IdentityMapping) String() string

String converts identity mapping into a human-readable string.

type IdentityMappings

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

IdentityMappings represents a list of identity mappings.

func (*IdentityMappings) Add

func (ims *IdentityMappings) Add(im *IdentityMapping) bool

Add adds new identity mapping into the list if it is not there yet.

func (*IdentityMappings) Count

func (ims *IdentityMappings) Count() int

Count returns the number of mappings in the list.

func (*IdentityMappings) Has

func (ims *IdentityMappings) Has(im *IdentityMapping) bool

Has returns true if the given mapping is already in the list.

func (*IdentityMappings) Join

func (ims *IdentityMappings) Join(ims2 *IdentityMappings) bool

Join adds all mappings from <ims2> into this list. Returns true if there were no duplicates.

func (*IdentityMappings) String

func (ims *IdentityMappings) String() string

String converts a list of identity mappings into a human-readable string.

func (*IdentityMappings) Subtract

func (ims *IdentityMappings) Subtract(ims2 *IdentityMappings) bool

Subtract removes all mappings that are in <ims2> from this list. Returns true if ims2 is subset of ims.

type Local

type Local struct {
	IP          net.IP
	Port        uint16
	Probability uint8
	VrfID       uint32
}

Local represents a single backend for VPP NAT mapping.

func (*Local) String

func (l *Local) String() string

String converts local into a human-readable string.

type MockNatPlugin

type MockNatPlugin struct {
	sync.Mutex

	Log logging.Logger
	// contains filtered or unexported fields
}

MockNatPlugin simulates the VPP/NAT plugin.

func NewMockNatPlugin

func NewMockNatPlugin(log logging.Logger) *MockNatPlugin

NewMockNatPlugin is a constructor for MockNatPlugin.

func (*MockNatPlugin) AddressPoolSize

func (mnt *MockNatPlugin) AddressPoolSize() int

AddressPoolSize returns the number of addresses in the NAT address pool.

func (*MockNatPlugin) ApplyTxn

func (mnt *MockNatPlugin) ApplyTxn(txn *localclient.Txn, latestRevs *syncbase.PrevRevisions) error

ApplyTxn applies transaction created by the service configurator.

func (*MockNatPlugin) DumpNat44DNat

func (mnt *MockNatPlugin) DumpNat44DNat() (dnats []*vpp_nat.DNat44)

DumpNat44DNat returns the current NAT44 DNAT config

func (*MockNatPlugin) DumpNat44Global

func (mnt *MockNatPlugin) DumpNat44Global() *vpp_nat.Nat44Global

DumpNat44Global returns the current NAT44 global config

func (*MockNatPlugin) GetInterfaceFeatures

func (mnt *MockNatPlugin) GetInterfaceFeatures(ifname string) NatFeatures

GetInterfaceFeatures returns features enabled for a given interface.

func (*MockNatPlugin) HasIdentityMapping

func (mnt *MockNatPlugin) HasIdentityMapping(im *IdentityMapping) bool

HasIdentityMapping tests for the presence of the given identity mapping.

func (*MockNatPlugin) HasStaticMapping

func (mnt *MockNatPlugin) HasStaticMapping(sm *StaticMapping) bool

HasStaticMapping tests for the presence of the given static mapping.

func (*MockNatPlugin) IsForwardingEnabled

func (mnt *MockNatPlugin) IsForwardingEnabled() bool

IsForwardingEnabled returns true if the forwarding is enabled.

func (*MockNatPlugin) NumOfIdentityMappings

func (mnt *MockNatPlugin) NumOfIdentityMappings() int

NumOfIdentityMappings returns the number of identity mappings installed.

func (*MockNatPlugin) NumOfIfsWithFeatures

func (mnt *MockNatPlugin) NumOfIfsWithFeatures() int

NumOfIfsWithFeatures returns the number of interfaces with some features enabled.

func (*MockNatPlugin) NumOfStaticMappings

func (mnt *MockNatPlugin) NumOfStaticMappings() int

NumOfStaticMappings returns the number of static mappings installed.

func (*MockNatPlugin) PoolContainsAddress

func (mnt *MockNatPlugin) PoolContainsAddress(addr net.IP) bool

PoolContainsAddress checks if the given address is in the NAT address pool.

func (*MockNatPlugin) Reset

func (mnt *MockNatPlugin) Reset()

Reset resets NAT configuration.

func (*MockNatPlugin) TwiceNatPoolContainsAddress

func (mnt *MockNatPlugin) TwiceNatPoolContainsAddress(addr string) bool

TwiceNatPoolContainsAddress checks if the given address is in the twice-NAT address pool.

func (*MockNatPlugin) TwiceNatPoolSize

func (mnt *MockNatPlugin) TwiceNatPoolSize() int

TwiceNatPoolSize returns the number of addresses in the twice-NAT address pool.

type NatFeatureType

type NatFeatureType int

NatFeatureType is one of IN, OUT, OUTPUT-IN, OUTPUT-OUT.

const (
	IN NatFeatureType = iota
	OUT
	OUTPUT_IN
	OUTPUT_OUT
)

func (NatFeatureType) Opposite

func (nft NatFeatureType) Opposite() NatFeatureType

func (NatFeatureType) String

func (nft NatFeatureType) String() string

type NatFeatures

type NatFeatures map[NatFeatureType]struct{}

NatFeatures is a set of NAT features.

func NewNatFeatures

func NewNatFeatures(features ...NatFeatureType) NatFeatures

NewNatFeatures is a constructor for NatFeatures.

func (NatFeatures) Add

func (nf NatFeatures) Add(feature NatFeatureType) bool

Add feature into the set. Returns false if the feature or its opposite is already there.

func (NatFeatures) Copy

func (nf NatFeatures) Copy() NatFeatures

Copy creates a deep copy of the set.

func (NatFeatures) Del

func (nf NatFeatures) Del(feature NatFeatureType)

Del feature from the set.

func (NatFeatures) Has

func (nf NatFeatures) Has(feature NatFeatureType) bool

Has returns true if the given feature is in the set.

func (NatFeatures) String

func (nf NatFeatures) String() string

String converts a set of NAT feature into a human-readable string.

type StaticMapping

type StaticMapping struct {
	ExternalIP   net.IP
	ExternalPort uint16
	Protocol     renderer.ProtocolType
	Locals       []*Local
	TwiceNAT     bool
}

StaticMapping represents a single static mapping.

func (*StaticMapping) Copy

func (sm *StaticMapping) Copy() *StaticMapping

Copy makes deep copy of a static mapping.

func (*StaticMapping) Equals

func (sm *StaticMapping) Equals(sm2 *StaticMapping) bool

Equals compares this static mapping with <sm2>.

func (*StaticMapping) String

func (sm *StaticMapping) String() string

String converts static mapping into a human-readable string.

type StaticMappings

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

StaticMappings represents a list of static mappings.

func (*StaticMappings) Add

func (sms *StaticMappings) Add(sm *StaticMapping) bool

Add adds new static mapping into the list if it is not there yet.

func (*StaticMappings) Count

func (sms *StaticMappings) Count() int

Count returns the number of mappings in the list.

func (*StaticMappings) Has

func (sms *StaticMappings) Has(sm *StaticMapping) bool

Has returns true if the given mapping is already in the list.

func (*StaticMappings) Join

func (sms *StaticMappings) Join(sms2 *StaticMappings) bool

Join adds all mappings from <sms2> into this list. Returns true if there were no duplicates.

func (*StaticMappings) String

func (sms *StaticMappings) String() string

String converts a list of static mappings into a human-readable string.

func (*StaticMappings) Subtract

func (sms *StaticMappings) Subtract(sms2 *StaticMappings) bool

Subtract removes all mappings that are in <sms2> from this list. Returns true if sms2 is subset of sms.

Jump to

Keyboard shortcuts

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