Changeset 314
- Timestamp:
- Mar 11, 2011, 8:18:19 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_ipvx.c
r295 r314 61 61 ( c < 'a' || c > 'f' ) && 62 62 ( c < 'A' || c > 'F' ) && 63 ( c != ':') )63 ( c != ':') && ( c != '.')) 64 64 return (1 == 0); 65 65 } … … 132 132 name, name_size, NULL, 0, NI_NUMERICHOST); 133 133 134 if (ret != 0) 135 { 136 if (name_size > 7) { 137 name[0] = '0'; name[1] = '.'; name[2] = '0'; name[3] = '.'; 138 name[4] = '0'; name[5] = '.'; name[6] = '0'; name[7] = '\0'; 139 } else if (name_size > 0) { 140 name[0] = '\0'; 141 } 134 135 /* fprintf(stderr, "FIXME: Error %s (%d), name %s (%d)\n", 136 gai_strerror(ret), ret, name, name_size); */ 137 138 if (ret != 0 && name_size > 0) 139 { 140 name[name_size-1] = '\0'; 141 142 if (!sh_ipvx_is_numeric(name)) 143 { 144 if (name_size > 7) { 145 name[0] = '0'; name[1] = '.'; name[2] = '0'; name[3] = '.'; 146 name[4] = '0'; name[5] = '.'; name[6] = '0'; name[7] = '\0'; 147 } else { 148 name[0] = '\0'; 149 } 150 } 142 151 } 143 152 return ret; … … 158 167 } 159 168 169 char * sh_ipvx_print_sockaddr (struct sockaddr * sa, int sa_family) 170 { 171 struct sh_sockaddr ss; 172 static char ipbuf[SH_IP_BUF]; 173 174 sh_ipvx_save(&ss, sa_family, sa); 175 sh_ipvx_ntoa (ipbuf, sizeof(ipbuf), &ss); 176 return ipbuf; 177 } 178 160 179 void sh_ipvx_save(struct sh_sockaddr * ss, int sa_family, struct sockaddr * sa) 161 180 { … … 166 185 case AF_INET: 167 186 ss->ss_family = AF_INET; 168 memcpy(&(ss->sin), sa, sizeof(struct sockaddr_in));187 memcpy(&(ss->sin), (struct sockaddr_in*) sa, sizeof(struct sockaddr_in)); 169 188 break; 170 189 #if defined(USE_IPVX) 171 190 case AF_INET6: 172 191 ss->ss_family = AF_INET6; 173 memcpy(&(ss->sin6), sa, sizeof(struct sockaddr_in6));192 memcpy(&(ss->sin6), (struct sockaddr_in6*) sa, sizeof(struct sockaddr_in6)); 174 193 break; 175 194 #endif … … 198 217 return 0; 199 218 #endif 219 } 220 221 int sh_ipvx_get_port(struct sockaddr * sa, int sa_family) 222 { 223 int port = 0; 224 #if defined(USE_IPVX) 225 226 switch (sa_family) 227 { 228 case AF_INET: 229 port = ntohs(((struct sockaddr_in *)sa)->sin_port); 230 break; 231 case AF_INET6: 232 port = ntohs(((struct sockaddr_in6 *)sa)->sin6_port); 233 break; 234 } 235 #else 236 port = ntohs(((struct sockaddr_in *)sa).sin_port); 237 #endif 238 return port; 200 239 } 201 240
Note:
See TracChangeset
for help on using the changeset viewer.