int mep_req_cancel(mep_req_handle hdl) { mep_req_cmd ossp_cmd; int offset = 0; MREQ* node = mep_req_search(hdl); void* tmp_data = NULL; if(!node){ fprintf(stderr, "%s %s %d mep_req search and Cancel failed.\n", __FILE__, __FUNCTION__, __LINE__); return M_REQ_NOK; }else{ node->ok2Send = 1; tmp_data = (void*)malloc(MREQ_HEAD_SZ); ossp_cmd = MREQ_CMD_CANCEL; memcpy(tmp_data, &ossp_cmd, MREQ_CMD_SZ); offset += MREQ_CMD_SZ; memcpy(tmp_data + offset, &hdl, MREQ_HDL_SZ); offset += MREQ_HDL_SZ; node->isCanceled = 44; } if(g_ep_hdl && node->ok2Send && tmp_data){ event_proxy_send_event(g_ep_hdl, tmp_data, MREQ_HEAD_SZ); //DumpHex(tmp_data, MREQ_HEAD_SZ+64); } mep_req_destory(hdl); if(tmp_data)free(tmp_data); return M_REQ_OK; }
static int smb_event_ep_send_event(void *event) { struct smbEventProxyCmd *pcmd = (struct smbEventProxyCmd *)event; if (smb_event_ep_obj == NULL ) { fprintf(stderr,"create device_object failed\n"); return -1; } #ifdef ENABLE_LOCK sem_wait(&SMBTREE_LOCK); #endif event_proxy_send_event(smb_event_ep_obj, event,sizeof(struct smbEventProxyCmd)); #ifdef ENABLE_LOCK sem_post(&SMBTREE_LOCK); #endif return -1; }
//int mep_req_send(mep_req_handle hdl, char* data, int data_len, mep_req_cb cb, void* usr_data){ int mep_req_send(mep_req_cmd ossp_cmd, mep_req_handle hdl, char* data, int data_len, mep_cpreq_cb cb, void* usr_data) { int offset = 0; MREQ* node = mep_req_search(hdl); void* tmp_data = NULL; if(!node){ fprintf(stderr, "%s %s %d mep_req send failed.\n", __FILE__, __FUNCTION__, __LINE__); return -1; //return M_REQ_NOK; }else{ node->data = malloc(data_len); if(node->data==NULL){ fprintf(stderr, "[%s:%s:%d] malloc failed\n", __FILE__, __FUNCTION__, __LINE__); return -1; } memcpy(node->data,data,data_len); node->data_len = data_len; node->cb = cb; node->usr_data = usr_data; node->ok2Send = 1; //WW: I insert a mep_req_handle into the packet to fifo_ep. it will be return when the OSSP reply. //And then I can check the handle of each node in the request queue to figure out which one this //response belongs to. tmp_data = (void*)malloc(data_len + MREQ_HEAD_SZ); memcpy(tmp_data, &ossp_cmd, MREQ_CMD_SZ); offset += MREQ_CMD_SZ; memcpy(tmp_data + offset, &hdl, MREQ_HDL_SZ); offset += MREQ_HDL_SZ; memcpy(tmp_data + offset, data, data_len); } if(g_ep_hdl && node->ok2Send && tmp_data){ event_proxy_send_event(g_ep_hdl, tmp_data, data_len+MREQ_HEAD_SZ); //fprintf(stderr, "%s %s %d data_len:%d.\n", __FILE__,__FUNCTION__,__LINE__, data_len); //DumpHex(tmp_data, data_len+MREQ_HEAD_SZ); } if(tmp_data)free(tmp_data); return hdl; }