当前位置: 首页>>代码示例>>C++>>正文


C++ dn_skipname函数代码示例

本文整理汇总了C++中dn_skipname函数的典型用法代码示例。如果您正苦于以下问题:C++ dn_skipname函数的具体用法?C++ dn_skipname怎么用?C++ dn_skipname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dn_skipname函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ns_skiprr

int
ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count)
{
	const u_char *optr = ptr;

	for ((void) NULL; count > 0; count--) {
		int b, rdlength;

		b = dn_skipname(ptr, eom);
		if (b < 0) {
			RETERR(EMSGSIZE);
		}
		ptr += b /*Name*/ + NS_INT16SZ /*Type*/ + NS_INT16SZ /*Class*/;
		if (section != ns_s_qd) {
			if (ptr + NS_INT32SZ + NS_INT16SZ > eom) {
				RETERR(EMSGSIZE);
			}
			ptr += NS_INT32SZ /*TTL*/;
			NS_GET16(rdlength, ptr);
			ptr += rdlength /*RData*/;
		}
	}
	if (ptr > eom) {
		RETERR(EMSGSIZE);
	}
	return (ptr - optr);
}
开发者ID:AaronVanGeffen,项目名称:bitlbee,代码行数:27,代码来源:ns_parse.c

示例2: ns_skiprr

isc_result_t
ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count,
	  int *rc) {
	const u_char *optr = ptr;

	for ((void)NULL; count > 0; count--) {
		int b, rdlength;

		b = dn_skipname(ptr, eom);
		if (b < 0)
			return ISC_R_INCOMPLETE;
		ptr += b/*Name*/ + NS_INT16SZ/*Type*/ + NS_INT16SZ/*Class*/;
		if (section != ns_s_qd) {
			if (ptr + NS_INT32SZ + NS_INT16SZ > eom)
				return ISC_R_INCOMPLETE;
			ptr += NS_INT32SZ/*TTL*/;
			rdlength = getUShort(ptr);
			ptr += 2;
			ptr += rdlength/*RData*/;
		}
	}
	if (ptr > eom)
		return ISC_R_INCOMPLETE;
	if (rc)
		*rc = ptr - optr;
	return ISC_R_SUCCESS;
}
开发者ID:gosudream,项目名称:netbsd-src,代码行数:27,代码来源:ns_parse.c

示例3: 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:12307,项目名称:state-threads,代码行数:35,代码来源:res.c

示例4: buf

dnsparse::dnsparse (const u_char *buf, size_t len, bool answer)
  : buf (buf), eom (buf + len),
    anp (NULL), error (0),
    hdr (len > sizeof (HEADER) ? (HEADER *) buf : NULL),
    ancount (hdr ? ntohs (hdr->ancount) : 0),
    nscount (hdr ? ntohs (hdr->nscount) : 0),
    arcount (hdr ? ntohs (hdr->arcount) : 0)
{
  if (!hdr)
    error = ARERR_BADRESP;
  else if (hdr->rcode)
    error = hdr->rcode;
  else if ((!hdr->qr && answer) || (hdr->qr && !answer))
    error = ARERR_BADRESP;
  else if (!ntohs (hdr->qdcount))
    error = ARERR_BADRESP;
#if 0
  else if (hdr->tc)
    error = ARERR_BADRESP;
#endif
  else {
    const u_char *cp = getqp ();
    for (int i = 0, l = ntohs (hdr->qdcount); i < l; i++) {
      int n = dn_skipname (cp, eom);
      cp += n + 4;
      if (n < 0 || cp > eom) {
	error = ARERR_BADRESP;
	return;
      }
    }
    anp = cp;
  }
}
开发者ID:gildafnai82,项目名称:craq,代码行数:33,代码来源:dnsparse.C

示例5: skiprr

static int
skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count) {
	const u_char *optr = ptr;

	for ((void)NULL; count > 0; count--) {
		int b, rdlength;

		b = dn_skipname(ptr, eom);
		if (b < 0)
			goto emsgsize;
		ptr += b/*Name*/ + NS_INT16SZ/*Type*/ + NS_INT16SZ/*Class*/;
		if (section != ns_s_qd) {
			if (ptr + NS_INT32SZ > eom)
				goto emsgsize;
			ptr += NS_INT32SZ/*TTL*/;
			if (ptr + NS_INT16SZ > eom)
				goto emsgsize;
			NS_GET16(rdlength, ptr);
			ptr += rdlength/*RData*/;
		}
	}
	if (ptr > eom)
		goto emsgsize;
	return ((int)(ptr - optr));
 emsgsize:
	errno = EMSGSIZE;
	return (-1);
}
开发者ID:jeppeter,项目名称:vbox,代码行数:28,代码来源:ns_parse.c

示例6: req_iquery

/* Modified version of req_action */
static enum req_action
req_iquery(HEADER *hp, u_char **cpp, u_char *eom, int *buflenp, u_char *msg)
{
	int dlen, alen, n, type, class, count;
	char anbuf[512], *data, *fname;

	/*
	 * Skip domain name, get class, and type.
	 */
	if ((n = dn_skipname(*cpp, eom)) < 0) {
	  printf("FORMERR IQuery packet name problem\n");
	  hp->rcode = FORMERR;
	  return (Finish);
	}
	*cpp += n;
	GETSHORT(type, *cpp);
	GETSHORT(class, *cpp);
	*cpp += INT32SZ;	/* ttl */
	GETSHORT(dlen, *cpp);
	*cpp += dlen;
	if (*cpp != eom) {
	  printf("FORMERR IQuery message length off\n");
	  hp->rcode = FORMERR;
	  return (Finish);
	}

	/*
	 * not all inverse queries are handled.
	 * this is a meaningless switch statement to preserve original program's structure 
	 */

	switch (type) {
	case T_A:
	  if (something == 0) 
	    return (Refuse);
	  break;
	default:
	  return (Refuse);
	}
	printf("req: IQuery class %d type %d\n", class, type);

	fname = (char *)msg + HFIXEDSZ;
	alen = (char *)*cpp - fname;
	
	printf("Copying %d bytes from fname to anbuf which can store %d bytes\n", alen, sizeof(anbuf)); 
	/*BAD*/
	memcpy(anbuf, fname, alen);
	data = anbuf + alen - dlen;
	*cpp = (u_char *)fname;
	*buflenp -= HFIXEDSZ;
	count = 0;


	/* ..... do some other stuff */

	return (Finish);
}
开发者ID:bitblaze-fuzzball,项目名称:d-s-se-directed-tests,代码行数:58,代码来源:iquery-bad.c

示例7: dblchk

static int dblchk(str *domain, str *dbltxt)
{
	str dblstr;
	char *dbl = getenv("DBLLOOKUP");
	int l, i;
	unsigned char ansbuf[512];
	
	if(!dbl || domain->len == 0) return 0;
	if(session_getnum("sump",0)) return 0; /* no point */


	str_init(&dblstr);
	str_copy(&dblstr, domain);
	str_catc(&dblstr, '.');
	str_cats(&dblstr, dbl);
			
	l = res_query(dblstr.s, C_IN, T_TXT, ansbuf, sizeof(ansbuf));
	if(l > 0 && ((HEADER *)ansbuf)->ancount != 0) {  /* something in the answer */
		unsigned char *recbuf = ansbuf+NS_HFIXEDSZ;
		
		/* skip over questions, why am I still writing stuff
		 * like this? */
		for(i = ns_get16(ansbuf+4); i != 0; --i)
			recbuf += dn_skipname(recbuf, ansbuf+l)+4;

		for(i = ns_get16(ansbuf+6); i != 0; --i) {
			recbuf += dn_skipname(recbuf, ansbuf+l);

			if(ns_get16(recbuf) != T_TXT) { /* CNAME or something */
				recbuf += 10 + ns_get16(recbuf+8);
				continue;
			}
			/* it's a TXT record, wow */
			str_init(dbltxt);
			str_copyb(dbltxt, (char*)recbuf+11, recbuf[10]);
			str_free(&dblstr);
			return 1;
		}
	} /* didn't find anything */
	str_free(&dblstr);
	return 0;
	}
开发者ID:spamvictim,项目名称:mailfront-addons,代码行数:42,代码来源:plugin-chkdns.c

示例8: 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

示例9: ns_find_tsig

u_char *
ns_find_tsig(u_char *msg, u_char *eom) {
	HEADER *hp = (HEADER *)msg;
	int n, type;
	u_char *cp = msg, *start;
	isc_result_t status;

	if (msg == NULL || eom == NULL || msg > eom)
		return (NULL);

	if (cp + HFIXEDSZ >= eom)
		return (NULL);

	if (hp->arcount == 0)
		return (NULL);

	cp += HFIXEDSZ;

	status = ns_skiprr(cp, eom, ns_s_qd, ntohs(hp->qdcount), &n);
	if (status != ISC_R_SUCCESS)
		return (NULL);
	cp += n;

	status = ns_skiprr(cp, eom, ns_s_an, ntohs(hp->ancount), &n);
	if (status != ISC_R_SUCCESS)
		return (NULL);
	cp += n;

	status = ns_skiprr(cp, eom, ns_s_ns, ntohs(hp->nscount), &n);
	if (status != ISC_R_SUCCESS)
		return (NULL);
	cp += n;

	status = ns_skiprr(cp, eom, ns_s_ar, ntohs(hp->arcount) - 1, &n);
	if (status != ISC_R_SUCCESS)
		return (NULL);
	cp += n;

	start = cp;
	n = dn_skipname(cp, eom);
	if (n < 0)
		return (NULL);
	cp += n;
	if (cp + INT16SZ >= eom)
		return (NULL);

	GETSHORT(type, cp);
	if (type != ns_t_tsig)
		return (NULL);
	return (start);
}
开发者ID:inibir,项目名称:daemongroup,代码行数:51,代码来源:ns_verify.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: while

bool
dnsparse::skipnrecs (const u_char **cpp, u_int nrec)
{
  const u_char *cp = *cpp;
  while (nrec-- > 0) {
    int n = dn_skipname (cp, eom);
    cp += n;
    if (n < 0 || cp + 10 > eom)
      return false;
    cp += 8;
    u_int16_t rdlen;
    GETSHORT (rdlen, cp);
    if (rdlen > eom - cp)
      return false;
    cp += rdlen;
  }
  *cpp = cp;
  return true;
}
开发者ID:gildafnai82,项目名称:craq,代码行数:19,代码来源:dnsparse.C

示例12: 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

示例13: dns_ns_skiprr

static int
dns_ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count) {
	const u_char *optr = ptr;

	while (count-- > 0) {
		int b, rdlength;

		b = dn_skipname(ptr, eom);
		if (b < 0)
			RETERR(EMSGSIZE);
		ptr += b/*Name*/ + NS_INT16SZ/*Type*/ + NS_INT16SZ/*Class*/;
		if (section != ns_s_qd) {
			if (ptr + NS_INT32SZ + NS_INT16SZ > eom)
				RETERR(EMSGSIZE);
			ptr += NS_INT32SZ/*TTL*/;
			DNS_NS_GET16(rdlength, ptr);
			ptr += rdlength/*RData*/;
		}
	}
	if (ptr > eom)
		RETERR(EMSGSIZE);
	return (ptr - optr);
}
开发者ID:MichaelMcDonnell,项目名称:wine,代码行数:23,代码来源:ns_parse.c

示例14: dns_query


//.........这里部分代码省略.........
	_res.retry = retry;

	res = res_send(buf, res, answer.buffer, sizeof(answer.buffer));

	_res.retrans = saved_retrans;
	_res.retry = saved_retry;

	if ('\0' != *ip)
	{
		memcpy(&(_res.nsaddr_list[0]), &saved_ns, sizeof(struct sockaddr_in));
		_res.nscount = saved_nscount;
	}

	hp = (HEADER *)answer.buffer;

	if (1 == short_answer)
	{
		SET_UI64_RESULT(result, NOERROR != hp->rcode || 0 == ntohs(hp->ancount) || -1 == res ? 0 : 1);
		return SYSINFO_RET_OK;
	}

	if (NOERROR != hp->rcode || 0 == ntohs(hp->ancount) || -1 == res)
		return SYSINFO_RET_FAIL;

	msg_end = answer.buffer + res;

	num_answers = ntohs(answer.h.ancount);
	num_query = ntohs(answer.h.qdcount);

	msg_ptr = answer.buffer + HFIXEDSZ;

	/* skipping query records */
	for (; 0 < num_query && msg_ptr < msg_end; num_query--)
		msg_ptr += dn_skipname(msg_ptr, msg_end) + QFIXEDSZ;

	for (; 0 < num_answers && msg_ptr < msg_end; num_answers--)
	{
		if (NULL == (name = get_name(answer.buffer, msg_end, &msg_ptr)))
			return SYSINFO_RET_FAIL;

		offset += zbx_snprintf(buffer + offset, sizeof(buffer) - offset, "%-20s", name);

		GETSHORT(q_type, msg_ptr);
		GETSHORT(q_class, msg_ptr);
		msg_ptr += INT32SZ;		/* skipping TTL */
		GETSHORT(q_len, msg_ptr);
		offset += zbx_snprintf(buffer + offset, sizeof(buffer) - offset, " %-8s", decode_type(q_type));

		switch (q_type)
		{
			case T_A:
				switch (q_class)
				{
					case C_IN:
					case C_HS:
						memcpy(&inaddr, msg_ptr, INADDRSZ);
						offset += zbx_snprintf(buffer + offset, sizeof(buffer) - offset, " %s", inet_ntoa(inaddr));
						break;
					default:
						;
				}

				msg_ptr += q_len;

				break;
			case T_NS:
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:67,代码来源:net.c

示例15: getsrv

int
getsrv (const char *name,struct srventry **list)
{
  int srvcount=0;
  u16 count;
  int i, rc;

  *list = NULL;

#ifdef USE_ADNS
  {
    adns_state state;
    adns_answer *answer = NULL;
    
    rc = adns_init (&state, adns_if_noerrprint, NULL);
    if (rc)
      {
        log_error ("error initializing adns: %s\n", strerror (errno));
        return -1;
      }

    rc = adns_synchronous (state, name, adns_r_srv, adns_qf_quoteok_query,
                           &answer);
    if (rc)
      {
        log_error ("DNS query failed: %s\n", strerror (errno));
        adns_finish (state);
        return -1;
      }
    if (answer->status != adns_s_ok 
        || answer->type != adns_r_srv || !answer->nrrs)
      {
        /* log_error ("DNS query returned an error or no records: %s (%s)\n", */
        /*            adns_strerror (answer->status), */
        /*            adns_errabbrev (answer->status)); */
        adns_free (answer);
        adns_finish (state);
        return 0;
      }

    for (count = 0; count < answer->nrrs; count++)
      {
        struct srventry *srv = NULL;
        struct srventry *newlist;

        if (strlen (answer->rrs.srvha[count].ha.host) >= MAXDNAME)
          {
            log_info ("hostname in SRV record too long - skipped\n");
            continue;
          }
      
        newlist = xtryrealloc (*list, (srvcount+1)*sizeof(struct srventry));
        if (!newlist)
          goto fail;
        *list = newlist;
        memset (&(*list)[srvcount], 0, sizeof(struct srventry));
        srv = &(*list)[srvcount];
        srvcount++;
      
        srv->priority = answer->rrs.srvha[count].priority;
        srv->weight   = answer->rrs.srvha[count].weight;
        srv->port     = answer->rrs.srvha[count].port;
        strcpy (srv->target, answer->rrs.srvha[count].ha.host);
      }

    adns_free (answer);
    adns_finish (state);
  }
#else /*!USE_ADNS*/
  {
    unsigned char answer[2048];
    HEADER *header = (HEADER *)answer;
    unsigned char *pt, *emsg;
    int r;
    u16 dlen;
    
    r = res_query (name, C_IN, T_SRV, answer, sizeof answer);
    if (r < sizeof (HEADER) || r > sizeof answer)
      return -1;
    if (header->rcode != NOERROR || !(count=ntohs (header->ancount)))
      return 0; /* Error or no record found.  */
    
    emsg = &answer[r];
    pt = &answer[sizeof(HEADER)];
  
    /* Skip over the query */
    rc = dn_skipname (pt, emsg);
    if (rc == -1)
      goto fail;
  
    pt += rc + QFIXEDSZ;
  
    while (count-- > 0 && pt < emsg)
      {
        struct srventry *srv=NULL;
        u16 type,class;
        struct srventry *newlist;
      
        newlist = xtryrealloc (*list, (srvcount+1)*sizeof(struct srventry));
        if (!newlist)
//.........这里部分代码省略.........
开发者ID:GroovIM,项目名称:transport,代码行数:101,代码来源:srv.c


注:本文中的dn_skipname函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。