void DialogShiftTimes::SaveHistory(json::Array const& shifted_blocks) { json::Object new_entry; new_entry["filename"] = context->subsController->Filename().filename().string(); new_entry["is by time"] = shift_by_time->GetValue(); new_entry["is backward"] = shift_backward->GetValue(); new_entry["amount"] = from_wx(shift_by_time->GetValue() ? shift_time->GetValue() : shift_frames->GetValue()); new_entry["fields"] = time_fields->GetSelection(); new_entry["mode"] = selection_mode->GetSelection(); new_entry["selection"] = shifted_blocks; history->push_front(new_entry); try { json::Writer::Write(*history, agi::io::Save(history_filename).Get()); } catch (agi::fs::FileSystemError const& e) { LOG_E("dialog_shift_times/save_history") << "Cannot save shift times history: " << e.GetChainedMessage(); } }
//------------------------------------------------------------------------------ void TrustZoneDevice::notify( uint32_t sessionId ) { // Check if it is MCP session - handle openSession() command if (sessionId != SID_MCP) { // Check if session ID exists to avoid flooding of nq by clients TrustletSession *ts = getTrustletSession(sessionId); if (ts == NULL) { LOG_E("no session with id=%d", sessionId); return; } LOG_I(" Sending notification for session %d to MobiCore", sessionId); } else { LOG_I(" Sending MCP notification to MobiCore"); } // Notify MobiCore about new data notification_t notification = { .sessionId = sessionId, .payload = 0 }; nq->putNotification(¬ification); //IMPROVEMENT-2012-03-07-maneaval What happens when/if nsiq fails? //In the old days an exception would be thrown but it was uncertain //where it was handled, some server(sock or Netlink). In that case //the server would just die but never actually signaled to the client //any error condition nsiq(); } //------------------------------------------------------------------------------ uint32_t TrustZoneDevice::getMobicoreStatus(void) { uint32_t status; pMcKMod->fcInfo(1, &status, NULL); return status; }
//------------------------------------------------------------------------------ mcResult_t CMcKMod::unlockWsmL2(uint32_t handle) { int ret = 0; LOG_I(" Unlocking World Shared Memory with handle %d", handle); if (!isOpen()) { LOG_E("no connection to kmod"); return MC_DRV_ERR_KMOD_NOT_OPEN; } ret = ioctl(fdKMod, MC_IO_UNLOCK_WSM, handle); // Failure here is not really important if (ret != 0) { LOG_I("ret = %d", ret); } return ret; }
bool _AutoPilot::init(void* pKiss) { CHECK_F(!this->_ThreadBase::init(pKiss)); Kiss* pK = (Kiss*)pKiss; pK->m_pInst = this; //create action instance Kiss* pCC = pK->o("action"); CHECK_T(pCC->empty()); Kiss** pItr = pCC->getChildItr(); int i = 0; while (pItr[i]) { Kiss* pAction = pItr[i]; i++; bool bInst = false; F_INFO(pAction->v("bInst", &bInst)); if (!bInst)continue; if (m_nAction >= N_ACTION)LOG(FATAL); ActionBase** pA = &m_pAction[m_nAction]; m_nAction++; //Add action modules below ADD_ACTION(RC_visualFollow); ADD_ACTION(APMcopter_landing); ADD_ACTION(APMcopter_guided); ADD_ACTION(HM_base); ADD_ACTION(HM_follow); ADD_ACTION(APMrover_base); ADD_ACTION(APMrover_follow); //Add action modules above LOG_E("Unknown action class: "+pAction->m_class); } return true; }
static bool fuzz_runVerifier(honggfuzz_t * hfuzz, fuzzer_t * crashedFuzzer) { bool ret = false; int crashFd = -1; uint8_t *crashBuf = NULL; off_t crashFileSz = 0; crashBuf = files_mapFile(crashedFuzzer->crashFileName, &crashFileSz, &crashFd, false); if (crashBuf == NULL) { LOG_E("Couldn't open and map '%s' in R/O mode", crashedFuzzer->crashFileName); goto bail; } LOG_I("Launching verifier for %" PRIx64 " hash", crashedFuzzer->backtrace); for (int i = 0; i < _HF_VERIFIER_ITER; i++) { fuzzer_t vFuzzer = { .pid = 0, .timeStartedMillis = util_timeNowMillis(), .crashFileName = {0}, .pc = 0ULL, .backtrace = 0ULL, .access = 0ULL, .exception = 0, .dynamicFileSz = 0, .dynamicFile = NULL, .hwCnts = { .cpuInstrCnt = 0ULL, .cpuBranchCnt = 0ULL, .pcCnt = 0ULL, .pathCnt = 0ULL, .customCnt = 0ULL, }, .sanCovCnts = { .hitBBCnt = 0ULL, .totalBBCnt = 0ULL, .dsoCnt = 0ULL, .iDsoCnt = 0ULL, .newBBCnt = 0ULL, .crashesCnt = 0ULL, }, .report = {'\0'}, .mainWorker = false
bool handle_cwGetGenericDeviceLogs(CAbstractPeer& peer, const char **pkt) { int sizePkt = 0, devId, fromTime, decimation, numEntries, i, entriesWritten = 0; uint32_t entriesRead = 0; bool printHeader = true; if (!skipInt(pkt, &devId) || !skipInt(pkt, &fromTime) || !skipInt(pkt, &decimation) || !skipInt(pkt, &numEntries) ) { LOG_E( "Invalid pkg"); } else { for(i=0; i < g_activeDevices.count(); i++) { if(devId == g_activeDevices[i]->m_ID) { sizePkt = m_snprintf(g_devScrapBuffer, sizeof(g_devScrapBuffer), "%d;%d;%d;", cwReplyGenericDeviceLogs, g_activeDevices[i]->m_deviceType, devId); do { sizePkt += deviceReadLog(devId, fromTime, decimation, (char*)(g_devScrapBuffer + sizePkt), sizeof(g_devScrapBuffer) - sizePkt, numEntries, printHeader, entriesWritten, entriesRead); fromTime = (fromTime/8192 + 1)*8192; } while( numEntries > entriesWritten && SystemClock.now(eTZ_UTC).toUnixTime() > fromTime); //LOG_I("cwGetGenericDeviceLogs %s", g_devScrapBuffer); peer.sendToPeer((const char*)g_devScrapBuffer, sizePkt); break; } } } }
//------------------------------------------------------------------------------ bool TrustZoneDevice::nsiq( void ) { // There is no need to set the NON-IDLE flag here. Sending an N-SIQ will // make the MobiCore run until it could set itself to a state where it // set the flag itself. IRQs and FIQs are disbaled for this period, so // there is no way the NWd can interrupt here. // not needed: mcFlags->schedule = MC_FLAG_SCHEDULE_NON_IDLE; int32_t ret = pMcKMod->fcNSIQ(); if (ret != 0) { LOG_E("pMcKMod->fcNSIQ() failed : %d", ret); return false; } // now we have to wake the scheduler, so MobiCore gets CPU time. schedSync.signal(); return true; }
char *str_sub (const char *s, unsigned int start, unsigned int end) { char *new_s = NULL; int i; if (s != NULL && start < end) { new_s = malloc (sizeof (*new_s) * (end - start + 2)); if (new_s != NULL) { for (i = start; i <= end; i++) { new_s[i-start] = s[i]; } new_s[i-start] = '\0'; } else { LOG_E(OTG,"Insufficient memory \n"); exit (-1); } } return new_s; }
//----------------------------------------------------------------------------- void mRAL_send_link_parameters_report_indication(ral_ue_instance_t instanceP, MIH_C_TRANSACTION_ID_T *transaction_id_pP, MIH_C_LINK_TUPLE_ID_T *link_identifier_pP, MIH_C_LINK_PARAM_RPT_LIST_T *link_parameters_report_list_pP) { //----------------------------------------------------------------------------- MIH_C_Message_Link_Parameters_Report_indication_t message; Bit_Buffer_t *bb_p; int message_total_length; module_id_t mod_id = instanceP - NB_eNB_INST; bb_p = new_BitBuffer_0(); BitBuffer_wrap(bb_p, g_msg_codec_send_buffer, (unsigned int)MSG_CODEC_SEND_BUFFER_SIZE); memset(&message, 0, sizeof (MIH_C_Message_Link_Parameters_Report_indication_t)); message.header.version = (MIH_C_VERSION_T)MIH_C_PROTOCOL_VERSION; message.header.service_identifier = (MIH_C_SID_T)2; message.header.operation_code = (MIH_C_OPCODE_T)3; message.header.action_identifier = (MIH_C_AID_T)5; message.header.transaction_id = *transaction_id_pP; MIH_C_MIHF_ID_set(&message.source, (u_int8_t*)g_ue_ral_obj[mod_id].link_id, strlen(g_ue_ral_obj[mod_id].link_id)); MIH_C_MIHF_ID_set(&message.destination, (u_int8_t*)g_ue_ral_obj[mod_id].mihf_id, strlen(g_ue_ral_obj[mod_id].mihf_id)); memcpy(&message.primitive.LinkIdentifier, link_identifier_pP, sizeof(MIH_C_LINK_TUPLE_ID_T)); memcpy(&message.primitive.LinkParametersReportList_list, link_parameters_report_list_pP, sizeof(MIH_C_LINK_PARAM_RPT_LIST_T)); message_total_length = MIH_C_Link_Message_Encode_Link_Parameters_Report_indication(bb_p, &message); if (mRAL_send_to_mih(instanceP, bb_p->m_buffer,message_total_length)<0) { LOG_E(RAL_UE, ": Send Link_Parameters_Report.indication\n"); } else { LOG_D(RAL_UE, ": Sent Link_Parameters_Report.indication\n"); } free_BitBuffer(bb_p); }
int main(int argc, char **argv) { struct sigaction action; int exitCode; parseArgs(argc,argv); initLogs(); if (keepAsDaemon) { LOG_N("Trying to keep as a daemon..."); if (daemon(false,false)<0) { LOG_E(strerror(errno)); LOG_W("... continuing daemonless"); } else { LOG_N("... Success "); } } memset(&action,0,sizeof(action)); action.sa_handler =signalHandler; sigaction(SIGHUP,&action,NULL); sigaction(SIGTERM,&action,NULL); // signal(SIGHUP,signalHandler); /* catch hangup signal */ // signal(SIGTERM,signalHandler); /* catch kill signal */ exitCode = runMonitor(); return exitCode; //return EXIT_SUCCESS; }
//----------------------------------------------------------------------------- void mRAL_send_capability_discover_confirm(ral_ue_instance_t instanceP, MIH_C_TRANSACTION_ID_T *transaction_id_pP, MIH_C_STATUS_T *status_pP, MIH_C_LINK_EVENT_LIST_T *supported_link_event_list_pP, MIH_C_LINK_CMD_LIST_T *supported_link_command_list_pP) { //----------------------------------------------------------------------------- MIH_C_Message_Link_Capability_Discover_confirm_t message; Bit_Buffer_t *bb_p; int message_total_length; module_id_t mod_id = instanceP - NB_eNB_INST; bb_p = new_BitBuffer_0(); BitBuffer_wrap(bb_p, g_msg_codec_send_buffer, (unsigned int)MSG_CODEC_SEND_BUFFER_SIZE); memset(&message, 0, sizeof (MIH_C_Message_Link_Capability_Discover_confirm_t)); message.header.version = (MIH_C_VERSION_T)MIH_C_PROTOCOL_VERSION; message.header.service_identifier = (MIH_C_SID_T)1; message.header.operation_code = (MIH_C_OPCODE_T)0; message.header.action_identifier = (MIH_C_AID_T)1; message.header.transaction_id = *transaction_id_pP; MIH_C_MIHF_ID_set(&message.source, (u_int8_t*)g_ue_ral_obj[mod_id].link_id, strlen(g_ue_ral_obj[mod_id].link_id)); MIH_C_MIHF_ID_set(&message.destination, (u_int8_t*)g_ue_ral_obj[mod_id].mihf_id, strlen(g_ue_ral_obj[mod_id].mihf_id)); message.primitive.Status = *status_pP; message.primitive.SupportedLinkEventList = supported_link_event_list_pP; message.primitive.SupportedLinkCommandList = supported_link_command_list_pP; message_total_length = MIH_C_Link_Message_Encode_Capability_Discover_confirm(bb_p, &message); if (mRAL_send_to_mih(instanceP, bb_p->m_buffer,message_total_length)<0) { LOG_E(RAL_UE, ": Send Link_Capability_Discover.confirm\n"); } else { LOG_D(RAL_UE, ": Sent Link_Capability_Discover.confirm\n"); } free_BitBuffer(bb_p); }
void *receive_thread(void *args) { flexran_agent_instance_t *d = args; void *data; int size; int priority; err_code_t err_code; Protocol__FlexranMessage *msg; while (1) { while (flexran_agent_msg_recv(d->enb_id, FLEXRAN_AGENT_DEFAULT, &data, &size, &priority) == 0) { LOG_D(FLEXRAN_AGENT,"received message with size %d\n", size); // Invoke the message handler msg=flexran_agent_handle_message(d->enb_id, data, size); free(data); // check if there is something to send back to the controller if (msg != NULL){ data=flexran_agent_pack_message(msg,&size); if (flexran_agent_msg_send(d->enb_id, FLEXRAN_AGENT_DEFAULT, data, size, priority)) { err_code = PROTOCOL__FLEXRAN_ERR__MSG_ENQUEUING; goto error; } LOG_D(FLEXRAN_AGENT,"sent message with size %d\n", size); } } } return NULL; error: LOG_E(FLEXRAN_AGENT,"receive_thread: error %d occured\n",err_code); return NULL; }
int send_chopstick_query_req(void* entity) { if (!entity) return FSM_FAIL; CVTTO_PHILOS(phi, entity); LOG_D("---%s need chopstick---fsmid[%d]", phi->philos->name, phi->fsmid); int chop_idx; if (phi->chops[0] == -1){ chop_idx = QUERY_LEFT(phi->philos->whoami); LOG_D("philos[%d] needs left chop[%d]", phi->philos->whoami, chop_idx); } else if (phi->chops[1] == -1){ chop_idx = QUERY_RIGHT(phi->philos->whoami); LOG_D("philos[%d] needs right chop[%d]", phi->philos->whoami, chop_idx); } else { LOG_E("No need to get chopstick,fsm[%d]", phi->fsmid); return FSM_FAIL; } msg_t * m = pack_chop_req_msg(chop_idx, GET, phi->fsmid); int ret = fsm_entity_start_timer(entity, QUERY_CHOP_TM, QUERY_CHOPSTICK_TIMEOUT); if (0 != ret){ LOG_NE("start timer failed"); free (m); return FSM_FAIL; } if (SM_OK != send_msg(m)){ perror("send msg failed"); LOG_NE("send msg failed"); return FSM_FAIL; } phi->nextjump = proc_chopstick_query_resp; philos_set_status(phi->philos, BUSY); LOG_D("send chopstick query req success. fsmid[%d]", phi->fsmid); return FSM_OK; }
void Hotkey::BuildHotkey(std::string const& context, json::Object const& hotkeys) { for (auto const& command : hotkeys) { const json::Array& command_hotkeys = command.second; for (auto const& hotkey : command_hotkeys) { std::vector<std::string> keys; try { const json::Array& arr_mod = hotkey["modifiers"]; keys.reserve(arr_mod.size() + 1); copy(arr_mod.begin(), arr_mod.end(), back_inserter(keys)); keys.push_back(hotkey["key"]); } catch (json::Exception const& e) { LOG_E("agi/hotkey/load") << "Failed loading hotkey for command '" << command.first << "': " << e.what(); } ComboInsert(Combo(context, command.first, keys)); } } }
static int nas_ue_process_events(struct epoll_event *events, int nb_events) { int event; int exit_loop = FALSE; LOG_I(NAS, "[UE] Received %d events\n", nb_events); for (event = 0; event < nb_events; event++) { if (events[event].events != 0) { /* If the event has not been yet been processed (not an itti message) */ if (events[event].data.fd == user_fd) { exit_loop = nas_user_receive_and_process(&user_fd, NULL); } else { LOG_E(NAS, "[UE] Received an event from an unknown fd %d!\n", events[event].data.fd); } } } return (exit_loop); }
char *sys_read_asset(const char *path, int *size) { FILE *file; int read_size __attribute__((unused)); char *ret; int default_size; size = size ?: &default_size; file = fopen(path, "rb"); if (!file) LOG_E("cannot file file %s", path); assert(file); fseek(file, 0, SEEK_END); *size = ftell(file); fseek(file, 0, SEEK_SET); ret = malloc(*size + 1); read_size = fread(ret, *size, 1, file); assert(read_size == 1 || *size == 0); fclose(file); ret[*size] = '\0'; return ret; }
TinyRet tiny_udp_multicast_open(int *fd, const char *group, uint16_t port, bool block) { TinyRet ret = TINY_RET_OK; do { *fd = socket(AF_INET, SOCK_DGRAM, 0); if (*fd < 0) { LOG_E(TAG, "socket failed"); ret = TINY_RET_E_SOCKET_FD; #ifdef _WIN32 DWORD e = GetLastError(); LOG_D(TAG, "socket, e = %d", e); #else LOG_D(TAG, "socket: %s", strerror(errno)); #endif break; } ret = tiny_join_multicast_group(*fd, group, port); if (RET_FAILED(ret)) { break; } if (!block) { ret = tiny_socket_set_nonblock(*fd); if (RET_FAILED(ret)) { break; } } } while (0); return ret; }
/** * Put an IP_PKTINFO control message into msg ancillary data buffer. */ static void ip_cmsg_recv_pktinfo(ci_netif* netif, const ci_ip_pkt_fmt* pkt, struct cmsg_state *cmsg_state) { /* TODO: This is horribly inefficient -- two system calls. Could be made * cheap with a user-level llap table. */ struct in_pktinfo info; ci_uint32 addr; int hwport; addr = oo_ip_hdr_const(pkt)->ip_daddr_be32; info.ipi_addr.s_addr = addr; /* Set the ifindex the pkt was received at. */ { ci_ifid_t ifindex = 0; int rc = 0; hwport = netif->state->intf_i_to_hwport[pkt->intf_i]; rc = cicp_llap_find(CICP_HANDLE(netif), &ifindex, CI_HWPORT_ID(hwport), pkt->vlan); if( rc != 0 ) LOG_E(ci_log("%s: cicp_llap_find(intf_i=%d, hwport=%d) failed rc=%d", __FUNCTION__, pkt->intf_i, hwport, rc)); info.ipi_ifindex = ifindex; } /* RFC1122: The specific-destination address is defined to be the * destination address in the IP header unless the header contains a * broadcast or multicast address, in which case the specific-destination * is an IP address assigned to the physical interface on which the * datagram arrived. */ /*\ FIXME: we should drop the packet if this call fails */ cicp_ipif_pktinfo_query(CICP_HANDLE(netif), netif, OO_PKT_P(pkt), info.ipi_ifindex, &info.ipi_spec_dst.s_addr ); ci_put_cmsg(cmsg_state, IPPROTO_IP, IP_PKTINFO, sizeof(info), &info); }
//----------------------------------------------------------------------------- void config_req_rlc_um ( const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP, const rlc_um_info_t * const config_um_pP, const rb_id_t rb_idP) { rlc_union_t *rlc_union_p = NULL; rlc_um_entity_t *rlc_p = NULL; hash_key_t key = RLC_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, rb_idP, srb_flagP); hashtable_rc_t h_rc; h_rc = hashtable_get(rlc_coll_p, key, (void**)&rlc_union_p); if (h_rc == HASH_TABLE_OK) { rlc_p = &rlc_union_p->rlc.um; LOG_D(RLC, PROTOCOL_RLC_UM_CTXT_FMT" CONFIG_REQ timer_reordering=%d sn_field_length=%d is_mXch=%d RB %u\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), config_um_pP->timer_reordering, config_um_pP->sn_field_length, config_um_pP->is_mXch, rb_idP); rlc_um_init(ctxt_pP, rlc_p); if (rlc_um_fsm_notify_event (ctxt_pP, rlc_p, RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT)) { rlc_um_set_debug_infos(ctxt_pP, rlc_p, srb_flagP, rb_idP); rlc_um_configure( ctxt_pP, rlc_p, config_um_pP->timer_reordering, config_um_pP->sn_field_length, config_um_pP->sn_field_length, config_um_pP->is_mXch); } } else { LOG_E(RLC, PROTOCOL_RLC_UM_CTXT_FMT" CONFIG_REQ RB %u RLC UM NOT FOUND\n", PROTOCOL_RLC_UM_CTXT_ARGS(ctxt_pP,rlc_p), rb_idP); } }
//----------------------------------------------------------------------------- void rlc_am_send_sdu (rlc_am_entity_t *rlcP,u32_t frame, u8_t eNB_flag) //----------------------------------------------------------------------------- { /*#ifndef USER_MODE unsigned long int rlc_um_time_us; int min, sec, usec; #endif*/ if ((rlcP->output_sdu_in_construction)) { #ifdef TRACE_RLC_AM_SEND_SDU LOG_D(RLC, "\n\n\n[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND_SDU] %d bytes sdu %p\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->output_sdu_size_to_write, rlcP->output_sdu_in_construction); /*#ifndef USER_MODE rlc_um_time_us = (unsigned long int)(rt_get_time_ns ()/(RTIME)1000); sec = (rlc_um_time_us/ 1000000); min = (sec / 60) % 60; sec = sec % 60; usec = rlc_um_time_us % 1000000; msg ("[RLC_UM_LITE][RB %d] at time %2d:%2d.%6d\n", rlcP->rb_id, min, sec , usec); #endif*/ #endif if (rlcP->output_sdu_size_to_write > 0) { #ifdef TRACE_RLC_STATS rlcP->rx_sdus += 1; #endif #ifdef TEST_RLC_AM rlc_am_v9_3_0_test_data_ind (rlcP->module_id, rlcP->rb_id, rlcP->output_sdu_size_to_write, rlcP->output_sdu_in_construction); #else rlc_data_ind (rlcP->module_id, frame, eNB_flag, rlcP->rb_id, rlcP->output_sdu_size_to_write, rlcP->output_sdu_in_construction, rlcP->is_data_plane); #endif rlcP->output_sdu_in_construction = NULL; } else { LOG_E(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND_SDU] ERROR SIZE <= 0 ... DO NOTHING, SET SDU SIZE TO 0\n", frame,rlcP->module_id, rlcP->rb_id); //msg("[RLC_AM][MOD %d] Freeing mem_block ...\n", rlcP->module_id); //free_mem_block (rlcP->output_sdu_in_construction); assert(3==4); } rlcP->output_sdu_size_to_write = 0; } }
Dart_Handle Isolate::New(const char* typeName, int argc, Dart_Handle* args) { // entering and leaving the scope here causes us to invalidate the instance handle! // Dart_EnterScope(); // Get type Dart_Handle type = Dart_GetType(library_, NewString(typeName), 0, NULL); if(Dart_IsError(type)) { LOG_E(Dart_GetError(type)); } // Invoke the unnamed constructor. Dart_Handle instance = Dart_New(type, Dart_Null(), argc, args); if (Dart_IsError(instance)) { // Dart_NewApiError LOG_E(Dart_GetError(instance) << " while instantiating '"<< type <<"'") } // Dart_ExitScope(); return instance; }
//------------------------------------------------------------------------------ CWsm_ptr TrustZoneDevice::registerWsmL2( addr_t buffer, uint32_t len, uint32_t pid ) { addr_t physAddr; uint32_t handle; int ret = pMcKMod->registerWsmL2( buffer, len, pid, &handle, &physAddr); if (ret != 0) { LOG_E("ipMcKMod->registerWsmL2() failed: %d", ret); return NULL; } return new CWsm(buffer,len,handle,physAddr); }
/* This is a binary search routine which operates on an array of floating point numbers and returns the index of the range the value lies in Used for RSRP and RSRQ measurement mapping. Can potentially be used for other things */ long binary_search_float(float elements[], long numElem, float value) { long first, last, middle; first = 0; last = numElem-1; middle = (first+last)/2; if(value <= elements[0]) return first; if(value >= elements[last]) return last; while (last - first > 1) { if (elements[middle] > value) last = middle; else first = middle; middle = (first+last)/2; } if (first < 0 || first >= numElem) LOG_E(RRC,"\n Error in binary search float!"); return first; }
int oo_os_sock_ioctl(ci_netif* ni, oo_sp sock_p, int request, void* arg, int* ioctl_rc) { oo_os_file os_sock_fd; int rc; if( (rc = oo_os_sock_get(ni, sock_p, &os_sock_fd)) == 0 ) { rc = ci_sys_ioctl(os_sock_fd, request, arg); if( rc < 0 ) rc = -errno; oo_os_sock_release(ni, os_sock_fd); if( ioctl_rc != NULL ) { *ioctl_rc = rc; rc = 0; } } else { LOG_E(ci_log("%s: [%d:%d] ERROR: failed to get kernel sock fd " "(rc=%d req=%d)", __FUNCTION__, NI_ID(ni), OO_SP_FMT(sock_p), rc, request)); } return rc; }
bool cmdlineAddEnv(honggfuzz_t* hfuzz, char* env) { size_t enveqlen = strlen(env); const char* eqpos = strchr(env, '='); if (eqpos) { enveqlen = (uintptr_t)eqpos - (uintptr_t)env + 1; } for (size_t i = 0; i < ARRAYSIZE(hfuzz->exe.envs); i++) { if (hfuzz->exe.envs[i] == NULL) { LOG_D("Adding envar '%s'", env); hfuzz->exe.envs[i] = env; return true; } if (strncmp(hfuzz->exe.envs[i], env, enveqlen) == 0) { LOG_W("Replacing envar '%s' with '%s'", hfuzz->exe.envs[i], env); hfuzz->exe.envs[i] = env; return true; } } LOG_E("No more space for new envars (max.%zu)", ARRAYSIZE(hfuzz->exe.envs)); return false; }
static int efab_tcp_helper_pipe_attach(ci_private_t* priv, void *arg) { oo_pipe_attach_t* op = arg; tcp_helper_resource_t* trs = priv->thr; tcp_helper_endpoint_t* ep = NULL; int rc; OO_DEBUG_TCPH(ci_log("%s: ep_id=%d", __FUNCTION__, op->ep_id)); if( trs == NULL ) { LOG_E(ci_log("%s: ERROR: not attached to a stack", __FUNCTION__)); return -EINVAL; } /* Validate and find the endpoint. */ if( ! IS_VALID_SOCK_P(&trs->netif, op->ep_id) ) return -EINVAL; ep = ci_trs_get_valid_ep(trs, op->ep_id); if( tcp_helper_endpoint_set_aflags(ep, OO_THR_EP_AFLAG_ATTACHED) & OO_THR_EP_AFLAG_ATTACHED ) return -EBUSY; rc = oo_create_fd(ep, op->flags, CI_PRIV_TYPE_PIPE_READER); if( rc < 0 ) { tcp_helper_endpoint_clear_aflags(ep, OO_THR_EP_AFLAG_ATTACHED); return rc; } op->rfd = rc; rc = oo_create_fd(ep, op->flags, CI_PRIV_TYPE_PIPE_WRITER); if( rc < 0 ) { efab_linux_sys_close(op->rfd); tcp_helper_endpoint_clear_aflags(ep, OO_THR_EP_AFLAG_ATTACHED); return rc; } op->wfd = rc; return 0; }
int mqtt_client_connect(MQTTClient* pClient, const char* address, const char* clientid , MQTTClient_connectionLost* connlost, MQTTClient_messageArrived* msgarrvd, MQTTClient_deliveryComplete* delivered) { MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer; int rc; // int ch; MQTTClient_create(pClient, address, clientid, MQTTCLIENT_PERSISTENCE_NONE, NULL); conn_opts.keepAliveInterval = 20; conn_opts.cleansession = 1; MQTTClient_setCallbacks(*pClient, NULL, connlost, msgarrvd, delivered); if ((rc = MQTTClient_connect(*pClient, &conn_opts)) != MQTTCLIENT_SUCCESS) { LOG_E("Failed to connect, return code %d\n", rc); MQTTClient_destroy(pClient); return -1; } return rc; }
OMX_ERRORTYPE AlsaSourceNmfHost::deInstantiateMain(void) { t_nmf_error nmf_error; LOG_I("Enter.\n"); nmf_error = mNmfMain->unbindComponent("source", mNmfil, "source"); if (nmf_error != NMF_OK) { LOG_E("\tError: unable to unbind main source! [%d]\n", nmf_error); return OMX_ErrorInsufficientResources; } nmf_error = mNmfMain->unbindFromUser("configure"); if (nmf_error != NMF_OK) { LOG_E("\tError: unable to unbind main configure! [%d]\n", nmf_error); return OMX_ErrorInsufficientResources; } nmf_error = mNmfil->unbindFromUser("configure"); if (nmf_error != NMF_OK) { LOG_E("\tError: unable to unbind il configure! [%d]\n", nmf_error); return OMX_ErrorInsufficientResources; } if (mNmfil->destroy() != NMF_OK) { LOG_E("\tError: mNmfil->destroy failed!\n"); return OMX_ErrorInsufficientResources; } nmf_error = mNmfMain->unbindFromUser("process"); if (nmf_error != NMF_OK) { LOG_E("\tError: unable to unbind main process! [%d]\n", nmf_error); return OMX_ErrorInsufficientResources; } alsasource_nmfil_host_composite_alsasourceDestroy((alsasource_nmfil_host_composite_alsasource*&)mNmfil); if (mNmfMain->destroy() != NMF_OK) { LOG_E("\tError: mNmfMain->destroy failed!\n"); return OMX_ErrorInsufficientResources; } alsasource_nmfil_host_composite_wrapperDestroy((alsasource_nmfil_host_composite_wrapper*&)mNmfMain); return OMX_ErrorNone; }
static int oo_pipe_ctor(ci_netif* netif, struct oo_pipe** out_pipe, int fds[2], int flags) { struct oo_pipe* p; int rc; ci_assert(netif); ci_netif_lock(netif); p = oo_pipe_buf_get(netif); if( !p ) { rc = -1; errno = ENOMEM; goto out; } if( flags & O_NONBLOCK ) { p->aflags = (CI_PFD_AFLAG_NONBLOCK << CI_PFD_AFLAG_READER_SHIFT) | (CI_PFD_AFLAG_NONBLOCK << CI_PFD_AFLAG_WRITER_SHIFT); } /* attach */ rc = ci_tcp_helper_pipe_attach(ci_netif_get_driver_handle(netif), W_SP(&p->b), flags, fds); if( rc < 0 ) { LOG_E(ci_log("%s: ci_tcp_helper_pipe_attach %d", __FUNCTION__, rc)); errno = -rc; rc = -1; goto out; } *out_pipe = p; out: ci_netif_unlock(netif); return rc; }
/** * Attach the spi device to SPI bus, this function must be used after initialization. */ rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, GPIO_TypeDef *cs_gpiox, uint16_t cs_gpio_pin) { RT_ASSERT(bus_name != RT_NULL); RT_ASSERT(device_name != RT_NULL); rt_err_t result; struct rt_spi_device *spi_device; struct stm32_hw_spi_cs *cs_pin; /* initialize the cs pin && select the slave*/ GPIO_InitTypeDef GPIO_Initure; GPIO_Initure.Pin = cs_gpio_pin; GPIO_Initure.Mode = GPIO_MODE_OUTPUT_PP; GPIO_Initure.Pull = GPIO_PULLUP; GPIO_Initure.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(cs_gpiox, &GPIO_Initure); HAL_GPIO_WritePin(cs_gpiox, cs_gpio_pin, GPIO_PIN_SET); /* attach the device to spi bus*/ spi_device = (struct rt_spi_device *)rt_malloc(sizeof(struct rt_spi_device)); RT_ASSERT(spi_device != RT_NULL); cs_pin = (struct stm32_hw_spi_cs *)rt_malloc(sizeof(struct stm32_hw_spi_cs)); RT_ASSERT(cs_pin != RT_NULL); cs_pin->GPIOx = cs_gpiox; cs_pin->GPIO_Pin = cs_gpio_pin; result = rt_spi_bus_attach_device(spi_device, device_name, bus_name, (void *)cs_pin); if (result != RT_EOK) { LOG_E("%s attach to %s faild, %d\n", device_name, bus_name, result); } RT_ASSERT(result == RT_EOK); LOG_D("%s attach to %s done", device_name, bus_name); return result; }