f-41: netif: HostMAC et MaxVNI partagés (RMAC, MAC de gateway, borne des VNI) #41
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
42d763f15e
commit
853a1b8377
10 changed files with 99 additions and 91 deletions
21
internal/netif/mac.go
Normal file
21
internal/netif/mac.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package netif
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
const (
|
||||
locallyAdministered byte = 0x02
|
||||
|
||||
RoleRouter byte = 0x02
|
||||
RoleHostGateway byte = 0x03
|
||||
)
|
||||
|
||||
func HostMAC(role byte, vtep net.IP) (net.HardwareAddr, error) {
|
||||
ip := vtep.To4()
|
||||
if ip == nil {
|
||||
return nil, fmt.Errorf("vtep %v is not an IPv4 address", vtep)
|
||||
}
|
||||
return net.HardwareAddr{locallyAdministered, role, ip[0], ip[1], ip[2], ip[3]}, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue