1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
4 for INTEL64(R), AMD64(R)
6 Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 OF THE POSSIBILITY OF SUCH DAMAGE.
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
31 /* File Info -----------------------------------------------------------
35 ----------------------------------------------------------------------*/
37 #include"drd64_libbrownie.h"
39 /* Drd64_Server_INetAddr_CmpInAddr */
42 Drd64_LibBrownie_INetAddr_CmpInAddr(
43 struct in_addr *p_dest,
44 struct in_addr *p_src )
47 return (( p_dest->s_addr == p_src->s_addr ) ? 0x00 : 0x01 );
51 /* Drd64_Server_INetAddr_CopyInAddr */
54 Drd64_LibBrownie_INetAddr_CopyInAddr(
55 struct in_addr *p_dest,
56 struct in_addr *p_src )
58 /* XXX : only FreeBSD */
59 memcpy( p_dest, p_src, sizeof( struct in_addr ) );
65 /* Drd64_LibDrd64_INet_SetInAddr */
68 Drd64_LibBrownie_INetAddr_SetInAddr_fromFQDN(
69 struct in_addr *p_addr,
72 struct hostent *p_hent;
74 if( NULL == p_addr ) { return 0xff; }
76 p_hent = gethostbyname( pstr_hostname );
77 if( NULL == p_hent ) {
81 if( NULL == p_hent->h_addr_list ) {
85 /* XXX : only FreeBSD */
86 memcpy( p_addr, *(p_hent->h_addr_list), p_hent->h_length );
92 /* Drd64_Server_INetAddr_SetInAddr_LocalHost */
95 Drd64_LibBrownie_INetAddr_SetInAddr_LocalHost(
96 struct in_addr *p_addr )
98 char str_hostname[ 256 ];
99 struct hostent *p_hent;
101 if( NULL == p_addr ) { return 0xff; }
103 if( 0 != gethostname( str_hostname, sizeof( str_hostname ) ))
106 p_hent = gethostbyname( str_hostname );
107 if( NULL == p_hent ) { return 0x02; }
109 if( NULL == p_hent->h_addr_list ) { return 0x03; }
111 /* XXX : only FreeBSD */
112 memcpy( p_addr, *(p_hent->h_addr_list), p_hent->h_length );
119 /* EOF of drd64_.c ----------------------------------- */