-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic IPv6 support for Jamulus #1455
Conversation
ipv6 support
socket.cpp ipv6 support for Linux/Windows/Mac socket.h extension for Windows Pointers to WSASendMsg and WSARecvMsg
added autosensing, if there is no ipv6 stack available in OS, fall back to ipv4 communication works with mac os, windows and linux
See also #1017 |
and removed one fprintf debug message
for compatibility with elder mac
It is essential for the choir i am singing in and for friends to have ipv6 support working, because in our regions (near Frankfurt and Cologne) many people use internet providers which don't have native ipv4 support, but have "Dual stack lite" with ipv6 native and ipv4 only over a central NAT instance, which leads to problems with ipv4. I have to keep backward compatiblity for jamulus and not disturb the registration on central server, therefore i decided to introduce a new option "ipmode", which defaults to ipv4 first and ipv6, if there is no ipv4 address for the server. For backward compatiblity, the connection to the central registration server is done by ipv4 only and transparent. I think, we should discuss, whether a registration for ipv6 on central server should be supported. My idea would be, to register the server twice, one time for ipv4 (as usual) and a second time with a Server name Postfix of "_v6" for ipv6. I patched ParseNetworkAddress(), so that it supports the additional parameter of "ipmode" with default to "0", so that old sources with ipv4 only are supported. I replaced sendto() and recvfrom() with sendmsg() and recvmsg(), added some setsockopts() at the start of a socket(), so that i can read the local ip address, which the client connected to, on the server, to choose the right ip address for the answer - i think, this is useful for ipv4 only, too. Therefore I added a field "LocalAddress" to Hostaddr. In addition, this code could be easily extended for supporting setting TOS/DSCP bits in the messages sent, which sometimes could be good (most times these flags are resetted by the ISP). I used "ipv4 mapped ipv6". In case, if there is no support for v6 in the kernel, the code falls back to its origin code of recvfrom and sendto with native v4 code. There is another implementation for ipv6 support in #1017, but this is my own one and works for me. It works on Windows, Mac and Linux. |
For the command line parameters, I would prefer a solution that is not dependent on the order |
Agreed. If I've understood what's being said above, something like this?
|
@@ -0,0 +1,607 @@ | |||
/******************************************************************************\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why has this file been added outside src
?
@@ -31,7 +31,8 @@ CClient::CClient ( const quint16 iPortNumber, | |||
const QString& strMIDISetup, | |||
const bool bNoAutoJackConnect, | |||
const QString& strNClientName, | |||
const bool bNMuteMeInPersonalMix ) : | |||
const bool bNMuteMeInPersonalMix, | |||
int ipmode ) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use spaces, be consistent with the existing source.
@@ -62,6 +63,7 @@ CClient::CClient ( const quint16 iPortNumber, | |||
bEnableOPUS64 ( false ), | |||
bJitterBufferOK ( true ), | |||
bNuteMeInPersonalMix ( bNMuteMeInPersonalMix ), | |||
iipmode ( ipmode ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above - spaces not tabs, please.
@@ -389,7 +391,8 @@ bool CClient::SetServerAddr ( QString strNAddr ) | |||
{ | |||
CHostAddress HostAddress; | |||
if ( NetworkUtil().ParseNetworkAddress ( strNAddr, | |||
HostAddress ) ) | |||
HostAddress, | |||
iipmode ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
@@ -113,7 +113,8 @@ class CClient : public QObject | |||
const QString& strMIDISetup, | |||
const bool bNoAutoJackConnect, | |||
const QString& strNClientName, | |||
const bool bNMuteMeInPersonalMix ); | |||
const bool bNMuteMeInPersonalMix, | |||
int ipmode=0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
@@ -355,6 +356,7 @@ class CClient : public QObject | |||
|
|||
bool bJitterBufferOK; | |||
bool bNuteMeInPersonalMix; | |||
int iipmode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
@@ -88,6 +88,7 @@ int main ( int argc, char** argv ) | |||
QString strServerListFilter = ""; | |||
QString strWelcomeMessage = ""; | |||
QString strClientName = ""; | |||
int ipmode = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
@@ -140,6 +141,41 @@ int main ( int argc, char** argv ) | |||
continue; | |||
} | |||
|
|||
// Use ipv4 protocol | |||
if ( GetFlagArgument ( argv, | |||
i, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
@@ -846,6 +883,8 @@ QString UsageArguments ( char **argv ) | |||
" -p, --port set your local port number\n" | |||
" -t, --notranslation disable translation (use English language)\n" | |||
" -v, --version output version information and exit\n" | |||
" -4, --ipv4 use IPv4 Protocol\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
@@ -1097,7 +1102,9 @@ class NetworkUtil | |||
{ | |||
public: | |||
static bool ParseNetworkAddress ( QString strAddress, | |||
CHostAddress& HostAddress ); | |||
CHostAddress& HostAddress, | |||
int inetmode=0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow standard alignment of code.
|
||
CHostAddress ( const CHostAddress& NHAddr ) : | ||
InetAddr ( NHAddr.InetAddr ), | ||
iPort ( NHAddr.iPort ) {} | ||
iPort ( NHAddr.iPort ), | ||
LocalAddr ( static_cast<quint32> ( 0 )) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow standard alignment of code - even where that means adjusting existing code.
@@ -768,16 +768,19 @@ class CHostAddress | |||
|
|||
CHostAddress() : | |||
InetAddr ( static_cast<quint32> ( 0 ) ), | |||
iPort ( 0 ) {} | |||
iPort ( 0 ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs reformatting so all the initialisers align.
this is a mistake and happened by copying. I will delete it.
…-----Original-Nachricht-----
Betreff: Re: [jamulussoftware/jamulus] Basic IPv6 support for Jamulus
(#1455)
Datum: 2021-04-10T14:44:41+0200
Von: "Peter L Jones" ***@***.***>
An: "jamulussoftware/jamulus" ***@***.***>
For the command line parameters, I would prefer a solution that is not
dependent on the order
Agreed.
"-46" = default, IPv4 first, IPv4 over IPv6 if there's no native IPV4 "-64" = IPv6 first, IPv4 if there is no IPv6 "-4" = IPv4 only "-6" = IPv6 only
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1455 (comment)>
, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATKQY5CKO26W6EXFYBWROTDTIBB3PANCNFSM42PHKWIA>
.
[ { ***@***.***": "http://schema.org", ***@***.***": "EmailMessage",
"potentialAction": { ***@***.***": "ViewAction", "target":
"#1455 (comment)",
"url":
"#1455 (comment)",
"name": "View Pull Request" }, "description": "View this Pull Request on
GitHub", "publisher": { ***@***.***": "Organization", "name": "GitHub", "url":
"https://github.com" } } ]
|
this was a mistake and happened during copying. I wil remove it.
-----Original-Nachricht-----
Betreff: Re: [jamulussoftware/jamulus] Basic IPv6 support for Jamulus
(#1455)
Datum: 2021-04-10T14:46:49+0200
Von: "Peter L Jones" ***@***.***>
An: "jamulussoftware/jamulus" ***@***.***>
@pljones commented on this pull request.
------------------------------------------------------------------------
In socket.cpp
<#1455 (comment)>
:
@@ -0,0 +1,607 @@ +/******************************************************************************\
Why has this file been added outside src?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1455 (review)>
, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATKQY5HHXET44PDMQFGPTM3TIBCC7ANCNFSM42PHKWIA>
.
[ { ***@***.***": "http://schema.org", ***@***.***": "EmailMessage",
"potentialAction": { ***@***.***": "ViewAction", "target":
"#1455 (review)",
"url":
"#1455 (review)",
"name": "View Pull Request" }, "description": "View this Pull Request on
GitHub", "publisher": { ***@***.***": "Organization", "name": "GitHub", "url":
"https://github.com" } } ]
|
I agree, that this would idea. But i didn't do it in my code, because flags
are for me always one char "-4" "-k" -l" "-?", and if we would use "-46",
the flag would be two chars.
In that case, it would be a long argument like "--46"
I have no problem to change the code in that way, but we would give the
syntax, that flags are only one char.
I don't know, what's better.
…-----Original-Nachricht-----
Betreff: Re: [jamulussoftware/jamulus] Basic IPv6 support for Jamulus
(#1455)
Datum: 2021-04-10T14:44:41+0200
Von: "Peter L Jones" ***@***.***>
An: "jamulussoftware/jamulus" ***@***.***>
For the command line parameters, I would prefer a solution that is not
dependent on the order
Agreed.
"-46" = default, IPv4 first, IPv4 over IPv6 if there's no native IPV4 "-64" = IPv6 first, IPv4 if there is no IPv6 "-4" = IPv4 only "-6" = IPv6 only
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1455 (comment)>
, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATKQY5CKO26W6EXFYBWROTDTIBB3PANCNFSM42PHKWIA>
.
[ { ***@***.***": "http://schema.org", ***@***.***": "EmailMessage",
"potentialAction": { ***@***.***": "ViewAction", "target":
"#1455 (comment)",
"url":
"#1455 (comment)",
"name": "View Pull Request" }, "description": "View this Pull Request on
GitHub", "publisher": { ***@***.***": "Organization", "name": "GitHub", "url":
"https://github.com" } } ]
|
Hello Peter Jones,
thanks for your review and the indent patches of my code.
Since i am new in your Jamulus forum, i don't know what to do.
I would like to follow your work and patch the source.
Shall i patch my source and upload it again?
Do i have to generate another pull request?
I don't think i can accept your changes directly.
I think, i have to patch my source, remove the socket.cpp outside the src
directory and upload the patched source again.
Is this correct?
Thanks again and in advance,
mstolle629
-----Original-Nachricht-----
Betreff: Re: [jamulussoftware/jamulus] Basic IPv6 support for Jamulus
(#1455)
Datum: 2021-04-10T14:48:20+0200
Von: "Peter L Jones" ***@***.***>
An: "jamulussoftware/jamulus" ***@***.***>
@pljones commented on this pull request.
------------------------------------------------------------------------
In src/client.cpp
<#1455 (comment)>
:
@@ -62,6 +63,7 @@ CClient::CClient ( const quint16 iPortNumber, bEnableOPUS64 ( false ), bJitterBufferOK ( true ), bNuteMeInPersonalMix ( bNMuteMeInPersonalMix ), + iipmode ( ipmode ),
As above - spaces not tabs, please.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1455 (review)>
, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATKQY5BZIJ5RJYYWIDJS7CTTIBCIRANCNFSM42PHKWIA>
.
[ { ***@***.***": "http://schema.org", ***@***.***": "EmailMessage",
"potentialAction": { ***@***.***": "ViewAction", "target":
"#1455 (review)",
"url":
"#1455 (review)",
"name": "View Pull Request" }, "description": "View this Pull Request on
GitHub", "publisher": { ***@***.***": "Organization", "name": "GitHub", "url":
"https://github.com" } } ]
|
The process is:
|
--ip46 and --ip64 don't seem very self-explanatory, maybe --preferip4 and --preferip6 would be easier to understand by just looking at parameters? |
I would keep the prefix |
Closing this in favour of #1938 instead. |
in our region, there are many people on ISP's with only "dual stack lite" ipv4 support (Vodafone, 1&1), which have problems with ipv4, because they use a central NAT instance.
This patch introduces ipv6 support.
It adds command line options "-4" and "-6", which decide, in which sequence NetworkAddresses are parsed. It also includes autosensing, if there is no ipv6 support in the kernel or driver - in that case it falls back to ipv4 and the old code.
In addition, it uses recvmsg() and sendmsg(), so that it can read the IP address, on which packets are received. In Case of Windows, it uses WSASendMsg and WSARecvMsg.
Tested on Windows, Linux and Mac.
In our environment, the response times of ipv6 are about 6ms faster than the response times of ipv4, because the connection on the internet is more direct, but this may vary.