Skip to content

Commit 6ee8cc6

Browse files
authored
Merge pull request #10 from crogers1/oxt-1011
[network] Implement method to see if vif connected
2 parents 9ec504c + 15bfbdc commit 6ee8cc6

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

nwd/Main.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ implementNWDServer = do
546546
, comCitrixXenclientNetworkdaemonList = runApp appState $ listNetworks
547547
, comCitrixXenclientNetworkdaemonListBackends = runApp appState $ listNetworkBackends
548548
, comCitrixXenclientNetworkdaemonIsInitialized = return True
549+
, comCitrixXenclientNetworkdaemonVifConnected = \vif domid -> vifConnected vif domid
549550
, comCitrixXenclientNetworkdaemonNdvmStatus = \uuid domid status -> runApp appState $ ndvmStatusUpdate uuid domid status
550551
, comCitrixXenclientNetworkdaemonCreateNetwork = createNetwork
551552
, comCitrixXenclientNetworkdaemonGetNetworkBackend = \nw -> runApp appState $ getNetworkBackend nw
@@ -581,6 +582,10 @@ listNetworkBackends = do
581582
then (networkSlaveObj slaveObj):[]
582583
else []
583584

585+
vifConnected :: String -> Int32 -> Rpc Bool
586+
vifConnected vif domid = do
587+
withNetworkSlave (fromIntegral domid) $ NWS.comCitrixXenclientNetworkslaveVifAdded slaveService slaveRootObj (vif)
588+
584589
getNetworkBackend :: String -> App String
585590
getNetworkBackend nw = do
586591
appState <- getAppState

nws/Main.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ import Data.Word
3535
import qualified Data.Map as M
3636
import qualified Data.Text.Lazy as TL
3737
import Data.Maybe
38+
import Data.List
3839

3940
import Text.Printf
4041
import Text.Regex.Posix
4142
import System.FilePath.Posix
4243
import System.Posix.Syslog
43-
import System.Process (system)
44+
import System.Process (system, readProcessWithExitCode)
4445

4546
import Control.Monad.Trans
4647
import Control.Monad.Error
@@ -172,6 +173,7 @@ implementNetworkSlaveInterfaces = do
172173
, comCitrixXenclientNetworkslaveNwConnectivity = runApp appState networkConnectivity
173174
, comCitrixXenclientNetworkslaveGetIcavmNetwork = runApp appState getIcavmNetwork
174175
, comCitrixXenclientNetworkslaveNmState = runApp appState $ liftRpc $ nmState
176+
, comCitrixXenclientNetworkslaveVifAdded = \vif -> runApp appState $ vifAdded vif
175177
}
176178

177179
createInternalNetworks :: Int -> App ()
@@ -230,3 +232,8 @@ listNetworks = do
230232
internalNws <- readMVar (internalNetworks appState)
231233
anyNw <- readMVar (anyNetwork appState)
232234
return ((M.keys wiredNws) ++ (M.keys wirelessNws) ++ (M.keys mobileNws) ++ (M.keys internalNws) ++ (anyNw:[]))
235+
236+
vifAdded :: String -> App (Bool)
237+
vifAdded vif = do
238+
(exitCode,stdout,_) <- liftIO $ readProcessWithExitCode "brctl" ["show"] []
239+
return $ isInfixOf vif stdout

nws/NetworkInterface.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ isWired :: NetworkObj -> Bool
8080
isWired network = network =~ "wired" :: Bool
8181

8282
isWireless :: NetworkObj -> Bool
83-
isWireless network = network =~ "wireless" :: Bool
83+
isWireless network = network =~ "wifi" :: Bool
8484

8585
isInternal :: NetworkObj -> Bool
8686
isInternal network = network =~ "internal" :: Bool
@@ -307,7 +307,7 @@ initWirelessNetwork iface = do
307307

308308
let index = 1 + getMaxIndex existingNws
309309
indexStr = show index
310-
nwId = "/wireless/" ++ indexStr
310+
nwId = "/wifi/" ++ indexStr
311311
sharedNw = nwId ++ "/shared"
312312
--brshared = "brwireless" ++ ifindex
313313
brshared = bridgeForWireless newNwConf index ifindex

0 commit comments

Comments
 (0)