Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/net/getaddrinfo.c
Show All 29 Lines | |||||
*/ | */ | ||||
/* | /* | ||||
* Issues to be discussed: | * Issues to be discussed: | ||||
* - Return values. There are nonstandard return values defined and used | * - Return values. There are nonstandard return values defined and used | ||||
* in the source code. This is because RFC2553 is silent about which error | * in the source code. This is because RFC2553 is silent about which error | ||||
* code must be returned for which situation. | * code must be returned for which situation. | ||||
* - freeaddrinfo(NULL). RFC2553 is silent about it. XNET 5.2 says it is | * - freeaddrinfo(NULL). RFC2553 is silent about it. XNET 5.2 says it is | ||||
* invalid. current code - SEGV on freeaddrinfo(NULL) | * invalid. Current code accepts NULL to be compatible with other OSes. | ||||
hselasky: s/current/Current/ | |||||
* | * | ||||
* Note: | * Note: | ||||
* - The code filters out AFs that are not supported by the kernel, | * - The code filters out AFs that are not supported by the kernel, | ||||
* when globbing NULL hostname (to loopback, or wildcard). Is it the right | * when globbing NULL hostname (to loopback, or wildcard). Is it the right | ||||
* thing to do? What is the relationship with post-RFC2553 AI_ADDRCONFIG | * thing to do? What is the relationship with post-RFC2553 AI_ADDRCONFIG | ||||
* in ai_flags? | * in ai_flags? | ||||
* - (post-2553) semantics of AI_ADDRCONFIG itself is too vague. | * - (post-2553) semantics of AI_ADDRCONFIG itself is too vague. | ||||
* (1) what should we do against numeric hostname (2) what should we do | * (1) what should we do against numeric hostname (2) what should we do | ||||
▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | |||||
#define MATCH(x, y, w) \ | #define MATCH(x, y, w) \ | ||||
((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY))) | ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY))) | ||||
void | void | ||||
freeaddrinfo(struct addrinfo *ai) | freeaddrinfo(struct addrinfo *ai) | ||||
{ | { | ||||
struct addrinfo *next; | struct addrinfo *next; | ||||
do { | while (ai != NULL) { | ||||
next = ai->ai_next; | next = ai->ai_next; | ||||
if (ai->ai_canonname) | |||||
free(ai->ai_canonname); | free(ai->ai_canonname); | ||||
/* no need to free(ai->ai_addr) */ | /* no need to free(ai->ai_addr) */ | ||||
free(ai); | free(ai); | ||||
ai = next; | ai = next; | ||||
} while (ai); | } | ||||
} | } | ||||
static int | static int | ||||
str2number(const char *p, int *portp) | str2number(const char *p, int *portp) | ||||
{ | { | ||||
char *ep; | char *ep; | ||||
unsigned long v; | unsigned long v; | ||||
▲ Show 20 Lines • Show All 2,656 Lines • Show Last 20 Lines |
s/current/Current/