{-# LANGUAGE CPP #-}#include "HsNetDef.h"
moduleNetwork.Socket.If(ifNameToIndex ,ifIndexToName )whereimportForeign.Marshal.Alloc(allocaBytes)importNetwork.Socket.Imports -- | Returns the index corresponding to the interface name.---- Since 2.7.0.0.ifNameToIndex::String->IO(MaybeInt)ifNameToIndex ifname =doindex <-withCStringifname c_if_nametoindex -- On failure zero is returned. We'll return Nothing.return$ifindex ==0thenNothingelseJust$fromIntegralindex -- | Returns the interface name corresponding to the index.---- Since 2.7.0.0.ifIndexToName::Int->IO(MaybeString)ifIndexToName ifn =allocaBytes16$\ptr ->do-- 16 == IFNAMSIZr <-c_if_indextoname (fromIntegralifn )ptr ifr ==nullPtrthenreturnNothingelseJust<$>peekCStringptr foreignimportCALLCONVsafe"if_nametoindex"c_if_nametoindex::CString->IOCUIntforeignimportCALLCONVsafe"if_indextoname"c_if_indextoname::CUInt->CString->IOCString

AltStyle によって変換されたページ (->オリジナル) /