com.github.sdnwiselab.sdnwise.packet.OpenPathPacket Maven / Gradle / Ivy
/*
* Copyright (C) 2015 SDN-WISE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package com.github.sdnwiselab.sdnwise.packet;
import com.github.sdnwiselab.sdnwise.util.NodeAddress;
import java.util.LinkedList;
import java.util.List;
/**
*
* @author SDN-WISE
*/
public class OpenPathPacket extends NetworkPacket{
public OpenPathPacket(byte[] data) {
super(data);
}
public OpenPathPacket() {
super();
this.setType(SDN_WISE_OPEN_PATH);
}
public OpenPathPacket(int[] data) {
super(data);
}
public OpenPathPacket setPath(List path){
byte i = 0;
for (NodeAddress addr : path) {
this.setPayloadAt(addr.getHigh(), i);
i++;
this.setPayloadAt(addr.getLow(), i);
i++;
}
return this;
}
public List getPath(){
LinkedList list = new LinkedList<>();
byte[] payload = this.getPayload();
for (int i = 0 ; i