本文整理汇总了C++中IpAddress::addr方法的典型用法代码示例。如果您正苦于以下问题:C++ IpAddress::addr方法的具体用法?C++ IpAddress::addr怎么用?C++ IpAddress::addr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IpAddress
的用法示例。
在下文中一共展示了IpAddress::addr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOGG
//L3 Interface Initialization
static bool setup_one_l3_interface(sai_vlan_id_t vlanid,
int port_count,
const sai_object_id_t *port_list,
const MacAddress mac,
const IpAddress ipaddr,
const IpAddress ipmask,
sai_object_id_t &rif_id)
{
LOGG(TEST_INFO, SETL3, "sai_vlan_api->create_vlan, create vlan %hu.\n", vlanid);
sai_status_t status = sai_vlan_api->create_vlan(vlanid);
if (status != SAI_STATUS_SUCCESS && status != SAI_STATUS_ITEM_ALREADY_EXISTS)
{
LOGG(TEST_ERR, SETL3, "fail to create vlan %hu. status=0x%x\n", vlanid, -status);
return false;
}
std::vector<sai_vlan_port_t> vlan_port_list;
for (int i = 0; i < port_count; ++i)
{
sai_vlan_port_t vlan_port;
vlan_port.port_id = port_list[i];
vlan_port.tagging_mode = SAI_VLAN_PORT_UNTAGGED;
vlan_port_list.push_back(vlan_port);
}
LOGG(TEST_INFO, SETL3, "sai_vlan_api->add_ports_to_vlan, add ports to vlan %d.\n", vlanid);
status = sai_vlan_api->add_ports_to_vlan(vlanid, port_count, vlan_port_list.data());
if (status != SAI_STATUS_SUCCESS)
{
LOGG(TEST_ERR, SETL3, "fail to add ports to vlan %hu. status=0x%x\n", vlanid, -status);
return false;
}
sai_attribute_t attr;
attr.id = SAI_PORT_ATTR_PORT_VLAN_ID;
attr.value.u16 = vlanid;
for (int i = 0; i < port_count; ++i)
{
LOGG(TEST_INFO, SETL3, "sai_port_api->set_port_attribute SAI_PORT_ATTR_PORT_VLAN_ID %hu to port 0x%lx\n",
vlanid, port_list[i]);
status = sai_port_api->set_port_attribute(port_list[i], &attr);
if (status != SAI_STATUS_SUCCESS)
{
LOGG(TEST_ERR, SETL3, "fail to set port %lu untagged vlan %hu. status=0x%x\n", port_list[i], vlanid, -status);
return false;
}
}
// create router interface
std::vector<sai_attribute_t> rif_attrs;
sai_attribute_t rif_attr;
rif_attr.id = SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID;
rif_attr.value.oid = g_vr_id;
rif_attrs.push_back(rif_attr);
rif_attr.id = SAI_ROUTER_INTERFACE_ATTR_TYPE;
rif_attr.value.s32 = SAI_ROUTER_INTERFACE_TYPE_VLAN;
rif_attrs.push_back(rif_attr);
rif_attr.id = SAI_ROUTER_INTERFACE_ATTR_SRC_MAC_ADDRESS;
memcpy(rif_attr.value.mac, mac.to_bytes(), sizeof(sai_mac_t));
rif_attrs.push_back(rif_attr);
rif_attr.id = SAI_ROUTER_INTERFACE_ATTR_VLAN_ID;
rif_attr.value.u16 = vlanid;
rif_attrs.push_back(rif_attr);
LOGG(TEST_INFO, SETL3, "sai_rif_api->create_router_interface\n");
status = sai_rif_api->create_router_interface(&rif_id, rif_attrs.size(), rif_attrs.data());
if (status != SAI_STATUS_SUCCESS)
{
LOGG(TEST_ERR, SETL3, "fail to create router interface. status=0x%x\n", -status);
return false;
}
if (!SAI_OID_TYPE_CHECK(rif_id, SAI_OBJECT_TYPE_ROUTER_INTERFACE))
{
LOGG(TEST_ERR, SETL3, "router interface oid generated is not the right type\n");
return false;
}
LOGG(TEST_DEBUG, SETL3, "router_interface created, rif_id 0x%lx\n", rif_id);
// add interface ip to l3 host table
LOGG(TEST_INFO, SETL3, "sai_route_api->create_route, SAI_ROUTE_ATTR_PACKET_ACTION, SAI_PACKET_ACTION_TRAP\n");
sai_unicast_route_entry_t unicast_route_entry;
unicast_route_entry.vr_id = g_vr_id;
unicast_route_entry.destination.addr_family = SAI_IP_ADDR_FAMILY_IPV4;
unicast_route_entry.destination.addr.ip4 = ipaddr.addr();
unicast_route_entry.destination.mask.ip4 = 0xffffffff;
sai_attribute_t route_attr;
//.........这里部分代码省略.........