/** * parse dns request */ int parse(char *buf,size_t len,SA *addr){ if(verbal>1) fprintf(stdout, "--------------in parse-------------\n"); checkbuf(buf,len); struct sockaddr_in tmpaddr = *((struct sockaddr_in*)addr); char* clientIP = inet_ntoa(tmpaddr.sin_addr); char name[MAXLINE] = {0}; char data[MAXLINE] = {0}; packet_t *packet = (packet_t *) buf; unsigned short requestID = packet->header.id; send_packet_t *sendPacket; parseRequestData(packet->data,name); fprintf(stdout,"name: %s\n",name); if(!strcmp(name,REQUESTNAME)){ int datalen=buildResponseData(packet->data,len-HEADER_LEN,data,clientIP); sendPacket=construct_response_packet(requestID,0,datalen,data,addr); checkbuf((char *)(sendPacket->data),datalen+HEADER_LEN); }else{ logWrite(clientIP,name,"0.0.0.0"); sendPacket=construct_response_packet(requestID,3,len-HEADER_LEN,packet->data,addr); } if(sendPacket!=NULL){ char *tmp = sendPacket->data->data; tmp+=len-HEADER_LEN; fprintf(stdout,"%d.%d.%d.%d\n",(int)(*(tmp+12)),(int)(*(tmp+13)),(int)(*(tmp+14)),(int)(*(tmp+15))); enqueue(DNS_stat->send_packets,sendPacket); } if(verbal>1) fprintf(stdout, "--------------in parse - done-------------\n"); return 0; }
void TransmRpcSession::dataReceived(bool error) { if(error) { QMessageBox::warning(parent, tr("TranRem"), tr("Error recieving data!"), QMessageBox::Ok ); //qDebug() << "Error recieving data!" << http->errorString(); emit errorSignal(dataRecievingError); } else { switch(http->lastResponse().statusCode()) { case 409: transmSessionId = http->lastResponse().value("X-Transmission-Session-Id"); requestHeader.setValue("X-Transmission-Session-Id", transmSessionId); response->close(); response->buffer().clear(); http->request(requestHeader, requestBody, response);//check this!!! break; case 200: response->seek(0); if(parseRequestData()) { emit requestComplete(); /* //debug qDebug() << "Tag: " << Tag << " Result: " << Result; int i; for(i=0;i<Torrents.size();i++) qDebug() << "# " << i << " Status: " << Torrents.at(i).status(); //end debug */ } else emit errorSignal(parsingError); break; default: QMessageBox::warning(parent, tr("TranRem"), tr("Response status code: %1").arg(http->lastResponse().statusCode()), QMessageBox::Ok ); //qDebug() << "Response status code: " << http->lastResponse().statusCode(); response->close(); response->buffer().clear(); emit errorSignal(connectionError); } }; };