diff options
| -rw-r--r-- | src/include/ipxe/vlan.h | 1 | ||||
| -rw-r--r-- | src/net/netdevice.c | 11 | ||||
| -rw-r--r-- | src/net/vlan.c | 17 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/include/ipxe/vlan.h b/src/include/ipxe/vlan.h index d9f4484e6..083c21916 100644 --- a/src/include/ipxe/vlan.h +++ b/src/include/ipxe/vlan.h @@ -61,6 +61,7 @@ struct vlan_header { extern struct net_device * vlan_find ( struct net_device *trunk, unsigned int tag ); +extern unsigned int vlan_tag ( struct net_device *netdev ); extern int vlan_can_be_trunk ( struct net_device *trunk ); extern int vlan_create ( struct net_device *trunk, unsigned int tag, unsigned int priority ); diff --git a/src/net/netdevice.c b/src/net/netdevice.c index ec3456a93..a71666304 100644 --- a/src/net/netdevice.c +++ b/src/net/netdevice.c @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <ipxe/init.h> #include <ipxe/device.h> #include <ipxe/errortab.h> +#include <ipxe/vlan.h> #include <ipxe/netdevice.h> /** @file @@ -783,5 +784,15 @@ static void net_step ( struct process *process __unused ) { net_poll(); } +/** + * Get the VLAN tag (when VLAN support is not present) + * + * @v netdev Network device + * @ret tag 0, indicating that device is not a VLAN device + */ +__weak unsigned int vlan_tag ( struct net_device *netdev __unused ) { + return 0; +} + /** Networking stack process */ PERMANENT_PROCESS ( net_process, net_step ); diff --git a/src/net/vlan.c b/src/net/vlan.c index f7281f5d7..1a2a08622 100644 --- a/src/net/vlan.c +++ b/src/net/vlan.c @@ -283,6 +283,23 @@ struct net_protocol vlan_protocol __net_protocol = { }; /** + * Get the VLAN tag + * + * @v netdev Network device + * @ret tag VLAN tag, or 0 if device is not a VLAN device + */ +unsigned int vlan_tag ( struct net_device *netdev ) { + struct vlan_device *vlan; + + if ( netdev->op == &vlan_operations ) { + vlan = netdev->priv; + return vlan->tag; + } else { + return 0; + } +} + +/** * Check if network device can be used as a VLAN trunk device * * @v trunk Trunk network device |
