Changeset 9e18df8f5e7a26e298226c96fd422993f7010dda
- Timestamp:
- 12/06/09 16:23:50
(8 months ago)
- Author:
- Hans Petter Jansson <hpj@kzerza.site>
- git-committer:
- Hans Petter Jansson <hpj@kzerza.site> 1260134630 +0100
- git-parent:
[f2c541b2675acaf0bf3788dc3ee480980045a378]
- git-author:
- Hans Petter Jansson <hpj@cl.no> 1260134630 +0100
- Message:
Get fallback IP resolver code to compile.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r62b6c7b |
r9e18df8 |
|
| 194 | 194 | |
|---|
| 195 | 195 | static GList * |
|---|
| 196 | | flow_ip_resolver_impl_lookup_by_name (const gchar *name) |
|---|
| | 196 | flow_ip_resolver_impl_lookup_by_name (const gchar *name, GError **error) |
|---|
| 197 | 197 | { |
|---|
| 198 | 198 | static GStaticMutex mutex = G_STATIC_MUTEX_INIT; |
|---|
| … | … | |
| 209 | 209 | DEBUG (g_print ("Looked up '%s'\n", name)); |
|---|
| 210 | 210 | |
|---|
| 211 | | if (!he || !flow_addr_family_is_ipv4 (he->h_addrtype)) |
|---|
| | 211 | if (!he || flow_addr_family_from_af (he->h_addrtype) != FLOW_ADDR_FAMILY_IPV4) |
|---|
| 212 | 212 | { |
|---|
| 213 | 213 | g_static_mutex_unlock (&mutex); |
|---|
| 214 | 214 | DEBUG (g_print ("No IPv4 hostent!\n")); |
|---|
| | 215 | |
|---|
| | 216 | if (error) |
|---|
| | 217 | *error = h_errno_to_gerror (0); |
|---|
| | 218 | |
|---|
| 215 | 219 | return NULL; |
|---|
| 216 | 220 | } |
|---|
| … | … | |
| 245 | 249 | |
|---|
| 246 | 250 | static GList * |
|---|
| 247 | | flow_ip_resolver_impl_lookup_by_addr (FlowIPAddr *ip_addr) |
|---|
| | 251 | flow_ip_resolver_impl_lookup_by_addr (FlowIPAddr *ip_addr, GError **error) |
|---|
| 248 | 252 | { |
|---|
| 249 | 253 | static GStaticMutex mutex = G_STATIC_MUTEX_INIT; |
|---|
| 250 | 254 | GList *name_list = NULL; |
|---|
| 251 | 255 | struct hostent *he; |
|---|
| 252 | | struct sockaddr_in *sa; |
|---|
| | 256 | FlowSockaddr sa; |
|---|
| | 257 | gint rv; |
|---|
| 253 | 258 | |
|---|
| 254 | 259 | if (flow_ip_addr_get_family (ip_addr) != FLOW_IP_ADDR_IPV4) |
|---|
| 255 | 260 | { |
|---|
| 256 | 261 | DEBUG (g_print ("Supporting IPv4 only.\n")); |
|---|
| 257 | | return NULL; |
|---|
| 258 | | } |
|---|
| 259 | | |
|---|
| 260 | | sa = (struct sockaddr_in *) flow_ip_addr_get_sockaddr (ip_addr, 0); |
|---|
| 261 | | if (!sa) |
|---|
| | 262 | |
|---|
| | 263 | if (error) |
|---|
| | 264 | *error = h_errno_to_gerror (0); |
|---|
| | 265 | |
|---|
| | 266 | return NULL; |
|---|
| | 267 | } |
|---|
| | 268 | |
|---|
| | 269 | rv = flow_ip_addr_get_sockaddr (ip_addr, &sa, 0); |
|---|
| | 270 | if (rv != 0) |
|---|
| 262 | 271 | { |
|---|
| 263 | 272 | DEBUG (g_print ("No SA.\n")); |
|---|
| | 273 | |
|---|
| | 274 | if (error) |
|---|
| | 275 | *error = h_errno_to_gerror (rv); |
|---|
| | 276 | |
|---|
| 264 | 277 | return NULL; |
|---|
| 265 | 278 | } |
|---|
| … | … | |
| 267 | 280 | g_static_mutex_lock (&mutex); |
|---|
| 268 | 281 | |
|---|
| 269 | | he = gethostbyaddr (flow_sockaddr_get_addr ((struct sockaddr *) sa), |
|---|
| 270 | | flow_sockaddr_get_addr_len ((struct sockaddr *) sa), |
|---|
| 271 | | flow_sockaddr_get_family ((struct sockaddr *) sa)); |
|---|
| 272 | | |
|---|
| 273 | | g_free (sa); |
|---|
| | 282 | he = gethostbyaddr (flow_sockaddr_get_addr ((struct sockaddr *) &sa), |
|---|
| | 283 | flow_sockaddr_get_addr_len ((struct sockaddr *) &sa), |
|---|
| | 284 | flow_sockaddr_get_family ((struct sockaddr *) &sa)); |
|---|
| 274 | 285 | |
|---|
| 275 | 286 | if (he && he->h_name) |
|---|
| … | … | |
| 281 | 292 | DEBUG (g_print ("No he.\n")); |
|---|
| 282 | 293 | |
|---|
| 283 | | |
|---|
| | 294 | if (error) |
|---|
| | 295 | *error = h_errno_to_gerror (0); |
|---|
| 284 | 296 | } |
|---|
| 285 | 297 | |
|---|