本文整理汇总了C++中dn_expand函数的典型用法代码示例。如果您正苦于以下问题:C++ dn_expand函数的具体用法?C++ dn_expand怎么用?C++ dn_expand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dn_expand函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dns_ptr_parser
/** parses a PTR record into a ptr_rdata structure */
struct ptr_rdata* dns_ptr_parser( unsigned char* msg, unsigned char* end,
unsigned char* rdata)
{
struct ptr_rdata* pname;
int len;
char name[MAX_DNS_NAME];
pname=0;
if (dn_expand(msg, end, rdata, name, MAX_DNS_NAME-1)==-1)
goto error;
len=strlen(name);
if (len>255)
goto error;
/* alloc sizeof struct + space for the null terminated name */
pname=local_malloc(sizeof(struct ptr_rdata)-1+len+1);
if(pname==0){
LM_ERR("out of memory\n");
goto error;
}
pname->ptrdname_len=len;
memcpy(pname->ptrdname, name, pname->ptrdname_len);
pname->ptrdname[pname->ptrdname_len]=0;
return pname;
error:
if (pname) local_free(pname);
return 0;
}
开发者ID:btriller,项目名称:kamailio,代码行数:28,代码来源:resolve.c
示例2: parse_answer
static int parse_answer(querybuf_t *ans, int len, struct in_addr *addr)
{
char buf[MAXPACKET];
HEADER *ahp;
u_char *cp, *eoa;
int type, n;
ahp = &ans->hdr;
eoa = ans->buf + len;
cp = ans->buf + sizeof(HEADER);
while (ahp->qdcount > 0) {
ahp->qdcount--;
cp += dn_skipname(cp, eoa) + QFIXEDSZ;
}
while (ahp->ancount > 0 && cp < eoa) {
ahp->ancount--;
if ((n = dn_expand(ans->buf, eoa, cp, buf, sizeof(buf))) < 0)
break;
cp += n;
type = _getshort(cp);
cp += 8;
n = _getshort(cp);
cp += 2;
if (type == T_CNAME) {
cp += n;
continue;
}
memcpy(addr, cp, n);
return 0;
}
h_errno = TRY_AGAIN;
return -1;
}
开发者ID:LeftThink,项目名称:state-threads,代码行数:35,代码来源:res.c
示例3: dn_expand_wrapper
// ccured wrappers
int dn_expand_wrapper(const u_char *msg, const u_char *eomorig,
const u_char *comp_dn, char *exp_dn, int length) {
__write_at_least(exp_dn, length);
__verify_nul(comp_dn);
return ( dn_expand(__ptrof(msg), __ptrof(eomorig), __ptrof(comp_dn),
__ptrof(exp_dn), length) );
}
开发者ID:cloudeyes,项目名称:zooberry,代码行数:8,代码来源:txt-dns-file-bad.c
示例4: ns_parserr
int
ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
int b;
int tmp;
/* Make section right. */
tmp = section;
if (tmp < 0 || section >= ns_s_max)
RETERR(ENODEV);
if (section != handle->_sect)
setsection(handle, section);
/* Make rrnum right. */
if (rrnum == -1)
rrnum = handle->_rrnum;
if (rrnum < 0 || rrnum >= handle->_counts[(int)section])
RETERR(ENODEV);
if (rrnum < handle->_rrnum)
setsection(handle, section);
if (rrnum > handle->_rrnum) {
b = ns_skiprr(handle->_msg_ptr, handle->_eom, section,
rrnum - handle->_rrnum);
if (b < 0)
return (-1);
handle->_msg_ptr += b;
handle->_rrnum = rrnum;
}
/* Do the parse. */
b = dn_expand(handle->_msg, handle->_eom,
handle->_msg_ptr, rr->name, NS_MAXDNAME);
if (b < 0)
return (-1);
handle->_msg_ptr += b;
if (handle->_msg_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom)
RETERR(EMSGSIZE);
NS_GET16(rr->type, handle->_msg_ptr);
NS_GET16(rr->rr_class, handle->_msg_ptr);
if (section == ns_s_qd) {
rr->ttl = 0;
rr->rdlength = 0;
rr->rdata = NULL;
} else {
if (handle->_msg_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom)
RETERR(EMSGSIZE);
NS_GET32(rr->ttl, handle->_msg_ptr);
NS_GET16(rr->rdlength, handle->_msg_ptr);
if (handle->_msg_ptr + rr->rdlength > handle->_eom)
RETERR(EMSGSIZE);
rr->rdata = handle->_msg_ptr;
handle->_msg_ptr += rr->rdlength;
}
if (++handle->_rrnum > handle->_counts[(int)section])
setsection(handle, (ns_sect)((int)section + 1));
/* All done. */
return (0);
}
开发者ID:coyizumi,项目名称:cs111,代码行数:59,代码来源:ns_parse.c
示例5: GetDN
static bool GetDN(const unsigned char * reply, const unsigned char * replyEnd, unsigned char * & cp, char * buff)
{
int len = dn_expand(reply, replyEnd, cp, buff, MAXDNAME);
if (len < 0)
return false;
cp += len;
return true;
}
开发者ID:joegen,项目名称:oss_core,代码行数:8,代码来源:DNS.cpp
示例6: rrextract
static int
rrextract(u_char *msg, int msglen, u_char *rrp, u_char *dname, int namelen)
{
/* cp is used to read data from rrp[] (the Resource Record)
* cp1 is used to write data into data[]
* However, we sometimes abuse cp1 and use it for reading too. :-/
*/
u_char *eom, *cp, *cp1, *rdatap;
u_int class, type, dlen;
int n;
long origTTL;
u_char data[MAXDATA*2+SPACE_FOR_VARS];
data [(MAXDATA*2)-1+SPACE_FOR_VARS] = EOS;
cp = rrp;
eom = msg + msglen;
GETSHORT(dlen, cp);
BOUNDS_CHECK(cp, dlen);
/* Begin case T_SIG: */
/* Just read one variable --- the original reads several. */
BOUNDS_CHECK(cp, SPACE_FOR_VARS);
cp1 = cp;
GETLONG(origTTL, cp1);
/* Skip checks on times which are present in the original. */
/* Copy over initial fields, which we read above. */
cp1 = (u_char *)data;
BOUNDS_CHECK(cp, SPACE_FOR_VARS);
memcpy(cp1, cp, SPACE_FOR_VARS);
cp += SPACE_FOR_VARS;
cp1 += SPACE_FOR_VARS;
/* Expand the domain name, set cp1 past the end of the uncompressed
* domain name.
*/
n = dn_expand(msg, eom, cp, (char *)cp1, (sizeof data));
if (n < 0) {
return (-1);
}
cp += n;
cp1 += strlen((char*)cp1)+1;
/* Figure out the length of the "signature" to copy over and copy it. */
n = dlen - (SPACE_FOR_VARS + n);
if (n > (sizeof data) - (cp1 - (u_char *)data)) {
return (-1); /* out of room! */
}
/* OK */
r_memcpy(cp1, cp, n);
return 0;
}
开发者ID:GiulioImperato,项目名称:frama-c,代码行数:58,代码来源:both_ok.c
示例7:
static char *get_name(unsigned char *msg, unsigned char *msg_end, unsigned char **msg_ptr)
{
int res;
static char buffer[MAX_STRING_LEN];
if (-1 == (res = dn_expand(msg, msg_end, *msg_ptr, buffer, sizeof(buffer))))
return NULL;
*msg_ptr += res;
return buffer;
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:12,代码来源:net.c
示例8: dn_expand
bool
dnsparse::qparse (const u_char **cpp, question *qp)
{
const u_char *cp = *cpp;
int n = dn_expand (buf, eom, cp, qp->q_name, sizeof (qp->q_name));
if (n < 0 || n >= MAXDNAME || cp + n + 4 > eom)
return false;
cp += n;
GETSHORT (qp->q_type, cp);
GETSHORT (qp->q_class, cp);
*cpp = cp;
return true;
}
开发者ID:gildafnai82,项目名称:craq,代码行数:13,代码来源:dnsparse.C
示例9: p_cdnname
const u_char *
p_cdnname(const u_char *cp, const u_char *msg, int len, FILE *file) {
char name[MAXDNAME];
int n;
if ((n = dn_expand(msg, msg + len, cp, name, sizeof name)) < 0)
return (NULL);
if (name[0] == '\0')
putc('.', file);
else
fputs(name, file);
return (cp + n);
}
开发者ID:hsienchieh,项目名称:uefilab,代码行数:13,代码来源:res_debug.c
示例10: krb5int_dns_nextans
/*
* krb5int_dns_nextans() - get next answer record
*
* Sets pp to NULL if no more records.
*/
int
krb5int_dns_nextans(struct krb5int_dns_state *ds,
const unsigned char **pp, int *lenp)
{
int len;
unsigned char *p;
unsigned short ntype, nclass, rdlen;
#if !HAVE_DN_SKIPNAME
char host[MAXDNAME];
#endif
*pp = NULL;
*lenp = 0;
p = ds->ptr;
while (ds->nanswers--) {
#if HAVE_DN_SKIPNAME
len = dn_skipname(p, (unsigned char *)ds->ansp + ds->anslen);
#else
len = dn_expand(ds->ansp, (unsigned char *)ds->ansp + ds->anslen,
p, host, sizeof(host));
#endif
if (len < 0 || !INCR_OK(ds->ansp, ds->anslen, p, len))
return -1;
p += len;
SAFE_GETUINT16(ds->ansp, ds->anslen, p, 2, ntype, out);
/* Also skip 4 bytes of TTL */
SAFE_GETUINT16(ds->ansp, ds->anslen, p, 6, nclass, out);
SAFE_GETUINT16(ds->ansp, ds->anslen, p, 2, rdlen, out);
if (!INCR_OK(ds->ansp, ds->anslen, p, rdlen))
return -1;
/* Solaris Kerberos - resync */
#if 0
if (rdlen > INT_MAX)
return -1;
#endif
if (nclass == ds->nclass && ntype == ds->ntype) {
*pp = p;
*lenp = rdlen;
ds->ptr = p + rdlen;
return 0;
}
p += rdlen;
}
return 0;
out:
return -1;
}
开发者ID:NanXiao,项目名称:illumos-joyent,代码行数:54,代码来源:dnsglue.c
示例11: krb5int_dns_expand
/*
* krb5int_dns_expand - wrapper for dn_expand()
*/
int
krb5int_dns_expand(struct krb5int_dns_state *ds, const unsigned char *p,
char *buf, int len)
{
#if HAVE_NS_NAME_UNCOMPRESS
return ns_name_uncompress(ds->ansp,
(unsigned char *)ds->ansp + ds->anslen,
p, buf, (size_t)len);
#else
return dn_expand(ds->ansp,
(unsigned char *)ds->ansp + ds->anslen,
p, buf, len);
#endif
}
开发者ID:Baalmart,项目名称:krb5,代码行数:18,代码来源:dnsglue.c
示例12: p_cdname
char *
p_cdname(char *cp, char *msg, FILE *file)
{
char name[MAXDNAME];
int n;
if ((n = dn_expand(msg, msg + 512, cp, name, sizeof(name))) < 0)
return (NULL);
if (name[0] == '\0') {
name[0] = '.';
name[1] = '\0';
}
fputs(name, file);
return (cp + n);
}
开发者ID:LambdaCalculus379,项目名称:SLS-1.02,代码行数:15,代码来源:res_debug.c
示例13: p_fqnname
const u_char *
p_fqnname (const u_char *cp, const u_char *msg, int msglen, char *name,
int namelen)
{
int n, newlen;
if ((n = dn_expand(msg, cp + msglen, cp, name, namelen)) < 0)
return (NULL);
newlen = strlen(name);
if (newlen == 0 || name[newlen - 1] != '.') {
if (newlen + 1 >= namelen) /* Lack space for final dot */
return (NULL);
else
strcpy(name + newlen, ".");
}
return (cp + n);
}
开发者ID:bminor,项目名称:glibc,代码行数:17,代码来源:res_debug.c
示例14: fqdn_to_env
static void fqdn_to_env(const char *name, const uint8_t *fqdn, size_t len)
{
size_t buf_len = strlen(name);
size_t buf_size = len + buf_len + 2;
const uint8_t *fqdn_end = fqdn + len;
char *buf = realloc(NULL, len + buf_len + 2);
memcpy(buf, name, buf_len);
buf[buf_len++] = '=';
int l = 1;
while (l > 0 && fqdn < fqdn_end) {
l = dn_expand(fqdn, fqdn_end, fqdn, &buf[buf_len], buf_size - buf_len);
fqdn += l;
buf_len += strlen(&buf[buf_len]);
buf[buf_len++] = ' ';
}
buf[buf_len - 1] = '\0';
putenv(buf);
}
开发者ID:rjknight123,项目名称:asuswrt-merlin,代码行数:18,代码来源:script.c
示例15: getMailserver
char* getMailserver(const char* domain) {
int len;
char answer[NS_PACKETSZ];
char *mailserver = malloc(NS_PACKETSZ);
ns_msg msg;
ns_rr rr;
if(res_init() == -1) {
return NULL;
}
len = res_query(domain,C_ANY,T_MX,answer,NS_PACKETSZ);
if(len == -1) {
return NULL;
}
/* return first MX record */
ns_initparse(answer,len,&msg);
ns_parserr(&msg,ns_s_an,0,&rr);
dn_expand(ns_msg_base(msg),ns_msg_base(msg)+ns_msg_size(msg),ns_rr_rdata(rr)+NS_INT16SZ,mailserver,NS_PACKETSZ);
return mailserver;
}
开发者ID:n0g,项目名称:cherami,代码行数:20,代码来源:sendmail.c
示例16: dns_srv_parser
/* SRV rdata format:
* 111111
* 0123456789012345
* +----------------+
* | priority |
* |----------------|
* | weight |
* |----------------|
* | port number |
* |----------------|
* | |
* ~ name ~
* | |
* +----------------+
*/
struct srv_rdata* dns_srv_parser( unsigned char* msg, unsigned char* end,
unsigned char* eor,
unsigned char* rdata)
{
struct srv_rdata* srv;
unsigned short priority;
unsigned short weight;
unsigned short port;
int len;
char name[MAX_DNS_NAME];
srv=0;
if ((rdata+6+1)>eor) goto error;
memcpy((void*)&priority, rdata, 2);
memcpy((void*)&weight, rdata+2, 2);
memcpy((void*)&port, rdata+4, 2);
rdata+=6;
if (dn_expand(msg, end, rdata, name, MAX_DNS_NAME-1)<0)
goto error;
len=strlen(name);
if (len>255)
goto error;
/* alloc enought space for the struct + null terminated name */
srv=local_malloc(sizeof(struct srv_rdata)-1+len+1);
if (srv==0){
LOG(L_ERR, "ERROR: dns_srv_parser: out of memory\n");
goto error;
}
srv->priority=ntohs(priority);
srv->weight=ntohs(weight);
srv->port=ntohs(port);
srv->name_len=len;
memcpy(srv->name, name, srv->name_len);
srv->name[srv->name_len]=0;
return srv;
error:
if (srv) local_free(srv);
return 0;
}
开发者ID:miao606,项目名称:kamailio,代码行数:56,代码来源:resolve.c
示例17: php_getmxrr
int php_getmxrr(char *hostname, char *mx_list, char *weight_list) {
#ifdef PCC_MINGW
return 0;
#else
char *mx_list_ptr = (char *)(mx_list + sprintf(mx_list, ""));
char *weight_list_ptr = (char *)(weight_list + sprintf(weight_list, ""));
unsigned char answer[MAXPACKET];
unsigned char expand_buffer[MAXHOSTNAMELEN];
int ans_len = res_search(hostname, C_IN, T_MX, answer, sizeof(answer));
HEADER *header_ptr = (HEADER *)&answer;
unsigned char *body_ptr = (unsigned char *)&answer + NS_HFIXEDSZ;
unsigned char *eom_ptr = (unsigned char *)&answer + sizeof(answer);
int n, ancount, qdcount, type, weight;
for (qdcount = ntohs((unsigned short)header_ptr->qdcount); qdcount--; body_ptr += (n + NS_QFIXEDSZ))
if ((n = dn_skipname(body_ptr, eom_ptr)) < 0)
return -1;
ancount = ntohs((unsigned short)header_ptr->ancount);
while (--ancount >= 0 && body_ptr < eom_ptr) {
if ((n = dn_skipname(body_ptr, eom_ptr)) < 0)
return -1;
body_ptr += n;
NS_GET16(type, body_ptr);
body_ptr += (NS_INT16SZ + NS_INT32SZ);
NS_GET16(n, body_ptr);
if (type != T_MX) {
body_ptr += n;
continue;
}
NS_GET16(weight, body_ptr);
if ((n = dn_expand(answer, eom_ptr, body_ptr, expand_buffer, sizeof(expand_buffer) - 1)) < 0)
return -1;
body_ptr += n;
mx_list_ptr += sprintf(mx_list_ptr - 1, " %s ", expand_buffer);
weight_list_ptr += sprintf(weight_list_ptr - 1, " %d ", weight);
}
return 0;
#endif /* PCC_MINGW */
}
开发者ID:96Levels,项目名称:roadsend-php,代码行数:41,代码来源:network.c
示例18: dns_ebl_parser
/* EBL rdata format:
* (see http://tools.ietf.org/html/draft-ietf-enum-branch-location-record-03)
* one or several character strings:
* 01234567
* +--------+
* | postion|
* +-----------+
* / separator /
* +-----------+
* / apex /
* +----------+
*
* where separator is a character string ( 8 bit len, followed by len chars)
* and apex is a domain-name.
*/
static struct ebl_rdata* dns_ebl_parser(unsigned char* msg, unsigned char* end,
unsigned char* eor,
unsigned char* rdata)
{
struct ebl_rdata* ebl;
int sep_len;
int apex_len;
char apex[MAX_DNS_NAME];
ebl=0;
/* check if len is at least 4 chars (minimum possible):
pos (1 byte) + sep. (min 1 byte) + apex (min. 2 bytes)
and also check if rdata+1 (pos) + 1 (sep. len) + sep_len + 1 is ok*/
if (unlikely(((rdata+4)>eor)||((rdata+1+1+rdata[1]+2)>eor))) goto error;
sep_len=rdata[1];
if (unlikely(dn_expand(msg, end, rdata+1+1+sep_len,
apex, MAX_DNS_NAME-1)==-1))
goto error;
apex_len=strlen(apex);
/* alloc sizeof struct + space for the 2 null-terminated strings */
ebl=local_malloc(sizeof(struct ebl_rdata)-1+sep_len+1+apex_len+1);
if (ebl==0){
LOG(L_ERR, "ERROR: dns_ebl_parser: out of memory\n");
goto error;
}
ebl->position=rdata[0];
ebl->separator=&ebl->str_table[0];
ebl->apex=ebl->separator+sep_len+1;
ebl->separator_len=sep_len;
ebl->apex_len=apex_len;
memcpy(ebl->separator, rdata+2, sep_len);
ebl->separator[sep_len]=0;
memcpy(ebl->apex, apex, apex_len);
ebl->apex[apex_len]=0;
return ebl;
error:
if (ebl) local_free(ebl);
return 0;
}
开发者ID:miao606,项目名称:kamailio,代码行数:55,代码来源:resolve.c
示例19: initparse
/*
* initparse
*
* Skip header and question section of reply. Set a pointer to the
* beginning of the answer section, and prepare to iterate over
* answer records.
*/
static int
initparse(struct krb5int_dns_state *ds)
{
HEADER *hdr;
unsigned char *p;
unsigned short nqueries, nanswers;
int len;
#if !HAVE_DN_SKIPNAME
char host[MAXDNAME];
#endif
if ((size_t) ds->anslen < sizeof(HEADER))
return -1;
hdr = (HEADER *)ds->ansp;
p = ds->ansp;
nqueries = ntohs((unsigned short)hdr->qdcount);
nanswers = ntohs((unsigned short)hdr->ancount);
p += sizeof(HEADER);
/*
* Skip query records.
*/
while (nqueries--) {
#if HAVE_DN_SKIPNAME
len = dn_skipname(p, (unsigned char *)ds->ansp + ds->anslen);
#else
len = dn_expand(ds->ansp, (unsigned char *)ds->ansp + ds->anslen,
p, host, sizeof(host));
#endif
if (len < 0 || !INCR_OK(ds->ansp, ds->anslen, p, len + 4))
return -1;
p += len + 4;
}
ds->ptr = p;
ds->nanswers = nanswers;
return 0;
}
开发者ID:Baalmart,项目名称:krb5,代码行数:45,代码来源:dnsglue.c
示例20: app_parse_srv
static int
app_parse_srv(radiodns_app_t *app, ns_msg handle, ns_rr rr, char *dnbuf, radiodns_srv_t *srv)
{
const unsigned char *rdata;
(void) app;
rdata = ns_rr_rdata(rr);
srv->priority = ns_get16(rdata);
rdata += NS_INT16SZ;
srv->weight = ns_get16(rdata);
rdata += NS_INT16SZ;
srv->port = ns_get16(rdata);
rdata += NS_INT16SZ;
dn_expand(ns_msg_base(handle), ns_msg_base(handle) + ns_msg_size(handle), rdata, dnbuf, MAXDNAME);
if(!(srv->target = strdup(dnbuf)))
{
return -2;
}
return 0;
}
开发者ID:nexgenta,项目名称:libradiodns,代码行数:24,代码来源:resolver.c
注:本文中的dn_expand函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论