add samples

This commit is contained in:
Mario Fetka
2026-04-19 23:08:28 +02:00
parent 22dcfb823b
commit a1490efb03
8 changed files with 458 additions and 136 deletions

View File

@@ -0,0 +1,35 @@
diff '--color=auto' -uNr ipx-utils-9999.orig/Makefile.am ipx-utils-9999/Makefile.am
--- ipx-utils-9999.orig/Makefile.am 2026-04-19 22:40:49.949320330 +0200
+++ ipx-utils-9999/Makefile.am 2026-04-19 22:42:54.743135308 +0200
@@ -4,7 +4,11 @@
ipx_configure \
ipx_interface \
ipx_internal_net \
- ipx_route
+ ipx_route \
+ ipxrcv \
+ ipxsend \
+ rip \
+ sap
ipx_configure_SOURCES = \
src/ipx_configure.c
@@ -18,6 +22,18 @@
ipx_route_SOURCES = \
src/ipx_route.c
+ipxrcv_SOURCES = \
+ Samples/ipxrcv.c
+
+ipxsend_SOURCES = \
+ Samples/ipxsend.c
+
+rip_SOURCES = \
+ Samples/rip.c
+
+sap_SOURCES = \
+ Samples/sap.c
+
man_MANS = \
docs/ipx_configure.8 \
docs/ipx_interface.8 \

View File

@@ -1,26 +1,140 @@
# Copyright 1999-2004 Gentoo Foundation
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# Config file for /etc/init.d/ipx
# Configuration for the IPX network startup helpers.
#
# This file is used by:
# - /etc/init.d/ipx
# - /usr/libexec/ipx/network-start.sh
# - /usr/libexec/ipx/network-stop.sh
# - /etc/systemd/system/ipx.service
#
# Manual interface configuration:
# IPX_INTERFACES contains one entry per line.
#
# Format:
# <device>:<frame>:<netnum>
#
# Example:
# IPX_INTERFACES="
# enp0s31f6:802.2:1
# enp46s0u1u3u3:802.2:2
# wlp0s20f3:802.2:3
# "
#
# Behaviour:
# - The first successfully configured interface becomes the primary IPX
# interface.
# - Additional interfaces are configured as non-primary interfaces.
# - Each manually configured interface should use its own IPX network
# number.
# - Interfaces that are not currently present are skipped with a warning.
# - This is useful for optional hardware such as a docking station NIC.
#
# Link-state handling:
# If IPX_SKIP_LINK_DOWN=yes, interfaces that exist but currently do not
# have an active link are skipped as well.
#
# This is useful for cases such as:
# - a docking station NIC that exists but currently has no link
# - a physical Ethernet device with no cable attached
#
# Detection order:
# 1. /sys/class/net/<if>/carrier
# 2. /sys/class/net/<if>/operstate
#
# Example with an optional docking station interface:
# IPX_INTERFACES="
# enp46s0u1u3u3:802.2:1
# enp0s31f6:802.2:2
# wlp0s20f3:802.2:3
# "
#
# In that example:
# - if enp46s0u1u3u3 is present and usable, it will be configured first
# and become the primary IPX interface
# - if enp46s0u1u3u3 is missing, it will be skipped
# - if enp46s0u1u3u3 exists but has no active link and
# IPX_SKIP_LINK_DOWN=yes, it will also be skipped
# - the next successfully configured interface will become primary
#
# Static route configuration:
# IPX_ROUTES contains one entry per line.
#
# Format:
# <target_network>:<router_network>:<router_node>
#
# Example:
# IPX_ROUTES="
# 00000010:00000001:508140F6AC45
# 00000020:00000003:44E517C3D034
# "
#
# Route behaviour:
# - Routes are added after all interfaces have been configured
# - During shutdown, routes are removed again by target network
# - Empty lines and comment lines starting with '#' are ignored
#
# Automatic configuration:
# IPX_AUTO_PRIMARY and IPX_AUTO_INTERFACE are passed to ipx_configure.
#
# Recommended setting for manual interface definitions:
# - IPX_AUTO_INTERFACE=off
#
# This avoids mixing manual interface definitions with automatically created
# IPX interfaces.
#
# Internal network mode:
# If IPX_INTERNAL_NET=yes, no physical interfaces from IPX_INTERFACES are
# configured.
#
# Instead, an IPX internal network is created using IPX_NETNUM and
# IPX_NODENUM.
#
# The internal network does not use a physical device or frame type and
# automatically becomes the primary IPX interface.
#
# There can only be one internal network per host.
# Automatically selecting a primary interface.
# Automatically select a primary IPX interface.
IPX_AUTO_PRIMARY=on
# Automatically creating interfaces.
IPX_AUTO_INTERFACE=on
# Automatically create IPX interfaces.
# Recommended: off when using IPX_INTERFACES.
IPX_AUTO_INTERFACE=off
# Interface to which IPX sockets are bound.
IPX_DEVICE=eth0
# Skip interfaces that are present but currently have no active link.
# Valid values: yes / no
IPX_SKIP_LINK_DOWN=yes
# The IPX frame type to use
IPX_FRAME=802.2
# Create a special kind of IPX interface that does not
# have a physical device or frame type.
# Create a special internal IPX network instead of binding to physical NICs.
# Valid values: yes / no
IPX_INTERNAL_NET=no
# Network number
# IPX network number for internal network mode only.
IPX_NETNUM=1
# Node number
# IPX node number for internal network mode only.
IPX_NODENUM=1
# Manually configured IPX interfaces.
# Format: <device>:<frame>:<netnum>
#
# The first successfully configured interface becomes primary.
# Missing interfaces are skipped.
IPX_INTERFACES="
enp46s0u1u3u3:802.2:1
enp0s31f6:802.2:2
wlp0s20f3:802.2:3
"
# Static IPX routes.
# Format: <target_network>:<router_network>:<router_node>
#
# Example:
# IPX_ROUTES="
# 00000010:00000001:508140F6AC45
# 00000020:00000003:44E517C3D034
# "
IPX_ROUTES="
"

View File

@@ -1,41 +1,27 @@
#!/sbin/openrc-run
# Copyright 1999-2016 Gentoo Foundation
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
#NB: Config is in /etc/conf.d/ipx
# IPX network setup service
#
# Configuration is read from /etc/conf.d/ipx.
# The actual start/stop logic is implemented in helper scripts under
# /usr/libexec/ipx/ so that OpenRC and systemd can share the same code.
description="Configure IPX interfaces and automatic IPX behaviour"
depend() {
use net
use net
}
start() {
local retval=0
ebegin "Bringing IPX up"
if [ ${IPX_INTERNAL_NET} = "yes" ]
then
/sbin/ipx_internal_net add ${IPX_NETNUM} ${IPX_NODENUM}
retval=$?
else
/sbin/ipx_interface add -p ${IPX_DEVICE} \
${IPX_FRAME} ${IPX_NETNUM}
retval=$?
fi
/sbin/ipx_configure \
--auto_primary=${IPX_AUTO_PRIMARY} \
--auto_interface=${IPX_AUTO_INTERFACE}
retval=$(( $retval + $? ))
eend ${retval} "Failed to bring IPX up"
ebegin "Bringing IPX up"
/usr/libexec/ipx/network-start.sh
eend $? "Failed to bring IPX up"
}
stop() {
local retval=0
ebegin "Bringing IPX down"
/sbin/ipx_configure --auto_primary=off --auto_interface=off
retval=$?
/sbin/ipx_interface delall
retval=$(( $retval + $? ))
eend ${retval} "Failed to down IPX"
ebegin "Bringing IPX down"
/usr/libexec/ipx/network-stop.sh
eend $? "Failed to bring IPX down"
}

View File

@@ -1,84 +1,16 @@
# It's not recommended to modify this file in-place, because it will be
# overwritten during upgrades. If you want to customize, the best
# way is to use the "systemctl edit" command to create an override unit.
#
# For example, to pass additional options, create an override unit
# (as is done by systemctl edit) and enter the following:
#
# [Service]
# Environment=OPTIONS="-l 127.0.0.1,::1"
[Unit]
Description=IPX Network Config
After=network.target
Description=IPX network setup
Documentation=man:systemd.service(5)
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/ipx
ExecStart=/usr/bin/memcached -p ${PORT} -u ${USER} -m ${CACHESIZE} -c ${MAXCONN} $OPTIONS
# Set up a new file system namespace and mounts private /tmp and /var/tmp
# directories so this service cannot access the global directories and
# other processes cannot access this service's directories.
PrivateTmp=true
# Mounts the /usr, /boot, and /etc directories read-only for processes
# invoked by this unit.
ProtectSystem=full
# Ensures that the service process and all its children can never gain new
# privileges
NoNewPrivileges=true
# Sets up a new /dev namespace for the executed processes and only adds API
# pseudo devices such as /dev/null, /dev/zero or /dev/random (as well as
# the pseudo TTY subsystem) to it, but no physical devices such as /dev/sda.
PrivateDevices=true
# Required for dropping privileges and running as a different user
CapabilityBoundingSet=CAP_SETGID CAP_SETUID CAP_SYS_RESOURCE
# Restricts the set of socket address families accessible to the processes
# of this unit. Protects against vulnerabilities such as CVE-2016-8655
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
# Some security features are not in the older versions of systemd used by
# e.g. RHEL7/CentOS 7. The below settings are automatically edited at package
# build time to uncomment them if the target platform supports them.
# Attempts to create memory mappings that are writable and executable at
# the same time, or to change existing memory mappings to become executable
# are prohibited.
##safer##MemoryDenyWriteExecute=true
# Explicit module loading will be denied. This allows to turn off module
# load and unload operations on modular kernels. It is recommended to turn
# this on for most services that do not need special file systems or extra
# kernel modules to work.
##safer##ProtectKernelModules=true
# Kernel variables accessible through /proc/sys, /sys, /proc/sysrq-trigger,
# /proc/latency_stats, /proc/acpi, /proc/timer_stats, /proc/fs and /proc/irq
# will be made read-only to all processes of the unit. Usually, tunable
# kernel variables should only be written at boot-time, with the sysctl.d(5)
# mechanism. Almost no services need to write to these at runtime; it is hence
# recommended to turn this on for most services.
##safer##ProtectKernelTunables=true
# The Linux Control Groups (cgroups(7)) hierarchies accessible through
# /sys/fs/cgroup will be made read-only to all processes of the unit.
# Except for container managers no services should require write access
# to the control groups hierarchies; it is hence recommended to turn this
# on for most services
##safer##ProtectControlGroups=true
# Any attempts to enable realtime scheduling in a process of the unit are
# refused.
##safer##RestrictRealtime=true
# Takes away the ability to create or manage any kind of namespace
##safer##RestrictNamespaces=true
ExecStart=/usr/libexec/ipx/network-start.sh
ExecStop=/usr/libexec/ipx/network-stop.sh
ExecStopPost=/usr/libexec/ipx/network-stop.sh
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,176 @@
#!/bin/sh
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# IPX start helper for systemd and OpenRC.
#
# This script reads its configuration from environment variables, typically
# provided through /etc/conf.d/ipx.
#
# Manual interface format:
# <device>:<frame>:<netnum>
#
# Static route format:
# <target_network>:<router_network>:<router_node>
#
# Behaviour:
# - The first successfully configured interface becomes the primary IPX
# interface.
# - Missing interfaces are skipped.
# - Optionally, interfaces with no active link can also be skipped.
# - Static routes are added after interface configuration.
set -u
configured=0
retval=0
primary_set=0
log_warn() {
printf '%s\n' "ipx: $*" >&2
}
log_err() {
printf '%s\n' "ipx: $*" >&2
}
link_is_usable() {
local dev carrier_file operstate_file state
dev=$1
carrier_file="/sys/class/net/${dev}/carrier"
operstate_file="/sys/class/net/${dev}/operstate"
if [ "${IPX_SKIP_LINK_DOWN:-no}" != "yes" ]; then
return 0
fi
if [ -r "${carrier_file}" ]; then
state=$(cat "${carrier_file}")
if [ "${state}" = "0" ]; then
log_warn "interface ${dev} has no carrier, skipping"
return 1
fi
return 0
fi
if [ -r "${operstate_file}" ]; then
state=$(cat "${operstate_file}")
case "${state}" in
down)
log_warn "interface ${dev} is link-down, skipping"
return 1
;;
esac
fi
return 0
}
if [ "${IPX_INTERNAL_NET:-no}" = "yes" ]; then
if ! /sbin/ipx_internal_net add "${IPX_NETNUM}" "${IPX_NODENUM}"; then
log_err "failed to create internal IPX network"
retval=1
fi
else
oldifs=${IFS}
IFS='
'
for entry in ${IPX_INTERFACES:-}; do
[ -n "${entry}" ] || continue
case "${entry}" in
\#*)
continue
;;
esac
dev=${entry%%:*}
rest=${entry#*:}
frame=${rest%%:*}
netnum=${rest#*:}
if [ -z "${dev}" ] || [ -z "${frame}" ] || [ -z "${netnum}" ] || [ "${rest}" = "${entry}" ]; then
log_err "invalid IPX_INTERFACES entry: ${entry}"
retval=1
break
fi
if [ ! -d "/sys/class/net/${dev}" ]; then
log_warn "interface ${dev} is not present, skipping"
continue
fi
if ! link_is_usable "${dev}"; then
continue
fi
if [ "${primary_set}" -eq 0 ]; then
if /sbin/ipx_interface add -p "${dev}" "${frame}" "${netnum}"; then
configured=1
primary_set=1
else
log_err "failed to add primary IPX interface on ${dev}"
retval=1
fi
else
if /sbin/ipx_interface add "${dev}" "${frame}" "${netnum}"; then
configured=1
else
log_err "failed to add IPX interface on ${dev}"
retval=1
fi
fi
done
IFS=${oldifs}
if [ "${configured}" -eq 0 ] && [ "${retval}" -eq 0 ]; then
log_warn "no configured IPX interfaces were present"
fi
fi
if [ "${retval}" -eq 0 ]; then
oldifs=${IFS}
IFS='
'
for entry in ${IPX_ROUTES:-}; do
[ -n "${entry}" ] || continue
case "${entry}" in
\#*)
continue
;;
esac
target=${entry%%:*}
rest=${entry#*:}
router_net=${rest%%:*}
router_node=${rest#*:}
if [ -z "${target}" ] || [ -z "${router_net}" ] || [ -z "${router_node}" ] || [ "${rest}" = "${entry}" ]; then
log_err "invalid IPX_ROUTES entry: ${entry}"
retval=1
break
fi
if ! /sbin/ipx_route add "${target}" "${router_net}" "${router_node}"; then
log_err "failed to add IPX route to ${target}"
retval=1
fi
done
IFS=${oldifs}
fi
if ! /sbin/ipx_configure \
--auto_primary="${IPX_AUTO_PRIMARY}" \
--auto_interface="${IPX_AUTO_INTERFACE}"; then
log_err "failed to apply automatic IPX configuration"
retval=1
fi
if [ "${retval}" -ne 0 ]; then
log_warn "startup failed, cleaning up partial IPX configuration"
/usr/libexec/ipx/network-stop.sh || true
fi
exit "${retval}"

View File

@@ -0,0 +1,50 @@
#!/bin/sh
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# IPX stop helper for systemd and OpenRC.
#
# This script disables automatic IPX behaviour, removes configured static
# routes, removes all configured IPX interfaces and deletes the internal IPX
# network if present.
set -u
retval=0
oldifs=${IFS}
IFS='
'
for entry in ${IPX_ROUTES:-}; do
[ -n "${entry}" ] || continue
case "${entry}" in
\#*)
continue
;;
esac
target=${entry%%:*}
if ! /sbin/ipx_route del "${target}"; then
printf '%s\n' "ipx: failed to remove route to ${target}" >&2
retval=1
fi
done
IFS=${oldifs}
if ! /sbin/ipx_configure --auto_primary=off --auto_interface=off; then
printf '%s\n' "ipx: failed to disable automatic IPX configuration" >&2
retval=1
fi
if ! /sbin/ipx_interface delall; then
printf '%s\n' "ipx: failed to remove IPX interfaces" >&2
retval=1
fi
if ! /sbin/ipx_internal_net del; then
:
fi
exit "${retval}"