Новости –  Прошивки –  Каталог навигаторов –  Восстановление навигатора

Вернуться   Мир Автомобильных навигаторов > PNA / PND Устройства > Навигатор на WinCE
Регистрация ФайлыПравила форумаБан-лист Справка Календарь Поиск Сообщения за день Все разделы прочитаны

 
  


     


Nokia N1 - первый Android-планшет известной финской компании
Ответ
 
Опции темы
Старый 20.04.2015, 10:59   #16
urban81
Писатель
Доп. информация
Сообщение

Всем здравствуйте.Спасибо за поддержку!Нашёл ТАМ в коде готовую прогу.Если две запустить на эмуляторе то они могут общаться с друг другом, как раз по локал хосту.Всё можно проследить по шагам... Но вот беда - никак не могу её скомпилировать по МИПС архитектуру...Кто разобрался как это сделать подскажите пожалуйста.Выкладываю эти проги и SDK для МИПС2 архитектуры и редактор риестра для мипс.Всем спасибо...
Проги: [Ссылки могут видеть только зарегистрированные пользователи. ]
SDK_MIPS2(переименовать doc в msi): [Ссылки могут видеть только зарегистрированные пользователи. ]
Редактор: [Ссылки могут видеть только зарегистрированные пользователи. ]
[Ссылки могут видеть только зарегистрированные пользователи. ]
[Ссылки могут видеть только зарегистрированные пользователи. ]
urban81 вне форума  
Пользователь сказал cпасибо:
Старый 20.04.2015, 15:47   #17
Anton 1983
Куратор
 
Аватар для Anton 1983
Доп. информация
По умолчанию

Есть у меня Платформбилдер и и сдк мипса. Посмотрю что ты накопал. Я пока так и не разобрался как перехватить вызов апи. Кое какие наработки есть, но плотно сидеть разбираться с программированием не получается.

Добавлено через 4 минуты
PS - я тебе кстати код выложил как подключиться к порту. Я даже как то лог снимал с порта и данные там смотрел. Время я там точно видел. Координаты тоже были , но не в явном виде. Помимо того что ты получишь лог с UDP порта его надо будет разложить, вытащить от туда полезную инфу - завернуть ее в нмеа, потом создать виртуальный компорт и послать этот нмеа поток в созданный порт.
__________________
В личку писать только после того как отписались в форуме!!!
Anton 1983 вне форума  
Старый 23.04.2015, 16:18   #18
urban81
Писатель
Доп. информация
Лампочка ТЕСТ НА ЭМУЛЯТОРЕ И ГУ!

Здравствуйте.Построил под мипс и протестил на эмуляторе.На эмуляторе не работает с настройками от Anton 1983.Работает с другими...Можно сравнить два проекта.На гу протестю вечером с настройками от Anton 1983.Приложение пишет лог.Один строится только под SDK2, другой только под SDK1_MIPSII.Кто знает как подключаться к гу через активсинк?Всем спасибо.
Проекты: [Ссылки могут видеть только зарегистрированные пользователи. ]
urban81 вне форума  
Пользователь сказал cпасибо:
Старый 24.04.2015, 07:43   #19
avtoserg
Супер-модератор
 
Аватар для avtoserg
Доп. информация
По умолчанию

urban81, зачем активсинк? аппарат как сьемный диск должен видиться
__________________
Могу дать удочку, рыбу не просить!!!
Могу выдать время для [Ссылки могут видеть только зарегистрированные пользователи. ]
avtoserg вне форума  
Пользователь сказал cпасибо:
Старый 30.04.2015, 15:20   #20
urban81
Писатель
Доп. информация
Вопрос Подключение есть!Как читать?!

Всем здравствуйте!Подключение есть!Но данные пока считать не получается!Используя код Anton 1983 и другие материалы написал простую прогу.Не проходит место:
Код HTML:
	if (WSAIoctl(sniffer, SIO_RCVALL, &j, sizeof(j), 0, 0, (LPDWORD) &in , 0 , 0) == SOCKET_ERROR)
	{
		fprintf(logfile, "WSAIoctl() failed.\n");
		MessageBox(0, TEXT("6"),TEXT ("6"), 0);
		fclose(logfile);
		return 1;
	}
Не нравится параметр SIO_RCVALL(см. код).Пробовал некоторые другие параметры (как в инете)...
Anton 1983 и все другие форумчане если вы знаеете, как правильно читать, прошу помочь!
Всем заранее спасибо.
Код HTML:
// winsock_sniffer.cpp: определяет точку входа для консольного приложения.
//

#include "stdafx.h"
#include "stdio.h"
#include "winsock2.h"

//#pragma comment(lib,"ws2_32.lib") //For winsock
#pragma comment(lib,"ws2.lib") //For winsock

#define SIO_RCVALL _WSAIOW(IOC_VENDOR,1) //this removes the need of mstcpip.h

void StartSniffing (SOCKET Sock); //This will sniff here and there

void ProcessPacket (char* , int); //This will decide how to digest
void PrintIpHeader (char*);
void PrintIcmpPacket (char* , int);
void PrintUdpPacket (char* , int);
void PrintTcpPacket (char* , int);
void ConvertToHex (char* , unsigned int);
void PrintData (char* , int);

typedef struct ip_hdr
{
	unsigned char ip_header_len:4; // 4-bit header length (in 32-bit words) normally=5 (Means 20 Bytes may be 24 also)
	unsigned char ip_version :4; // 4-bit IPv4 version
	unsigned char ip_tos; // IP type of service
	unsigned short ip_total_length; // Total length
	unsigned short ip_id; // Unique identifier

	unsigned char ip_frag_offset :5; // Fragment offset field

	unsigned char ip_more_fragment :1;
	unsigned char ip_dont_fragment :1;
	unsigned char ip_reserved_zero :1;

	unsigned char ip_frag_offset1; //fragment offset

	unsigned char ip_ttl; // Time to live
	unsigned char ip_protocol; // Protocol(TCP,UDP etc)
	unsigned short ip_checksum; // IP checksum
	unsigned int ip_srcaddr; // Source address
	unsigned int ip_destaddr; // Source address
} IPV4_HDR;

typedef struct udp_hdr
{
	unsigned short source_port; // Source port no.
	unsigned short dest_port; // Dest. port no.
	unsigned short udp_length; // Udp packet length
	unsigned short udp_checksum; // Udp checksum (optional)
} UDP_HDR;

// TCP header
typedef struct tcp_header
{
	unsigned short source_port; // source port
	unsigned short dest_port; // destination port
	unsigned int sequence; // sequence number - 32 bits
	unsigned int acknowledge; // acknowledgement number - 32 bits

	unsigned char ns :1; //Nonce Sum Flag Added in RFC 3540.
	unsigned char reserved_part1:3; //according to rfc
	unsigned char data_offset:4; /*The number of 32-bit words in the TCP header.
	This indicates where the data begins.
	The length of the TCP header is always a multiple
	of 32 bits.*/

	unsigned char fin :1; //Finish Flag
	unsigned char syn :1; //Synchronise Flag
	unsigned char rst :1; //Reset Flag
	unsigned char psh :1; //Push Flag
	unsigned char ack :1; //Acknowledgement Flag
	unsigned char urg :1; //Urgent Flag

	unsigned char ecn :1; //ECN-Echo Flag
	unsigned char cwr :1; //Congestion Window Reduced Flag

	////////////////////////////////

	unsigned short window; // window
	unsigned short checksum; // checksum
	unsigned short urgent_pointer; // urgent pointer
} TCP_HDR;

typedef struct icmp_hdr
{
	BYTE type; // ICMP Error type
	BYTE code; // Type sub code
	USHORT checksum;
	USHORT id;
	USHORT seq;
} ICMP_HDR;

FILE *logfile;
int tcp=0,udp=0,icmp=0,others=0,igmp=0,total=0,i,j;
struct sockaddr_in source,dest;
char hex[2];

//Its free!
IPV4_HDR *iphdr;
TCP_HDR *tcpheader;
UDP_HDR *udpheader;
ICMP_HDR *icmpheader;


void StartSniffing(SOCKET sniffer)
{
	//char *Buffer = (char *)malloc(65536); //Its Big!
	char *Buffer = (char *)malloc(2048); //Its Big!
	int mangobyte;

	if (Buffer == NULL)
	{
		fprintf(logfile, "malloc() failed.\n");
		return;
	}

	do
	{
		//mangobyte = recvfrom(sniffer , Buffer , 65536 , 0 , 0 , 0); //Eat as much as u can
		mangobyte = recvfrom(sniffer , Buffer , 2048 , 0 , 0 , 0); //Eat as much as u can

		if(mangobyte > 0)
		{
			ProcessPacket(Buffer, mangobyte);
		}
		else
		{
			fprintf(logfile,  "recvfrom() failed.\n");
		}
	}
	while (mangobyte > 0);

	free(Buffer);
}

void ProcessPacket(char* Buffer, int Size)
{
	iphdr = (IPV4_HDR *)Buffer;
	++total;

	switch (iphdr->ip_protocol) //Check the Protocol and do accordingly...
	{
		case 1: //ICMP Protocol
		++icmp;
		PrintIcmpPacket(Buffer,Size);
		break;

		case 2: //IGMP Protocol
		++igmp;
		break;

		case 6: //TCP Protocol
		++tcp;
		PrintTcpPacket(Buffer,Size);
		break;

		case 17: //UDP Protocol
		++udp;
		PrintUdpPacket(Buffer,Size);
		break;

		default: //Some Other Protocol like ARP etc.
		++others;
		break;
	}
	fprintf(logfile, "TCP : %d UDP : %d ICMP : %d IGMP : %d Others : %d Total : %d\r",tcp,udp,icmp,igmp,others,total);
}

void PrintIpHeader (char* Buffer )
{
	unsigned short iphdrlen;

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

	memset(&source, 0, sizeof(source));
	source.sin_addr.s_addr = iphdr->ip_srcaddr;

	memset(&dest, 0, sizeof(dest));
	dest.sin_addr.s_addr = iphdr->ip_destaddr;

	fprintf(logfile,"\n");
	fprintf(logfile,"IP Header\n");
	fprintf(logfile," |-IP Version : %d\n",(unsigned int)iphdr->ip_version);
	fprintf(logfile," |-IP Header Length : %d DWORDS or %d Bytes\n",(unsigned int)iphdr->ip_header_len,((unsigned int)(iphdr->ip_header_len))*4);
	fprintf(logfile," |-Type Of Service : %d\n",(unsigned int)iphdr->ip_tos);
	fprintf(logfile," |-IP Total Length : %d Bytes(Size of Packet)\n",ntohs(iphdr->ip_total_length));
	fprintf(logfile," |-Identification : %d\n",ntohs(iphdr->ip_id));
	fprintf(logfile," |-Reserved ZERO Field : %d\n",(unsigned int)iphdr->ip_reserved_zero);
	fprintf(logfile," |-Dont Fragment Field : %d\n",(unsigned int)iphdr->ip_dont_fragment);
	fprintf(logfile," |-More Fragment Field : %d\n",(unsigned int)iphdr->ip_more_fragment);
	fprintf(logfile," |-TTL : %d\n",(unsigned int)iphdr->ip_ttl);
	fprintf(logfile," |-Protocol : %d\n",(unsigned int)iphdr->ip_protocol);
	fprintf(logfile," |-Checksum : %d\n",ntohs(iphdr->ip_checksum));
	fprintf(logfile," |-Source IP : %s\n",inet_ntoa(source.sin_addr));
	fprintf(logfile," |-Destination IP : %s\n",inet_ntoa(dest.sin_addr));
}

void PrintTcpPacket(char* Buffer, int Size)
{
	unsigned short iphdrlen;

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

	tcpheader=(TCP_HDR*)(Buffer+iphdrlen);

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

	PrintIpHeader( Buffer );

	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(Buffer,iphdrlen);

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

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

	fprintf(logfile,"\n###########################################################");
}

void PrintUdpPacket(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);

	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###########################################################");
}

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###########################################################");
}

/*
	Print the hex values of the data
*/
void PrintData (char* data , int Size)
{
	char a , line[17] , c;
	int j;

	//loop over each character and print
	for(i=0 ; i < Size ; i++)
	{
		c = data[i];

		//Print the hex value for every character , with a space. Important to make unsigned
		fprintf(logfile," %.2x", (unsigned char) c);

		//Add the character to data line. Important to make unsigned
		a = ( c >=32 && c <=128) ? (unsigned char) c : '.';

		line[i%16] = a;

		//if last character of a line , then print the line - 16 characters in 1 line
		if( (i!=0 && (i+1)%16==0) || i == Size - 1)
		{
			line[i%16 + 1] = '\0';

			//print a big gap of 10 characters between hex and characters
			fprintf(logfile ,"          ");

			//Print additional spaces for last lines which might be less than 16 characters in length
			for( j = strlen(line) ; j < 16; j++)
			{
				fprintf(logfile , "   ");
			}

			fprintf(logfile , "%s \n" , line);
		}
	}

	fprintf(logfile , "\n");
}



int _tmain(int argc, _TCHAR* argv[])
{
	SOCKET sniffer;
	struct in_addr addr;
	int in;

	char hostname[100];
	struct hostent *local;
	WSADATA wsa;

	//logfile=fopen("log.txt","w");
	logfile=fopen("\\DiskA3\\log_UDP.txt","w");
	//logfile=fopen("\\Storage Card\\log_UDP.txt","w");
	if(logfile == NULL)
	{
		MessageBox(0, TEXT("0"),TEXT ("0"), 0);
		fprintf(logfile, "Unable to create file.");
	}

	//Initialise Winsock
	fprintf(logfile, "\nInitialising Winsock...");
	if (WSAStartup(MAKEWORD(1,1), &wsa) != 0)
	//if (WSAStartup(MAKEWORD(2,2), &wsa) != 0)
	{
		fprintf(logfile, "WSAStartup() failed.\n");
		MessageBox(0, TEXT("1"),TEXT ("1"), 0);
		fclose(logfile);
		return 1;
	}
	fprintf(logfile, "Initialised");

	//Create a RAW Socket
	fprintf(logfile, "\nCreating RAW Socket...");
	sniffer = socket(AF_INET, SOCK_RAW, IPPROTO_IP);
	if (sniffer == INVALID_SOCKET)
	{
		fprintf(logfile, "Failed to create raw socket.\n");
		MessageBox(0, TEXT("2"),TEXT ("2"), 0);
		fclose(logfile);
		return 1;
	}
	fprintf(logfile, "Created.");

	//Retrive the local hostname
	if (gethostname(hostname, sizeof(hostname)) == SOCKET_ERROR)
	{
		fprintf(logfile, "Error : %d",WSAGetLastError());
		MessageBox(0, TEXT("3"),TEXT ("3"), 0);
		fclose(logfile);
		return 1;
	}
	fprintf(logfile, "\nHost name : %s \n",hostname);

	//Retrive the available IPs of the local host
	local = gethostbyname(hostname);
	fprintf(logfile, "\nAvailable Network Interfaces : \n");
	if (local == NULL)
	{
		fprintf(logfile, "Error : %d.\n",WSAGetLastError());
		MessageBox(0, TEXT("4"),TEXT ("4"), 0);
		fclose(logfile);
		return 1;
	}

	for (i = 0; local->h_addr_list[i] != 0; ++i)
	{
		memcpy(&addr, local->h_addr_list[i], sizeof(struct in_addr));
		fprintf(logfile, "Interface Number : %d Address : %s\n",i,inet_ntoa(addr));
	}

	//fprintf(logfile, "Enter the interface number you would like to sniff : ");
	//scanf("%d",&in);
	in = 0;

	//memset(&dest, 0, sizeof(dest));
	//memcpy(&dest.sin_addr.s_addr,local->h_addr_list[in],sizeof(dest.sin_addr.s_addr));

	dest.sin_addr.s_addr = htonl(INADDR_ANY);
	dest.sin_family = AF_INET;
	dest.sin_port = htons(29000);

	fprintf(logfile, "\nBinding socket to local system and port %d ...", dest.sin_port );
	if (bind(sniffer,(struct sockaddr *)&dest,sizeof(dest)) == SOCKET_ERROR)
	{
		fprintf(logfile, "bind(%s) failed.\n", inet_ntoa(addr));
		MessageBox(0, TEXT("5"),TEXT ("5"), 0);
		fclose(logfile);
		return 1;
	}
	fprintf(logfile, "Binding successful");

	//Enable this socket with the power to sniff : SIO_RCVALL is the key Receive ALL ;)

	j=1;
	fprintf(logfile, "\nSetting socket to sniff...");
	if (WSAIoctl(sniffer, SIO_RCVALL, &j, sizeof(j), 0, 0, (LPDWORD) &in , 0 , 0) == SOCKET_ERROR)
	{
		fprintf(logfile, "WSAIoctl() failed.\n");
		MessageBox(0, TEXT("6"),TEXT ("6"), 0);
		fclose(logfile);
		return 1;
	}
	fprintf(logfile, "Socket set.");

	//Begin
	fprintf(logfile, "\nStarted Sniffing\n");
	fprintf(logfile, "Packet Capture Statistics...\n");
	StartSniffing(sniffer); //Happy Sniffing

	//End
	closesocket(sniffer);
	fclose(logfile);
	WSACleanup();

	return 0;
}
urban81 вне форума  
Старый 06.05.2015, 23:51   #21
urban81
Писатель
Доп. информация
Восклицание Лог есть!Пишем в порт!

Всем здравствуйте!Прога(см. код) начала снимать данные(см. log_UDP.txt)!Это простое консольное приложение. Могу выложить проект кому надо...Дальше надо их прокинуть в виртуальный ком порт.Выкладывал код виртуального порта(см. выше) он хорошо работал на вин се 5, кто знает как приладить его к 6 и протестить на эмуляторе.Прошу помочь.Смотрел на устройстве в редакторе реестра мипс(прикладывал выше) там есть 7 портов.
Активсинк нужен для живой пошаговой отладки на устройстве да и вообще можно что нибудь полезное с ним подмутить.
Так же прошу помощи в анализе и преобразовании полученных данных.Всем кто в теме спасибо за внимание.
Код:
Код HTML:
// winsock_sniffer.cpp: определяет точку входа для консольного приложения.
//

#include "stdafx.h"
#include "stdio.h"
#include "winsock2.h"
#include "mstcpip.h"

//#pragma comment(lib,"ws2_32.lib") //For winsock
#pragma comment(lib,"ws2.lib") //For winsock

//#define SIO_RCVALL _WSAIOW(IOC_VENDOR,1) //this removes the need of mstcpip.h

void StartSniffing (SOCKET Sock); //This will sniff here and there

void ProcessPacket (char* , int); //This will decide how to digest
void PrintIpHeader (char*);
void PrintIcmpPacket (char* , int);
void PrintUdpPacket (char* , int);
void PrintTcpPacket (char* , int);
void ConvertToHex (char* , unsigned int);
void PrintData (char* , int);

typedef struct ip_hdr
{
	unsigned char ip_header_len:4; // 4-bit header length (in 32-bit words) normally=5 (Means 20 Bytes may be 24 also)
	unsigned char ip_version :4; // 4-bit IPv4 version
	unsigned char ip_tos; // IP type of service
	unsigned short ip_total_length; // Total length
	unsigned short ip_id; // Unique identifier

	unsigned char ip_frag_offset :5; // Fragment offset field

	unsigned char ip_more_fragment :1;
	unsigned char ip_dont_fragment :1;
	unsigned char ip_reserved_zero :1;

	unsigned char ip_frag_offset1; //fragment offset

	unsigned char ip_ttl; // Time to live
	unsigned char ip_protocol; // Protocol(TCP,UDP etc)
	unsigned short ip_checksum; // IP checksum
	unsigned int ip_srcaddr; // Source address
	unsigned int ip_destaddr; // Source address
} IPV4_HDR;

typedef struct udp_hdr
{
	unsigned short source_port; // Source port no.
	unsigned short dest_port; // Dest. port no.
	unsigned short udp_length; // Udp packet length
	unsigned short udp_checksum; // Udp checksum (optional)
} UDP_HDR;

// TCP header
typedef struct tcp_header
{
	unsigned short source_port; // source port
	unsigned short dest_port; // destination port
	unsigned int sequence; // sequence number - 32 bits
	unsigned int acknowledge; // acknowledgement number - 32 bits

	unsigned char ns :1; //Nonce Sum Flag Added in RFC 3540.
	unsigned char reserved_part1:3; //according to rfc
	unsigned char data_offset:4; /*The number of 32-bit words in the TCP header.
	This indicates where the data begins.
	The length of the TCP header is always a multiple
	of 32 bits.*/

	unsigned char fin :1; //Finish Flag
	unsigned char syn :1; //Synchronise Flag
	unsigned char rst :1; //Reset Flag
	unsigned char psh :1; //Push Flag
	unsigned char ack :1; //Acknowledgement Flag
	unsigned char urg :1; //Urgent Flag

	unsigned char ecn :1; //ECN-Echo Flag
	unsigned char cwr :1; //Congestion Window Reduced Flag

	////////////////////////////////

	unsigned short window; // window
	unsigned short checksum; // checksum
	unsigned short urgent_pointer; // urgent pointer
} TCP_HDR;

typedef struct icmp_hdr
{
	BYTE type; // ICMP Error type
	BYTE code; // Type sub code
	USHORT checksum;
	USHORT id;
	USHORT seq;
} ICMP_HDR;

FILE *logfile;
int tcp=0,udp=0,icmp=0,others=0,igmp=0,total=0,i,j;
struct sockaddr_in source,dest;
char hex[2];

//Its free!
IPV4_HDR *iphdr;
TCP_HDR *tcpheader;
UDP_HDR *udpheader;
ICMP_HDR *icmpheader;


void StartSniffing(SOCKET sniffer)
{
	char *Buffer = (char *)malloc(65536); //Its Big!
	//char *Buffer = (char *)malloc(2048); //Its Big!
	int mangobyte;

	if (Buffer == NULL)
	{
		fprintf(logfile, "malloc() failed.\n");
		return;
	}

	do
	{
		mangobyte = recvfrom(sniffer , Buffer , 65536 , 0 , 0 , 0); //Eat as much as u can
		//mangobyte = recvfrom(sniffer , Buffer , 2048 , 0 , 0 , 0); //Eat as much as u can

		if(mangobyte > 0)
		{
			ProcessPacket(Buffer, mangobyte);
		}
		else
		{
			fprintf(logfile,  "recvfrom() failed.\n");
		}
	}
	while (mangobyte > 0);

	free(Buffer);
}

void ProcessPacket(char* Buffer, int Size)
{
	iphdr = (IPV4_HDR *)Buffer;
	++total;

	switch (iphdr->ip_protocol) //Check the Protocol and do accordingly...
	{
		case 1: //ICMP Protocol
		++icmp;
		PrintIcmpPacket(Buffer,Size);
		break;

		case 2: //IGMP Protocol
		++igmp;
		break;

		case 6: //TCP Protocol
		++tcp;
		PrintTcpPacket(Buffer,Size);
		break;

		case 17: //UDP Protocol
		++udp;
		PrintUdpPacket(Buffer,Size);
		break;

		default: //Some Other Protocol like ARP etc.
		++others;
		break;
	}
	fprintf(logfile, "TCP : %d UDP : %d ICMP : %d IGMP : %d Others : %d Total : %d\r",tcp,udp,icmp,igmp,others,total);
}

void PrintIpHeader (char* Buffer )
{
	unsigned short iphdrlen;

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

	memset(&source, 0, sizeof(source));
	source.sin_addr.s_addr = iphdr->ip_srcaddr;

	memset(&dest, 0, sizeof(dest));
	dest.sin_addr.s_addr = iphdr->ip_destaddr;

	fprintf(logfile,"\n");
	fprintf(logfile,"IP Header\n");
	fprintf(logfile," |-IP Version : %d\n",(unsigned int)iphdr->ip_version);
	fprintf(logfile," |-IP Header Length : %d DWORDS or %d Bytes\n",(unsigned int)iphdr->ip_header_len,((unsigned int)(iphdr->ip_header_len))*4);
	fprintf(logfile," |-Type Of Service : %d\n",(unsigned int)iphdr->ip_tos);
	fprintf(logfile," |-IP Total Length : %d Bytes(Size of Packet)\n",ntohs(iphdr->ip_total_length));
	fprintf(logfile," |-Identification : %d\n",ntohs(iphdr->ip_id));
	fprintf(logfile," |-Reserved ZERO Field : %d\n",(unsigned int)iphdr->ip_reserved_zero);
	fprintf(logfile," |-Dont Fragment Field : %d\n",(unsigned int)iphdr->ip_dont_fragment);
	fprintf(logfile," |-More Fragment Field : %d\n",(unsigned int)iphdr->ip_more_fragment);
	fprintf(logfile," |-TTL : %d\n",(unsigned int)iphdr->ip_ttl);
	fprintf(logfile," |-Protocol : %d\n",(unsigned int)iphdr->ip_protocol);
	fprintf(logfile," |-Checksum : %d\n",ntohs(iphdr->ip_checksum));
	fprintf(logfile," |-Source IP : %s\n",inet_ntoa(source.sin_addr));
	fprintf(logfile," |-Destination IP : %s\n",inet_ntoa(dest.sin_addr));
}

void PrintTcpPacket(char* Buffer, int Size)
{
	unsigned short iphdrlen;

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

	tcpheader=(TCP_HDR*)(Buffer+iphdrlen);

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

	PrintIpHeader( Buffer );

	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(Buffer,iphdrlen);

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

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

	fprintf(logfile,"\n###########################################################");
}

void PrintUdpPacket(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);

	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###########################################################");
}

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###########################################################");
}

/*
	Print the hex values of the data
*/
void PrintData (char* data , int Size)
{
	char a , line[17] , c;
	int j;

	//loop over each character and print
	for(i=0 ; i < Size ; i++)
	{
		c = data[i];

		//Print the hex value for every character , with a space. Important to make unsigned
		fprintf(logfile," %.2x", (unsigned char) c);

		//Add the character to data line. Important to make unsigned
		a = ( c >=32 && c <=128) ? (unsigned char) c : '.';

		line[i%16] = a;

		//if last character of a line , then print the line - 16 characters in 1 line
		if( (i!=0 && (i+1)%16==0) || i == Size - 1)
		{
			line[i%16 + 1] = '\0';

			//print a big gap of 10 characters between hex and characters
			fprintf(logfile ,"          ");

			//Print additional spaces for last lines which might be less than 16 characters in length
			for( j = strlen(line) ; j < 16; j++)
			{
				fprintf(logfile , "   ");
			}

			fprintf(logfile , "%s \n" , line);
		}
	}

	fprintf(logfile , "\n");
}



int _tmain(int argc, _TCHAR* argv[])
{
	SOCKET sniffer;
	struct in_addr addr;
	int in;

	char hostname[100];
	struct hostent *local;
	WSADATA wsa;

	BOOL dontLinger = TRUE;
	LINGER lingerOpt;

	//logfile=fopen("log.txt","w");
	logfile=fopen("\\DiskA3\\log_UDP.txt","w");
	//logfile=fopen("\\Storage Card\\log_UDP.txt","w");
	if(logfile == NULL)
	{
		MessageBox(0, TEXT("0"),TEXT ("0"), 0);
		fprintf(logfile, "Unable to create file.");
	}

	//Initialise Winsock
	fprintf(logfile, "\nInitialising Winsock...");
	//if (WSAStartup(MAKEWORD(1,1), &wsa) != 0)
	if (WSAStartup(MAKEWORD(2,2), &wsa) != 0)
	{
		fprintf(logfile, "WSAStartup() failed.\n");
		MessageBox(0, TEXT("1"),TEXT ("1"), 0);
		fclose(logfile);
		return 1;
	}
	fprintf(logfile, "Initialised");

	//Create a RAW Socket
	fprintf(logfile, "\nCreating RAW Socket...");
	//sniffer = socket(AF_INET, SOCK_RAW, IPPROTO_IP);

	sniffer = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);

	if (sniffer == INVALID_SOCKET)
	{
		fprintf(logfile, "Failed to create raw socket.\n");
		MessageBox(0, TEXT("2"),TEXT ("2"), 0);
		fclose(logfile);
		return 1;
	}
	fprintf(logfile, "Created.");

	BOOL bOptVal = TRUE;

	//Retrive the local hostname
	if (gethostname(hostname, sizeof(hostname)) == SOCKET_ERROR)
	{
		fprintf(logfile, "Error : %d",WSAGetLastError());
		MessageBox(0, TEXT("3"),TEXT ("3"), 0);
		fclose(logfile);
		return 1;
	}
	fprintf(logfile, "\nHost name : %s \n",hostname);

	//Retrive the available IPs of the local host
	local = gethostbyname(hostname);
	fprintf(logfile, "\nAvailable Network Interfaces : \n");
	if (local == NULL)
	{
		fprintf(logfile, "Error : %d.\n",WSAGetLastError());
		MessageBox(0, TEXT("4"),TEXT ("4"), 0);
		fclose(logfile);
		return 1;
	}

	for (i = 0; local->h_addr_list[i] != 0; ++i)
	{
		memcpy(&addr, local->h_addr_list[i], sizeof(struct in_addr));
		fprintf(logfile, "Interface Number : %d Address : %s\n",i,inet_ntoa(addr));
	}

	//fprintf(logfile, "Enter the interface number you would like to sniff : ");
	//scanf("%d",&in);
	in = 0;

	//memset(&dest, 0, sizeof(dest));
	//memcpy(&dest.sin_addr.s_addr,local->h_addr_list[in],sizeof(dest.sin_addr.s_addr));
	//dest.sin_addr.s_addr = inet_addr("127.0.0.1");
	dest.sin_addr.s_addr = htonl(INADDR_ANY);
	dest.sin_family = AF_INET;
	dest.sin_port = htons(29000);
	//dest.sin_port = 0;

	fprintf(logfile, "\nBinding socket to local system and port %d ...", dest.sin_port );
	if (bind(sniffer,(struct sockaddr *)&dest,sizeof(dest)) == SOCKET_ERROR)
	{
		fprintf(logfile, "bind(%s) failed.\n", inet_ntoa(addr));
		MessageBox(0, TEXT("5"),TEXT ("5"), 0);
		fclose(logfile);
		return 1;
	}
	fprintf(logfile, "Binding successful");

	//Enable this socket with the power to sniff : SIO_RCVALL is the key Receive ALL ;)
	Sleep(1000);
	j=1;
	fprintf(logfile, "\nSetting socket to sniff...");
	//DWORD flag = TRUE;
	/*if (WSAIoctl(sniffer, SIO_RCVALL, &j, sizeof(j), 0, 0, (LPDWORD) &in , 0 , 0) == SOCKET_ERROR)
    //if (ioctlsocket(sniffer, SIO_RCVALL, &flag) == SOCKET_ERROR)

	{
		fprintf(logfile, "WSAIoctl() failed.\n");
		MessageBox(0, TEXT("6"),TEXT ("6"), 0);
		fclose(logfile);
		return 1;
	}*/
	fprintf(logfile, "Socket set.");

	//Begin
	fprintf(logfile, "\nStarted Sniffing\n");
	fprintf(logfile, "Packet Capture Statistics...\n");
	StartSniffing(sniffer); //Happy Sniffing

	//End
	closesocket(sniffer);
	fclose(logfile);
	WSACleanup();

	return 0;
}
Лог, log_UDP.txt:
Код:
Initialising Winsock...Initialised
Creating RAW Socket...Created.
Host name : DbAu13XX 

Available Network Interfaces : 
Interface Number : 0 Address : 192.168.2.2

Binding socket to local system and port 18545 ...Binding successful
Setting socket to sniff...Socket set.
Started Sniffing
Packet Capture Statistics...


***********************UDP Packet*************************

IP Header
 |-IP Version : 14
 |-IP Header Length : 9 DWORDS or 36 Bytes
 |-Type Of Service : 3
 |-IP Total Length : 0 Bytes(Size of Packet)
 |-Identification : 44033
 |-Reserved ZERO Field : 0
 |-Dont Fragment Field : 0
 |-More Fragment Field : 0
 |-TTL : 10
 |-Protocol : 17
 |-Checksum : 3863
 |-Source IP : 5.0.220.7
 |-Destination IP : 4.1.3.15

UDP Header
 |-Source Port : 0
 |-Destination Port : 0
 |-UDP Length : 0
 |-UDP Checksum : 0

IP Header
 e9 03 00 00 ac 01 00 00 0a 11 0f 17 05 00 dc 07          ................ 
 04 01 03 0f 0c 00 d9 07 03 1f 00 00 00 00 00 00          ................ 
 00 00 00 00                                              .... 

UDP Header
 00 00 00 00 00 00 00 00                                  ........ 

Data Payload
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 01 00 00 00 c5 60 01 00 35 dc 67 09 0e 88 e2 0b          .....`..5.g..... 
 00 00 00 00 00 00 00 00 01 e9 6a 40 00 00 00 00          ..........j@.... 
 00 00 00 00 9f 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 df 07 00 00 05 00 00 00 06 00 00 00          ................ 
 01 00 00 00 0c 00 00 00 0c 00 00 00 15 00 00 00          ................ 
 1a 00 00 00 00 00 00 40 f0 e1 f2 3f 00 00 00 60          .......@...?...` 
 1a f0 eb 3f 09 00 00 00 02 00 00 00 1d ec 67 09          ...?..........g. 
 02 8d e2 0b 00 00 00 00 f3 d9 74 40 00 00 02 00          ..........t@.... 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 00          ................ 
 00 00 00 00 00 00 00 80 d7 aa d9 3f 01 00 00 00          ...........?.... 
 00 00 00 00 00 00 00 80 d7 aa d9 3f c8 00 00 00          ...........?.... 
 00 00 00 00 00 00 00 00 00 00 00 00 88 9f 00 00          ................ 
 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00          ................ 
 01 00 00 00 00 00 00 00 00 11 01 01 01 01 33 6f          ..............3o 
 42 03 03 01 18 01 01 01 01 1e 26 2e 03 03 02 1c          B.........&..... 
 01 01 01 01 33 4f 24 03 03 03 0f 01 01 01 01 24          ....3O$........$ 
 eb 1f 03 03 04 01 01 01 01 01 33 2c 15 03 03 05          ..........3,.... 
 0d 01 01 01 01 19 c5 13 03 03 06 0c 01 01 00 00          ................ 
 16 06 0e 03 00 07 0b 01 01 01 01 2d 21 09 03 03          ...........-!... 
 08 04 01 01 01 01 25 15 07 03 03 09 06 01 01 01          ......%......... 
 01 25 93 07 03 03 0a 16 01 00 00 00 00 47 05 03          .%...........G.. 
 00 0b 12 01 00 00 00 00 2a 00 03 00 00 00 00 00          ........*....... 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00                                              .... 


###########################################################TCP : 0 UDP : 1 ICMP : 0 IGMP : 0 Others : 0 Total : 1


***********************UDP Packet*************************

IP Header
 |-IP Version : 14
 |-IP Header Length : 9 DWORDS or 36 Bytes
 |-Type Of Service : 3
 |-IP Total Length : 0 Bytes(Size of Packet)
 |-Identification : 44289
 |-Reserved ZERO Field : 0
 |-Dont Fragment Field : 0
 |-More Fragment Field : 0
 |-TTL : 10
 |-Protocol : 17
 |-Checksum : 3863
 |-Source IP : 5.0.220.7
 |-Destination IP : 4.1.3.15

UDP Header
 |-Source Port : 0
 |-Destination Port : 0
 |-UDP Length : 0
 |-UDP Checksum : 0

IP Header
 e9 03 00 00 ad 01 00 00 0a 11 0f 17 05 00 dc 07          ................ 
 04 01 03 0f 0c 00 d9 07 03 1f 00 00 00 00 00 00          ................ 
 00 00 00 00                                              .... 

UDP Header
 00 00 00 00 00 00 00 00                                  ........ 

Data Payload
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 01 00 00 00 8d 61 01 00 35 dc 67 09 0e 88 e2 0b          .....a..5.g..... 
 00 00 00 00 00 00 00 00 01 e9 6a 40 00 00 00 00          ..........j@.... 
 00 00 00 00 9f 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 df 07 00 00 05 00 00 00 06 00 00 00          ................ 
 01 00 00 00 0c 00 00 00 0c 00 00 00 15 00 00 00          ................ 
 1b 00 00 00 00 00 00 e0 10 e2 f2 3f 00 00 00 20          ...........?...  
 4c f0 eb 3f 09 00 00 00 02 00 00 00 1d ec 67 09          L..?..........g. 
 02 8d e2 0b 00 00 00 00 f3 d9 74 40 00 00 02 00          ..........t@.... 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 00          ................ 
 00 00 00 00 00 00 00 80 d7 aa d9 3f 01 00 00 00          ...........?.... 
 00 00 00 00 00 00 00 80 d7 aa d9 3f c8 00 00 00          ...........?.... 
 00 00 00 00 00 00 00 00 00 00 00 00 88 9f 00 00          ................ 
 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00          ................ 
 01 00 00 00 00 00 00 00 00 11 01 01 01 01 33 6f          ..............3o 
 42 03 03 01 18 01 01 01 01 1f 26 2e 03 03 02 1c          B.........&..... 
 01 01 01 01 33 4f 24 03 03 03 0f 01 01 01 01 25          ....3O$........% 
 eb 1f 03 03 04 01 01 01 01 01 33 2c 15 03 03 05          ..........3,.... 
 0d 01 01 01 01 1c c5 13 03 03 06 0c 01 01 00 00          ................ 
 17 06 0e 03 00 07 0b 01 01 01 01 2d 21 09 03 03          ...........-!... 
 08 04 01 01 01 01 24 15 07 03 03 09 06 01 01 01          ......$......... 
 01 25 93 07 03 03 0a 16 01 00 00 00 00 47 04 03          .%...........G.. 
 00 0b 12 01 00 00 00 00 2a 00 03 00 00 00 00 00          ........*....... 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00                                              .... 


###########################################################TCP : 0 UDP : 2 ICMP : 0 IGMP : 0 Others : 0 Total : 2


***********************UDP Packet*************************

IP Header
 |-IP Version : 14
 |-IP Header Length : 9 DWORDS or 36 Bytes
 |-Type Of Service : 3
 |-IP Total Length : 0 Bytes(Size of Packet)
 |-Identification : 44545
 |-Reserved ZERO Field : 0
 |-Dont Fragment Field : 0
 |-More Fragment Field : 0
 |-TTL : 10
 |-Protocol : 17
 |-Checksum : 3863
 |-Source IP : 5.0.220.7
 |-Destination IP : 4.1.3.15

UDP Header
 |-Source Port : 0
 |-Destination Port : 0
 |-UDP Length : 0
 |-UDP Checksum : 0

IP Header
 e9 03 00 00 ae 01 00 00 0a 11 0f 17 05 00 dc 07          ................ 
 04 01 03 0f 0c 00 d9 07 03 1f 00 00 00 00 00 00          ................ 
 00 00 00 00                                              .... 

UDP Header
 00 00 00 00 00 00 00 00                                  ........ 

Data Payload
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 01 00 00 00 55 62 01 00 35 dc 67 09 0e 88 e2 0b          ....Ub..5.g..... 
 00 00 00 00 00 00 00 00 01 e9 6a 40 00 00 00 00          ..........j@.... 
 00 00 00 00 9f 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 df 07 00 00 05 00 00 00 06 00 00 00          ................ 
 01 00 00 00 0c 00 00 00 0c 00 00 00 15 00 00 00          ................ 
 1b 00 00 00 00 00 00 e0 10 e2 f2 3f 00 00 00 20          ...........?...  
 4c f0 eb 3f 09 00 00 00 02 00 00 00 1d ec 67 09          L..?..........g. 
 02 8d e2 0b 00 00 00 00 f3 d9 74 40 00 00 02 00          ..........t@.... 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 00          ................ 
 00 00 00 00 00 00 00 80 d7 aa d9 3f 01 00 00 00          ...........?.... 
 00 00 00 00 00 00 00 80 d7 aa d9 3f c8 00 00 00          ...........?.... 
 00 00 00 00 00 00 00 00 00 00 00 00 88 9f 00 00          ................ 
 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00          ................ 
 01 00 00 00 00 00 00 00 00 11 01 01 01 01 33 6f          ..............3o 
 42 03 03 01 18 01 01 01 01 1f 26 2e 03 03 02 1c          B.........&..... 
 01 01 01 01 33 4f 24 03 03 03 0f 01 01 01 01 25          ....3O$........% 
 eb 1f 03 03 04 01 01 01 01 01 33 2c 15 03 03 05          ..........3,.... 
 0d 01 01 01 01 1c c5 13 03 03 06 0c 01 01 00 00          ................ 
 17 06 0e 03 00 07 0b 01 01 01 01 2d 21 09 03 03          ...........-!... 
 08 04 01 01 01 01 24 15 07 03 03 09 06 01 01 01          ......$......... 
 01 25 93 07 03 03 0a 16 01 00 00 00 00 47 04 03          .%...........G.. 
 00 0b 12 01 00 00 00 00 2a 00 03 00 00 00 00 00          ........*....... 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00                                              .... 


###########################################################TCP : 0 UDP : 3 ICMP : 0 IGMP : 0 Others : 0 Total : 3


***********************UDP Packet*************************

IP Header
 |-IP Version : 14
 |-IP Header Length : 9 DWORDS or 36 Bytes
 |-Type Of Service : 3
 |-IP Total Length : 0 Bytes(Size of Packet)
 |-Identification : 44801
 |-Reserved ZERO Field : 0
 |-Dont Fragment Field : 0
 |-More Fragment Field : 0
 |-TTL : 10
 |-Protocol : 17
 |-Checksum : 3863
 |-Source IP : 5.0.220.7
 |-Destination IP : 4.1.3.15

UDP Header
 |-Source Port : 0
 |-Destination Port : 0
 |-UDP Length : 0
 |-UDP Checksum : 0

IP Header
 e9 03 00 00 af 01 00 00 0a 11 0f 17 05 00 dc 07          ................ 
 04 01 03 0f 0c 00 d9 07 03 1f 00 00 00 00 00 00          ................ 
 00 00 00 00                                              .... 

UDP Header
 00 00 00 00 00 00 00 00                                  ........ 

Data Payload
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 01 00 00 00 1d 63 01 00 35 dc 67 09 0e 88 e2 0b          .....c..5.g..... 
 00 00 00 00 00 00 00 00 01 e9 6a 40 00 00 00 00          ..........j@.... 
 00 00 00 00 9f 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 df 07 00 00 05 00 00 00 06 00 00 00          ................ 
 01 00 00 00 0c 00 00 00 0c 00 00 00 15 00 00 00          ................ 
 1b 00 00 00 00 00 00 e0 10 e2 f2 3f 00 00 00 20          ...........?...  
 4c f0 eb 3f 09 00 00 00 02 00 00 00 1d ec 67 09          L..?..........g. 
 02 8d e2 0b 00 00 00 00 f3 d9 74 40 00 00 02 00          ..........t@.... 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 00          ................ 
 00 00 00 00 00 00 00 80 d7 aa d9 3f 01 00 00 00          ...........?.... 
 00 00 00 00 00 00 00 80 d7 aa d9 3f c8 00 00 00          ...........?.... 
 00 00 00 00 00 00 00 00 00 00 00 00 88 9f 00 00          ................ 
 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00          ................ 
 01 00 00 00 00 00 00 00 00 11 01 01 01 01 33 6f          ..............3o 
 42 03 03 01 18 01 01 01 01 1f 26 2e 03 03 02 1c          B.........&..... 
 01 01 01 01 33 4f 24 03 03 03 0f 01 01 01 01 25          ....3O$........% 
 eb 1f 03 03 04 01 01 01 01 01 33 2c 15 03 03 05          ..........3,.... 
 0d 01 01 01 01 1c c5 13 03 03 06 0c 01 01 00 00          ................ 
 17 06 0e 03 00 07 0b 01 01 01 01 2d 21 09 03 03          ...........-!... 
 08 04 01 01 01 01 24 15 07 03 03 09 06 01 01 01          ......$......... 
 01 25 93 07 03 03 0a 16 01 00 00 00 00 47 04 03          .%...........G.. 
 00 0b 12 01 00 00 00 00 2a 00 03 00 00 00 00 00          ........*....... 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00                                              .... 


###########################################################TCP : 0 UDP : 4 ICMP : 0 IGMP : 0 Others : 0 Total : 4


***********************UDP Packet*************************

IP Header
 |-IP Version : 14
 |-IP Header Length : 9 DWORDS or 36 Bytes
 |-Type Of Service : 3
 |-IP Total Length : 0 Bytes(Size of Packet)
 |-Identification : 45057
 |-Reserved ZERO Field : 0
 |-Dont Fragment Field : 0
 |-More Fragment Field : 0
 |-TTL : 10
 |-Protocol : 17
 |-Checksum : 3863
 |-Source IP : 5.0.220.7
 |-Destination IP : 4.1.3.15

UDP Header
 |-Source Port : 0
 |-Destination Port : 0
 |-UDP Length : 0
 |-UDP Checksum : 0

IP Header
 e9 03 00 00 b0 01 00 00 0a 11 0f 17 05 00 dc 07          ................ 
 04 01 03 0f 0c 00 d9 07 03 1f 00 00 00 00 00 00          ................ 
 00 00 00 00                                              .... 

UDP Header
 00 00 00 00 00 00 00 00                                  ........ 

Data Payload
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 01 00 00 00 e5 63 01 00 35 dc 67 09 0e 88 e2 0b          .....c..5.g..... 
 00 00 00 00 00 00 00 00 01 e9 6a 40 00 00 00 00          ..........j@.... 
 00 00 00 00 9f 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 df 07 00 00 05 00 00 00 06 00 00 00          ................ 
 01 00 00 00 0c 00 00 00 0c 00 00 00 15 00 00 00          ................ 
 1b 00 00 00 00 00 00 e0 10 e2 f2 3f 00 00 00 20          ...........?...  
 4c f0 eb 3f 09 00 00 00 02 00 00 00 1d ec 67 09          L..?..........g. 
 02 8d e2 0b 00 00 00 00 f3 d9 74 40 00 00 02 00          ..........t@.... 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 00          ................ 
 00 00 00 00 00 00 00 80 d7 aa d9 3f 01 00 00 00          ...........?.... 
 00 00 00 00 00 00 00 80 d7 aa d9 3f c8 00 00 00          ...........?.... 
 00 00 00 00 00 00 00 00 00 00 00 00 88 9f 00 00          ................ 
 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00          ................ 
 01 00 00 00 00 00 00 00 00 11 01 01 01 01 33 6f          ..............3o 
 42 03 03 01 18 01 01 01 01 1f 26 2e 03 03 02 1c          B.........&..... 
 01 01 01 01 33 4f 24 03 03 03 0f 01 01 01 01 25          ....3O$........% 
 eb 1f 03 03 04 01 01 01 01 01 33 2c 15 03 03 05          ..........3,.... 
 0d 01 01 01 01 1c c5 13 03 03 06 0c 01 01 00 00          ................ 
 17 06 0e 03 00 07 0b 01 01 01 01 2d 21 09 03 03          ...........-!... 
 08 04 01 01 01 01 24 15 07 03 03 09 06 01 01 01          ......$......... 
 01 25 93 07 03 03 0a 16 01 00 00 00 00 47 04 03          .%...........G.. 
 00 0b 12 01 00 00 00 00 2a 00 03 00 00 00 00 00          ........*....... 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00                                              .... 


###########################################################TCP : 0 UDP : 5 ICMP : 0 IGMP : 0 Others : 0 Total : 5


***********************UDP Packet*************************

IP Header
 |-IP Version : 14
 |-IP Header Length : 9 DWORDS or 36 Bytes
 |-Type Of Service : 3
 |-IP Total Length : 0 Bytes(Size of Packet)
 |-Identification : 45313
 |-Reserved ZERO Field : 0
 |-Dont Fragment Field : 0
 |-More Fragment Field : 0
 |-TTL : 10
 |-Protocol : 17
 |-Checksum : 3863
 |-Source IP : 5.0.220.7
 |-Destination IP : 4.1.3.15

UDP Header
 |-Source Port : 0
 |-Destination Port : 0
 |-UDP Length : 0
 |-UDP Checksum : 0

IP Header
 e9 03 00 00 b1 01 00 00 0a 11 0f 17 05 00 dc 07          ................ 
 04 01 03 0f 0c 00 d9 07 03 1f 00 00 00 00 00 00          ................ 
 00 00 00 00                                              .... 

UDP Header
 00 00 00 00 00 00 00 00                                  ........ 

Data Payload
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 01 00 00 00 ad 64 01 00 35 dc 67 09 0e 88 e2 0b          .....d..5.g..... 
 00 00 00 00 00 00 00 00 01 e9 6a 40 00 00 00 00          ..........j@.... 
 00 00 00 00 9f 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 df 07 00 00 05 00 00 00 06 00 00 00          ................ 
 01 00 00 00 0c 00 00 00 0c 00 00 00 15 00 00 00          ................ 
 1b 00 00 00 00 00 00 e0 10 e2 f2 3f 00 00 00 20          ...........?...  
 4c f0 eb 3f 09 00 00 00 02 00 00 00 1d ec 67 09          L..?..........g. 
 02 8d e2 0b 00 00 00 00 f3 d9 74 40 00 00 02 00          ..........t@.... 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 00          ................ 
 00 00 00 00 00 00 00 80 d7 aa d9 3f 01 00 00 00          ...........?.... 
 00 00 00 00 00 00 00 80 d7 aa d9 3f c8 00 00 00          ...........?.... 
 00 00 00 00 00 00 00 00 00 00 00 00 86 9f 00 00          ................ 
 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00          ................ 
 01 00 00 00 00 00 00 00 00 11 01 01 01 01 33 6f          ..............3o 
 42 03 03 01 18 01 01 01 01 1f 26 2e 03 03 02 1c          B.........&..... 
 01 01 01 01 33 4f 24 03 03 03 0f 01 01 01 01 25          ....3O$........% 
 eb 1f 03 03 04 01 01 01 01 01 33 2c 15 03 03 05          ..........3,.... 
 0d 01 01 01 01 1c c5 13 03 03 06 0c 01 01 00 00          ................ 
 17 06 0e 03 00 07 0b 01 01 01 01 2d 21 09 03 03          ...........-!... 
 08 04 01 01 01 01 24 15 07 03 03 09 06 01 01 01          ......$......... 
 01 25 93 07 03 03 0a 16 01 00 00 00 00 47 04 03          .%...........G.. 
 00 0b 12 01 00 00 00 00 2a 00 03 00 00 00 00 00          ........*....... 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00          ................ 
 00 00 00 00                                              .... 


###########################################################TCP : 0 UDP : 6 ICMP : 0 IGMP : 0 Others : 0 Total : 6
recvfrom() failed.
urban81 вне форума  
Пользователь сказал cпасибо:
Старый 24.05.2015, 23:11   #22
urban81
Писатель
Доп. информация
Восклицание Думаю осталось совсем чуть чуть!

Здравствуйте.Решение приобрело "вид".Думаю это будет простой виртуальный драйвер(ком 6).Выкладываю проект для тестов на эмуляторе.Пока без пояснений...Проект сосотоит из :
1.Поект ДЛЛ виртуального драйвера.
2.Каб который установит эту ДЛЛ.
3.Проет ЛИБ NMEA.Он нужен для тестов на эмуляторе и на случай если функция конвертации протоколов(см. выше) не подойдёт. Придётя детально разбираться...
Также обращаю внимание,в проекте стоит перехват-хук нажатия аппаратных кнопок.
Не хватает принудидельной перезагрузки родной оболочки-это нужно для инициализации гпс в нашей навигации, которую мы выберем.Так же можно вызывать нашу навигацию из ДЛЛ.Всё в купе не тестил, только поотдельности.Так что , прошу,если чего исправляйте... Всем кто в теме спасибо за внимание.
Проект: [Ссылки могут видеть только зарегистрированные пользователи. ]
ИСПРАВИЛ!!!
urban81 вне форума  
Пользователь сказал cпасибо:
Старый 25.05.2015, 07:57   #23
avtoserg
Супер-модератор
 
Аватар для avtoserg
Доп. информация
По умолчанию

urban81, ссылка битая
__________________
Могу дать удочку, рыбу не просить!!!
Могу выдать время для [Ссылки могут видеть только зарегистрированные пользователи. ]
avtoserg вне форума  
Старый 04.06.2015, 18:06   #24
urban81
Писатель
Доп. информация
Восклицание Протестил на 4!Идём на ГУ!

Здравствуйте.Протестил на эмуляторе на 4.Работу драйвера можно посмотреть в логе.Добавил загрузку навигатора, взял 7 троп(см.проект Reader).Убрал проект каба.Убрал отлов нажатия клавишь.Нажатия также надо искать в локал хосте.Сейчас неуверен нужна ли перезагрузка родной оболочки...При помощи либы(читай выше), она генерит какие то посылки ЗНАЧОК СПУТНИКОВ СТАЛ ЗЕЛЁНЫМ!Сейчас занимаюсь расшифровкой лога с гу.Прошу помощи в этом.Все проекты можно взять выше ССЫЛКУ ОБНОВИЛ!Всем спасибо!

P.S.ОБЪЯВЛЯЮ КОНКУРС КТО В СДЕЛАЕТ ПЕРЕХВАТ АПИ РЕАДФАЙЛ ПРИ ПОМОЩИ ПРАВКИ ТАБЛИЦ ИМПОРТА И ВЫЛОЖИТ РАБОЧИЙ КОД ТОМУ ВЫШЛЮ КЛАССИЧЕСКУЮ АВСТРИЙСКУЮ ШЛЯПУ !
urban81 вне форума  
Пользователь сказал cпасибо:
Старый 11.06.2015, 12:57   #25
urban81
Писатель
Доп. информация
По умолчанию

Привет avtoserg.У тебя получилось лог снимать с помощь кода который выкладывал? Снял один раз и успокоился... Сейчас с этим кодом пробою ничего нет... вроде доходит до места:
Код:
mangobyte = recvfrom(sniffer , Buffer , 65536 , 0 , 0 , 0); //Eat as much as u can
и всё как будто там нет данных...
В чём хитрость не пойму.Подскажи пожалуйста если чего знаешь.Заранее спасибо.
urban81 вне форума  
Старый 12.06.2015, 00:31   #26
Sanik
Новичок
Доп. информация
По умолчанию

Хитрость в том, что давно пора купить готовое решение и не страдать фигней.
Sanik вне форума  
Старый 14.06.2015, 23:40   #27
urban81
Писатель
Доп. информация
Восклицание Хитрость раскрыта!Собираю воедино!

Здравствуйте форумчане.Спасибо за помощь.Вот ХИТРОСТЬ!Нужно было убить процесс родной проги(Navi.exe), чтобы первому сесть на порт.Но после того, как "убиваем" происходит перезагрузка гу.Это потому что родная прога (Navi.exe) ведёт общение с другими прогами или ёщё с чем то...И если это общение прекращается - перезагрузка...Что бы не было перезагрузки надо всем прогам "врать" что мы и есть Navi.exe.Либо при помощи:[Ссылки могут видеть только зарегистрированные пользователи. ] , либо тоже что то скидывать в локал хост.Всем спасибо.
urban81 вне форума  
Старый 15.06.2015, 08:07   #28
avtoserg
Супер-модератор
 
Аватар для avtoserg
Доп. информация
По умолчанию

urban81, головы такой под рукой нет
__________________
Могу дать удочку, рыбу не просить!!!
Могу выдать время для [Ссылки могут видеть только зарегистрированные пользователи. ]
avtoserg вне форума  
Старый 15.06.2015, 14:24   #29
urban81
Писатель
Доп. информация
По умолчанию

Здравствуйте форумчане.Здравствуйте avtoserg.Вы видите что нибудь ещё кроме времени в этих удп пакетах.Какой это вообще протокол?
urban81 вне форума  
Старый 15.06.2015, 21:51   #30
Sanik
Новичок
Доп. информация
По умолчанию

Может все-таки пора купить полноценное решение? Нету готовых координат в этих пакетах и никогда не было. Координаты из них получаются путем достаточно сложных математических вычислений. Алгоритм которых мы восстанавливали не один месяц.
Sanik вне форума  
Ответ

Опции темы


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Штатная навигация Kia Sorento 2012года Valerrra Неправильно созданные темы и сообщения попадают сюда 0 19.11.2013 12:36


Текущее время: 19:14. Часовой пояс GMT +4.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd. Перевод: zCarot

Копирайты