- Timestamp:
- 05/27/09 08:08:10 (3 years ago)
- Location:
- Whitix/trunk/user/posix
- Files:
-
- 2 modified
-
include/netinet/in.h (modified) (2 diffs)
-
socket/socket.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/trunk/user/posix/include/netinet/in.h
r608 r2058 34 34 35 35 #define INADDR_LOOPBACK 0x7F000001 36 #define INADDR_ANY 0L 37 #define INADDR_BROADCAST 0xFFFFFFFF 36 38 37 39 struct ip_mreqn … … 44 46 typedef unsigned long in_addr_t; 45 47 48 extern unsigned short ntohs(unsigned short s); 49 extern unsigned short htons(unsigned short s); 50 extern unsigned long ntohl(unsigned long l); 51 extern unsigned long htonl(unsigned long l); 52 46 53 #endif -
Whitix/trunk/user/posix/socket/socket.c
r1825 r2058 99 99 } 100 100 101 /* NOTE: The following functions are for little-endian systems only */ 101 102 unsigned short ntohs(unsigned short s) 102 103 { 103 printf("ntohs\n"); 104 return 0; 104 return ((s & 0x00ff) << 8) | 105 ((s & 0xff00) >> 8); 106 105 107 } 106 108 107 short htons(short s)109 unsigned short htons(unsigned short s) 108 110 { 109 printf("htons\n"); 110 return 0; 111 return ntohs(s); 111 112 } 112 113 113 114 unsigned long ntohl(unsigned long l) 114 115 { 115 printf("ntohl\n"); 116 return 0; 116 return ((l & 0x000000ffU) << 24) | 117 ((l & 0x0000ff00U) << 8) | 118 ((l & 0x00ff0000U) >> 8) | 119 ((l & 0xff000000U) >> 24); 117 120 } 118 121 119 long htonl(long l)122 unsigned long htonl(unsigned long l) 120 123 { 121 printf("htonl\n"); 122 return 0; 124 return ntohl(l); 123 125 } 124 126
