forked from Fishwaldo/sophgo-sg200x-debian
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
125 additions
and
0 deletions.
There are no files selected for viewing
125 changes: 125 additions & 0 deletions
125
configs/common/patches/buildroot/0001-nanokvm-server-kvm_system-support-end0.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
From bf70fa07902d5d9dea409eecfe23492da52604bd Mon Sep 17 00:00:00 2001 | ||
From: scpcom <[email protected]> | ||
Date: Tue, 4 Feb 2025 20:04:00 +0100 | ||
Subject: [PATCH] nanokvm-server: kvm_system: support end0 | ||
|
||
--- | ||
...0022-support-kvm_system-support-end0.patch | 106 ++++++++++++++++++ | ||
1 file changed, 106 insertions(+) | ||
create mode 100644 package/nanokvm-server/0022-support-kvm_system-support-end0.patch | ||
|
||
diff --git a/package/nanokvm-server/0022-support-kvm_system-support-end0.patch b/package/nanokvm-server/0022-support-kvm_system-support-end0.patch | ||
new file mode 100644 | ||
index 0000000000..c1f93d63ad | ||
--- /dev/null | ||
+++ b/package/nanokvm-server/0022-support-kvm_system-support-end0.patch | ||
@@ -0,0 +1,106 @@ | ||
+From 395c6cc92256dff9a963bb052a1eb4b92ef89f83 Mon Sep 17 00:00:00 2001 | ||
+From: scpcom <[email protected]> | ||
+Date: Tue, 4 Feb 2025 20:02:13 +0100 | ||
+Subject: [PATCH] support: kvm_system: support end0 | ||
+ | ||
+--- | ||
+ support/kvm_system/main/include/config.h | 1 + | ||
+ .../main/lib/system_state/system_state.cpp | 31 ++++++++++++++----- | ||
+ 2 files changed, 25 insertions(+), 7 deletions(-) | ||
+ | ||
+diff --git a/support/kvm_system/main/include/config.h b/support/kvm_system/main/include/config.h | ||
+index 528c86d..e4a3b93 100644 | ||
+--- a/support/kvm_system/main/include/config.h | ||
++++ b/support/kvm_system/main/include/config.h | ||
+@@ -67,6 +67,7 @@ typedef struct { | ||
+ char wifi_ap_pass[9] = {0}; | ||
+ uint8_t oled_sleep_state = 0; // 0:wakeup; 1:sleep; | ||
+ int8_t reconvery_update = 0; // 0:Undetected; 1:Needs Update; 2:Update finish; -1:not need to update | ||
++ char eth_intf[16] = {0}; | ||
+ } kvm_sys_state_t; | ||
+ | ||
+ typedef struct { | ||
+diff --git a/support/kvm_system/main/lib/system_state/system_state.cpp b/support/kvm_system/main/lib/system_state/system_state.cpp | ||
+index 953a805..c5f8cd1 100644 | ||
+--- a/support/kvm_system/main/lib/system_state/system_state.cpp | ||
++++ b/support/kvm_system/main/lib/system_state/system_state.cpp | ||
+@@ -12,19 +12,29 @@ int get_ip_addr(ip_addr_t ip_type) | ||
+ { | ||
+ switch (ip_type){ | ||
+ case ETH_IP: // eth_addr | ||
+- if(strcmp(ip_address()["eth0"].c_str(), (char*)kvm_sys_state.eth_addr) != 0){ | ||
+- if(*(ip_address()["eth0"].c_str()) == 0){ | ||
++ { | ||
++ string interface_eth = "eth0"; | ||
++ string ip_address_eth = ip_address()[interface_eth]; | ||
++ if(*(ip_address_eth.c_str()) == 0){ | ||
++ interface_eth = "end0"; | ||
++ ip_address_eth = ip_address()[interface_eth]; | ||
++ } | ||
++ if(strcmp(ip_address_eth.c_str(), (char*)kvm_sys_state.eth_addr) != 0){ | ||
++ if(*(ip_address_eth.c_str()) == 0){ | ||
+ printf("can`t get ip addr\r\n"); | ||
+ kvm_sys_state.eth_addr[0] = 0; | ||
++ strcpy(kvm_sys_state.eth_intf, "eth0"); | ||
+ return 0; | ||
+ } | ||
+ for(int i = 0; i <= 15; i++) | ||
+ { | ||
+- kvm_sys_state.eth_addr[i] = *(ip_address()["eth0"].c_str() + i); | ||
++ kvm_sys_state.eth_addr[i] = *(ip_address_eth.c_str() + i); | ||
+ printf("%c", kvm_sys_state.eth_addr[i]); | ||
+ } | ||
+ printf("\r\n"); | ||
++ strcpy(kvm_sys_state.eth_intf, interface_eth.c_str()); | ||
+ } | ||
++ } | ||
+ return 1; | ||
+ case WiFi_IP: // wifi_addr | ||
+ if(strcmp(ip_address()["wlan0"].c_str(), (char*)kvm_sys_state.wifi_addr) != 0){ | ||
+@@ -73,7 +83,7 @@ int get_ip_addr(ip_addr_t ip_type) | ||
+ memset( kvm_sys_state.eth_route, 0, sizeof( kvm_sys_state.eth_route ) ); | ||
+ char Cmd[100]={0}; | ||
+ memset( Cmd, 0, sizeof( Cmd ) ); | ||
+- sprintf( Cmd,"ip route | grep -i '^default' | grep -i 'eth0' | awk '{print $3}'"); | ||
++ sprintf( Cmd,"ip route | grep -i '^default' | grep -i -E 'eth0|end0' | awk '{print $3}'"); | ||
+ FILE* fp = popen( Cmd, "r" ); | ||
+ if ( NULL == fp ) | ||
+ { | ||
+@@ -146,8 +156,8 @@ int get_ip_addr(ip_addr_t ip_type) | ||
+ int chack_net_state(ip_addr_t use_ip_type) | ||
+ { | ||
+ char Cmd[100]={0}; | ||
+- if (use_ip_type == ETH_ROUTE) sprintf( Cmd,"ping -I eth0 -w 1 %s > /dev/null", kvm_sys_state.eth_route); | ||
+- else if (use_ip_type == WiFi_ROUTE) sprintf( Cmd,"ping -I wlan0 -w 1 %s > /dev/null", kvm_sys_state.wifi_route); | ||
++ if (use_ip_type == ETH_ROUTE) sprintf( Cmd,"ping -I %s -w 1 %s > /dev/null", kvm_sys_state.eth_intf, kvm_sys_state.eth_route); | ||
++ else if (use_ip_type == WiFi_ROUTE) sprintf( Cmd,"ping -I %s -w 1 %s > /dev/null", "wlan0", kvm_sys_state.wifi_route); | ||
+ else return -1; // 不支持的端口 | ||
+ if(system(Cmd) == 0){ // 256:不通; = 0:通 | ||
+ return 1; | ||
+@@ -169,6 +179,7 @@ int kvm_eth_cable_exist() | ||
+ int file_size; | ||
+ uint8_t RW_Data[10]; | ||
+ fp = fopen("/sys/class/net/eth0/carrier", "r"); | ||
++ if (!fp) fp = fopen("/sys/class/net/end0/carrier", "r"); | ||
+ fseek(fp, 0, SEEK_END); | ||
+ file_size = ftell(fp); | ||
+ fseek(fp, 0, SEEK_SET); | ||
+@@ -388,8 +399,14 @@ void kvm_update_eth_state(void) | ||
+ eth_cable_state = kvm_eth_cable_exist(); | ||
+ | ||
+ if(eth_cable_state){ | ||
++ string interface_eth = "eth0"; | ||
++ string ip_address_eth = ip_address()[interface_eth]; | ||
++ if(*(ip_address_eth.c_str()) == 0){ | ||
++ interface_eth = "end0"; | ||
++ ip_address_eth = ip_address()[interface_eth]; | ||
++ } | ||
+ // 获取实时IP | ||
+- if(strcmp(ip_address()["eth0"].c_str(), (char*)kvm_sys_state.eth_addr) != 0){ | ||
++ if(strcmp(ip_address_eth.c_str(), (char*)kvm_sys_state.eth_addr) != 0){ | ||
+ // if(1){ | ||
+ if(get_ip_addr(ETH_IP)){ | ||
+ kvm_sys_state.eth_state = 2; | ||
+-- | ||
+2.34.1 | ||
+ | ||
-- | ||
2.34.1 | ||
|