void invocation(const ComType com, const uint8_t *data) {
	switch(((StandardMessage*)data)->header.fid) {
		case FID_SET_CONFIGURATION: {
			set_configuration(com, (SetConfiguration*)data);
			return;
		}

		case FID_GET_CONFIGURATION: {
			get_configuration(com, (GetConfiguration*)data);
			return;
		}

		case FID_SET_CALIBRATION: {
			set_calibration(com, (SetCalibration*)data);
			return;
		}

		case FID_GET_CALIBRATION: {
			get_calibration(com, (GetCalibration*)data);
			return;
		}

		default: {
			simple_invocation(com, data);
			break;
		}
	}

	if(((StandardMessage*)data)->header.fid > FID_LAST) {
		BA->com_return_error(data, sizeof(MessageHeader), MESSAGE_ERROR_CODE_NOT_SUPPORTED, com);
	}
}
Пример #2
0
ui_element_instance_ptr UIElement::instantiate(HWND p_parent,ui_element_config::ptr cfg,ui_element_instance_callback_ptr p_callback)
{
	set_configuration(cfg);
	m_callback = p_callback;

	initialize_window(p_parent);

	return this;
}
Пример #3
0
/*
 * Main
 */
int         main(int argc, char *argv[]) {
    config  cfg;

    memset(&cfg, 0, sizeof(cfg));
    fail_if_aes_ni_absent();
    set_configuration(&cfg, argc, argv);
    process_stream(&cfg);
    exit(EXIT_SUCCESS);
}
Пример #4
0
int system_set_configuration(adc_input input, adc_range range,
    adc_integration_period period, adc_channel _channel, double _gain, double _offset,
    adc_resolution res)
{
    xSemaphoreTake(syslock, portMAX_DELAY);
    int ret = set_configuration(input, range, period, _channel, _gain, _offset, res);
    xSemaphoreGive(syslock);
    return ret;
}
Пример #5
0
// Called in ISR context
// Set configuration. Return false if the
// configuration is not supported.
void USBTester::callback_set_configuration(uint8_t configuration)
{
    bool ret = false;

    if (configuration >= DEFAULT_CONFIGURATION && configuration <= LAST_CONFIGURATION) {
        endpoint_remove_all();
        ret = set_configuration(configuration);
    }

    complete_set_configuration(ret);
}
Пример #6
0
//-----------------------------------------------------------------
// usb_process_request:
//-----------------------------------------------------------------
static void usb_process_request(struct device_request *request, unsigned char type, unsigned char req, unsigned char *data)
{
	if ( type == USB_STANDARD_REQUEST )
	{
        // Standard requests
        switch (req)
        {
        case REQ_GET_STATUS:
            get_status(request);
            break;
        case REQ_CLEAR_FEATURE:
            clear_feature(request);
            break;
        case REQ_SET_FEATURE:
            set_feature(request);
            break;
        case REQ_SET_ADDRESS:
            set_address(request);
            break;
        case REQ_GET_DESCRIPTOR:
            get_descriptor(request);
            break;
        case REQ_GET_CONFIGURATION:
            get_configuration(request);
            break;
        case REQ_SET_CONFIGURATION:
            set_configuration(request);
            break;
        case REQ_GET_INTERFACE:
            get_interface(request);
            break;
        case REQ_SET_INTERFACE:
            set_interface(request);
            break;
        default:
            log_printf(USBLOG_ERR, "USB: Unknown standard request %x\n", req);
		    usbhw_control_endpoint_stall();
            break;
        }
	}
	else if ( type == USB_VENDOR_REQUEST )
	{
        log_printf(USBLOG_ERR, "Vendor: Unknown command\n");

        // None supported
		usbhw_control_endpoint_stall();
	}
	else if ( type == USB_CLASS_REQUEST && _class_request)
	{
        _class_request(req, request->wValue, request->wIndex, data, request->wLength);
	}
	else
        usbhw_control_endpoint_stall();
}
Пример #7
0
void system_init(void)
{
    hal_sys_init();
    hal_i2c_init();
    usb_uart_init();
    tmp245_init();
    /* initialize system lock */
    syslock = xSemaphoreCreateMutex();
    set_configuration(ADC_INPUT_VOLTAGE_DC, ADC_RANGE_300, 
        ADC_INTEGRATION_50HZ, ADC_CHANNEL_0, 1, 0, ADC_RESOLUTION_5_5);
}
Пример #8
0
SmoothArtUIE::SmoothArtUIE(ui_element_config::ptr cfg, ui_element_instance_callback_ptr callback)
	: m_callback(callback)
{
	set_configuration(cfg);

	playlist = static_api_ptr_t<playlist_manager>();
	playback = static_api_ptr_t<playback_control>();
	art_loader = static_api_ptr_t<album_art_manager>()->instantiate();

	if (!RendererGL::isInitialized())
		RendererGL::Initialize();
}
Пример #9
0
/*---------------------------------------------------------------------------*/
static int configure(int type, int c) {
	switch (type) {
		case SENSORS_ACTIVE:
			if (c) {
				// set active
				set_configuration();
			} else {
				// set inactive
			}
			return 1;
	}
	return 0;
}
Пример #10
0
bool USB_Device::set_default()
{
    if (!_dev || !_dev->config || !_dev->config->interface || !_dev->config->interface->altsetting)
    {
        return false;
    }

    int config = _dev->config->bConfigurationValue;
    int interface = _dev->config->interface->altsetting->bInterfaceNumber;
    int alt = _dev->config->interface->altsetting->bAlternateSetting;
    
    return set_configuration(config) &&
           claim_interface(interface) &&
           set_altinterface(alt);
}
static int set_connected_dhcp(struct connman_network *network)
{
	int err;

	DBG("network %p", network);

	set_configuration(network);

	err = __connman_dhcp_start(network, dhcp_callback);
	if (err < 0) {
		connman_error("Can not request DHCP lease");
		return err;
	}

	return 0;
}
static void set_connected_manual(struct connman_network *network)
{
	struct connman_service *service;
	struct connman_ipconfig *ipconfig;
	int err;

	DBG("network %p", network);

	service = __connman_service_lookup_from_network(network);

	ipconfig = __connman_service_get_ip4config(service);

	if (__connman_ipconfig_get_local(ipconfig) == NULL)
		__connman_service_read_ip4config(service);

	set_configuration(network);

	err = __connman_ipconfig_address_add(ipconfig);
	if (err < 0)
		goto err;

#if defined TIZEN_EXT
/*
 * Description: __connman_service_lookup_from_index cannot find correct service
 */
	err = __connman_ipconfig_gateway_add(ipconfig, service);
#else
	err = __connman_ipconfig_gateway_add(ipconfig);
#endif
	if (err < 0)
		goto err;

	network->connecting = FALSE;

	connman_network_set_associating(network, FALSE);

	return;

err:
	connman_network_set_error(network,
					CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL);
	return;
}
Пример #13
0
static int set_config(struct a2dp_sep *sep, struct audio_device *dev,
				uint8_t *configuration, size_t length,
				struct a2dp_setup *setup,
				a2dp_endpoint_config_t cb,
				void *user_data)
{
	struct media_endpoint *endpoint = user_data;
	struct a2dp_config_data *data;

	data = g_new0(struct a2dp_config_data, 1);
	data->setup = setup;
	data->cb = cb;

	if (set_configuration(endpoint, dev, configuration, length,
					config_cb, data, g_free) == TRUE)
		return 0;

	g_free(data);
	return -ENOMEM;
}
static int set_connected_fixed(struct connman_network *network)
{
	struct connman_service *service;
	struct connman_ipconfig *ipconfig_ipv4;
	int err;

	DBG("");

	service = __connman_service_lookup_from_network(network);

	ipconfig_ipv4 = __connman_service_get_ip4config(service);

	set_configuration(network);

	network->connecting = FALSE;

	connman_network_set_associating(network, FALSE);

	err = __connman_ipconfig_address_add(ipconfig_ipv4);
	if (err < 0)
		goto err;

#if defined TIZEN_EXT
/*
 * Description: __connman_service_lookup_from_index cannot find correct service
 */
	err = __connman_ipconfig_gateway_add(ipconfig_ipv4, service);
#else
	err = __connman_ipconfig_gateway_add(ipconfig_ipv4);
#endif
	if (err < 0)
		goto err;

	return 0;

err:
	connman_network_set_error(network,
			CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL);

	return err;
}
Пример #15
0
static int initialise_temper1(struct usb_dev_handle *handle)
{
	int r = detach_driver(handle, INTERFACE0);
	if (r >= 0) r = 
		detach_driver(handle, INTERFACE1);
	if (r >= 0) r = 
		set_configuration(handle, 0x01);
	if (r >= 0) r = 
		claim_interface(handle, INTERFACE0);
	if (r >= 0) r = 
		claim_interface(handle, INTERFACE1);
/*
	// In light of discovery that the HID implementation has a keyboard emulation
	// and a vendor specific mode, don't touch anything else. No init needed?
	if (r >= 0) r = 
		control_message(handle, CTRL_REQ_TYPE, CTRL_REQ, CTRL_VALUE, 
			0, cq_initialise, sizeof(cq_initialise));
		
*/
	return r;
}
Пример #16
0
RES_CODE usb_remote_hid_t::scan_hid(uint32_t port_indx, USBSubClassCode subcls, USBProtocolCode proto)
{
	RES_CODE res;

	// select EPT_0 and device address
	ep0_hnd->mode.as_bytes[0] = EPT_0; // RX pipe
	ep0_hnd->mode.as_bytes[1] = EPT_0; // TX pipe
	res = hdc_init(port_indx);
	if(res == RES_OK)
	{
		epi_hnd->mode0 = ep0_hnd->mode0;  // device hub port
		// TRACE Device descriptor
		TRACELN("HID: dev found %x:%x", dev_descriptor.idVendor, dev_descriptor.idProduct);
		trace_usb_descriptor(&dev_descriptor.as_generic);
		if(dev_descriptor.bDeviceClass == INTERFACE_DEFINED_CLASS)
		{
			//loop the configurations
			for(uint32_t cfg_indx=0; cfg_indx<dev_descriptor.bNumConfigurations; cfg_indx++)
			{
				res = get_config_descriptor(cfg_indx);
				if(res != RES_OK)
					break;

				// TRACE Configuration descriptor(s)
				trace_usb_descriptor(&config_descriptor->as_generic);

				//loop the interfaces
				for(uint32_t iface_indx=0; iface_indx<config_descriptor->bNumInterfaces; iface_indx++)
				{
					pid = usb_get_interface(config_descriptor, iface_indx);
					if(pid && pid->bDeviceClass == HID_DEVICE_CLASS &&
							pid->bDeviceSubClass == subcls && pid->bDeviceProtocol == proto)
					{
						// set the configuration
//						set_configuration(0);
						res = set_configuration(config_descriptor->bConfigurationValue);

						if(res == RES_OK)
						{
							epi_hnd->mode.as_bytes[0] = EPT_0;
							epi_hnd->mode.as_bytes[1] = EPT_0;
							for(int i=0; i<pid->bNumEndpoints && i<2; i++)
							{
								USBEndpointDescriptor* ped;

								ped = usb_get_enpoint(config_descriptor, i);
								if(ped && ped->bmAttributes == ENDPOINT_TYPE_INTERRUPT)
								{
									if( ped->bEndpointAddress & 0x80 )
									{
										if(epi_hnd->mode.as_bytes[0] == EPT_0)
										{
											epi_hnd->mode.as_bytes[0] = ped->bEndpointAddress & 0x7F;
											epi_hnd->mode.as_ushort[1] = ep0_hnd->mode.as_ushort[1]; //drv_state_cnt
											usb_svc_configendpoint(epi_hnd, &ped->as_generic);
										}
									} else
									{
										if(epi_hnd->mode.as_bytes[1] == EPT_0)
										{
											epi_hnd->mode.as_bytes[1] = ped->bEndpointAddress ;
											epi_hnd->mode.as_ushort[1] = ep0_hnd->mode.as_ushort[1]; //drv_state_cnt
											usb_svc_configendpoint(epi_hnd, &ped->as_generic);
										}
									}
								}
							}
							hid_idle = 255;
							get_idle(HID_REPORT_ALL);
							return RES_OK;

						}
					}
				}
			}
		}
	}

	if(res == RES_OK)
		res = RES_ERROR;
	return res;
}
Пример #17
0
static unsigned int
handle_standard_requests()
{
  switch(usb_setup_buffer.bmRequestType) {
  case 0x80: /* standard device IN requests */
    switch(usb_setup_buffer.bRequest) {
    case GET_DESCRIPTOR:
      switch (HIGH_BYTE(usb_setup_buffer.wValue)) {
      case DEVICE:
	get_device_descriptor();
	break;
      case CONFIGURATION:
	get_configuration_descriptor();
	break;
      case STRING:
	get_string_descriptor();
	break;
      default:
	/* Unknown descriptor */
	return 0;
      }
      break;
    case GET_CONFIGURATION:
      get_configuration();
      break;
    case GET_STATUS:
      get_device_status();
      break;
    case GET_INTERFACE:
      get_interface();
      break;
    default:
      return 0;
    }
    break;
  case 0x81: /* standard interface IN requests */
    switch(usb_setup_buffer.bRequest) {
    case GET_STATUS:
      get_interface_status();
      break;
#ifdef HID_ENABLED
      case GET_DESCRIPTOR:
	switch (USB_setup_buffer.wValue.byte.high) {
	case REPORT:
	  get_report_descriptor();
	  break;
	}
	break;
#endif	
    default:
      return 0;
    }
    break;
  case 0x82: /* standard endpoint IN requests */
    switch(usb_setup_buffer.bRequest) {
    case GET_STATUS:
      get_endpoint_status();
      break;
    default:
      return 0;
    }
    break;
  case 0x00: /* standard device OUT requests */
    switch(usb_setup_buffer.bRequest) {
    case SET_ADDRESS:
      PRINTF("Address: %d\r\n", LOW_BYTE(usb_setup_buffer.wValue));
      usb_flags |= USB_FLAG_ADDRESS_PENDING;
      /* The actual setting of the address is done when the status packet
	 is sent. */
      usb_send_ctrl_status();
      break;
#if SETABLE_STRING_DESCRIPTORS > 0
    case SET_DESCRIPTOR:
      if (usb_setup_buffer.wValue.byte.high == STRING) {
	set_string_descriptor();
      } else {
	return 0;
      }
      break;
#endif
    case SET_CONFIGURATION:
      if (set_configuration()) {
#if 0
	config_msg.data.config = LOW_BYTE(usb_setup_buffer.wValue);
	notify_user(&config_msg);
#endif
      }
      break;
    default:
      return 0;
    }
    break;
  case 0x01: /* standard interface OUT requests */
    switch(usb_setup_buffer.bRequest) {
    case SET_INTERFACE:
      /* Change interface here if we support more than one */
      usb_send_ctrl_status();
      break;
    default:
      return 0;
    }
    break;
  case 0x02: /* standard endpoint OUT requests */
    switch(usb_setup_buffer.bRequest) {
    case SET_FEATURE:
    case CLEAR_FEATURE:
      if (usb_setup_buffer.wValue == ENDPOINT_HALT_FEATURE) {
	usb_arch_halt_endpoint(usb_setup_buffer.wIndex, usb_setup_buffer.bRequest== SET_FEATURE);
	usb_send_ctrl_status();
      } else {
	usb_error_stall();
      }
      break;
    default:
      return 0;
    }
    break;
#ifdef HID_ENABLED
  case 0xa1: /* class specific interface IN request*/
    switch(USB_setup_buffer.bRequest) {
    case GET_HID_REPORT:
      PRINTF("Get report\r\n");
      send_ctrl_response((code u_int8_t*)&zero_byte,
			   sizeof(zero_byte));
      break;
    case GET_HID_IDLE:
      PRINTF("Get idle\r\n");
      send_ctrl_response((code u_int8_t*)&zero_byte,
			 sizeof(zero_byte));
      break;
    default:
      return 0;
      }
    break;
  case 0x21: /* class specific interface OUT request*/
    switch(USB_setup_buffer.bRequest) {
    case SET_HID_IDLE:
      PRINTF("Set idle\r\n");
      send_ctrl_status();
      break;
    default:
      return 0;
    }
    break;
#endif
  default:
    return 0;
  }
  return 1;
}
Пример #18
0
int
main( int argc, char *argv[] )
{
     DFBResult ret;

     /* Initialize DirectFB including command line parsing. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          DirectFBError( "DirectFBInit() failed", ret );
          return -1;
     }

     /* Parse the command line. */
     if (!parse_command_line( argc, argv ))
          return -2;

     /* Create the super interface. */
     ret = DirectFBCreate( &dfb );
     if (ret) {
          DirectFBError( "DirectFBCreate() failed", ret );
          return -3;
     }

     /* Get the primary display layer. */
     ret = dfb->GetDisplayLayer( dfb, id, &layer );
     if (ret) {
          if (ret == DFB_IDNOTFOUND)
               fprintf (stderr, "\nUnknown layer id, check 'dfbinfo' for valid values.\n\n");
          else
               DirectFBError( "IDirectFB::GetDisplayLayer() failed", ret );
          dfb->Release( dfb );
          return -4;
     }

     /* Get a description of the layer. */
     ret = layer->GetDescription( layer, &desc );
     if (ret) {
          DirectFBError( "IDirectFBDisplayLayer::GetDescription() failed", ret );
          layer->Release( layer );
          dfb->Release( dfb );
          return -5;
     }

     /* Acquire administrative cooperative level. */
     ret = layer->SetCooperativeLevel( layer, DLSCL_ADMINISTRATIVE );
     if (ret) {
          DirectFBError( "IDirectFBDisplayLayer::SetCooperativeLevel() failed", ret );
          layer->Release( layer );
          dfb->Release( dfb );
          return -6;
     }

     /* Show/change the configuration. */
     set_configuration();

     /* Test Lock() on layer surface? */
     if (test_lock) {
          IDirectFBSurface *surface;

          fprintf( stderr, "\nGetting layer surface...\n" );

          ret = layer->GetSurface( layer, &surface );
          if (ret)
               DirectFBError( "IDirectFBDisplayLayer::GetSurface() failed", ret );
          else {
               void *data;
               int   pitch;

               fprintf( stderr, "\nTesting Lock( %s ) on layer surface...\n",
                        test_lock == DSLF_READ ? "read only" : test_lock == DSLF_WRITE ? "write only" : "read/write" );

               ret = surface->Lock( surface, test_lock, &data, &pitch );
               if (ret)
                    DirectFBError( "IDirectFBSurface::Lock() failed", ret );
               else
                    fprintf( stderr, "  => OK\n\n" );

               surface->Release( surface );
          }
     }

     /* Release the display layer. */
     layer->Release( layer );

     /* Release the super interface. */
     dfb->Release( dfb );

     return EXIT_SUCCESS;
}
int menu_hardware_select_comms_port::run(OUT int * selection_index)
{
  string menu_str;
  int rc;
  char tmp_buff[MAX_PATH_LENGTH];
  char exit_dialog;
  int number_of_items;

  //help text box
  text_box tb;

  link_def_t * link_def;
  wandev_conf_t *linkconf;

  Debug(DBG_MENU_HARDWARE_SELECT_COMMS_PORT, ("menu_net_interface_setup::run()\n"));

again:
  number_of_items = 2;

  link_def = cfr->link_defs;
  linkconf = cfr->link_defs->linkconf;

  Debug(DBG_MENU_HARDWARE_SELECT_COMMS_PORT, ("cfr->link_defs->name: %s\n", link_def->name));

  rc = YES;
  exit_dialog = NO;
  menu_str = " ";

  Debug(DBG_MENU_HARDWARE_SELECT_COMMS_PORT, ("linkconf->card_type: DEC:%d, HEX: 0x%X\n",
    linkconf->card_type, linkconf->card_type));

  /////////////////////////////////////////////////
  snprintf(tmp_buff, MAX_PATH_LENGTH, " \"%d\" ", WANOPT_PRIMARY);
  menu_str += tmp_buff;
  snprintf(tmp_buff, MAX_PATH_LENGTH, " \"Primary\" ");
  menu_str += tmp_buff;

  /////////////////////////////////////////////////
  snprintf(tmp_buff, MAX_PATH_LENGTH, " \"%d\" ", WANOPT_SECONDARY);
  menu_str += tmp_buff;
  snprintf(tmp_buff, MAX_PATH_LENGTH, " \"Secondary\" ");
  menu_str += tmp_buff;

  //////////////////////////////////////////////////////////////////////////////////////
  //create the explanation text for the menu
  snprintf(tmp_buff, MAX_PATH_LENGTH,
"\n------------------------------------------\
\nSelect Communications Port for Wan Device: %s", link_def->name);

  if(set_configuration(   YES,//indicates to call V2 of the function
                          MENU_BOX_BACK,//MENU_BOX_SELECT,
                          lxdialog_path,
                          "SELECT COMMUNICATIONS PORT",
                          WANCFG_PROGRAM_NAME,
                          tmp_buff,
                          MENU_HEIGTH, MENU_WIDTH,
                          number_of_items,
                          (char*)menu_str.c_str()
                          ) == NO){
    rc = NO;
    goto cleanup;
  }

  if(show(selection_index) == NO){
    rc = NO;
    goto cleanup;
  }
  //////////////////////////////////////////////////////////////////////////////////////

  exit_dialog = NO;
  switch(*selection_index)
  {
  case MENU_BOX_BUTTON_SELECT:
    Debug(DBG_MENU_HARDWARE_SELECT_COMMS_PORT,
      ("hardware_setup: option selected for editing: %s\n", get_lxdialog_output_string()));

    Debug(DBG_MENU_HARDWARE_SELECT_COMMS_PORT,
      ("comms_port: atoi(get_lxdialog_output_string(): %d\n", atoi(get_lxdialog_output_string())));

    switch(atoi(get_lxdialog_output_string()))
    {
    case WANOPT_SECONDARY:
      //V2 - all protocols in the LIP layer. all runs on both ports
      /*
      if(is_protocol_valid_for_card_type(
                          link_def->linkconf->config_id,
                          linkconf->card_type,
                          link_def->card_version,
                          1) == NO){
        tb.show_error_message(lxdialog_path, NO_PROTOCOL_NEEDED,
"Currently selected protocol (%s)\n\
is invalid for Secondary Port.",
          get_protocol_string(link_def->linkconf->config_id));
        goto again;
      }

      linkconf->comm_port = 1;
      exit_dialog = YES;
      break;
      */
    case WANOPT_PRIMARY:
      linkconf->comm_port = 0;
      exit_dialog = YES;
      break;

    default:
      ERR_DBG_OUT(("Invalid option selected for editing!! selection: %s\n",
        get_lxdialog_output_string()));
      rc = NO;
      exit_dialog = YES;
    }
    break;

  case MENU_BOX_BUTTON_HELP:

    switch(atoi(get_lxdialog_output_string()))
    {
    case WANOPT_SECONDARY:
    case WANOPT_PRIMARY:
      tb.show_help_message(lxdialog_path, NO_PROTOCOL_NEEDED, "Please select Communications port");
      break;

    default:
      ERR_DBG_OUT(("Invalid option selected for editing!! selection: %s\n",
        get_lxdialog_output_string()));
      rc = NO;
      exit_dialog = YES;
    }
    break;

  case MENU_BOX_BUTTON_EXIT:
    exit_dialog = YES;
    break;
  }//switch(*selection_index)


  if(exit_dialog == NO){
    goto again;
  }

cleanup:
  return rc;
}
EAP_FUNC_EXPORT eap_status_e eap_plugin_server_message_if_c::process_message(eap_process_tlv_message_data_c * const message)
{
	// Parses message data composed of Attribute-Value Pairs.

	EAP_TRACE_DATA_DEBUG(
		m_am_tools,
		EAP_TRACE_FLAGS_NEVER,
		(EAPL("eap_plugin_server_message_if_c::process_message()"),
		message->get_message_data(),
		message->get_message_data_length()));

	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, TRACE_FLAGS_DEFAULT, "returns: eap_plugin_server_message_if_c::process_message()");

	eap_array_c<eap_tlv_header_c> parameters(m_am_tools);

	eap_status_e status = message->parse_message_data(&parameters);
	if (status != eap_status_ok)
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);

		(void) send_error_message(
			status,
			eap_tlv_message_type_function_none);

		return EAP_STATUS_RETURN(m_am_tools, status);
	}

	if (parameters.get_object_count() == 0)
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);

		status = eap_status_illegal_parameter;

		(void) send_error_message(
			status,
			eap_tlv_message_type_function_none);

		return EAP_STATUS_RETURN(m_am_tools, status);
	}

	const eap_tlv_header_c * const function_header = parameters.get_object(eap_message_payload_index_function);
	if (function_header == 0
		|| (function_header->get_type() != eap_tlv_message_type_error
			&& function_header->get_type() != eap_tlv_message_type_function))
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);

		status = eap_status_illegal_parameter;

		(void) send_error_message(
			status,
			eap_tlv_message_type_function_none);

		return EAP_STATUS_RETURN(m_am_tools, status);
	}

	if (function_header->get_type() == eap_tlv_message_type_error)
	{
		status = process_message_type_error(&parameters);
	}
	else // function_header->get_type() == eap_tlv_message_type_function
	{
		eap_tlv_message_type_function_e function(eap_tlv_message_type_function_none);

		status = message->get_parameter_data(function_header, &function);
		if (status != eap_status_ok)
		{
			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);

			(void) send_error_message(
				status,
				eap_tlv_message_type_function_none);

			return EAP_STATUS_RETURN(m_am_tools, status);
		}

		EAP_TRACE_DEBUG(
			m_am_tools, 
			TRACE_FLAGS_DEFAULT, 
			(EAPL("eap_plugin_server_message_if_c::process_message(): this = 0x%08x, message=%d=%s\n"),
			this,
			function,
			eap_process_tlv_message_data_c::get_function_string(function)));

		switch(function)
		{
		case eap_tlv_message_type_function_plugin_get_configuration:
			status = get_configuration(&parameters);
			break;
		case eap_tlv_message_type_function_plugin_set_configuration:
			status = set_configuration(&parameters);
			break;
		case eap_tlv_message_type_function_plugin_copy_configuration:
			status = copy_configuration(&parameters);
			break;
		case eap_tlv_message_type_function_plugin_delete_configuration:
			status = delete_configuration(&parameters);
			break;
		case eap_tlv_message_type_function_plugin_set_index:
			status = set_index(&parameters);
			break;
		case eap_tlv_message_type_function_plugin_get_type_info:
			status = get_type_info(&parameters);
			break;
		case eap_tlv_message_type_function_plugin_invoke_ui:
			status = invoke_ui(&parameters);
			break;
		default:
			EAP_TRACE_ERROR(
				m_am_tools,
				TRACE_FLAGS_DEFAULT,
				(EAPL("ERROR: process_data(): unknown function %d.\n"),
				 function));

			status = eap_status_illegal_parameter;

			EAP_ASSERT_ANYWAY_TOOLS(m_am_tools);
		};

		if (status != eap_status_ok
			&& status != eap_status_success
			&& status != eap_status_pending_request
			&& status != eap_status_completed_request
			&& status != eap_status_drop_packet_quietly)
		{
			(void) send_error_message(
				status,
				function);
		}
	}

	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
	return EAP_STATUS_RETURN(m_am_tools, status);
}
Пример #21
0
int
main( int argc, char *argv[] )
{
     DFBResult ret;

     /* Initialize DirectFB including command line parsing. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          DirectFBError( "DirectFBInit() failed", ret );
          return -1;
     }

     /* Parse the command line. */
     if (!parse_command_line( argc, argv ))
          return -2;

     /* Create the super interface. */
     ret = DirectFBCreate( &dfb );
     if (ret) {
          DirectFBError( "DirectFBCreate() failed", ret );
          return -3;
     }

     /* Get the primary display layer. */
     ret = dfb->GetDisplayLayer( dfb, id, &layer );
     if (ret) {
          if (ret == DFB_IDNOTFOUND)
               fprintf (stderr, "\nUnknown layer id, check 'dfbinfo' for valid values.\n\n");
          else
               DirectFBError( "IDirectFB::GetDisplayLayer() failed", ret );
          dfb->Release( dfb );
          return -4;
     }

     /* Get a description of the layer. */
     ret = layer->GetDescription( layer, &desc );
     if (ret) {
          DirectFBError( "IDirectFBDisplayLayer::GetDescription() failed", ret );
          layer->Release( layer );
          dfb->Release( dfb );
          return -5;
     }

     /* Acquire administrative cooperative level. */
     ret = layer->SetCooperativeLevel( layer, DLSCL_ADMINISTRATIVE );
     if (ret) {
          DirectFBError( "IDirectFBDisplayLayer::SetCooperativeLevel() failed", ret );
          layer->Release( layer );
          dfb->Release( dfb );
          return -6;
     }

     /* Show/change the configuration. */
     set_configuration();

     /* Release the display layer. */
     layer->Release( layer );

     /* Release the super interface. */
     dfb->Release( dfb );

     return EXIT_SUCCESS;
}
Пример #22
0
void avdtp_dump(int level, struct frame *frm)
{
	uint8_t hdr, sid, nsp, type;
	uint16_t seqn;
	uint32_t time, ssrc;

	switch (frm->num) {
	case 1:
		p_indent(level, frm);
		hdr = get_u8(frm);

		nsp = (hdr & 0x0c) == 0x04 ? get_u8(frm) : 0;
		sid = hdr & 0x08 ? 0x00 : get_u8(frm);

		printf("AVDTP(s): %s %s: transaction %d nsp 0x%02x\n",
			hdr & 0x08 ? pt2str(hdr) : si2str(sid),
			mt2str(hdr), hdr >> 4, nsp);

		switch (sid & 0x7f) {
		case 0x01:
			discover(level + 1, hdr, frm);
			break;
		case 0x02:
		case 0x0c:
			get_capabilities(level + 1, hdr, frm);
			break;
		case 0x03:
			set_configuration(level + 1, hdr, frm);
			break;
		case 0x04:
			get_configuration(level + 1, hdr, frm);
			break;
		case 0x05:
			reconfigure(level + 1, hdr, frm);
			break;
		case 0x06:
			open_close_stream(level + 1, hdr, frm);
			break;
		case 0x07:
			start_suspend_stream(level + 1, hdr, frm);
			break;
		case 0x08:
			open_close_stream(level + 1, hdr, frm);
			break;
		case 0x09:
			start_suspend_stream(level + 1, hdr, frm);
			break;
		case 0x0a:
			abort_streaming(level + 1, hdr, frm);
			break;
		case 0x0b:
			security(level + 1, hdr, frm);
			break;
		case 0x0d:
			delay_report(level + 1, hdr, frm);
			break;
		}

		break;

	case 2:
		p_indent(level, frm);
		hdr  = get_u8(frm);
		type = get_u8(frm);
		seqn = get_u16(frm);
		time = get_u32(frm);
		ssrc = get_u32(frm);

		printf("AVDTP(m): ver %d %s%scc %d %spt %d seqn %d time %d ssrc %d\n",
			hdr >> 6, hdr & 0x20 ? "pad " : "", hdr & 0x10 ? "ext " : "",
			hdr & 0xf, type & 0x80 ? "mark " : "", type & 0x7f, seqn, time, ssrc);
		break;
	}

	raw_dump(level, frm);
}
int menu_aft_logical_channels_list::run(OUT int * selection_index)
{
  string menu_str;
  int rc;
  char tmp_buff[MAX_PATH_LENGTH];
  char exit_dialog;
  unsigned int new_number_of_groups_of_channels;
  int num_of_visible_items;
  list_element_chan_def* list_el_chan_def = NULL;
  sdla_fe_cfg_t* fe_cfg = &cfr->link_defs->linkconf->fe_cfg;

  //help text box
  text_box tb;

  objects_list * obj_list = cfr->main_obj_list;

  Debug(DBG_MENU_AFT_LOGICAL_CHANNELS_LIST, ("menu_new_device_configuration::run()\n"));

again:
  rc = YES;
  exit_dialog = NO;
  menu_str = " ";

  //adjust number of items in the menu depending on number of dlcis
  num_of_visible_items = cfr->main_obj_list->get_size() + 2;
  //8 items looks best
  if(num_of_visible_items > 8){
    num_of_visible_items = 8;
  }

  //////////////////////////////////////////////////////////////////////////////////////
  snprintf(tmp_buff, MAX_PATH_LENGTH, " \"%d\" ", NUMBER_OF_LOGICAL_CHANNELS);
  menu_str += tmp_buff;
  snprintf(tmp_buff, MAX_PATH_LENGTH, " \"Number of %s------> %d\" ",
    TIME_SLOT_GROUPS_STR,
    cfr->main_obj_list->get_size());
  menu_str += tmp_buff;

  //////////////////////////////////////////////////////////////////////////////////////
  snprintf(tmp_buff, MAX_PATH_LENGTH, " \"%d\" ", EMPTY_LINE);
  menu_str += tmp_buff;
  snprintf(tmp_buff, MAX_PATH_LENGTH, " \" \" ");
  menu_str += tmp_buff;

  //////////////////////////////////////////////////////////////////////////////////////
  if(create_logical_channels_list_str(menu_str) == NO){
    return NO;
  }

  //////////////////////////////////////////////////////////////////////////////////////
  //create the explanation text for the menu
  snprintf(tmp_buff, MAX_PATH_LENGTH,
"\n------------------------------------------\
\n%s configuration for Wan Device: %s",TIME_SLOT_GROUPS_STR, cfr->link_defs->name);

  if(set_configuration(   YES,//indicates to call V2 of the function
                          MENU_BOX_BACK,//MENU_BOX_SELECT,
                          lxdialog_path,
                          "AFT SETUP",
                          WANCFG_PROGRAM_NAME,
                          tmp_buff,
                          MENU_HEIGTH, MENU_WIDTH,
                          num_of_visible_items,
                          (char*)menu_str.c_str()
                          ) == NO){
    rc = NO;
    goto cleanup;
  }

  if(show(selection_index) == NO){
    rc = NO;
    goto cleanup;
  }

  //////////////////////////////////////////////////////////////////////////////////////

  exit_dialog = NO;
  switch(*selection_index)
  {
  case MENU_BOX_BUTTON_SELECT:
    Debug(DBG_MENU_AFT_LOGICAL_CHANNELS_LIST,
      ("option selected for editing: %s\n", get_lxdialog_output_string()));

    switch(atoi(get_lxdialog_output_string()))
    {
    case EMPTY_LINE:
      goto again;
      
    case NUMBER_OF_LOGICAL_CHANNELS:
      {
        input_box_number_of_logical_channels
          number_of_logical_channels( (int*)&new_number_of_groups_of_channels,
                                      fe_cfg->media);

        //convert int to string
        if(obj_list->get_size() == 0){
          //suggest 1 logical channel
          snprintf(tmp_buff, MAX_PATH_LENGTH, "%d", 1);
        }else{
          snprintf(tmp_buff, MAX_PATH_LENGTH, "%d", obj_list->get_size());
        }

        if(number_of_logical_channels.show( lxdialog_path,
                                            WANCONFIG_AFT,
                                            tmp_buff,//IN char * initial_text,
                                            selection_index) == NO){
          rc = NO;
          goto cleanup;
        }

        if(new_number_of_groups_of_channels != obj_list->get_size()){
		
          Debug(DBG_MENU_AFT_LOGICAL_CHANNELS_LIST,
            ("new_number_of_groups_of_channels: %d, old number: %d\n",
            new_number_of_groups_of_channels,
            obj_list->get_size()
            ));

          adjust_number_of_groups_of_channels(obj_list, new_number_of_groups_of_channels);
        }
        goto again;
      }
      break;

    default:
      //one of the Timeslot Groups was selected for configuration
      Debug(DBG_MENU_AFT_LOGICAL_CHANNELS_LIST, ("default case selection: %d\n", *selection_index));

      list_el_chan_def = (list_element_chan_def*)
                            obj_list->find_element(
                              remove_spaces_in_int_string(get_lxdialog_output_string()));

      if(list_el_chan_def != NULL){

	menu_aft_logical_channel_cfg per_aft_logical_channel_cfg( lxdialog_path,
                                                                  cfr,
                                                                  list_el_chan_def);
        //list_el_chan_def = NULL;
        //do NOT use list_el_chan_def on return - it may be invalid!
        rc = per_aft_logical_channel_cfg.run(cfr->wanpipe_number, selection_index,
                                            obj_list->get_size());
        if(rc == YES){
          goto again;
        }
	
      }else{
        //failed to find the element
        ERR_DBG_OUT(("Failed to find the element!! selection: %s\n",
          get_lxdialog_output_string()));
        rc = NO;
        exit_dialog = YES;
      }
    }
    break;

  case MENU_BOX_BUTTON_HELP:
    switch(atoi(get_lxdialog_output_string()))
    {
    case NUMBER_OF_LOGICAL_CHANNELS:
      tb.show_help_message(lxdialog_path, NO_PROTOCOL_NEEDED, number_of_timeslot_groups);
      break;

    default:
      tb.show_help_message( lxdialog_path, NO_PROTOCOL_NEEDED,
                            per_group_configuration_options_help_str);
      break;
    }
    break;

  case MENU_BOX_BUTTON_BACK:
    
    if(check_bound_channels_not_overlapping() == NO){
      exit_dialog = NO;
      break;
    }

    exit_dialog = YES;
    break;
  }//switch(*selection_index)

  if(exit_dialog == NO){
    goto again;
  }
cleanup:
  return rc;
}
Пример #24
0
// Called for every found device - see if a driver is available for
// this device and do setup if so.
static int
configure_usb_device(struct usbdevice_s *usbdev)
{
    ASSERT32FLAT();
    dprintf(3, "config_usb: %p\n", usbdev->defpipe);

    // Set the max packet size for endpoint 0 of this device.
    struct usb_device_descriptor dinfo;
    int ret = get_device_info8(usbdev->defpipe, &dinfo);
    if (ret)
        return 0;
    u16 maxpacket = dinfo.bMaxPacketSize0;
    if (dinfo.bcdUSB >= 0x0300)
        maxpacket = 1 << dinfo.bMaxPacketSize0;
    dprintf(3, "device rev=%04x cls=%02x sub=%02x proto=%02x size=%d\n"
            , dinfo.bcdUSB, dinfo.bDeviceClass, dinfo.bDeviceSubClass
            , dinfo.bDeviceProtocol, maxpacket);
    if (maxpacket < 8)
        return 0;
    struct usb_endpoint_descriptor epdesc = {
        .wMaxPacketSize = maxpacket,
        .bmAttributes = USB_ENDPOINT_XFER_CONTROL,
    };
    usbdev->defpipe = usb_realloc_pipe(usbdev, usbdev->defpipe, &epdesc);
    if (!usbdev->defpipe)
        return -1;

    // Get configuration
    struct usb_config_descriptor *config = get_device_config(usbdev->defpipe);
    if (!config)
        return 0;

    // Determine if a driver exists for this device - only look at the
    // first interface of the first configuration.
    struct usb_interface_descriptor *iface = (void*)(&config[1]);
    if (iface->bInterfaceClass != USB_CLASS_HID
            && iface->bInterfaceClass != USB_CLASS_MASS_STORAGE
            && iface->bInterfaceClass != USB_CLASS_HUB)
        // Not a supported device.
        goto fail;

    // Set the configuration.
    ret = set_configuration(usbdev->defpipe, config->bConfigurationValue);
    if (ret)
        goto fail;

    // Configure driver.
    usbdev->config = config;
    usbdev->iface = iface;
    usbdev->imax = (void*)config + config->wTotalLength - (void*)iface;
    if (iface->bInterfaceClass == USB_CLASS_HUB)
        ret = usb_hub_setup(usbdev);
    else if (iface->bInterfaceClass == USB_CLASS_MASS_STORAGE) {
        if (iface->bInterfaceProtocol == US_PR_BULK)
            ret = usb_msc_setup(usbdev);
        if (iface->bInterfaceProtocol == US_PR_UAS)
            ret = usb_uas_setup(usbdev);
    } else
        ret = usb_hid_setup(usbdev);
    if (ret)
        goto fail;

    free(config);
    return 1;
fail:
    free(config);
    return 0;
}
Пример #25
0
status_t
set_configuration_v2(const void *device,
	const usb_configuration_info *configuration)
{
	return set_configuration((usb_id)(ssize_t)device, configuration);
}
/**
 * Submit a LinuxRequest.
 * @param env The JNIEnv.
 * @param fd The file descriptor.
 * @param linuxRequest The LinuxRequest.
 */
static void submitRequest( JNIEnv *env, int fd, jobject linuxRequest )
{
	int type, err, sync = 0;

	jclass LinuxRequest;
	jmethodID getType, setError, setCompleted;

	LinuxRequest = (*env)->GetObjectClass( env, linuxRequest );
	getType = (*env)->GetMethodID( env, LinuxRequest, "getType", "()I" );
	setCompleted = (*env)->GetMethodID( env, LinuxRequest, "setCompleted", "(Z)V" );
	setError = (*env)->GetMethodID( env, LinuxRequest, "setError", "(I)V" );
	(*env)->DeleteLocalRef( env, LinuxRequest );

	type = (*env)->CallIntMethod( env, linuxRequest, getType );

	dbg(MSG_DEBUG1, "submitRequest : Submitting Request.\n");

	switch (type) {
	case LINUX_PIPE_REQUEST:
		dbg(MSG_DEBUG1, "submitRequest : Submitting Pipe Request.\n");
		err = pipe_request( env, fd, linuxRequest );
		break;
	case LINUX_DCP_REQUEST:
		dbg(MSG_DEBUG1, "submitRequest : Submitting Dcp Request.\n");
		err = dcp_request( env, fd, linuxRequest );
		break;
	case LINUX_SET_INTERFACE_REQUEST:
		dbg(MSG_DEBUG1, "submitRequest : Submitting SetInterface Request.\n");
		err = set_interface( env, fd, linuxRequest );
		sync = 1;
		break;
	case LINUX_SET_CONFIGURATION_REQUEST:
		dbg(MSG_DEBUG1, "submitRequest : Submitting SetConfiguration Request.\n");
		err = set_configuration( env, fd, linuxRequest );
		sync = 1;
		break;
	case LINUX_CLAIM_INTERFACE_REQUEST:
		dbg(MSG_DEBUG1, "submitRequest : Submitting ClaimInterface Request.\n");
		err = claim_interface( env, fd, 1, linuxRequest );
		sync = 1;
		break;
	case LINUX_RELEASE_INTERFACE_REQUEST:
		dbg(MSG_DEBUG1, "submitRequest : Submitting ReleaseInterface Request.\n");
		err = claim_interface( env, fd, 0, linuxRequest );
		sync = 1;
		break;
	case LINUX_IS_CLAIMED_INTERFACE_REQUEST:
		dbg(MSG_DEBUG1, "submitRequest : Submitting IsClaimed Request.\n");
		err = is_claimed( env, fd, linuxRequest );
		sync = 1;
		break;
	case LINUX_ISOCHRONOUS_REQUEST:
		dbg(MSG_DEBUG1, "submitRequest : Submitting Isochronous Request.\n");
		err = isochronous_request( env, fd, linuxRequest );
		break;
	default: /* ? */
		dbg( MSG_ERROR, "submitRequest : Unknown Request type %d\n", type );
		err = -EINVAL;
		break;
	}

	if (err)
		(*env)->CallVoidMethod( env, linuxRequest, setError, err );

	if (sync || err)
		(*env)->CallVoidMethod( env, linuxRequest, setCompleted, JNI_TRUE );
}
Пример #27
0
 ConfigurableFunctor()
 {
   T::set_configuration(fmap);
   set_configuration("");
 }