use of org.onosproject.dhcprelay.api.DhcpServerInfo in project onos by opennetworkinglab.
the class Dhcp6HandlerImpl method processDhcp6ForwardOnly.
private List<InternalPacket> processDhcp6ForwardOnly(PacketContext context, Ethernet clientPacket, Set<Interface> clientInterfaces, DHCP6 dhcpPacket) {
ConnectPoint inPort = context.inPacket().receivedFrom();
log.trace("Got DHCPv6 on port {}", inPort);
boolean directConnFlag = Dhcp6HandlerUtil.directlyConnected(dhcpPacket);
List<InternalPacket> internalPackets = new ArrayList<>();
List<DhcpServerInfo> serverInfoList = findValidServerInfo(directConnFlag);
for (DhcpServerInfo dhcpServer : serverInfoList) {
Interface serverInterface = getServerInterface(dhcpServer);
if (serverInterface == null) {
log.warn("Can't get server interface, ignore");
continue;
}
Ethernet newPacket = Dhcp6HandlerUtil.buildDhcp6PacketFromClient(context, clientPacket, clientInterfaces, dhcpServer, serverInterface);
log.trace("Built packet for server {} : {}", dhcpServer, newPacket);
internalPackets.add(InternalPacket.internalPacket(newPacket, dhcpServer.getDhcpServerConnectPoint().get()));
}
return internalPackets;
}
use of org.onosproject.dhcprelay.api.DhcpServerInfo in project onos by opennetworkinglab.
the class DhcpRelayCommand method doExecute.
@Override
protected void doExecute() {
List<DhcpServerInfo> defaultDhcpServerInfoList = DHCP_RELAY_SERVICE.getDefaultDhcpServerInfoList();
List<DhcpServerInfo> indirectDhcpServerInfoList = DHCP_RELAY_SERVICE.getIndirectDhcpServerInfoList();
if (defaultDhcpServerInfoList.isEmpty() && indirectDhcpServerInfoList.isEmpty()) {
print(MISSING_SERVER_CFG);
return;
}
if (!defaultDhcpServerInfoList.isEmpty()) {
print(DEFAULT_SERVERS);
listServers(defaultDhcpServerInfoList);
}
if (!indirectDhcpServerInfoList.isEmpty()) {
print(INDIRECT_SERVERS);
listServers(indirectDhcpServerInfoList);
}
// DHCP records
Collection<DhcpRecord> records = DHCP_RELAY_SERVICE.getDhcpRecords();
if (records.isEmpty()) {
print(NO_RECORDS);
return;
}
// Handle display of counters
boolean toResetFlag;
if (counter != null) {
if (counter.equals("counter") || counter.equals("[counter]")) {
print(CONUTER_HEADER);
} else {
print("first parameter is [counter]");
return;
}
if (reset != null) {
if (reset.equals("reset") || reset.equals("[reset]")) {
toResetFlag = true;
} else {
print("Last parameter is [reset]");
return;
}
} else {
toResetFlag = false;
}
records.forEach(record -> {
print(COUNTER_HOST, record.macAddress(), record.vlanId(), record.locations(), record.directlyConnected() ? DIRECTLY : EMPTY);
DhcpRelayCounters v6Counters = record.getV6Counters();
Map<String, Integer> countersMap = v6Counters.getCounters();
countersMap.forEach((name, value) -> {
print("%-30s ............................ %-4d packets", name, value);
});
if (toResetFlag) {
v6Counters.resetCounters();
record.updateLastSeen();
DHCP_RELAY_SERVICE.updateDhcpRecord(HostId.hostId(record.macAddress(), record.vlanId()), record);
}
});
return;
}
// Handle display of records
print(HEADER);
records.forEach(record -> print(HOST, record.macAddress(), record.vlanId(), record.locations(), record.directlyConnected() ? DIRECTLY : EMPTY, Tools.timeAgo(record.lastSeen()), ip4State(record), ip6State(record)));
}
Aggregations