tcb may be NULL */
| 3294 | |
| 3295 | /* tcb may be NULL */ |
| 3296 | struct sctp_ifa * |
| 3297 | sctp_source_address_selection(struct sctp_inpcb *inp, |
| 3298 | struct sctp_tcb *stcb, |
| 3299 | sctp_route_t *ro, |
| 3300 | struct sctp_nets *net, |
| 3301 | int non_asoc_addr_ok, uint32_t vrf_id) |
| 3302 | { |
| 3303 | struct sctp_ifa *answer; |
| 3304 | uint8_t dest_is_priv, dest_is_loop; |
| 3305 | sa_family_t fam; |
| 3306 | #ifdef INET |
| 3307 | struct sockaddr_in *to = (struct sockaddr_in *)&ro->ro_dst; |
| 3308 | #endif |
| 3309 | #ifdef INET6 |
| 3310 | struct sockaddr_in6 *to6 = (struct sockaddr_in6 *)&ro->ro_dst; |
| 3311 | #endif |
| 3312 | |
| 3313 | /** |
| 3314 | * Rules: |
| 3315 | * - Find the route if needed, cache if I can. |
| 3316 | * - Look at interface address in route, Is it in the bound list. If so we |
| 3317 | * have the best source. |
| 3318 | * - If not we must rotate amongst the addresses. |
| 3319 | * |
| 3320 | * Cavets and issues |
| 3321 | * |
| 3322 | * Do we need to pay attention to scope. We can have a private address |
| 3323 | * or a global address we are sourcing or sending to. So if we draw |
| 3324 | * it out |
| 3325 | * zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 3326 | * For V4 |
| 3327 | * ------------------------------------------ |
| 3328 | * source * dest * result |
| 3329 | * ----------------------------------------- |
| 3330 | * <a> Private * Global * NAT |
| 3331 | * ----------------------------------------- |
| 3332 | * <b> Private * Private * No problem |
| 3333 | * ----------------------------------------- |
| 3334 | * <c> Global * Private * Huh, How will this work? |
| 3335 | * ----------------------------------------- |
| 3336 | * <d> Global * Global * No Problem |
| 3337 | *------------------------------------------ |
| 3338 | * zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 3339 | * For V6 |
| 3340 | *------------------------------------------ |
| 3341 | * source * dest * result |
| 3342 | * ----------------------------------------- |
| 3343 | * <a> Linklocal * Global * |
| 3344 | * ----------------------------------------- |
| 3345 | * <b> Linklocal * Linklocal * No problem |
| 3346 | * ----------------------------------------- |
| 3347 | * <c> Global * Linklocal * Huh, How will this work? |
| 3348 | * ----------------------------------------- |
| 3349 | * <d> Global * Global * No Problem |
| 3350 | *------------------------------------------ |
| 3351 | * zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz |
| 3352 | * |
| 3353 | * And then we add to that what happens if there are multiple addresses |
no test coverage detected