1package network // import "github.com/docker/docker/api/types/network" 2import ( 3 "github.com/docker/docker/api/types/filters" 4 "github.com/docker/docker/errdefs" 5) 6 7// Address represents an IP address 8type Address struct { 9 Addr string 10 PrefixLen int 11} 12 13// IPAM represents IP Address Management 14type IPAM struct { 15 Driver string 16 Options map[string]string //Per network IPAM driver options 17 Config []IPAMConfig 18} 19 20// IPAMConfig represents IPAM configurations 21type IPAMConfig struct { 22 Subnet string `json:",omitempty"` 23 IPRange string `json:",omitempty"` 24 Gateway string `json:",omitempty"` 25 AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"` 26} 27 28// EndpointIPAMConfig represents IPAM configurations for the endpoint 29type EndpointIPAMConfig struct { 30 IPv4Address string `json:",omitempty"` 31 IPv6Address string `json:",omitempty"` 32 LinkLocalIPs []string `json:",omitempty"` 33} 34 35// Copy makes a copy of the endpoint ipam config 36func (cfg *EndpointIPAMConfig) Copy() *EndpointIPAMConfig { 37 cfgCopy := *cfg 38 cfgCopy.LinkLocalIPs = make([]string, 0, len(cfg.LinkLocalIPs)) 39 cfgCopy.LinkLocalIPs = append(cfgCopy.LinkLocalIPs, cfg.LinkLocalIPs...) 40 return &cfgCopy 41} 42 43// PeerInfo represents one peer of an overlay network 44type PeerInfo struct { 45 Name string 46 IP string 47} 48 49// EndpointSettings stores the network endpoint details 50type EndpointSettings struct { 51 // Configurations 52 IPAMConfig *EndpointIPAMConfig 53 Links []string 54 Aliases []string 55 // Operational data 56 NetworkID string 57 EndpointID string 58 Gateway string 59 IPAddress string 60 IPPrefixLen int 61 IPv6Gateway string 62 GlobalIPv6Address string 63 GlobalIPv6PrefixLen int 64 MacAddress string 65 DriverOpts map[string]string 66} 67 68// Task carries the information about one backend task 69type Task struct { 70 Name string 71 EndpointID string 72 EndpointIP string 73 Info map[string]string 74} 75 76// ServiceInfo represents service parameters with the list of service's tasks 77type ServiceInfo struct { 78 VIP string 79 Ports []string 80 LocalLBIndex int 81 Tasks []Task 82} 83 84// Copy makes a deep copy of `EndpointSettings` 85func (es *EndpointSettings) Copy() *EndpointSettings { 86 epCopy := *es 87 if es.IPAMConfig != nil { 88 epCopy.IPAMConfig = es.IPAMConfig.Copy() 89 } 90 91 if es.Links != nil { 92 links := make([]string, 0, len(es.Links)) 93 epCopy.Links = append(links, es.Links...) 94 } 95 96 if es.Aliases != nil { 97 aliases := make([]string, 0, len(es.Aliases)) 98 epCopy.Aliases = append(aliases, es.Aliases...) 99 } 100 return &epCopy 101} 102 103// NetworkingConfig represents the container's networking configuration for each of its interfaces 104// Carries the networking configs specified in the `docker run` and `docker network connect` commands 105type NetworkingConfig struct { 106 EndpointsConfig map[string]*EndpointSettings // Endpoint configs for each connecting network 107} 108 109// ConfigReference specifies the source which provides a network's configuration 110type ConfigReference struct { 111 Network string 112} 113 114var acceptedFilters = map[string]bool{ 115 "driver": true, 116 "type": true, 117 "name": true, 118 "id": true, 119 "label": true, 120 "scope": true, 121} 122 123// ValidateFilters validates the list of filter args with the available filters. 124func ValidateFilters(filter filters.Args) error { 125 return errdefs.InvalidParameter(filter.Validate(acceptedFilters)) 126} 127