static int pnpdr_process_version(IWTSVirtualChannelCallback * pChannelCallback, char * data, uint32 data_size) { PNPDR_CHANNEL_CALLBACK * callback = (PNPDR_CHANNEL_CALLBACK *) pChannelCallback; uint32 MajorVersion; uint32 MinorVersion; uint32 Capabilities; uint32 out_size; char * out_data; MajorVersion = GET_UINT32(data, 0); MinorVersion = GET_UINT32(data, 4); Capabilities = GET_UINT32(data, 8); LLOGLN(10, ("pnpdr_process_version: MajorVersion=%d MinorVersion=%d Capabilities=%d", MajorVersion, MinorVersion, Capabilities)); out_size = 20; out_data = (char *) malloc(out_size); memset(out_data, 0, out_size); SET_UINT32(out_data, 0, out_size); SET_UINT32(out_data, 4, IRPDR_ID_VERSION); SET_UINT32(out_data, 8, MajorVersion); SET_UINT32(out_data, 12, MinorVersion); SET_UINT32(out_data, 16, Capabilities); callback->channel->Write(callback->channel, out_size, out_data, NULL); free(out_data); return 0; }
int tsmf_ifman_check_format_support_request(TSMF_IFMAN * ifman) { uint32 PlatformCookie; uint32 numMediaType; uint32 FormatSupported = 1; PlatformCookie = GET_UINT32(ifman->input_buffer, 0); /* NoRolloverFlags (4 bytes) ignored */ numMediaType = GET_UINT32(ifman->input_buffer, 8); LLOGLN(0, ("tsmf_ifman_check_format_support_request: PlatformCookie %d numMediaType %d", PlatformCookie, numMediaType)); if (tsmf_codec_check_media_type(ifman->input_buffer + 12)) FormatSupported = 0; if (FormatSupported == 1) LLOGLN(0, ("tsmf_ifman_check_format_support_request: format ok.")); ifman->output_buffer_size = 12; ifman->output_buffer = malloc(12); SET_UINT32(ifman->output_buffer, 0, FormatSupported); SET_UINT32(ifman->output_buffer, 4, PlatformCookie); SET_UINT32(ifman->output_buffer, 8, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; return 0; }
static void uei_of_store_hk(void) { static channel_t *uei_of_2_5V_channel = NULL; static channel_t *uei_of_3_3V_channel = NULL; static channel_t *uei_of_24V_channel = NULL; static channel_t *uei_of_Vin_channel = NULL; static channel_t *uei_of_1_5V_channel = NULL; static channel_t *uei_of_1_2V_channel = NULL; static channel_t *uei_of_i_in_channel = NULL; static channel_t *uei_of_temp1_channel = NULL; static channel_t *uei_of_temp2_channel = NULL; if (!uei_of_2_5V_channel) { uei_of_2_5V_channel = channels_find_by_name("uei_of_2_5V"); uei_of_3_3V_channel = channels_find_by_name("uei_of_3_3V"); uei_of_24V_channel = channels_find_by_name("uei_of_24V"); uei_of_Vin_channel = channels_find_by_name("uei_of_Vin"); uei_of_1_5V_channel = channels_find_by_name("uei_of_1_5V"); uei_of_1_2V_channel = channels_find_by_name("uei_of_1_2V"); uei_of_i_in_channel = channels_find_by_name("uei_of_i_in"); uei_of_temp1_channel = channels_find_by_name("uei_of_temp1"); uei_of_temp2_channel = channels_find_by_name("uei_of_temp2"); } SET_UINT32(uei_of_2_5V_channel, raw_diag_data[DQ_LDIAG_ADC_V_2_5]); SET_UINT32(uei_of_3_3V_channel, raw_diag_data[DQ_LDIAG_ADC_V_3_3]); SET_UINT32(uei_of_24V_channel, raw_diag_data[DQ_LDIAG_ADC_V_24]); SET_UINT32(uei_of_Vin_channel, raw_diag_data[DQ_LDIAG_ADC_V_IN]); SET_UINT32(uei_of_1_5V_channel, raw_diag_data[DQ_LDIAG_ADC_V_1_5]); SET_UINT32(uei_of_1_2V_channel, raw_diag_data[DQ_LDIAG_ADC_V_1_2]); SET_UINT32(uei_of_i_in_channel, raw_diag_data[DQ_L2_ADC_I_IN]); SET_UINT32(uei_of_temp1_channel, raw_diag_data[DQ_LDIAG_ADC_TEMP1]); SET_UINT32(uei_of_temp2_channel, raw_diag_data[DQ_LDIAG_ADC_TEMP1]); }
int tsmf_ifman_set_topology_request(TSMF_IFMAN * ifman) { LLOGLN(0, ("tsmf_ifman_set_topology_request:")); ifman->output_buffer_size = 8; ifman->output_buffer = malloc(8); SET_UINT32(ifman->output_buffer, 0, 1); /* TopologyReady */ SET_UINT32(ifman->output_buffer, 4, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; return 0; }
os_status hwTimer32SetAndForget(soc_timer32_module_t module, timer32_input_select_t timer_input) { /* clear is required by HW for preventing the lock to start from previous signals */ SET_UINT32(soc_timer32_module[module].tmr_clrl, (0x1 << timer_input)); SET_UINT32(soc_timer32_module[module].tmr_saf, (0x1 << timer_input)); #ifdef B4860_FAMILY DBAR_SCFG(); #endif //B4860_FAMILY return OS_SUCCESS; }
os_status hwTimer32SetInitiatorMode(soc_timer32_module_t module, timer32_number_in_module_t initiator_timer, uint32_t reinit_timers, uint32_t output_signal_timers) { uint32_t i = 0; uint32_t reinit_timers_ = reinit_timers; uint32_t output_signal_timers_ = output_signal_timers; uint16_t *timers_ctrl = timers_control_32b; #ifdef HW_TIMER_ERROR_ASSERT OS_ASSERT_COND(!(module > NUM_OF_HW_TIMER_32b_MODULES-1)); OS_ASSERT_COND((initiator_timer & ~(SOC_TIMER32_IN_MODULE_TIMER_0 | SOC_TIMER32_IN_MODULE_TIMER_1 | SOC_TIMER32_IN_MODULE_TIMER_2 | SOC_TIMER32_IN_MODULE_TIMER_3)) == 0); OS_ASSERT_COND((reinit_timers & ~(SOC_TIMER32_IN_MODULE_TIMER_0 | SOC_TIMER32_IN_MODULE_TIMER_1 | SOC_TIMER32_IN_MODULE_TIMER_2 | SOC_TIMER32_IN_MODULE_TIMER_3)) == 0); OS_ASSERT_COND((output_signal_timers & ~(SOC_TIMER32_IN_MODULE_TIMER_0 | SOC_TIMER32_IN_MODULE_TIMER_1 | SOC_TIMER32_IN_MODULE_TIMER_2 | SOC_TIMER32_IN_MODULE_TIMER_3)) == 0); #endif /* set initiator timer */ SET_UINT32(soc_timer32_module[module].tmr[numeric_trans_timer32_in_module(initiator_timer)].tmr_sctl, TMR32_SCTL_MSTR); /* set timers to reinitialized when a compare event occurs on the initiator timer */ while(reinit_timers_!=0) { if (reinit_timers_ & 0x1) { timers_ctrl[FIRST_TIMER_IN_MODULE(module)+i] |= TMR32_CTRL_COINIT; } reinit_timers_ = reinit_timers_ >>1; i++; } /* set timers to forces its output flag signal when a compare event occurs on the initiator timer */ i=0; while(output_signal_timers_ !=0) { if (output_signal_timers_ & 0x1) { SET_UINT32(soc_timer32_module[module].tmr[i].tmr_sctl, TMR32_SCTL_EEOF); } output_signal_timers_ = output_signal_timers_ >>1; i++; } #ifdef B4860_FAMILY DBAR_SCFG(); #endif //B4860_FAMILY return OS_SUCCESS; }
int tsmf_ifman_on_playback_rate_changed(TSMF_IFMAN * ifman) { LLOGLN(0, ("tsmf_ifman_on_playback_rate_changed:")); ifman->output_buffer_size = 16; ifman->output_buffer = malloc(16); SET_UINT32(ifman->output_buffer, 0, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ SET_UINT32(ifman->output_buffer, 4, 0); /* StreamId */ SET_UINT32(ifman->output_buffer, 8, TSMM_CLIENT_EVENT_MONITORCHANGED); /* EventId */ SET_UINT32(ifman->output_buffer, 12, 0); /* cbData */ ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return 0; }
int tsmf_ifman_rim_exchange_capability_request(TSMF_IFMAN * ifman) { uint32 CapabilityValue; CapabilityValue = GET_UINT32(ifman->input_buffer, 0); LLOGLN(0, ("tsmf_ifman_rim_exchange_capability_request: server CapabilityValue %d", CapabilityValue)); ifman->output_buffer_size = 8; ifman->output_buffer = malloc(8); SET_UINT32(ifman->output_buffer, 0, 1); /* CapabilityValue */ SET_UINT32(ifman->output_buffer, 4, 0); /* Result */ return 0; }
static int set_variable_uint(uint32 val, char * data, uint32 * pos) { int cb; if (val <= 0xFF) { cb = 0; SET_UINT8(data, *pos, val); *pos += 1; } else if (val <= 0xFFFF) { cb = 1; SET_UINT16(data, *pos, val); *pos += 2; } else { cb = 3; SET_UINT32(data, *pos, val); *pos += 4; } return cb; }
int cliprdr_send_packet(cliprdrPlugin * plugin, int type, int flag, char * data, int length) { char * out_data; int size; uint32 error; LLOGLN(10, ("cliprdr_send_packet: type=%d, flag=%d, length=%d", type, flag, length)); size = 12 + length; out_data = (char *) malloc(size); memset(out_data, 0, size); SET_UINT16(out_data, 0, (uint16)type); SET_UINT16(out_data, 2, (uint16)flag); SET_UINT32(out_data, 4, (uint32)length); if (data != 0) { memcpy(out_data + 8, data, length); } error = plugin->ep.pVirtualChannelWrite(plugin->open_handle, out_data, size, out_data); if (error != CHANNEL_RC_OK) { LLOGLN(0, ("cliprdr_send_packet: " "VirtualChannelWrite " "failed %d", error)); return 1; } return 0; }
/* Output device redirection capability set header */ void rdpdr_out_capset_header(char* data, int size, uint16 capabilityType, uint16 capabilityLength, uint32 version) { SET_UINT16(data, 0, capabilityType); /* capabilityType */ SET_UINT16(data, 2, capabilityLength); /* capabilityLength */ SET_UINT32(data, 4, version); /* version */ }
os_status osGpioHwiConfigure(int gpio_num, int port, bool edge) { OS_ASSERT_COND(gpio_num < OS_NUM_OF_GPIO); OS_ASSERT_COND(port <= OS_NUM_OF_GPIO_PORTS); CLEAR_UINT32(g_dsp_pa_ccsr_map->gpio[gpio_num].gpdir, 1<<(31-port)); SET_UINT32(g_dsp_pa_ccsr_map->gpio[gpio_num].gpimr, 1<<(31-port)); if (edge == OS_GPIO_EDGE_HIGH_TO_LOW) { SET_UINT32(g_dsp_pa_ccsr_map->gpio[gpio_num].gpicr, 1<<(31-port)); } else { CLEAR_UINT32(g_dsp_pa_ccsr_map->gpio[gpio_num].gpicr, 1<<(31-port)); } return OS_SUCCESS; }
static int audin_send_open_reply_pdu(IWTSVirtualChannelCallback * pChannelCallback, uint32 Result) { AUDIN_CHANNEL_CALLBACK * callback = (AUDIN_CHANNEL_CALLBACK *) pChannelCallback; char out_data[5]; SET_UINT8(out_data, 0, MSG_SNDIN_OPEN_REPLY); SET_UINT32(out_data, 1, Result); return callback->channel->Write(callback->channel, 5, out_data, NULL); }
static int audin_send_format_change_pdu(IWTSVirtualChannelCallback * pChannelCallback, uint32 NewFormat) { AUDIN_CHANNEL_CALLBACK * callback = (AUDIN_CHANNEL_CALLBACK *) pChannelCallback; char out_data[5]; SET_UINT8(out_data, 0, MSG_SNDIN_FORMATCHANGE); SET_UINT32(out_data, 1, NewFormat); return callback->channel->Write(callback->channel, 5, out_data, NULL); }
int tsmf_ifman_exchange_capability_request(TSMF_IFMAN * ifman) { uint8 * p; uint32 numHostCapabilities; uint32 i; uint32 CapabilityType; uint32 cbCapabilityLength; uint32 v; ifman->output_buffer_size = ifman->input_buffer_size + 4; ifman->output_buffer = malloc(ifman->output_buffer_size); memcpy(ifman->output_buffer, ifman->input_buffer, ifman->input_buffer_size); SET_UINT32(ifman->output_buffer, ifman->input_buffer_size, 0); /* Result */ numHostCapabilities = GET_UINT32(ifman->output_buffer, 0); p = ifman->output_buffer + 4; for (i = 0; i < numHostCapabilities; i++) { CapabilityType = GET_UINT32(p, 0); cbCapabilityLength = GET_UINT32(p, 4); switch (CapabilityType) { case 1: /* Protocol version request */ v = GET_UINT32(p, 8); LLOGLN(0, ("tsmf_ifman_exchange_capability_request: server protocol version %d", v)); break; case 2: /* Supported platform */ v = GET_UINT32(p, 8); LLOGLN(0, ("tsmf_ifman_exchange_capability_request: server supported platform %d", v)); /* Claim that we support both MF and DShow platforms. */ SET_UINT32(p, 8, MMREDIR_CAPABILITY_PLATFORM_MF | MMREDIR_CAPABILITY_PLATFORM_DSHOW); break; default: LLOGLN(0, ("tsmf_ifman_exchange_capability_request: unknown capability type %d", CapabilityType)); break; } p += 8 + cbCapabilityLength; } ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; return 0; }
static int process_CREATE_REQUEST_PDU(drdynvcPlugin * plugin, int Sp, int cbChId, char * data, int data_size) { int pos; int error; int size; char * out_data; uint32 ChannelId; pos = 1; ChannelId = get_variable_uint(cbChId, data, &pos); LLOGLN(10, ("process_CREATE_REQUEST_PDU: ChannelId=%d ChannelName=%s", ChannelId, data + pos)); size = pos + 4; out_data = (char *) malloc(size); SET_UINT8(out_data, 0, 0x10 | cbChId); memcpy(out_data + 1, data + 1, pos - 1); error = dvcman_create_channel(plugin->channel_mgr, ChannelId, data + pos); if (error == 0) { LLOGLN(10, ("process_CREATE_REQUEST_PDU: channel created")); SET_UINT32(out_data, pos, 0); } else { LLOGLN(10, ("process_CREATE_REQUEST_PDU: no listener")); SET_UINT32(out_data, pos, (uint32)(-1)); } hexdump(out_data, size); error = plugin->ep.pVirtualChannelWrite(plugin->open_handle, out_data, size, out_data); if (error != CHANNEL_RC_OK) { LLOGLN(0, ("process_CREATE_REQUEST_PDU: " "VirtualChannelWrite " "failed %d", error)); return 1; } return 0; }
char * irp_output_device_io_completion(IRP* irp, int * data_size) { char * data; *data_size = 20 + irp->outputBufferLength; data = malloc(*data_size); memset(data, 0, *data_size); SET_UINT16(data, 0, RDPDR_CTYP_CORE); /* component */ SET_UINT16(data, 2, PAKID_CORE_DEVICE_IOCOMPLETION); /* packetID */ SET_UINT32(data, 4, irp->dev->id); /* deviceID */ SET_UINT32(data, 8, irp->completionID); /* completionID */ SET_UINT32(data, 12, irp->ioStatus); /* ioStatus */ SET_UINT32(data, 16, irp->outputResult); if (irp->outputBufferLength > 0) { memcpy(data + 20, irp->outputBuffer, irp->outputBufferLength); } return data; }
os_status osGpioOutputSet(int gpio_num, int port, bool value) { OS_ASSERT_COND(gpio_num < OS_NUM_OF_GPIO); OS_ASSERT_COND(port <= OS_NUM_OF_GPIO_PORTS); SET_UINT32(g_dsp_pa_ccsr_map->gpio[gpio_num].gpdir, 1<<(31-port)); CLEAR_UINT32(g_dsp_pa_ccsr_map->gpio[gpio_num].gpodr, 1<<(31-port)); if (value == 1) { SET_UINT32(g_dsp_pa_ccsr_map->gpio[gpio_num].gpdat, 1<<(31-port)); } else if (value == 0) { CLEAR_UINT32(g_dsp_pa_ccsr_map->gpio[gpio_num].gpdat, 1<<(31-port)); } else OS_ASSERT; return OS_SUCCESS; }
PCSC_API LONG SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition) { char msg[256]; int code; int bytes; int status; LLOGLN(10, ("SCardDisconnect: hCard 0x%8.8x dwDisposition %d", (int)hCard, (int)dwDisposition)); if (g_sck == -1) { LLOGLN(0, ("SCardDisconnect: error, not connected")); return SCARD_F_INTERNAL_ERROR; } SET_UINT32(msg, 0, hCard); SET_UINT32(msg, 4, dwDisposition); if (send_message(SCARD_DISCONNECT, msg, 8) != 0) { LLOGLN(0, ("SCardDisconnect: error, send_message")); return SCARD_F_INTERNAL_ERROR; } bytes = 256; code = SCARD_DISCONNECT; if (get_message(&code, msg, &bytes) != 0) { LLOGLN(0, ("SCardDisconnect: error, get_message")); return SCARD_F_INTERNAL_ERROR; } if ((code != SCARD_DISCONNECT) || (bytes != 4)) { LLOGLN(0, ("SCardDisconnect: error, bad code")); return SCARD_F_INTERNAL_ERROR; } status = GET_UINT32(msg, 0); LLOGLN(10, ("SCardDisconnect: got status 0x%8.8x", status)); return status; }
int tsmf_ifman_on_playback_stopped(TSMF_IFMAN * ifman) { TSMF_PRESENTATION * presentation; LLOGLN(0, ("tsmf_ifman_on_playback_stopped:")); presentation = tsmf_presentation_find_by_id(ifman->input_buffer); if (presentation) tsmf_presentation_stop(presentation); else LLOGLN(0, ("tsmf_ifman_on_playback_stopped: unknown presentation id")); ifman->output_buffer_size = 16; ifman->output_buffer = malloc(16); SET_UINT32(ifman->output_buffer, 0, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ SET_UINT32(ifman->output_buffer, 4, 0); /* StreamId */ SET_UINT32(ifman->output_buffer, 8, TSMM_CLIENT_EVENT_STOP_COMPLETED); /* EventId */ SET_UINT32(ifman->output_buffer, 12, 0); /* cbData */ ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return 0; }
static int send_message(int code, char *data, int bytes) { char header[8]; pthread_mutex_lock(&g_mutex); SET_UINT32(header, 0, bytes); SET_UINT32(header, 4, code); if (send(g_sck, header, 8, 0) != 8) { pthread_mutex_unlock(&g_mutex); return 1; } if (send(g_sck, data, bytes, 0) != bytes) { pthread_mutex_unlock(&g_mutex); return 1; } LLOGLN(10, ("send_message:")); LHEXDUMP(10, (data, bytes)); pthread_mutex_unlock(&g_mutex); return 0; }
PCSC_API LONG SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition) { char msg[256]; int code; int bytes; int status; LLOGLN(10, ("SCardEndTransaction:")); if (g_sck == -1) { LLOGLN(0, ("SCardEndTransaction: error, not connected")); return SCARD_F_INTERNAL_ERROR; } SET_UINT32(msg, 0, hCard); SET_UINT32(msg, 4, dwDisposition); if (send_message(SCARD_END_TRANSACTION, msg, 8) != 0) { LLOGLN(0, ("SCardEndTransaction: error, send_message")); return SCARD_F_INTERNAL_ERROR; } bytes = 256; code = SCARD_END_TRANSACTION; if (get_message(&code, msg, &bytes) != 0) { LLOGLN(0, ("SCardEndTransaction: error, get_message")); return SCARD_F_INTERNAL_ERROR; } if ((code != SCARD_END_TRANSACTION) || (bytes != 4)) { LLOGLN(0, ("SCardEndTransaction: error, bad code")); return SCARD_F_INTERNAL_ERROR; } status = GET_UINT32(msg, 0); LLOGLN(10, ("SCardEndTransaction: got status 0x%8.8x", status)); return status; }
int tsmf_ifman_shutdown_presentation(TSMF_IFMAN * ifman) { TSMF_PRESENTATION * presentation; LLOGLN(0, ("tsmf_ifman_shutdown_presentation:")); presentation = tsmf_presentation_find_by_id(ifman->input_buffer); if (presentation) tsmf_presentation_free(presentation); ifman->output_buffer_size = 4; ifman->output_buffer = malloc(4); SET_UINT32(ifman->output_buffer, 0, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; return 0; }
int tsmf_ifman_on_end_of_stream(TSMF_IFMAN * ifman) { TSMF_PRESENTATION * presentation; TSMF_STREAM * stream; uint32 StreamId; presentation = tsmf_presentation_find_by_id(ifman->input_buffer); StreamId = GET_UINT32(ifman->input_buffer, 16); stream = tsmf_stream_find_by_id(presentation, StreamId); tsmf_stream_end(stream); LLOGLN(0, ("tsmf_ifman_on_end_of_stream: StreamId %d", StreamId)); ifman->output_buffer_size = 16; ifman->output_buffer = malloc(16); SET_UINT32(ifman->output_buffer, 0, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ SET_UINT32(ifman->output_buffer, 4, StreamId); /* StreamId */ SET_UINT32(ifman->output_buffer, 8, TSMM_CLIENT_EVENT_ENDOFSTREAM); /* EventId */ SET_UINT32(ifman->output_buffer, 12, 0); /* cbData */ ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return 0; }
/* Output device direction general capability set */ int rdpdr_out_general_capset(char* data, int size) { SET_UINT32(data, 8, 0); /* osType, ignored on receipt */ SET_UINT32(data, 12, 0); /* osVersion, unused and must be set to zero */ SET_UINT16(data, 16, 1); /* protocolMajorVersion, must be set to 1 */ SET_UINT16(data, 18, RDPDR_MINOR_RDP_VERSION_5_2); /* protocolMinorVersion */ SET_UINT32(data, 20, 0x0000FFFF); /* ioCode1 */ SET_UINT32(data, 24, 0); /* ioCode2, must be set to zero, reserved for future use */ SET_UINT32(data, 28, RDPDR_DEVICE_REMOVE_PDUS | RDPDR_CLIENT_DISPLAY_NAME_PDU | RDPDR_USER_LOGGEDON_PDU); /* extendedPDU */ SET_UINT32(data, 32, ENABLE_ASYNCIO); /* extraFlags1 */ SET_UINT32(data, 36, 0); /* extraFlags2, must be set to zero, reserved for future use */ SET_UINT32(data, 40, 0); /* SpecialTypeDeviceCap, number of special devices to be redirected before logon */ rdpdr_out_capset_header(data, size, CAP_GENERAL_TYPE, 44, GENERAL_CAPABILITY_VERSION_02); return 44; }
PCSC_API LONG SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext) { char msg[256]; DWORD context; int code; int bytes; int status; LLOGLN(10, ("SCardEstablishContext:")); if (g_sck == -1) { if (connect_to_chansrv() != 0) { LLOGLN(0, ("SCardEstablishContext: error, can not connect " "to chansrv")); return SCARD_F_INTERNAL_ERROR; } } SET_UINT32(msg, 0, dwScope); if (send_message(SCARD_ESTABLISH_CONTEXT, msg, 4) != 0) { LLOGLN(0, ("SCardEstablishContext: error, send_message")); return SCARD_F_INTERNAL_ERROR; } bytes = 256; code = SCARD_ESTABLISH_CONTEXT; if (get_message(&code, msg, &bytes) != 0) { LLOGLN(0, ("SCardEstablishContext: error, get_message")); return SCARD_F_INTERNAL_ERROR; } if ((code != SCARD_ESTABLISH_CONTEXT) || (bytes != 8)) { LLOGLN(0, ("SCardEstablishContext: error, bad code")); return SCARD_F_INTERNAL_ERROR; } context = GET_UINT32(msg, 0); status = GET_UINT32(msg, 4); LLOGLN(10, ("SCardEstablishContext: got context 0x%8.8x", (int)context)); *phContext = context; return status; }
/* Decodes the raw packet in buf to create a rr. Assumes buf points to the * start of a rr. * Note: Question rrs dont have rdatalen or rdata. Set is_question when * decoding question rrs, else clear is_question */ void dns_decode_rr(struct dns_rr *rr, char **buf, int is_question,char *header, char *buf_start, struct dns_message *m) { /* if the first two bits the of the name are set, then the message has been compressed and so the next byte is an offset from the start of the message pointing to the start of the name */ if( **buf & 0xC0 ){ (*buf)++; header += *(*buf)++; dns_decode_name( rr->name, &header ); }else{ /* ordinary decode name */ dns_decode_name( rr->name, buf ); } SET_UINT16( rr->type, buf ); SET_UINT16( rr->class, buf); if( is_question != 1 ){ SET_UINT32( rr->ttl, buf ); SET_UINT16( rr->rdatalen, buf ); /* BRCM message format wrong. drop it */ if(((*buf - buf_start) >= MAX_PACKET_SIZE) || (((*buf - buf_start) + rr->rdatalen) >= MAX_PACKET_SIZE) || (rr->rdatalen >= MAX_PACKET_SIZE/2)) { m->header.ancount = 0; return; } memcpy( rr->data, *buf, rr->rdatalen ); *buf += rr->rdatalen; /* for(i = 0; i < rr->rdatalen; i+=4 ) SET_UINT32( (uint32)rr->data[i], buf ); */ } if( rr->type == PTR ){ /* reverse lookup */ dns_decode_reverse_name( rr->name ); } }
PCSC_API LONG SCardBeginTransaction(SCARDHANDLE hCard) { char msg[256]; int code; int bytes; int status; LLOGLN(10, ("SCardBeginTransaction: hCard 0x%8.8x", (int)hCard)); if (hCard == 0) { LLOGLN(0, ("SCardBeginTransaction: error, bad hCard")); return SCARD_F_INTERNAL_ERROR; } if (g_sck == -1) { LLOGLN(0, ("SCardBeginTransaction: error, not connected")); return SCARD_F_INTERNAL_ERROR; } SET_UINT32(msg, 0, hCard); if (send_message(SCARD_BEGIN_TRANSACTION, msg, 4) != 0) { LLOGLN(0, ("SCardBeginTransaction: error, send_message")); return SCARD_F_INTERNAL_ERROR; } bytes = 256; code = SCARD_BEGIN_TRANSACTION; if (get_message(&code, msg, &bytes) != 0) { LLOGLN(0, ("SCardBeginTransaction: error, get_message")); return SCARD_F_INTERNAL_ERROR; } if ((code != SCARD_BEGIN_TRANSACTION) || (bytes != 4)) { LLOGLN(0, ("SCardBeginTransaction: error, bad code")); return SCARD_F_INTERNAL_ERROR; } status = GET_UINT32(msg, 0); LLOGLN(10, ("SCardBeginTransaction: got status 0x%8.8x", status)); return status; }
static int audin_process_version(IWTSVirtualChannelCallback * pChannelCallback, char * data, uint32 data_size) { AUDIN_CHANNEL_CALLBACK * callback = (AUDIN_CHANNEL_CALLBACK *) pChannelCallback; uint32 Version; uint32 out_size; char * out_data; int error; Version = GET_UINT32(data, 0); LLOGLN(10, ("audin_process_version: Version=%d", Version)); out_size = 5; out_data = (char *) malloc(out_size); memset(out_data, 0, out_size); SET_UINT8(out_data, 0, MSG_SNDIN_VERSION); SET_UINT32(out_data, 1, Version); error = callback->channel->Write(callback->channel, out_size, out_data, NULL); free(out_data); return error; }
PCSC_API LONG SCardReleaseContext(SCARDCONTEXT hContext) { char msg[256]; int code; int bytes; int status; LLOGLN(10, ("SCardReleaseContext:")); if (g_sck == -1) { LLOGLN(0, ("SCardReleaseContext: error, not connected")); return SCARD_F_INTERNAL_ERROR; } SET_UINT32(msg, 0, hContext); if (send_message(SCARD_RELEASE_CONTEXT, msg, 4) != 0) { LLOGLN(0, ("SCardReleaseContext: error, send_message")); return SCARD_F_INTERNAL_ERROR; } bytes = 256; code = SCARD_RELEASE_CONTEXT; if (get_message(&code, msg, &bytes) != 0) { LLOGLN(0, ("SCardReleaseContext: error, get_message")); return SCARD_F_INTERNAL_ERROR; } if ((code != SCARD_RELEASE_CONTEXT) || (bytes != 4)) { LLOGLN(0, ("SCardReleaseContext: error, bad code")); return SCARD_F_INTERNAL_ERROR; } status = GET_UINT32(msg, 0); LLOGLN(10, ("SCardReleaseContext: got status 0x%8.8x", status)); return status; }