}
@Override
public List<OFAction> parseActions(ByteBuffer data, int length, int limit) {
List<OFAction> results = new ArrayList<OFAction>();
OFAction demux = new OFAction();
OFAction ofa;
int end = data.position() + length;
while (limit == 0 || results.size() <= limit) {
if (data.remaining() < OFAction.MINIMUM_LENGTH ||
(data.position() + OFAction.MINIMUM_LENGTH) > end)
return results;
data.mark();
demux.readFrom(data);
data.reset();
if (demux.getLengthU() > data.remaining() ||
(data.position() + demux.getLengthU()) > end)
return results;
ofa = getAction(demux.getType());
ofa.readFrom(data);
if (OFAction.class.equals(ofa.getClass())) {
// advance the position for un-implemented messages
data.position(data.position()+(ofa.getLengthU() -
OFAction.MINIMUM_LENGTH));
}
results.add(ofa);
}