int ieee80211_register_hw(struct ieee80211_hw *hw) { struct ieee80211_local *local = hw_to_local(hw); int result; enum ieee80211_band band; int channels, max_bitrates; bool supp_ht; static const u32 cipher_suites[] = { WLAN_CIPHER_SUITE_WEP40, WLAN_CIPHER_SUITE_WEP104, WLAN_CIPHER_SUITE_TKIP, WLAN_CIPHER_SUITE_CCMP, /* keep last -- depends on hw flags! */ WLAN_CIPHER_SUITE_AES_CMAC }; /* * generic code guarantees at least one band, * set this very early because much code assumes * that hw.conf.channel is assigned */ channels = 0; max_bitrates = 0; supp_ht = false; for (band = 0; band < IEEE80211_NUM_BANDS; band++) { struct ieee80211_supported_band *sband; sband = local->hw.wiphy->bands[band]; if (!sband) continue; if (!local->oper_channel) { /* init channel we're on */ local->hw.conf.channel = local->oper_channel = &sband->channels[0]; local->hw.conf.channel_type = NL80211_CHAN_NO_HT; } channels += sband->n_channels; if (max_bitrates < sband->n_bitrates) max_bitrates = sband->n_bitrates; supp_ht = supp_ht || sband->ht_cap.ht_supported; } local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) + sizeof(void *) * channels, GFP_KERNEL); if (!local->int_scan_req) return -ENOMEM; /* if low-level driver supports AP, we also support VLAN */ if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) local->hw.wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP_VLAN); /* mac80211 always supports monitor */ local->hw.wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR); if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) local->hw.wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; else if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) local->hw.wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC; WARN((local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD) && (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK), "U-APSD not supported with HW_PS_NULLFUNC_STACK\n"); /* * Calculate scan IE length -- we need this to alloc * memory and to subtract from the driver limit. It * includes the (extended) supported rates and HT * information -- SSID is the driver's responsibility. */ local->scan_ies_len = 4 + max_bitrates; /* (ext) supp rates */ if (supp_ht) local->scan_ies_len += 2 + sizeof(struct ieee80211_ht_cap); if (!local->ops->hw_scan) { /* For hw_scan, driver needs to set these up. */ local->hw.wiphy->max_scan_ssids = 4; local->hw.wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; } /* * If the driver supports any scan IEs, then assume the * limit includes the IEs mac80211 will add, otherwise * leave it at zero and let the driver sort it out; we * still pass our IEs to the driver but userspace will * not be allowed to in that case. */ if (local->hw.wiphy->max_scan_ie_len) local->hw.wiphy->max_scan_ie_len -= local->scan_ies_len; local->hw.wiphy->cipher_suites = cipher_suites; local->hw.wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); if (!(local->hw.flags & IEEE80211_HW_MFP_CAPABLE)) local->hw.wiphy->n_cipher_suites--; result = wiphy_register(local->hw.wiphy); if (result < 0) goto fail_wiphy_register; /* * We use the number of queues for feature tests (QoS, HT) internally * so restrict them appropriately. */ if (hw->queues > IEEE80211_MAX_QUEUES) hw->queues = IEEE80211_MAX_QUEUES; local->workqueue = create_singlethread_workqueue(wiphy_name(local->hw.wiphy)); if (!local->workqueue) { result = -ENOMEM; goto fail_workqueue; } /* * The hardware needs headroom for sending the frame, * and we need some headroom for passing the frame to monitor * interfaces, but never both at the same time. */ BUILD_BUG_ON(IEEE80211_TX_STATUS_HEADROOM != sizeof(struct ieee80211_tx_status_rtap_hdr)); local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom, sizeof(struct ieee80211_tx_status_rtap_hdr)); debugfs_hw_add(local); /* * if the driver doesn't specify a max listen interval we * use 5 which should be a safe default */ if (local->hw.max_listen_interval == 0) local->hw.max_listen_interval = 5; local->hw.conf.listen_interval = local->hw.max_listen_interval; local->hw.conf.dynamic_ps_forced_timeout = -1; result = sta_info_start(local); if (result < 0) goto fail_sta_info; result = ieee80211_wep_init(local); if (result < 0) { printk(KERN_DEBUG "%s: Failed to initialize wep: %d\n", wiphy_name(local->hw.wiphy), result); goto fail_wep; } rtnl_lock(); result = ieee80211_init_rate_ctrl_alg(local, hw->rate_control_algorithm); if (result < 0) { printk(KERN_DEBUG "%s: Failed to initialize rate control " "algorithm\n", wiphy_name(local->hw.wiphy)); goto fail_rate; } /* add one default STA interface if supported */ if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) { result = ieee80211_if_add(local, "wlan%d", NULL, NL80211_IFTYPE_STATION, NULL); if (result) printk(KERN_WARNING "%s: Failed to add default virtual iface\n", wiphy_name(local->hw.wiphy)); } rtnl_unlock(); ieee80211_led_init(local); local->network_latency_notifier.notifier_call = ieee80211_max_network_latency; result = pm_qos_add_notifier(PM_QOS_NETWORK_LATENCY, &local->network_latency_notifier); if (result) { rtnl_lock(); goto fail_pm_qos; } return 0; fail_pm_qos: ieee80211_led_exit(local); ieee80211_remove_interfaces(local); fail_rate: rtnl_unlock(); ieee80211_wep_free(local); fail_wep: sta_info_stop(local); fail_sta_info: destroy_workqueue(local->workqueue); fail_workqueue: wiphy_unregister(local->hw.wiphy); fail_wiphy_register: kfree(local->int_scan_req); return result; }
static void LoadConfigFromFile(FILE *f) { ConfigBlock *curBlock = cfgBlocks; ConfigEntry *ent; while(fgets(buffer, sizeof(buffer), f)) { int i = 0; while(isspace(buffer[i])) i++; if(!buffer[i] || buffer[i] == '#') continue; memmove(buffer, buffer+i, strlen(buffer+i)+1); if(buffer[0] == '[') { ConfigBlock *nextBlock; unsigned int i2; i2 = 1; while(buffer[i2] && buffer[i2] != ']') i2++; if(!buffer[i2]) { ERR("config parse error: bad line \"%s\"\n", buffer); continue; } buffer[i2] = 0; do { i2++; if(buffer[i2] && !isspace(buffer[i2])) { if(buffer[i2] != '#') WARN("config warning: extra data after block: \"%s\"\n", buffer+i2); break; } } while(buffer[i2]); nextBlock = NULL; for(i2 = 0;i2 < cfgCount;i2++) { if(strcasecmp(cfgBlocks[i2].name, buffer+1) == 0) { nextBlock = cfgBlocks+i2; TRACE("found block '%s'\n", nextBlock->name); break; } } if(!nextBlock) { nextBlock = realloc(cfgBlocks, (cfgCount+1)*sizeof(ConfigBlock)); if(!nextBlock) { ERR("config parse error: error reallocating config blocks\n"); continue; } cfgBlocks = nextBlock; nextBlock = cfgBlocks+cfgCount; cfgCount++; nextBlock->name = strdup(buffer+1); nextBlock->entries = NULL; nextBlock->entryCount = 0; TRACE("found new block '%s'\n", nextBlock->name); } curBlock = nextBlock; continue; } /* Look for the option name */ i = 0; while(buffer[i] && buffer[i] != '#' && buffer[i] != '=' && !isspace(buffer[i])) i++; if(!buffer[i] || buffer[i] == '#' || i == 0) { ERR("config parse error: malformed option line: \"%s\"\n", buffer); continue; } /* Seperate the option */ if(buffer[i] != '=') { buffer[i++] = 0; while(isspace(buffer[i])) i++; if(buffer[i] != '=') { ERR("config parse error: option without a value: \"%s\"\n", buffer); continue; } } /* Find the start of the value */ buffer[i++] = 0; while(isspace(buffer[i])) i++; /* Check if we already have this option set */ ent = curBlock->entries; while((unsigned int)(ent-curBlock->entries) < curBlock->entryCount) { if(strcasecmp(ent->key, buffer) == 0) break; ent++; } if((unsigned int)(ent-curBlock->entries) >= curBlock->entryCount) { /* Allocate a new option entry */ ent = realloc(curBlock->entries, (curBlock->entryCount+1)*sizeof(ConfigEntry)); if(!ent) { ERR("config parse error: error reallocating config entries\n"); continue; } curBlock->entries = ent; ent = curBlock->entries + curBlock->entryCount; curBlock->entryCount++; ent->key = strdup(buffer); ent->value = NULL; } /* Look for the end of the line (Null term, new-line, or #-symbol) and eat up the trailing whitespace */ memmove(buffer, buffer+i, strlen(buffer+i)+1); i = 0; while(buffer[i] && buffer[i] != '#' && buffer[i] != '\n') i++; do { i--; } while(i >= 0 && isspace(buffer[i])); buffer[++i] = 0; free(ent->value); ent->value = strdup(buffer); TRACE("found '%s' = '%s'\n", ent->key, ent->value); } }
int CrFbDisplayWindow::windowDimensionsSync(bool fForceCleanup) { int rc = VINF_SUCCESS; if (!mpWindow) return VINF_SUCCESS; //HCR_FRAMEBUFFER hFb = getFramebuffer(); if (!fForceCleanup && isActive()) { const RTRECT* pRect = getRect(); if (mpWindow->GetParentId() != mParentId) { rc = mpWindow->Reparent(mParentId); if (!RT_SUCCESS(rc)) { WARN(("err")); return rc; } } rc = mpWindow->SetPosition(pRect->xLeft - mViewportRect.xLeft, pRect->yTop - mViewportRect.yTop); if (!RT_SUCCESS(rc)) { WARN(("err")); return rc; } setRegionsChanged(); rc = mpWindow->SetSize((uint32_t)(pRect->xRight - pRect->xLeft), (uint32_t)(pRect->yBottom - pRect->yTop)); if (!RT_SUCCESS(rc)) { WARN(("err")); return rc; } rc = mpWindow->SetVisible(!g_CrPresenter.fWindowsForceHidden); if (!RT_SUCCESS(rc)) { WARN(("err")); return rc; } } else { rc = mpWindow->SetVisible(false); if (!RT_SUCCESS(rc)) { WARN(("err")); return rc; } #if 0 rc = mpWindow->Reparent(mDefaultParentId); if (!RT_SUCCESS(rc)) { WARN(("err")); return rc; } #endif } return rc; }
static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller) { DispatchEx *This = impl_from_IDispatchEx(iface); IUnknown *unk; ITypeInfo *ti; dispex_data_t *data; UINT argerr=0; int min, max, n; HRESULT hres; TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller); if(This->data->vtbl && This->data->vtbl->invoke) { hres = This->data->vtbl->invoke(This->outer, id, lcid, wFlags, pdp, pvarRes, pei); if (hres != DISP_E_UNKNOWNNAME) return hres; } if(wFlags == DISPATCH_CONSTRUCT) { FIXME("DISPATCH_CONSTRUCT not implemented\n"); return E_NOTIMPL; } data = get_dispex_data(This); if(!data) return E_FAIL; min = 0; max = data->func_cnt-1; while(min <= max) { n = (min+max)/2; if(data->funcs[n].id == id) break; if(data->funcs[n].id < id) min = n+1; else max = n-1; } if(min > max) { WARN("invalid id %x\n", id); return DISP_E_UNKNOWNNAME; } hres = get_typeinfo(data->funcs[n].tid, &ti); if(FAILED(hres)) { ERR("Could not get type info: %08x\n", hres); return hres; } hres = IUnknown_QueryInterface(This->outer, get_riid_from_tid(data->funcs[n].tid), (void**)&unk); if(FAILED(hres)) { ERR("Could not get iface: %08x\n", hres); ITypeInfo_Release(ti); return E_FAIL; } if (is_propputref_id(id) && wFlags == DISPATCH_PROPERTYPUT) wFlags = DISPATCH_PROPERTYPUTREF; hres = ITypeInfo_Invoke(ti, unk, id, wFlags, pdp, pvarRes, pei, &argerr); ITypeInfo_Release(ti); IUnknown_Release(unk); return hres; }
static HRESULT IDirectSoundCaptureBufferImpl_Create( DirectSoundCaptureDevice *device, IDirectSoundCaptureBufferImpl ** ppobj, LPCDSCBUFFERDESC lpcDSCBufferDesc) { LPWAVEFORMATEX wfex; IDirectSoundCaptureBufferImpl *This; TRACE( "(%p,%p,%p)\n", device, ppobj, lpcDSCBufferDesc); if (ppobj == NULL) { WARN("invalid parameter: ppobj == NULL\n"); return DSERR_INVALIDPARAM; } *ppobj = NULL; if (!device) { WARN("not initialized\n"); return DSERR_UNINITIALIZED; } if (lpcDSCBufferDesc == NULL) { WARN("invalid parameter: lpcDSCBufferDesc == NULL\n"); return DSERR_INVALIDPARAM; } if ( ((lpcDSCBufferDesc->dwSize != sizeof(DSCBUFFERDESC)) && (lpcDSCBufferDesc->dwSize != sizeof(DSCBUFFERDESC1))) || (lpcDSCBufferDesc->dwBufferBytes == 0) || (lpcDSCBufferDesc->lpwfxFormat == NULL) ) { /* FIXME: DSERR_BADFORMAT ? */ WARN("invalid lpcDSCBufferDesc\n"); return DSERR_INVALIDPARAM; } wfex = lpcDSCBufferDesc->lpwfxFormat; TRACE("(formattag=0x%04x,chans=%d,samplerate=%d," "bytespersec=%d,blockalign=%d,bitspersamp=%d,cbSize=%d)\n", wfex->wFormatTag, wfex->nChannels, wfex->nSamplesPerSec, wfex->nAvgBytesPerSec, wfex->nBlockAlign, wfex->wBitsPerSample, wfex->cbSize); device->pwfx = DSOUND_CopyFormat(wfex); if ( device->pwfx == NULL ) return DSERR_OUTOFMEMORY; This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, sizeof(IDirectSoundCaptureBufferImpl)); if ( This == NULL ) { WARN("out of memory\n"); return DSERR_OUTOFMEMORY; } else { HRESULT err = DS_OK; LPBYTE newbuf; DWORD buflen; This->numIfaces = 0; This->ref = 0; This->refn = 0; This->device = device; This->device->capture_buffer = This; This->nrofnotifies = 0; This->pdscbd = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, lpcDSCBufferDesc->dwSize); if (This->pdscbd) CopyMemory(This->pdscbd, lpcDSCBufferDesc, lpcDSCBufferDesc->dwSize); else { WARN("no memory\n"); This->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); return DSERR_OUTOFMEMORY; } This->IDirectSoundCaptureBuffer8_iface.lpVtbl = &dscbvt; This->IDirectSoundNotify_iface.lpVtbl = &dscnvt; err = IMMDevice_Activate(device->mmdevice, &IID_IAudioClient, CLSCTX_INPROC_SERVER, NULL, (void**)&device->client); if(FAILED(err)){ WARN("Activate failed: %08x\n", err); HeapFree(GetProcessHeap(), 0, This->pdscbd); This->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); return err; } err = IAudioClient_Initialize(device->client, AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_NOPERSIST, 200 * 100000, 50000, device->pwfx, NULL); if(FAILED(err)){ WARN("Initialize failed: %08x\n", err); IAudioClient_Release(device->client); device->client = NULL; HeapFree(GetProcessHeap(), 0, This->pdscbd); This->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); if(err == AUDCLNT_E_UNSUPPORTED_FORMAT) return DSERR_BADFORMAT; return err; } err = IAudioClient_GetService(device->client, &IID_IAudioCaptureClient, (void**)&device->capture); if(FAILED(err)){ WARN("GetService failed: %08x\n", err); IAudioClient_Release(device->client); device->client = NULL; HeapFree(GetProcessHeap(), 0, This->pdscbd); This->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); return err; } buflen = lpcDSCBufferDesc->dwBufferBytes; TRACE("desired buflen=%d, old buffer=%p\n", buflen, device->buffer); if (device->buffer) newbuf = HeapReAlloc(GetProcessHeap(),0,device->buffer,buflen); else newbuf = HeapAlloc(GetProcessHeap(),0,buflen); if (newbuf == NULL) { IAudioClient_Release(device->client); device->client = NULL; IAudioCaptureClient_Release(device->capture); device->capture = NULL; HeapFree(GetProcessHeap(), 0, This->pdscbd); This->device->capture_buffer = 0; HeapFree( GetProcessHeap(), 0, This ); return DSERR_OUTOFMEMORY; } device->buffer = newbuf; device->buflen = buflen; } IDirectSoundCaptureBuffer_AddRef(&This->IDirectSoundCaptureBuffer8_iface); *ppobj = This; TRACE("returning DS_OK\n"); return DS_OK; }
static int qat_engine_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)) { unsigned int retVal = 1; CpaStatus status = CPA_STATUS_SUCCESS; int flags = 0; int fd = 0; switch (cmd) { case QAT_CMD_POLL: BREAK_IF(!engine_inited, "POLL failed as engine is not initialized\n"); BREAK_IF(qat_instance_handles == NULL, "POLL failed as no instances are available\n"); BREAK_IF(!enable_external_polling, "POLL failed as external polling is not enabled\n"); BREAK_IF(p == NULL, "POLL failed as the input parameter was NULL\n"); *(int *)p = (int)poll_instances(); break; case QAT_CMD_ENABLE_EXTERNAL_POLLING: BREAK_IF(engine_inited, \ "ENABLE_EXTERNAL_POLLING failed as the engine is already initialized\n"); DEBUG("Enabled external polling\n"); enable_external_polling = 1; enable_inline_polling = 0; break; case QAT_CMD_ENABLE_INLINE_POLLING: BREAK_IF(engine_inited, \ "ENABLE_INLINE_POLLING failed as the engine is already initialized\n"); DEBUG("Enabled inline polling\n"); enable_inline_polling = 1; enable_external_polling = 0; break; case QAT_CMD_GET_EXTERNAL_POLLING_FD: BREAK_IF(!enable_event_driven_polling || !enable_external_polling, \ "GET_EXTERNAL_POLLING_FD failed as this engine message is only supported \ when running in Event Driven Mode with External Polling enabled\n"); BREAK_IF(!engine_inited, \ "GET_EXTERNAL_POLLING_FD failed as the engine is not initialized\n"); BREAK_IF(qat_instance_handles == NULL, \ "GET_EXTERNAL_POLLING_FD failed as no instances are available\n"); BREAK_IF(p == NULL, "GET_EXTERNAL_POLLING_FD failed as the input parameter was NULL\n"); BREAK_IF(i >= qat_num_instances, \ "GET_EXTERNAL_POLLING_FD failed as the instance does not exist\n"); /* Get the file descriptor for the instance */ status = icp_sal_CyGetFileDescriptor(qat_instance_handles[i], &fd); BREAK_IF(CPA_STATUS_FAIL == status, \ "GET_EXTERNAL_POLLING_FD failed as there was an error retrieving the fd\n"); /* Make the file descriptor non-blocking */ flags = fcntl(fd, F_GETFL, 0); fcntl(fd, F_SETFL, flags | O_NONBLOCK); DEBUG("External polling FD for instance[%ld] = %d\n", i, fd); *(int *)p = fd; break; case QAT_CMD_ENABLE_EVENT_DRIVEN_POLLING_MODE: DEBUG("Enabled event driven polling mode\n"); BREAK_IF(engine_inited, \ "ENABLE_EVENT_DRIVEN_POLLING_MODE failed as the engine is already initialized\n"); enable_event_driven_polling = 1; break; case QAT_CMD_DISABLE_EVENT_DRIVEN_POLLING_MODE: DEBUG("Disabled event driven polling mode\n"); BREAK_IF(engine_inited, \ "DISABLE_EVENT_DRIVEN_POLLING_MODE failed as the engine is already initialized\n"); enable_event_driven_polling = 0; break; case QAT_CMD_SET_INSTANCE_FOR_THREAD: BREAK_IF(!engine_inited, \ "SET_INSTANCE_FOR_THREAD failed as the engine is not initialized\n"); BREAK_IF(qat_instance_handles == NULL, \ "SET_INSTANCE_FOR_THREAD failed as no instances are available\n"); DEBUG("Set instance for thread = %ld\n", i); qat_set_instance_for_thread(i); break; case QAT_CMD_GET_NUM_OP_RETRIES: BREAK_IF(p == NULL, "GET_NUM_OP_RETRIES failed as the input parameter was NULL\n"); BREAK_IF(!engine_inited, "GET_NUM_OP_RETRIES failed as the engine is not initialized\n"); *(int *)p = qatPerformOpRetries; break; case QAT_CMD_SET_MAX_RETRY_COUNT: BREAK_IF(i < -1 || i > 100000, "The Message retry count value is out of range, using default value\n"); DEBUG("Set max retry counter = %ld\n", i); qat_max_retry_count = (int)i; break; case QAT_CMD_SET_INTERNAL_POLL_INTERVAL: BREAK_IF(i < 1 || i > 1000000, "The polling interval value is out of range, using default value\n"); DEBUG("Set internal poll interval = %ld ns\n", i); qat_poll_interval = (useconds_t) i; break; case QAT_CMD_SET_EPOLL_TIMEOUT: BREAK_IF(i < 1 || i > 10000, "The epoll timeout value is out of range, using default value\n") DEBUG("Set epoll_wait timeout = %ld ms\n", i); qat_epoll_timeout = (int) i; break; case QAT_CMD_GET_NUM_CRYPTO_INSTANCES: BREAK_IF(p == NULL, \ "GET_NUM_CRYPTO_INSTANCES failed as the input parameter was NULL\n"); BREAK_IF(!engine_inited, \ "GET_NUM_CRYPTO_INSTANCES failed as the engine is not initialized\n"); BREAK_IF(qat_instance_handles == NULL, \ "GET_NUM_CRYPTO_INSTANCES failed as no instances are available\n"); DEBUG("Get number of crypto instances = %d\n", qat_num_instances); *(int *)p = qat_num_instances; break; case QAT_CMD_SET_CRYPTO_SMALL_PACKET_OFFLOAD_THRESHOLD: #ifndef OPENSSL_ENABLE_QAT_SMALL_PACKET_CIPHER_OFFLOADS if(p) { char *token; char str_p[1024]; char *itr = str_p; strncpy(str_p, (const char *)p, 1024); while((token = strsep(&itr, ","))) { char *name_token = strsep(&token,":"); char *value_token = strsep(&token,":"); if(name_token && value_token) { retVal = qat_pkt_threshold_table_set_threshold( name_token, atoi(value_token)); } else { WARN("Invalid name_token or value_token\n"); retVal = 0; } } } else { WARN("Invalid p parameter\n"); retVal = 0; } #else WARN("QAT_CMD_SET_CRYPTO_SMALL_PACKET_OFFLOAD_THRESHOLD is not supported\n"); retVal = 0; #endif break; default: WARN("CTRL command not implemented\n"); retVal = 0; break; } if(!retVal) { QATerr(QAT_F_QAT_ENGINE_CTRL, QAT_R_ENGINE_CTRL_CMD_FAILURE); } return retVal; }
/****************************************************************************** * function: * bind_qat(ENGINE *e, * const char *id) * * @param e [IN] - OpenSSL engine pointer * @param id [IN] - engine id * * description: * Connect Qat engine to OpenSSL engine library ******************************************************************************/ static int bind_qat(ENGINE *e, const char *id) { int ret = 0; #ifndef OPENSSL_ENABLE_QAT_UPSTREAM_DRIVER int upstream_flags = 0; unsigned int devmasks[] = { 0, 0, 0, 0, 0 }; #endif QAT_DEBUG_LOG_INIT(); WARN("QAT Warnings enabled.\n"); DEBUG("QAT Debug enabled.\n"); DEBUG("id=%s\n", id); if (access(QAT_DEV, F_OK) != 0) { WARN("Qat memory driver not present\n"); QATerr(QAT_F_BIND_QAT, QAT_R_MEM_DRV_NOT_PRESENT); goto end; } #ifndef OPENSSL_ENABLE_QAT_UPSTREAM_DRIVER if (!getDevices(devmasks, &upstream_flags)) { WARN("Qat device not present\n"); QATerr(QAT_F_BIND_QAT, QAT_R_QAT_DEV_NOT_PRESENT); goto end; } #endif if (id && (strcmp(id, engine_qat_id) != 0)) { WARN("ENGINE_id defined already!\n"); QATerr(QAT_F_BIND_QAT, QAT_R_ENGINE_ID_ALREADY_DEFINED); goto end; } if (!ENGINE_set_id(e, engine_qat_id)) { WARN("ENGINE_set_id failed\n"); QATerr(QAT_F_BIND_QAT, QAT_R_ENGINE_SET_ID_FAILURE); goto end; } if (!ENGINE_set_name(e, engine_qat_name)) { WARN("ENGINE_set_name failed\n"); QATerr(QAT_F_BIND_QAT, QAT_R_ENGINE_SET_NAME_FAILURE); goto end; } /* Ensure the QAT error handling is set up */ ERR_load_QAT_strings(); /* * Create static structures for ciphers now * as this function will be called by a single thread. */ qat_create_ciphers(); if (!ENGINE_set_RSA(e, qat_get_RSA_methods())) { WARN("ENGINE_set_RSA failed\n"); QATerr(QAT_F_BIND_QAT, QAT_R_ENGINE_SET_RSA_FAILURE); goto end; } if (!ENGINE_set_DSA(e, qat_get_DSA_methods())) { WARN("ENGINE_set_DSA failed\n"); QATerr(QAT_F_BIND_QAT, QAT_R_ENGINE_SET_DSA_FAILURE); goto end; } if (!ENGINE_set_DH(e, qat_get_DH_methods())) { WARN("ENGINE_set_DH failed\n"); QATerr(QAT_F_BIND_QAT, QAT_R_ENGINE_SET_DH_FAILURE); goto end; } if (!ENGINE_set_EC(e, qat_get_EC_methods())) { WARN("ENGINE_set_EC failed\n"); QATerr(QAT_F_BIND_QAT, QAT_R_ENGINE_SET_EC_FAILURE); goto end; } if (!ENGINE_set_ciphers(e, qat_ciphers)) { WARN("ENGINE_set_ciphers failed\n"); QATerr(QAT_F_BIND_QAT, QAT_R_ENGINE_SET_CIPHER_FAILURE); goto end; } if (!ENGINE_set_pkey_meths(e, qat_PRF_pkey_methods)) { WARN("ENGINE_set_pkey_meths failed\n"); QATerr(QAT_F_BIND_QAT, QAT_R_ENGINE_SET_PKEY_FAILURE); goto end; } pthread_atfork(engine_finish_before_fork_handler, NULL, engine_init_child_at_fork_handler); ret = 1; ret &= ENGINE_set_destroy_function(e, qat_engine_destroy); ret &= ENGINE_set_init_function(e, qat_engine_init); ret &= ENGINE_set_finish_function(e, qat_engine_finish); ret &= ENGINE_set_ctrl_function(e, qat_engine_ctrl); ret &= ENGINE_set_cmd_defns(e, qat_cmd_defns); if (ret == 0) { WARN("Engine failed to register init, finish or destroy functions\n"); QATerr(QAT_F_BIND_QAT, QAT_R_ENGINE_REGISTER_FUNC_FAILURE); } end: return ret; }
static void assert_device_not_suspended(struct drm_i915_private *dev_priv) { WARN(HAS_RUNTIME_PM(dev_priv->dev) && dev_priv->pm.suspended, "Device suspended\n"); }
/****************************************************************************** * DnsQueryConfig [DNSAPI.@] * */ DNS_STATUS WINAPI DnsQueryConfig( DNS_CONFIG_TYPE config, DWORD flag, PCWSTR adapter, PVOID reserved, PVOID buffer, PDWORD len ) { DNS_STATUS ret = ERROR_INVALID_PARAMETER; TRACE( "(%d,0x%08x,%s,%p,%p,%p)\n", config, flag, debugstr_w(adapter), reserved, buffer, len ); if (!len) return ERROR_INVALID_PARAMETER; switch (config) { case DnsConfigDnsServerList: { #ifdef HAVE_RESOLV initialise_resolver(); ret = dns_get_serverlist( buffer, len ); break; #else WARN( "compiled without resolver support\n" ); break; #endif } case DnsConfigHostName_A: case DnsConfigHostName_UTF8: return dns_get_hostname_a( ComputerNameDnsHostname, buffer, len ); case DnsConfigFullHostName_A: case DnsConfigFullHostName_UTF8: return dns_get_hostname_a( ComputerNameDnsFullyQualified, buffer, len ); case DnsConfigPrimaryDomainName_A: case DnsConfigPrimaryDomainName_UTF8: return dns_get_hostname_a( ComputerNameDnsDomain, buffer, len ); case DnsConfigHostName_W: return dns_get_hostname_w( ComputerNameDnsHostname, buffer, len ); case DnsConfigFullHostName_W: return dns_get_hostname_w( ComputerNameDnsFullyQualified, buffer, len ); case DnsConfigPrimaryDomainName_W: return dns_get_hostname_w( ComputerNameDnsDomain, buffer, len ); case DnsConfigAdapterDomainName_A: case DnsConfigAdapterDomainName_W: case DnsConfigAdapterDomainName_UTF8: case DnsConfigSearchList: case DnsConfigAdapterInfo: case DnsConfigPrimaryHostNameRegistrationEnabled: case DnsConfigAdapterHostNameRegistrationEnabled: case DnsConfigAddressRegistrationMaxCount: FIXME( "unimplemented config type %d\n", config ); break; default: WARN( "unknown config type: %d\n", config ); break; } return ret; }
/** * @brief Make an HTTP GET or POST request using a connected client with no HTTP BODY * * This function is used to make a GET or POST request using @p client to the uri of the client's * #Azy_Net object (azy_net_get(client)) using HTTP method @p type, content-type * defined by @p transport, and the optional deserialization function specified by @p cb. * @param client The client (NOT #NULL) * @param type The HTTP method to use (NOT #NULL) * @param netdata The HTTP BODY to send with a POST * @param cb The deserialization callback to use for the response * @param data The user data to be passed to resulting callbacks * @return The #Azy_Client_Call_Id of the transmission, to be used with azy_client_callback_set, * or 0 on failure */ Azy_Client_Call_Id azy_client_blank(Azy_Client *client, Azy_Net_Type type, Azy_Net_Data *netdata, Azy_Content_Cb cb, void *data) { Eina_Strbuf *msg; Azy_Client_Handler_Data *hd; DBG("(client=%p, net=%p)", client, client->net); if (!AZY_MAGIC_CHECK(client, AZY_MAGIC_CLIENT)) { AZY_MAGIC_FAIL(client, AZY_MAGIC_CLIENT); return 0; } EINA_SAFETY_ON_NULL_RETURN_VAL(client->net, 0); EINA_SAFETY_ON_TRUE_RETURN_VAL((type != AZY_NET_TYPE_GET) && (type != AZY_NET_TYPE_POST), 0); while (++azy_client_send_id__ < 1) ; client->net->type = type; if (!client->net->http.req.http_path) { WARN("NULL URI passed, defaulting to \"/\""); azy_net_uri_set(client->net, "/"); } if (netdata && netdata->size && (type == AZY_NET_TYPE_POST)) azy_net_message_length_set(client->net, netdata->size); msg = azy_net_header_create(client->net); EINA_SAFETY_ON_NULL_GOTO(msg, error); #ifdef ISCOMFITOR char buf[64]; snprintf(buf, sizeof(buf), "\nSENDING >>>>>>>>>>>>>>>>>>>>>>>>\n%%.%zus\n>>>>>>>>>>>>>>>>>>>>>>>>", eina_strbuf_length_get(msg)); DBG(buf, eina_strbuf_string_get(msg)); #endif EINA_SAFETY_ON_TRUE_GOTO(!ecore_con_server_send(client->net->conn, eina_strbuf_string_get(msg), eina_strbuf_length_get(msg)), error); if (netdata && netdata->size && (type == AZY_NET_TYPE_POST)) { INFO("Send [1/2] complete! %zu bytes queued for sending.", eina_strbuf_length_get(msg)); EINA_SAFETY_ON_TRUE_GOTO(!ecore_con_server_send(client->net->conn, netdata->data, netdata->size), error); INFO("Send [2/2] complete! %" PRIi64 " bytes queued for sending.", netdata->size); } else INFO("Send [1/1] complete! %zu bytes queued for sending.", eina_strbuf_length_get(msg)); eina_strbuf_free(msg); msg = NULL; ecore_con_server_flush(client->net->conn); hd = calloc(1, sizeof(Azy_Client_Handler_Data)); EINA_SAFETY_ON_NULL_RETURN_VAL(hd, 0); hd->client = client; hd->callback = cb; hd->type = type; hd->content_data = data; if (netdata && netdata->size && (type == AZY_NET_TYPE_POST)) { hd->send = eina_strbuf_new(); eina_strbuf_append_length(hd->send, (char *)netdata->data, netdata->size); } hd->id = azy_client_send_id__; AZY_MAGIC_SET(hd, AZY_MAGIC_CLIENT_DATA_HANDLER); if (!client->conns) { client->recv = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb)_azy_client_handler_data, hd); ecore_con_server_data_set(client->net->conn, client); } client->conns = eina_list_append(client->conns, hd); DBG("(client=%p, net=%p, hd=%p)", client, client->net, hd); return azy_client_send_id__; error: if (msg) eina_strbuf_free(msg); return 0; }
static struct iwl_op_mode * iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg, const struct iwl_fw *fw, struct dentry *dbgfs_dir) { struct ieee80211_hw *hw; struct iwl_op_mode *op_mode; struct iwl_mvm *mvm; struct iwl_trans_config trans_cfg = {}; static const u8 no_reclaim_cmds[] = { TX_CMD, }; int err, scan_size; u32 min_backoff; /* * We use IWL_MVM_STATION_COUNT to check the validity of the station * index all over the driver - check that its value corresponds to the * array size. */ BUILD_BUG_ON(ARRAY_SIZE(mvm->fw_id_to_mac_id) != IWL_MVM_STATION_COUNT); /******************************** * 1. Allocating and configuring HW data ********************************/ hw = ieee80211_alloc_hw(sizeof(struct iwl_op_mode) + sizeof(struct iwl_mvm), &iwl_mvm_hw_ops); if (!hw) return NULL; if (cfg->max_rx_agg_size) hw->max_rx_aggregation_subframes = cfg->max_rx_agg_size; if (cfg->max_tx_agg_size) hw->max_tx_aggregation_subframes = cfg->max_tx_agg_size; op_mode = hw->priv; op_mode->ops = &iwl_mvm_ops; mvm = IWL_OP_MODE_GET_MVM(op_mode); mvm->dev = trans->dev; mvm->trans = trans; mvm->cfg = cfg; mvm->fw = fw; mvm->hw = hw; mvm->restart_fw = iwlwifi_mod_params.restart_fw ? -1 : 0; mvm->aux_queue = 15; mvm->first_agg_queue = 16; mvm->last_agg_queue = mvm->cfg->base_params->num_of_queues - 1; if (mvm->cfg->base_params->num_of_queues == 16) { mvm->aux_queue = 11; mvm->first_agg_queue = 12; } mvm->sf_state = SF_UNINIT; mvm->low_latency_agg_frame_limit = 6; mvm->cur_ucode = IWL_UCODE_INIT; mutex_init(&mvm->mutex); mutex_init(&mvm->d0i3_suspend_mutex); spin_lock_init(&mvm->async_handlers_lock); INIT_LIST_HEAD(&mvm->time_event_list); INIT_LIST_HEAD(&mvm->aux_roc_te_list); INIT_LIST_HEAD(&mvm->async_handlers_list); spin_lock_init(&mvm->time_event_lock); mvm->workqueue = create_singlethread_workqueue(DRV_NAME); if (!mvm->workqueue) { ieee80211_free_hw(mvm->hw); return NULL; } INIT_WORK(&mvm->async_handlers_wk, iwl_mvm_async_handlers_wk); INIT_WORK(&mvm->roc_done_wk, iwl_mvm_roc_done_wk); INIT_WORK(&mvm->sta_drained_wk, iwl_mvm_sta_drained_wk); INIT_WORK(&mvm->d0i3_exit_work, iwl_mvm_d0i3_exit_work); INIT_DELAYED_WORK(&mvm->fw_dump_wk, iwl_mvm_fw_error_dump_wk); INIT_DELAYED_WORK(&mvm->tdls_cs.dwork, iwl_mvm_tdls_ch_switch_work); spin_lock_init(&mvm->d0i3_tx_lock); spin_lock_init(&mvm->refs_lock); skb_queue_head_init(&mvm->d0i3_tx); init_waitqueue_head(&mvm->d0i3_exit_waitq); SET_IEEE80211_DEV(mvm->hw, mvm->trans->dev); /* * Populate the state variables that the transport layer needs * to know about. */ trans_cfg.op_mode = op_mode; trans_cfg.no_reclaim_cmds = no_reclaim_cmds; trans_cfg.n_no_reclaim_cmds = ARRAY_SIZE(no_reclaim_cmds); trans_cfg.rx_buf_size_8k = iwlwifi_mod_params.amsdu_size_8K; if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_DW_BC_TABLE) trans_cfg.bc_table_dword = true; trans_cfg.command_names = iwl_mvm_cmd_strings; trans_cfg.cmd_queue = IWL_MVM_CMD_QUEUE; trans_cfg.cmd_fifo = IWL_MVM_TX_FIFO_CMD; trans_cfg.scd_set_active = true; trans_cfg.sdio_adma_addr = fw->sdio_adma_addr; /* Set a short watchdog for the command queue */ trans_cfg.cmd_q_wdg_timeout = iwl_mvm_get_wd_timeout(mvm, NULL, false, true); snprintf(mvm->hw->wiphy->fw_version, sizeof(mvm->hw->wiphy->fw_version), "%s", fw->fw_version); /* Configure transport layer */ iwl_trans_configure(mvm->trans, &trans_cfg); trans->rx_mpdu_cmd = REPLY_RX_MPDU_CMD; trans->rx_mpdu_cmd_hdr_size = sizeof(struct iwl_rx_mpdu_res_start); trans->dbg_dest_tlv = mvm->fw->dbg_dest_tlv; trans->dbg_dest_reg_num = mvm->fw->dbg_dest_reg_num; memcpy(trans->dbg_conf_tlv, mvm->fw->dbg_conf_tlv, sizeof(trans->dbg_conf_tlv)); trans->dbg_trigger_tlv = mvm->fw->dbg_trigger_tlv; /* set up notification wait support */ iwl_notification_wait_init(&mvm->notif_wait); /* Init phy db */ mvm->phy_db = iwl_phy_db_init(trans); if (!mvm->phy_db) { IWL_ERR(mvm, "Cannot init phy_db\n"); goto out_free; } IWL_INFO(mvm, "Detected %s, REV=0x%X\n", mvm->cfg->name, mvm->trans->hw_rev); min_backoff = calc_min_backoff(trans, cfg); iwl_mvm_tt_initialize(mvm, min_backoff); /* set the nvm_file_name according to priority */ if (iwlwifi_mod_params.nvm_file) { mvm->nvm_file_name = iwlwifi_mod_params.nvm_file; } else if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000) { if (CSR_HW_REV_STEP(trans->hw_rev) == SILICON_B_STEP) mvm->nvm_file_name = mvm->cfg->default_nvm_file_B_step; else mvm->nvm_file_name = mvm->cfg->default_nvm_file_C_step; } if (WARN(cfg->no_power_up_nic_in_init && !mvm->nvm_file_name, "not allowing power-up and not having nvm_file\n")) goto out_free; /* * Even if nvm exists in the nvm_file driver should read again the nvm * from the nic because there might be entries that exist in the OTP * and not in the file. * for nics with no_power_up_nic_in_init: rely completley on nvm_file */ if (cfg->no_power_up_nic_in_init && mvm->nvm_file_name) { err = iwl_nvm_init(mvm, false); if (err) goto out_free; } else { err = iwl_trans_start_hw(mvm->trans); if (err) goto out_free; mutex_lock(&mvm->mutex); err = iwl_run_init_mvm_ucode(mvm, true); if (!err || !iwlmvm_mod_params.init_dbg) iwl_trans_stop_device(trans); mutex_unlock(&mvm->mutex); /* returns 0 if successful, 1 if success but in rfkill */ if (err < 0 && !iwlmvm_mod_params.init_dbg) { IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", err); goto out_free; } } scan_size = iwl_mvm_scan_size(mvm); mvm->scan_cmd = kmalloc(scan_size, GFP_KERNEL); if (!mvm->scan_cmd) goto out_free; /* Set EBS as successful as long as not stated otherwise by the FW. */ mvm->last_ebs_successful = true; err = iwl_mvm_mac_setup_register(mvm); if (err) goto out_free; err = iwl_mvm_dbgfs_register(mvm, dbgfs_dir); if (err) goto out_unregister; memset(&mvm->rx_stats, 0, sizeof(struct mvm_statistics_rx)); /* rpm starts with a taken ref. only set the appropriate bit here. */ mvm->refs[IWL_MVM_REF_UCODE_DOWN] = 1; return op_mode; out_unregister: ieee80211_unregister_hw(mvm->hw); iwl_mvm_leds_exit(mvm); out_free: iwl_phy_db_free(mvm->phy_db); kfree(mvm->scan_cmd); if (!cfg->no_power_up_nic_in_init || !mvm->nvm_file_name) iwl_trans_op_mode_leave(trans); destroy_workqueue(mvm->workqueue); ieee80211_free_hw(mvm->hw); return NULL; }
/** * @brief Make a method call using a connected client * * This function is used to make a method call on @p client as defined in * @p content, using content-type defined by @p transport and the deserialization * function specified by @p cb. This should generally not be used by users, as azy_parser * will automatically generate the correct calls from a .azy file. * @param client The client (NOT #NULL) * @param content The content containing the method name and parameters (NOT #NULL) * @param transport The content-type (xml/json/etc) to use * @param cb The deserialization callback to use for the response * @return The #Azy_Client_Call_Id of the transmission, to be used with azy_client_callback_set, * or 0 on failure */ Azy_Client_Call_Id azy_client_call(Azy_Client *client, Azy_Content *content, Azy_Net_Transport transport, Azy_Content_Cb cb) { Eina_Strbuf *msg; Azy_Client_Handler_Data *hd; DBG("(client=%p, net=%p, content=%p)", client, client->net, content); if (!AZY_MAGIC_CHECK(client, AZY_MAGIC_CLIENT)) { AZY_MAGIC_FAIL(client, AZY_MAGIC_CLIENT); return 0; } EINA_SAFETY_ON_NULL_RETURN_VAL(client->net, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(content, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(content->method, 0); INFO("New method call: '%s'", content->method); while (++azy_client_send_id__ < 1) ; content->id = azy_client_send_id__; azy_net_transport_set(client->net, transport); if (!azy_content_serialize_request(content, transport)) return 0; azy_net_type_set(client->net, AZY_NET_TYPE_POST); if (!client->net->http.req.http_path) { WARN("URI currently set to NULL, defaulting to \"/\""); azy_net_uri_set(client->net, "/"); } azy_net_message_length_set(client->net, content->length); msg = azy_net_header_create(client->net); EINA_SAFETY_ON_NULL_GOTO(msg, error); if (azy_rpc_log_dom >= 0) { char buf[64]; snprintf(buf, sizeof(buf), "\nSENDING >>>>>>>>>>>>>>>>>>>>>>>>\n%%.%is%%.%llis\n>>>>>>>>>>>>>>>>>>>>>>>>", eina_strbuf_length_get(msg), content->length); RPC_DBG(buf, eina_strbuf_string_get(msg), content->buffer); } EINA_SAFETY_ON_TRUE_GOTO(!ecore_con_server_send(client->net->conn, eina_strbuf_string_get(msg), eina_strbuf_length_get(msg)), error); INFO("Send [1/2] complete! %zu bytes queued for sending.", eina_strbuf_length_get(msg)); eina_strbuf_free(msg); msg = NULL; EINA_SAFETY_ON_TRUE_GOTO(!ecore_con_server_send(client->net->conn, content->buffer, content->length), error); INFO("Send [2/2] complete! %lli bytes queued for sending.", content->length); ecore_con_server_flush(client->net->conn); hd = calloc(1, sizeof(Azy_Client_Handler_Data)); EINA_SAFETY_ON_NULL_RETURN_VAL(hd, 0); hd->client = client; hd->method = eina_stringshare_ref(content->method); hd->callback = cb; hd->type = AZY_NET_TYPE_POST; hd->content_data = content->data; hd->send = eina_strbuf_new(); eina_strbuf_append_length(hd->send, (char *)content->buffer, content->length); hd->id = azy_client_send_id__; AZY_MAGIC_SET(hd, AZY_MAGIC_CLIENT_DATA_HANDLER); if (!client->conns) { client->recv = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb)_azy_client_handler_data, hd); ecore_con_server_data_set(client->net->conn, client); } client->conns = eina_list_append(client->conns, hd); DBG("(client=%p, net=%p, content=%p, hd=%p)", client, client->net, content, hd); return azy_client_send_id__; error: if (msg) eina_strbuf_free(msg); return 0; }
static HRESULT HttpProtocol_start_downloading(Protocol *prot) { HttpProtocol *This = impl_from_Protocol(prot); LPWSTR content_type, content_length, ranges; DWORD len = sizeof(DWORD); DWORD status_code; BOOL res; HRESULT hres; static const WCHAR wszDefaultContentType[] = {'t','e','x','t','/','h','t','m','l',0}; if(!This->http_negotiate) { WARN("Expected IHttpNegotiate pointer to be non-NULL\n"); return S_OK; } res = HttpQueryInfoW(This->base.request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status_code, &len, NULL); if(res) { LPWSTR response_headers = query_http_info(This, HTTP_QUERY_RAW_HEADERS_CRLF); if(response_headers) { hres = IHttpNegotiate_OnResponse(This->http_negotiate, status_code, response_headers, NULL, NULL); heap_free(response_headers); if (hres != S_OK) { WARN("IHttpNegotiate_OnResponse failed: %08x\n", hres); return S_OK; } } }else { WARN("HttpQueryInfo failed: %d\n", GetLastError()); } ranges = query_http_info(This, HTTP_QUERY_ACCEPT_RANGES); if(ranges) { IInternetProtocolSink_ReportProgress(This->base.protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL); heap_free(ranges); } content_type = query_http_info(This, HTTP_QUERY_CONTENT_TYPE); if(content_type) { /* remove the charset, if present */ LPWSTR p = strchrW(content_type, ';'); if (p) *p = '\0'; IInternetProtocolSink_ReportProgress(This->base.protocol_sink, (This->base.bindf & BINDF_FROMURLMON) ? BINDSTATUS_MIMETYPEAVAILABLE : BINDSTATUS_RAWMIMETYPE, content_type); heap_free(content_type); }else { WARN("HttpQueryInfo failed: %d\n", GetLastError()); IInternetProtocolSink_ReportProgress(This->base.protocol_sink, (This->base.bindf & BINDF_FROMURLMON) ? BINDSTATUS_MIMETYPEAVAILABLE : BINDSTATUS_RAWMIMETYPE, wszDefaultContentType); } content_length = query_http_info(This, HTTP_QUERY_CONTENT_LENGTH); if(content_length) { This->base.content_length = atoiW(content_length); heap_free(content_length); } return S_OK; }
static HRESULT HttpProtocol_open_request(Protocol *prot, IUri *uri, DWORD request_flags, HINTERNET internet_session, IInternetBindInfo *bind_info) { HttpProtocol *This = impl_from_Protocol(prot); LPWSTR addl_header = NULL, post_cookie = NULL; IServiceProvider *service_provider = NULL; IHttpNegotiate2 *http_negotiate2 = NULL; BSTR url, host, user, pass, path; LPOLESTR accept_mimes[257]; const WCHAR **accept_types; BYTE security_id[512]; DWORD len, port, flags; ULONG num, error; BOOL res, b; HRESULT hres; static const WCHAR wszBindVerb[BINDVERB_CUSTOM][5] = {{'G','E','T',0}, {'P','O','S','T',0}, {'P','U','T',0}}; hres = IUri_GetPort(uri, &port); if(FAILED(hres)) return hres; hres = IUri_GetHost(uri, &host); if(FAILED(hres)) return hres; hres = IUri_GetUserName(uri, &user); if(SUCCEEDED(hres)) { hres = IUri_GetPassword(uri, &pass); if(SUCCEEDED(hres)) { This->base.connection = InternetConnectW(internet_session, host, port, user, pass, INTERNET_SERVICE_HTTP, This->https ? INTERNET_FLAG_SECURE : 0, (DWORD_PTR)&This->base); SysFreeString(pass); } SysFreeString(user); } SysFreeString(host); if(FAILED(hres)) return hres; if(!This->base.connection) { WARN("InternetConnect failed: %d\n", GetLastError()); return INET_E_CANNOT_CONNECT; } num = sizeof(accept_mimes)/sizeof(accept_mimes[0])-1; hres = IInternetBindInfo_GetBindString(bind_info, BINDSTRING_ACCEPT_MIMES, accept_mimes, num, &num); if(hres == INET_E_USE_DEFAULT_SETTING) { static const WCHAR default_accept_mimeW[] = {'*','/','*',0}; static const WCHAR *default_accept_mimes[] = {default_accept_mimeW, NULL}; accept_types = default_accept_mimes; num = 0; }else if(hres == S_OK) { accept_types = (const WCHAR**)accept_mimes; }else { WARN("GetBindString BINDSTRING_ACCEPT_MIMES failed: %08x\n", hres); return INET_E_NO_VALID_MEDIA; } accept_mimes[num] = 0; if(This->https) request_flags |= INTERNET_FLAG_SECURE; hres = IUri_GetPathAndQuery(uri, &path); if(SUCCEEDED(hres)) { This->base.request = HttpOpenRequestW(This->base.connection, This->base.bind_info.dwBindVerb < BINDVERB_CUSTOM ? wszBindVerb[This->base.bind_info.dwBindVerb] : This->base.bind_info.szCustomVerb, path, NULL, NULL, accept_types, request_flags, (DWORD_PTR)&This->base); SysFreeString(path); } while(num--) CoTaskMemFree(accept_mimes[num]); if(FAILED(hres)) return hres; if (!This->base.request) { WARN("HttpOpenRequest failed: %d\n", GetLastError()); return INET_E_RESOURCE_NOT_FOUND; } hres = IInternetProtocolSink_QueryInterface(This->base.protocol_sink, &IID_IServiceProvider, (void **)&service_provider); if (hres != S_OK) { WARN("IInternetProtocolSink_QueryInterface IID_IServiceProvider failed: %08x\n", hres); return hres; } hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate, &IID_IHttpNegotiate, (void **)&This->http_negotiate); if (hres != S_OK) { WARN("IServiceProvider_QueryService IID_IHttpNegotiate failed: %08x\n", hres); IServiceProvider_Release(service_provider); return hres; } hres = IUri_GetAbsoluteUri(uri, &url); if(FAILED(hres)) { IServiceProvider_Release(service_provider); return hres; } hres = IHttpNegotiate_BeginningTransaction(This->http_negotiate, url, default_headersW, 0, &addl_header); SysFreeString(url); if(hres != S_OK) { WARN("IHttpNegotiate_BeginningTransaction failed: %08x\n", hres); IServiceProvider_Release(service_provider); return hres; } len = addl_header ? strlenW(addl_header) : 0; This->full_header = heap_alloc(len*sizeof(WCHAR)+sizeof(default_headersW)); if(!This->full_header) { IServiceProvider_Release(service_provider); return E_OUTOFMEMORY; } if(len) memcpy(This->full_header, addl_header, len*sizeof(WCHAR)); CoTaskMemFree(addl_header); memcpy(This->full_header+len, default_headersW, sizeof(default_headersW)); hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2, (void **)&http_negotiate2); IServiceProvider_Release(service_provider); if(hres != S_OK) { WARN("IServiceProvider_QueryService IID_IHttpNegotiate2 failed: %08x\n", hres); /* No goto done as per native */ }else { len = sizeof(security_id)/sizeof(security_id[0]); hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, security_id, &len, 0); IHttpNegotiate2_Release(http_negotiate2); if (hres != S_OK) WARN("IHttpNegotiate2_GetRootSecurityId failed: %08x\n", hres); } /* FIXME: Handle security_id. Native calls undocumented function IsHostInProxyBypassList. */ if(This->base.bind_info.dwBindVerb == BINDVERB_POST) { num = 0; hres = IInternetBindInfo_GetBindString(bind_info, BINDSTRING_POST_COOKIE, &post_cookie, 1, &num); if(hres == S_OK && num) { if(!InternetSetOptionW(This->base.request, INTERNET_OPTION_SECONDARY_CACHE_KEY, post_cookie, lstrlenW(post_cookie))) WARN("InternetSetOption INTERNET_OPTION_SECONDARY_CACHE_KEY failed: %d\n", GetLastError()); CoTaskMemFree(post_cookie); } } flags = INTERNET_ERROR_MASK_COMBINED_SEC_CERT; res = InternetSetOptionW(This->base.request, INTERNET_OPTION_ERROR_MASK, &flags, sizeof(flags)); if(!res) WARN("InternetSetOption(INTERNET_OPTION_ERROR_MASK) failed: %u\n", GetLastError()); b = TRUE; res = InternetSetOptionW(This->base.request, INTERNET_OPTION_HTTP_DECODING, &b, sizeof(b)); if(!res) WARN("InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %u\n", GetLastError()); do { error = send_http_request(This); switch(error) { case ERROR_IO_PENDING: return S_OK; case ERROR_SUCCESS: /* * If sending response ended synchronously, it means that we have the whole data * available locally (most likely in cache). */ return protocol_syncbinding(&This->base); default: hres = handle_http_error(This, error); } } while(hres == RPC_E_RETRY); WARN("HttpSendRequest failed: %d\n", error); return hres; }
char * __tar_get_dir_contents (char *p, int device) { DIR *dirp; register struct dirent *d; char *new_buf; char *namebuf; int bufsiz; int len; voidstar the_buffer; char *buf; size_t n_strs; #if 0 int n_size; #endif char *p_buf; char **vec, **p_vec; errno = 0; dirp = opendir (p); bufsiz = strlen (p) + NAMSIZ; namebuf = tar_xmalloc ((size_t) (bufsiz + 2)); if (!dirp) { ERROR ((0, errno, _("Cannot open directory %s"), p)); new_buf = NULL; } else { struct dirname *dp; int all_children; dp = __tar_get_dir (p); all_children = dp ? dp->allnew : 0; strcpy (namebuf, p); if (p[strlen (p) - 1] != '/') strcat (namebuf, "/"); len = strlen (namebuf); the_buffer = __tar_init_buffer (); while (d = readdir (dirp), d) { struct stat hs; /* Skip `.' and `..'. */ if (__tar_is_dot_or_dotdot (d->d_name)) continue; if ((int) NAMLEN (d) + len >= bufsiz) { bufsiz += NAMSIZ; namebuf = (char *) tar_realloc (namebuf, (size_t) (bufsiz + 2)); } strcpy (namebuf + len, d->d_name); #ifdef AIX if (flag_follow_links ? statx (namebuf, &hs, STATSIZE, STX_HIDDEN) : statx (namebuf, &hs, STATSIZE, STX_HIDDEN | STX_LINK)) #else if (flag_follow_links ? stat (namebuf, &hs) : lstat (namebuf, &hs)) #endif { ERROR ((0, errno, _("Cannot stat %s"), namebuf)); continue; } if ((flag_local_filesys && device != hs.st_dev) || (flag_exclude && __tar_check_exclude (namebuf))) __tar_add_buffer (the_buffer, "N", 1); #ifdef AIX else if (S_ISHIDDEN (hs.st_mode)) { __tar_add_buffer (the_buffer, "D", 1); strcat (d->d_name, "A"); d->d_namlen++; } #endif /* AIX */ else if (S_ISDIR (hs.st_mode)) { if (dp = __tar_get_dir (namebuf), dp) { if (dp->dev != hs.st_dev || dp->ino != hs.st_ino) { if (flag_verbose) WARN ((0, 0, _("Directory %s has been renamed"), namebuf)); dp->allnew = 1; dp->dev = hs.st_dev; dp->ino = hs.st_ino; } dp->dir_text = ""; } else { if (flag_verbose) WARN ((0, 0, _("Directory %s is new"), namebuf)); __tar_add_dir (namebuf, hs.st_dev, hs.st_ino, ""); dp = __tar_get_dir (namebuf); dp->allnew = 1; } if (all_children && dp) dp->allnew = 1; __tar_add_buffer (the_buffer, "D", 1); } else if (!all_children && flag_new_files && new_time > hs.st_mtime && (flag_new_files > 1 || new_time > hs.st_ctime)) __tar_add_buffer (the_buffer, "N", 1); else __tar_add_buffer (the_buffer, "Y", 1); __tar_add_buffer (the_buffer, d->d_name, (int) (NAMLEN (d) + 1)); } __tar_add_buffer (the_buffer, "\000\000", 2); closedir (dirp); /* Well, we've read in the contents of the dir, now sort them. */ buf = __tar_get_buffer (the_buffer); if (buf[0] == '\0') { __tar_flush_buffer (the_buffer); new_buf = NULL; } else { n_strs = 0; for (p_buf = buf; *p_buf;) { int tmp; tmp = strlen (p_buf) + 1; n_strs++; p_buf += tmp; } vec = (char **) tar_xmalloc (sizeof (char *) * (n_strs + 1)); for (p_vec = vec, p_buf = buf; *p_buf; p_buf += strlen (p_buf) + 1) *p_vec++ = p_buf; *p_vec = 0; qsort ((voidstar) vec, n_strs, sizeof (char *), __tar_dirent_cmp); new_buf = (char *) tar_xmalloc ((size_t) (p_buf - buf + 2)); for (p_vec = vec, p_buf = new_buf; *p_vec; p_vec++) { char *p_tmp; for (p_tmp = *p_vec; (*p_buf++ = *p_tmp++); ) ; } *p_buf++ = '\0'; free (vec); __tar_flush_buffer (the_buffer); } } free (namebuf); return new_buf; }
static HRESULT activate_inplace(WebBrowser *This, IOleClientSite *active_site) { HWND parent_hwnd; HRESULT hres; if(This->inplace) return S_OK; if(!active_site) return E_INVALIDARG; hres = IOleClientSite_QueryInterface(active_site, &IID_IOleInPlaceSite, (void**)&This->inplace); if(FAILED(hres)) { WARN("Could not get IOleInPlaceSite\n"); return hres; } hres = IOleInPlaceSite_CanInPlaceActivate(This->inplace); if(hres != S_OK) { WARN("CanInPlaceActivate returned: %08x\n", hres); IOleInPlaceSite_Release(This->inplace); This->inplace = NULL; return E_FAIL; } hres = IOleInPlaceSite_GetWindow(This->inplace, &parent_hwnd); if(SUCCEEDED(hres)) SHSetParentHwnd(This->shell_embedding_hwnd, parent_hwnd); IOleInPlaceSite_OnInPlaceActivate(This->inplace); This->frameinfo.cb = sizeof(OLEINPLACEFRAMEINFO); IOleInPlaceSite_GetWindowContext(This->inplace, &This->doc_host.frame, &This->uiwindow, &This->pos_rect, &This->clip_rect, &This->frameinfo); SetWindowPos(This->shell_embedding_hwnd, NULL, This->pos_rect.left, This->pos_rect.top, This->pos_rect.right-This->pos_rect.left, This->pos_rect.bottom-This->pos_rect.top, SWP_NOZORDER | SWP_SHOWWINDOW); if(This->client) { IOleContainer *container; IOleClientSite_ShowObject(This->client); hres = IOleClientSite_GetContainer(This->client, &container); if(SUCCEEDED(hres)) { if(This->container) IOleContainer_Release(This->container); This->container = container; } } if(This->doc_host.frame) IOleInPlaceFrame_GetWindow(This->doc_host.frame, &This->frame_hwnd); return S_OK; }
int qat_engine_init(ENGINE *e) { int instNum, err; CpaStatus status = CPA_STATUS_SUCCESS; CpaBoolean limitDevAccess = CPA_FALSE; int ret_pthread_sigmask; pthread_mutex_lock(&qat_engine_mutex); if(engine_inited) { pthread_mutex_unlock(&qat_engine_mutex); return 1; } DEBUG("QAT Engine initialization:\n"); DEBUG("- External polling: %s\n", enable_external_polling ? "ON": "OFF"); DEBUG("- Inline polling: %s\n", enable_inline_polling ? "ON": "OFF"); DEBUG("- Internal poll interval: %dns\n", qat_poll_interval); DEBUG("- Epoll timeout: %dms\n", qat_epoll_timeout); DEBUG("- Event driven polling mode: %s\n", enable_event_driven_polling ? "ON": "OFF"); DEBUG("- Instance for thread: %s\n", enable_instance_for_thread ? "ON": "OFF"); DEBUG("- Max retry count: %d\n", qat_max_retry_count); CRYPTO_INIT_QAT_LOG(); polling_thread = pthread_self(); if ((err = pthread_key_create(&qatInstanceForThread, NULL)) != 0) { WARN("pthread_key_create failed: %s\n", strerror(err)); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_PTHREAD_CREATE_FAILURE); pthread_mutex_unlock(&qat_engine_mutex); return 0; } #ifndef OPENSSL_ENABLE_QAT_UPSTREAM_DRIVER /* limitDevAccess is passed as an input to icp_sal_userStartMultiProcess(). * However, in upstream driver the value is ignored and read directly from * the configuration file -> No need to parse the file here. */ if (!checkLimitDevAccessValue((int *)&limitDevAccess, ICPConfigSectionName_libcrypto)) { WARN("Could not load driver config file. Assuming LimitDevAccess = 0\n"); } #endif /* Initialise the QAT hardware */ if (CPA_STATUS_SUCCESS != icp_sal_userStartMultiProcess(ICPConfigSectionName_libcrypto, limitDevAccess)) { WARN("icp_sal_userStart failed\n"); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_ICP_SAL_USERSTART_FAIL); pthread_mutex_unlock(&qat_engine_mutex); return 0; } /* Get the number of available instances */ status = cpaCyGetNumInstances(&qat_num_instances); if (CPA_STATUS_SUCCESS != status) { WARN("cpaCyGetNumInstances failed, status=%d\n", status); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_GET_NUM_INSTANCE_FAILURE); pthread_mutex_unlock(&qat_engine_mutex); qat_engine_finish(e); return 0; } if (!qat_num_instances) { WARN("No crypto instances found\n"); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_INSTANCE_UNAVAILABLE); pthread_mutex_unlock(&qat_engine_mutex); qat_engine_finish(e); return 0; } DEBUG("Found %d Cy instances\n", qat_num_instances); /* Allocate memory for the instance handle array */ qat_instance_handles = (CpaInstanceHandle *) OPENSSL_zalloc(((int)qat_num_instances) * sizeof(CpaInstanceHandle)); if (NULL == qat_instance_handles) { WARN("OPENSSL_zalloc() failed for instance handles.\n"); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_INSTANCE_HANDLE_MALLOC_FAILURE); pthread_mutex_unlock(&qat_engine_mutex); qat_engine_finish(e); return 0; } /* Get the Cy instances */ status = cpaCyGetInstances(qat_num_instances, qat_instance_handles); if (CPA_STATUS_SUCCESS != status) { WARN("cpaCyGetInstances failed, status=%d\n", status); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_GET_INSTANCE_FAILURE); pthread_mutex_unlock(&qat_engine_mutex); qat_engine_finish(e); return 0; } if (!enable_external_polling && !enable_inline_polling) { if (qat_is_event_driven()) { CpaStatus status; int flags; int engine_fd; /* Add the file descriptor to an epoll event list */ internal_efd = epoll_create1(0); if (-1 == internal_efd) { WARN("Error creating epoll fd\n"); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_EPOLL_CREATE_FAILURE); pthread_mutex_unlock(&qat_engine_mutex); qat_engine_finish(e); return 0; } for (instNum = 0; instNum < qat_num_instances; instNum++) { /* Get the file descriptor for the instance */ status = icp_sal_CyGetFileDescriptor(qat_instance_handles[instNum], &engine_fd); if (CPA_STATUS_FAIL == status) { WARN("Error getting file descriptor for instance\n"); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_GET_FILE_DESCRIPTOR_FAILURE); pthread_mutex_unlock(&qat_engine_mutex); qat_engine_finish(e); return 0; } /* Make the file descriptor non-blocking */ eng_poll_st[instNum].eng_fd = engine_fd; eng_poll_st[instNum].inst_index = instNum; flags = fcntl(engine_fd, F_GETFL, 0); fcntl(engine_fd, F_SETFL, flags | O_NONBLOCK); eng_epoll_events[instNum].data.ptr = &eng_poll_st[instNum]; eng_epoll_events[instNum].events = EPOLLIN | EPOLLET; if (-1 == epoll_ctl(internal_efd, EPOLL_CTL_ADD, engine_fd, &eng_epoll_events[instNum])) { WARN("Error adding fd to epoll\n"); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_EPOLL_CTL_FAILURE); pthread_mutex_unlock(&qat_engine_mutex); qat_engine_finish(e); return 0; } } } } /* Set translation function and start each instance */ for (instNum = 0; instNum < qat_num_instances; instNum++) { /* Set the address translation function */ status = cpaCySetAddressTranslation(qat_instance_handles[instNum], virtualToPhysical); if (CPA_STATUS_SUCCESS != status) { WARN("cpaCySetAddressTranslation failed, status=%d\n", status); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_SET_ADDRESS_TRANSLATION_FAILURE); pthread_mutex_unlock(&qat_engine_mutex); qat_engine_finish(e); return 0; } /* Start the instances */ status = cpaCyStartInstance(qat_instance_handles[instNum]); if (CPA_STATUS_SUCCESS != status) { WARN("cpaCyStartInstance failed, status=%d\n", status); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_START_INSTANCE_FAILURE); pthread_mutex_unlock(&qat_engine_mutex); qat_engine_finish(e); return 0; } instance_started[instNum] = 1; } if (!enable_external_polling && !enable_inline_polling) { if (!qat_is_event_driven()) { sigemptyset(&set); sigaddset(&set, SIGUSR1); ret_pthread_sigmask = pthread_sigmask(SIG_BLOCK, &set, NULL); if (ret_pthread_sigmask != 0) { WARN("pthread_sigmask error\n"); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_POLLING_THREAD_SIGMASK_FAILURE); pthread_mutex_unlock(&qat_engine_mutex); qat_engine_finish(e); return 0; } } if (qat_create_thread(&polling_thread, NULL, qat_is_event_driven() ? event_poll_func : timer_poll_func, NULL)) { WARN("Creation of polling thread failed\n"); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_POLLING_THREAD_CREATE_FAILURE); polling_thread = pthread_self(); pthread_mutex_unlock(&qat_engine_mutex); qat_engine_finish(e); return 0; } if (qat_adjust_thread_affinity(polling_thread) == 0) { WARN("Setting polling thread affinity failed\n"); QATerr(QAT_F_QAT_ENGINE_INIT, QAT_R_SET_POLLING_THREAD_AFFINITY_FAILURE); pthread_mutex_unlock(&qat_engine_mutex); qat_engine_finish(e); return 0; } if (!qat_is_event_driven()) { while (!cleared_to_start) sleep(1); } } /* Reset curr_inst */ curr_inst = 0; engine_inited = 1; pthread_mutex_unlock(&qat_engine_mutex); return 1; }
static VOID StartShell(VOID) { WCHAR Shell[MAX_PATH]; TCHAR szMsg[RC_STRING_MAX_SIZE]; DWORD Type, Size; DWORD Value = 0; LONG rc; HKEY hKey; TRACE("()\n"); /* Safe Mode shell run */ rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option", 0, KEY_QUERY_VALUE, &hKey); if(rc == ERROR_SUCCESS) { Size = sizeof(Value); rc = RegQueryValueExW(hKey, L"UseAlternateShell", NULL, &Type, (LPBYTE)&Value, &Size); if(rc == ERROR_SUCCESS) { RegCloseKey(hKey); if(Type == REG_DWORD) { if(Value) { /* Safe Mode Alternate Shell required */ rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot", 0, KEY_READ, &hKey); if(rc == ERROR_SUCCESS) { Size = MAX_PATH * sizeof(WCHAR); rc = RegQueryValueExW(hKey, L"AlternateShell", NULL, &Type, (LPBYTE)Shell, &Size); if(rc == ERROR_SUCCESS) { RegCloseKey(hKey); if ((Type == REG_SZ) || (Type == REG_EXPAND_SZ)) { TRACE("Key located - %s\n", debugstr_w(Shell)); /* Try to run alternate shell */ if (TryToStartShell(Shell)) { TRACE("Alternate shell started (Safe Mode)\n"); return; } } else { WARN("Wrong type %lu (expected %u or %u)\n", Type, REG_SZ, REG_EXPAND_SZ); } } else { WARN("Alternate shell in Safe Mode required but not specified."); } } } } else { WARN("Wrong type %lu (expected %u)\n", Type, REG_DWORD); } } } /* Try to run shell in user key */ if (GetShell(Shell, HKEY_CURRENT_USER) && TryToStartShell(Shell)) { TRACE("Started shell from HKEY_CURRENT_USER\n"); return; } /* Try to run shell in local machine key */ if (GetShell(Shell, HKEY_LOCAL_MACHINE) && TryToStartShell(Shell)) { TRACE("Started shell from HKEY_LOCAL_MACHINE\n"); return; } /* Try default shell */ if (IsConsoleShell()) { if (GetSystemDirectory(Shell, MAX_PATH - 8)) wcscat(Shell, L"\\cmd.exe"); else wcscpy(Shell, L"cmd.exe"); } else { if (GetWindowsDirectory(Shell, MAX_PATH - 13)) wcscat(Shell, L"\\explorer.exe"); else wcscpy(Shell, L"explorer.exe"); } if (!TryToStartShell(Shell)) { WARN("Failed to start default shell %s\n", debugstr_w(Shell)); LoadString( GetModuleHandle(NULL), IDS_SHELL_FAIL, szMsg, sizeof(szMsg) / sizeof(szMsg[0])); MessageBox(0, szMsg, NULL, 0); } }
int qat_engine_finish_int(ENGINE *e, int reset_globals) { int i; int ret = 1; CpaStatus status = CPA_STATUS_SUCCESS; ENGINE_EPOLL_ST *epollst = NULL; int pthread_kill_ret; DEBUG("---- Engine Finishing...\n\n"); pthread_mutex_lock(&qat_engine_mutex); keep_polling = 0; if (qat_use_signals()) { pthread_kill_ret = pthread_kill(timer_poll_func_thread, SIGUSR1); if (pthread_kill_ret != 0) { WARN("pthread_kill error\n"); QATerr(QAT_F_QAT_ENGINE_FINISH_INT, QAT_R_PTHREAD_KILL_FAILURE); ret = 0; } } if (qat_instance_handles) { for (i = 0; i < qat_num_instances; i++) { if(instance_started[i]) { status = cpaCyStopInstance(qat_instance_handles[i]); if (CPA_STATUS_SUCCESS != status) { WARN("cpaCyStopInstance failed, status=%d\n", status); QATerr(QAT_F_QAT_ENGINE_FINISH_INT, QAT_R_STOP_INSTANCE_FAILURE); ret = 0; } instance_started[i] = 0; } } } /* If polling thread is different from the main thread, wait for polling * thread to finish. pthread_equal returns 0 when threads are different. */ if (!enable_external_polling && !enable_inline_polling && pthread_equal(polling_thread, pthread_self()) == 0) { if (qat_join_thread(polling_thread, NULL) != 0) { WARN("Polling thread join failed with status: %d\n", ret); QATerr(QAT_F_QAT_ENGINE_FINISH_INT, QAT_R_PTHREAD_JOIN_FAILURE); ret = 0; } } polling_thread = pthread_self(); if (qat_instance_handles) { OPENSSL_free(qat_instance_handles); qat_instance_handles = NULL; } if (!enable_external_polling && !enable_inline_polling && qat_is_event_driven()) { for (i = 0; i < qat_num_instances; i++) { epollst = (ENGINE_EPOLL_ST*)eng_epoll_events[i].data.ptr; if (epollst) { if (-1 == epoll_ctl(internal_efd, EPOLL_CTL_DEL, epollst->eng_fd, &eng_epoll_events[i])) { WARN("Error removing fd from epoll\n"); QATerr(QAT_F_QAT_ENGINE_FINISH_INT, QAT_R_EPOLL_CTL_FAILURE); ret = 0; } close(epollst->eng_fd); } } } /* Reset global variables */ qat_num_instances = 0; icp_sal_userStop(); engine_inited = 0; internal_efd = 0; qat_instance_handles = NULL; keep_polling = 1; curr_inst = 0; qatPerformOpRetries = 0; /* Reset the configuration global variables (to their default values) only * if requested, i.e. when we are not re-initializing the engine after * forking */ if (reset_globals) { enable_external_polling = 0; enable_inline_polling = 0; enable_event_driven_polling = 0; enable_instance_for_thread = 0; qat_poll_interval = QAT_POLL_PERIOD_IN_NS; qat_max_retry_count = QAT_CRYPTO_NUM_POLLING_RETRIES; } pthread_mutex_unlock(&qat_engine_mutex); CRYPTO_CLOSE_QAT_LOG(); return ret; }
void get_request(int server_s) { int fd; /* socket */ struct SOCKADDR remote_addr; /* address */ struct SOCKADDR salocal; int remote_addrlen = sizeof (struct SOCKADDR); request *conn; /* connection */ size_t len; static int system_bufsize = 0; /* Default size of SNDBUF given by system */ remote_addr.S_FAMILY = 0xdead; fd = accept(server_s, (struct sockaddr *) &remote_addr, &remote_addrlen); if (fd == -1) { if (errno != EAGAIN && errno != EWOULDBLOCK) /* abnormal error */ WARN("accept"); else /* no requests */ pending_requests = 0; return; } if (fd >= FD_SETSIZE) { WARN("Got fd >= FD_SETSIZE."); close(fd); return; } #ifdef DEBUGNONINET /* This shows up due to race conditions in some Linux kernels when the client closes the socket sometime between the select() and accept() syscalls. Code and description by Larry Doolittle <*****@*****.**> */ #define HEX(x) (((x)>9)?(('a'-10)+(x)):('0'+(x))) if (remote_addr.sin_family != AF_INET) { struct sockaddr *bogus = (struct sockaddr *) &remote_addr; char *ap, ablock[44]; int i; close(fd); log_error_time(); for (ap = ablock, i = 0; i < remote_addrlen && i < 14; i++) { *ap++ = ' '; *ap++ = HEX((bogus->sa_data[i] >> 4) & 0x0f); *ap++ = HEX(bogus->sa_data[i] & 0x0f); } *ap = '\0'; fprintf(stderr, "non-INET connection attempt: socket %d, " "sa_family = %hu, sa_data[%d] = %s\n", fd, bogus->sa_family, remote_addrlen, ablock); return; } #endif /* XXX Either delete this, or document why it's needed */ /* Pointed out 3-Oct-1999 by Paul Saab <*****@*****.**> */ #ifdef REUSE_EACH_CLIENT_CONNECTION_SOCKET if ((setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *) &sock_opt, sizeof (sock_opt))) == -1) { DIE("setsockopt: unable to set SO_REUSEADDR"); } #endif len = sizeof(salocal); if (getsockname(fd, (struct sockaddr *) &salocal, &len) != 0) { WARN("getsockname"); close(fd); return; } conn = new_request(); if (!conn) { close(fd); return; } conn->fd = fd; conn->status = READ_HEADER; conn->header_line = conn->client_stream; conn->time_last = current_time; conn->kacount = ka_max; ascii_sockaddr(&salocal, conn->local_ip_addr, NI_MAXHOST); /* nonblocking socket */ if (set_nonblock_fd(conn->fd) == -1) WARN("fcntl: unable to set new socket to non-block"); /* set close on exec to true */ if (fcntl(conn->fd, F_SETFD, 1) == -1) WARN("fctnl: unable to set close-on-exec for new socket"); /* Increase buffer size if we have to. * Only ask the system the buffer size on the first request, * and assume all subsequent sockets have the same size. */ if (system_bufsize == 0) { len = sizeof (system_bufsize); if (getsockopt (conn->fd, SOL_SOCKET, SO_SNDBUF, &system_bufsize, &len) == 0 && len == sizeof (system_bufsize)) { /* fprintf(stderr, "%sgetsockopt reports SNDBUF %d\n", get_commonlog_time(), system_bufsize); */ ; } else { WARN("getsockopt(SNDBUF)"); system_bufsize = 1; } } if (system_bufsize < sockbufsize) { if (setsockopt (conn->fd, SOL_SOCKET, SO_SNDBUF, (void *) &sockbufsize, sizeof (sockbufsize)) == -1) { WARN("setsockopt: unable to set socket buffer size"); #ifdef DIE_ON_ERROR_TUNING_SNDBUF exit(errno); #endif } } /* for log file and possible use by CGI programs */ ascii_sockaddr(&remote_addr, conn->remote_ip_addr, NI_MAXHOST); /* for possible use by CGI programs */ conn->remote_port = net_port(&remote_addr); status.requests++; #ifdef USE_TCPNODELAY /* Thanks to Jef Poskanzer <*****@*****.**> for this tweak */ { int one = 1; if (setsockopt(conn->fd, IPPROTO_TCP, TCP_NODELAY, (void *) &one, sizeof (one)) == -1) { DIE("setsockopt: unable to set TCP_NODELAY"); } } #endif #ifndef NO_RATE_LIMIT if (conn->fd > max_connections) { send_r_service_unavailable(conn); conn->status = DONE; pending_requests = 0; } #endif /* NO_RATE_LIMIT */ total_connections++; enqueue(&request_ready, conn); }
/************************************************************************** * JoyGetDevCaps [MMSYSTEM.102] */ static LRESULT JSTCK_GetDevCaps(DWORD_PTR dwDevID, LPJOYCAPSW lpCaps, DWORD dwSize) { WINE_JSTCK* jstck; #ifdef HAVE_LINUX_22_JOYSTICK_API int dev; char nrOfAxes; char nrOfButtons; char identString[MAXPNAMELEN]; int i; int driverVersion; #else static const WCHAR ini[] = {'W','i','n','e',' ','J','o','y','s','t','i','c','k',' ','D','r','i','v','e','r',0}; #endif if ((jstck = JSTCK_drvGet(dwDevID)) == NULL) return MMSYSERR_NODRIVER; #ifdef HAVE_LINUX_22_JOYSTICK_API if ((dev = JSTCK_OpenDevice(jstck)) < 0) return JOYERR_PARMS; ioctl(dev, JSIOCGAXES, &nrOfAxes); ioctl(dev, JSIOCGBUTTONS, &nrOfButtons); ioctl(dev, JSIOCGVERSION, &driverVersion); ioctl(dev, JSIOCGNAME(sizeof(identString)), identString); TRACE("Driver: 0x%06x, Name: %s, #Axes: %d, #Buttons: %d\n", driverVersion, identString, nrOfAxes, nrOfButtons); lpCaps->wMid = MM_MICROSOFT; lpCaps->wPid = MM_PC_JOYSTICK; MultiByteToWideChar(CP_UNIXCP, 0, identString, -1, lpCaps->szPname, MAXPNAMELEN); lpCaps->szPname[MAXPNAMELEN-1] = '\0'; lpCaps->wXmin = 0; lpCaps->wXmax = 0xFFFF; lpCaps->wYmin = 0; lpCaps->wYmax = 0xFFFF; lpCaps->wZmin = 0; lpCaps->wZmax = (nrOfAxes >= 3) ? 0xFFFF : 0; #ifdef BODGE_THE_HAT /* Half-Life won't allow you to map an axis event to things like "next weapon" and "use". Linux reports the hat on my stick as axis U and V. So, IFF BODGE_THE_HAT is defined, lie through our teeth and say we have 32 buttons, and we will map the axes to the high buttons. Really, perhaps this should be a registry entry, or even a parameter to the Linux joystick driver (which would completely remove the need for this.) */ lpCaps->wNumButtons = 32; #else lpCaps->wNumButtons = nrOfButtons; #endif if (dwSize == sizeof(JOYCAPSW)) { /* complete 95 structure */ lpCaps->wRmin = 0; lpCaps->wRmax = 0xFFFF; lpCaps->wUmin = 0; lpCaps->wUmax = 0xFFFF; lpCaps->wVmin = 0; lpCaps->wVmax = 0xFFFF; lpCaps->wMaxAxes = 6; /* same as MS Joystick Driver */ lpCaps->wNumAxes = 0; /* nr of axes in use */ lpCaps->wMaxButtons = 32; /* same as MS Joystick Driver */ lpCaps->szRegKey[0] = 0; lpCaps->szOEMVxD[0] = 0; lpCaps->wCaps = 0; for (i = 0; i < nrOfAxes; i++) { switch (jstck->axesMap[i]) { case 0: /* X */ case 1: /* Y */ lpCaps->wNumAxes++; break; case 2: /* Z */ case 6: /* Throttle */ lpCaps->wNumAxes++; lpCaps->wCaps |= JOYCAPS_HASZ; break; case 5: /* Rz */ case 7: /* Rudder */ lpCaps->wNumAxes++; lpCaps->wCaps |= JOYCAPS_HASR; break; case 3: /* Rx */ lpCaps->wNumAxes++; lpCaps->wCaps |= JOYCAPS_HASU; break; case 4: /* Ry */ lpCaps->wNumAxes++; lpCaps->wCaps |= JOYCAPS_HASV; break; case 16: /* Hat 0 X */ case 17: /* Hat 0 Y */ lpCaps->wCaps |= JOYCAPS_HASPOV | JOYCAPS_POV4DIR; /* TODO: JOYCAPS_POVCTS handling */ break; default: WARN("Unknown axis %hhu(%u). Skipped.\n", jstck->axesMap[i], i); } } } #else lpCaps->wMid = MM_MICROSOFT; lpCaps->wPid = MM_PC_JOYSTICK; strcpyW(lpCaps->szPname, ini); /* joystick product name */ lpCaps->wXmin = 0; lpCaps->wXmax = 0xFFFF; lpCaps->wYmin = 0; lpCaps->wYmax = 0xFFFF; lpCaps->wZmin = 0; lpCaps->wZmax = 0; lpCaps->wNumButtons = 2; if (dwSize == sizeof(JOYCAPSW)) { /* complete 95 structure */ lpCaps->wRmin = 0; lpCaps->wRmax = 0; lpCaps->wUmin = 0; lpCaps->wUmax = 0; lpCaps->wVmin = 0; lpCaps->wVmax = 0; lpCaps->wCaps = 0; lpCaps->wMaxAxes = 2; lpCaps->wNumAxes = 2; lpCaps->wMaxButtons = 4; lpCaps->szRegKey[0] = 0; lpCaps->szOEMVxD[0] = 0; } #endif return JOYERR_NOERROR; }
static semanage_list_t *get_home_dirs(genhomedircon_settings_t * s) { semanage_list_t *homedir_list = NULL; semanage_list_t *shells = NULL; fc_match_handle_t hand; char *rbuf = NULL; char *path = NULL; long rbuflen; uid_t temp, minuid = 500, maxuid = 60000; int minuid_set = 0; struct passwd pwstorage, *pwbuf; struct stat buf; int retval; path = semanage_findval(PATH_ETC_USERADD, "HOME", "="); if (path && *path) { if (semanage_list_push(&homedir_list, path)) goto fail; } free(path); path = semanage_findval(PATH_ETC_LIBUSER, "LU_HOMEDIRECTORY", "="); if (path && *path) { if (semanage_list_push(&homedir_list, path)) goto fail; } free(path); path = NULL; if (!homedir_list) { if (semanage_list_push(&homedir_list, PATH_DEFAULT_HOME)) { goto fail; } } if (!stat(PATH_EXPORT_HOME, &buf)) { if (S_ISDIR(buf.st_mode)) { if (semanage_list_push(&homedir_list, PATH_EXPORT_HOME)) { goto fail; } } } if (!(s->usepasswd)) return homedir_list; shells = get_shell_list(); assert(shells); path = semanage_findval(PATH_ETC_LOGIN_DEFS, "UID_MIN", NULL); if (path && *path) { temp = atoi(path); minuid = temp; minuid_set = 1; } free(path); path = NULL; path = semanage_findval(PATH_ETC_LOGIN_DEFS, "UID_MAX", NULL); if (path && *path) { temp = atoi(path); maxuid = temp; } free(path); path = NULL; path = semanage_findval(PATH_ETC_LIBUSER, "LU_UIDNUMBER", "="); if (path && *path) { temp = atoi(path); if (!minuid_set || temp < minuid) { minuid = temp; minuid_set = 1; } } free(path); path = NULL; rbuflen = sysconf(_SC_GETPW_R_SIZE_MAX); if (rbuflen <= 0) goto fail; rbuf = malloc(rbuflen); if (rbuf == NULL) goto fail; setpwent(); while ((retval = getpwent_r(&pwstorage, rbuf, rbuflen, &pwbuf)) == 0) { if (pwbuf->pw_uid < minuid || pwbuf->pw_uid > maxuid) continue; if (!semanage_list_find(shells, pwbuf->pw_shell)) continue; int len = strlen(pwbuf->pw_dir) -1; for(; len > 0 && pwbuf->pw_dir[len] == '/'; len--) { pwbuf->pw_dir[len] = '\0'; } if (strcmp(pwbuf->pw_dir, "/") == 0) continue; if (ignore(pwbuf->pw_dir)) continue; if (semanage_str_count(pwbuf->pw_dir, '/') <= 1) continue; if (!(path = strdup(pwbuf->pw_dir))) { break; } semanage_rtrim(path, '/'); if (!semanage_list_find(homedir_list, path)) { /* * Now check for an existing file context that matches * so we don't label a non-homedir as a homedir. */ hand.dir = path; hand.matched = 0; if (semanage_fcontext_iterate(s->h_semanage, fcontext_matches, &hand) == STATUS_ERR) goto fail; /* NOTE: old genhomedircon printed a warning on match */ if (hand.matched) { WARN(s->h_semanage, "%s homedir %s or its parent directory conflicts with a file context already specified in the policy. This usually indicates an incorrectly defined system account. If it is a system account please make sure its uid is less than %u or greater than %u or its login shell is /sbin/nologin.", pwbuf->pw_name, pwbuf->pw_dir, minuid, maxuid); } else { if (semanage_list_push(&homedir_list, path)) goto fail; } } free(path); path = NULL; } if (retval && retval != ENOENT) { WARN(s->h_semanage, "Error while fetching users. " "Returning list so far."); } if (semanage_list_sort(&homedir_list)) goto fail; endpwent(); free(rbuf); semanage_list_destroy(&shells); return homedir_list; fail: endpwent(); free(rbuf); free(path); semanage_list_destroy(&homedir_list); semanage_list_destroy(&shells); return NULL; }
void lxc_fini(const char *name, struct lxc_handler *handler) { int i, rc; pid_t self = getpid(); char *namespaces[LXC_NS_MAX+1]; size_t namespace_count = 0; /* The STOPPING state is there for future cleanup code which can take * awhile. */ lxc_set_state(name, handler, STOPPING); for (i = 0; i < LXC_NS_MAX; i++) { if (handler->nsfd[i] != -1) { rc = asprintf(&namespaces[namespace_count], "%s:/proc/%d/fd/%d", ns_info[i].proc_name, self, handler->nsfd[i]); if (rc == -1) { SYSERROR("Failed to allocate memory."); break; } ++namespace_count; } } namespaces[namespace_count] = NULL; if (handler->conf->reboot && setenv("LXC_TARGET", "reboot", 1)) SYSERROR("Failed to set environment variable: LXC_TARGET=reboot."); if (!handler->conf->reboot && setenv("LXC_TARGET", "stop", 1)) SYSERROR("Failed to set environment variable: LXC_TARGET=stop."); if (run_lxc_hooks(name, "stop", handler->conf, handler->lxcpath, namespaces)) ERROR("Failed to run lxc.hook.stop for container \"%s\".", name); while (namespace_count--) free(namespaces[namespace_count]); for (i = 0; i < LXC_NS_MAX; i++) { if (handler->nsfd[i] != -1) { close(handler->nsfd[i]); handler->nsfd[i] = -1; } } if (handler->netnsfd >= 0) { close(handler->netnsfd); handler->netnsfd = -1; } lxc_set_state(name, handler, STOPPED); if (run_lxc_hooks(name, "post-stop", handler->conf, handler->lxcpath, NULL)) { ERROR("Failed to run lxc.hook.post-stop for container \"%s\".", name); if (handler->conf->reboot) { WARN("Container will be stopped instead of rebooted."); handler->conf->reboot = 0; if (setenv("LXC_TARGET", "stop", 1)) WARN("Failed to set environment variable: LXC_TARGET=stop."); } } /* Reset mask set by setup_signal_fd. */ if (sigprocmask(SIG_SETMASK, &handler->oldmask, NULL)) WARN("Failed to restore signal mask."); lxc_console_delete(&handler->conf->console); lxc_delete_tty(&handler->conf->tty_info); close(handler->conf->maincmd_fd); handler->conf->maincmd_fd = -1; free(handler->name); if (handler->ttysock[0] != -1) { close(handler->ttysock[0]); close(handler->ttysock[1]); } if (handler->conf->ephemeral == 1 && handler->conf->reboot != 1) lxc_destroy_container_on_signal(handler, name); cgroup_destroy(handler); free(handler); }
static DWORD WINAPI ScreenSaverThreadMain( IN LPVOID lpParameter) { PWLSESSION Session = (PWLSESSION)lpParameter; HANDLE HandleArray[3]; #ifdef USE_GETLASTINPUTINFO LASTINPUTINFO lastInputInfo; #else DWORD LastActivity; #endif DWORD TimeToWait; DWORD Timeout; /* Timeout before screen saver starts, in milliseconds */ DWORD ret; if (!ImpersonateLoggedOnUser(Session->UserToken)) { ERR("ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError()); return 0; } Session->hUserActivity = CreateEventW(NULL, FALSE, FALSE, NULL); if (!Session->hUserActivity) { ERR("WL: Unable to create event (error %lu)\n", GetLastError()); goto cleanup; } Session->hEndOfScreenSaver = CreateEventW(NULL, FALSE, FALSE, NULL); if (!Session->hEndOfScreenSaver) { ERR("WL: Unable to create event (error %lu)\n", GetLastError()); goto cleanup; } HandleArray[0] = Session->hEndOfScreenSaverThread; HandleArray[1] = Session->hScreenSaverParametersChanged; HandleArray[2] = Session->hEndOfScreenSaver; LoadScreenSaverParameters(&Timeout); #ifndef USE_GETLASTINPUTINFO InterlockedExchange((LONG*)&Session->LastActivity, GetTickCount()); #else lastInputInfo.cbSize = sizeof(LASTINPUTINFO); #endif for (;;) { /* See the time of last activity and calculate a timeout */ #ifndef USE_GETLASTINPUTINFO LastActivity = InterlockedCompareExchange((LONG*)&Session->LastActivity, 0, 0); TimeToWait = Timeout - (GetTickCount() - LastActivity); #else if (GetLastInputInfo(&lastInputInfo)) TimeToWait = Timeout - (GetTickCount() - lastInputInfo.dwTime); else { WARN("GetLastInputInfo() failed with error %lu\n", GetLastError()); TimeToWait = 10; /* Try again in 10 ms */ } #endif if (TimeToWait > Timeout) { /* GetTickCount() got back to 0 */ TimeToWait = Timeout; } /* Wait for the timeout, or the end of this thread */ ret = WaitForMultipleObjects(2, HandleArray, FALSE, TimeToWait); if (ret == WAIT_OBJECT_0) break; else if (ret == WAIT_OBJECT_0 + 1) LoadScreenSaverParameters(&Timeout); /* Check if we didn't had recent activity */ #ifndef USE_GETLASTINPUTINFO LastActivity = InterlockedCompareExchange((LONG*)&Session->LastActivity, 0, 0); if (LastActivity + Timeout > GetTickCount()) continue; #else if (!GetLastInputInfo(&lastInputInfo)) { WARN("GetLastInputInfo() failed with error %lu\n", GetLastError()); continue; } if (lastInputInfo.dwTime + Timeout > GetTickCount()) continue; #endif /* Run screen saver */ PostMessageW(Session->SASWindow, WLX_WM_SAS, WLX_SAS_TYPE_SCRNSVR_TIMEOUT, 0); /* Wait for the end of this thread or of the screen saver */ ret = WaitForMultipleObjects(3, HandleArray, FALSE, INFINITE); if (ret == WAIT_OBJECT_0) break; else if (ret == WAIT_OBJECT_0 + 1) LoadScreenSaverParameters(&Timeout); else if (ret == WAIT_OBJECT_0 + 2) SystemParametersInfoW(SPI_SETSCREENSAVERRUNNING, FALSE, NULL, 0); } cleanup: RevertToSelf(); if (Session->hUserActivity) CloseHandle(Session->hUserActivity); if (Session->hEndOfScreenSaver) CloseHandle(Session->hEndOfScreenSaver); #ifndef USE_GETLASTINPUTINFO if (Session->KeyboardHook) UnhookWindowsHookEx(Session->KeyboardHook); if (Session->MouseHook) UnhookWindowsHookEx(Session->MouseHook); #endif CloseHandle(Session->hEndOfScreenSaverThread); CloseHandle(Session->hScreenSaverParametersChanged); return 0; }
static void CALLBACK DSOUND_capture_timer(UINT timerID, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2) { DirectSoundCaptureDevice *device = (DirectSoundCaptureDevice*)user; UINT32 packet_frames, packet_bytes, avail_bytes; DWORD flags; BYTE *buf; HRESULT hr; if(!device->ref) return; EnterCriticalSection(&device->lock); if(!device->capture_buffer || device->state == STATE_STOPPED){ LeaveCriticalSection(&device->lock); return; } if(device->state == STATE_STOPPING){ device->state = STATE_STOPPED; LeaveCriticalSection(&device->lock); return; } if(device->state == STATE_STARTING) device->state = STATE_CAPTURING; hr = IAudioCaptureClient_GetBuffer(device->capture, &buf, &packet_frames, &flags, NULL, NULL); if(FAILED(hr)){ LeaveCriticalSection(&device->lock); WARN("GetBuffer failed: %08x\n", hr); return; } packet_bytes = packet_frames * device->pwfx->nBlockAlign; avail_bytes = device->buflen - device->write_pos_bytes; if(avail_bytes > packet_bytes) avail_bytes = packet_bytes; memcpy(device->buffer + device->write_pos_bytes, buf, avail_bytes); capture_CheckNotify(device->capture_buffer, device->write_pos_bytes, avail_bytes); packet_bytes -= avail_bytes; if(packet_bytes > 0){ if(device->capture_buffer->flags & DSCBSTART_LOOPING){ memcpy(device->buffer, buf + avail_bytes, packet_bytes); capture_CheckNotify(device->capture_buffer, 0, packet_bytes); }else{ device->state = STATE_STOPPED; capture_CheckNotify(device->capture_buffer, 0, 0); } } device->write_pos_bytes += avail_bytes + packet_bytes; device->write_pos_bytes %= device->buflen; hr = IAudioCaptureClient_ReleaseBuffer(device->capture, packet_frames); if(FAILED(hr)){ LeaveCriticalSection(&device->lock); WARN("ReleaseBuffer failed: %08x\n", hr); return; } LeaveCriticalSection(&device->lock); }
void DSMFactory::runMonitorAppSelect(const AmSipRequest& req, string& start_diag, map<string, string>& vars) { #define FALLBACK_OR_EXCEPTION(code, reason) \ if (MonSelectFallback.empty()) { \ throw AmSession::Exception(code, reason); \ } else { \ DBG("falling back to '%s'\n", MonSelectFallback.c_str()); \ start_diag = MonSelectFallback; \ return; \ } #ifdef USE_MONITORING if (NULL == MONITORING_GLOBAL_INTERFACE) { ERROR("using $(mon_select) but monitoring not loaded\n"); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } AmArg di_args, ret; if (MonSelectCaller != MonSelect_NONE) { AmUriParser from_parser; if (MonSelectCaller == MonSelect_FROM) from_parser.uri = req.from_uri; else { size_t end; string pai = getHeader(req.hdrs, SIP_HDR_P_ASSERTED_IDENTITY, true); if (!from_parser.parse_contact(pai, 0, end)) { WARN("Failed to parse " SIP_HDR_P_ASSERTED_IDENTITY " '%s'\n", pai.c_str()); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } } if (!from_parser.parse_uri()) { DBG("failed to parse caller uri '%s'\n", from_parser.uri.c_str()); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } AmArg caller_filter; caller_filter.push("caller"); caller_filter.push(from_parser.uri_user); DBG(" && looking for caller=='%s'\n", from_parser.uri_user.c_str()); di_args.push(caller_filter); } if (MonSelectCallee != MonSelect_NONE) { AmArg callee_filter; callee_filter.push("callee"); if (MonSelectCallee == MonSelect_RURI) callee_filter.push(req.user); else { AmUriParser to_parser; size_t end; if (!to_parser.parse_contact(req.to, 0, end)) { ERROR("Failed to parse To '%s'\n", req.to.c_str()); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } if (!to_parser.parse_uri()) { DBG("failed to parse callee uri '%s'\n", to_parser.uri.c_str()); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } callee_filter.push(to_parser.uri_user); } DBG(" && looking for callee=='%s'\n", req.user.c_str()); di_args.push(callee_filter); } // apply additional filters if (MonSelectFilters.size()) { string app_params = getHeader(req.hdrs, PARAM_HDR); for (vector<string>::iterator it = MonSelectFilters.begin(); it != MonSelectFilters.end(); it++) { AmArg filter; filter.push(*it); // avp name string app_param_val = get_header_keyvalue(app_params, *it); filter.push(app_param_val); di_args.push(filter); DBG(" && looking for %s=='%s'\n", it->c_str(), app_param_val.c_str()); } } MONITORING_GLOBAL_INTERFACE->invoke("listByFilter",di_args,ret); if ((ret.getType()!=AmArg::Array)|| !ret.size()) { DBG("call info not found. caller uri %s, r-uri %s\n", req.from_uri.c_str(), req.r_uri.c_str()); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } AmArg sess_id, sess_params; if (ret.size()>1) { DBG("multiple call info found - picking the first one\n"); } const char* session_id = ret.get(0).asCStr(); sess_id.push(session_id); MONITORING_GLOBAL_INTERFACE->invoke("get",sess_id,sess_params); if ((sess_params.getType()!=AmArg::Array)|| !sess_params.size() || sess_params.get(0).getType() != AmArg::Struct) { INFO("call parameters not found. caller uri %s, r-uri %s, id %s\n", req.from_uri.c_str(), req.r_uri.c_str(), ret.get(0).asCStr()); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } AmArg& sess_dict = sess_params.get(0); if (sess_dict.hasMember("app")) { start_diag = sess_dict["app"].asCStr(); DBG("selected application '%s' for session\n", start_diag.c_str()); } else { ERROR("selected session params don't contain 'app'\n"); FALLBACK_OR_EXCEPTION(500, "Internal Server Error"); } AmArg2DSMStrMap(sess_dict["appParams"], vars); vars["mon_session_record"] = session_id; #else ERROR("using $(mon_select) for dsm application, " "but compiled without monitoring support!\n"); throw AmSession::Exception(500, "Internal Server Error"); #endif #undef FALLBACK_OR_EXCEPTION }
static int stm32_sdmmc2_read(int lba, uintptr_t buf, size_t size) { uint32_t error_flags = SDMMC_STAR_RXOVERR | SDMMC_STAR_DCRCFAIL | SDMMC_STAR_DTIMEOUT; uint32_t flags = error_flags | SDMMC_STAR_DATAEND; uint32_t status; uint32_t *buffer; uintptr_t base = sdmmc2_params.reg_base; uintptr_t fifo_reg = base + SDMMC_FIFOR; unsigned int start; int ret; /* Assert buf is 4 bytes aligned */ assert((buf & GENMASK(1, 0)) == 0U); buffer = (uint32_t *)buf; if (sdmmc2_params.use_dma) { inv_dcache_range(buf, size); return 0; } if (size <= MMC_BLOCK_SIZE) { flags |= SDMMC_STAR_DBCKEND; } start = get_timer(0); do { status = mmio_read_32(base + SDMMC_STAR); if ((status & error_flags) != 0U) { ERROR("%s: Read error (status = %x)\n", __func__, status); mmio_write_32(base + SDMMC_DCTRLR, SDMMC_DCTRLR_FIFORST); mmio_write_32(base + SDMMC_ICR, SDMMC_STATIC_FLAGS); ret = stm32_sdmmc2_stop_transfer(); if (ret != 0) { return ret; } return -EIO; } if (get_timer(start) > TIMEOUT_1_S) { ERROR("%s: timeout 1s (status = %x)\n", __func__, status); mmio_write_32(base + SDMMC_ICR, SDMMC_STATIC_FLAGS); ret = stm32_sdmmc2_stop_transfer(); if (ret != 0) { return ret; } return -ETIMEDOUT; } if (size < (8U * sizeof(uint32_t))) { if ((mmio_read_32(base + SDMMC_DCNTR) > 0U) && ((status & SDMMC_STAR_RXFIFOE) == 0U)) { *buffer = mmio_read_32(fifo_reg); buffer++; } } else if ((status & SDMMC_STAR_RXFIFOHF) != 0U) { uint32_t count; /* Read data from SDMMC Rx FIFO */ for (count = 0; count < 8U; count++) { *buffer = mmio_read_32(fifo_reg); buffer++; } } } while ((status & flags) == 0U); mmio_write_32(base + SDMMC_ICR, SDMMC_STATIC_FLAGS); if ((status & SDMMC_STAR_DPSMACT) != 0U) { WARN("%s: DPSMACT=1, send stop\n", __func__); return stm32_sdmmc2_stop_transfer(); } return 0; }
int i915_gem_set_tiling(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_i915_gem_set_tiling *args = data; drm_i915_private_t *dev_priv = dev->dev_private; struct drm_gem_object *obj; struct drm_i915_gem_object *obj_priv; int ret = 0; obj = drm_gem_object_lookup(dev, file_priv, args->handle); if (obj == NULL) return -EINVAL; obj_priv = to_intel_bo(obj); if (!i915_tiling_ok(dev, args->stride, obj->size, args->tiling_mode)) { drm_gem_object_unreference_unlocked(obj); return -EINVAL; } if (obj_priv->pin_count) { drm_gem_object_unreference_unlocked(obj); return -EBUSY; } if (args->tiling_mode == I915_TILING_NONE) { args->swizzle_mode = I915_BIT_6_SWIZZLE_NONE; args->stride = 0; } else { if (args->tiling_mode == I915_TILING_X) args->swizzle_mode = dev_priv->mm.bit_6_swizzle_x; else args->swizzle_mode = dev_priv->mm.bit_6_swizzle_y; /* Hide bit 17 swizzling from the user. This prevents old Mesa * from aborting the application on sw fallbacks to bit 17, * and we use the pread/pwrite bit17 paths to swizzle for it. * If there was a user that was relying on the swizzle * information for drm_intel_bo_map()ed reads/writes this would * break it, but we don't have any of those. */ if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_17) args->swizzle_mode = I915_BIT_6_SWIZZLE_9; if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_10_17) args->swizzle_mode = I915_BIT_6_SWIZZLE_9_10; /* If we can't handle the swizzling, make it untiled. */ if (args->swizzle_mode == I915_BIT_6_SWIZZLE_UNKNOWN) { args->tiling_mode = I915_TILING_NONE; args->swizzle_mode = I915_BIT_6_SWIZZLE_NONE; args->stride = 0; } } mutex_lock(&dev->struct_mutex); if (args->tiling_mode != obj_priv->tiling_mode || args->stride != obj_priv->stride) { /* We need to rebind the object if its current allocation * no longer meets the alignment restrictions for its new * tiling mode. Otherwise we can just leave it alone, but * need to ensure that any fence register is cleared. */ if (!i915_gem_object_fence_offset_ok(obj, args->tiling_mode)) ret = i915_gem_object_unbind(obj); else if (obj_priv->fence_reg != I915_FENCE_REG_NONE) ret = i915_gem_object_put_fence_reg(obj); else i915_gem_release_mmap(obj); if (ret != 0) { WARN(ret != -ERESTARTSYS, "failed to reset object for tiling switch"); args->tiling_mode = obj_priv->tiling_mode; args->stride = obj_priv->stride; goto err; } obj_priv->tiling_mode = args->tiling_mode; obj_priv->stride = args->stride; } err: drm_gem_object_unreference(obj); mutex_unlock(&dev->struct_mutex); return ret; }
// // Function called when a new HTTP request have been recieved. // static void http_handler(struct evhttp_request *request, void *userdata) { struct owl_state* state = userdata; // Setup general response headers struct evkeyvalq *headers = evhttp_request_get_output_headers(request); evhttp_add_header(headers, "Server", USER_AGENT); // Get the requested URI const char* uri = evhttp_request_get_uri(request); const int http_method = evhttp_request_get_command(request); if( http_method != EVHTTP_REQ_GET && http_method != EVHTTP_REQ_PUT && http_method != EVHTTP_REQ_POST) { evhttp_send_error(request, 501, "Not Implemented"); return; } TRACE("Received HTTP request: %s (method %d)\n", uri, http_method); // Keep the request for async usage state->http_request = request; // // Retrieve application state (sync) if(string_starts_with(uri, "/api/state") && http_method == EVHTTP_REQ_GET) { state_action(state); } // // Shutdown owl application (async) else if(string_starts_with(uri, "/api/shutdown") && http_method == EVHTTP_REQ_GET) { shutdown_action(state); } // // Try to login to Spotify (async) else if(string_starts_with(uri, "/api/login") && http_method == EVHTTP_REQ_GET) { char* username = extract_uri_section(2, uri); char* password = extract_uri_section(3, uri); if(username != NULL && password != NULL) { login_to_spotify_action(state, username, password); } else { WARN("Could not extract username and password in order to login to Spotify!\n"); respond_error(request, OWL_HTTO_ERROR_NO_LOGIN_DETAILS, "No username or password given"); } } else if(string_starts_with(uri, "/api/login") && http_method == EVHTTP_REQ_POST) { TRACE("POST LOGIN\n"); get_post_argument(request, "username"); evhttp_send_error(request, 501, "Not Implemented"); } // // Logout from spotify (async) else if(string_starts_with(uri, "/api/logout") && http_method == EVHTTP_REQ_GET) { if(state->state > OWL_STATE_LOGGING_IN && state->state < OWL_STATE_LOGGING_OUT) logout_from_spotify_action(state); else respond_success(request); } // // Clear the entire queue else if(string_starts_with(uri, "/api/queue/clear") && http_method == EVHTTP_REQ_GET) { if(state->state < OWL_STATE_IDLE || state->state > OWL_STATE_PLAYING) { respond_error(request, OWL_HTTP_ERROR_NOT_LOGGED_IN, "Operation not allowed when not logged in"); } else { const int size = queue_size(state->spotify_state->queue); for(int i = 0; i < size; i++) { owl_track *track = pop_from_queue(state->spotify_state->queue); free_track(track); } respond_success(request); } } // // Get the current playback queue (sync) else if(string_starts_with(uri, "/api/queue") && http_method == EVHTTP_REQ_GET) { if(state->state < OWL_STATE_IDLE || state->state > OWL_STATE_PLAYING) { WARN("Operation not allowed at this state (%d)\n", state->state); respond_error(request, OWL_HTTP_ERROR_NOT_LOGGED_IN, "Operation not allowed when not logged in"); } else { respond_with_queue(state->http_request, state->spotify_state->queue); } } // // Serve static file immediately else { // Create the buffer to retrn as content struct evbuffer *content_buffer = evbuffer_new(); // If not a handler this is a static request char *static_file = (char *) malloc(strlen(doc_root) + strlen(uri) + 1); stpcpy(stpcpy(static_file, doc_root), uri); TRACE("Looking for static file: %s\n", static_file); bool file_exists = 1; struct stat st; if(stat(static_file, &st) == -1 || S_ISDIR(st.st_mode)) { file_exists = 0; evhttp_send_error(request, HTTP_NOTFOUND, "Not Found"); } if(file_exists) { const int file_size = st.st_size; FILE *fp = fopen(static_file, "r"); const char* content_type = resolve_content_type(static_file); evbuffer_add_file(content_buffer, fileno(fp), 0, file_size); // will close TRACE("Resolving content type for filename: %s to: %s\n", static_file, content_type); evhttp_add_header(headers, "Content-Type", content_type); evhttp_send_reply(request, HTTP_OK, "OK", content_buffer); } free(static_file); // Send the data evhttp_send_reply(request, HTTP_OK, USER_AGENT, content_buffer); // Free memrory evbuffer_free(content_buffer); } return; }
/* Called from MMC_WRITE_MULTIPLE_BLOCK or MMC_READ_MULTIPLE_BLOCK */ static void usdhi6_sg_advance(struct usdhi6_host *host) { struct mmc_data *data = host->mrq->data; size_t done, total; /* New offset: set at the end of the previous block */ if (host->head_pg.page) { /* Finished a cross-page block, jump to the new page */ host->page_idx++; host->offset = data->blksz - host->head_len; host->blk_page = host->pg.mapped; usdhi6_sg_unmap(host, false); } else { host->offset += data->blksz; /* The completed block didn't cross a page boundary */ if (host->offset == PAGE_SIZE) { /* If required, we'll map the page below */ host->offset = 0; host->page_idx++; } } /* * Now host->blk_page + host->offset point at the end of our last block * and host->page_idx is the index of the page, in which our new block * is located, if any */ done = (host->page_idx << PAGE_SHIFT) + host->offset; total = host->sg->offset + sg_dma_len(host->sg); dev_dbg(mmc_dev(host->mmc), "%s(): %zu of %zu @ %zu\n", __func__, done, total, host->offset); if (done < total && host->offset) { /* More blocks in this page */ if (host->offset + data->blksz > PAGE_SIZE) /* We approached at a block, that spans 2 pages */ usdhi6_blk_bounce(host, host->sg); return; } /* Finished current page or an SG segment */ usdhi6_sg_unmap(host, false); if (done == total) { /* * End of an SG segment or the complete SG: jump to the next * segment, we'll map it later in usdhi6_blk_read() or * usdhi6_blk_write() */ struct scatterlist *next = sg_next(host->sg); host->page_idx = 0; if (!next) host->wait = USDHI6_WAIT_FOR_DATA_END; host->sg = next; if (WARN(next && sg_dma_len(next) % data->blksz, "SG size %u isn't a multiple of block size %u\n", sg_dma_len(next), data->blksz)) data->error = -EINVAL; return; } /* We cannot get here after crossing a page border */ /* Next page in the same SG */ host->pg.page = nth_page(sg_page(host->sg), host->page_idx); host->pg.mapped = kmap(host->pg.page); host->blk_page = host->pg.mapped; dev_dbg(mmc_dev(host->mmc), "Mapped %p (%lx) at %p for CMD%u @ 0x%p\n", host->pg.page, page_to_pfn(host->pg.page), host->pg.mapped, host->mrq->cmd->opcode, host->mrq); }