static PyObject * canbridge_input_recv(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, "")) return NULL; input_recv(); return Py_BuildValue(""); }
static BOOL peer_recv_data_pdu(freerdp_peer* client, wStream* s) { BYTE type; UINT16 length; UINT32 share_id; BYTE compressed_type; UINT16 compressed_len; if (!rdp_read_share_data_header(s, &length, &type, &share_id, &compressed_type, &compressed_len)) return FALSE; #ifdef WITH_DEBUG_RDP WLog_DBG(TAG, "recv %s Data PDU (0x%02"PRIX8"), length: %"PRIu16"", type < ARRAYSIZE(DATA_PDU_TYPE_STRINGS) ? DATA_PDU_TYPE_STRINGS[type] : "???", type, length); #endif switch (type) { case DATA_PDU_TYPE_SYNCHRONIZE: if (!rdp_recv_client_synchronize_pdu(client->context->rdp, s)) return FALSE; break; case DATA_PDU_TYPE_CONTROL: if (!rdp_server_accept_client_control_pdu(client->context->rdp, s)) return FALSE; break; case DATA_PDU_TYPE_INPUT: if (!input_recv(client->context->rdp->input, s)) return FALSE; break; case DATA_PDU_TYPE_BITMAP_CACHE_PERSISTENT_LIST: /* TODO: notify server bitmap cache data */ break; case DATA_PDU_TYPE_FONT_LIST: if (!rdp_server_accept_client_font_list_pdu(client->context->rdp, s)) return FALSE; break; case DATA_PDU_TYPE_SHUTDOWN_REQUEST: mcs_send_disconnect_provider_ultimatum(client->context->rdp->mcs); return FALSE; case DATA_PDU_TYPE_FRAME_ACKNOWLEDGE: if (Stream_GetRemainingLength(s) < 4) return FALSE; Stream_Read_UINT32(s, client->ack_frame_id); IFCALL(client->update->SurfaceFrameAcknowledge, client->update->context, client->ack_frame_id); break; case DATA_PDU_TYPE_REFRESH_RECT: if (!update_read_refresh_rect(client->update, s)) return FALSE; break; case DATA_PDU_TYPE_SUPPRESS_OUTPUT: if (!update_read_suppress_output(client->update, s)) return FALSE; break; default: WLog_ERR(TAG, "Data PDU type %"PRIu8"", type); break; } return TRUE; }
int main(int argc, char **argv) { char *localip; int localport; char* remoteip; int remoteport; FILE* logfile; char* logfile_name; struct stat logfile_stats; long logfile_len; union pkt_any out; union pkt_any in; if (argc != 6) { printf("usage: dummysender <local ip> <local port> " "<remote ip> <remote port> <logfile name>\n"); return 0; } localip = argv[1]; localport = atoi(argv[2]); remoteip = argv[3]; remoteport = atoi(argv[4]); logfile_name = argv[5]; printf("using %s:%d -> %s:%d\n", localip, localport, remoteip, remoteport); printf("Sending logfile: %s\n", logfile_name); logfile = fopen(logfile_name, "r"); if(logfile == NULL){ perror("fopen"); fprintf(stderr, "Error opening log file for sending\n"); exit(1); } stat(logfile_name, &logfile_stats); logfile_len = logfile_stats.st_size; if (socket_init(localip, localport, remoteip, remoteport)) return -1; input_init(); output_init(); while(!feof(logfile)){ //int priority, node, channel;// value; //unsigned int timestamp; // unsigned long long otherstamp; uint32_t header; uint64_t payload; long double scanalysis_time; fscanf(logfile, "%x %Lx %Lf", &header, &payload, &scanalysis_time); out.sample.type = PKT_SAMPLE; out.sample.can.id = header; out.sample.can.data[0] = (payload >> 56) & 0xFF; out.sample.can.data[1] = (payload >> 48) & 0xFF; out.sample.can.data[2] = (payload >> 40 ) & 0xFF; out.sample.can.data[3] = (payload >> 32 ) & 0xFF; out.sample.can.data[4] = (payload >> 24) & 0xFF; out.sample.can.data[5] = (payload >> 16) & 0xFF; out.sample.can.data[6] = (payload >> 8 ) & 0xFF; out.sample.can.data[7] = (payload >> 0 ) & 0xFF; out.sample.can.length = 8; output_queue(&out); out.sample.type = PKT_SAMPLE; /* WHAT THE F**K IS THIS SHIT switch(node){ case 5: out.sample.can.id = fake_heartbeat_id(node, 28); break; case 26: out.sample.can.id = fake_heartbeat_id(node, 26); break; case 111: case 113: out.sample.can.id = fake_heartbeat_id(node, 25); break; case 40: out.sample.can.id = fake_heartbeat_id(node, 13); break; case 30: out.sample.can.id = fake_heartbeat_id(node, 23); break; case 155: case 160: case 165: case 170: case 175: case 180: case 185: out.sample.can.id = fake_heartbeat_id(node, 22); break; } */ /* again, wtf out.sample.can.data[0] = 0; out.sample.can.data[1] = 0; out.sample.can.data[2] = 0; out.sample.can.data[3] = 0; out.sample.can.data[4] = (timestamp >> 24) & 0xFF; out.sample.can.data[5] = (timestamp >> 16) & 0xFF; out.sample.can.data[6] = (timestamp >> 8 ) & 0xFF; out.sample.can.data[7] = (timestamp >> 0 ) & 0xFF; out.sample.can.length = 8; output_queue(&out); */ fprintf(stdout, "\r%d%%\r", (int)(100.0 * ((float)ftell(logfile)) / (float)logfile_len)); while(input_dequeue(&in)==0){ printf("Recieved " "packet_type=%d " "packet_id=%d " "can_id=%x " "can.data=[%x %x %x %x %x %x %x %x] " "can_length=%d\n", in.sample.type, in.sample.packet_id, in.sample.can.id & 0x1FFFFFFF, in.sample.can.data[0], in.sample.can.data[1], in.sample.can.data[2], in.sample.can.data[3], in.sample.can.data[4], in.sample.can.data[5], in.sample.can.data[6], in.sample.can.data[7], in.sample.can.length ); } output_send(); input_recv(); usleep(5000); } return 0; }
static BOOL peer_recv_data_pdu(freerdp_peer* client, wStream* s) { BYTE type; UINT16 length; UINT32 share_id; BYTE compressed_type; UINT16 compressed_len; if (!rdp_read_share_data_header(s, &length, &type, &share_id, &compressed_type, &compressed_len)) return FALSE; switch (type) { case DATA_PDU_TYPE_SYNCHRONIZE: if (!rdp_recv_client_synchronize_pdu(client->context->rdp, s)) return FALSE; break; case DATA_PDU_TYPE_CONTROL: if (!rdp_server_accept_client_control_pdu(client->context->rdp, s)) return FALSE; break; case DATA_PDU_TYPE_INPUT: if (!input_recv(client->context->rdp->input, s)) return FALSE; break; case DATA_PDU_TYPE_BITMAP_CACHE_PERSISTENT_LIST: /* TODO: notify server bitmap cache data */ break; case DATA_PDU_TYPE_FONT_LIST: if (!rdp_server_accept_client_font_list_pdu(client->context->rdp, s)) return FALSE; if (!client->connected) { /** * PostConnect should only be called once and should not be called * after a reactivation sequence. */ IFCALLRET(client->PostConnect, client->connected, client); if (!client->connected) return FALSE; } if (!client->activated) { /* Activate will be called everytime after the client is activated/reactivated. */ IFCALLRET(client->Activate, client->activated, client); if (!client->activated) return FALSE; } break; case DATA_PDU_TYPE_SHUTDOWN_REQUEST: mcs_send_disconnect_provider_ultimatum(client->context->rdp->mcs); return FALSE; case DATA_PDU_TYPE_FRAME_ACKNOWLEDGE: if(stream_get_left(s) < 4) return FALSE; stream_read_UINT32(s, client->ack_frame_id); break; case DATA_PDU_TYPE_REFRESH_RECT: if (!update_read_refresh_rect(client->update, s)) return FALSE; break; case DATA_PDU_TYPE_SUPPRESS_OUTPUT: if (!update_read_suppress_output(client->update, s)) return FALSE; break; default: fprintf(stderr, "Data PDU type %d\n", type); break; } return TRUE; }