Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Polestar 3 Performance, test drive: comodità e potenza possono convivere
Polestar 3 Performance, test drive: comodità e potenza possono convivere
Abbiamo passato diversi giorni alla guida di Polestar 3, usata in tutti i contesti. Come auto di tutti i giorni è comodissima, ma se si libera tutta la potenza è stupefacente
Qualcomm Snapdragon X2 Elite: l'architettura del SoC per i notebook del 2026
Qualcomm Snapdragon X2 Elite: l'architettura del SoC per i notebook del 2026
In occasione del proprio Architecture Deep Dive 2025 Qualcomm ha mostrato in dettaglio l'architettura della propria prossima generazione di SoC destinati ai notebook Windows for ARM di prossima generazione. Snapdragon X2 Elite si candida, con sistemi in commercio nella prima metà del 2026, a portare nuove soluzioni nel mondo dei notebook sottili con grande autonomia
Recensione DJI Mini 5 Pro: il drone C0 ultra-leggero con sensore da 1 pollice
Recensione DJI Mini 5 Pro: il drone C0 ultra-leggero con sensore da 1 pollice
DJI Mini 5 Pro porta nella serie Mini il primo sensore CMOS da 1 pollice, unendo qualità d'immagine professionale alla portabilità estrema tipica di tutti i prodotti della famiglia. È un drone C0, quindi in un peso estremamente contenuto e che non richiede patentino, propone un gimbal rotabile a 225 gradi, rilevamento ostacoli anche notturno e autonomia fino a 36 minuti. Caratteristiche che rendono il nuovo drone un riferimento per creator e appassionati
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 22-04-2003, 19:26   #1
sephiro
Junior Member
 
Iscritto dal: Nov 2001
Messaggi: 1
[Problema] che struttura per una query al dns?

Salve,
sto sviluppando per motivi didattici un piccolo programmino che non fa altro che intercettare le query di una certa macchina al dns, ed inviare una risposta manipolata.
Il mio problema e' che per catturare una query e per creare una response uso questa struttura:
Codice:
struct dns_header {
	// Header DNS
	u_int16_t id;			/* query identification number 		*/
	unsigned	qr: 1;		/* response flag  			*/
	unsigned	opcode: 4;	/* purpose of message 			*/
	unsigned	aa: 1;		/* authoritative answer 		*/
	unsigned	tc: 1;		/* truncated message 			*/
	unsigned	rd: 1;		/* recursion desired 			*/
	unsigned	ra: 1;		/* recursion available  		*/
	unsigned	unused :1;	/* unused bits (MBZ as of 4.9.3a3)	*/
	unsigned	ad: 1;		/* authentic data from named  		*/
	unsigned	cd: 1;		/* checking disabled by resolver 	*/
	unsigned	rcode: 4;	/* response code  			*/
	u_int16_t qdcount;		/* number of question entries 		*/
	u_int16_t ancount;		/* number of answer entries 		*/
	u_int16_t nscount;		/* number of authority entries 		*/
	u_int16_t arcount;		/* number of resource entries		*/	
};

struct rr {
	char * rd;
	char name[256];
	unsigned short int type;
	unsigned short int classe;
	unsigned long int ttl;
	unsigned short int rdlenght;
};

struct query {
  char name[256];
  unsigned short int type;
  unsigned short int classe;
};

struct dns_packet {
	struct dns_header head;
	struct query question;
	struct rr answer;
  	struct rr authoritative;
  	//struct rr additional;
};
purtroppo quando invio la risposta il pacchetto viene classificato come "bad packet" e quindi scartato.
Ho appurato che il problema sta nella struttura non adatta, in quanto tutto il resto funziona regolarmente.
Suggerimenti? Il linguaggio usato e' il C.
sephiro è offline   Rispondi citando il messaggio o parte di esso
Old 23-04-2003, 10:50   #2
cionci
Senior Member
 
L'Avatar di cionci
 
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
Ho scopiazzato queste strutture da un programma per Windows che fa query ad un server DNS... Non so quanto ti possa tornare utile, ma le metto lo stesso...

Codice:
typedef unsigned char BYTE;
typedef unsigned char UCHAR;
typedef void *LPVOID;

#define DNS_FLAGS_QR		0x8000	//Query or Response
#define DNS_FLAGS_OPCODE	0x7800	//Operation Code
#define DNS_FLAGS_AA		0x0400	//Authoritative Answer
#define DNS_FLAGS_TC		0x0200	//Truncated
#define DNS_FLAGS_RD		0x0100	//Recursion Desired
#define DNS_FLAGS_RA		0x0080	//Recursion Available
#define DNS_FLAGS_Z			0x0070	//Reserved
#define DNS_FLAGS_RCODE		0x000F	//Response Code

#define DNS_TYPE_A			1
#define DNS_TYPE_NS			2
#define DNS_TYPE_MD			3
#define DNS_TYPE_MF			4
#define DNS_TYPE_CNAME		5
#define DNS_TYPE_SOA		6
#define DNS_TYPE_MB			7
#define DNS_TYPE_MG			8
#define DNS_TYPE_MR			9
#define DNS_TYPE_NULL		10
#define DNS_TYPE_WKS		11
#define DNS_TYPE_PTR		12
#define DNS_TYPE_HINFO		13
#define DNS_TYPE_MINFO		14
#define DNS_TYPE_MX			15
#define DNS_TYPE_TXT		16
#define DNS_TYPE_RP			17
#define DNS_TYPE_AFSDB		18
#define DNS_TYPE_X25		19
#define DNS_TYPE_ISDN		20
#define DNS_TYPE_RT			21
#define DNS_TYPE_NSAP		22
#define DNS_TYPE_NSAP_PTR	23
#define DNS_TYPE_SIG		24
#define DNS_TYPE_KEY		25
#define DNS_TYPE_PX			26
#define DNS_TYPE_GPOS		27
#define DNS_TYPE_AAAA		28
#define DNS_TYPE_LOC		29

#define DNS_CLASS_IN		1
#define DNS_CLASS_CS		2
#define DNS_CLASS_CH		3
#define DNS_CLASS_HS		4

#define DNS_ERR_NONE		0
#define DNS_ERR_FORMAT		1
#define DNS_ERR_SERVER		2
#define DNS_ERR_NAME		3
#define DNS_ERR_NOSUPP		4
#define DNS_ERR_REFUSED		5

#define DNS_STANDARD		0
#define DNS_INVERSE			1
#define DNS_STATUS			2

typedef struct {
	USHORT ID;
	USHORT Flags;
	/*
		0... .... .... .... = Query/Response
		.000 0... .... .... = Operation Code
		.... .0.. .... .... = Authoritative Answer
		.... ..0. .... .... = Truncated
		.... ...0 .... .... = Recursion Desired
		.... .... 0... .... = Recursion Available
		.... .... .000 .... = Z
		.... .... .... 0000 = Response Code
	*/
	USHORT QDCount;
	USHORT ANCount;
	USHORT NSCount;
	USHORT ARCount;
} DNS_HEADER;

typedef struct {
    UCHAR* Name;
    USHORT Type;
    USHORT Class;
} DNS_QUESTION;

typedef struct {
    UCHAR* Name;
    USHORT Type;
	USHORT Class;
	long   TTL;
    USHORT RDLength;
    LPVOID pData;
} DNS_RECORD;

typedef struct {
	DNS_HEADER header;
	DNS_QUESTION* Question;
	DNS_RECORD* Answer;
	DNS_RECORD* Authority;
	DNS_RECORD* Additional;
} DNS_PACKET;

typedef struct {
    UCHAR* MName;
    UCHAR* RName;
    ULONG  Serial;
    ULONG  Refresh;
    ULONG  Retry;
    ULONG  Expire;
    ULONG  Minimum;
} DNS_SOA;

typedef struct {
    UCHAR* Address;
    BYTE   Protocol;
    LPVOID BitMap;
} DNS_WKS;

typedef struct {
    UCHAR*  CPU;
    UCHAR*  OS;
} DNS_HINFO;

typedef struct {
    UCHAR*  RMailBX;
    UCHAR*  EMailBX;
} DNS_MINFO;

typedef struct {
    USHORT Preference;
    UCHAR* Exchange;
} DNS_MX;

typedef struct {
    UCHAR*  mbox_dname;
    UCHAR*  txt_dname;
} DNS_RP;

typedef struct {
    USHORT  SubType;
    UCHAR*  HostName;
} DNS_AFSDB;

typedef struct {
    UCHAR*  address;
    UCHAR*  sa;
} DNS_ISDN;

typedef struct {
    USHORT  Preference;
    UCHAR*  Intermediate_Host;
} DNS_RT;

typedef struct {
	USHORT ip6[8];
} DNS_AAAA;

typedef struct {
    BYTE   Version;
    BYTE   Size;
    BYTE   Horiz_Pre;
    BYTE   Vert_Pre;
    ULONG  Latitude;
    ULONG  Longitude;
    ULONG  Altitude;
} DNS_LOC;
cionci è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Polestar 3 Performance, test drive: comodità e potenza possono convivere Polestar 3 Performance, test drive: comodit&agra...
Qualcomm Snapdragon X2 Elite: l'architettura del SoC per i notebook del 2026 Qualcomm Snapdragon X2 Elite: l'architettura del...
Recensione DJI Mini 5 Pro: il drone C0 ultra-leggero con sensore da 1 pollice Recensione DJI Mini 5 Pro: il drone C0 ultra-leg...
ASUS Expertbook PM3: il notebook robusto per le aziende ASUS Expertbook PM3: il notebook robusto per le ...
Test ride con Gowow Ori: elettrico e off-road vanno incredibilmente d'accordo Test ride con Gowow Ori: elettrico e off-road va...
'Robot abbastanza forti da fratturare un...
Anche DAZN ha il suo Black Friday: 40 eu...
Carmageddon: Rogue Shift, il prossimo ca...
Redal Alert 2: Command & Conquer si ...
Kingston Technology: memorie e storage c...
Narwal Freo Z10 Ultra: il robot con moci...
In 3 minuti le vedete tutte: sono le mig...
Black Friday da record per Tineco: le sc...
La nuova PS5 con Fortnite manda in tilt ...
Amazon, i tagli hanno colpito soprattutt...
Pazzesco: Panasonic Lumix DC-GH5M2E a 79...
Ecco tutte le offerte Black Friday pi&ug...
DJI Neo a 169€, Flip Combo a 309€ e molt...
Quattro persone arrestate negli USA per ...
Kindle Paperwhite Signature Edition, Col...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 16:20.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Served by www3v