Buggy code:
for ( OFSwitch sw : switches ) { entry . addSwitch ( sw ) ; } } else if ( ( src . length ) == 4 ) { entry . addSwitch ( controller . getTopologyMapper ( ) . getMapping ( ByteBuffer . wrap ( src ) . getInt ( ) ) ) ; } OFFlowMod mod = new OFFlowMod ( ) ; OFMatch match = new OFMatch ( ) ; mod . setCommand ( ( ( byte ) ( 0 ) ) ) ; mod . setPriority ( ( ( short ) ( priority ) ) ) ; mod . setTableId ( ( ( byte ) ( 0 ) ) ) ; List < OFInstruction > instructions = new ArrayList < OFInstruction > ( ) ; if ( ( request . getFlowAction ( ) ) == ( FlowAction . ALLOW ) ) { OFInstructionGotoTable instruction = new OFInstructionGotoTable ( ) ; instruction . setTableId ( ( ( byte ) ( 1 ) ) ) ; instructions . add ( instruction ) ; } else if ( ( request . getFlowAction ( ) ) == ( FlowAction . DROP ) ) { OFActionOutput action = new OFActionOutput ( ) ; action . setMaxLength ( ( ( short ) ( 0 ) ) ) ; List < OFAction > actions = new ArrayList < OFAction > ( ) ; actions . add ( action ) ; OFInstructionApplyActions instruction = new OFInstructionApplyActions ( actions ) ; instructions . add ( instruction ) ; } mod . setInstructions ( instructions ) ; match . setDataLayerDestination ( src ) ; match . setDataLayerType ( ( ( short ) ( 2048 ) ) ) ; if ( ( src . length ) == 5 ) { int mask = ( - 1 ) << ( 32 - ( src [ 4 ] ) ) ; match . setNetworkDestinationMask ( ByteBuffer . wrap ( src ) . getInt ( ) , mask ) ; } else if ( ( src . length ) == 4 ) { match . setNetworkSource ( ByteBuffer . wrap ( dst ) . getInt ( ) ) ; } mod . setMatch ( match ) ; entry . setFlowMod ( mod ) ; retVal . add ( entry ) ; } } } else { for ( byte [ ] src : srcList ) { for ( byte [ ] dst : dstList ) { FlowEntry entry = new FlowEntry ( ) ; if ( ( src . length ) == 5 ) { ArrayList < OFSwitch > switches = controller . getTopologyMapper ( ) . getMappings ( ByteBuffer . wrap ( src ) . getInt ( ) , ( ( int ) ( src [ 4 ] ) ) ) ; for ( OFSwitch sw : switches ) { entry . addSwitch ( sw ) ; } } else if ( ( src . length ) == 4 ) { entry . addSwitch ( controller . getTopologyMapper ( ) . getMapping ( ByteBuffer . wrap ( src ) . getInt ( ) ) ) ; } OFFlowMod mod = new OFFlowMod ( ) ; OFMatch match = new OFMatch ( ) ; mod . setCommand ( ( ( byte ) ( 0 ) ) ) ; mod . setPriority ( ( ( short ) ( priority ) ) ) ; mod . setTableId ( ( ( byte ) ( 0 ) ) ) ; List < OFInstruction > instructions = new ArrayList < OFInstruction > ( ) ; if ( ( request . getFlowAction ( ) ) == ( FlowAction . ALLOW ) ) { OFInstructionGotoTable instruction = new OFInstructionGotoTable ( ) ; instruction . setTableId ( ( ( byte ) ( 1 ) ) ) ; instructions . add ( instruction ) ; } else if ( ( request . getFlowAction ( ) ) == ( FlowAction . DROP ) ) { OFActionOutput action = new OFActionOutput ( ) ; action . setMaxLength ( ( ( short ) ( 0 ) ) ) ; List < OFAction > actions = new ArrayList < OFAction > ( ) ; actions . add ( action ) ; OFInstructionApplyActions instruction = new OFInstructionApplyActions ( actions ) ; instructions . add ( instruction ) ; } mod . setInstructions ( instructions ) ; match . setDataLayerType ( ( ( short ) ( 2048 ) ) ) ; if ( ( src . length ) == 5 ) { int mask = ( - 1 ) << ( 32 - ( src [ 4 ] ) ) ; <START_BUG> match . setNetworkDestinationMask ( ByteBuffer . wrap ( src ) . getInt ( ) , mask ) ; <END_BUG> } else if ( ( src . length ) == 4 ) { match . setNetworkSource ( ByteBuffer . wrap ( src ) . getInt ( ) ) ; } if ( ( dst . length ) == 5 ) { int mask = ( - 1 ) << ( 32 - ( dst [ 4 ] ) ) ; match . setNetworkDestinationMask ( ByteBuffer . wrap ( dst ) . getInt ( ) , mask ) ; } else if ( ( dst . length ) == 4 ) { match . setNetworkDestination ( ByteBuffer . wrap ( dst ) . getInt ( ) ) ; } mod . setMatch ( match ) ; entry . setFlowMod ( mod ) ; retVal . add ( entry ) ; } } } } return retVal ; } public void updateFlows ( HostMapping newHost ) { } public boolean isAllowed ( HostMapping host ) { } public void removeIfAble ( ArrayList < FlowEntry > relevantFlows ) { } }

Fix:
match . setNetworkSourceMask ( ByteBuffer . wrap ( src ) . getInt ( ) , mask ) ;