socket: support binding to interface *AND* IP

Introduce new notation for CURLOPT_INTERFACE / --interface:
ifhost!<interface>!<host>

Binding to an interface doesn't set the address, and an interface can
have multiple addresses.

When binding to an address (without interface), the kernel is free to
choose the route, and it can route through any device that can access
the target address, not necessarily the one with the chosen address.

Moreover, it is possible for different interfaces to have the same IP
address, on which case we need to provide a way to be more specific.

Factor out the parsing part of interface option, and add unit tests:
1663.

Closes #13719
This commit is contained in:
Orgad Shaneh 2024-05-17 14:44:44 +03:00 committed by Daniel Stenberg
parent 23fe1a52dc
commit 3060557af7
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
10 changed files with 322 additions and 79 deletions

View file

@ -211,7 +211,7 @@ test1620 test1621 \
test1630 test1631 test1632 test1633 test1634 test1635 \
\
test1650 test1651 test1652 test1653 test1654 test1655 \
test1660 test1661 test1662 \
test1660 test1661 test1662 test1663 \
\
test1670 test1671 \
\

23
tests/data/test1663 Normal file
View file

@ -0,0 +1,23 @@
<testcase>
<info>
<keywords>
unittest
interface
bind
</keywords>
</info>
#
# Client-side
<client>
<server>
none
</server>
<features>
unittest
</features>
<name>
unit tests for interface option parsing
</name>
</client>
</testcase>