27 Commits

Author SHA1 Message Date
Vincent Li
67d1b8a4e9 network-functions.pl: Add function to extract prefix
wireguard-functions.pl requires get_prefix

commit 0e55d27737
Author: Michael Tremer <michael.tremer@ipfire.org>
Date:   Wed Mar 20 12:09:58 2024 +0100

    network-functions.pl: Add function to extract prefix

    Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2025-07-04 17:17:07 +00:00
Vincent Li
6ed934dbfc configroot: add pool address normalization sub
wireguard.cgi needs pool address normalization

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2025-07-03 17:55:04 +00:00
Adolf Belka
b52a84ddc7 dhcp.cgi: Fix bug#10629 - Highlight fixed IP's in dynamic range in red
- This v2 patch has moved the extraHead variable into header.pl
- This patch marks all IP's that are in the Fixed list but are also in the dynamic range
   that has been defined, in red.
- Additional function created to check if an ip address is in a defined range.
- Added an additional key item under the Fixed Leases table for Fixed IP in dynamic range
- Added line to English Language file for this key item.
- ./make lang run before commit.
- Tested in vm testbed and confirmed that any ip address in the Fixed Leases table that
   is in the defined dynamic range is highlighted in red
- This uses the css background-color appoach from the first patch in this set.
- This patch only highlights those IP's that overlap in red but does nothing more. So a
   user can still create new ones if they want but they will all show up in red.
- This patch flags up if people are doing things that they shouldn't be doing but allows
   them to continue doing so without changing anything if they don't want to and so will
   not break existing setups.

Fixes: Bug#10629
Tested-by: Adolf Belka <adolf.belka@ipfire.org>
Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org>
Tested-by: Bernhard Bitsch <bbitsch@ipfire.org>
2023-03-04 13:41:21 +00:00
Michael Tremer
6395bed8a4 aliases: Add support to assign aliases to multiple RED interfaces
This is a little patch which will extend the aliases page to offer an
interface selection if there are more than one RED interfaces.

This is a little hack to make configuration easier for users who have
manually set up more than one RED interface (e.g. for load balancing or
fail-over) and want to use the UI to configure firewall rules.

As a little benefit on the side, I had to rewrite setaliases.c to use
ip(8) instead of ifconfig(8).

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Acked-by: Peter Müller <peter.mueller@ipfire.org>
2022-07-06 10:01:50 +00:00
Arne Fitzenreiter
b9a0d7065b network_functions: fix _get_wireless_status function
the function has returned the number of lines instead of the output itself.

Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2021-09-12 10:55:43 +02:00
Leo-Andres Hofmann
6dd084c22d network-functions.pl: Improve wifi_get_link_quality
iwconfig doesn't return values for "Link Quality" if the interface
is disconnected, causing a division by zero error. If there are odd
values, the resulting percentage may contain many decimal places.

This patch makes wifi_get_link_quality return zero instead of failing
and rounds the percentage to a more meaningful integer.

Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de>
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2021-09-05 08:50:05 +00:00
Stefan Schantl
f3e3cb371d network-functions.pl: Use new system methods
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
2021-06-17 20:11:37 +00:00
Michael Tremer
45b1fc5c7f hostapd: Find device by MAC address
With wireless device as members in bridges, we cannot predict the name
very well. So we will use the MAC address and find the correct device
name when we launch hostapd.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2021-04-16 10:05:57 +00:00
Leo-Andres Hofmann
92d8c1f73c network-functions.pl: Add MAC address compare function
Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2021-03-25 09:21:39 +00:00
Arne Fitzenreiter
69d90c36cc network-functions.pl: declare use of smartmatch
perl complains about the use of experimental smartmatch feature
if it is not declared.

Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2021-02-01 10:45:38 +00:00
Leo-Andres Hofmann
eea288bc1a network-functions.pl: Improve zone configuration functions
Cache ethernet configuration in public variable "ethernet_settings",
add functions to simplify working with the network configuration.

Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2021-01-25 19:32:40 +00:00
Leo-Andres Hofmann
abffcc99ad Refactor "get_available_network_zones", move to network-functions.pl
This function nicely translates the ethernet/settings "CONFIG_TYPE"
into a list of available zones. Therefore it should be more accessible!

Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2021-01-25 19:32:38 +00:00
Peter Müller
cc9eb2d306 network-functions.pl: add missing unit tests for changed, network membership procedure
Cc: Tim FitzGeorge <ipfr@tfitzgeorge.me.uk>
Cc: Alexander Marx <alexander.marx@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2020-07-28 18:37:32 +00:00
Peter Müller
6386584baa network-functions.pl: fix network membership test
This is based on an orphaned patch provided by Tim FitzGeorge and
_finally_ fixes incorrect network membership calculations. Those were
are usability pain in the ass deluxe, as they rendered some combinations
of configuring OpenVPN and IPsec services unusable.

Fixes: #11235
Fixes: #12263

Cc: Tim FitzGeorge <ipfr@tfitzgeorge.me.uk>
Cc: Michael Tremer <michael.tremer@ipfire.org>
Cc: Alexander Marx <alexander.marx@ipfire.org>
Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2020-07-28 18:37:25 +00:00
Florian Bührle
1dcf513a41 webif: Add a GUI for configuring VLAN interfaces
This patch adds a new CGI file which allows users to edit the
VLAN configuration as well as configuring zones as bridges.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2019-05-08 12:15:27 +01:00
Alexander Marx
3f3974b711 Network-functions: add check if variables are defined
in function network_equal and network2bin a check for undefined variables were missing.
added them.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2017-11-07 16:19:23 +00:00
Alexander Marx
1047805dba BUG11466: Fix network_equal function
The network_equal function only tested the subnet addresses of two given networks which lead to
errormessages saying "This is the green network"
The fix tests netwok and subnet IP's to fix this

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2017-11-07 16:16:18 +00:00
Michael Tremer
dbfd2622f5 captive: Get MAC address of a device without calling arp
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2017-09-22 18:55:27 +01:00
Michael Tremer
c335b0cd8e index.cgi: Show WiFi properties on front page
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2017-05-16 16:02:25 +02:00
Michael Tremer
3713af1e27 network-functions.pl: Add tests for the new equals function
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2017-01-11 17:18:46 +00:00
Michael Tremer
8f23ce8e53 network-functions.pl: Fix code formatting
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2017-01-11 17:09:42 +00:00
Alexander Marx
ff6cc71107 BUG11278: enable creation from subnets of internal networks
In firewallgroups it was not possible to create new networks that are subnets of
IPFire internal networks. Now this is possible for all internal networks.

Signed-off-by: Alexander Marx <alexander.marx@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2017-01-11 17:05:53 +00:00
Alexander Marx
f770b72899 BUG10940: remove leading zeros in ip address
in firewallgroups (hosts) an error was created when using ip adresses
like 192.168.000.008. Now all leading zeros are deleted in
firewallgroups and in the firewall itself when using single ip addresses
as source or target.

Signed-off-by: Alexander Marx <alexander.marx@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2015-11-09 17:32:59 +00:00
Arne Fitzenreiter
01d61d1549 network_functions.pl: fix ip_address_in_network for x86_64
calculation of last address must use only 32bit of inverted netmask.

Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2015-09-20 13:03:34 +02:00
Michael Tremer
883c5453d9 network-functions: Add check_subnet()
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2015-08-25 21:55:40 +01:00
Michael Tremer
5428eeeeaa url-filter: Use upstream proxy when downloading blacklists
Fixes #10690

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
2015-06-16 14:39:26 +02:00
Michael Tremer
4e9a2b5732 general-functions.pl: Replace lots of broken network code.
The state of some code especially in general-functions.pl
is in such a bad shape and faulty.
This is a first step that replaces some of the network
functions with those who have been tested and work for
undefined inputs.

The old functions have been left in place as stubs
and must be removed at some time.
2014-07-27 22:46:20 +02:00