本文整理汇总了Java中net.floodlightcontroller.packet.IPv4.PROTOCOL_ICMP属性的典型用法代码示例。如果您正苦于以下问题:Java IPv4.PROTOCOL_ICMP属性的具体用法?Java IPv4.PROTOCOL_ICMP怎么用?Java IPv4.PROTOCOL_ICMP使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.floodlightcontroller.packet.IPv4
的用法示例。
在下文中一共展示了IPv4.PROTOCOL_ICMP属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jsonToVip
protected LBVip jsonToVip(String json) throws IOException {
if (json==null) return null;
MappingJsonFactory f = new MappingJsonFactory();
JsonParser jp;
LBVip vip = new LBVip();
try {
jp = f.createJsonParser(json);
} catch (JsonParseException e) {
throw new IOException(e);
}
jp.nextToken();
if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
throw new IOException("Expected START_OBJECT");
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
throw new IOException("Expected FIELD_NAME");
}
String n = jp.getCurrentName();
jp.nextToken();
if (jp.getText().equals(""))
continue;
if (n.equals("id")) {
vip.id = jp.getText();
continue;
}
if (n.equals("tenant_id")) {
vip.tenantId = jp.getText();
continue;
}
if (n.equals("name")) {
vip.name = jp.getText();
continue;
}
if (n.equals("network_id")) {
vip.netId = jp.getText();
continue;
}
if (n.equals("protocol")) {
String tmp = jp.getText();
if (tmp.equalsIgnoreCase("TCP")) {
vip.protocol = IPv4.PROTOCOL_TCP;
} else if (tmp.equalsIgnoreCase("UDP")) {
vip.protocol = IPv4.PROTOCOL_UDP;
} else if (tmp.equalsIgnoreCase("ICMP")) {
vip.protocol = IPv4.PROTOCOL_ICMP;
}
continue;
}
if (n.equals("address")) {
vip.address = IPv4.toIPv4Address(jp.getText());
continue;
}
if (n.equals("port")) {
vip.port = Short.parseShort(jp.getText());
continue;
}
if (n.equals("pool_id")) {
vip.pools.add(jp.getText());
continue;
}
log.warn("Unrecognized field {} in " +
"parsing Vips",
jp.getText());
}
jp.close();
return vip;
}
示例2: jsonToPool
protected LBPool jsonToPool(String json) throws IOException {
if (json==null) return null;
MappingJsonFactory f = new MappingJsonFactory();
JsonParser jp;
LBPool pool = new LBPool();
try {
jp = f.createJsonParser(json);
} catch (JsonParseException e) {
throw new IOException(e);
}
jp.nextToken();
if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
throw new IOException("Expected START_OBJECT");
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
throw new IOException("Expected FIELD_NAME");
}
String n = jp.getCurrentName();
jp.nextToken();
if (jp.getText().equals(""))
continue;
if (n.equals("id")) {
pool.id = jp.getText();
continue;
}
if (n.equals("tenant_id")) {
pool.tenantId = jp.getText();
continue;
}
if (n.equals("name")) {
pool.name = jp.getText();
continue;
}
if (n.equals("network_id")) {
pool.netId = jp.getText();
continue;
}
if (n.equals("lb_method")) {
pool.lbMethod = Short.parseShort(jp.getText());
continue;
}
if (n.equals("protocol")) {
String tmp = jp.getText();
if (tmp.equalsIgnoreCase("TCP")) {
pool.protocol = IPv4.PROTOCOL_TCP;
} else if (tmp.equalsIgnoreCase("UDP")) {
pool.protocol = IPv4.PROTOCOL_UDP;
} else if (tmp.equalsIgnoreCase("ICMP")) {
pool.protocol = IPv4.PROTOCOL_ICMP;
}
continue;
}
if (n.equals("vip_id")) {
pool.vipId = jp.getText();
continue;
}
log.warn("Unrecognized field {} in " +
"parsing Pools",
jp.getText());
}
jp.close();
return pool;
}