| | 266 | } |
|---|
| | 267 | |
|---|
| | 268 | static void |
|---|
| | 269 | validate_two_ip_services (FlowIPProcessor *ip_processor, FlowIPService *ip_service_a, FlowIPService *ip_service_b) |
|---|
| | 270 | { |
|---|
| | 271 | FlowIPProcessorPrivate *priv = ip_processor->priv; |
|---|
| | 272 | gboolean new_valid_state = FALSE; |
|---|
| | 273 | |
|---|
| | 274 | /* If one of the IP services is bad, the whole thing goes down the drain */ |
|---|
| | 275 | new_valid_state = ip_service_is_valid (ip_processor, ip_service_a); |
|---|
| | 276 | if (new_valid_state) |
|---|
| | 277 | new_valid_state = ip_service_is_valid (ip_processor, ip_service_b); |
|---|
| | 278 | |
|---|
| | 279 | if (priv->valid_state != new_valid_state) |
|---|
| | 280 | { |
|---|
| | 281 | /* Must use property setter, so property change listeners get called */ |
|---|
| | 282 | flow_ip_processor_set_valid_state (ip_processor, new_valid_state); |
|---|
| | 283 | } |
|---|
| | 284 | } |
|---|
| | 285 | |
|---|
| | 286 | static gboolean |
|---|
| | 287 | start_lookup_ip_service (FlowIPProcessor *ip_processor, FlowIPService *ip_service, FlowPacket *packet) |
|---|
| | 288 | { |
|---|
| | 289 | FlowIPProcessorPrivate *priv = ip_processor->priv; |
|---|
| | 290 | |
|---|
| | 291 | g_assert (priv->current_packet == NULL); |
|---|
| | 292 | |
|---|
| | 293 | if (((priv->resolve_to_addrs && flow_ip_service_get_n_addresses (ip_service) == 0) || |
|---|
| | 294 | (priv->resolve_to_names && !flow_ip_service_have_name (ip_service)))) |
|---|
| | 295 | { |
|---|
| | 296 | /* Need to do a lookup */ |
|---|
| | 297 | priv->current_packet = packet; |
|---|
| | 298 | |
|---|
| | 299 | g_signal_connect_swapped (ip_service, "resolved", (GCallback) current_ip_resolved, ip_processor); |
|---|
| | 300 | flow_ip_service_resolve (ip_service); |
|---|
| | 301 | return TRUE; |
|---|
| | 302 | } |
|---|
| | 303 | |
|---|
| | 304 | return FALSE; |
|---|
| | 305 | } |
|---|
| | 306 | |
|---|
| | 307 | static FlowIPService * |
|---|
| | 308 | get_udp_connect_op_local_service_if_applicable (FlowUdpConnectOp *udp_connect_op) |
|---|
| | 309 | { |
|---|
| | 310 | FlowIPService *ip_service; |
|---|
| | 311 | |
|---|
| | 312 | ip_service = flow_udp_connect_op_get_local_service (udp_connect_op); |
|---|
| | 313 | |
|---|
| | 314 | if (ip_service && |
|---|
| | 315 | !flow_ip_service_get_n_addresses (ip_service) && |
|---|
| | 316 | !flow_ip_service_have_name (ip_service)) |
|---|
| | 317 | { |
|---|
| | 318 | /* A port-only local bind address is always valid */ |
|---|
| | 319 | ip_service = NULL; |
|---|
| | 320 | } |
|---|
| | 321 | |
|---|
| | 322 | return ip_service; |
|---|
| 271 | | validate_ip_service (ip_processor, ip_service); |
|---|
| | 342 | packet_data = flow_packet_get_data (packet); |
|---|
| | 343 | |
|---|
| | 344 | if (FLOW_IS_UDP_CONNECT_OP (packet_data)) |
|---|
| | 345 | { |
|---|
| | 346 | FlowIPService *udp_remote_service = flow_udp_connect_op_get_remote_service (packet_data); |
|---|
| | 347 | FlowIPService *udp_local_service = get_udp_connect_op_local_service_if_applicable (packet_data); |
|---|
| | 348 | |
|---|
| | 349 | /* If necessary, start second step of UDP remote/local service lookup */ |
|---|
| | 350 | if (udp_local_service && ip_service != udp_local_service && |
|---|
| | 351 | start_lookup_ip_service (ip_processor, udp_local_service, packet)) |
|---|
| | 352 | return; |
|---|
| | 353 | |
|---|
| | 354 | validate_two_ip_services (ip_processor, udp_remote_service, udp_local_service); |
|---|
| | 355 | } |
|---|
| | 356 | else |
|---|
| | 357 | { |
|---|
| | 358 | validate_ip_service (ip_processor, ip_service); |
|---|
| | 359 | } |
|---|
| 322 | | if (((priv->resolve_to_addrs && flow_ip_service_get_n_addresses (ip_service) == 0) || |
|---|
| 323 | | (priv->resolve_to_names && !flow_ip_service_have_name (ip_service)))) |
|---|
| 324 | | { |
|---|
| 325 | | /* Need to do a lookup */ |
|---|
| 326 | | priv->current_packet = packet; |
|---|
| 327 | | |
|---|
| 328 | | g_signal_connect_swapped (ip_service, "resolved", (GCallback) current_ip_resolved, ip_processor); |
|---|
| 329 | | flow_ip_service_resolve (ip_service); |
|---|
| | 417 | if (start_lookup_ip_service (ip_processor, ip_service, packet)) |
|---|