mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-28 17:12:22 +00:00
Compare commits
1 Commits
1a3955554a
...
staging-WI
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
553f894dc7 |
@@ -5,3 +5,6 @@
|
||||
# list ssid 'EAP101-ERICHI'
|
||||
# list ssid 'EAP101-AKIHO'
|
||||
# list ssid 'EAP101-DAMAYU'
|
||||
#
|
||||
# config dhcpinject 'dhcpinject'
|
||||
# option iface_count '6'
|
||||
|
||||
@@ -9,9 +9,9 @@ SERVICE_NAME="dhcpinject"
|
||||
PROG=/usr/bin/udhcpinject
|
||||
|
||||
start_service() {
|
||||
local ssid_list=""
|
||||
local ssids=""
|
||||
local ports=""
|
||||
local ifaces=""
|
||||
|
||||
# Function to process each ssid
|
||||
append_ssid() {
|
||||
@@ -40,6 +40,9 @@ start_service() {
|
||||
|
||||
# Get the list of ports
|
||||
config_list_foreach uplink port append_port
|
||||
|
||||
# Get the iface_count
|
||||
config_get ifaces dhcpinject iface_count
|
||||
|
||||
# Fallback to eth0 if no ports are specified
|
||||
if [ -z "$ports" ]; then
|
||||
@@ -47,11 +50,11 @@ start_service() {
|
||||
fi
|
||||
|
||||
# Optional: Log or echo for debugging
|
||||
logger -t dhcp_inject "Generated SSIDs=$ssids, Uplink=$ports"
|
||||
logger -t dhcp_inject "Generated SSIDs=$ssids, Uplink=$ports, IFACEs=$ifaces"
|
||||
|
||||
procd_open_instance "$SERVICE_NAME"
|
||||
procd_set_param command $PROG
|
||||
procd_set_param env SSIDs="$ssids" PORTs="$ports"
|
||||
procd_set_param env SSIDs="$ssids" PORTs="$ports" IFACEs="$ifaces"
|
||||
procd_set_param respawn 3600 10 10
|
||||
procd_set_param file /etc/config/dhcpinject
|
||||
procd_set_param reload_signal SIGHUP
|
||||
|
||||
@@ -26,6 +26,7 @@ struct iface_info *iface_map = NULL;
|
||||
static struct port_info *ports = NULL;
|
||||
int iface_count = 0;
|
||||
int port_count = 0;
|
||||
int total_iface = 0;
|
||||
static pcap_t *handle = NULL;
|
||||
static char *provided_ssids = NULL;
|
||||
static char *provided_ports = NULL;
|
||||
@@ -192,6 +193,11 @@ int parse_ssids(const char *ssids) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (iface_count != total_iface) {
|
||||
syslog(LOG_ERR, "Expect %d but only %d interfaces were found.\n", total_iface, iface_count);
|
||||
return -1;
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, "Found %d matching interfaces\n", iface_count);
|
||||
return 0;
|
||||
}
|
||||
@@ -310,7 +316,6 @@ void signal_handler(int sig) {
|
||||
exit(0);
|
||||
} else if (sig == SIGHUP) {
|
||||
syslog(LOG_INFO, "Received reload signal, reconfiguring...\n");
|
||||
sleep(5);
|
||||
// Clean up existing resources
|
||||
cleanup_tc();
|
||||
|
||||
@@ -561,7 +566,19 @@ int main(int argc, char *argv[]) {
|
||||
signal(SIGTERM, signal_handler);
|
||||
signal(SIGHUP, signal_handler);
|
||||
|
||||
sleep(5);
|
||||
// Read IFACEs from environment variable
|
||||
char *iface_env = getenv("IFACEs");
|
||||
if (!iface_env) {
|
||||
syslog(LOG_ERR, "No IFACEs provided. Exiting...\n");
|
||||
cleanup();
|
||||
return 1;
|
||||
}
|
||||
total_iface = atoi(iface_env);
|
||||
if (total_iface <= 0) {
|
||||
syslog(LOG_ERR, "Invalid IFACEs value: %s. Exiting...\n", iface_env);
|
||||
cleanup();
|
||||
return 1;
|
||||
}
|
||||
|
||||
provided_ssids = getenv("SSIDs");
|
||||
syslog(LOG_INFO, "Provided SSIDs: %s\n", provided_ssids);
|
||||
@@ -618,4 +635,4 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
cleanup();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user