Skip to content

Commit f6995bc

Browse files
committed
get device pci info
1 parent f8cbf5e commit f6995bc

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Set Linux as router in one command. Able to provide Internet, or create WiFi hot
44

55
It wraps `iptables`, `dnsmasq` etc. stuff. Use in one command, restore in one command or by `control-c` (or even by closing terminal window).
66

7-
[📰 News & Developer Notes](https://github.com/garywill/linux-router/issues/28) | [More tools and projects 🛠️](https://garywill.github.io) | [🍻 Buy me a coffee ❤️](https://github.com/garywill/receiving/blob/master/receiving_methods.md)
7+
[Linux-Router News & Developer Notes 📰](https://github.com/garywill/linux-router/issues/28) | [More tools and projects 🛠️](https://garywill.github.io) | [🍻 Buy me a coffee ❤️](https://github.com/garywill/receiving/blob/master/receiving_methods.md)
88

99
## Features
1010

@@ -413,16 +413,15 @@ On exit of a linux-router instance, script **will do cleanup**, i.e. undo most c
413413

414414
## TODO
415415

416-
<details>
417-
416+
Sooner is better:
418417
- Detect firewalld and make sure it won't interfere our interface
418+
419+
Future:
419420
- WPA3
420421
- Global IPv6
421422
- Explictly ban forwarding if not needed
422423
- Bring bridging method back
423424

424-
</details>
425-
426425
## License
427426

428427
linux-router is LGPL licensed
@@ -486,7 +485,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
486485

487486
Visit [**my homepage** 🏡](https://garywill.github.io) to see **more tools and projects** 🛠️.
488487

489-
> [❤️ Buy me a coffee](https://github.com/garywill/receiving/blob/master/receiving_methods.md) , this project took me lots of time! ([❤️ 扫个码打赏一个!](https://github.com/garywill/receiving/blob/master/receiving_methods.md))
488+
> [❤️ Buy me a coffee](https://github.com/garywill/receiving/blob/master/receiving_methods.md) , this project took me lots of time! ([❤️ 扫码领红包并打赏一个!](https://github.com/garywill/receiving/blob/master/receiving_methods.md))
490489
>
491490
> 🥂 ( ^\_^) o自自o (^_^ ) 🍻
492491

lnxrouter

100644100755
+28-3
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,32 @@ get_interface_mac() {
626626
cat "/sys/class/net/${1}/address"
627627
}
628628

629+
get_interface_pci_info() { # pci id / model / virtual
630+
is_interface "$1" || return
631+
632+
local device_path
633+
local pci_id
634+
local pci_full
635+
636+
device_path="$(readlink -f /sys/class/net/$1)"
637+
638+
if [[ "$device_path" == "/sys/devices/pci"* ]]; then
639+
pci_id="$(echo $device_path | sed 's/\//\n/g' | tail -n 3 |sed -n 1p)"
640+
641+
if which lspci >/dev/null 2>&1 ; then
642+
pci_full="$( lspci -D -nn | grep -E "^$pci_id " )"
643+
echo " PCI: $pci_full"
644+
else
645+
echo " PCI: $pci_id"
646+
fi
647+
elif [[ "$device_path" == *"/virtual/"* ]]; then
648+
echo " virtual interface"
649+
fi
650+
# TODO usb
651+
# TODO current driver
652+
}
653+
654+
629655
alloc_new_vface_name() { # only for wifi
630656
local i=0
631657
local v_iface_name=
@@ -1928,8 +1954,7 @@ echo
19281954
echo "PID: $$"
19291955

19301956
TARGET_IFACE="$(decide_target_interface)" || exit 1 # judge wired (-i CONN_IFACE) or wireless hotspot (--ap $WIFI_IFACE)
1931-
echo "Target interface is ${TARGET_IFACE} ($(get_interface_mac $TARGET_IFACE))"
1932-
# TODO: show interface type, device model and pci/usb id (hwdata pci.ids), current driver
1957+
echo "Target interface is ${TARGET_IFACE} ($(get_interface_mac $TARGET_IFACE)) $(get_interface_pci_info $TARGET_IFACE)"
19331958

19341959
if [[ "$MAC_USE_RANDOM" -eq 1 ]] ; then
19351960
NEW_MACADDR="$(generate_random_mac)"
@@ -2065,7 +2090,7 @@ fi
20652090
[[ $NO_DNSMASQ -eq 0 ]] && ( allow_dhcp ; start_dnsmasq )
20662091

20672092
echo
2068-
echo "== Setting up completed, now linux-router is working =="
2093+
echo "== Setting up completed, now linux-router should be working =="
20692094

20702095
#============================================================
20712096
#============================================================

0 commit comments

Comments
 (0)