亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? id.c

?? This a good VPN source
?? C
字號(hào):
/* identity representation, as in IKE ID Payloads (RFC 2407 DOI 4.6.2.1) * Copyright (C) 1999-2001  D. Hugh Redelmeier * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License * for more details. * * RCSID $Id: id.c,v 1.44 2004/06/17 07:27:16 mcr Exp $ */#include <stdlib.h>#include <string.h>#include <ctype.h>#include <errno.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <unistd.h>#ifndef HOST_NAME_MAX	/* POSIX 1003.1-2001 says <unistd.h> defines this */# define HOST_NAME_MAX	255 /* upper bound, according to SUSv2 */#endif#include <sys/queue.h>#include <openswan.h>#include <openswan/ipsec_policy.h>#include "constants.h"#include "defs.h"#include "id.h"#include "log.h"#include "x509.h"#include "pgp.h"#include "certs.h"#include "smartcard.h"#ifdef XAUTH_USEPAM#include <security/pam_appl.h>#endif#include "connections.h"	/* needs id.h */#include "packet.h"#include "whack.h"const struct id empty_id;	/* ID_NONE */enum myid_state myid_state = MYID_UNKNOWN;struct id myids[MYID_SPECIFIED+1];	/* %myid */char *myid_str[MYID_SPECIFIED+1];     /* string form of IDs *//* initialize id module * Fills in myid from environment variable IPSECmyid or defaultrouteaddr */voidinit_id(void){    passert(empty_id.kind == ID_NONE);    myid_state = MYID_UNKNOWN;    {	enum myid_state s;	for (s = MYID_UNKNOWN; s <= MYID_SPECIFIED; s++)	{	    myids[s] = empty_id;	    myid_str[s] = NULL;	}    }    set_myid(MYID_SPECIFIED, getenv("IPSECmyid"));    set_myid(MYID_IP, getenv("defaultrouteaddr"));    set_myFQDN();}static voidcalc_myid_str(enum myid_state s){    /* preformat the ID name */    char buf[IDTOA_BUF];    idtoa(&myids[s], buf, IDTOA_BUF);    replace(myid_str[s], clone_str(buf, "myid string"));}voidset_myid(enum myid_state s, char *idstr){    if (idstr != NULL)    {	struct id id;	err_t ugh = atoid(idstr, &id, FALSE);	if (ugh != NULL)	{	    loglog(RC_BADID, "myid malformed: %s \"%s\"", ugh, idstr);	}	else	{	    free_id_content(&myids[s]);	    unshare_id_content(&id);	    myids[s] = id;	    if (s == MYID_SPECIFIED)		myid_state = MYID_SPECIFIED;	    calc_myid_str(s);	}    }}voidset_myFQDN(void){    char FQDN[HOST_NAME_MAX + 1];    int r = gethostname(FQDN, sizeof(FQDN));    free_id_content(&myids[MYID_HOSTNAME]);    myids[MYID_HOSTNAME] = empty_id;    if (r != 0)    {	log_errno((e, "gethostname() failed in set_myFQDN"));    }    else    {	FQDN[sizeof(FQDN) - 1] = '\0';	/* insurance */	{	    size_t len = strlen(FQDN);	    if (len > 0 && FQDN[len-1] == '.')	    {		/* nuke trailing . */		FQDN[len-1]='\0';	    }	}	if (!strcaseeq(FQDN, "localhost.localdomain"))	{	    clonetochunk(myids[MYID_HOSTNAME].name, FQDN, strlen(FQDN), "my FQDN");	    myids[MYID_HOSTNAME].kind = ID_FQDN;	    calc_myid_str(MYID_HOSTNAME);	}    }}voidshow_myid_status(void){    char idstr[IDTOA_BUF];    (void)idtoa(&myids[myid_state], idstr, sizeof(idstr));    whack_log(RC_COMMENT, "%%myid = %s", idstr);}/*  Note that there may be as many as six IDs that are temporary at *  one time before unsharing the two ends of a connection. So we need *  at least six temporary buffers for DER_ASN1_DN IDs. *  We rotate them. Be careful! */#define	MAX_BUF		6char*temporary_cyclic_buffer(void){    static char buf[MAX_BUF][IDTOA_BUF];	/* MAX_BUF internal buffers */    static int counter = 0;			/* cyclic counter */    if (++counter == MAX_BUF) counter = 0;	/* next internal buffer */    return buf[counter];			/* assign temporary buffer */}/* Convert textual form of id into a (temporary) struct id. * Note that if the id is to be kept, unshare_id_content will be necessary. */err_tatoid(char *src, struct id *id, bool myid_ok){    err_t ugh = NULL;    *id = empty_id;    if (myid_ok && streq("%myid", src))    {	id->kind = ID_MYID;    }    else if (strchr(src, '=') != NULL)    {	/* we interpret this as an ASCII X.501 ID_DER_ASN1_DN */	id->kind = ID_DER_ASN1_DN;	id->name.ptr = temporary_cyclic_buffer(); /* assign temporary buffer */	id->name.len = 0;	/* convert from LDAP style or openssl x509 -subject style to ASN.1 DN	 * discard optional @ character in front of DN	 */	ugh = atodn((*src == '@')?src+1:src, &id->name);    }    else if (strchr(src, '@') == NULL)    {	if (streq(src, "%any") || streq(src, "0.0.0.0"))	{	    /* any ID will be accepted */	    id->kind = ID_NONE;	}	else	{	   /* !!! this test is not sufficient for distinguishing address families.	    * We need a notation to specify that a FQDN is to be resolved to IPv6.	    */	   const struct af_info *afi = strchr(src, ':') == NULL	? &af_inet4_info: &af_inet6_info;	   id->kind = afi->id_addr;	   ugh = ttoaddr(src, 0, afi->af, &id->ip_addr);	}    }    else    {	if (*src == '@')	{	    if (*(src+1) == '#')	    {		/* if there is a second specifier (#) on the line		 * we interprete this as ID_KEY_ID		 */		id->kind = ID_KEY_ID;		id->name.ptr = src;		/* discard @~, convert from hex to bin */		ugh = ttodata(src+2, 0, 16, id->name.ptr, strlen(src), &id->name.len);	    }	    else if (*(src+1) == '~')	    {		/* if there is a second specifier (~) on the line		* we interprete this as a binary ID_DER_ASN1_DN		*/		id->kind = ID_DER_ASN1_DN;		id->name.ptr = src;		/* discard @~, convert from hex to bin */		ugh = ttodata(src+2, 0, 16, id->name.ptr, strlen(src), &id->name.len);	    }	    else if (*(src+1) == '[')	    {		/* if there is a second specifier ([) on the line		 * we interprete this as a text ID_KEY_ID, and we remove		 * a trailing ", if there is one.		 */		int len = strlen(src+2);		id->kind = ID_KEY_ID;		id->name.ptr = src+2;		if(src[len+2]==']')		{		    src[len+2-1]='\0';		    len--;		}		id->name.len = len;	    }	    else	    {		id->kind = ID_FQDN;		id->name.ptr = src+1;	/* discard @ */		id->name.len = strlen(src)-1;	    }	}	else	{	    /* We leave in @, as per DOI 4.6.2.4	     * (but DNS wants . instead).	     */	    id->kind = ID_USER_FQDN;	    id->name.ptr = src;	    id->name.len = strlen(src);	}    }    return ugh;}/* *  Converts a binary key ID into hexadecimal format */static intkeyidtoa(char *dst, size_t dstlen, chunk_t keyid){    int n = datatot(keyid.ptr, keyid.len, 'x', dst, dstlen);    return ((n < (int)dstlen)? n : (int)dstlen) - 1;}voidiptoid(const ip_address *ip, struct id *id){    *id = empty_id;    switch (addrtypeof(ip))    {    case AF_INET:	id->kind = ID_IPV4_ADDR;	break;    case AF_INET6:	id->kind = ID_IPV6_ADDR;	break;    default:	bad_case(addrtypeof(ip));    }    id->ip_addr = *ip;}intidtoa(const struct id *id, char *dst, size_t dstlen){    int n;    id = resolve_myid(id);    switch (id->kind)    {    case ID_NONE:	n = snprintf(dst, dstlen, "(none)");	break;    case ID_IPV4_ADDR:    case ID_IPV6_ADDR:	n = (int)addrtot(&id->ip_addr, 0, dst, dstlen) - 1;	break;    case ID_FQDN:	n = snprintf(dst, dstlen, "@%.*s", (int)id->name.len, id->name.ptr);	break;    case ID_USER_FQDN:	n = snprintf(dst, dstlen, "%.*s", (int)id->name.len, id->name.ptr);	break;    case ID_DER_ASN1_DN:	n = dntoa(dst, dstlen, id->name);	break;    case ID_KEY_ID:	passert(dstlen > 4);	dst[0]='@';	dst[1]='#';	dstlen-=2; dst+=2;	n = keyidtoa(dst, dstlen, id->name);	n+= 2;	break;    default:	n = snprintf(dst, dstlen, "unknown id kind %d", id->kind);	break;    }    /* "Sanitize" string so that log isn't endangered:     * replace unprintable characters with '?'.     */    if (n > 0)    {	for ( ; *dst != '\0'; dst++)	    if (!isprint(*dst))		*dst = '?';    }    return n;}/* Replace the shell metacharacters ', \, ", `, and $ in a character string * by escape sequences consisting of their octal values */voidescape_metachar(const char *src, char *dst, size_t dstlen){    while (*src != '\0' && dstlen > 4)    {	switch (*src)	{	case '\'':	case '\\':	case '"':	case '`':	case '$':	    sprintf(dst,"\\%s%o", (*src < 64)?"0":"", *src);	    dst += 4;	    dstlen -= 4;	    break;	default:	    *dst++ = *src;	    dstlen--;	}	src++;    }    *dst = '\0';}/* Make private copy of string in struct id. * This is needed if the result of atoid is to be kept. */voidunshare_id_content(struct id *id){    switch (id->kind)    {    case ID_FQDN:    case ID_USER_FQDN:    case ID_DER_ASN1_DN:    case ID_KEY_ID:	id->name.ptr = clone_bytes(id->name.ptr, id->name.len, "keep id name");	break;    case ID_MYID:    case ID_NONE:    case ID_IPV4_ADDR:    case ID_IPV6_ADDR:	break;    default:	bad_case(id->kind);    }}voidfree_id_content(struct id *id){    switch (id->kind)    {    case ID_FQDN:    case ID_USER_FQDN:    case ID_DER_ASN1_DN:    case ID_KEY_ID:	freeanychunk(id->name);	break;    case ID_MYID:    case ID_NONE:    case ID_IPV4_ADDR:    case ID_IPV6_ADDR:	break;    default:	bad_case(id->kind);    }}/* compare two struct id values */boolsame_id(const struct id *a, const struct id *b){    a = resolve_myid(a);    b = resolve_myid(b);    if (a->kind != b->kind)	return FALSE;    switch (a->kind)    {    case ID_NONE:	return TRUE;	/* kind of vacuous */    case ID_IPV4_ADDR:    case ID_IPV6_ADDR:	return sameaddr(&a->ip_addr, &b->ip_addr);    case ID_FQDN:    case ID_USER_FQDN:	/* assumptions:	 * - case should be ignored	 * - trailing "." should be ignored (even if the only character?)	 */	{	    size_t al = a->name.len		, bl = b->name.len;	    while (al > 0 && a->name.ptr[al - 1] == '.')		al--;	    while (bl > 0 && b->name.ptr[bl - 1] == '.')		bl--;	    return al == bl		&& strncasecmp(a->name.ptr, b->name.ptr, al) == 0;	}    case ID_DER_ASN1_DN:	return same_dn(a->name, b->name);    case ID_KEY_ID:	return a->name.len == b->name.len	    && memcmp(a->name.ptr, b->name.ptr, a->name.len) == 0;    default:	bad_case(a->kind);    }}/* compare two struct id values, DNs can contain wildcards */boolmatch_id(const struct id *a, const struct id *b, int *wildcards){        char abuf[IDTOA_BUF];    char bbuf[IDTOA_BUF];    DBG(DBG_CONTROLMORE,	idtoa(a, abuf, IDTOA_BUF);	idtoa(b, bbuf, IDTOA_BUF);	DBG_log("   match_id a=%s b=%s", abuf, bbuf);	);        if (b->kind == ID_NONE)    {	*wildcards = MAX_WILDCARDS;	return TRUE;    }    DBG(DBG_CONTROLMORE	, DBG_log("  match_id called with a=%s b=%s"		  , abuf, bbuf));    if (a->kind != b->kind)	return FALSE;    if (a->kind == ID_DER_ASN1_DN)	return match_dn(a->name, b->name, wildcards);    else    {	*wildcards = 0;	return same_id(a, b);    }}/* count the numer of wildcards in an id */intid_count_wildcards(const struct id *id){    int count;    char idbuf[IDTOA_BUF];    count = 0;    switch (id->kind)    {    case ID_NONE:	count = MAX_WILDCARDS;	break;    case ID_DER_ASN1_DN:	count = dn_count_wildcards(id->name);	break;    default:	count = 0;	break;    }	    idtoa(id, idbuf, IDTOA_BUF);    DBG(DBG_CONTROL,	DBG_log("counting wild cards for %s is %d"		, idbuf		, count));        return count;}/* build an ID payload * Note: no memory is allocated for the body of the payload (tl->ptr). * We assume it will end up being a pointer into a sufficiently * stable datastructure.  It only needs to last a short time. */voidbuild_id_payload(struct isakmp_ipsec_id *hd, chunk_t *tl, struct end *end){    const struct id *id = resolve_myid(&end->id);    zero(hd);    hd->isaiid_idtype = id->kind;    switch (id->kind)    {    case ID_NONE:	hd->isaiid_idtype = aftoinfo(addrtypeof(&end->host_addr))->id_addr;	tl->len = addrbytesptr(&end->host_addr	    , (const unsigned char **)&tl->ptr);	/* sets tl->ptr too */	break;    case ID_FQDN:    case ID_USER_FQDN:    case ID_DER_ASN1_DN:    case ID_KEY_ID:	*tl = id->name;	break;    case ID_IPV4_ADDR:    case ID_IPV6_ADDR:	tl->len = addrbytesptr(&id->ip_addr	    , (const unsigned char **)&tl->ptr);	/* sets tl->ptr too */	break;    default:	bad_case(id->kind);    }}/* * Local Variables: * c-basic-offset:4 * c-style: pluto * End: */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲影视在线观看| 麻豆精品视频在线| 日韩一区二区三区三四区视频在线观看| 九色综合狠狠综合久久| 亚洲人成在线观看一区二区| 欧美成人精精品一区二区频| 欧美系列在线观看| 成人免费毛片高清视频| 精品中文字幕一区二区| 亚洲成在线观看| 国产精品久久久久国产精品日日| 日韩一区和二区| 欧美丝袜丝交足nylons图片| 国产91精品入口| 日韩一区二区视频在线观看| 色综合久久久网| 国产suv一区二区三区88区| 人禽交欧美网站| 亚洲六月丁香色婷婷综合久久 | 日韩片之四级片| 色婷婷综合视频在线观看| 丁香六月综合激情| 国产福利一区二区三区视频在线| 日本v片在线高清不卡在线观看| 一区二区三区国产| 亚洲色欲色欲www在线观看| 亚洲国产精品t66y| 日本一区二区三区电影| 久久女同性恋中文字幕| 久久亚洲综合av| 日韩欧美国产wwwww| 欧美一区二区视频在线观看 | 欧美日韩小视频| 欧美亚洲国产怡红院影院| 色天使色偷偷av一区二区| 色综合久久六月婷婷中文字幕| av在线播放成人| www.视频一区| 91色在线porny| 91福利视频在线| 欧洲国内综合视频| 欧美天堂一区二区三区| 欧美色视频在线观看| 欧美丝袜丝交足nylons| 欧美美女直播网站| 欧美一区二区视频免费观看| 欧美一级生活片| 欧美电视剧免费观看| 精品国产免费人成电影在线观看四季| 精品精品国产高清一毛片一天堂| 久久综合九色综合97婷婷| 久久久.com| 亚洲色图欧美激情| 亚洲图片欧美色图| 亚洲国产精品成人综合| 亚洲欧洲日产国码二区| 亚洲精品菠萝久久久久久久| 一区二区三区免费| 日韩黄色在线观看| 国产在线一区二区| 不卡的av中国片| 欧美午夜精品电影| 欧美一级理论性理论a| 欧美sm美女调教| 国产精品人人做人人爽人人添| 亚洲色图清纯唯美| 免费在线看成人av| 国产成人在线视频网址| 92国产精品观看| 欧美日韩不卡在线| 精品日韩在线观看| 国产精品国产精品国产专区不蜜 | 狠狠色丁香婷综合久久| 丁香另类激情小说| 欧美日韩中文字幕精品| 日韩欧美的一区二区| 精品国产伦一区二区三区免费| 亚洲国产精品黑人久久久| 香蕉成人伊视频在线观看| 国产一区欧美日韩| 色噜噜久久综合| 久久综合久久综合亚洲| 一区二区三区四区视频精品免费| 免费高清视频精品| 91免费视频网址| 欧美成人欧美edvon| 一个色在线综合| 国产一区二区三区最好精华液| 91在线精品一区二区| 欧美成人高清电影在线| 亚洲色图欧美偷拍| 国产一区二区三区免费| 欧美日韩一区二区在线观看| 国产拍欧美日韩视频二区| 亚洲大片免费看| 99re这里只有精品视频首页| 欧美一卡二卡在线观看| 17c精品麻豆一区二区免费| 久久国产福利国产秒拍| 日本高清免费不卡视频| 国产亚洲精久久久久久| 日韩电影免费在线看| 色婷婷综合久久久中文字幕| 欧美国产1区2区| 九九九久久久精品| 欧美日韩欧美一区二区| 欧美激情一区在线观看| 久久精品国产亚洲aⅴ| 欧美系列在线观看| 亚洲人快播电影网| jlzzjlzz亚洲女人18| 欧美xxx久久| 日本欧美在线观看| 欧美三日本三级三级在线播放| 亚洲欧美在线观看| 国产成人免费视频网站 | 欧美大白屁股肥臀xxxxxx| 亚洲第四色夜色| 欧美性猛交xxxx黑人交| 中文字幕一区在线观看| 国产成人午夜视频| 久久久欧美精品sm网站| 久久99最新地址| 日韩精品中文字幕一区| 美女任你摸久久| 91精品国产黑色紧身裤美女| 亚洲一二三专区| 欧美系列日韩一区| 亚洲综合色网站| 在线观看一区不卡| 亚洲成人自拍网| 欧美日本一道本在线视频| 亚洲国产视频a| 欧美日韩电影在线| 五月天激情综合| 欧美高清视频一二三区| 日韩精彩视频在线观看| 欧美一区二区三区在线视频| 琪琪久久久久日韩精品| 日韩午夜精品视频| 黄色日韩三级电影| 欧美极品xxx| 91麻豆视频网站| 午夜视频在线观看一区| 91精品中文字幕一区二区三区| 日本一不卡视频| 精品黑人一区二区三区久久| 国产成人aaa| 一色桃子久久精品亚洲| 91麻豆视频网站| 日欧美一区二区| 久久影院午夜论| k8久久久一区二区三区| 亚洲综合男人的天堂| 欧美喷潮久久久xxxxx| 免费观看日韩电影| 国产欧美精品一区二区色综合| zzijzzij亚洲日本少妇熟睡| 一区二区在线观看免费视频播放| 欧美亚洲日本一区| 激情小说亚洲一区| 中文字幕一区二区三区色视频| 色婷婷久久综合| 免费成人在线视频观看| 国产欧美视频在线观看| 欧美在线观看18| 麻豆精品久久精品色综合| 日本一区二区三区视频视频| 91在线视频播放| 欧美aaa在线| 国产精品毛片无遮挡高清| 在线观看av不卡| 国产精品一区免费视频| 亚洲精品成人天堂一二三| 91精品欧美综合在线观看最新| 国产乱人伦精品一区二区在线观看 | 国产欧美日韩在线视频| 欧美性猛片xxxx免费看久爱| 国产综合一区二区| 亚洲一区二区三区小说| 久久免费美女视频| 欧美少妇bbb| 国产成人夜色高潮福利影视| 亚洲国产精品久久久久秋霞影院| 久久一区二区三区四区| 日本福利一区二区| 久久se精品一区精品二区| 亚洲欧美日韩国产一区二区三区 | 欧美日韩中文国产| 国产成人精品一区二区三区网站观看| 夜夜嗨av一区二区三区四季av| 日韩一区二区免费在线电影| 97国产一区二区| 国产精品伊人色| 日本强好片久久久久久aaa| 日韩理论电影院| 国产丝袜欧美中文另类| 日韩欧美精品在线视频| 在线观看亚洲a| av成人老司机|