Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 1 | package org.openflow.protocol.match; |
| 2 | |
| 3 | import org.jboss.netty.buffer.ChannelBuffer; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 4 | import org.openflow.types.EthType; |
| 5 | import org.openflow.types.IPv4; |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 6 | import org.openflow.types.IpDscp; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 7 | import org.openflow.types.IpProtocol; |
| 8 | import org.openflow.types.MacAddress; |
| 9 | import org.openflow.types.OFPort; |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 10 | import org.openflow.types.OFValueType; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 11 | import org.openflow.types.U16; |
| 12 | import org.openflow.types.VlanPcp; |
| 13 | import org.openflow.types.VlanVid; |
| 14 | |
| 15 | public class MatchBuilderVer10 implements MatchBuilder { |
| 16 | |
| 17 | interface BuilderParamHandler<T> { |
| 18 | public T get(MatchBuilderVer10 builder); |
| 19 | |
| 20 | public void set(MatchBuilderVer10 builder, T value); |
| 21 | } |
| 22 | |
| 23 | // public static Map<MatchField<?,?>, BuilderParamHandler<?>> |
| 24 | // handlerMap = new HashMap(); |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 25 | |
| 26 | protected int wildcards; |
| 27 | protected OFPort inputPort; |
| 28 | protected MacAddress dataLayerSource; |
| 29 | protected MacAddress dataLayerDestination; |
| 30 | protected VlanVid dataLayerVirtualLan; |
| 31 | protected VlanPcp dataLayerVirtualLanPriorityCodePoint; |
| 32 | protected EthType dataLayerType; |
| 33 | protected IpDscp ipDscp; |
| 34 | protected IpProtocol networkProtocol; |
| 35 | protected IPv4 networkSource; |
| 36 | protected IPv4 networkDestination; |
| 37 | protected U16 transportSource; |
| 38 | protected U16 transportDestination; |
| 39 | |
| 40 | @SuppressWarnings("unchecked") |
| 41 | @Override |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame^] | 42 | public <F extends OFValueType<F>> F get(final MatchField<F> match) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 43 | switch (match.id) { |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame^] | 44 | case IN_PORT: |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 45 | return (F) inputPort; |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame^] | 46 | case ETH_SRC: |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 47 | return (F) dataLayerSource; |
| 48 | default: |
| 49 | return null; |
| 50 | } |
| 51 | } |
| 52 | |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 53 | @Override |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame^] | 54 | public <F extends OFValueType<F>> MatchBuilder set(final MatchField<F> match, final F value) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 55 | switch (match.id) { |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame^] | 56 | case IN_PORT: |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 57 | inputPort = (OFPort) value; |
| 58 | break; |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame^] | 59 | case ETH_SRC: |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 60 | dataLayerSource = (MacAddress) value; |
| 61 | break; |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame^] | 62 | default: |
| 63 | break; |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 64 | } |
| 65 | return this; |
| 66 | } |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame^] | 67 | |
| 68 | @Override |
| 69 | public <F extends OFValueType<F>> MatchBuilder unset(final MatchField<F> match) { |
| 70 | // TODO Auto-generated method stub |
| 71 | return null; |
| 72 | } |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 73 | |
| 74 | public OFPort getInputPort() { |
| 75 | return inputPort; |
| 76 | } |
| 77 | |
| 78 | public void setInputPort(final OFPort inputPort) { |
| 79 | this.inputPort = inputPort; |
| 80 | } |
| 81 | |
| 82 | public MacAddress getDataLayerSource() { |
| 83 | return dataLayerSource; |
| 84 | } |
| 85 | |
| 86 | public void setDataLayerSource(final MacAddress dataLayerSource) { |
| 87 | this.dataLayerSource = dataLayerSource; |
| 88 | } |
| 89 | |
| 90 | @Override |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 91 | public boolean supports(final MatchField<?> field) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 92 | // TODO Auto-generated method stub |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | @Override |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 97 | public boolean supportsMasked(final MatchField<?> field) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 98 | // TODO Auto-generated method stub |
| 99 | return false; |
| 100 | } |
| 101 | |
| 102 | @Override |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 103 | public boolean isExact(final MatchField<?> field) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 104 | // TODO Auto-generated method stub |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | @Override |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 109 | public boolean isFullyWildcarded(final MatchField<?> field) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 110 | // TODO Auto-generated method stub |
| 111 | return false; |
| 112 | } |
| 113 | |
| 114 | @Override |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 115 | public boolean isPartiallyMasked(final MatchField<?> field) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 116 | // TODO Auto-generated method stub |
| 117 | return false; |
| 118 | } |
| 119 | |
| 120 | @Override |
| 121 | public MatchBuilder getBuilder() { |
| 122 | // TODO Auto-generated method stub |
| 123 | return null; |
| 124 | } |
| 125 | |
| 126 | @Override |
| 127 | public int getLength() { |
| 128 | // TODO Auto-generated method stub |
| 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | @Override |
Andreas Wundsam | 2730346 | 2013-07-16 12:52:35 -0700 | [diff] [blame] | 133 | public void writeTo(final ChannelBuffer bb) { |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 134 | // TODO Auto-generated method stub |
| 135 | |
| 136 | } |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 137 | /* |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 138 | @Override |
| 139 | public <M> void setMasked(final MatchField<?, M> match, final M value) { |
| 140 | // TODO Auto-generated method stub |
| 141 | |
| 142 | } |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 143 | */ |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 144 | @Override |
| 145 | public Match getMatch() { |
| 146 | // TODO Auto-generated method stub |
| 147 | return null; |
| 148 | } |
| 149 | |
| 150 | } |