C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 22nd, 2012, 08:56 AM
click66 click66 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 click66 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 21 sec
Reputation Power: 0
Question Send dns reponse

I'm trying to send a dns response message to my browser, now I created some structs and filled one in for the website of drupal.org.

When I'm sending the response wiresharks sais it is malformed,
could someone take a look?

Code:
	dnsresponse response;
	unsigned char buf[sizeof response];


	response.id = (unsigned short) htons(GetCurrentProcessId());
	response.response = 1;
	response.opCode = 0;
	response.authoritative = 0;
	response.truncated = 0;
	response.recursion = 1;
	response.recursionAvField = 1;
	response.z = 0;

	response.replyCode = 0;

	response.questions = 1;
	response.answer = 1;
	response.authorityRRS = 0;
	response.additionalRRS = 0;

	response.qName = (unsigned char *)malloc(sizeof("www.drupal.org"));
	response.qType = 1;
	response.qClass = 1;

	response.aName = (unsigned char *)malloc(sizeof("www.drupal.org"));
	response.aType = 1;
	response.aClass = 1;
	response.ttl = 0;
	response.dataLength = 9;
	response.addr = 2362640912;

	memcpy(buf, &response, sizeof response);


My struct is as follows:

Code:
typedef struct
{
	unsigned short id; // ID nummer
	unsigned short response :1; // 1 is reply 0 is query
	unsigned short opCode :4;
	unsigned short authoritative :1; // DNS server is authoritative server
	unsigned short truncated :1;
	unsigned short recursion :1; // Recursie of niet
	unsigned short recursionAvField :1; // Recursie in reply
	unsigned short z :3;
	//unsigned short aa;
	//unsigned short nAD;
	unsigned short replyCode :4;

	unsigned short questions;
	unsigned short answer;
	unsigned short authorityRRS;
	unsigned short additionalRRS;

	unsigned char * qName;
	unsigned short qType;
	unsigned short qClass;

	unsigned char * aName;
	unsigned short aType;
	unsigned short aClass;
	int ttl :32;
	unsigned short dataLength;
	unsigned int addr :32;
}dnsresponse;


Kind regards,

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Send dns reponse

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap