alias_dns.c revision e64031e20c39650a7bc902a3e1aba613b9415dee
/* $Id$ */
/** @file
* libalias helper for using the host resolver instead of dnsproxy.
*/
/*
* Copyright (C) 2009 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef RT_OS_WINDOWS
# include <netdb.h>
#endif
#include <slirp.h>
#include "alias.h"
#include "alias_local.h"
#include "alias_mod.h"
#define DNS_CONTROL_PORT_NUMBER 53
/* see RFC 1035(4.1.1) */
union dnsmsg_header
{
struct
{
unsigned id:16;
unsigned rd:1;
unsigned tc:1;
unsigned aa:1;
unsigned opcode:4;
unsigned qr:1;
unsigned rcode:4;
unsigned Z:3;
unsigned ra:1;
} X;
};
struct dnsmsg_answer
{
};
/* see RFC 1035(4.1) */
static int
{
return -1;
return 0;
return -1;
}
static void doanswer(struct libalias *la, union dnsmsg_header *hdr,char *qname, struct ip *pip, struct hostent *h)
{
int i;
if (!h)
{
}
else
{
char *query;
char *answers;
char **cstr;
char *c;
uint16_t packet_len = 0;
#if 0
/* here is no compressed names+answers + new query */
#endif
+ sizeof(struct udphdr)
+ sizeof(union dnsmsg_header)
/* add aliases */
{
}
/* add addresses */
{
}
/* don't forget update m_len */
}
}
static int
{
int i;
/* Parse dns request */
char cname[255];
return 0; /* this is respose */
{
}
h = gethostbyname(cname);
/*
* We have changed the size and the content of udp, to avoid double csum calculation
* will assign to zero
*/
return 0;
}
/*
* qstr is z-string with -dot- replaced with \count to next -dot-
* e.g. ya.ru is \02ya\02ru
* Note: it's assumed that caller allocates buffer for cstr
*/
{
const char *q;
char *c;
{
if ( isalpha(*q)
|| isdigit(*q)
|| *q == '-'
|| *q == '_')
{
*c = *q;
c++;
}
else if (c != &pszStr[0])
{
*c = '.';
c++;
}
}
*c = '\0';
}
/*
*
*/
{
const char *c;
const char *pc;
char *q;
{
/* at the begining or at -dot- position */
{
if (c != pcszStr)
c++;
}
else
{
*q = *c;
c++;
}
}
*q = '\0';
}
int
{
}
int
{
}
static int
{
int error;
if (!handlers)
switch (type)
{
case MOD_LOAD:
error = 0;
break;
case MOD_UNLOAD:
error = 0;
break;
default:
}
return error;
}