示例#1
0
switch_status_t switch_api_lib_init(switch_device_t device) {
  switch_log_init();
  SWITCH_API_TRACE("Initializing switch api!!");
  switch_pd_client_init(device);
  switch_router_mac_init(device);
  switch_port_init(device);
  switch_bd_init(device);
  switch_lag_init(device);
  switch_interface_init(device);
  switch_mac_table_init(device);
  switch_l3_init(device);
  switch_vrf_init(device);
  switch_neighbor_init(device);
  switch_nhop_init(device);
  switch_mcast_init(device);
  switch_acl_init(device);
  switch_nat_init(device);
  switch_stp_init(device);
  switch_tunnel_init(device);
  switch_mirror_init(device);
  switch_hostif_init(device);
  switch_capability_init(device);
  switch_meter_init(device);
  switch_packet_init(device);
  switch_sflow_init(device);
  switch_qos_init(device);
  switch_buffer_init(device);
  switch_queue_init(device);
  switch_scheduler_init(device);
  switch_packet_init(device);

  return SWITCH_STATUS_SUCCESS;
}
示例#2
0
//Discover ports and initialize, raw sockets and I/O thread
rofl_result_t netfpga_discover_ports(){
	unsigned int i;	
	switch_port_t* port;
	char iface_name[NETFPGA_INTERFACE_NAME_LEN] = "0"; //nfX\0

	//Just add stuff
	for(i=0; i< NETFPGA_NUM_PORTS; ++i){
		//Compose name nf0...nf3
		snprintf(iface_name, NETFPGA_INTERFACE_NAME_LEN, NETFPGA_INTERFACE_BASE_NAME"%d", i);
		
		ROFL_DEBUG("["FWD_MOD_NAME"] Attempting to discover %s\n", iface_name);

		//Initialize pipeline structure	
		port = switch_port_init(iface_name, true/*will be overriden afterwards*/, PORT_TYPE_PHYSICAL, PORT_STATE_LIVE);

		//Init NetFPGA state (platform specific state)
		if(netfpga_init_port(port) != ROFL_SUCCESS) //checked
			return ROFL_FAILURE;
		
		//Add to available ports
		if( physical_switch_add_port(port) != ROFL_SUCCESS )// in rofl-core
			return ROFL_FAILURE;
		
	}


	return ROFL_SUCCESS;		
}