Open n-thumann opened 10 months ago
Hi, thanks for raising this one. The explanation is embarassingly simple: when I started working on running Unix commands on iOS (a few years before a-Shell), I copied what was, at the time, the source code for network commands on Apple OpenSource server. A quick check shows that this ifconfig.c ("Copyright (c) 2009-2017 Apple Inc.") does not have provision for "inet6", only "inet". I've downloaded a more recent version of the source code ("Copyright (c) 2009-2021 Apple Inc.") which seems to have it.
I still need to prepare it for cross-compiling and then cross-compile it. I'll keep you posted. It will always be the BSD version of ifconfig
, not the GNU version, so -L
will remain an illegal option.
Thanks for taking care! 🚀
It will always be the BSD version of ifconfig, not the GNU version, so -L will remain an illegal option.
Is that the case? E.g. macOS and FreeBSD support -L
, while Debian doesn't. Isn't this snipped related?
https://github.com/holzschu/network_ios/blob/471d12e5c953bbaf16468bbb86b6c26bb6338d1f/ifconfig/af_inet6.c#L650-L655
You're right, thanks for checking this. I was looking at the code for usage()
and looking for -L
, but I had missed the %s
:
fprintf(stderr,
"usage: ifconfig %sinterface address_family [address [dest_address]]\n"
" [parameters]\n"
" ifconfig interface create\n"
" ifconfig -a %s[-d] [-m] [-u] [-v] [address_family]\n"
" ifconfig -l [-d] [-u] [address_family]\n"
" ifconfig %s[-d] [-m] [-u] [-v]\n"
" ifconfig -X pattern %s[-a] [-d] [-d] [-m] [-u] [-v] [address_family]\n",
options, options, options, options);
So the question for me becomes: how to make sure that the option is registered. I'm having another look at the code.
Hi,
the bad news is: I still don't understand how ifconfig is loading options.
The good news is: linking with af_inet6.c
did the trick. The latest TestFlight version of a-Shell mini has ifconfig with ipv6 and -L
: https://testflight.apple.com/join/REdHww5C
It works for me (I have twice as many IPv6 connections on the iPhone (4G + wifi) than on the iPad (wifi only)). I'll let you test extensively in case I missed something in terms of behaviour.
I just tested it and can confirm that it's working!
I compared the interfaces and IP addresses reported by ifconfig -L
with the ones reported in HE.NET Network Tools and they line up. The IPv6 address lifetimes and states (e.g. a secured, a temporary and a deprecated one on my en0
) are also as expected.
Thank you very much for these tests (and for opening the issue in the first place). The build has also passed Apple's check for forbidden internal API calls (which is good). It will be in version 1.12.5.
Reference for future looks at this issue: I had to comment half of ifconfig code, because it uses function calls that are not in the iOS SDK. Most of these (e.g. router mode, or setting parameters instead of reading them) are indeed not compatible with iOS. I also had to copy some header files from the MacOS SDK, to have data types and #define
values.
There are two files named ifconfig.c
in the repository and both have 2141 lines. Was /ifconfig.c
added by mistake in commit 471d12e5c953bbaf16468bbb86b6c26bb6338d1f?
Yes, and it's been removed since then, but I hadn't pushed the changes. It should be done now.
Both ifconfig
and ping6
fixes have been committed. Do you have plans for a new release?
If by "release" you mean as part of the a-Shell app, then it's already out. If by "release" you mean a release of the binary framework for network_ios, then it's done by github actions, and that has just failed. I'm going to have to edit the actions to make it work (since I am not aware of anyone using network_ios for their own work, I don't prioritize making new binary releases of the framework...)
If by "release" you mean as part of the a-Shell app, then it's already out. If by "release" you mean a release of the binary framework for network_ios, then it's done by github actions, and that has just failed. I'm going to have to edit the actions to make it work (since I am not aware of anyone using network_ios for their own work, I don't prioritize making new binary releases of the framework...)
I mean the latter, and as far as I know Blink Shell is using it. https://github.com/blinksh/blink/blob/df04676bc07fde94b57a9cc7aedf2430ab996e07/xcfs/Package.swift#L73
Even though my device as IPv6 addresses assigned to several interfaces (e.g. WiFi or cellular), the
ifconfig
command only lists IPv4 addresses. Additionally,-L
ofifconfig
to display the address lifetime for IPv6 addresses seems to an illegal option. IPv6 connectivity in general is working fine:ping6 google.com
succeeds and even shows the source IPv6 address.I'm using a-Shell 1.12.2. Thanks in advance :v: