added support for string type
[govpp.git] / vendor / github.com / google / gopacket / routing / common.go
1 // Copyright 2012 Google, Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
5 // tree.
6
7 package routing
8
9 import (
10         "net"
11 )
12
13 // Router implements simple IPv4/IPv6 routing based on the kernel's routing
14 // table.  This routing library has very few features and may actually route
15 // incorrectly in some cases, but it should work the majority of the time.
16 type Router interface {
17         // Route returns where to route a packet based on the packet's source
18         // and destination IP address.
19         //
20         // Callers may pass in nil for src, in which case the src is treated as
21         // either 0.0.0.0 or ::, depending on whether dst is a v4 or v6 address.
22         //
23         // It returns the interface on which to send the packet, the gateway IP
24         // to send the packet to (if necessary), the preferred src IP to use (if
25         // available).  If the preferred src address is not given in the routing
26         // table, the first IP address of the interface is provided.
27         //
28         // If an error is encountered, iface, geteway, and
29         // preferredSrc will be nil, and err will be set.
30         Route(dst net.IP) (iface *net.Interface, gateway, preferredSrc net.IP, err error)
31
32         // RouteWithSrc routes based on source information as well as destination
33         // information.  Either or both of input/src can be nil.  If both are, this
34         // should behave exactly like Route(dst)
35         RouteWithSrc(input net.HardwareAddr, src, dst net.IP) (iface *net.Interface, gateway, preferredSrc net.IP, err error)
36 }