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:
GnomeZworc 2026-10-12 12:23:48 +02:00
commit 853a1b8377
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
10 changed files with 99 additions and 91 deletions

21
internal/netif/mac.go Normal file
View 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
}