@ ConditionalOnClass ( { MacAddress . class , PcapIf . class , PcapAddr . class , SockAddr . class , DeviceNotFoundException . class , PlatformNotSupportedException . class } ) //@ConditionalOnBean(PcapIf.class) @ Bean ( MAC_ADDRESS_BEAN_NAME ) public MacAddress macAddress ( @ Qualifier ( PCAP_IF_BEAN_NAME ) PcapIf pcapIf ) throws PlatformNotSupportedException , DeviceNotFoundException , SocketException { MacAddress macAddress ; if ( pcapIf . isLoopback ( ) ) { macAddress = MacAddress . ZERO ; if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "No MAC address for loopback interface, use default address: {}." , macAddress ) ; } return macAddress ; } if ( Platforms . isWindows ( ) ) { byte [ ] hardwareAddress = Jxnet . FindHardwareAddress ( pcapIf . getName ( ) ) ; if ( hardwareAddress != null && hardwareAddress . length == MacAddress . MAC_ADDRESS_LENGTH ) { macAddress = MacAddress . valueOf ( hardwareAddress ) ; } else { throw new DeviceNotFoundException ( ) ; } } else { macAddress = MacAddress . fromNicName ( pcapIf . getName ( ) ) ; } if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Mac address: {}." , macAddress ) ; } return macAddress ; }
Default mac address specified by pcapIf .