Beispiel #1
0
BOOL CIPFindDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
	InitAdapter();
#if defined(_DEBUG)
	SetDlgItemText(IDC_EDIT_MAC, _T("08:20:3e:9a:5f:17"));
#endif

	InitListCtrl();
	GetDlgItem(IDC_BUTTON_START)->EnableWindow(true);

	return TRUE;  // return TRUE  unless you set the focus to a control
}
Beispiel #2
0
static int 
usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
	int retval =0 ;	
   	PMINI_ADAPTER psAdapter = NULL;
	PS_INTERFACE_ADAPTER psIntfAdapter = NULL;
	struct usb_device      *udev = NULL;

//	BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Usbbcm probe!!");
	if((intf == NULL) || (id == NULL))
	{
	//	BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "intf or id is NULL");
		return -EINVAL;
	}

	/* Allocate Adapter structure */
	if((psAdapter = kmalloc(sizeof(MINI_ADAPTER), GFP_KERNEL)) == NULL)
	{
		//BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory");
		return -ENOMEM;
	}
	
	memset(psAdapter, 0, sizeof(MINI_ADAPTER));

    /* Init default driver debug state */

    psAdapter->stDebugState.debug_level = DBG_LVL_CURR;
	psAdapter->stDebugState.type = DBG_TYPE_INITEXIT;
	memset (psAdapter->stDebugState.subtype, 0, sizeof (psAdapter->stDebugState.subtype));

    /* Technically, one can start using BCM_DEBUG_PRINT after this point.
	 * However, realize that by default the Type/Subtype bitmaps are all zero now;
	 * so no prints will actually appear until the TestApp turns on debug paths via 
	 * the ioctl(); so practically speaking, in early init, no logging happens.
	 *
	 * A solution (used below): we explicitly set the bitmaps to 1 for Type=DBG_TYPE_INITEXIT
	 * and ALL subtype's of the same. Now all bcm debug statements get logged, enabling debug
	 * during early init.
	 * Further, we turn this OFF once init_module() completes.
	 */

    psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xff;
	BCM_SHOW_DEBUG_BITMAP(psAdapter);

	retval = InitAdapter(psAdapter);
	if(retval)
	{
		BCM_DEBUG_PRINT (psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InitAdapter Failed\n");
		AdapterFree(psAdapter);
		return retval;
	}

	/* Allocate interface adapter structure */
	if((psAdapter->pvInterfaceAdapter = 
		kmalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL)) == NULL)
	{
		BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory");
		AdapterFree (psAdapter);
		return -ENOMEM;
	}
	memset(psAdapter->pvInterfaceAdapter, 0, sizeof(S_INTERFACE_ADAPTER));

	psIntfAdapter = InterfaceAdapterGet(psAdapter);
	psIntfAdapter->psAdapter = psAdapter;
	
	/* Store usb interface in Interface Adapter */
	psIntfAdapter->interface = intf;
	usb_set_intfdata(intf, psIntfAdapter);

	BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "psIntfAdapter 0x%x",(unsigned int)psIntfAdapter);
	retval = InterfaceAdapterInit(psIntfAdapter);
	if(retval)
	{	
		/* If the Firmware/Cfg File is not present
 		 * then return success, let the application
 		 * download the files. 
 		 */
		if(-ENOENT == retval){
			BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "File Not Found, Use App to Download\n");
			return STATUS_SUCCESS;
		}
		BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapterInit Failed \n");
		usb_set_intfdata(intf, NULL);	
		udev = interface_to_usbdev (intf);
		usb_put_dev(udev);
		if(psAdapter->bUsbClassDriverRegistered == TRUE)
				usb_deregister_dev (intf, &usbbcm_class);
		InterfaceAdapterFree(psIntfAdapter);
		return retval ;
	}
	if(psAdapter->chip_id > T3)
	{
		uint32_t uiNackZeroLengthInt=4;
		if(wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, &uiNackZeroLengthInt, sizeof(uiNackZeroLengthInt)))
		{
			return -EIO;;
		}
	}

	udev = interface_to_usbdev (intf);
	/* Check whether the USB-Device Supports remote Wake-Up */
	if(USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes) 
	{
		/* If Suspend then only support dynamic suspend */
		if(psAdapter->bDoSuspend) 
		{
			udev->autosuspend_delay = 0;
			intf->needs_remote_wakeup = 1;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
			udev->autosuspend_disabled = 0;
#else
			usb_enable_autosuspend(udev);
#endif
			device_init_wakeup(&intf->dev,1);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
			usb_autopm_disable(intf);
#endif
			INIT_WORK(&psIntfAdapter->usbSuspendWork, putUsbSuspend);
			BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Enabling USB Auto-Suspend\n");
		}
		else
		{ 
			intf->needs_remote_wakeup = 0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
			udev->autosuspend_disabled = 1;
#else
			usb_disable_autosuspend(udev);
#endif
		}
	}

    psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0x0;
    return retval;
}
Beispiel #3
0
int runHybridABETest(Charm_t *pGroup)
{
	Charm_t *pABEClass = NULL, *pClass = NULL;

    pABEClass = InitScheme("charm.schemes.abenc.abenc_bsw07", "CPabe_BSW07", pGroup);
    if(pABEClass == NULL) return -1;

    debug("cpabe initialized.\n");

    pClass = InitAdapter("charm.adapters.abenc_adapt_hybrid", "HybridABEnc", pABEClass, pGroup);
    if(pClass == NULL) return -1;

    debug("hyb_abe initialized.\n");

    Charm_t *pKeys = CallMethod(pClass, "setup", "");
    debug("setup ok.\n");

	Charm_t *pkDict = GetIndex(pKeys, 0);
	Charm_t *mskDict = GetIndex(pKeys, 1);

	Charm_t *pValue = GetDict(pkDict, "g");
	Charm_t *pValue1 = GetDict(mskDict, "beta");

	char *attrList = "[ONE, TWO]";

	debug("calling keygen...\n");
	char *policy = "((THREE or ONE) and (THREE or TWO))";
	printf("attribute: '%s'\n", attrList);
	printf("enc policy: '%s'\n", policy);
	Charm_t *skDict = CallMethod(pClass, "keygen", "%O%O%A", pkDict, mskDict, attrList);

	Charm_t *pValue2 = objectToBytes(skDict, pGroup);
    debug("keygen ok.\n");

	//Charm_t *pValue2 = GetDict(skDict, "D");

	char *msg = "this is a test message.";
	Charm_t *ctDict = CallMethod(pClass, "encrypt", "%O%b%s", pkDict, msg, policy);
    debug("encrypt ok.\n");

	Charm_t *rec_msg = CallMethod(pClass, "decrypt", "%O%O%O", pkDict, skDict, ctDict);
    debug("decrypt ok.\n");

    printf("g => ");
	PrintObject(pValue);
	printf("beta => ");
	PrintObject(pValue1);
	printf("sk serialized => \n");
	PrintObject(pValue2);
	//	printf("ct :=> \n");
	//	PrintObject(pValue3);
	printf("original msg :=> '%s'\n", msg);
	//	PrintObject(msg);
	printf("rec msg :=> \n");
	PrintObject(rec_msg);

	Free(pValue);
	Free(pValue1);
	Free(pValue2);
//	Free(pValue3);
	Free(rec_msg);
	Free(skDict);
	Free(pkDict);
	Free(mskDict);
	Free(pKeys);
	Free(pClass);
    Free(pABEClass);
	return 0;
}