예제 #1
0
void cmd_exec(void)
{
	switch(usb_in_buffer[0])
	{
		case CMD_CAL:
			cmd_cali();
			break;

		case CMD_MOV:
			cmd_move();
			break;

		case CMD_TST:
			cmd_test();
			break;

		case CMD_HLT:
			cmd_halt();
			break;

		case CMD_QRY:
			cmd_query();
			usb_send();
			break;

		default:
			break;
	}
}
예제 #2
0
bool ConCommandTester::RT_TestPlayerCommand_Anon ( PlayerHandler::iterator ph, const basic_string& command )
{
	if( IsActive () )
	{
		// To lower
		basic_string lower_cmd ( command );
		//if( basic_string::IsValidMultibyteString ( lower_cmd ) )
		//{
			lower_cmd.lower ();

			size_t id ( 0 );
			size_t const max ( m_commands_list.Size () );
			for( CommandInfoT* cmd_test ( &m_commands_list[ id ] ); id != max; cmd_test = &m_commands_list[ ++id ] )
			{
				for( size_t x ( 0 ); x < lower_cmd.size (); ++x )
				{
					if( StriCmpOffset ( lower_cmd.c_str (), cmd_test->command_name.c_str (), x ) )
					{
						// Ignored cmds are always at the end of the set
						if( cmd_test->ignore ) return false;

						//RT_AddPlayerCommand ( ph, command );
						//Detection_CmdViolation pDetection;
						//pDetection.PrepareDetectionData ( GetPlayerDataStructByIndex ( ph.GetIndex () ) );
						//pDetection.PrepareDetectionLog ( *ph, this );
						//pDetection.Log ();

						//if( cmd_test->ban ) ph->Ban ( "ConCommand exploit" );
						//else ph->Kick ( "ConCommand exploit" );
						return true;
					}
				}
			}
			//RT_AddPlayerCommand ( ph, command );
		//}
		//else
		//{
			//g_Logger.Msg<MSG_LOG> ( Helpers::format ( "Dropped invalid command from %s", ph->GetName () ) );
			//ph->Kick ( "Invalid ConCommand" );
		//	return true;
		//}
	}
	return false;
}
예제 #3
0
/********************************************************************
 *	モニタコマンド受信と実行.
 ********************************************************************
 */
void ProcessIO(void)
{
	// 返答パケットが空であること、かつ、
	// 処理対象の受信データがある.
	{
		//受信データがあれば、受信データを受け取る.
		PacketToPC.raw[0]=Cmd0;		// CMD ECHOBACK
#if	0
		//コマンドに対応する処理を呼び出す.
			 if(Cmd0 >= HIDASP_PAGE_TX)  {cmd_avrspx();}	// AVRライターコマンド.
		else if(Cmd0 >= PICSPX_SETADRS24){cmd_picspx();}	// PICライターコマンド.
		else 
#endif
		switch(Cmd0) {
		 case HIDASP_PEEK: 		{cmd_peek();break;}	// メモリー読み出し.
		 case HIDASP_POKE: 		{cmd_poke();break;}	// メモリー書き込み.
		 case HIDASP_JMP: 		{cmd_exec(PacketFromPC.adrs,PacketFromPC.size);break;}	// 実行.
		 case HIDASP_PAGE_ERASE:{cmd_page_erase();break;}	//Flash消去.
		 case HIDASP_PAGE_WRITE:{cmd_page_write();break;}	//Flash書込.
		 case HIDASP_FLASH_LOCK:{cmd_flash_lock();break;}	//FlashLock.
		 case HIDASP_SET_MODE:  {cmd_set_mode();break;}
		 case HIDASP_BOOT_RWW: 	{cmd_test();break;}			// 接続テスト.
		 case HIDASP_TEST: 		{cmd_echo();break;}			// 接続テスト.

#if	APPLICATION_MODE
//		 case HIDASP_GET_STRING:{cmd_get_string();break;}
		 case HIDASP_USER_CMD:  {cmd_user_cmd();break;}
#endif
		 default: break;
		}
	}

	// 必要なら、返答パケットをインタラプト転送(EP1)でホストPCに返却する.
	if( ToPcRdy ) {
		USBputpacket(PacketToPC.raw,PACKET_SIZE);
		ToPcRdy = 0;

		if(poll_mode!=0) {
			if(mHIDRxIsBusy()) {	//コマンドが来ない限り送り続ける.
				make_report();
			}
		}
	}
}
예제 #4
0
int
main (int argc, char *argv[])
{
    int result;

    char *config = NULL;

    int ch;
    progname = argv[0];

    while ((ch = getopt(argc, argv, "c:vVh")) != -1) {
        switch (ch) {
        case 'c':
            config = strdup(optarg);
            break;
        case 'v':
            verbose++;
            break;
        case 'V':
            version();
            exit(0);
            break;
        case 'h':
            usage();
            exit(0);
            break;
        default:
            usage();
            exit(1);
        }
    }
    argc -= optind;
    argv += optind;

    if (!argc) {
        usage();
        exit(1);
    }


    if (!strcasecmp(argv[0], "logout")) {
        if (config) free(config);
        exit(cmd_logout());
    }

    result = hsm_open(config, hsm_prompt_pin);
    if (result) {
        hsm_print_error(NULL);
        exit(-1);
    }

    openlog("hsmutil", LOG_PID, LOG_USER);

    if (!strcasecmp(argv[0], "login")) {
        argc --;
        argv ++;
        result = cmd_login();
    } else if (!strcasecmp(argv[0], "list")) {
        argc --;
        argv ++;
        result = cmd_list(argc, argv);
    } else if (!strcasecmp(argv[0], "generate")) {
        argc --;
        argv ++;
        result = cmd_generate(argc, argv);
    } else if (!strcasecmp(argv[0], "remove")) {
        argc --;
        argv ++;
        result = cmd_remove(argc, argv);
    } else if (!strcasecmp(argv[0], "purge")) {
        argc --;
        argv ++;
        result = cmd_purge(argc, argv);
    } else if (!strcasecmp(argv[0], "dnskey")) {
        argc --;
        argv ++;
        result = cmd_dnskey(argc, argv);
    } else if (!strcasecmp(argv[0], "test")) {
        argc --;
        argv ++;
        result = cmd_test(argc, argv);
    } else if (!strcasecmp(argv[0], "info")) {
        argc --;
        argv ++;
        result = cmd_info();
    } else if (!strcasecmp(argv[0], "debug")) {
        argc --;
        argv ++;
        result = cmd_debug();
    } else {
        usage();
        result = -1;
    }

    (void) hsm_close();
    if (config) free(config);

    closelog();

    exit(result);
}