genericopenlibs/openenvcore/libc/src/net/getaddrinfo.c
changeset 72 403e7f6ed6c5
parent 71 28ccaba883f4
equal deleted inserted replaced
71:28ccaba883f4 72:403e7f6ed6c5
   406 	struct addrinfo ai;
   406 	struct addrinfo ai;
   407 	struct addrinfo ai0;
   407 	struct addrinfo ai0;
   408 	struct addrinfo *pai;
   408 	struct addrinfo *pai;
   409 	const struct explore *ex;
   409 	const struct explore *ex;
   410     int numeric = 0;
   410     int numeric = 0;
       
   411 	#ifdef __SYMBIAN32__
       
   412     int hints_specified = 0;
       
   413 	struct addrinfo hints_local;
       
   414 	#endif
   411 	memset(&sentinel, 0, sizeof(sentinel));
   415 	memset(&sentinel, 0, sizeof(sentinel));
   412 	cur = &sentinel;
   416 	cur = &sentinel;
   413 	pai = &ai;
   417 	pai = &ai;
   414 	pai->ai_flags = 0;
   418 	pai->ai_flags = 0;
   415 	pai->ai_family = PF_UNSPEC;
   419 	pai->ai_family = PF_UNSPEC;
   420 	pai->ai_addr = NULL;
   424 	pai->ai_addr = NULL;
   421 	pai->ai_next = NULL;
   425 	pai->ai_next = NULL;
   422 	if (hostname == NULL && servname == NULL)
   426 	if (hostname == NULL && servname == NULL)
   423 		return EAI_NONAME;
   427 		return EAI_NONAME;
   424 	if (hints) {
   428 	if (hints) {
       
   429 		#ifdef __SYMBIAN32__
       
   430         /* Real hint specified do not set hints to NULL */
       
   431         hints_specified = 1;
       
   432 		#endif
   425 		/* error check for hints */
   433 		/* error check for hints */
   426 		if (hints->ai_addrlen || hints->ai_canonname ||
   434 		if (hints->ai_addrlen || hints->ai_canonname ||
   427 		    hints->ai_addr || hints->ai_next)
   435 		    hints->ai_addr || hints->ai_next)
   428 			ERR(EAI_BADHINTS); /* xxx */
   436 			ERR(EAI_BADHINTS); /* xxx */
   429 		if (hints->ai_flags & ~AI_MASK)
   437 		if (hints->ai_flags & ~AI_MASK)
   457 					ERR(EAI_BADHINTS);
   465 					ERR(EAI_BADHINTS);
   458 				}
   466 				}
   459 			}
   467 			}
   460 		}
   468 		}
   461 	}
   469 	}
   462 
   470 	#ifdef __SYMBIAN32__
       
   471 	else {
       
   472 	/* No hints specified by caller, create local hint with
       
   473 	 * ai_family set to AF_UNSPEC, this is to handle NULL hint 
       
   474 	 * specification
       
   475 	 */
       
   476 	memset((void *)&hints_local,0,sizeof(struct addrinfo));
       
   477 	hints_local.ai_family = AF_UNSPEC;
       
   478 	hints = &hints_local;
       
   479 	}
       
   480 	#endif
   463 	/*
   481 	/*
   464 	 * post-2553: AI_ALL and AI_V4MAPPED are effective only against
   482 	 * post-2553: AI_ALL and AI_V4MAPPED are effective only against
   465 	 * AF_INET6 query.  They need to be ignored if specified in other
   483 	 * AF_INET6 query.  They need to be ignored if specified in other
   466 	 * occassions.
   484 	 * occassions.
   467 	 */
   485 	 */
   633 			 * If the returned entry is for an active connection,
   651 			 * If the returned entry is for an active connection,
   634 			 * and the given name is not numeric, reorder the
   652 			 * and the given name is not numeric, reorder the
   635 			 * list, so that the application would try the list
   653 			 * list, so that the application would try the list
   636 			 * in the most efficient order.
   654 			 * in the most efficient order.
   637 			 */
   655 			 */
       
   656             /* 
       
   657              * Since hints is not specified by caller, remove reference
       
   658              * to hints_local, this is used to handle NULL hint specification
       
   659              * Here doesnt matter as Symbian port doesnt provide reorder policy
       
   660              * May be useful for future implementation 
       
   661              */            
       
   662 			#ifdef __SYMBIAN32__ 
       
   663             if(!hints_specified)
       
   664                 hints = NULL;
       
   665 			#endif	
   638 			if (hints == NULL || !(hints->ai_flags & AI_PASSIVE)) {
   666 			if (hints == NULL || !(hints->ai_flags & AI_PASSIVE)) {
   639 				if (!numeric)
   667 				if (!numeric)
   640 					(void)reorder(&sentinel);
   668 					(void)reorder(&sentinel);
   641 			}
   669 			}
   642 			*res = sentinel.ai_next;
   670 			*res = sentinel.ai_next;