-
-
Save voidlizard/70a12ec6c01be0cf2832 to your computer and use it in GitHub Desktop.
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
-- Get SCMessage body | |
{-# INLINE getSCMessageBody #-} | |
getSCMessageBody :: OFPHeader -> Get (M.TransactionID, M.SCMessage) | |
getSCMessageBody hdr@(OFPHeader {..}) = | |
if msgType == ofptPacketIn | |
then do packetInRecord <- getPacketInRecord len | |
return (msgTransactionID, M.PacketIn packetInRecord) | |
else if msgType == ofptEchoRequest | |
then do bytes <- getWord8s (len - headerSize) | |
return (msgTransactionID, M.SCEchoRequest bytes) | |
else if msgType == ofptEchoReply | |
then do bytes <- getWord8s (len - headerSize) | |
return (msgTransactionID, M.SCEchoReply bytes) | |
else if msgType == ofptFeaturesReply | |
then do switchFeaturesRecord <- getSwitchFeaturesRecord len | |
return (msgTransactionID, M.Features switchFeaturesRecord) | |
else if msgType == ofptHello | |
then return (msgTransactionID, M.SCHello) | |
else if msgType == ofptPortStatus | |
then do body <- getPortStatus | |
return (msgTransactionID, M.PortStatus body) | |
else if msgType == ofptError | |
then do body <- getSwitchError len | |
return (msgTransactionID, M.Error body) | |
else if msgType == ofptFlowRemoved | |
then do body <- getFlowRemovedRecord | |
return (msgTransactionID, M.FlowRemoved body) | |
else if msgType == ofptBarrierReply | |
then return (msgTransactionID, M.BarrierReply) | |
else if msgType == ofptStatsReply | |
then do body <- getStatsReply len | |
return (msgTransactionID, M.StatsReply body) | |
else if msgType == ofptQueueGetConfigReply | |
then do qcReply <- getQueueConfigReply len | |
return (msgTransactionID, M.QueueConfigReply qcReply) | |
else error ("Unrecognized message header: " ++ show hdr) | |
where len = fromIntegral msgLength |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍