Пример #1
0
void PrintUdpPacket(unsigned char *Buffer,int Size)
{
	unsigned short iphdrlen;
		
	iphdr = (IPV4_HDR *)Buffer;
	iphdrlen = iphdr->ip_header_len*4;
	
	udpheader = (UDP_HDR *)(Buffer + iphdrlen);
	
	fprintf(logfile,"\n\n***********************UDP Packet*************************\n");
	
	PrintIpHeader(Buffer,Size);			
	
	fprintf(logfile,"\nUDP Header\n");
	fprintf(logfile,"   |-Source Port      : %d\n",ntohs(udpheader->source_port));
	fprintf(logfile,"   |-Destination Port : %d\n",ntohs(udpheader->dest_port));
	fprintf(logfile,"   |-UDP Length       : %d\n",ntohs(udpheader->udp_length));
	fprintf(logfile,"   |-UDP Checksum     : %d\n",ntohs(udpheader->udp_checksum));
	
	fprintf(logfile,"\n");
	fprintf(logfile,"IP Header\n");
	PrintData(Buffer,iphdrlen);
		
	fprintf(logfile,"UDP Header\n");
	PrintData(Buffer+iphdrlen,sizeof(UDP_HDR));
		
	fprintf(logfile,"Data Payload\n");	
	PrintData(Buffer+iphdrlen+sizeof(UDP_HDR)
		,(Size - sizeof(UDP_HDR) - iphdr->ip_header_len*4));
	
	fprintf(logfile,"\n###########################################################");
}
Пример #2
0
static QList<PrintLine> alignPrinterData(DirectPrintContext *print_context, const ReceiptsPrinterOptions &printer_options)
{
	QList<PrintLine> ret;
	int line_length = printer_options.characterPrinterLineLength();
	PrintLine line;
	{
		line << PrintData(PrintData::Command::Init);
		ret.insert(ret.length(), line);
	}
	line.clear();
	for (int i = 0; i < print_context->line.count(); ++i) {
		const PrintData &pd = print_context->line[i];
		bool is_eol = (pd.command == PrintData::Command::Eoln) || (i == (print_context->line.count() - 1));
		if(pd.command != PrintData::Command::Eoln) {
			line << pd;
		}
		if(is_eol) {
			int fixed_text_len = 0;
			int spring_cnt = 0;
			for (int j = 0; j < line.length(); ++j) {
				const PrintData &pd2 = line[j];
				if(pd2.width < 0)
					spring_cnt++;
				else if(pd2.width > 0)
					fixed_text_len += pd2.width;
				else
					fixed_text_len += pd2.textLength();
			}
			for (int j = 0; j < line.length(); ++j) {
				PrintData &pd2 = line[j];
				if(pd2.isCommand())
					continue;
				int w = pd2.width;
				if(w < 0)
					w = (line_length - fixed_text_len) / spring_cnt;
				if(w > 0) {
					int w_rest = w - pd2.textLength();
					if(w_rest > 0) {
						if(pd2.alignment == Qt::AlignLeft)
							pd2.data = pd2.data + QByteArray(w_rest, ' ');
						else if(pd2.alignment == Qt::AlignRight)
							pd2.data = QByteArray(w_rest, ' ') + pd2.data;
						else if(pd2.alignment == Qt::AlignHCenter)
							pd2.data = QByteArray(w_rest/2+1, ' ') + pd2.data + QByteArray(w_rest/2+1, ' ');
					}
					pd2.data = pd2.data.mid(0, w);
					pd2.width = 0;
				}
			}
			ret.insert(ret.length(), line);
			line.clear();
		}
	}
	{
		line.clear();
		line << PrintData(PrintData::Command::Cut);
		ret.insert(ret.length(), line);
	}
	return ret;
}
Пример #3
0
void print_udp_packet(unsigned char *Buffer , int Size)
{
     
    unsigned short iphdrlen;
     
    struct iphdr *iph = (struct iphdr *)Buffer;
    iphdrlen = iph->ihl*4;
     
    struct udphdr *udph = (struct udphdr*)(Buffer + iphdrlen);
     
    fprintf(logfile,"\n\n***********************UDP Packet*************************\n");
     
    print_ip_header(Buffer,Size);           
     
    fprintf(logfile,"\nUDP Header\n");
    fprintf(logfile,"   |-Source Port      : %d\n" , ntohs(udph->source));
    fprintf(logfile,"   |-Destination Port : %d\n" , ntohs(udph->dest));
    fprintf(logfile,"   |-UDP Length       : %d\n" , ntohs(udph->len));
    fprintf(logfile,"   |-UDP Checksum     : %d\n" , ntohs(udph->check));
     
    fprintf(logfile,"\n");
    fprintf(logfile,"IP Header\n");
    PrintData(Buffer , iphdrlen);
         
    fprintf(logfile,"UDP Header\n");
    PrintData(Buffer+iphdrlen , sizeof udph);
         
    fprintf(logfile,"Data Payload\n");  
    PrintData(Buffer + iphdrlen + sizeof udph ,( Size - sizeof udph - iph->ihl * 4 ));
     
    fprintf(logfile,"\n###########################################################");
}
Пример #4
0
/*
Print the UDP header for UDP packets
*/
void print_udp_packet(u_char *Buffer, int Size)
{
	int iphdrlen = 0, data_size = 0;

	iphdr = (IPV4_HDR *)(Buffer + sizeof(ETHER_HDR));
	iphdrlen = iphdr->ip_header_len * 4;

	udpheader = (UDP_HDR*)(Buffer + iphdrlen + sizeof(ETHER_HDR));

	data = (Buffer + sizeof(ETHER_HDR)+iphdrlen + sizeof(UDP_HDR));
	data_size = (Size - sizeof(ETHER_HDR)-iphdrlen - sizeof(UDP_HDR));

	fprintf(logfile, "\n\n***********************UDP Packet*************************\n");

	PrintIpHeader(Buffer, Size);

	fprintf(logfile, "\nUDP Header\n");
	fprintf(logfile, " |-Source Port : %d\n", ntohs(udpheader->source_port));
	fprintf(logfile, " |-Destination Port : %d\n", ntohs(udpheader->dest_port));
	fprintf(logfile, " |-UDP Length : %d\n", ntohs(udpheader->udp_length));
	fprintf(logfile, " |-UDP Checksum : %d\n", ntohs(udpheader->udp_checksum));

	fprintf(logfile, "\n");

	fprintf(logfile, "IP Header\n");
	PrintData((u_char*)iphdr, iphdrlen);

	fprintf(logfile, "UDP Header\n");
	PrintData((u_char*)udpheader, sizeof(UDP_HDR));

	fprintf(logfile, "Data Payload\n");
	PrintData(data, data_size);

	fprintf(logfile, "\n###########################################################\n");
}
void PrintNode(PNode *Tree){
	if (*Tree){
		printf("Элемент: ");
		PrintData(&(*Tree)->data);
		if ((*Tree)->left){
			printf(" Л: ");
			PrintData(&(*Tree)->left->data);
		}
		else
			printf(" Л: *");
		
		if ((*Tree)->right){
			printf(" П: ");
			PrintData(&(*Tree)->right->data);
		}
		else 
			printf(" П: *");
		printf("\n");
		if ((*Tree)->left){
			PrintNode(&(*Tree)->left);
		}
		if ((*Tree)->right){
			PrintNode(&((*Tree)->right));
		}
	}
}
Пример #6
0
//Methods
void CFDRunClass::Run()
{
SetInitialConditions();
bool velcheck;
UpdateFluidFlag();
SetPreliminaryGuessValues();
float t=0;
int m=0;
do
{
 	RunNavierStokes();
	velcheck=UpdateVelocity();
	RunFreeSurfaceCalc();
	t+=dt;
	m+=1;
	vector<float> timevec;
	timevec.push_back(0.02);timevec.push_back(0.05);timevec.push_back(0.1);timevec.push_back(0.2);timevec.push_back(0.3);timevec.push_back(0.4);timevec.push_back(0.5);timevec.push_back(0.6);timevec.push_back(0.7);timevec.push_back(0.8);timevec.push_back(0.9);timevec.push_back(1.0);
	//timevec.push_back(0.01);timevec.push_back(0.02);timevec.push_back(0.05);timevec.push_back(0.1);timevec.push_back(0.2);timevec.push_back(0.3);timevec.push_back(0.4);
	for(int mit=0;mit<=11;mit++)
	{
	if(t==timevec[mit] || ((t-dt)<timevec[mit] && t>timevec[mit]))
	{
	PrintData(m,t);
	PrintFreeSurfaceData(m);
	}
	}
}while((t<tmax)&&(velcheck==true));
PrintData(m,t);
}
Пример #7
0
int main()
{
    SList s,s1,s2;
    s1=Created();
    s2=Created();
    PrintData(s1);
    PrintData(s2);
    s=Merge(s1,s2);
    printf("\t");
    PrintData(s);
}
Пример #8
0
void CUdpProcess::RunL()
    {
    __FLOG_STATIC0(KSubSys, KLogComponent , _L8("CUdpProcess::RunL"));
    switch (iProcessState)
        {
        case EDataSending:
            //As a client, send data first.
            iSendBuf.SetLength(iSize);
            iSendBuf.Repeat(KSendData());
            iConsole.Printf(_L("Send data.."));
            PrintData(iSendBuf);
            iConsole.Printf(_L("In RunL, port=%d"), iAddr.Port());
            TInt sendLen = SendDataL(iSendBuf, iAddr, iSize);
            
            if (sendLen != iSize)
                {
                iConsole.Printf(
                        _L("The length of data sent is not equal to requested! requested[%d], sent[%d]"),
                        iSize, sendLen);
                }
            break;

        case EDataTransfer:
            //In data transfer, some data is received
            iConsole.Printf(_L("recv Package, size[%d], status[%d]\n"),
                    iRecvSize(), iStatus.Int());
            if (KErrNone == iStatus.Int())
                {
                iConsole.Printf(_L("Receive data."));
                PrintData(iRecvBuf);

                if (iMode)
                    {
                    //As a server, send back the data received
                    TInt len = SendDataL(iRecvBuf, iPeerAddr, iRecvBuf.Length());
                    iConsole.Printf(_L("Send back the data. len[%d]"), len);
                    }
                }
            else
                {
                iConsole.Printf(_L("Something is wrong..."));
                return;
                }

            iRecvBuf.SetLength(0);
            iRecvSize = iSize;
            //iListenSocket.RecvFrom(iRecvBuf, iPeerAddr, 0, iStatus);
            iSocket.RecvFrom(iRecvBuf, iPeerAddr, 0, iStatus);
            SetActive();
            iConsole.Printf(_L("\nWait for UDP incoming data at port[%d]...\n"),iPort);
            break;
        }
    }
Пример #9
0
int main()
{
  double V0[] = {1,0,0,1,0,0};
  std::vector<double> Vertices0(V0, V0+6);
  Triangle<2>::SetGlobalCoordinatesArray(Vertices0);
  Triangle<2> P10(1,2,3);
  ShapesP12D::Bulk P10Shapes(&P10);
  
  std::cout << "Parametric triangle\n";
  PrintData(P10Shapes);

  std::cout << "\nTwice Parametric triangle\n";

  double V1[] = {2,0,0,2,0,0};
  std::vector<double> Vertices1(V1, V1+6);
  Triangle<2>::SetGlobalCoordinatesArray(Vertices1);
  Triangle<2> P11(1,2,3);
  ShapesP12D::Bulk P11Shapes(&P11);

  PrintData(P11Shapes);

  std::cout << "\nReordered nodes of  twice parametric triangle\n";

  double V2[] = {0,0,2,0,0,2};
  std::vector<double> Vertices2(V2, V2+6);
  Triangle<2>::SetGlobalCoordinatesArray(Vertices2);
  Triangle<2> P12(1,2,3);
  ShapesP12D::Bulk P12Shapes(&P12);

  PrintData(P12Shapes);

  std::cout << "\n Equilateral triangle with area sqrt(3)\n";

  double V3[] = {0,0,2,0,1,sqrt(3)};
  std::vector<double> Vertices3(V3, V3+6);
  Triangle<2>::SetGlobalCoordinatesArray(Vertices3);
  Triangle<2> P13(1,2,3);
  ShapesP12D::Bulk P13Shapes(&P13);

  PrintData(P13Shapes);

  std::cout << "\n Irregular triangle with area sqrt(3)\n";

  double V4[] = {0,0,2,0,2.5,sqrt(3)};
  std::vector<double> Vertices4(V4, V4+6);
  Triangle<2>::SetGlobalCoordinatesArray(Vertices4);
  Triangle<2> P14(1,2,3);
  ShapesP12D::Bulk P14Shapes(&P14);

  PrintData(P14Shapes);

}
Пример #10
0
/*
Print the TCP header for TCP packets
*/
void PrintTcpPacket(u_char* Buffer, int Size)
{
	unsigned short iphdrlen;
	int header_size = 0, tcphdrlen, data_size;

	iphdr = (IPV4_HDR *)(Buffer + sizeof(ETHER_HDR));
	iphdrlen = iphdr->ip_header_len * 4;

	tcpheader = (TCP_HDR*)(Buffer + iphdrlen + sizeof(ETHER_HDR));
	tcphdrlen = tcpheader->data_offset * 4;

	data = (Buffer + sizeof(ETHER_HDR)+iphdrlen + tcphdrlen);
	data_size = (Size - sizeof(ETHER_HDR)-iphdrlen - tcphdrlen);

	fprintf(logfile, "\n\n***********************TCP Packet*************************\n");

	PrintIpHeader(Buffer, Size);

	fprintf(logfile, "\n");
	fprintf(logfile, "TCP Header\n");
	fprintf(logfile, " |-Source Port : %u\n", ntohs(tcpheader->source_port));
	fprintf(logfile, " |-Destination Port : %u\n", ntohs(tcpheader->dest_port));
	fprintf(logfile, " |-Sequence Number : %u\n", ntohl(tcpheader->sequence));
	fprintf(logfile, " |-Acknowledge Number : %u\n", ntohl(tcpheader->acknowledge));
	fprintf(logfile, " |-Header Length : %d DWORDS or %d BYTES\n", (unsigned int)tcpheader->data_offset, (unsigned int)tcpheader->data_offset * 4);
	fprintf(logfile, " |-CWR Flag : %d\n", (unsigned int)tcpheader->cwr);
	fprintf(logfile, " |-ECN Flag : %d\n", (unsigned int)tcpheader->ecn);
	fprintf(logfile, " |-Urgent Flag : %d\n", (unsigned int)tcpheader->urg);
	fprintf(logfile, " |-Acknowledgement Flag : %d\n", (unsigned int)tcpheader->ack);
	fprintf(logfile, " |-Push Flag : %d\n", (unsigned int)tcpheader->psh);
	fprintf(logfile, " |-Reset Flag : %d\n", (unsigned int)tcpheader->rst);
	fprintf(logfile, " |-Synchronise Flag : %d\n", (unsigned int)tcpheader->syn);
	fprintf(logfile, " |-Finish Flag : %d\n", (unsigned int)tcpheader->fin);
	fprintf(logfile, " |-Window : %d\n", ntohs(tcpheader->window));
	fprintf(logfile, " |-Checksum : %d\n", ntohs(tcpheader->checksum));
	fprintf(logfile, " |-Urgent Pointer : %d\n", tcpheader->urgent_pointer);
	fprintf(logfile, "\n");
	fprintf(logfile, " DATA Dump ");
	fprintf(logfile, "\n");

	fprintf(logfile, "IP Header\n");
	PrintData((u_char*)iphdr, iphdrlen);

	fprintf(logfile, "TCP Header\n");
	PrintData((u_char*)tcpheader, tcphdrlen);

	fprintf(logfile, "Data Payload\n");
	PrintData(data, data_size);

	fprintf(logfile, "\n###########################################################\n");
}
Пример #11
0
void CPacket::ProcessTCPPacket(const unsigned char* pBuffer, int nSize)
{
	unsigned short iphdrlen;

	struct iphdr *iph = (struct iphdr *)( pBuffer  + sizeof(struct ethhdr) );
	iphdrlen = iph->ihl*4;

	struct tcphdr *tcph=(struct tcphdr*)(pBuffer + iphdrlen + sizeof(struct ethhdr));

	int header_size =  sizeof(struct ethhdr) + iphdrlen + tcph->doff*4;

	fprintf(m_pLogfile , "\n\n***********************TCP Packet*************************\n");  

	//print_ip_header(pBuffer, nSize);
	ProcessIPHeader(pBuffer, nSize);

	fprintf(m_pLogfile , "\n");
	fprintf(m_pLogfile , "TCP Header\n");
	fprintf(m_pLogfile , "   |-Source Port      : %u\n",ntohs(tcph->source));
	fprintf(m_pLogfile , "   |-Destination Port : %u\n",ntohs(tcph->dest));
	fprintf(m_pLogfile , "   |-Sequence Number    : %u\n",ntohl(tcph->seq));
	fprintf(m_pLogfile , "   |-Acknowledge Number : %u\n",ntohl(tcph->ack_seq));
	fprintf(m_pLogfile , "   |-Header Length      : %d DWORDS or %d BYTES\n" ,(unsigned int)tcph->doff,(unsigned int)tcph->doff*4);
	//fprintf(m_pLogfile , "   |-CWR Flag : %d\n",(unsigned int)tcph->cwr);
	//fprintf(m_pLogfile , "   |-ECN Flag : %d\n",(unsigned int)tcph->ece);
	fprintf(m_pLogfile , "   |-Urgent Flag          : %d\n",(unsigned int)tcph->urg);
	fprintf(m_pLogfile , "   |-Acknowledgement Flag : %d\n",(unsigned int)tcph->ack);
	fprintf(m_pLogfile , "   |-Push Flag            : %d\n",(unsigned int)tcph->psh);
	fprintf(m_pLogfile , "   |-Reset Flag           : %d\n",(unsigned int)tcph->rst);
	fprintf(m_pLogfile , "   |-Synchronise Flag     : %d\n",(unsigned int)tcph->syn);
	fprintf(m_pLogfile , "   |-Finish Flag          : %d\n",(unsigned int)tcph->fin);
	fprintf(m_pLogfile , "   |-Window         : %d\n",ntohs(tcph->window));
	fprintf(m_pLogfile , "   |-Checksum       : %d\n",ntohs(tcph->check));
	fprintf(m_pLogfile , "   |-Urgent Pointer : %d\n",tcph->urg_ptr);
	fprintf(m_pLogfile , "\n");
	fprintf(m_pLogfile , "                        DATA Dump                         ");
	fprintf(m_pLogfile , "\n");

	fprintf(m_pLogfile , "IP Header\n");
	PrintData(pBuffer,iphdrlen);

	fprintf(m_pLogfile , "TCP Header\n");
	PrintData(pBuffer+iphdrlen,tcph->doff*4);

	fprintf(m_pLogfile , "Data Payload\n");    
	PrintData(pBuffer + header_size , nSize - header_size );

	fprintf(m_pLogfile , "\n###########################################################");


}
void print_icmp_packet(const u_char * Buffer , int Size)
{
    unsigned short iphdrlen;

    struct iphdr *iph = (struct iphdr *)(Buffer  + sizeof(struct ethhdr));
    iphdrlen = iph->ihl * 4;

    struct icmphdr *icmph = (struct icmphdr *)(Buffer + iphdrlen  + sizeof(struct ethhdr));

    int header_size =  sizeof(struct ethhdr) + iphdrlen + sizeof icmph;

    fprintf(logfile , "\n\n***********************ICMP Packet*************************\n");

    print_ip_header(Buffer , Size);

    fprintf(logfile , "\n");

    fprintf(logfile , "ICMP Header\n");
    fprintf(logfile , "   |-Type : %d",(unsigned int)(icmph->type));

    if((unsigned int)(icmph->type) == 11)
    {
        fprintf(logfile , "  (TTL Expired)\n");
    }
    else if((unsigned int)(icmph->type) == ICMP_ECHOREPLY)
    {
        fprintf(logfile , "  (ICMP Echo Reply)\n");
    }

    fprintf(logfile , "   |-Code : %d\n",(unsigned int)(icmph->code));
    fprintf(logfile , "   |-Checksum : %d\n",ntohs(icmph->checksum));
    //fprintf(logfile , "   |-ID       : %d\n",ntohs(icmph->id));
    //fprintf(logfile , "   |-Sequence : %d\n",ntohs(icmph->sequence));
    fprintf(logfile , "\n");

    fprintf(logfile , "IP Header\n");
    PrintData(Buffer,iphdrlen);

    fprintf(logfile , "UDP Header\n");
    PrintData(Buffer + iphdrlen , sizeof icmph);

    fprintf(logfile , "Data Payload\n");

    //Move the pointer ahead and reduce the size of string
    PrintData(Buffer + header_size , (Size - header_size) );

    fprintf(logfile , "\n###########################################################");
}
Пример #13
0
/* Checks for attributes and outputs their values */
void PrintAttributes(NXhandle fileId)
{
    int status, attrLen, attrType;
    NXname attrName;
    void *attrBuffer;

    do {
        status = NXgetnextattr(fileId, attrName, &attrLen, &attrType);
        if (status == NX_ERROR)
            return;
        if (status == NX_OK) {
            attrLen++;	/* Add space for string termination */
            if (NXmalloc
                    ((void **)&attrBuffer, 1, &attrLen,
                     attrType) != NX_OK)
                return;
            if (NXgetattr
                    (fileId, attrName, attrBuffer, &attrLen,
                     &attrType) != NX_OK)
                return;
            printf("    %s = ", attrName);
            PrintData(attrBuffer, attrType, attrLen);
            printf("\n");
            if (NXfree((void **)&attrBuffer) != NX_OK)
                return;
        }
    } while (status != NX_EOD);
    return;
}
Пример #14
0
static void OnReceiveCB(EVENTHUBRECEIVER_RESULT result, EVENTDATA_HANDLE eventDataHandle, void* userContext)
{
    (void)userContext;

    switch (result)
    {
        case EVENTHUBRECEIVER_TIMEOUT:
        {
            timeoutCounter++;
            (void)printf("INFO: Timeout Seen# %d\r\n", timeoutCounter);
            break;
        }
        case EVENTHUBRECEIVER_OK:
        {
            EVENTDATA_RESULT eventDataResult;
            MAP_HANDLE map;
            size_t dataSize;
            const unsigned char *dataBuffer;

            if ((eventDataResult = EventData_GetData(eventDataHandle, &dataBuffer, &dataSize)) == EVENTDATA_OK)
            {
                PrintData(dataBuffer, dataSize);
            }
            if ((map = EventData_Properties(eventDataHandle)) != NULL)
            {
                PrintProperties(map);
            }
            PrintEventDataReceiveParams(eventDataHandle);
            break;
        }
        default:
            (void)printf("ERROR: Result code %u.\r\n", result);
    };
}
Пример #15
0
void CPacket::DumpTCPPacket(const unsigned char* pBuffer, int nSize)
{
	unsigned short iphdrlen;

	//+ struct iphdr *iph = (struct iphdr *)( pBuffer  + sizeof(struct ethhdr) );
	struct ip *iph = (struct ip*)(pBuffer + sizeof(struct ether_header)); 
	//+ iphdrlen = iph->ihl*4;
	iphdrlen = iph->ip_hl;

	//+ struct tcphdr *tcph=(struct tcphdr*)(pBuffer + iphdrlen + sizeof(struct ethhdr));
	struct tcphdr *tcph=(struct tcphdr*)(pBuffer + iphdrlen + sizeof(struct ether_header));

	//+ int header_size =  sizeof(struct ethhdr) + iphdrlen + tcph->doff*4;
	int header_size =  sizeof(struct ether_header) + iphdrlen + tcph->th_off;// check th_off : data offset
	
	fprintf(m_fPrintType , "\n[+]TCP Header\n");
	//+ fprintf(m_fPrintType , "   |-Source Port      : %u\n",ntohs(tcph->source));
	fprintf(m_fPrintType , "   |-Source Port      : %u\n",ntohs(tcph->th_sport));
	//+ fprintf(m_fPrintType , "   |-Destination Port : %u\n",ntohs(tcph->dest));
	fprintf(m_fPrintType , "   |-Destination Port : %u\n",ntohs(tcph->th_dport));
	//+ fprintf(m_fPrintType , "   |-Sequence Number    : %u\n",ntohl(tcph->seq));
	fprintf(m_fPrintType , "   |-Sequence Number    : %u\n",ntohl(tcph->th_seq));
	//+ fprintf(m_fPrintType , "   |-Acknowledge Number : %u\n",ntohl(tcph->ack_seq));
	fprintf(m_fPrintType , "   |-Acknowledge Number : %u\n",ntohl(tcph->th_ack));
	//+ fprintf(m_fPrintType , "   |-Header Length      : %d DWORDS or %d BYTES\n" ,(unsigned int)tcph->doff,(unsigned int)tcph->doff*4);
	fprintf(m_fPrintType , "   |-Header Length      : %d DWORDS or %d BYTES\n" , (unsigned int)tcph->th_off,(unsigned int)tcph->th_off*4);// check th_off : data offset



	// 1. "netinet/tcp.h"
	// 2. struct tcphdr
	// 3. unsigned char th_flags 
	//    #define TH_FIN  0x01
	//    #define TH_SYN  0x02
	//    #define TH_RST  0x04
	//    #define TH_PUSH 0x08
	//    #define TH_ACK  0x10
	//    #define TH_URG  0x20
	//    #define TH_ECE  0x40
	//    #define TH_CWR  0x80
	//    #define TH_FLAGS        (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR)

	// fprintf(m_fPrintType , "   |-Urgent Flag          : %d\n",(unsigned int)tcph->urg);
	// fprintf(m_fPrintType , "   |-Acknowledgement Flag : %d\n",(unsigned int)tcph->ack);
	// fprintf(m_fPrintType , "   |-Push Flag            : %d\n",(unsigned int)tcph->psh);
	// fprintf(m_fPrintType , "   |-Reset Flag           : %d\n",(unsigned int)tcph->rst);
	// fprintf(m_fPrintType , "   |-Synchronise Flag     : %d\n",(unsigned int)tcph->syn);
	// fprintf(m_fPrintType , "   |-Finish Flag          : %d\n",(unsigned int)tcph->fin);
	
	// fprintf(m_fPrintType , "   |-Window         : %d\n",ntohs(tcph->window));
	// fprintf(m_fPrintType , "   |-Checksum       : %d\n",ntohs(tcph->check));
	// fprintf(m_fPrintType , "   |-Urgent Pointer : %d\n",tcph->urg_ptr);
	// fprintf(m_fPrintType , "\n");

	fprintf(m_fPrintType , "[+]Data Payload\n");    
	PrintData(pBuffer + header_size , nSize - header_size );

	fprintf(m_fPrintType , "\n###########################################################\n");
}
Пример #16
0
void PrintTree(BinNode *p)
{
  if (p != NULL){
    PrintTree(p->left);
    PrintData(p->data);
    PrintTree(p->right);
  }
}
Пример #17
0
void PrintIcmpPacket(u_char* Buffer, int Size)
{
	int iphdrlen = 0, icmphdrlen = 0, data_size = 0;

	iphdr = (IPV4_HDR *)(Buffer + sizeof(ETHER_HDR));
	iphdrlen = iphdr->ip_header_len * 4;

	icmpheader = (ICMP_HDR*)(Buffer + iphdrlen + sizeof(ETHER_HDR));

	data = (Buffer + sizeof(ETHER_HDR)+iphdrlen + sizeof(ICMP_HDR));
	data_size = (Size - sizeof(ETHER_HDR)-iphdrlen - sizeof(ICMP_HDR));

	fprintf(logfile, "\n\n***********************ICMP Packet*************************\n");
	PrintIpHeader(Buffer, Size);

	fprintf(logfile, "\n");

	fprintf(logfile, "ICMP Header\n");
	fprintf(logfile, " |-Type : %d", (unsigned int)(icmpheader->type));

	if ((unsigned int)(icmpheader->type) == 11)
	{
		fprintf(logfile, " (TTL Expired)\n");
	}
	else if ((unsigned int)(icmpheader->type) == 0)
	{
		fprintf(logfile, " (ICMP Echo Reply)\n");
	}

	fprintf(logfile, " |-Code : %d\n", (unsigned int)(icmpheader->code));
	fprintf(logfile, " |-Checksum : %d\n", ntohs(icmpheader->checksum));
	fprintf(logfile, " |-ID : %d\n", ntohs(icmpheader->id));
	fprintf(logfile, " |-Sequence : %d\n", ntohs(icmpheader->seq));
	fprintf(logfile, "\n");

	fprintf(logfile, "IP Header\n");
	PrintData((u_char*)iphdr, iphdrlen);

	fprintf(logfile, "ICMP Header\n");
	PrintData((u_char*)icmpheader, sizeof(ICMP_HDR));

	fprintf(logfile, "Data Payload\n");
	PrintData(data, data_size);

	fprintf(logfile, "\n###########################################################\n");
}
Пример #18
0
void PrintCrntNode(List *list)
{
  if (list->crnt == NULL){
    puts("着目要素はありません。");
  }else{
    PrintData(list->crnt->data);
  }
}
Пример #19
0
void print_tcp_packet(unsigned char* Buffer, int Size)
{
    unsigned short iphdrlen;

    struct iphdr *iph = (struct iphdr *)Buffer;
    iphdrlen = iph->ihl*4;

    struct tcphdr *tcph=(struct tcphdr*)(Buffer + iphdrlen);

    fprintf(logfile,"\n\n***********************TCP Packet*************************\n");

    print_ip_header(Buffer,Size);

    fprintf(logfile,"\n");
    fprintf(logfile,"TCP Header\n");
    fprintf(logfile,"   |-Source Port      : %u\n",ntohs(tcph->source));
    fprintf(logfile,"   |-Destination Port : %u\n",ntohs(tcph->dest));
    fprintf(logfile,"   |-Sequence Number    : %u\n",ntohl(tcph->seq));
    fprintf(logfile,"   |-Acknowledge Number : %u\n",ntohl(tcph->ack_seq));
    fprintf(logfile,"   |-Header Length      : %d DWORDS or %d BYTES\n" ,(unsigned int)tcph->doff,(unsigned int)tcph->doff*4);
    //fprintf(logfile,"   |-CWR Flag : %d\n",(unsigned int)tcph->cwr);
    //fprintf(logfile,"   |-ECN Flag : %d\n",(unsigned int)tcph->ece);
    fprintf(logfile,"   |-Urgent Flag          : %d\n",(unsigned int)tcph->urg);
    fprintf(logfile,"   |-Acknowledgement Flag : %d\n",(unsigned int)tcph->ack);
    fprintf(logfile,"   |-Push Flag            : %d\n",(unsigned int)tcph->psh);
    fprintf(logfile,"   |-Reset Flag           : %d\n",(unsigned int)tcph->rst);
    fprintf(logfile,"   |-Synchronise Flag     : %d\n",(unsigned int)tcph->syn);
    fprintf(logfile,"   |-Finish Flag          : %d\n",(unsigned int)tcph->fin);
    fprintf(logfile,"   |-Window         : %d\n",ntohs(tcph->window));
    fprintf(logfile,"   |-Checksum       : %d\n",ntohs(tcph->check));
    fprintf(logfile,"   |-Urgent Pointer : %d\n",tcph->urg_ptr);
    fprintf(logfile,"\n");
    fprintf(logfile,"                        DATA Dump                         ");
    fprintf(logfile,"\n");

    fprintf(logfile,"IP Header\n");
    PrintData(Buffer,iphdrlen);

    fprintf(logfile,"TCP Header\n");
    PrintData(Buffer+iphdrlen,tcph->doff*4);

    fprintf(logfile,"Data Payload\n");
    PrintData(Buffer + iphdrlen + tcph->doff*4 , (Size - tcph->doff*4-iph->ihl*4) );

    fprintf(logfile,"\n###########################################################");
}
Пример #20
0
int main()
{
	int iData[MAX_CNT];
	SetData(iData,MAX_CNT);
	time_t sTmp = clock();
	//선택 정렬
	SelectSort(iData,MAX_CNT);
	time_t eTmp = clock();
	printf("\n%s : %8.3f[%ld]\n","선택 정렬",(eTmp-sTmp)/(double)CLK_TCK,eTmp-sTmp);
	PrintData(iData, 10);

	SetData(iData, MAX_CNT);
	sTmp = clock();
	//거품 정렬
	BubbleSort(iData, MAX_CNT);
	eTmp = clock();
	printf("\n%s : %8.3f[%ld]\n", "거품 정렬", (eTmp - sTmp) / (double)CLK_TCK, eTmp - sTmp);
	PrintData(iData, 10);

	SetData(iData, MAX_CNT);
	sTmp = clock();
	//삽입 정렬
	InsertSort(iData, MAX_CNT);
	eTmp = clock();
	printf("\n%s : %8.3f[%ld]\n", "삽입 정렬", (eTmp - sTmp) / (double)CLK_TCK, eTmp - sTmp);
	PrintData(iData, 10);

	SetData(iData, MAX_CNT);
	sTmp = clock();
	//쉘 정렬
	ShellSort(iData, MAX_CNT);
	eTmp = clock();
	printf("\n%s : %8.3f[%ld]\n", "쉘 정렬", (eTmp - sTmp) / (double)CLK_TCK, eTmp - sTmp);
	PrintData(iData, 10);

	SetData(iData, MAX_CNT);
	sTmp = clock();
	//퀵 정렬
	QuickSort(iData,0, MAX_CNT-1);
	eTmp = clock();
	printf("\n%s : %8.3f[%ld]\n", "퀵 정렬", (eTmp - sTmp) / (double)CLK_TCK, eTmp - sTmp);
	PrintData(iData, 10);
     return 0;
}
Пример #21
0
int main()
{
	FreqTableList * table;
	DataSet *data;
	data = ReadData("Personality.dat");
	table = CreateFreqTableList();
	PrintData(data);
	computeFreqTableList(data, table);
	PrintFeqTable(table);
}
Пример #22
0
void PrintIcmpPacket(char* Buffer , int Size)
{
	unsigned short iphdrlen;

	iphdr = (IPV4_HDR *)Buffer;
	iphdrlen = iphdr->ip_header_len*4;

	icmpheader=(ICMP_HDR*)(Buffer+iphdrlen);

	fprintf(logfile,"\n\n***********************ICMP Packet*************************\n");
	PrintIpHeader(Buffer);

	fprintf(logfile,"\n");

	fprintf(logfile,"ICMP Header\n");
	fprintf(logfile," |-Type : %d",(unsigned int)(icmpheader->type));

	if((unsigned int)(icmpheader->type)==11)
	{
		fprintf(logfile," (TTL Expired)\n");
	}
	else if((unsigned int)(icmpheader->type)==0)
	{
		fprintf(logfile," (ICMP Echo Reply)\n");
	}

	fprintf(logfile," |-Code : %d\n",(unsigned int)(icmpheader->code));
	fprintf(logfile," |-Checksum : %d\n",ntohs(icmpheader->checksum));
	fprintf(logfile," |-ID : %d\n",ntohs(icmpheader->id));
	fprintf(logfile," |-Sequence : %d\n",ntohs(icmpheader->seq));
	fprintf(logfile,"\n");

	fprintf(logfile,"IP Header\n");
	PrintData(Buffer,iphdrlen);

	fprintf(logfile,"UDP Header\n");
	PrintData(Buffer+iphdrlen,sizeof(ICMP_HDR));

	fprintf(logfile,"Data Payload\n");
	PrintData(Buffer+iphdrlen+sizeof(ICMP_HDR) , (Size - sizeof(ICMP_HDR) - iphdr->ip_header_len*4));

	fprintf(logfile,"\n###########################################################");
}
Пример #23
0
void Profiler::PrintData(ProfilerBlock* block, String& output, unsigned depth, unsigned maxDepth, bool showUnused,
    bool showTotal) const
{
    char line[LINE_MAX_LENGTH];
    char indentedName[LINE_MAX_LENGTH];

    unsigned intervalFrames = Max(intervalFrames_, 1U);

    if (depth >= maxDepth)
        return;

    // Do not print the root block as it does not collect any actual data
    if (block != root_)
    {
        if (showUnused || block->intervalCount_ || (showTotal && block->totalCount_))
        {
            memset(indentedName, ' ', NAME_MAX_LENGTH);
            indentedName[depth] = 0;
            strcat(indentedName, block->name_);
            indentedName[strlen(indentedName)] = ' ';
            indentedName[NAME_MAX_LENGTH] = 0;

            if (!showTotal)
            {
                float avg = (block->intervalCount_ ? block->intervalTime_ / block->intervalCount_ : 0.0f) / 1000.0f;
                float max = block->intervalMaxTime_ / 1000.0f;
                float frame = block->intervalTime_ / intervalFrames / 1000.0f;
                float all = block->intervalTime_ / 1000.0f;

                sprintf(line, "%s %5u %8.3f %8.3f %8.3f %9.3f\n", indentedName, Min(block->intervalCount_, 99999U),
                    avg, max, frame, all);
            }
            else
            {
                float avg = (block->frameCount_ ? block->frameTime_ / block->frameCount_ : 0.0f) / 1000.0f;
                float max = block->frameMaxTime_ / 1000.0f;
                float all = block->frameTime_ / 1000.0f;

                float totalAvg = (block->totalCount_ ? block->totalTime_ / block->totalCount_ : 0.0f) / 1000.0f;
                float totalMax = block->totalMaxTime_ / 1000.0f;
                float totalAll = block->totalTime_ / 1000.0f;

                sprintf(line, "%s %5u %8.3f %8.3f %9.3f  %7u %9.3f %9.3f %11.3f\n", indentedName, Min(block->frameCount_, 99999U),
                    avg, max, all, Min(block->totalCount_, 99999U), totalAvg, totalMax, totalAll);
            }

            output += String(line);
        }

        ++depth;
    }

    for (PODVector<ProfilerBlock*>::ConstIterator i = block->children_.Begin(); i != block->children_.End(); ++i)
        PrintData(*i, output, depth, maxDepth, showUnused, showTotal);
}
Пример #24
0
//Out Word
void Print(pDICT node)
{
	if(node == NULL)
		return;
	else
	{
		Print(node->leftlink);
		PrintData(node->data);
		Print(node->rightlink);
	}
}
Пример #25
0
void print_icmp_packet(unsigned char* Buffer , int Size)
{
    unsigned short iphdrlen;

    struct iphdr *iph = (struct iphdr *)Buffer;
    iphdrlen = iph->ihl*4;

    struct icmphdr *icmph = (struct icmphdr *)(Buffer + iphdrlen);

    fprintf(logfile,"\n\n***********************ICMP Packet*************************\n");

    print_ip_header(Buffer , Size);

    fprintf(logfile,"\n");

    fprintf(logfile,"ICMP Header\n");
    fprintf(logfile,"   |-Type : %d",(unsigned int)(icmph->type));

    if((unsigned int)(icmph->type) == 11)
        fprintf(logfile,"  (TTL Expired)\n");
    else if((unsigned int)(icmph->type) == ICMP_ECHOREPLY)
        fprintf(logfile,"  (ICMP Echo Reply)\n");
    fprintf(logfile,"   |-Code : %d\n",(unsigned int)(icmph->code));
    fprintf(logfile,"   |-Checksum : %d\n",ntohs(icmph->checksum));
    //fprintf(logfile,"   |-ID       : %d\n",ntohs(icmph->id));
    //fprintf(logfile,"   |-Sequence : %d\n",ntohs(icmph->sequence));
    fprintf(logfile,"\n");

    fprintf(logfile,"IP Header\n");
    PrintData(Buffer,iphdrlen);

    fprintf(logfile,"UDP Header\n");
    PrintData(Buffer + iphdrlen , sizeof icmph);

    fprintf(logfile,"Data Payload\n");
    PrintData(Buffer + iphdrlen + sizeof icmph , (Size - sizeof icmph - iph->ihl * 4));

    fprintf(logfile,"\n###########################################################");
}
Пример #26
0
void PrintList(List *list)
{
  if (list->head == NULL){
    puts("ノードがありません。");
  }else{
    Node *ptr = list->head;

    puts("【一覧表】");
    while (ptr != NULL){
      PrintData(ptr->data);
      ptr = ptr->next;
    }
  }
}
Пример #27
0
int socket_send_data(FOURD *cnx,const char*msg,int len)
{
	int iResult;
	Printf("Send:%d bytes\n",len);
	PrintData(msg,len);
	Printf("\n");
	// Send an initial buffer
	iResult = send( cnx->socket, msg, len, 0 );
	if (iResult == SOCKET_ERROR) {
		Printf("send failed: %d\n", WSAGetLastError());
		socket_disconnect(cnx);
		return 1;
	}
	return 0;
}
Пример #28
0
int main(void)
{
	int aList[3] = { 0 };
	int nMax = -9999, i = 0;
	//입력
	for (i = 0; i < 3; ++i)
		aList[i] = GetData();

	//최댓값 계산
	nMax = GetMax(aList[0], aList[1], aList[2]);

	//출력
	PrintData(aList[0], aList[1], aList[2], nMax);
	return 0;
}
void print_udp_packet(const u_char *Buffer , int Size)
{

    unsigned short iphdrlen;

    struct iphdr *iph = (struct iphdr *)(Buffer +  sizeof(struct ethhdr));
    iphdrlen = iph->ihl*4;

    struct udphdr *udph = (struct udphdr*)(Buffer + iphdrlen  + sizeof(struct ethhdr));

    int header_size =  sizeof(struct ethhdr) + iphdrlen + sizeof udph;

    fprintf(logfile , "\n\n***********************UDP Packet*************************\n");

    print_ip_header(Buffer,Size);

    fprintf(logfile , "\nUDP Header\n");
    fprintf(logfile , "   |-Source Port      : %d\n" , ntohs(udph->source));
    fprintf(logfile , "   |-Destination Port : %d\n" , ntohs(udph->dest));
    fprintf(logfile , "   |-UDP Length       : %d\n" , ntohs(udph->len));
    fprintf(logfile , "   |-UDP Checksum     : %d\n" , ntohs(udph->check));

    fprintf(logfile , "\n");
    fprintf(logfile , "IP Header\n");
    PrintData(Buffer , iphdrlen);

    fprintf(logfile , "UDP Header\n");
    PrintData(Buffer+iphdrlen , sizeof udph);

    fprintf(logfile , "Data Payload\n");

    //Move the pointer ahead and reduce the size of string
    PrintData(Buffer + header_size , Size - header_size);

    fprintf(logfile , "\n###########################################################");
}
Пример #30
0
void LookUpWord(pDICT root)
{
	pDICT Look;
	char KeyWord[1024];
	printf("Enter Keyword look up: " );
	gets(KeyWord);
	flushall();
	Look = FindProcess(root,KeyWord);
	if(Look != false)	
		PrintData(Look->data);
	else
	{
		printf("The Word not exits");
	}
}