/** * Create an interface * * @param interfaceName * @return NetworkPort * @throws Exception */ public static NetworkPort createInterface(String interfaceName) throws Exception { String argsInterface[] = new String[2]; argsInterface = splitInterfaces(interfaceName); String name = argsInterface[0]; int port = Integer.parseInt(argsInterface[1]); NetworkPort networkPort = new NetworkPort(); networkPort.setName(name); networkPort.setPortNumber(port); networkPort.setLinkTechnology(LinkTechnology.OTHER); return networkPort; }
/* * (non-Javadoc) * * @see org.opennaas.extensions.router.capability.ip.IIPCapability#setIPv4(org.opennaas.extensions.router.model.LogicalPort) */ @Override public void setIPv4(LogicalDevice iface, IPProtocolEndpoint ipProtocolEndpoint) throws CapabilityException { NetworkPort param = new NetworkPort(); param.setName(iface.getName()); if (iface instanceof NetworkPort) { param.setPortNumber(((NetworkPort) iface).getPortNumber()); param.setLinkTechnology(((NetworkPort) iface).getLinkTechnology()); } IPProtocolEndpoint ip = new IPProtocolEndpoint(); ip.setIPv4Address(ipProtocolEndpoint.getIPv4Address()); ip.setSubnetMask(ipProtocolEndpoint.getSubnetMask()); param.addProtocolEndpoint(ipProtocolEndpoint); IAction action = createActionAndCheckParams(IPActionSet.SET_IPv4, param); queueAction(action); }
private LogicalPort createLogicalInterface(String ifaceName, int portNumber) { NetworkPort iface = new NetworkPort(); iface.setName(ifaceName); iface.setPortNumber(portNumber); return iface; }