common.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2015 flannel authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package backend
  15. import (
  16. "net"
  17. "golang.org/x/net/context"
  18. "github.com/coreos/flannel/subnet"
  19. )
  20. type ExternalInterface struct {
  21. Iface *net.Interface
  22. IfaceAddr net.IP
  23. ExtAddr net.IP
  24. }
  25. // Besides the entry points in the Backend interface, the backend's New()
  26. // function receives static network interface information (like internal and
  27. // external IP addresses, MTU, etc) which it should cache for later use if
  28. // needed.
  29. type Backend interface {
  30. // Called when the backend should create or begin managing a new network
  31. RegisterNetwork(ctx context.Context, config *subnet.Config) (Network, error)
  32. }
  33. type Network interface {
  34. Lease() *subnet.Lease
  35. MTU() int
  36. Run(ctx context.Context)
  37. }
  38. type BackendCtor func(sm subnet.Manager, ei *ExternalInterface) (Backend, error)