-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from siemens/develop
Develop
- Loading branch information
Showing
13 changed files
with
139 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// (c) Siemens AG 2024 | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import React from 'react' | ||
|
||
import { SvgIconProps } from '@mui/material' | ||
|
||
import HardwareNicIcon from 'icons/nifs/HardwareNic' | ||
import HardwareNicPFIcon from 'icons/nifs/HardwareNicPF' | ||
import HardwareNicVFIcon from 'icons/nifs/HardwareNicVF' | ||
import { NetworkInterface, SRIOVRole } from 'models/gw/nif' | ||
|
||
const nifSRIOVIcons = { | ||
[SRIOVRole.None]: HardwareNicIcon, | ||
[SRIOVRole.PF]: HardwareNicPFIcon, | ||
[SRIOVRole.VF]: HardwareNicVFIcon, | ||
} | ||
|
||
export interface NifHWIconProps extends SvgIconProps { | ||
/** network interface object describing a network interface in detail. */ | ||
nif: NetworkInterface | ||
} | ||
|
||
export const NifHWIcon = ({ nif, ...props }: NifHWIconProps) => { | ||
const HWIcon = nifSRIOVIcons[nif.sriovrole || SRIOVRole.None] | ||
return <HWIcon {...props} /> | ||
} | ||
|
||
export default NifHWIcon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { NifHWIcon } from './NifHWIcon' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// (c) Siemens AG 2024 | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import React from 'react' | ||
|
||
import { SvgIconProps } from '@mui/material' | ||
|
||
import { NetworkInterface } from 'models/gw/nif' | ||
import BridgeIcon from 'icons/nifs/Bridge' | ||
import DummyIcon from 'icons/nifs/Dummy' | ||
import MacvlanIcon from 'icons/nifs/Macvlan' | ||
import TapIcon from 'icons/nifs/Tap' | ||
import TunIcon from 'icons/nifs/Tun' | ||
import VethIcon from 'icons/nifs/Veth' | ||
import { BridgeInternalIcon, MacvlanMasterIcon, NicIcon, OverlayIcon } from 'icons/nifs' | ||
import { GHOSTWIRE_LABEL_ROOT } from 'models/gw/model' | ||
import { NifHWIcon } from 'components/nifhwicon' | ||
|
||
// Known network interface type icons, indexed by the kind property of network | ||
// interface objects (and directly taken from what Linux' RTNETLINK tells us). | ||
const nifTypeIcons: { [key: string]: (props: SvgIconProps) => JSX.Element } = { | ||
'bridge': BridgeIcon, | ||
'dummy': DummyIcon, | ||
'macvlan': MacvlanIcon, | ||
'tap': TapIcon, | ||
'tun': TunIcon, | ||
'veth': VethIcon, | ||
'vxlan': OverlayIcon, | ||
} | ||
|
||
export interface NifIconProps extends SvgIconProps { | ||
/** network interface object describing a network interface in detail. */ | ||
nif: NetworkInterface | ||
/** show HW NIC icon instead of generic icon if nic is "physical". */ | ||
considerPhysical?: boolean | ||
} | ||
|
||
export const NifIcon = ({ nif, considerPhysical, ...props }: NifIconProps) => { | ||
if (!nif) { | ||
return <></> | ||
} | ||
if (considerPhysical && nif.isPhysical) { | ||
return <NifHWIcon nif={nif} {...props} /> | ||
} | ||
if (nif.labels && GHOSTWIRE_LABEL_ROOT + 'bridge/internal' in nif.labels) { | ||
return <BridgeInternalIcon {...props} /> | ||
} | ||
const Icon = (nif.tuntapDetails && nifTypeIcons[nif.tuntapDetails.mode]) || | ||
(nif.macvlans && MacvlanMasterIcon) || | ||
nifTypeIcons[nif.kind] || NicIcon | ||
return <Icon {...props} /> | ||
} | ||
|
||
export default NifIcon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { NifIcon } from './NifIcon' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters