void usb_test_hotplug(const char *hcd_id, const int port, void (*port_check)(void)) { QDict *response; char *cmd; cmd = g_strdup_printf("{'execute': 'device_add'," " 'arguments': {" " 'driver': 'usb-tablet'," " 'port': '%d'," " 'bus': '%s.0'," " 'id': 'usbdev%d'" "}}", port, hcd_id, port); response = qmp(cmd); g_free(cmd); g_assert(response); g_assert(!qdict_haskey(response, "error")); QDECREF(response); if (port_check) { port_check(); } cmd = g_strdup_printf("{'execute': 'device_del'," " 'arguments': {" " 'id': 'usbdev%d'" "}}", port); response = qmp(cmd); g_free(cmd); g_assert(response); g_assert(qdict_haskey(response, "event")); g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); }
static void hdl_nopen(void) { int8 type=0; uint8 DstIP[4], *dip = NULL; uint16 SrcPort, DstPort = 0; if(atci.tcmd.sign == CMD_SIGN_NONE) atci.tcmd.sign = CMD_SIGN_QUEST; if(atci.tcmd.sign == CMD_SIGN_QUEST) { CMD_CLEAR(); act_nopen_q(); } else if(atci.tcmd.sign == CMD_SIGN_INDIV) RESP_CR(RET_WRONG_SIGN); else if(atci.tcmd.sign == CMD_SIGN_EQUAL) { if(CMP_CHAR_3(atci.tcmd.arg1, 'S', 'C', 'U')) RESP_CDR(RET_WRONG_ARG, 1); if(port_check(atci.tcmd.arg2, &SrcPort) != RET_OK) RESP_CDR(RET_WRONG_ARG, 2); if(atci.tcmd.arg1[0] == 'C') { if(ip_check(atci.tcmd.arg3, DstIP) != RET_OK) RESP_CDR(RET_WRONG_ARG, 3); if(port_check(atci.tcmd.arg4, &DstPort) != RET_OK) RESP_CDR(RET_WRONG_ARG, 4); dip = DstIP; } else if(atci.tcmd.arg1[0] == 'U') { if(atci.tcmd.arg3[0] != 0 && atci.tcmd.arg4[0] != 0) { if(ip_check(atci.tcmd.arg3, DstIP) != RET_OK) RESP_CDR(RET_WRONG_ARG, 3); if(port_check(atci.tcmd.arg4, &DstPort) != RET_OK) RESP_CDR(RET_WRONG_ARG, 4); dip = DstIP; } else { CHK_ARG_LEN(atci.tcmd.arg3, 0, 3); CHK_ARG_LEN(atci.tcmd.arg4, 0, 4); } } else { // 'S' 무시정책이냐 아니면 전부 확인 정책이냐 CHK_ARG_LEN(atci.tcmd.arg3, 0, 3); CHK_ARG_LEN(atci.tcmd.arg4, 0, 4); } CHK_ARG_LEN(atci.tcmd.arg5, 0, 5); type = atci.tcmd.arg1[0]; CMD_CLEAR(); act_nopen_a(type, SrcPort, dip, DstPort); } else CRITICAL_ERRA("wrong sign(%d)", atci.tcmd.sign); }
int parameter_check(char *domain, char *type, char *proto, char *port, char *server_ip) { if (domain == NULL || type_check(type) == PARAMETER_ERROR || server_ip == NULL \ || proto_check(proto) == PARAMETER_ERROR || port_check(port) == PARAMETER_ERROR) { return PARAMETER_ERROR; } else { return PARAMETER_NO_ERROR; } }
static void hdl_nsend(void) { int8 num = -1; int32 ret; uint8 *dip = NULL; uint16 *dport = NULL; if(atci.tcmd.sign == CMD_SIGN_NONE) RESP_CR(RET_WRONG_SIGN); if(atci.tcmd.sign == CMD_SIGN_QUEST) RESP_CR(RET_WRONG_SIGN); else if(atci.tcmd.sign == CMD_SIGN_INDIV) RESP_CR(RET_WRONG_SIGN); else if(atci.tcmd.sign == CMD_SIGN_EQUAL) { if(atci.tcmd.arg1[0] != 0) { if(str_check(isdigit, atci.tcmd.arg1) != RET_OK) RESP_CDR(RET_WRONG_ARG, 1); if(CHK_DGT_RANGE(atci.tcmd.arg1, num, ATC_SOCK_NUM_START, ATC_SOCK_NUM_END)) RESP_CDR(RET_RANGE_OUT, 1); } if(str_check(isdigit, atci.tcmd.arg2) != RET_OK || (atci.sendlen = atoi((char*)atci.tcmd.arg2)) < 1 || atci.sendlen > WORK_BUF_SIZE) RESP_CDR(RET_RANGE_OUT, 2); if(atci.tcmd.arg3[0]) { if(ip_check(atci.tcmd.arg3, atci.sendip) == RET_OK) dip = atci.sendip; else RESP_CDR(RET_WRONG_ARG, 3); } if(atci.tcmd.arg4[0]) { if(port_check(atci.tcmd.arg4, &atci.sendport)==RET_OK) dport = &atci.sendport; else RESP_CDR(RET_WRONG_ARG, 4); } CHK_ARG_LEN(atci.tcmd.arg5, 0, 5); CHK_ARG_LEN(atci.tcmd.arg6, 0, 6); CMD_CLEAR(); ret = act_nsend_chk(num, &atci.sendlen, dip, dport); if(ret != RET_OK) return; atci.sendsock = num; // 유효성 검사가 완료되면 SEND모드로 전환 atci.worklen = 0; cmd_resp(RET_ASYNC, num); } else CRITICAL_ERRA("wrong sign(%d)", atci.tcmd.sign); }