summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-protocols
diff options
context:
space:
mode:
authorTudor Florea <tudor.florea@enea.com>2015-10-08 22:51:41 +0200
committerTudor Florea <tudor.florea@enea.com>2015-10-08 22:51:41 +0200
commit1219bf8a90a7bf8cd3a5363551ef635d51e8fc8e (patch)
treea21a5fc103bb3bd65ecd85ed22be5228fc54e447 /meta-networking/recipes-protocols
downloadmeta-openembedded-1219bf8a90a7bf8cd3a5363551ef635d51e8fc8e.tar.gz
initial commit for Enea Linux 5.0 arm
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'meta-networking/recipes-protocols')
-rw-r--r--meta-networking/recipes-protocols/accel-ppp/accel-ppp_git.bb41
-rw-r--r--meta-networking/recipes-protocols/net-snmp/files/ifmib.patch66
-rwxr-xr-xmeta-networking/recipes-protocols/net-snmp/files/init63
-rw-r--r--meta-networking/recipes-protocols/net-snmp/files/snmpd.conf422
-rw-r--r--meta-networking/recipes-protocols/net-snmp/files/snmptrapd.conf18
-rw-r--r--meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Added-checks-for-printing-variables-with-wrong-types.patch455
-rw-r--r--meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service13
-rw-r--r--meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service13
-rw-r--r--meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch1618
-rw-r--r--meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb136
-rw-r--r--meta-networking/recipes-protocols/openflow/openflow.inc35
-rw-r--r--meta-networking/recipes-protocols/openflow/openflow_1.0.bb4
-rw-r--r--meta-networking/recipes-protocols/openflow/openflow_git.bb4
-rw-r--r--meta-networking/recipes-protocols/openl2tp/openl2tp/Makefile-modify-CFLAGS-to-aviod-build-error.patch106
-rw-r--r--meta-networking/recipes-protocols/openl2tp/openl2tp/openl2tp-simplify-gcc-warning-hack.patch41
-rw-r--r--meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb36
-rw-r--r--meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/fix-parallel-build.patch19
-rw-r--r--meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/options.pptp30
-rw-r--r--meta-networking/recipes-protocols/pptp-linux/pptp-linux_1.7.2.bb31
-rw-r--r--meta-networking/recipes-protocols/quagga/files/Zebra-sync-zebra-routing-table-with-the-kernel-one.patch48
-rw-r--r--meta-networking/recipes-protocols/quagga/files/babel-close-the-stdout-stderr-as-in-other-daemons.patch50
-rw-r--r--meta-networking/recipes-protocols/quagga/files/babeld.service14
-rw-r--r--meta-networking/recipes-protocols/quagga/files/bgpd.service14
-rw-r--r--meta-networking/recipes-protocols/quagga/files/isisd.service14
-rw-r--r--meta-networking/recipes-protocols/quagga/files/ospf6d.service14
-rw-r--r--meta-networking/recipes-protocols/quagga/files/ospfd.service14
-rw-r--r--meta-networking/recipes-protocols/quagga/files/quagga-Avoid-duplicate-connected-address.patch54
-rw-r--r--meta-networking/recipes-protocols/quagga/files/quagga.default13
-rw-r--r--meta-networking/recipes-protocols/quagga/files/quagga.init200
-rw-r--r--meta-networking/recipes-protocols/quagga/files/quagga.pam13
-rw-r--r--meta-networking/recipes-protocols/quagga/files/ripd-fix-two-bugs-after-received-SIGHUP.patch50
-rw-r--r--meta-networking/recipes-protocols/quagga/files/ripd.service14
-rw-r--r--meta-networking/recipes-protocols/quagga/files/ripngd.service14
-rw-r--r--meta-networking/recipes-protocols/quagga/files/volatiles.03_quagga3
-rw-r--r--meta-networking/recipes-protocols/quagga/files/watchquagga.default12
-rw-r--r--meta-networking/recipes-protocols/quagga/files/watchquagga.init64
-rw-r--r--meta-networking/recipes-protocols/quagga/files/zebra.service15
-rw-r--r--meta-networking/recipes-protocols/quagga/quagga.inc250
-rw-r--r--meta-networking/recipes-protocols/quagga/quagga_0.99.23.bb9
-rw-r--r--meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure.patch11
-rw-r--r--meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure_in_cross.patch142
-rw-r--r--meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/discard-use-of-dnl-in-Makefile.am.patch27
-rw-r--r--meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/dont-swallow-errors.patch15
-rw-r--r--meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.default22
-rwxr-xr-xmeta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.init59
-rw-r--r--meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-src-restrictions.patch20
-rw-r--r--meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/top-autoconf.patch27
-rw-r--r--meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/update-config.patch32
-rw-r--r--meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/use-ldflags.patch27
-rw-r--r--meta-networking/recipes-protocols/rp-pppoe/rp-pppoe_3.8.bb59
-rw-r--r--meta-networking/recipes-protocols/xl2tpd/xl2tpd.inc40
-rw-r--r--meta-networking/recipes-protocols/xl2tpd/xl2tpd_git.bb5
-rw-r--r--meta-networking/recipes-protocols/zeroconf/zeroconf/compilefix.patch19
-rw-r--r--meta-networking/recipes-protocols/zeroconf/zeroconf/debian-zeroconf51
-rw-r--r--meta-networking/recipes-protocols/zeroconf/zeroconf/zeroconf-default17
-rw-r--r--meta-networking/recipes-protocols/zeroconf/zeroconf_0.9.bb34
56 files changed, 4637 insertions, 0 deletions
diff --git a/meta-networking/recipes-protocols/accel-ppp/accel-ppp_git.bb b/meta-networking/recipes-protocols/accel-ppp/accel-ppp_git.bb
new file mode 100644
index 000000000..526818c05
--- /dev/null
+++ b/meta-networking/recipes-protocols/accel-ppp/accel-ppp_git.bb
@@ -0,0 +1,41 @@
1SUMMARY = "ACCEL-PPP is a high performance VPN server application for linux"
2HOMEPAGE = "http://sourceforge.net/apps/trac/accel-ppp/wiki"
3
4LICENSE = "GPLv2"
5LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a"
6
7DEPENDS = "openssl libpcre"
8
9inherit cmake
10
11PR = "r1"
12PV = "1.7.3+git"
13
14SRCREV = "4acfa46c321a344b9a6ce4128e72d1e02828d8a0"
15SRC_URI = "git://accel-ppp.git.sourceforge.net/gitroot/accel-ppp/accel-ppp;branch=1.7"
16
17S = "${WORKDIR}/git"
18
19EXTRA_OECMAKE = " \
20 -DBUILD_DRIVER=FALSE \
21 -DCMAKE_INSTALL_PREFIX=${prefix} \
22 -DCMAKE_BUILD_TYPE=Release \
23 -DLOG_PGSQL=FALSE \
24 -DRADIUS=FALSE \
25 -DNETSNMP=FALSE \
26"
27FILES_${PN}-dbg += "/usr/lib/${BPN}/.debug/*"
28
29PACKAGES =+ "${PN}-libs"
30FILES_${PN}-libs = "${libdir}/${BPN}/*.so /usr/lib/${BPN}/*.so"
31INSANE_SKIP_${PN}-libs = "dev-so"
32RDEPENDS_${PN} += "${PN}-libs"
33
34do_install_prepend() {
35 cmlist=`find ${S} -name CMakeLists.txt`
36 for file in $cmlist; do
37 sed -i -e "s:LIBRARY DESTINATION lib/accel-ppp:LIBRARY DESTINATION ${baselib}/accel-ppp:g" \
38 -e "s:\${CMAKE_INSTALL_PREFIX}/lib/accel-ppp:\${CMAKE_INSTALL_PREFIX}/${baselib}/accel-ppp:g" \
39 $cmlist
40 done
41}
diff --git a/meta-networking/recipes-protocols/net-snmp/files/ifmib.patch b/meta-networking/recipes-protocols/net-snmp/files/ifmib.patch
new file mode 100644
index 000000000..859c52c3e
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/files/ifmib.patch
@@ -0,0 +1,66 @@
1Signed-off-by: Jack Mitchell <jack@embed.me.uk>
2Upstream-Status: Pending
3Bug-Report: http://sourceforge.net/p/net-snmp/bugs/2449/
4
5diff --git a/agent/mibgroup/if-mib/data_access/interface_linux.c b/agent/mibgroup/if-mib/data_access/interface_linux.c
6index 3419811..d6eb91a 100644
7--- a/agent/mibgroup/if-mib/data_access/interface_linux.c
8+++ b/agent/mibgroup/if-mib/data_access/interface_linux.c
9@@ -18,7 +18,31 @@ netsnmp_feature_require(interface_ioctl_flags_set)
10
11 #ifdef HAVE_PCI_LOOKUP_NAME
12 #include <pci/pci.h>
13+#include <setjmp.h>
14 static struct pci_access *pci_access;
15+
16+/* Avoid letting libpci call exit(1) when no PCI bus is available. */
17+static int do_longjmp =0;
18+static jmp_buf err_buf;
19+static void
20+netsnmp_pci_error(char *msg, ...)
21+{
22+ va_list args;
23+ char *buf;
24+ int buflen;
25+
26+ va_start(args, msg);
27+ buflen = strlen("pcilib: ")+strlen(msg)+2;
28+ buf = malloc(buflen);
29+ snprintf(buf, buflen, "pcilib: %s\n", msg);
30+ snmp_vlog(LOG_ERR, buf, args);
31+ free(buf);
32+ va_end(args);
33+ if (do_longjmp)
34+ longjmp(err_buf, 1);
35+ else
36+ exit(1);
37+}
38 #endif
39
40 #ifdef HAVE_LINUX_ETHTOOL_H
41@@ -147,10 +171,22 @@ netsnmp_arch_interface_init(void)
42
43 #ifdef HAVE_PCI_LOOKUP_NAME
44 pci_access = pci_alloc();
45- if (pci_access)
46+ if (!pci_access) {
47+ snmp_log(LOG_ERR, "pcilib: pci_alloc failed\n");
48+ return;
49+ }
50+
51+ pci_access->error = netsnmp_pci_error;
52+
53+ do_longjmp = 1;
54+ if (setjmp(err_buf)) {
55+ pci_cleanup(pci_access);
56+ snmp_log(LOG_ERR, "pcilib: pci_init failed\n");
57+ pci_access = NULL;
58+ }
59+ else if (pci_access)
60 pci_init(pci_access);
61- else
62- snmp_log(LOG_ERR, "Unable to create pci access method\n");
63+ do_longjmp = 0;
64 #endif
65 }
66
diff --git a/meta-networking/recipes-protocols/net-snmp/files/init b/meta-networking/recipes-protocols/net-snmp/files/init
new file mode 100755
index 000000000..434b2fa3f
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/files/init
@@ -0,0 +1,63 @@
1#! /bin/sh
2# /etc/init.d/snmpd: start snmp daemon.
3
4test -x /usr/sbin/snmpd || exit 0
5test -x /usr/sbin/snmptrapd || exit 0
6
7# Defaults
8export MIBDIRS=/usr/share/snmp/mibs
9SNMPDRUN=yes
10SNMPDOPTS='-Lsd -Lf /dev/null -p /var/run/snmpd.pid'
11TRAPDRUN=no
12TRAPDOPTS='-Lsd -p /var/run/snmptrapd.pid'
13
14# Cd to / before starting any daemons.
15cd /
16
17case "$1" in
18 start)
19 echo -n "Starting network management services:"
20 if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
21 start-stop-daemon -S -x /usr/sbin/snmpd \
22 -- $SNMPDOPTS
23 echo -n " snmpd"
24 fi
25 if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
26 start-stop-daemon -S -x /usr/sbin/snmptrapd \
27 -- $TRAPDOPTS
28 echo -n " snmptrapd"
29 fi
30 echo "."
31 ;;
32 stop)
33 echo -n "Stopping network management services:"
34 start-stop-daemon -K -x /usr/sbin/snmpd
35 echo -n " snmpd"
36 start-stop-daemon -K -x /usr/sbin/snmptrapd
37 echo -n " snmptrapd"
38 echo "."
39 ;;
40 restart|reload|force-reload)
41 echo -n "Restarting network management services:"
42 start-stop-daemon -K -x /usr/sbin/snmpd
43 start-stop-daemon -K -x /usr/sbin/snmptrapd
44 # Allow the daemons time to exit completely.
45 sleep 2
46 if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
47 start-stop-daemon -S -x /usr/sbin/snmpd -- $SNMPDOPTS
48 echo -n " snmpd"
49 fi
50 if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
51 # Allow snmpd time to start up.
52 sleep 1
53 start-stop-daemon -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
54 echo -n " snmptrapd"
55 fi
56 echo "."
57 ;;
58 *)
59 echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}"
60 exit 1
61esac
62
63exit 0
diff --git a/meta-networking/recipes-protocols/net-snmp/files/snmpd.conf b/meta-networking/recipes-protocols/net-snmp/files/snmpd.conf
new file mode 100644
index 000000000..728171c42
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/files/snmpd.conf
@@ -0,0 +1,422 @@
1###############################################################################
2#
3# EXAMPLE.conf:
4# An example configuration file for configuring the ucd-snmp snmpd agent.
5#
6###############################################################################
7#
8# This file is intended to only be an example. If, however, you want
9# to use it, it should be placed in /etc/snmp/snmpd.conf.
10# When the snmpd agent starts up, this is where it will look for it.
11#
12# You might be interested in generating your own snmpd.conf file using
13# the "snmpconf" program (perl script) instead. It's a nice menu
14# based interface to writing well commented configuration files. Try it!
15#
16# Note: This file is automatically generated from EXAMPLE.conf.def.
17# Do NOT read the EXAMPLE.conf.def file! Instead, after you have run
18# configure & make, and then make sure you read the EXAMPLE.conf file
19# instead, as it will tailor itself to your configuration.
20
21# All lines beginning with a '#' are comments and are intended for you
22# to read. All other lines are configuration commands for the agent.
23
24#
25# PLEASE: read the snmpd.conf(5) manual page as well!
26#
27
28
29###############################################################################
30# Access Control
31###############################################################################
32
33# YOU SHOULD CHANGE THE "COMMUNITY" TOKEN BELOW TO A NEW KEYWORD ONLY
34# KNOWN AT YOUR SITE. YOU *MUST* CHANGE THE NETWORK TOKEN BELOW TO
35# SOMETHING REFLECTING YOUR LOCAL NETWORK ADDRESS SPACE.
36
37# By far, the most common question I get about the agent is "why won't
38# it work?", when really it should be "how do I configure the agent to
39# allow me to access it?"
40#
41# By default, the agent responds to the "public" community for read
42# only access, if run out of the box without any configuration file in
43# place. The following examples show you other ways of configuring
44# the agent so that you can change the community names, and give
45# yourself write access as well.
46#
47# The following lines change the access permissions of the agent so
48# that the COMMUNITY string provides read-only access to your entire
49# NETWORK (EG: 10.10.10.0/24), and read/write access to only the
50# localhost (127.0.0.1, not its real ipaddress).
51#
52# For more information, read the FAQ as well as the snmpd.conf(5)
53# manual page.
54
55####
56# First, map the community name (COMMUNITY) into a security name
57# (local and mynetwork, depending on where the request is coming
58# from):
59
60# sec.name source community
61com2sec paranoid default public
62#com2sec readonly default public
63#com2sec readwrite default private
64
65####
66# Second, map the security names into group names:
67
68# sec.model sec.name
69group MyROSystem v1 paranoid
70group MyROSystem v2c paranoid
71group MyROSystem usm paranoid
72group MyROGroup v1 readonly
73group MyROGroup v2c readonly
74group MyROGroup usm readonly
75group MyRWGroup v1 readwrite
76group MyRWGroup v2c readwrite
77group MyRWGroup usm readwrite
78
79####
80# Third, create a view for us to let the groups have rights to:
81
82# incl/excl subtree mask
83view all included .1 80
84view system included .iso.org.dod.internet.mgmt.mib-2.system
85
86####
87# Finally, grant the 2 groups access to the 1 view with different
88# write permissions:
89
90# context sec.model sec.level match read write notif
91access MyROSystem "" any noauth exact system none none
92access MyROGroup "" any noauth exact all none none
93access MyRWGroup "" any noauth exact all all none
94
95# -----------------------------------------------------------------------------
96
97
98###############################################################################
99# System contact information
100#
101
102# It is also possible to set the sysContact and sysLocation system
103# variables through the snmpd.conf file. **PLEASE NOTE** that setting
104# the value of these objects here makes these objects READ-ONLY
105# (regardless of any access control settings). Any attempt to set the
106# value of an object whose value is given here will fail with an error
107# status of notWritable.
108
109syslocation Unknown (configure /etc/snmp/snmpd.local.conf)
110syscontact Root <root@localhost> (configure /etc/snmp/snmpd.local.conf)
111
112# Example output of snmpwalk:
113# % snmpwalk -v 1 -c public localhost system
114# system.sysDescr.0 = "SunOS name sun4c"
115# system.sysObjectID.0 = OID: enterprises.ucdavis.ucdSnmpAgent.sunos4
116# system.sysUpTime.0 = Timeticks: (595637548) 68 days, 22:32:55
117# system.sysContact.0 = "Me <me@somewhere.org>"
118# system.sysName.0 = "name"
119# system.sysLocation.0 = "Right here, right now."
120# system.sysServices.0 = 72
121
122
123# -----------------------------------------------------------------------------
124
125
126###############################################################################
127# Process checks.
128#
129# The following are examples of how to use the agent to check for
130# processes running on the host. The syntax looks something like:
131#
132# proc NAME [MAX=0] [MIN=0]
133#
134# NAME: the name of the process to check for. It must match
135# exactly (ie, http will not find httpd processes).
136# MAX: the maximum number allowed to be running. Defaults to 0.
137# MIN: the minimum number to be running. Defaults to 0.
138
139#
140# Examples:
141#
142
143# Make sure mountd is running
144#proc mountd
145
146# Make sure there are no more than 4 ntalkds running, but 0 is ok too.
147#proc ntalkd 4
148
149# Make sure at least one sendmail, but less than or equal to 10 are running.
150#proc sendmail 10 1
151
152# A snmpwalk of the prTable would look something like this:
153#
154# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.2
155# enterprises.ucdavis.procTable.prEntry.prIndex.1 = 1
156# enterprises.ucdavis.procTable.prEntry.prIndex.2 = 2
157# enterprises.ucdavis.procTable.prEntry.prIndex.3 = 3
158# enterprises.ucdavis.procTable.prEntry.prNames.1 = "mountd"
159# enterprises.ucdavis.procTable.prEntry.prNames.2 = "ntalkd"
160# enterprises.ucdavis.procTable.prEntry.prNames.3 = "sendmail"
161# enterprises.ucdavis.procTable.prEntry.prMin.1 = 0
162# enterprises.ucdavis.procTable.prEntry.prMin.2 = 0
163# enterprises.ucdavis.procTable.prEntry.prMin.3 = 1
164# enterprises.ucdavis.procTable.prEntry.prMax.1 = 0
165# enterprises.ucdavis.procTable.prEntry.prMax.2 = 4
166# enterprises.ucdavis.procTable.prEntry.prMax.3 = 10
167# enterprises.ucdavis.procTable.prEntry.prCount.1 = 0
168# enterprises.ucdavis.procTable.prEntry.prCount.2 = 0
169# enterprises.ucdavis.procTable.prEntry.prCount.3 = 1
170# enterprises.ucdavis.procTable.prEntry.prErrorFlag.1 = 1
171# enterprises.ucdavis.procTable.prEntry.prErrorFlag.2 = 0
172# enterprises.ucdavis.procTable.prEntry.prErrorFlag.3 = 0
173# enterprises.ucdavis.procTable.prEntry.prErrMessage.1 = "No mountd process running."
174# enterprises.ucdavis.procTable.prEntry.prErrMessage.2 = ""
175# enterprises.ucdavis.procTable.prEntry.prErrMessage.3 = ""
176# enterprises.ucdavis.procTable.prEntry.prErrFix.1 = 0
177# enterprises.ucdavis.procTable.prEntry.prErrFix.2 = 0
178# enterprises.ucdavis.procTable.prEntry.prErrFix.3 = 0
179#
180# Note that the errorFlag for mountd is set to 1 because one is not
181# running (in this case an rpc.mountd is, but thats not good enough),
182# and the ErrMessage tells you what's wrong. The configuration
183# imposed in the snmpd.conf file is also shown.
184#
185# Special Case: When the min and max numbers are both 0, it assumes
186# you want a max of infinity and a min of 1.
187#
188
189
190# -----------------------------------------------------------------------------
191
192
193###############################################################################
194# Executables/scripts
195#
196
197#
198# You can also have programs run by the agent that return a single
199# line of output and an exit code. Here are two examples.
200#
201# exec NAME PROGRAM [ARGS ...]
202#
203# NAME: A generic name.
204# PROGRAM: The program to run. Include the path!
205# ARGS: optional arguments to be passed to the program
206
207# a simple hello world
208#exec echotest /bin/echo hello world
209
210# Run a shell script containing:
211#
212# #!/bin/sh
213# echo hello world
214# echo hi there
215# exit 35
216#
217# Note: this has been specifically commented out to prevent
218# accidental security holes due to someone else on your system writing
219# a /tmp/shtest before you do. Uncomment to use it.
220#
221#exec shelltest /bin/sh /tmp/shtest
222
223# Then,
224# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.8
225# enterprises.ucdavis.extTable.extEntry.extIndex.1 = 1
226# enterprises.ucdavis.extTable.extEntry.extIndex.2 = 2
227# enterprises.ucdavis.extTable.extEntry.extNames.1 = "echotest"
228# enterprises.ucdavis.extTable.extEntry.extNames.2 = "shelltest"
229# enterprises.ucdavis.extTable.extEntry.extCommand.1 = "/bin/echo hello world"
230# enterprises.ucdavis.extTable.extEntry.extCommand.2 = "/bin/sh /tmp/shtest"
231# enterprises.ucdavis.extTable.extEntry.extResult.1 = 0
232# enterprises.ucdavis.extTable.extEntry.extResult.2 = 35
233# enterprises.ucdavis.extTable.extEntry.extOutput.1 = "hello world."
234# enterprises.ucdavis.extTable.extEntry.extOutput.2 = "hello world."
235# enterprises.ucdavis.extTable.extEntry.extErrFix.1 = 0
236# enterprises.ucdavis.extTable.extEntry.extErrFix.2 = 0
237
238# Note that the second line of the /tmp/shtest shell script is cut
239# off. Also note that the exit status of 35 was returned.
240
241# -----------------------------------------------------------------------------
242
243
244###############################################################################
245# disk checks
246#
247
248# The agent can check the amount of available disk space, and make
249# sure it is above a set limit.
250
251# disk PATH [MIN=DEFDISKMINIMUMSPACE]
252#
253# PATH: mount path to the disk in question.
254# MIN: Disks with space below this value will have the Mib's errorFlag set.
255# Default value = DEFDISKMINIMUMSPACE.
256
257# Check the / partition and make sure it contains at least 10 megs.
258
259#disk / 10000
260
261# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.9
262# enterprises.ucdavis.diskTable.dskEntry.diskIndex.1 = 0
263# enterprises.ucdavis.diskTable.dskEntry.diskPath.1 = "/" Hex: 2F
264# enterprises.ucdavis.diskTable.dskEntry.diskDevice.1 = "/dev/dsk/c201d6s0"
265# enterprises.ucdavis.diskTable.dskEntry.diskMinimum.1 = 10000
266# enterprises.ucdavis.diskTable.dskEntry.diskTotal.1 = 837130
267# enterprises.ucdavis.diskTable.dskEntry.diskAvail.1 = 316325
268# enterprises.ucdavis.diskTable.dskEntry.diskUsed.1 = 437092
269# enterprises.ucdavis.diskTable.dskEntry.diskPercent.1 = 58
270# enterprises.ucdavis.diskTable.dskEntry.diskErrorFlag.1 = 0
271# enterprises.ucdavis.diskTable.dskEntry.diskErrorMsg.1 = ""
272
273# -----------------------------------------------------------------------------
274
275
276###############################################################################
277# load average checks
278#
279
280# load [1MAX=DEFMAXLOADAVE] [5MAX=DEFMAXLOADAVE] [15MAX=DEFMAXLOADAVE]
281#
282# 1MAX: If the 1 minute load average is above this limit at query
283# time, the errorFlag will be set.
284# 5MAX: Similar, but for 5 min average.
285# 15MAX: Similar, but for 15 min average.
286
287# Check for loads:
288#load 12 14 14
289
290# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.10
291# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.1 = 1
292# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.2 = 2
293# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.3 = 3
294# enterprises.ucdavis.loadTable.laEntry.loadaveNames.1 = "Load-1"
295# enterprises.ucdavis.loadTable.laEntry.loadaveNames.2 = "Load-5"
296# enterprises.ucdavis.loadTable.laEntry.loadaveNames.3 = "Load-15"
297# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.1 = "0.49" Hex: 30 2E 34 39
298# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.2 = "0.31" Hex: 30 2E 33 31
299# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.3 = "0.26" Hex: 30 2E 32 36
300# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.1 = "12.00"
301# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.2 = "14.00"
302# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.3 = "14.00"
303# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.1 = 0
304# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.2 = 0
305# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.3 = 0
306# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.1 = ""
307# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.2 = ""
308# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.3 = ""
309
310# -----------------------------------------------------------------------------
311
312
313###############################################################################
314# Extensible sections.
315#
316
317# This alleviates the multiple line output problem found in the
318# previous executable mib by placing each mib in its own mib table:
319
320# Run a shell script containing:
321#
322# #!/bin/sh
323# echo hello world
324# echo hi there
325# exit 35
326#
327# Note: this has been specifically commented out to prevent
328# accidental security holes due to someone else on your system writing
329# a /tmp/shtest before you do. Uncomment to use it.
330#
331# exec .1.3.6.1.4.1.2021.50 shelltest /bin/sh /tmp/shtest
332
333# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.50
334# enterprises.ucdavis.50.1.1 = 1
335# enterprises.ucdavis.50.2.1 = "shelltest"
336# enterprises.ucdavis.50.3.1 = "/bin/sh /tmp/shtest"
337# enterprises.ucdavis.50.100.1 = 35
338# enterprises.ucdavis.50.101.1 = "hello world."
339# enterprises.ucdavis.50.101.2 = "hi there."
340# enterprises.ucdavis.50.102.1 = 0
341
342# Now the Output has grown to two lines, and we can see the 'hi
343# there.' output as the second line from our shell script.
344#
345# Note that you must alter the mib.txt file to be correct if you want
346# the .50.* outputs above to change to reasonable text descriptions.
347
348# Other ideas:
349#
350# exec .1.3.6.1.4.1.2021.51 ps /bin/ps
351# exec .1.3.6.1.4.1.2021.52 top /usr/local/bin/top
352# exec .1.3.6.1.4.1.2021.53 mailq /usr/bin/mailq
353
354# -----------------------------------------------------------------------------
355
356
357###############################################################################
358# Pass through control.
359#
360
361# Usage:
362# pass MIBOID EXEC-COMMAND
363#
364# This will pass total control of the mib underneath the MIBOID
365# portion of the mib to the EXEC-COMMAND.
366#
367# Note: You'll have to change the path of the passtest script to your
368# source directory or install it in the given location.
369#
370# Example: (see the script for details)
371# (commented out here since it requires that you place the
372# script in the right location. (its not installed by default))
373
374# pass .1.3.6.1.4.1.2021.255 /bin/sh /usr/local/passtest
375
376# % snmpwalk -v 1 -c public localhost .1.3.6.1.4.1.2021.255
377# enterprises.ucdavis.255.1 = "life the universe and everything"
378# enterprises.ucdavis.255.2.1 = 42
379# enterprises.ucdavis.255.2.2 = OID: 42.42.42
380# enterprises.ucdavis.255.3 = Timeticks: (363136200) 42 days, 0:42:42
381# enterprises.ucdavis.255.4 = IpAddress: 127.0.0.1
382# enterprises.ucdavis.255.5 = 42
383# enterprises.ucdavis.255.6 = Gauge: 42
384#
385# % snmpget -v 1 -c public localhost .1.3.6.1.4.1.2021.255.5
386# enterprises.ucdavis.255.5 = 42
387#
388# % snmpset -v 1 -c public localhost .1.3.6.1.4.1.2021.255.1 s "New string"
389# enterprises.ucdavis.255.1 = "New string"
390#
391
392# For specific usage information, see the man/snmpd.conf.5 manual page
393# as well as the local/passtest script used in the above example.
394
395###############################################################################
396# Subagent control
397#
398
399# The agent can support subagents using a number of extension mechanisms.
400# From the 4.2.1 release, AgentX support is being compiled in by default.
401# However, this is still experimental code, so should not be used on
402# critical production systems.
403# Please see the file README.agentx for more details.
404#
405# If having read, marked, learnt and inwardly digested this information,
406# you decide that you do wish to make use of this mechanism, simply
407# uncomment the following directive.
408#
409# master agentx
410#
411# I repeat - this is *NOT* regarded as suitable for front-line production
412# systems, though it is probably stable enough for day-to-day use.
413# Probably.
414#
415# No refunds will be given.
416
417###############################################################################
418# Further Information
419#
420# See the snmpd.conf manual page, and the output of "snmpd -H".
421# MUCH more can be done with the snmpd.conf than is shown as an
422# example here.
diff --git a/meta-networking/recipes-protocols/net-snmp/files/snmptrapd.conf b/meta-networking/recipes-protocols/net-snmp/files/snmptrapd.conf
new file mode 100644
index 000000000..8d2e4375e
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/files/snmptrapd.conf
@@ -0,0 +1,18 @@
1###############################################################################
2#
3# EXAMPLE.conf:
4# An example configuration file for configuring the ucd-snmp snmptrapd agent.
5#
6###############################################################################
7#
8# This file is intended to only be an example. If, however, you want
9# to use it, it should be placed in /etc/snmp/snmptrapd.conf.
10# When the snmptrapd agent starts up, this is where it will look for it.
11#
12# All lines beginning with a '#' are comments and are intended for you
13# to read. All other lines are configuration commands for the agent.
14
15#
16# PLEASE: read the snmptrapd.conf(5) manual page as well!
17#
18
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Added-checks-for-printing-variables-with-wrong-types.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Added-checks-for-printing-variables-with-wrong-types.patch
new file mode 100644
index 000000000..30374cfe9
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-Added-checks-for-printing-variables-with-wrong-types.patch
@@ -0,0 +1,455 @@
1From 7f4a7b891332899cea26e95be0337aae01648742 Mon Sep 17 00:00:00 2001
2From: Jan Safranek <jsafranek@users.sourceforge.net>
3Date: Thu, 31 Jul 2014 13:46:49 +0200
4Subject: [PATCH] Added checks for printing variables with wrong types.
5
6Upstream-Status: Backport
7
8When -OQ command line argument is used, variable formatter preffers the type
9of the varible parsed from a MIB file instead of checking type of the variable
10as parsed from SNMP message.
11
12This can lead to crashes when incoming packets contains a variable with
13NULL type, while the MIB says the variable should be non-NULL, like Integer.
14The formatter then tries to interpret the NULL (from packet) as Integer (from
15MIB file).
16
17Signed-off-by: Jan Safranek <jsafranek@users.sourceforge.net>
18---
19 snmplib/mib.c | 270 ++++++++++++++++++++++++++++-----------------------------
20 1 file changed, 135 insertions(+), 135 deletions(-)
21
22diff --git a/snmplib/mib.c b/snmplib/mib.c
23index 9d3ca41..c6e0010 100644
24--- a/snmplib/mib.c
25+++ b/snmplib/mib.c
26@@ -439,17 +439,16 @@ sprint_realloc_octet_string(u_char ** buf, size_t * buf_len,
27 u_char *cp;
28 int output_format, cnt;
29
30- if ((var->type != ASN_OCTET_STR) &&
31- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
32- const char str[] = "Wrong Type (should be OCTET STRING): ";
33- if (snmp_cstrcat
34- (buf, buf_len, out_len, allow_realloc, str)) {
35- return sprint_realloc_by_type(buf, buf_len, out_len,
36+ if (var->type != ASN_OCTET_STR) {
37+ if (!netsnmp_ds_get_boolean(
38+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
39+ const char str[] = "Wrong Type (should be OCTET STRING): ";
40+ if (!snmp_cstrcat(buf, buf_len, out_len, allow_realloc, str))
41+ return 0;
42+ }
43+ return sprint_realloc_by_type(buf, buf_len, out_len,
44 allow_realloc, var, NULL, NULL,
45 NULL);
46- } else {
47- return 0;
48- }
49 }
50
51
52@@ -702,16 +701,16 @@ sprint_realloc_float(u_char ** buf, size_t * buf_len,
53 const struct enum_list *enums,
54 const char *hint, const char *units)
55 {
56- if ((var->type != ASN_OPAQUE_FLOAT) &&
57- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
58- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
59- "Wrong Type (should be Float): ")) {
60- return sprint_realloc_by_type(buf, buf_len, out_len,
61+ if (var->type != ASN_OPAQUE_FLOAT) {
62+ if (!netsnmp_ds_get_boolean(
63+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
64+ u_char str[] = "Wrong Type (should be Float): ";
65+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
66+ return 0;
67+ }
68+ return sprint_realloc_by_type(buf, buf_len, out_len,
69 allow_realloc, var, NULL, NULL,
70 NULL);
71- } else {
72- return 0;
73- }
74 }
75
76 if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
77@@ -772,17 +771,16 @@ sprint_realloc_double(u_char ** buf, size_t * buf_len,
78 const struct enum_list *enums,
79 const char *hint, const char *units)
80 {
81- if ((var->type != ASN_OPAQUE_DOUBLE) &&
82- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
83- if (snmp_cstrcat
84- (buf, buf_len, out_len, allow_realloc,
85- "Wrong Type (should be Double): ")) {
86- return sprint_realloc_by_type(buf, buf_len, out_len,
87+ if (var->type != ASN_OPAQUE_DOUBLE) {
88+ if (!netsnmp_ds_get_boolean(
89+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
90+ u_char str[] = "Wrong Type (should be Double): ";
91+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
92+ return 0;
93+ }
94+ return sprint_realloc_by_type(buf, buf_len, out_len,
95 allow_realloc, var, NULL, NULL,
96 NULL);
97- } else {
98- return 0;
99- }
100 }
101
102 if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
103@@ -847,20 +845,21 @@ sprint_realloc_counter64(u_char ** buf, size_t * buf_len, size_t * out_len,
104 {
105 char a64buf[I64CHARSZ + 1];
106
107- if ((var->type != ASN_COUNTER64
108+ if (var->type != ASN_COUNTER64
109 #ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
110 && var->type != ASN_OPAQUE_COUNTER64
111 && var->type != ASN_OPAQUE_I64 && var->type != ASN_OPAQUE_U64
112 #endif
113- ) && (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
114- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
115- "Wrong Type (should be Counter64): ")) {
116- return sprint_realloc_by_type(buf, buf_len, out_len,
117+ ) {
118+ if (!netsnmp_ds_get_boolean(
119+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
120+ u_char str[] = "Wrong Type (should be Counter64): ";
121+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
122+ return 0;
123+ }
124+ return sprint_realloc_by_type(buf, buf_len, out_len,
125 allow_realloc, var, NULL, NULL,
126 NULL);
127- } else {
128- return 0;
129- }
130 }
131
132 if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
133@@ -948,23 +947,25 @@ sprint_realloc_opaque(u_char ** buf, size_t * buf_len,
134 const struct enum_list *enums,
135 const char *hint, const char *units)
136 {
137- if ((var->type != ASN_OPAQUE
138+ if (var->type != ASN_OPAQUE
139 #ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
140 && var->type != ASN_OPAQUE_COUNTER64
141 && var->type != ASN_OPAQUE_U64
142 && var->type != ASN_OPAQUE_I64
143 && var->type != ASN_OPAQUE_FLOAT && var->type != ASN_OPAQUE_DOUBLE
144 #endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
145- ) && (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
146- if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
147- "Wrong Type (should be Opaque): ")) {
148- return sprint_realloc_by_type(buf, buf_len, out_len,
149+ ) {
150+ if (!netsnmp_ds_get_boolean(
151+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
152+ u_char str[] = "Wrong Type (should be Opaque): ";
153+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
154+ return 0;
155+ }
156+ return sprint_realloc_by_type(buf, buf_len, out_len,
157 allow_realloc, var, NULL, NULL,
158 NULL);
159- } else {
160- return 0;
161- }
162 }
163+
164 #ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
165 switch (var->type) {
166 case ASN_OPAQUE_COUNTER64:
167@@ -1040,17 +1041,16 @@ sprint_realloc_object_identifier(u_char ** buf, size_t * buf_len,
168 {
169 int buf_overflow = 0;
170
171- if ((var->type != ASN_OBJECT_ID) &&
172- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
173- u_char str[] =
174- "Wrong Type (should be OBJECT IDENTIFIER): ";
175- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
176- return sprint_realloc_by_type(buf, buf_len, out_len,
177+ if (var->type != ASN_OBJECT_ID) {
178+ if (!netsnmp_ds_get_boolean(
179+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
180+ u_char str[] = "Wrong Type (should be OBJECT IDENTIFIER): ";
181+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
182+ return 0;
183+ }
184+ return sprint_realloc_by_type(buf, buf_len, out_len,
185 allow_realloc, var, NULL, NULL,
186 NULL);
187- } else {
188- return 0;
189- }
190 }
191
192 if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
193@@ -1110,16 +1110,16 @@ sprint_realloc_timeticks(u_char ** buf, size_t * buf_len, size_t * out_len,
194 {
195 char timebuf[40];
196
197- if ((var->type != ASN_TIMETICKS) &&
198- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
199- u_char str[] = "Wrong Type (should be Timeticks): ";
200- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
201- return sprint_realloc_by_type(buf, buf_len, out_len,
202+ if (var->type != ASN_TIMETICKS) {
203+ if (!netsnmp_ds_get_boolean(
204+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
205+ u_char str[] = "Wrong Type (should be Timeticks): ";
206+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
207+ return 0;
208+ }
209+ return sprint_realloc_by_type(buf, buf_len, out_len,
210 allow_realloc, var, NULL, NULL,
211 NULL);
212- } else {
213- return 0;
214- }
215 }
216
217 if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_NUMERIC_TIMETICKS)) {
218@@ -1277,17 +1277,18 @@ sprint_realloc_integer(u_char ** buf, size_t * buf_len, size_t * out_len,
219 {
220 char *enum_string = NULL;
221
222- if ((var->type != ASN_INTEGER) &&
223- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
224- u_char str[] = "Wrong Type (should be INTEGER): ";
225- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
226- return sprint_realloc_by_type(buf, buf_len, out_len,
227+ if (var->type != ASN_INTEGER) {
228+ if (!netsnmp_ds_get_boolean(
229+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
230+ u_char str[] = "Wrong Type (should be INTEGER): ";
231+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
232+ return 0;
233+ }
234+ return sprint_realloc_by_type(buf, buf_len, out_len,
235 allow_realloc, var, NULL, NULL,
236 NULL);
237- } else {
238- return 0;
239- }
240 }
241+
242 for (; enums; enums = enums->next) {
243 if (enums->value == *var->val.integer) {
244 enum_string = enums->label;
245@@ -1380,16 +1381,16 @@ sprint_realloc_uinteger(u_char ** buf, size_t * buf_len, size_t * out_len,
246 {
247 char *enum_string = NULL;
248
249- if ((var->type != ASN_UINTEGER) &&
250- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
251- u_char str[] = "Wrong Type (should be UInteger32): ";
252- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
253- return sprint_realloc_by_type(buf, buf_len, out_len,
254+ if (var->type != ASN_UINTEGER) {
255+ if (!netsnmp_ds_get_boolean(
256+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
257+ u_char str[] = "Wrong Type (should be UInteger32): ";
258+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
259+ return 0;
260+ }
261+ return sprint_realloc_by_type(buf, buf_len, out_len,
262 allow_realloc, var, NULL, NULL,
263 NULL);
264- } else {
265- return 0;
266- }
267 }
268
269 for (; enums; enums = enums->next) {
270@@ -1477,17 +1478,16 @@ sprint_realloc_gauge(u_char ** buf, size_t * buf_len, size_t * out_len,
271 {
272 char tmp[32];
273
274- if ((var->type != ASN_GAUGE) &&
275- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
276- u_char str[] =
277- "Wrong Type (should be Gauge32 or Unsigned32): ";
278- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
279- return sprint_realloc_by_type(buf, buf_len, out_len,
280+ if (var->type != ASN_GAUGE) {
281+ if (!netsnmp_ds_get_boolean(
282+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
283+ u_char str[] = "Wrong Type (should be Gauge32 or Unsigned32): ";
284+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
285+ return 0;
286+ }
287+ return sprint_realloc_by_type(buf, buf_len, out_len,
288 allow_realloc, var, NULL, NULL,
289 NULL);
290- } else {
291- return 0;
292- }
293 }
294
295 if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
296@@ -1550,16 +1550,16 @@ sprint_realloc_counter(u_char ** buf, size_t * buf_len, size_t * out_len,
297 {
298 char tmp[32];
299
300- if ((var->type != ASN_COUNTER) &&
301- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
302- u_char str[] = "Wrong Type (should be Counter32): ";
303- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
304- return sprint_realloc_by_type(buf, buf_len, out_len,
305+ if (var->type != ASN_COUNTER) {
306+ if (!netsnmp_ds_get_boolean(
307+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
308+ u_char str[] = "Wrong Type (should be Counter32): ";
309+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
310+ return 0;
311+ }
312+ return sprint_realloc_by_type(buf, buf_len, out_len,
313 allow_realloc, var, NULL, NULL,
314 NULL);
315- } else {
316- return 0;
317- }
318 }
319
320 if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
321@@ -1613,16 +1613,16 @@ sprint_realloc_networkaddress(u_char ** buf, size_t * buf_len,
322 {
323 size_t i;
324
325- if ((var->type != ASN_IPADDRESS) &&
326- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
327- u_char str[] = "Wrong Type (should be NetworkAddress): ";
328- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
329- return sprint_realloc_by_type(buf, buf_len, out_len,
330+ if (var->type != ASN_IPADDRESS) {
331+ if (!netsnmp_ds_get_boolean(
332+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
333+ u_char str[] = "Wrong Type (should be NetworkAddress): ";
334+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
335+ return 0;
336+ }
337+ return sprint_realloc_by_type(buf, buf_len, out_len,
338 allow_realloc, var, NULL, NULL,
339 NULL);
340- } else {
341- return 0;
342- }
343 }
344
345 if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
346@@ -1679,16 +1679,16 @@ sprint_realloc_ipaddress(u_char ** buf, size_t * buf_len, size_t * out_len,
347 {
348 u_char *ip = var->val.string;
349
350- if ((var->type != ASN_IPADDRESS) &&
351- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
352- u_char str[] = "Wrong Type (should be IpAddress): ";
353- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
354- return sprint_realloc_by_type(buf, buf_len, out_len,
355+ if (var->type != ASN_IPADDRESS) {
356+ if (!netsnmp_ds_get_boolean(
357+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
358+ u_char str[] = "Wrong Type (should be IpAddress): ";
359+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
360+ return 0;
361+ }
362+ return sprint_realloc_by_type(buf, buf_len, out_len,
363 allow_realloc, var, NULL, NULL,
364 NULL);
365- } else {
366- return 0;
367- }
368 }
369
370 if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
371@@ -1737,20 +1737,20 @@ sprint_realloc_null(u_char ** buf, size_t * buf_len, size_t * out_len,
372 const struct enum_list *enums,
373 const char *hint, const char *units)
374 {
375- if ((var->type != ASN_NULL) &&
376- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
377- u_char str[] = "Wrong Type (should be NULL): ";
378- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
379- return sprint_realloc_by_type(buf, buf_len, out_len,
380+ if (var->type != ASN_NULL) {
381+ if (!netsnmp_ds_get_boolean(
382+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
383+ u_char str[] = "Wrong Type (should be NULL): ";
384+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
385+ return 0;
386+ }
387+ return sprint_realloc_by_type(buf, buf_len, out_len,
388 allow_realloc, var, NULL, NULL,
389 NULL);
390- } else {
391- return 0;
392- }
393- } else {
394- u_char str[] = "NULL";
395- return snmp_strcat(buf, buf_len, out_len, allow_realloc, str);
396 }
397+
398+ u_char str[] = "NULL";
399+ return snmp_strcat(buf, buf_len, out_len, allow_realloc, str);
400 }
401
402
403@@ -1785,16 +1785,16 @@ sprint_realloc_bitstring(u_char ** buf, size_t * buf_len, size_t * out_len,
404 u_char *cp;
405 char *enum_string;
406
407- if ((var->type != ASN_BIT_STR && var->type != ASN_OCTET_STR) &&
408- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
409- u_char str[] = "Wrong Type (should be BITS): ";
410- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
411- return sprint_realloc_by_type(buf, buf_len, out_len,
412+ if (var->type != ASN_BIT_STR && var->type != ASN_OCTET_STR) {
413+ if (!netsnmp_ds_get_boolean(
414+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
415+ u_char str[] = "Wrong Type (should be BITS): ";
416+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
417+ return 0;
418+ }
419+ return sprint_realloc_by_type(buf, buf_len, out_len,
420 allow_realloc, var, NULL, NULL,
421 NULL);
422- } else {
423- return 0;
424- }
425 }
426
427 if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
428@@ -1869,16 +1869,16 @@ sprint_realloc_nsapaddress(u_char ** buf, size_t * buf_len,
429 const struct enum_list *enums, const char *hint,
430 const char *units)
431 {
432- if ((var->type != ASN_NSAP) &&
433- (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
434- u_char str[] = "Wrong Type (should be NsapAddress): ";
435- if (snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
436- return sprint_realloc_by_type(buf, buf_len, out_len,
437+ if (var->type != ASN_NSAP) {
438+ if (!netsnmp_ds_get_boolean(
439+ NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT)) {
440+ u_char str[] = "Wrong Type (should be NsapAddress): ";
441+ if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str))
442+ return 0;
443+ }
444+ return sprint_realloc_by_type(buf, buf_len, out_len,
445 allow_realloc, var, NULL, NULL,
446 NULL);
447- } else {
448- return 0;
449- }
450 }
451
452 if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
453--
4541.7.10.4
455
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service b/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service
new file mode 100644
index 000000000..10a1eb212
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/snmpd.service
@@ -0,0 +1,13 @@
1[Unit]
2Description=Simple Network Management Protocol (SNMP) Daemon.
3After=syslog.target network.target
4
5[Service]
6Type=notify
7Environment=OPTIONS="-LS0-6d"
8EnvironmentFile=-/etc/default/snmpd
9ExecStart=/usr/sbin/snmpd $OPTIONS -f
10ExecReload=/bin/kill -HUP $MAINPID
11
12[Install]
13WantedBy=multi-user.target
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service b/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service
new file mode 100644
index 000000000..951f9f270
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/snmptrapd.service
@@ -0,0 +1,13 @@
1[Unit]
2Description=Simple Network Management Protocol (SNMP) Trap Daemon.
3After=syslog.target network.target
4
5[Service]
6Type=notify
7Environment=OPTIONS="-Lsd"
8EnvironmentFile=-/etc/default/snmptrapd
9ExecStart=/usr/sbin/snmptrapd $OPTIONS -f
10ExecReload=/bin/kill -HUP $MAINPID
11
12[Install]
13WantedBy=multi-user.target
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch b/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch
new file mode 100644
index 000000000..e19153bbc
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp/systemd-support.patch
@@ -0,0 +1,1618 @@
1Systemd support backported from the master branch as of 23/04/2012 (post 5.7.1, pre 5.8).
2
3The following commits have been cherry-picked:
4
519499c3c90bf9d7b2b9e5d08baa26cc6bba28a11
6fef6cddfdb94da1a6b1fb768af62918b80f11fd3
70641e43c694c485cbbffef0556efc4641bd3ff50
876530a89f1c8bbd0b63acce63e10d5d4812a1a16 (conflict resolved)
9bf108d7f1354f6276fc43c129963f2c49b9fc242
103692875172352f72cf3afd0d35f355e83d7e421b
1174412748067c685e1d8ab6ed3bcc3ca9c2774844
1286132e3f1e6ef7b4e0b96d8fa24e37c81b71b0e0
1363557cf8986a33dba1d4429b583a901361052c4f
14
15Upstream-Status: Backport
16
17Signed-off-by: Thomas Fitzsimmons <fitzsim@cisco.com>
18diff --git a/README.systemd b/README.systemd
19new file mode 100644
20index 0000000..f731851
21--- /dev/null
22+++ b/README.systemd
23@@ -0,0 +1,41 @@
24+README.systemd
25+--------------
26+Net-SNMP provides two daemons, which support systemd system manager.
27+See http://www.freedesktop.org/wiki/Software/systemd to learn how
28+systemd works. Both socket activation and notification is supported by these
29+daemons.
30+
31+To enable systemd support, the sources must be compiled with
32+--with-systemd configure option.
33+
34+snmpd - The SNMP agent
35+----------------------
36+Socket activation od snmpd daemon is implemented, but it's discouraged.
37+The reason is simple - snmpd not only listens and processes SNMP requests
38+from network, but also gathers system statistics counters, sends traps and
39+communicates with subagents. It even opens few netlink sockets.
40+
41+In other words, snmpd should run from system start to properly work.
42+This can be done in two ways:
43+1) either as snmpd service unit with 'Type=notification' and without a socket
44+ unit
45+2) or as snmpd service unit with 'Type=simple', appropriate socket socket unit
46+ and the snmpd service enabled. This way systemd creates the snmpd listening
47+ socket early during boot and passes the sockets to snmpd slightly later
48+ (but still during machine boot). This way systemd can paralelize start of
49+ services, which depend on snmpd. Admins must adjust the socket file manually,
50+ depending if the snmpd support AgentX, IPv6, SMUX etc.
51+
52+snmpd should be started with '-f' command line parameter to disable forking -
53+systemd does that for us automatically.
54+
55+
56+snmptrapd - The trap processing daemon
57+--------------------------------------
58+snmptrapd supports full socket activation and also notification (if needed).
59+Both 'Type=simple' (with appropriate socket unit) and 'Type=notify' services
60+will work. Again, '-f' parameter should be provided on snmptrapd command line.
61+
62+If integration with SNMP agent using AgentX protocol is enabled, snmptrapd should
63+start during boot and not after first SNMP trap arrives. Same rules as for snmpd
64+applies then.
65\ No newline at end of file
66diff --git a/agent/snmpd.c b/agent/snmpd.c
67index b177d5b..08bdfc7 100644
68--- a/agent/snmpd.c
69+++ b/agent/snmpd.c
70@@ -164,6 +164,10 @@ typedef long fd_mask;
71
72 #endif
73
74+#ifndef NETSNMP_NO_SYSTEMD
75+#include <net-snmp/library/sd-daemon.h>
76+#endif
77+
78 netsnmp_feature_want(logging_file)
79 netsnmp_feature_want(logging_stdio)
80 netsnmp_feature_want(logging_syslog)
81@@ -441,18 +445,28 @@ main(int argc, char *argv[])
82 int agent_mode = -1;
83 char *pid_file = NULL;
84 char option_compatability[] = "-Le";
85+#ifndef WIN32
86+ int prepared_sockets = 0;
87+#endif
88 #if HAVE_GETPID
89 int fd;
90 FILE *PID;
91 #endif
92
93 #ifndef WIN32
94+#ifndef NETSNMP_NO_SYSTEMD
95+ /* check if systemd has sockets for us and don't close them */
96+ prepared_sockets = netsnmp_sd_listen_fds(0);
97+#endif /* NETSNMP_NO_SYSTEMD */
98+
99 /*
100 * close all non-standard file descriptors we may have
101 * inherited from the shell.
102 */
103- for (i = getdtablesize() - 1; i > 2; --i) {
104- (void) close(i);
105+ if (!prepared_sockets) {
106+ for (i = getdtablesize() - 1; i > 2; --i) {
107+ (void) close(i);
108+ }
109 }
110 #endif /* #WIN32 */
111
112@@ -1100,6 +1114,19 @@ main(int argc, char *argv[])
113 netsnmp_addrcache_initialise();
114
115 /*
116+ * Let systemd know we're up.
117+ */
118+#ifndef NETSNMP_NO_SYSTEMD
119+ netsnmp_sd_notify(1, "READY=1\n");
120+ if (prepared_sockets)
121+ /*
122+ * Clear the environment variable, we already processed all the sockets
123+ * by now.
124+ */
125+ netsnmp_sd_listen_fds(1);
126+#endif
127+
128+ /*
129 * Forever monitor the dest_port for incoming PDUs.
130 */
131 DEBUGMSGTL(("snmpd/main", "We're up. Starting to process data.\n"));
132diff --git a/apps/snmptrapd.c b/apps/snmptrapd.c
133index 1a52080..0857ae1 100644
134--- a/apps/snmptrapd.c
135+++ b/apps/snmptrapd.c
136@@ -125,6 +125,10 @@ SOFTWARE.
137
138 #include <net-snmp/net-snmp-features.h>
139
140+#ifndef NETSNMP_NO_SYSTEMD
141+#include <net-snmp/library/sd-daemon.h>
142+#endif
143+
144 #ifndef BSD4_3
145 #define BSD4_2
146 #endif
147@@ -655,15 +659,24 @@ main(int argc, char *argv[])
148 int agentx_subagent = 1;
149 #endif
150 netsnmp_trapd_handler *traph;
151+#ifndef WIN32
152+ int prepared_sockets = 0;
153+#endif
154
155
156 #ifndef WIN32
157+#ifndef NETSNMP_NO_SYSTEMD
158+ /* check if systemd has sockets for us and don't close them */
159+ prepared_sockets = netsnmp_sd_listen_fds(0);
160+#endif
161 /*
162 * close all non-standard file descriptors we may have
163 * inherited from the shell.
164 */
165- for (i = getdtablesize() - 1; i > 2; --i) {
166- (void) close(i);
167+ if (!prepared_sockets) {
168+ for (i = getdtablesize() - 1; i > 2; --i) {
169+ (void) close(i);
170+ }
171 }
172 #endif /* #WIN32 */
173
174@@ -1311,6 +1324,19 @@ main(int argc, char *argv[])
175 #endif
176 #endif
177
178+ /*
179+ * Let systemd know we're up.
180+ */
181+#ifndef NETSNMP_NO_SYSTEMD
182+ netsnmp_sd_notify(1, "READY=1\n");
183+ if (prepared_sockets)
184+ /*
185+ * Clear the environment variable, we already processed all the sockets
186+ * by now.
187+ */
188+ netsnmp_sd_listen_fds(1);
189+#endif
190+
191 #ifdef WIN32SERVICE
192 trapd_status = SNMPTRAPD_RUNNING;
193 #endif
194diff --git a/configure.d/config_modules_lib b/configure.d/config_modules_lib
195index b6609c1..5849072 100644
196--- a/configure.d/config_modules_lib
197+++ b/configure.d/config_modules_lib
198@@ -53,6 +53,14 @@ if test "x$PARTIALTARGETOS" = "xmingw32" -o "x$PARTIALTARGETOS" = "xmingw32msvc"
199 other_ftobjs_list="$other_ftobjs_list winpipe.ft"
200 fi
201
202+# Linux systemd
203+if test "x$with_systemd" == "xyes"; then
204+ other_src_list="$other_src_list sd-daemon.c"
205+ other_objs_list="$other_objs_list sd-daemon.o"
206+ other_lobjs_list="$other_lobjs_list sd-daemon.lo"
207+ other_ftobjs_list="$other_ftobjs_list sd-daemon.ft"
208+fi
209+
210 AC_SUBST(other_src_list)
211 AC_SUBST(other_objs_list)
212 AC_SUBST(other_lobjs_list)
213diff --git a/configure.d/config_project_with_enable b/configure.d/config_project_with_enable
214index 8b46ad2..59d6d5c 100644
215--- a/configure.d/config_project_with_enable
216+++ b/configure.d/config_project_with_enable
217@@ -689,6 +689,15 @@ if test "x$with_dummy_values" != "xyes"; then
218 data for])
219 fi
220
221+NETSNMP_ARG_WITH(systemd,
222+[ --with-systemd Provide systemd support. See README.systemd
223+ for details.])
224+# Define unless specifically suppressed (i.e., option defaults to false).
225+if test "x$with_systemd" != "xyes"; then
226+ AC_DEFINE(NETSNMP_NO_SYSTEMD, 1,
227+ [If you don't want to integrate with systemd.])
228+fi
229+
230 NETSNMP_ARG_ENABLE(set-support,
231 [ --disable-set-support Do not allow SNMP set requests.])
232 if test "x$enable_set_support" = "xno"; then
233diff --git a/dist/snmpd.service b/dist/snmpd.service
234new file mode 100644
235index 0000000..31391e5
236--- /dev/null
237+++ b/dist/snmpd.service
238@@ -0,0 +1,18 @@
239+#
240+# SNMP agent service file for systemd
241+#
242+#
243+# The service should be enabled, i.e. snmpd should start during machine boot.
244+# Socket activation shall not be used. See README.systemd for details.
245+
246+[Unit]
247+Description=Simple Network Management Protocol (SNMP) daemon.
248+After=syslog.target network.target
249+
250+[Service]
251+# Type=notify is also supported. It should be set when snmpd.socket is not used.
252+Type=simple
253+ExecStart=/usr/sbin/snmpd -f
254+
255+[Install]
256+WantedBy=multi-user.target
257diff --git a/dist/snmpd.socket b/dist/snmpd.socket
258new file mode 100644
259index 0000000..7f3a2d9
260--- /dev/null
261+++ b/dist/snmpd.socket
262@@ -0,0 +1,17 @@
263+[Unit]
264+Description=Socket listening for SNMP and AgentX messages
265+
266+[Socket]
267+ListenDatagram=0.0.0.0:161
268+# Uncomment other listening addresses as needed - TCP, UDP6, TCP6.
269+# It must match listening addresses/ports defined in snmpd.service
270+# or snmpd.conf.
271+# ListenStream=0.0.0.0:161
272+# ListenDatagram=[::]:161
273+# ListenStream=[::]:161
274+#
275+# Uncomment AgentX socket if snmpd.conf enables AgentX protocol.
276+# ListenStream=/var/agentx/master
277+
278+[Install]
279+WantedBy=sockets.target
280diff --git a/dist/snmptrapd.service b/dist/snmptrapd.service
281new file mode 100644
282index 0000000..e88a5b4
283--- /dev/null
284+++ b/dist/snmptrapd.service
285@@ -0,0 +1,16 @@
286+#
287+# SNMP trap-processing service file for systemd
288+#
289+
290+[Unit]
291+Description=Simple Network Management Protocol (SNMP) Trap daemon.
292+After=syslog.target network.target
293+
294+[Service]
295+# Type=notify is also supported. It should be set when snmptrapd.socket is not
296+# used.
297+Type=simple
298+ExecStart=/usr/sbin/snmptrapd -f
299+
300+[Install]
301+WantedBy=multi-user.target
302diff --git a/dist/snmptrapd.socket b/dist/snmptrapd.socket
303new file mode 100644
304index 0000000..0fc8a7c
305--- /dev/null
306+++ b/dist/snmptrapd.socket
307@@ -0,0 +1,14 @@
308+[Unit]
309+Description=Socket listening for SNMP trap messages
310+
311+[Socket]
312+ListenDatagram=0.0.0.0:162
313+# Uncomment other listening addresses as needed - TCP, UDP6, TCP6.
314+# It must match listening addresses/ports defined in snmptrapd.service
315+# or snmptrapd.conf.
316+# ListenStream=0.0.0.0:162
317+# ListenDatagram=[::]:162
318+# ListenStream=[::]:162
319+
320+[Install]
321+WantedBy=sockets.target
322diff --git a/include/net-snmp/library/sd-daemon.h b/include/net-snmp/library/sd-daemon.h
323new file mode 100644
324index 0000000..85274c9
325--- /dev/null
326+++ b/include/net-snmp/library/sd-daemon.h
327@@ -0,0 +1,290 @@
328+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
329+
330+#ifndef SNMPD_SD_DAEMON_H
331+#define SNMPD_SD_DAEMON_H
332+
333+/***
334+ Copyright 2010 Lennart Poettering
335+
336+ Permission is hereby granted, free of charge, to any person
337+ obtaining a copy of this software and associated documentation files
338+ (the "Software"), to deal in the Software without restriction,
339+ including without limitation the rights to use, copy, modify, merge,
340+ publish, distribute, sublicense, and/or sell copies of the Software,
341+ and to permit persons to whom the Software is furnished to do so,
342+ subject to the following conditions:
343+
344+ The above copyright notice and this permission notice shall be
345+ included in all copies or substantial portions of the Software.
346+
347+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
348+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
349+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
350+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
351+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
352+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
353+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
354+ SOFTWARE.
355+***/
356+
357+#ifdef HAVE_SYS_TYPES_H
358+#include <sys/types.h>
359+#endif
360+#ifdef HAVE_INTTYPES_H
361+#include <inttypes.h>
362+#endif
363+
364+#ifdef __cplusplus
365+extern "C" {
366+#endif
367+
368+/*
369+ Reference implementation of a few systemd related interfaces for
370+ writing daemons. These interfaces are trivial to implement. To
371+ simplify porting we provide this reference implementation.
372+ Applications are welcome to reimplement the algorithms described
373+ here if they do not want to include these two source files.
374+
375+ The following functionality is provided:
376+
377+ - Support for logging with log levels on stderr
378+ - File descriptor passing for socket-based activation
379+ - Daemon startup and status notification
380+ - Detection of systemd boots
381+
382+ You may compile this with -DDISABLE_SYSTEMD to disable systemd
383+ support. This makes all those calls NOPs that are directly related to
384+ systemd (i.e. only sd_is_xxx() will stay useful).
385+
386+ Since this is drop-in code we don't want any of our symbols to be
387+ exported in any case. Hence we declare hidden visibility for all of
388+ them.
389+
390+ You may find an up-to-date version of these source files online:
391+
392+ http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.h
393+ http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c
394+
395+ This should compile on non-Linux systems, too, but with the
396+ exception of the sd_is_xxx() calls all functions will become NOPs.
397+
398+ See sd-daemon(7) for more information.
399+*/
400+
401+#ifndef _sd_printf_attr_
402+#if __GNUC__ >= 4
403+#define _sd_printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
404+#else
405+#define _sd_printf_attr_(a,b)
406+#endif
407+#endif
408+
409+/*
410+ Log levels for usage on stderr:
411+
412+ fprintf(stderr, SD_NOTICE "Hello World!\n");
413+
414+ This is similar to printk() usage in the kernel.
415+*/
416+#define SD_EMERG "<0>" /* system is unusable */
417+#define SD_ALERT "<1>" /* action must be taken immediately */
418+#define SD_CRIT "<2>" /* critical conditions */
419+#define SD_ERR "<3>" /* error conditions */
420+#define SD_WARNING "<4>" /* warning conditions */
421+#define SD_NOTICE "<5>" /* normal but significant condition */
422+#define SD_INFO "<6>" /* informational */
423+#define SD_DEBUG "<7>" /* debug-level messages */
424+
425+/* The first passed file descriptor is fd 3 */
426+#define SD_LISTEN_FDS_START 3
427+
428+/*
429+ Returns how many file descriptors have been passed, or a negative
430+ errno code on failure. Optionally, removes the $LISTEN_FDS and
431+ $LISTEN_PID file descriptors from the environment (recommended, but
432+ problematic in threaded environments). If r is the return value of
433+ this function you'll find the file descriptors passed as fds
434+ SD_LISTEN_FDS_START to SD_LISTEN_FDS_START+r-1. Returns a negative
435+ errno style error code on failure. This function call ensures that
436+ the FD_CLOEXEC flag is set for the passed file descriptors, to make
437+ sure they are not passed on to child processes. If FD_CLOEXEC shall
438+ not be set, the caller needs to unset it after this call for all file
439+ descriptors that are used.
440+
441+ See sd_listen_fds(3) for more information.
442+*/
443+int netsnmp_sd_listen_fds(int unset_environment);
444+
445+/*
446+ Helper call for identifying a passed file descriptor. Returns 1 if
447+ the file descriptor is a FIFO in the file system stored under the
448+ specified path, 0 otherwise. If path is NULL a path name check will
449+ not be done and the call only verifies if the file descriptor
450+ refers to a FIFO. Returns a negative errno style error code on
451+ failure.
452+
453+ See sd_is_fifo(3) for more information.
454+*/
455+int netsnmp_sd_is_fifo(int fd, const char *path);
456+
457+/*
458+ Helper call for identifying a passed file descriptor. Returns 1 if
459+ the file descriptor is a special character device on the file
460+ system stored under the specified path, 0 otherwise.
461+ If path is NULL a path name check will not be done and the call
462+ only verifies if the file descriptor refers to a special character.
463+ Returns a negative errno style error code on failure.
464+
465+ See sd_is_special(3) for more information.
466+*/
467+int netsnmp_sd_is_special(int fd, const char *path);
468+
469+/*
470+ Helper call for identifying a passed file descriptor. Returns 1 if
471+ the file descriptor is a socket of the specified family (AF_INET,
472+ ...) and type (SOCK_DGRAM, SOCK_STREAM, ...), 0 otherwise. If
473+ family is 0 a socket family check will not be done. If type is 0 a
474+ socket type check will not be done and the call only verifies if
475+ the file descriptor refers to a socket. If listening is > 0 it is
476+ verified that the socket is in listening mode. (i.e. listen() has
477+ been called) If listening is == 0 it is verified that the socket is
478+ not in listening mode. If listening is < 0 no listening mode check
479+ is done. Returns a negative errno style error code on failure.
480+
481+ See sd_is_socket(3) for more information.
482+*/
483+int netsnmp_sd_is_socket(int fd, int family, int type, int listening);
484+
485+/*
486+ Helper call for identifying a passed file descriptor. Returns 1 if
487+ the file descriptor is an Internet socket, of the specified family
488+ (either AF_INET or AF_INET6) and the specified type (SOCK_DGRAM,
489+ SOCK_STREAM, ...), 0 otherwise. If version is 0 a protocol version
490+ check is not done. If type is 0 a socket type check will not be
491+ done. If port is 0 a socket port check will not be done. The
492+ listening flag is used the same way as in sd_is_socket(). Returns a
493+ negative errno style error code on failure.
494+
495+ See sd_is_socket_inet(3) for more information.
496+*/
497+int netsnmp_sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port);
498+
499+/*
500+ Helper call for identifying a passed file descriptor. Returns 1 if
501+ the file descriptor is an AF_UNIX socket of the specified type
502+ (SOCK_DGRAM, SOCK_STREAM, ...) and path, 0 otherwise. If type is 0
503+ a socket type check will not be done. If path is NULL a socket path
504+ check will not be done. For normal AF_UNIX sockets set length to
505+ 0. For abstract namespace sockets set length to the length of the
506+ socket name (including the initial 0 byte), and pass the full
507+ socket path in path (including the initial 0 byte). The listening
508+ flag is used the same way as in sd_is_socket(). Returns a negative
509+ errno style error code on failure.
510+
511+ See sd_is_socket_unix(3) for more information.
512+*/
513+int netsnmp_sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length);
514+
515+/*
516+ Informs systemd about changed daemon state. This takes a number of
517+ newline separated environment-style variable assignments in a
518+ string. The following variables are known:
519+
520+ READY=1 Tells systemd that daemon startup is finished (only
521+ relevant for services of Type=notify). The passed
522+ argument is a boolean "1" or "0". Since there is
523+ little value in signaling non-readiness the only
524+ value daemons should send is "READY=1".
525+
526+ STATUS=... Passes a single-line status string back to systemd
527+ that describes the daemon state. This is free-from
528+ and can be used for various purposes: general state
529+ feedback, fsck-like programs could pass completion
530+ percentages and failing programs could pass a human
531+ readable error message. Example: "STATUS=Completed
532+ 66% of file system check..."
533+
534+ ERRNO=... If a daemon fails, the errno-style error code,
535+ formatted as string. Example: "ERRNO=2" for ENOENT.
536+
537+ BUSERROR=... If a daemon fails, the D-Bus error-style error
538+ code. Example: "BUSERROR=org.freedesktop.DBus.Error.TimedOut"
539+
540+ MAINPID=... The main pid of a daemon, in case systemd did not
541+ fork off the process itself. Example: "MAINPID=4711"
542+
543+ Daemons can choose to send additional variables. However, it is
544+ recommended to prefix variable names not listed above with X_.
545+
546+ Returns a negative errno-style error code on failure. Returns > 0
547+ if systemd could be notified, 0 if it couldn't possibly because
548+ systemd is not running.
549+
550+ Example: When a daemon finished starting up, it could issue this
551+ call to notify systemd about it:
552+
553+ sd_notify(0, "READY=1");
554+
555+ See sd_notifyf() for more complete examples.
556+
557+ See sd_notify(3) for more information.
558+*/
559+int netsnmp_sd_notify(int unset_environment, const char *state);
560+
561+/*
562+ Similar to sd_notify() but takes a format string.
563+
564+ Example 1: A daemon could send the following after initialization:
565+
566+ sd_notifyf(0, "READY=1\n"
567+ "STATUS=Processing requests...\n"
568+ "MAINPID=%lu",
569+ (unsigned long) getpid());
570+
571+ Example 2: A daemon could send the following shortly before
572+ exiting, on failure:
573+
574+ sd_notifyf(0, "STATUS=Failed to start up: %s\n"
575+ "ERRNO=%i",
576+ strerror(errno),
577+ errno);
578+
579+ See sd_notifyf(3) for more information.
580+*/
581+int netsnmp_sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(2,3);
582+
583+/*
584+ Returns > 0 if the system was booted with systemd. Returns < 0 on
585+ error. Returns 0 if the system was not booted with systemd. Note
586+ that all of the functions above handle non-systemd boots just
587+ fine. You should NOT protect them with a call to this function. Also
588+ note that this function checks whether the system, not the user
589+ session is controlled by systemd. However the functions above work
590+ for both user and system services.
591+
592+ See sd_booted(3) for more information.
593+*/
594+int netsnmp_sd_booted(void);
595+
596+/**
597+ * Find an socket with given parameters. See man sd_is_socket_inet for
598+ * description of the arguments.
599+ *
600+ * Returns the file descriptor if it is found, 0 otherwise.
601+ */
602+int netsnmp_sd_find_inet_socket(int family, int type, int listening, int port);
603+
604+/**
605+ * Find an unix socket with given parameters. See man sd_is_socket_unix for
606+ * description of the arguments.
607+ *
608+ * Returns the file descriptor if it is found, 0 otherwise.
609+ */
610+int
611+netsnmp_sd_find_unix_socket(int type, int listening, const char *path);
612+
613+#ifdef __cplusplus
614+}
615+#endif
616+
617+#endif /* SNMPD_SD_DAEMON_H */
618diff --git a/snmplib/sd-daemon.c b/snmplib/sd-daemon.c
619new file mode 100644
620index 0000000..42dba29
621--- /dev/null
622+++ b/snmplib/sd-daemon.c
623@@ -0,0 +1,532 @@
624+/*
625+ * Systemd integration parts.
626+ *
627+ * Most of this file is directly copied from systemd sources.
628+ * Changes:
629+ * - all functions were renamed to have netsnmp_ prefix
630+ * - includes were changed to match Net-SNMP style.
631+ * - removed gcc export macros
632+ * - removed POSIX message queues
633+ */
634+
635+#include <net-snmp/net-snmp-config.h>
636+#include <net-snmp/net-snmp-features.h>
637+#include <net-snmp/types.h>
638+#include <net-snmp/library/snmp_debug.h>
639+
640+#ifndef NETSNMP_NO_SYSTEMD
641+
642+/***
643+ Copyright 2010 Lennart Poettering
644+
645+ Permission is hereby granted, free of charge, to any person
646+ obtaining a copy of this software and associated documentation files
647+ (the "Software"), to deal in the Software without restriction,
648+ including without limitation the rights to use, copy, modify, merge,
649+ publish, distribute, sublicense, and/or sell copies of the Software,
650+ and to permit persons to whom the Software is furnished to do so,
651+ subject to the following conditions:
652+
653+ The above copyright notice and this permission notice shall be
654+ included in all copies or substantial portions of the Software.
655+
656+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
657+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
658+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
659+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
660+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
661+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
662+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
663+ SOFTWARE.
664+***/
665+
666+#ifndef _GNU_SOURCE
667+#define _GNU_SOURCE
668+#endif
669+
670+#include <sys/types.h>
671+#include <sys/stat.h>
672+#include <sys/socket.h>
673+#include <sys/un.h>
674+#include <sys/fcntl.h>
675+#include <netinet/in.h>
676+#include <stdlib.h>
677+#include <errno.h>
678+#include <unistd.h>
679+#include <string.h>
680+#include <stdarg.h>
681+#include <stdio.h>
682+#include <stddef.h>
683+#include <limits.h>
684+
685+#include <net-snmp/library/sd-daemon.h>
686+
687+int netsnmp_sd_listen_fds(int unset_environment) {
688+
689+ int r, fd;
690+ const char *e;
691+ char *p = NULL;
692+ unsigned long l;
693+
694+ if (!(e = getenv("LISTEN_PID"))) {
695+ r = 0;
696+ goto finish;
697+ }
698+
699+ errno = 0;
700+ l = strtoul(e, &p, 10);
701+
702+ if (errno != 0) {
703+ r = -errno;
704+ goto finish;
705+ }
706+
707+ if (!p || *p || l <= 0) {
708+ r = -EINVAL;
709+ goto finish;
710+ }
711+
712+ /* Is this for us? */
713+ if (getpid() != (pid_t) l) {
714+ r = 0;
715+ goto finish;
716+ }
717+
718+ if (!(e = getenv("LISTEN_FDS"))) {
719+ r = 0;
720+ goto finish;
721+ }
722+
723+ errno = 0;
724+ l = strtoul(e, &p, 10);
725+
726+ if (errno != 0) {
727+ r = -errno;
728+ goto finish;
729+ }
730+
731+ if (!p || *p) {
732+ r = -EINVAL;
733+ goto finish;
734+ }
735+
736+ for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int) l; fd ++) {
737+ int flags;
738+
739+ if ((flags = fcntl(fd, F_GETFD)) < 0) {
740+ r = -errno;
741+ goto finish;
742+ }
743+
744+ if (flags & FD_CLOEXEC)
745+ continue;
746+
747+ if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
748+ r = -errno;
749+ goto finish;
750+ }
751+ }
752+
753+ r = (int) l;
754+
755+finish:
756+ if (unset_environment) {
757+ unsetenv("LISTEN_PID");
758+ unsetenv("LISTEN_FDS");
759+ }
760+
761+ return r;
762+}
763+
764+int netsnmp_sd_is_fifo(int fd, const char *path) {
765+ struct stat st_fd;
766+
767+ if (fd < 0)
768+ return -EINVAL;
769+
770+ memset(&st_fd, 0, sizeof(st_fd));
771+ if (fstat(fd, &st_fd) < 0)
772+ return -errno;
773+
774+ if (!S_ISFIFO(st_fd.st_mode))
775+ return 0;
776+
777+ if (path) {
778+ struct stat st_path;
779+
780+ memset(&st_path, 0, sizeof(st_path));
781+ if (stat(path, &st_path) < 0) {
782+
783+ if (errno == ENOENT || errno == ENOTDIR)
784+ return 0;
785+
786+ return -errno;
787+ }
788+
789+ return
790+ st_path.st_dev == st_fd.st_dev &&
791+ st_path.st_ino == st_fd.st_ino;
792+ }
793+
794+ return 1;
795+}
796+
797+int netsnmp_sd_is_special(int fd, const char *path) {
798+ struct stat st_fd;
799+
800+ if (fd < 0)
801+ return -EINVAL;
802+
803+ if (fstat(fd, &st_fd) < 0)
804+ return -errno;
805+
806+ if (!S_ISREG(st_fd.st_mode) && !S_ISCHR(st_fd.st_mode))
807+ return 0;
808+
809+ if (path) {
810+ struct stat st_path;
811+
812+ if (stat(path, &st_path) < 0) {
813+
814+ if (errno == ENOENT || errno == ENOTDIR)
815+ return 0;
816+
817+ return -errno;
818+ }
819+
820+ if (S_ISREG(st_fd.st_mode) && S_ISREG(st_path.st_mode))
821+ return
822+ st_path.st_dev == st_fd.st_dev &&
823+ st_path.st_ino == st_fd.st_ino;
824+ else if (S_ISCHR(st_fd.st_mode) && S_ISCHR(st_path.st_mode))
825+ return st_path.st_rdev == st_fd.st_rdev;
826+ else
827+ return 0;
828+ }
829+
830+ return 1;
831+}
832+
833+static int sd_is_socket_internal(int fd, int type, int listening) {
834+ struct stat st_fd;
835+
836+ if (fd < 0 || type < 0)
837+ return -EINVAL;
838+
839+ if (fstat(fd, &st_fd) < 0)
840+ return -errno;
841+
842+ if (!S_ISSOCK(st_fd.st_mode))
843+ return 0;
844+
845+ if (type != 0) {
846+ int other_type = 0;
847+ socklen_t l = sizeof(other_type);
848+
849+ if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &other_type, &l) < 0)
850+ return -errno;
851+
852+ if (l != sizeof(other_type))
853+ return -EINVAL;
854+
855+ if (other_type != type)
856+ return 0;
857+ }
858+
859+ if (listening >= 0) {
860+ int accepting = 0;
861+ socklen_t l = sizeof(accepting);
862+
863+ if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &accepting, &l) < 0)
864+ return -errno;
865+
866+ if (l != sizeof(accepting))
867+ return -EINVAL;
868+
869+ if (!accepting != !listening)
870+ return 0;
871+ }
872+
873+ return 1;
874+}
875+
876+union sockaddr_union {
877+ struct sockaddr sa;
878+ struct sockaddr_in in4;
879+ struct sockaddr_in6 in6;
880+ struct sockaddr_un un;
881+ struct sockaddr_storage storage;
882+};
883+
884+int netsnmp_sd_is_socket(int fd, int family, int type, int listening) {
885+ int r;
886+
887+ if (family < 0)
888+ return -EINVAL;
889+
890+ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
891+ return r;
892+
893+ if (family > 0) {
894+ union sockaddr_union sockaddr;
895+ socklen_t l;
896+
897+ memset(&sockaddr, 0, sizeof(sockaddr));
898+ l = sizeof(sockaddr);
899+
900+ if (getsockname(fd, &sockaddr.sa, &l) < 0)
901+ return -errno;
902+
903+ if (l < sizeof(sa_family_t))
904+ return -EINVAL;
905+
906+ return sockaddr.sa.sa_family == family;
907+ }
908+
909+ return 1;
910+}
911+
912+int netsnmp_sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) {
913+ union sockaddr_union sockaddr;
914+ socklen_t l;
915+ int r;
916+
917+ if (family != 0 && family != AF_INET && family != AF_INET6)
918+ return -EINVAL;
919+
920+ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
921+ return r;
922+
923+ memset(&sockaddr, 0, sizeof(sockaddr));
924+ l = sizeof(sockaddr);
925+
926+ if (getsockname(fd, &sockaddr.sa, &l) < 0)
927+ return -errno;
928+
929+ if (l < sizeof(sa_family_t))
930+ return -EINVAL;
931+
932+ if (sockaddr.sa.sa_family != AF_INET &&
933+ sockaddr.sa.sa_family != AF_INET6)
934+ return 0;
935+
936+ if (family > 0)
937+ if (sockaddr.sa.sa_family != family)
938+ return 0;
939+
940+ if (port > 0) {
941+ if (sockaddr.sa.sa_family == AF_INET) {
942+ if (l < sizeof(struct sockaddr_in))
943+ return -EINVAL;
944+
945+ return htons(port) == sockaddr.in4.sin_port;
946+ } else {
947+ if (l < sizeof(struct sockaddr_in6))
948+ return -EINVAL;
949+
950+ return htons(port) == sockaddr.in6.sin6_port;
951+ }
952+ }
953+
954+ return 1;
955+}
956+
957+int netsnmp_sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) {
958+ union sockaddr_union sockaddr;
959+ socklen_t l;
960+ int r;
961+
962+ if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
963+ return r;
964+
965+ memset(&sockaddr, 0, sizeof(sockaddr));
966+ l = sizeof(sockaddr);
967+
968+ if (getsockname(fd, &sockaddr.sa, &l) < 0)
969+ return -errno;
970+
971+ if (l < sizeof(sa_family_t))
972+ return -EINVAL;
973+
974+ if (sockaddr.sa.sa_family != AF_UNIX)
975+ return 0;
976+
977+ if (path) {
978+ if (length <= 0)
979+ length = strlen(path);
980+
981+ if (length <= 0)
982+ /* Unnamed socket */
983+ return l == offsetof(struct sockaddr_un, sun_path);
984+
985+ if (path[0])
986+ /* Normal path socket */
987+ return
988+ (l >= offsetof(struct sockaddr_un, sun_path) + length + 1) &&
989+ memcmp(path, sockaddr.un.sun_path, length+1) == 0;
990+ else
991+ /* Abstract namespace socket */
992+ return
993+ (l == offsetof(struct sockaddr_un, sun_path) + length) &&
994+ memcmp(path, sockaddr.un.sun_path, length) == 0;
995+ }
996+
997+ return 1;
998+}
999+
1000+int netsnmp_sd_notify(int unset_environment, const char *state) {
1001+ int fd = -1, r;
1002+ struct msghdr msghdr;
1003+ struct iovec iovec;
1004+ union sockaddr_union sockaddr;
1005+ const char *e;
1006+
1007+ if (!state) {
1008+ r = -EINVAL;
1009+ goto finish;
1010+ }
1011+
1012+ if (!(e = getenv("NOTIFY_SOCKET")))
1013+ return 0;
1014+
1015+ /* Must be an abstract socket, or an absolute path */
1016+ if ((e[0] != '@' && e[0] != '/') || e[1] == 0) {
1017+ r = -EINVAL;
1018+ goto finish;
1019+ }
1020+
1021+ if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) {
1022+ r = -errno;
1023+ goto finish;
1024+ }
1025+
1026+ memset(&sockaddr, 0, sizeof(sockaddr));
1027+ sockaddr.sa.sa_family = AF_UNIX;
1028+ strncpy(sockaddr.un.sun_path, e, sizeof(sockaddr.un.sun_path));
1029+
1030+ if (sockaddr.un.sun_path[0] == '@')
1031+ sockaddr.un.sun_path[0] = 0;
1032+
1033+ memset(&iovec, 0, sizeof(iovec));
1034+ iovec.iov_base = (char *)state;
1035+ iovec.iov_len = strlen(state);
1036+
1037+ memset(&msghdr, 0, sizeof(msghdr));
1038+ msghdr.msg_name = &sockaddr;
1039+ msghdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(e);
1040+
1041+ if (msghdr.msg_namelen > sizeof(struct sockaddr_un))
1042+ msghdr.msg_namelen = sizeof(struct sockaddr_un);
1043+
1044+ msghdr.msg_iov = &iovec;
1045+ msghdr.msg_iovlen = 1;
1046+
1047+ if (sendmsg(fd, &msghdr, MSG_NOSIGNAL) < 0) {
1048+ r = -errno;
1049+ goto finish;
1050+ }
1051+
1052+ r = 1;
1053+
1054+finish:
1055+ if (unset_environment)
1056+ unsetenv("NOTIFY_SOCKET");
1057+
1058+ if (fd >= 0)
1059+ close(fd);
1060+
1061+ return r;
1062+}
1063+
1064+int netsnmp_sd_notifyf(int unset_environment, const char *format, ...) {
1065+ va_list ap;
1066+ char *p = NULL;
1067+ int r;
1068+
1069+ va_start(ap, format);
1070+ r = vasprintf(&p, format, ap);
1071+ va_end(ap);
1072+
1073+ if (r < 0 || !p)
1074+ return -ENOMEM;
1075+
1076+ r = netsnmp_sd_notify(unset_environment, p);
1077+ free(p);
1078+
1079+ return r;
1080+}
1081+
1082+int netsnmp_sd_booted(void) {
1083+ struct stat a, b;
1084+
1085+ /* We simply test whether the systemd cgroup hierarchy is
1086+ * mounted */
1087+
1088+ if (lstat("/sys/fs/cgroup", &a) < 0)
1089+ return 0;
1090+
1091+ if (lstat("/sys/fs/cgroup/systemd", &b) < 0)
1092+ return 0;
1093+
1094+ return a.st_dev != b.st_dev;
1095+}
1096+
1097+/* End of original sd-daemon.c from systemd sources */
1098+
1099+int
1100+netsnmp_sd_find_inet_socket(int family, int type, int listening, int port)
1101+{
1102+ int count, fd;
1103+
1104+ count = netsnmp_sd_listen_fds(0);
1105+ if (count <= 0) {
1106+ DEBUGMSGTL(("systemd:find_inet_socket", "No LISTEN_FDS found.\n"));
1107+ return 0;
1108+ }
1109+ DEBUGMSGTL(("systemd:find_inet_socket", "LISTEN_FDS reports %d sockets.\n",
1110+ count));
1111+
1112+ for (fd = 3; fd < 3+count; fd++) {
1113+ int rc = netsnmp_sd_is_socket_inet(fd, family, type, listening, port);
1114+ if (rc < 0)
1115+ DEBUGMSGTL(("systemd:find_inet_socket",
1116+ "sd_is_socket_inet error: %d\n", rc));
1117+ if (rc > 0) {
1118+ DEBUGMSGTL(("systemd:find_inet_socket",
1119+ "Found the socket in LISTEN_FDS\n"));
1120+ return fd;
1121+ }
1122+ }
1123+ DEBUGMSGTL(("systemd:find_inet_socket", "Socket not found in LISTEN_FDS\n"));
1124+ return 0;
1125+}
1126+
1127+int
1128+netsnmp_sd_find_unix_socket(int type, int listening, const char *path)
1129+{
1130+ int count, fd;
1131+
1132+ count = netsnmp_sd_listen_fds(0);
1133+ if (count <= 0) {
1134+ DEBUGMSGTL(("systemd:find_unix_socket", "No LISTEN_FDS found.\n"));
1135+ return 0;
1136+ }
1137+ DEBUGMSGTL(("systemd:find_unix_socket", "LISTEN_FDS reports %d sockets.\n",
1138+ count));
1139+
1140+ for (fd = 3; fd < 3+count; fd++) {
1141+ int rc = netsnmp_sd_is_socket_unix(fd, type, listening, path, 0);
1142+ if (rc < 0)
1143+ DEBUGMSGTL(("systemd:find_unix_socket",
1144+ "netsnmp_sd_is_socket_unix error: %d\n", rc));
1145+ if (rc > 0) {
1146+ DEBUGMSGTL(("systemd:find_unix_socket",
1147+ "Found the socket in LISTEN_FDS\n"));
1148+ return fd;
1149+ }
1150+ }
1151+ DEBUGMSGTL(("systemd:find_unix_socket", "Socket not found in LISTEN_FDS\n"));
1152+ return 0;
1153+}
1154+
1155+#endif /* ! NETSNMP_NO_SYSTEMD */
1156diff --git a/snmplib/transports/snmpTCPDomain.c b/snmplib/transports/snmpTCPDomain.c
1157index b8bdba4..ab7f3a1 100644
1158--- a/snmplib/transports/snmpTCPDomain.c
1159+++ b/snmplib/transports/snmpTCPDomain.c
1160@@ -43,6 +43,10 @@
1161 #include <net-snmp/library/snmpTCPBaseDomain.h>
1162 #include <net-snmp/library/tools.h>
1163
1164+#ifndef NETSNMP_NO_SYSTEMD
1165+#include <net-snmp/library/sd-daemon.h>
1166+#endif
1167+
1168 /*
1169 * needs to be in sync with the definitions in snmplib/snmpUDPDomain.c
1170 * and perl/agent/agent.xs
1171@@ -149,6 +153,7 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
1172 netsnmp_transport *t = NULL;
1173 netsnmp_udp_addr_pair *addr_pair = NULL;
1174 int rc = 0;
1175+ int socket_initialized = 0;
1176
1177 #ifdef NETSNMP_NO_LISTEN_SUPPORT
1178 if (local)
1179@@ -178,7 +183,19 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
1180 t->domain_length =
1181 sizeof(netsnmp_snmpTCPDomain) / sizeof(netsnmp_snmpTCPDomain[0]);
1182
1183- t->sock = socket(PF_INET, SOCK_STREAM, 0);
1184+#ifndef NETSNMP_NO_SYSTEMD
1185+ /*
1186+ * Maybe the socket was already provided by systemd...
1187+ */
1188+ if (local) {
1189+ t->sock = netsnmp_sd_find_inet_socket(PF_INET, SOCK_STREAM, 1,
1190+ ntohs(addr->sin_port));
1191+ if (t->sock)
1192+ socket_initialized = 1;
1193+ }
1194+#endif
1195+ if (!socket_initialized)
1196+ t->sock = socket(PF_INET, SOCK_STREAM, 0);
1197 if (t->sock < 0) {
1198 netsnmp_transport_free(t);
1199 return NULL;
1200@@ -215,11 +232,13 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
1201 setsockopt(t->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&opt,
1202 sizeof(opt));
1203
1204- rc = bind(t->sock, (struct sockaddr *)addr, sizeof(struct sockaddr));
1205- if (rc != 0) {
1206- netsnmp_socketbase_close(t);
1207- netsnmp_transport_free(t);
1208- return NULL;
1209+ if (!socket_initialized) {
1210+ rc = bind(t->sock, (struct sockaddr *)addr, sizeof(struct sockaddr));
1211+ if (rc != 0) {
1212+ netsnmp_socketbase_close(t);
1213+ netsnmp_transport_free(t);
1214+ return NULL;
1215+ }
1216 }
1217
1218 /*
1219@@ -235,12 +254,13 @@ netsnmp_tcp_transport(struct sockaddr_in *addr, int local)
1220 /*
1221 * Now sit here and wait for connections to arrive.
1222 */
1223-
1224- rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
1225- if (rc != 0) {
1226- netsnmp_socketbase_close(t);
1227- netsnmp_transport_free(t);
1228- return NULL;
1229+ if (!socket_initialized) {
1230+ rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
1231+ if (rc != 0) {
1232+ netsnmp_socketbase_close(t);
1233+ netsnmp_transport_free(t);
1234+ return NULL;
1235+ }
1236 }
1237
1238 /*
1239diff --git a/snmplib/transports/snmpTCPIPv6Domain.c b/snmplib/transports/snmpTCPIPv6Domain.c
1240index 3c96856..305a861 100644
1241--- a/snmplib/transports/snmpTCPIPv6Domain.c
1242+++ b/snmplib/transports/snmpTCPIPv6Domain.c
1243@@ -49,6 +49,10 @@
1244 #include <net-snmp/library/snmpTCPBaseDomain.h>
1245 #include <net-snmp/library/tools.h>
1246
1247+#ifndef NETSNMP_NO_SYSTEMD
1248+#include <net-snmp/library/sd-daemon.h>
1249+#endif
1250+
1251 #include "inet_ntop.h"
1252
1253 oid netsnmp_TCPIPv6Domain[] = { TRANSPORT_DOMAIN_TCP_IPV6 };
1254@@ -140,6 +144,8 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
1255 {
1256 netsnmp_transport *t = NULL;
1257 int rc = 0;
1258+ char *str = NULL;
1259+ int socket_initialized = 0;
1260
1261 #ifdef NETSNMP_NO_LISTEN_SUPPORT
1262 if (local)
1263@@ -174,7 +180,19 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
1264 t->domain = netsnmp_TCPIPv6Domain;
1265 t->domain_length = sizeof(netsnmp_TCPIPv6Domain) / sizeof(oid);
1266
1267- t->sock = socket(PF_INET6, SOCK_STREAM, 0);
1268+#ifndef NETSNMP_NO_SYSTEMD
1269+ /*
1270+ * Maybe the socket was already provided by systemd...
1271+ */
1272+ if (local) {
1273+ t->sock = netsnmp_sd_find_inet_socket(PF_INET6, SOCK_STREAM, 1,
1274+ ntohs(addr->sin6_port));
1275+ if (t->sock)
1276+ socket_initialized = 1;
1277+ }
1278+#endif
1279+ if (!socket_initialized)
1280+ t->sock = socket(PF_INET6, SOCK_STREAM, 0);
1281 if (t->sock < 0) {
1282 netsnmp_transport_free(t);
1283 return NULL;
1284@@ -220,12 +238,14 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
1285
1286 setsockopt(t->sock, SOL_SOCKET, SO_REUSEADDR, (void *)&opt, sizeof(opt));
1287
1288- rc = bind(t->sock, (struct sockaddr *) addr,
1289- sizeof(struct sockaddr_in6));
1290- if (rc != 0) {
1291- netsnmp_socketbase_close(t);
1292- netsnmp_transport_free(t);
1293- return NULL;
1294+ if (!socket_initialized) {
1295+ rc = bind(t->sock, (struct sockaddr *) addr,
1296+ sizeof(struct sockaddr_in6));
1297+ if (rc != 0) {
1298+ netsnmp_socketbase_close(t);
1299+ netsnmp_transport_free(t);
1300+ return NULL;
1301+ }
1302 }
1303
1304 /*
1305@@ -242,11 +262,13 @@ netsnmp_tcp6_transport(struct sockaddr_in6 *addr, int local)
1306 * Now sit here and wait for connections to arrive.
1307 */
1308
1309- rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
1310- if (rc != 0) {
1311- netsnmp_socketbase_close(t);
1312- netsnmp_transport_free(t);
1313- return NULL;
1314+ if (!socket_initialized) {
1315+ rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
1316+ if (rc != 0) {
1317+ netsnmp_socketbase_close(t);
1318+ netsnmp_transport_free(t);
1319+ return NULL;
1320+ }
1321 }
1322
1323 /*
1324diff --git a/snmplib/transports/snmpUDPIPv4BaseDomain.c b/snmplib/transports/snmpUDPIPv4BaseDomain.c
1325index c67427b..428e6d6 100644
1326--- a/snmplib/transports/snmpUDPIPv4BaseDomain.c
1327+++ b/snmplib/transports/snmpUDPIPv4BaseDomain.c
1328@@ -40,6 +40,10 @@
1329
1330 #include <net-snmp/library/snmpSocketBaseDomain.h>
1331
1332+#ifndef NETSNMP_NO_SYSTEMD
1333+#include <net-snmp/library/sd-daemon.h>
1334+#endif
1335+
1336 #if (defined(linux) && defined(IP_PKTINFO)) \
1337 || defined(IP_RECVDSTADDR) && HAVE_STRUCT_MSGHDR_MSG_CONTROL \
1338 && HAVE_STRUCT_MSGHDR_MSG_FLAGS
1339@@ -67,6 +71,7 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local)
1340 char *client_socket = NULL;
1341 netsnmp_indexed_addr_pair addr_pair;
1342 socklen_t local_addr_len;
1343+ int socket_initialized = 0;
1344
1345 #ifdef NETSNMP_NO_LISTEN_SUPPORT
1346 if (local)
1347@@ -91,7 +96,19 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local)
1348 free(str);
1349 }
1350
1351- t->sock = socket(PF_INET, SOCK_DGRAM, 0);
1352+#ifndef NETSNMP_NO_SYSTEMD
1353+ /*
1354+ * Maybe the socket was already provided by systemd...
1355+ */
1356+ if (local) {
1357+ t->sock = netsnmp_sd_find_inet_socket(PF_INET, SOCK_DGRAM, -1,
1358+ ntohs(addr->sin_port));
1359+ if (t->sock)
1360+ socket_initialized = 1;
1361+ }
1362+#endif
1363+ if (!socket_initialized)
1364+ t->sock = socket(PF_INET, SOCK_DGRAM, 0);
1365 DEBUGMSGTL(("UDPBase", "openned socket %d as local=%d\n", t->sock, local));
1366 if (t->sock < 0) {
1367 netsnmp_transport_free(t);
1368@@ -141,12 +158,14 @@ netsnmp_udpipv4base_transport(struct sockaddr_in *addr, int local)
1369 DEBUGMSGTL(("netsnmp_udp", "set IP_RECVDSTADDR\n"));
1370 }
1371 #endif
1372- rc = bind(t->sock, (struct sockaddr *) addr,
1373- sizeof(struct sockaddr));
1374- if (rc != 0) {
1375- netsnmp_socketbase_close(t);
1376- netsnmp_transport_free(t);
1377- return NULL;
1378+ if (!socket_initialized) {
1379+ rc = bind(t->sock, (struct sockaddr *) addr,
1380+ sizeof(struct sockaddr));
1381+ if (rc != 0) {
1382+ netsnmp_socketbase_close(t);
1383+ netsnmp_transport_free(t);
1384+ return NULL;
1385+ }
1386 }
1387 t->data = NULL;
1388 t->data_length = 0;
1389diff --git a/snmplib/transports/snmpUDPIPv6Domain.c b/snmplib/transports/snmpUDPIPv6Domain.c
1390index b3eaae4..35b617f 100644
1391--- a/snmplib/transports/snmpUDPIPv6Domain.c
1392+++ b/snmplib/transports/snmpUDPIPv6Domain.c
1393@@ -67,6 +67,10 @@ static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
1394 #include <net-snmp/library/snmpSocketBaseDomain.h>
1395 #include <net-snmp/library/tools.h>
1396
1397+#ifndef NETSNMP_NO_SYSTEMD
1398+#include <net-snmp/library/sd-daemon.h>
1399+#endif
1400+
1401 #include "inet_ntop.h"
1402 #include "inet_pton.h"
1403
1404@@ -190,6 +194,8 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
1405 {
1406 netsnmp_transport *t = NULL;
1407 int rc = 0;
1408+ char *str = NULL;
1409+ int socket_initialized = 0;
1410
1411 #ifdef NETSNMP_NO_LISTEN_SUPPORT
1412 if (local)
1413@@ -217,7 +223,19 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
1414 t->domain_length =
1415 sizeof(netsnmp_UDPIPv6Domain) / sizeof(netsnmp_UDPIPv6Domain[0]);
1416
1417- t->sock = socket(PF_INET6, SOCK_DGRAM, 0);
1418+#ifndef NETSNMP_NO_SYSTEMD
1419+ /*
1420+ * Maybe the socket was already provided by systemd...
1421+ */
1422+ if (local) {
1423+ t->sock = netsnmp_sd_find_inet_socket(PF_INET6, SOCK_DGRAM, -1,
1424+ ntohs(addr->sin6_port));
1425+ if (t->sock)
1426+ socket_initialized = 1;
1427+ }
1428+#endif
1429+ if (!socket_initialized)
1430+ t->sock = socket(PF_INET6, SOCK_DGRAM, 0);
1431 if (t->sock < 0) {
1432 netsnmp_transport_free(t);
1433 return NULL;
1434@@ -242,13 +260,14 @@ netsnmp_udp6_transport(struct sockaddr_in6 *addr, int local)
1435 }
1436 }
1437 #endif
1438-
1439- rc = bind(t->sock, (struct sockaddr *) addr,
1440- sizeof(struct sockaddr_in6));
1441- if (rc != 0) {
1442- netsnmp_socketbase_close(t);
1443- netsnmp_transport_free(t);
1444- return NULL;
1445+ if (!socket_initialized) {
1446+ rc = bind(t->sock, (struct sockaddr *) addr,
1447+ sizeof(struct sockaddr_in6));
1448+ if (rc != 0) {
1449+ netsnmp_socketbase_close(t);
1450+ netsnmp_transport_free(t);
1451+ return NULL;
1452+ }
1453 }
1454 t->local = (unsigned char*)malloc(18);
1455 if (t->local == NULL) {
1456diff --git a/snmplib/transports/snmpUnixDomain.c b/snmplib/transports/snmpUnixDomain.c
1457index 674dc2b..9f3d3cb 100644
1458--- a/snmplib/transports/snmpUnixDomain.c
1459+++ b/snmplib/transports/snmpUnixDomain.c
1460@@ -37,6 +37,10 @@
1461 #include <net-snmp/library/system.h> /* mkdirhier */
1462 #include <net-snmp/library/tools.h>
1463
1464+#ifndef NETSNMP_NO_SYSTEMD
1465+#include <net-snmp/library/sd-daemon.h>
1466+#endif
1467+
1468 netsnmp_feature_child_of(transport_unix_socket_all, transport_all)
1469 netsnmp_feature_child_of(unix_socket_paths, transport_unix_socket_all)
1470
1471@@ -295,6 +299,8 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local)
1472 netsnmp_transport *t = NULL;
1473 sockaddr_un_pair *sup = NULL;
1474 int rc = 0;
1475+ char *string = NULL;
1476+ int socket_initialized = 0;
1477
1478 #ifdef NETSNMP_NO_LISTEN_SUPPORT
1479 /* SPECIAL CIRCUMSTANCE: We still want AgentX to be able to operate,
1480@@ -333,7 +339,18 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local)
1481 t->data_length = sizeof(sockaddr_un_pair);
1482 sup = (sockaddr_un_pair *) t->data;
1483
1484- t->sock = socket(PF_UNIX, SOCK_STREAM, 0);
1485+#ifndef NETSNMP_NO_SYSTEMD
1486+ /*
1487+ * Maybe the socket was already provided by systemd...
1488+ */
1489+ if (local) {
1490+ t->sock = netsnmp_sd_find_unix_socket(SOCK_STREAM, 1, addr->sun_path);
1491+ if (t->sock)
1492+ socket_initialized = 1;
1493+ }
1494+#endif
1495+ if (!socket_initialized)
1496+ t->sock = socket(PF_UNIX, SOCK_STREAM, 0);
1497 if (t->sock < 0) {
1498 netsnmp_transport_free(t);
1499 return NULL;
1500@@ -357,25 +374,26 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local)
1501
1502 t->flags |= NETSNMP_TRANSPORT_FLAG_LISTEN;
1503
1504- unlink(addr->sun_path);
1505- rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr));
1506-
1507- if (rc != 0 && errno == ENOENT && create_path) {
1508- rc = mkdirhier(addr->sun_path, create_mode, 1);
1509+ if (!socket_initialized) {
1510+ unlink(addr->sun_path);
1511+ rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr));
1512+ if (rc != 0 && errno == ENOENT && create_path) {
1513+ rc = mkdirhier(addr->sun_path, create_mode, 1);
1514+ if (rc != 0) {
1515+ netsnmp_unix_close(t);
1516+ netsnmp_transport_free(t);
1517+ return NULL;
1518+ }
1519+ rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr));
1520+ }
1521 if (rc != 0) {
1522+ DEBUGMSGTL(("netsnmp_unix_transport",
1523+ "couldn't bind \"%s\", errno %d (%s)\n",
1524+ addr->sun_path, errno, strerror(errno)));
1525 netsnmp_unix_close(t);
1526 netsnmp_transport_free(t);
1527 return NULL;
1528 }
1529- rc = bind(t->sock, (struct sockaddr *) addr, SUN_LEN(addr));
1530- }
1531- if (rc != 0) {
1532- DEBUGMSGTL(("netsnmp_unix_transport",
1533- "couldn't bind \"%s\", errno %d (%s)\n",
1534- addr->sun_path, errno, strerror(errno)));
1535- netsnmp_unix_close(t);
1536- netsnmp_transport_free(t);
1537- return NULL;
1538 }
1539
1540 /*
1541@@ -391,16 +409,17 @@ netsnmp_unix_transport(struct sockaddr_un *addr, int local)
1542 * Now sit here and listen for connections to arrive.
1543 */
1544
1545- rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
1546- if (rc != 0) {
1547- DEBUGMSGTL(("netsnmp_unix_transport",
1548- "couldn't listen to \"%s\", errno %d (%s)\n",
1549- addr->sun_path, errno, strerror(errno)));
1550- netsnmp_unix_close(t);
1551- netsnmp_transport_free(t);
1552- return NULL;
1553+ if (!socket_initialized) {
1554+ rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
1555+ if (rc != 0) {
1556+ DEBUGMSGTL(("netsnmp_unix_transport",
1557+ "couldn't listen to \"%s\", errno %d (%s)\n",
1558+ addr->sun_path, errno, strerror(errno)));
1559+ netsnmp_unix_close(t);
1560+ netsnmp_transport_free(t);
1561+ return NULL;
1562+ }
1563 }
1564-
1565 } else {
1566 t->remote = (u_char *)malloc(strlen(addr->sun_path));
1567 if (t->remote == NULL) {
1568diff --git a/win32/libsnmp/Makefile.in b/win32/libsnmp/Makefile.in
1569index 98d83c8..dd5689b 100644
1570--- a/win32/libsnmp/Makefile.in
1571+++ b/win32/libsnmp/Makefile.in
1572@@ -42,6 +42,7 @@ LIB32_OBJS= \
1573 "$(INTDIR)\read_config.obj" \
1574 "$(INTDIR)\readdir.obj" \
1575 "$(INTDIR)\scapi.obj" \
1576+ "$(INTDIR)\sd-daemon.obj" \
1577 "$(INTDIR)\snmp-tc.obj" \
1578 "$(INTDIR)\snmp.obj" \
1579 "$(INTDIR)\snmpCallbackDomain.obj" \
1580@@ -307,6 +308,12 @@ SOURCE=..\..\snmplib\scapi.c
1581 $(CPP) $(CPP_PROJ) $(SOURCE)
1582
1583
1584+SOURCE=..\..\snmplib\sd-daemon.c
1585+
1586+"$(INTDIR)\sd-daemon.obj" : $(SOURCE) "$(INTDIR)"
1587+ $(CPP) $(CPP_PROJ) $(SOURCE)
1588+
1589+
1590 SOURCE="..\..\snmplib\snmp-tc.c"
1591
1592 "$(INTDIR)\snmp-tc.obj" : $(SOURCE) "$(INTDIR)"
1593diff --git a/win32/net-snmp/net-snmp-config.h b/win32/net-snmp/net-snmp-config.h
1594index 7791ee0..1eccf42 100644
1595--- a/win32/net-snmp/net-snmp-config.h
1596+++ b/win32/net-snmp/net-snmp-config.h
1597@@ -1705,6 +1705,8 @@ enum {
1598 #define DMALLOC_FUNC_CHECK
1599 #endif
1600
1601+#define NETSNMP_NO_SYSTEMD
1602+
1603 /* #undef NETSNMP_ENABLE_LOCAL_SMUX */
1604
1605 /* define if agentx transport is to use domain sockets only */
1606diff --git a/win32/net-snmp/net-snmp-config.h.in b/win32/net-snmp/net-snmp-config.h.in
1607index 5215865..1607bfa 100644
1608--- a/win32/net-snmp/net-snmp-config.h.in
1609+++ b/win32/net-snmp/net-snmp-config.h.in
1610@@ -1705,6 +1705,8 @@ enum {
1611 #define DMALLOC_FUNC_CHECK
1612 #endif
1613
1614+#define NETSNMP_NO_SYSTEMD
1615+
1616 /* #undef NETSNMP_ENABLE_LOCAL_SMUX */
1617
1618 /* define if agentx transport is to use domain sockets only */
diff --git a/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb
new file mode 100644
index 000000000..f6ddcacec
--- /dev/null
+++ b/meta-networking/recipes-protocols/net-snmp/net-snmp_5.7.2.1.bb
@@ -0,0 +1,136 @@
1SUMMARY = "Various tools relating to the Simple Network Management Protocol"
2HOMEPAGE = "http://www.net-snmp.org/"
3LICENSE = "BSD"
4
5LIC_FILES_CHKSUM = "file://README;beginline=3;endline=8;md5=7f7f00ba639ac8e8deb5a622ea24634e"
6
7DEPENDS = "openssl libnl pciutils"
8
9SRC_URI = "${SOURCEFORGE_MIRROR}/net-snmp/net-snmp-${PV}.zip \
10 file://0001-Added-checks-for-printing-variables-with-wrong-types.patch \
11 file://init \
12 file://snmpd.conf \
13 file://snmptrapd.conf \
14 file://systemd-support.patch \
15 file://snmpd.service \
16 file://snmptrapd.service \
17 file://ifmib.patch \
18"
19
20SRC_URI[md5sum] = "a2c83518648b0f2a5d378625e45c0e18"
21SRC_URI[sha256sum] = "ac9105539971f7cfb1456a86d479e18e8a8b3712212595ad40504347ba5843da"
22
23inherit autotools update-rc.d siteinfo systemd
24
25EXTRA_OEMAKE = "INSTALL_PREFIX=${D}"
26
27PARALLEL_MAKE = ""
28CCACHE = ""
29
30TARGET_CC_ARCH += "${LDFLAGS}"
31
32EXTRA_OECONF = "--disable-embedded-perl \
33 --with-perl-modules=no \
34 --enable-shared \
35 --disable-manuals \
36 --with-defaults \
37 ${@base_conditional('SITEINFO_ENDIANNESS', 'le', '--with-endianness=little', '--with-endianness=big', d)}"
38
39CACHED_CONFIGUREVARS = " \
40 ac_cv_header_valgrind_valgrind_h=no \
41 ac_cv_header_valgrind_memcheck_h=no \
42"
43
44do_configure_prepend() {
45 export PERLPROG="${bindir}/env perl"
46}
47
48do_install_append() {
49 install -d ${D}${sysconfdir}/snmp
50 install -d ${D}${sysconfdir}/init.d
51 install -m 755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/snmpd
52 install -m 644 ${WORKDIR}/snmpd.conf ${D}${sysconfdir}/snmp/
53 install -m 644 ${WORKDIR}/snmptrapd.conf ${D}${sysconfdir}/snmp/
54 sed -e "s@-I/usr/include@@g" \
55 -e "s@^prefix=.*@prefix=${STAGING_DIR_HOST}@g" \
56 -e "s@^exec_prefix=.*@exec_prefix=${STAGING_DIR_HOST}@g" \
57 -e "s@^includedir=.*@includedir=${STAGING_INCDIR}@g" \
58 -e "s@^libdir=.*@libdir=${STAGING_LIBDIR}@g" \
59 -i ${D}${bindir}/net-snmp-config
60 install -d ${D}${systemd_unitdir}/system
61 install -m 0644 ${WORKDIR}/snmpd.service ${D}${systemd_unitdir}/system
62 install -m 0644 ${WORKDIR}/snmptrapd.service ${D}${systemd_unitdir}/system
63}
64
65SYSROOT_PREPROCESS_FUNCS += "net_snmp_sysroot_preprocess"
66
67net_snmp_sysroot_preprocess () {
68 if [ -e ${D}${bindir}/net-snmp-config ]; then
69 install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/
70 install -m 755 ${D}${bindir}/net-snmp-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/
71 fi
72}
73
74PACKAGES =+ "${PN}-static ${PN}-libs ${PN}-mibs ${PN}-server ${PN}-client ${PN}-server-snmpd \
75 ${PN}-server-snmptrapd"
76
77ALLOW_EMPTY_${PN}-server = "1"
78ALLOW_EMPTY_${PN} = "1"
79
80FILES_${PN}-libs = "${libdir}/lib*${SOLIBS}"
81FILES_${PN}-mibs = "${datadir}/snmp/mibs"
82FILES_${PN}-server-snmpd = "${sbindir}/snmpd \
83 ${sysconfdir}/snmp/snmpd.conf \
84 ${sysconfdir}/init.d \
85 ${systemd_unitdir}/system/snmpd.service \
86"
87
88FILES_${PN}-server-snmptrapd = "${sbindir}/snmptrapd \
89 ${sysconfdir}/snmp/snmptrapd.conf \
90 ${systemd_unitdir}/system/snmptrapd.service \
91"
92
93FILES_${PN}-client = "${bindir}/* ${datadir}/snmp/"
94FILES_${PN}-dbg += "${libdir}/.debug/ ${sbindir}/.debug/ ${bindir}/.debug/"
95FILES_${PN}-dev += "${bindir}/net-snmp-config ${bindir}/mib2c ${bindir}/mib2c-update"
96
97CONFFILES_${PN}-server-snmpd = "${sysconfdir}/snmp/snmpd.conf"
98CONFFILES_${PN}-server-snmptrapd = "${sysconfdir}/snmp/snmptrapd.conf"
99
100INITSCRIPT_PACKAGES = "${PN}-server"
101INITSCRIPT_NAME_${PN}-server = "snmpd"
102INITSCRIPT_PARAMS_${PN}-server = "defaults"
103
104EXTRA_OECONF += "${@base_contains('DISTRO_FEATURES', 'systemd', '--with-systemd', '--without-systemd', d)}"
105
106SYSTEMD_PACKAGES = "${PN}-server-snmpd \
107 ${PN}-server-snmptrapd"
108
109SYSTEMD_SERVICE_${PN}-server-snmpd = "snmpd.service"
110SYSTEMD_SERVICE_${PN}-server-snmptrapd = "snmptrapd.service"
111
112RDEPENDS_${PN}-server-snmpd += "net-snmp-mibs"
113RDEPENDS_${PN}-server-snmptrapd += "net-snmp-server-snmpd"
114RDEPENDS_${PN}-server += "net-snmp-server-snmpd net-snmp-server-snmptrapd"
115RDEPENDS_${PN}-client += "net-snmp-mibs"
116RDEPENDS_${PN}-dev = "net-snmp-client (= ${EXTENDPKGV}) net-snmp-server (= ${EXTENDPKGV})"
117RRECOMMENDS_${PN}-dbg = "net-snmp-client (= ${EXTENDPKGV}) net-snmp-server (= ${EXTENDPKGV})"
118
119RPROVIDES_${PN}-server-snmpd += "${PN}-server-snmpd-systemd"
120RREPLACES_${PN}-server-snmpd += "${PN}-server-snmpd-systemd"
121RCONFLICTS_${PN}-server-snmpd += "${PN}-server-snmpd-systemd"
122
123RPROVIDES_${PN}-server-snmptrapd += "${PN}-server-snmptrapd-systemd"
124RREPLACES_${PN}-server-snmptrapd += "${PN}-server-snmptrapd-systemd"
125RCONFLICTS_${PN}-server-snmptrapd += "${PN}-server-snmptrapd-systemd"
126
127LEAD_SONAME = "libnetsnmp.so"
128
129pkg_postrm_${PN}-server() {
130 if test "x$D" != "x"; then
131 OPT="-r $D "
132 else
133 OPT=""
134 /etc/init.d/snmpd stop
135 fi
136}
diff --git a/meta-networking/recipes-protocols/openflow/openflow.inc b/meta-networking/recipes-protocols/openflow/openflow.inc
new file mode 100644
index 000000000..1a226f82c
--- /dev/null
+++ b/meta-networking/recipes-protocols/openflow/openflow.inc
@@ -0,0 +1,35 @@
1SUMMARY = "OpenFlow communications protocol"
2DESCRIPTION = "\
3Open standard that enables researchers to run experimental protocols in \
4contained networks. OpenFlow is a communications interface between \
5control and forwarding planes of a software-defined networking architecture.\
6"
7HOMEPAGE = "http://www.openflow.org"
8
9SECTION = "networking"
10LICENSE = "GPLv2"
11
12LIC_FILES_CHKSUM = "file://COPYING;md5=e870c934e2c3d6ccf085fd7cf0a1e2e2"
13
14SRC_URI = "git://gitosis.stanford.edu/openflow.git;protocol=git"
15
16DEPENDS = "virtual/libc"
17
18EXTRA_OECONF += "KARCH=${TARGET_ARCH}"
19
20PACKAGECONFIG ??= "openssl"
21PACKAGECONFIG[openssl] = "--enable-ssl,--disable-ssl, openssl, libssl"
22
23S = "${WORKDIR}/git"
24
25inherit autotools-brokensep
26
27do_configure() {
28 ./boot.sh
29 oe_runconf
30}
31
32do_install_append() {
33 # Remove /var/run as it is created on startup
34 rm -rf ${D}${localstatedir}/run
35}
diff --git a/meta-networking/recipes-protocols/openflow/openflow_1.0.bb b/meta-networking/recipes-protocols/openflow/openflow_1.0.bb
new file mode 100644
index 000000000..a7e254dd8
--- /dev/null
+++ b/meta-networking/recipes-protocols/openflow/openflow_1.0.bb
@@ -0,0 +1,4 @@
1include ${BPN}.inc
2
3SRCREV = "5ccca75a69f99791659bcfbcf35353ab1921320a"
4PV = "1.0"
diff --git a/meta-networking/recipes-protocols/openflow/openflow_git.bb b/meta-networking/recipes-protocols/openflow/openflow_git.bb
new file mode 100644
index 000000000..6403bfb22
--- /dev/null
+++ b/meta-networking/recipes-protocols/openflow/openflow_git.bb
@@ -0,0 +1,4 @@
1include ${BPN}.inc
2
3SRCREV = "c84f33f09d5dbcfc9b489f64cb30475bf36f653a"
4PV = "1.0+git${SRCPV}"
diff --git a/meta-networking/recipes-protocols/openl2tp/openl2tp/Makefile-modify-CFLAGS-to-aviod-build-error.patch b/meta-networking/recipes-protocols/openl2tp/openl2tp/Makefile-modify-CFLAGS-to-aviod-build-error.patch
new file mode 100644
index 000000000..96dbc7551
--- /dev/null
+++ b/meta-networking/recipes-protocols/openl2tp/openl2tp/Makefile-modify-CFLAGS-to-aviod-build-error.patch
@@ -0,0 +1,106 @@
1From 152486fa3c36c3b99d17d5b553cf87ef412fae8e Mon Sep 17 00:00:00 2001
2From: Li xin <lixin.fnst@cn.fujitsu.com>
3Date: Mon, 1 Dec 2014 01:53:41 +0900
4Subject: [PATCH] Makefile:modify CFLAGS to aviod build error.
5
6Upstream-Status: pending
7
8Signed-off-by: Li Xin <lixin.fnst@cn.fujitsu.com>
9---
10 Makefile | 22 +++++++++++-----------
11 plugins/Makefile | 6 +++---
12 2 files changed, 14 insertions(+), 14 deletions(-)
13
14diff --git a/Makefile b/Makefile
15index 4aaa448..baa7882 100644
16--- a/Makefile
17+++ b/Makefile
18@@ -152,10 +152,10 @@ LIBS.dmalloc= -ldmalloc
19 export USE_DMALLOC
20 endif
21
22-CPPFLAGS= $(CPPFLAGS.l2tptest) $(CPPFLAGS-y)
23-CFLAGS= -I. -Iusl -Icli -isystem include \
24- -MMD -Wall -Werror -Wno-strict-aliasing \
25- $(CPPFLAGS) $(CPPFLAGS.dmalloc) \
26+ADD_CPPFLAGS= $(CPPFLAGS.l2tptest) $(CPPFLAGS-y)
27+ADD_CFLAGS= -I. -Iusl -Icli -isystem include \
28+ -MMD -Wall -Wno-strict-aliasing \
29+ $(ADD_CPPFLAGS) $(CPPFLAGS.dmalloc) \
30 -DSYS_LIBDIR=$(SYS_LIBDIR)
31 LDFLAGS.l2tpd= -Wl,-E -L. -Lusl -lusl -ldl $(LIBS.dmalloc) -lc
32 LDFLAGS.l2tpconfig= -Lcli -lcli -lreadline $(LIBS.dmalloc) $(READLINE_LDFLAGS) -lc
33@@ -170,10 +170,10 @@ CFLAGS.optimize= $(OPT_CFLAGS)
34 endif
35 export CFLAGS.optimize
36
37-CFLAGS+= $(CFLAGS.optimize)
38+ADD_CFLAGS+= $(CFLAGS.optimize)
39
40 ifeq ($(L2TP_USE_ASYNC_RPC),y)
41-CPPFLAGS+= -DL2TP_ASYNC_RPC
42+ADD_CPPFLAGS+= -DL2TP_ASYNC_RPC
43 endif
44
45 ifeq ($(L2TP_FEATURE_RPC_MANAGEMENT),y)
46@@ -220,13 +220,13 @@ endif
47
48 # Compile without -Wall because rpcgen-generated code is full of warnings.
49 %_xdr.o: %_xdr.c
50- $(CC) -I. -MMD -w $(CFLAGS.optimize) -c $(CPPFLAGS) $<
51+ $(CC) -I. -MMD -w $(CFLAGS.optimize) -c $(ADD_CPPFLAGS) $<
52
53 %_client.o: %_client.c
54- $(CC) -I. -MMD -w $(CFLAGS.optimize) -c $(CPPFLAGS) $<
55+ $(CC) -I. -MMD -w $(CFLAGS.optimize) -c $(ADD_CPPFLAGS) $<
56
57 %_server.o: %_server.c
58- $(CC) -I. -MMD -w $(CFLAGS.optimize) -c $(CPPFLAGS) $<
59+ $(CC) -I. -MMD -w $(CFLAGS.optimize) -c $(ADD_CPPFLAGS) $<
60
61 %_xdr.c: %.x
62 -$(RM) $@
63@@ -272,7 +272,7 @@ l2tpconfig: $(L2TPCONFIG_SRCS.o)
64 $(CC) -o $@ $^ $(LDFLAGS.l2tpconfig)
65
66 %.o: %.c
67- $(CC) -c $(CFLAGS) $< -o $@
68+ $(CC) -c $(CFLAGS) $(ADD_CFLAGS) $< -o $@
69
70 l2tp_options.h: FORCE
71 @rm -f $@.tmp
72@@ -325,7 +325,7 @@ install: install-all
73 install-all: all install-daemon install-app
74
75 install-daemon:
76- @for d in $(filter-out usl,$(SUBDIRS)); do $(MAKE) -C $$d $(MFLAGS) EXTRA_CFLAGS="$(CPPFLAGS)" install; if [ $$? -ne 0 ]; then exit 1; fi; done
77+ @for d in $(filter-out usl,$(SUBDIRS)); do $(MAKE) -C $$d $(MFLAGS) EXTRA_CFLAGS="$(CPPFLAGS) $(ADD_CPPFLAGS)" install; if [ $$? -ne 0 ]; then exit 1; fi; done
78 $(INSTALL) -d $(DESTDIR)/usr/sbin
79 $(INSTALL) openl2tpd $(DESTDIR)/usr/sbin
80
81diff --git a/plugins/Makefile b/plugins/Makefile
82index 5be996d..6810236 100644
83--- a/plugins/Makefile
84+++ b/plugins/Makefile
85@@ -1,7 +1,7 @@
86-CFLAGS := $(CFLAGS.optimize) -MMD -Wall \
87+ADD_CFLAGS := $(CFLAGS.optimize) -MMD -Wall \
88 -isystem ../include \
89 -I. -I.. -I../usl -fPIC $(EXTRA_CFLAGS)
90-LDFLAGS := -shared
91+ADD_LDFLAGS := -shared
92
93 PLUGINS.c:= ppp_unix.c ppp_null.c ipsec.c event_sock.c
94
95@@ -21,7 +21,7 @@ clean:
96 $(RM) $(PLUGINS.so) $(wildcard *.o) $(wildcard *.d) $(SRC.generated)
97
98 %.so: %.c
99- $(CC) -o $@ $(LDFLAGS) $(CFLAGS) $<
100+ $(CC) -o $@ $(LDFLAGS) $(ADD_LDFLAGS) $(CFLAGS) $(ADD_CFLAGS) $<
101
102 install: all
103 $(INSTALL) -d $(DESTDIR)$(SYS_LIBDIR)/openl2tp
104--
1051.8.4.2
106
diff --git a/meta-networking/recipes-protocols/openl2tp/openl2tp/openl2tp-simplify-gcc-warning-hack.patch b/meta-networking/recipes-protocols/openl2tp/openl2tp/openl2tp-simplify-gcc-warning-hack.patch
new file mode 100644
index 000000000..c11a127b8
--- /dev/null
+++ b/meta-networking/recipes-protocols/openl2tp/openl2tp/openl2tp-simplify-gcc-warning-hack.patch
@@ -0,0 +1,41 @@
1From 460549a3de27f8dd8371b6d6fc1f69d8bffa102b Mon Sep 17 00:00:00 2001
2From: Joe MacDonald <joe_macdonald@mentor.com>
3Date: Tue, 6 Jan 2015 11:23:21 -0500
4Subject: [PATCH] openl2tp: simplify gcc warning hack
5
6The hack to work around the gcc warning causes problems with some modern
7gcc configurations. Since the redef behaviour is essentially correct
8everywhere and since the hack is still required on 32-bit builders, leave
9it in place but remove the #if guard since it is only there to ensure that
10the l2tp_private.h file is updated if the rpc source file is changed and
11the two get out of sync.
12
13Upstream-status: pending
14
15Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
16---
17 l2tp_private.h | 6 ------
18 1 file changed, 6 deletions(-)
19
20diff --git a/l2tp_private.h b/l2tp_private.h
21index f3c1af7..cca6806 100644
22--- a/l2tp_private.h
23+++ b/l2tp_private.h
24@@ -89,14 +89,8 @@
25 * So we redefine the constant with UL suffix to avoid the gcc warning.
26 * Is there some C preprocessor magic that could avoid having to do this?
27 */
28-#if L2TP_API_TUNNEL_FLAG_MTU != 2147483648
29-#error Constant L2TP_API_TUNNEL_FLAG_MTU changed. Update local definition here.
30-#endif
31 #undef L2TP_API_TUNNEL_FLAG_MTU
32 #define L2TP_API_TUNNEL_FLAG_MTU 2147483648UL
33-#if L2TP_API_SESSION_FLAG_NO_PPP != 2147483648
34-#error Constant L2TP_API_SESSION_FLAG_NO_PPP changed. Update local definition here.
35-#endif
36 #undef L2TP_API_SESSION_FLAG_NO_PPP
37 #define L2TP_API_SESSION_FLAG_NO_PPP 2147483648UL
38
39--
401.9.1
41
diff --git a/meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb b/meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb
new file mode 100644
index 000000000..5a041073d
--- /dev/null
+++ b/meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb
@@ -0,0 +1,36 @@
1SUMMARY = "An L2TP client/server, designed for VPN use."
2DESCRIPTION = "OpenL2TP is an open source L2TP client / server, written \
3specifically for Linux. It has been designed for use as an enterprise \
4L2TP VPN server or in commercial, Linux-based, embedded networking \
5products and is able to support hundreds of sessions, each with \
6different configuration. It is used by several ISPs to provide \
7L2TP services and by corporations to implement L2TP VPNs."
8HOMEPAGE = "http://www.openl2tp.org/"
9SECTION = "console/network"
10LICENSE = "GPL-2.0"
11LIC_FILES_CHKSUM = "file://COPYING;md5=e9d9259cbbf00945adc25a470c1d3585"
12DEPENDS = "popt flex readline"
13
14SRC_URI = "http://ftp.jaist.ac.jp/pub/sourceforge/o/op/${PN}/${PN}/${PV}/${BP}.tar.gz \
15 file://Makefile-modify-CFLAGS-to-aviod-build-error.patch \
16 file://openl2tp-simplify-gcc-warning-hack.patch \
17 "
18SRC_URI[md5sum] = "e3d08dedfb9e6a9a1e24f6766f6dadd0"
19SRC_URI[sha256sum] = "1c97704d4b963a87fbc0e741668d4530933991515ae9ab0dffd11b5444f4860f"
20
21inherit autotools-brokensep pkgconfig
22
23PARALLEL_MAKE = ""
24EXTRA_OEMAKE = 'CFLAGS="${CFLAGS} -Wno-nused-but-set-variable"'
25
26do_compile_prepend() {
27 sed -i -e "s:SYS_LIBDIR=.*:SYS_LIBDIR=${libdir}:g" \
28 -e 's:$(CROSS_COMPILE)as:${AS}:g' \
29 -e 's:$(CROSS_COMPILE)ld:${LD}:g' \
30 -e 's:$(CROSS_COMPILE)gcc:${CC}:g' \
31 -e 's:$(CROSS_COMPILE)ar:${AR}:g' \
32 -e 's:$(CROSS_COMPILE)nm:${NM}:g' \
33 -e 's:$(CROSS_COMPILE)strip:${STRIP}:g' \
34 -e 's:$(CROSS_COMPILE)install:install:g' \
35 ${S}/Makefile
36}
diff --git a/meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/fix-parallel-build.patch b/meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/fix-parallel-build.patch
new file mode 100644
index 000000000..77722b064
--- /dev/null
+++ b/meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/fix-parallel-build.patch
@@ -0,0 +1,19 @@
1pptp.c and version.c depend on config.h
2
3Upstream-Status: Backport
4
5Upstream has already similar fixes. Will be available on next release.
6
7Signed-off-by: Jesse Zhang <sen.zhang@windriver.com>
8
9--- a/Makefile 2013-02-27 17:09:24.431226665 +0800
10+++ b/Makefile 2013-02-27 17:09:03.442075550 +0800
11@@ -43,6 +43,8 @@
12 pptpsetup.8: pptpsetup
13 pod2man $? > $@
14
15+pptp.o version.o: config.h
16+
17 config.h:
18 echo "/* text added by Makefile target config.h */" > config.h
19 echo "#define PPTP_LINUX_VERSION \"$(VERSION)$(RELEASE)\"" >> config.h
diff --git a/meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/options.pptp b/meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/options.pptp
new file mode 100644
index 000000000..f446e22a6
--- /dev/null
+++ b/meta-networking/recipes-protocols/pptp-linux/pptp-linux-1.7.2/options.pptp
@@ -0,0 +1,30 @@
1#
2# Lock the port
3#
4lock
5
6#
7# We don't need the tunnel server to authenticate itself
8#
9noauth
10
11#
12# Turn off transmission protocols we know won't be used
13#
14nobsdcomp
15nodeflate
16
17#
18# We want MPPE
19# (option naming specific to ppp 2.4.0 with unofficial patch)
20#
21#mppe-40
22mppe-128
23#mppe-stateless
24
25#
26# We want a sane mtu/mru
27# (ppp 2.4.0 with unofficial patch)
28#
29#mtu 1000
30#mru 1000
diff --git a/meta-networking/recipes-protocols/pptp-linux/pptp-linux_1.7.2.bb b/meta-networking/recipes-protocols/pptp-linux/pptp-linux_1.7.2.bb
new file mode 100644
index 000000000..6a90578bc
--- /dev/null
+++ b/meta-networking/recipes-protocols/pptp-linux/pptp-linux_1.7.2.bb
@@ -0,0 +1,31 @@
1SUMMARY = "Client for Microsoft PPTP VPNs"
2DESCRIPTION = "PPTP Client is a Linux, FreeBSD, NetBSD \
3 and OpenBSD client for the proprietary Microsoft Point-to-Point \
4 Tunneling Protocol, PPTP. Allows connection to a PPTP based \
5 Virtual Private Network (VPN) as used by employers and some \
6 cable and ADSL internet service providers."
7HOMEPAGE = "http://pptpclient.sourceforge.net"
8SECTION = "network"
9LICENSE = "GPLv2+"
10LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b"
11
12PR = "r1"
13
14SRC_URI = "${SOURCEFORGE_MIRROR}/sourceforge/pptpclient/pptp-${PV}.tar.gz \
15 file://options.pptp \
16 file://fix-parallel-build.patch \
17"
18
19SRC_URI[md5sum] = "4c3d19286a37459a632c7128c92a9857"
20SRC_URI[sha256sum] = "e98ae0065d2a39fa3131654ff28cb7070e996f668ed6d0e7d9a445b8d37694bc"
21
22S = "${WORKDIR}/pptp-${PV}"
23
24do_install() {
25 install -d ${D}${sbindir} ${D}${sysconfdir}/ppp ${D}${mandir}/man8
26 install -m 555 pptp ${D}${sbindir}
27 install -m 644 pptp.8 ${D}${mandir}/man8
28 install -m 644 ${WORKDIR}/options.pptp ${D}${sysconfdir}/ppp
29}
30
31RDEPENDS_${PN} = "ppp"
diff --git a/meta-networking/recipes-protocols/quagga/files/Zebra-sync-zebra-routing-table-with-the-kernel-one.patch b/meta-networking/recipes-protocols/quagga/files/Zebra-sync-zebra-routing-table-with-the-kernel-one.patch
new file mode 100644
index 000000000..35f4637d8
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/Zebra-sync-zebra-routing-table-with-the-kernel-one.patch
@@ -0,0 +1,48 @@
1sync zebra routing table with the kernel one when interface is down
2
3Add router to kernel main router table with "ip", then you can see
4a router item in kernel main router table. Also can see this router
5item in zebra router table. If down the interface, this router item
6will be deleted from kernel main router table, but it will not be
7deleted from zebra router table, just set as inactive.
8
9This patch is adopted from [1].
10[1] http://www.gossamer-threads.com/lists/quagga/dev/22609
11
12Upstream-Status: Pending
13
14Signed-of-by: Aws Ismail <aws.ismail@windriver.com>
15Signed-of-by: Roy.Li <rongqing.li@windriver.com>
16
17---
18 zebra/zebra_rib.c | 7 +++++++
19 1 files changed, 7 insertions(+), 0 deletions(-)
20
21diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
22index 154e8d5..63434d0 100644
23--- a/zebra/zebra_rib.c
24+++ b/zebra/zebra_rib.c
25@@ -765,6 +765,9 @@ rib_match_ipv6 (struct in6_addr *addr)
26 #define RIB_SYSTEM_ROUTE(R) \
27 ((R)->type == ZEBRA_ROUTE_KERNEL || (R)->type == ZEBRA_ROUTE_CONNECT)
28
29+#define RIB_KERNEL_ROUTE(R) \
30+ ((R)->type == ZEBRA_ROUTE_KERNEL)
31+
32 /* This function verifies reachability of one given nexthop, which can be
33 * numbered or unnumbered, IPv4 or IPv6. The result is unconditionally stored
34 * in nexthop->flags field. If the 4th parameter, 'set', is non-zero,
35@@ -1135,6 +1138,10 @@ rib_process (struct route_node *rn)
36 redistribute_delete (&rn->p, fib);
37 if (! RIB_SYSTEM_ROUTE (fib))
38 rib_uninstall_kernel (rn, fib);
39+#ifdef GNU_LINUX
40+ else if(RIB_KERNEL_ROUTE (fib) && !if_is_up(if_lookup_by_index(fib->nexthop->ifindex)))
41+ del=fib;
42+#endif
43 UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED);
44
45 /* Set real nexthop. */
46--
471.7.4.1
48
diff --git a/meta-networking/recipes-protocols/quagga/files/babel-close-the-stdout-stderr-as-in-other-daemons.patch b/meta-networking/recipes-protocols/quagga/files/babel-close-the-stdout-stderr-as-in-other-daemons.patch
new file mode 100644
index 000000000..c2757a2fb
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/babel-close-the-stdout-stderr-as-in-other-daemons.patch
@@ -0,0 +1,50 @@
1From ba71f768e6dbb1f2ac72ed3bd880bff75a48d345 Mon Sep 17 00:00:00 2001
2From: Roy Li <rongqing.li@windriver.com>
3Date: Wed, 19 Feb 2014 14:13:40 +0800
4Subject: [PATCH] babeld: close stdout once the background daemon is created
5
6Upstream-Status: pending
7
8Once babald becomes a background daemon, it should not output information to
9stdout, so need to close stdout.
10
11In fact, other daemons close their stdout when they run into background, like
12ospfd, isisd and bgpd, by calling daemon() which is in lib/daemon.c
13
14Closing the stdout can fix a tee hang issue { #/usr/sbin/babeld -d |tee tmp }
15
16Signed-off-by: Roy Li <rongqing.li@windriver.com>
17---
18 babeld/util.c | 10 +++++++++-
19 1 file changed, 9 insertions(+), 1 deletion(-)
20
21diff --git a/babeld/util.c b/babeld/util.c
22index 011f382..76203bc 100644
23--- a/babeld/util.c
24+++ b/babeld/util.c
25@@ -425,7 +425,7 @@ uchar_to_in6addr(struct in6_addr *dest, const unsigned char *src)
26 int
27 daemonise()
28 {
29- int rc;
30+ int rc, fd;
31
32 fflush(stdout);
33 fflush(stderr);
34@@ -441,5 +441,13 @@ daemonise()
35 if(rc < 0)
36 return -1;
37
38+ fd = open("/dev/null", O_RDWR, 0);
39+ if (fd != -1)
40+ {
41+ dup2(fd, STDOUT_FILENO);
42+ if (fd > 2)
43+ close(fd);
44+ }
45+
46 return 1;
47 }
48--
491.7.10.4
50
diff --git a/meta-networking/recipes-protocols/quagga/files/babeld.service b/meta-networking/recipes-protocols/quagga/files/babeld.service
new file mode 100644
index 000000000..dd344b0b3
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/babeld.service
@@ -0,0 +1,14 @@
1[Unit]
2Description=Babel routing daemon
3BindTo=zebra.service
4After=zebra.service
5ConditionPathExists=@SYSCONFDIR@/quagga/babeld.conf
6
7[Service]
8Type=forking
9EnvironmentFile=-@SYSCONFDIR@/default/quagga
10ExecStart=@SBINDIR@/babeld -d $babeld_options -f /etc/quagga/babeld.conf
11Restart=on-abort
12
13[Install]
14WantedBy=multi-user.target
diff --git a/meta-networking/recipes-protocols/quagga/files/bgpd.service b/meta-networking/recipes-protocols/quagga/files/bgpd.service
new file mode 100644
index 000000000..164c81724
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/bgpd.service
@@ -0,0 +1,14 @@
1[Unit]
2Description=BGP routing daemon
3BindTo=zebra.service
4After=zebra.service
5ConditionPathExists=@SYSCONFDIR@/quagga/bgpd.conf
6
7[Service]
8Type=forking
9EnvironmentFile=-@SYSCONFDIR@/default/quagga
10ExecStart=@SBINDIR@/bgpd -d $bgpd_options -f /etc/quagga/bgpd.conf
11Restart=on-abort
12
13[Install]
14WantedBy=multi-user.target
diff --git a/meta-networking/recipes-protocols/quagga/files/isisd.service b/meta-networking/recipes-protocols/quagga/files/isisd.service
new file mode 100644
index 000000000..9bfe7b65e
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/isisd.service
@@ -0,0 +1,14 @@
1[Unit]
2Description=IS-IS routing daemon
3BindTo=zebra.service
4After=zebra.service
5ConditionPathExists=@SYSCONFDIR@/quagga/isisd.conf
6
7[Service]
8Type=forking
9EnvironmentFile=-@SYSCONFDIR@/default/quagga
10ExecStart=@SBINDIR@/isisd -d $isisd_options -f /etc/quagga/isisd.conf
11Restart=on-abort
12
13[Install]
14WantedBy=multi-user.target
diff --git a/meta-networking/recipes-protocols/quagga/files/ospf6d.service b/meta-networking/recipes-protocols/quagga/files/ospf6d.service
new file mode 100644
index 000000000..4b8ebf802
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/ospf6d.service
@@ -0,0 +1,14 @@
1[Unit]
2Description=OSPF routing daemon for IPv6
3BindTo=zebra.service
4After=zebra.service
5ConditionPathExists=@SYSCONFDIR@/quagga/ospf6d.conf
6
7[Service]
8Type=forking
9EnvironmentFile=-@SYSCONFDIR@/default/quagga
10ExecStart=@SBINDIR@/ospf6d -d $ospf6d_options -f /etc/quagga/ospf6d.conf
11Restart=on-abort
12
13[Install]
14WantedBy=multi-user.target
diff --git a/meta-networking/recipes-protocols/quagga/files/ospfd.service b/meta-networking/recipes-protocols/quagga/files/ospfd.service
new file mode 100644
index 000000000..f9f5031b4
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/ospfd.service
@@ -0,0 +1,14 @@
1[Unit]
2Description=OSPF routing daemon
3BindTo=zebra.service
4After=zebra.service
5ConditionPathExists=@SYSCONFDIR@/quagga/ospfd.conf
6
7[Service]
8Type=forking
9EnvironmentFile=-@SYSCONFDIR@/default/quagga
10ExecStart=@SBINDIR@/ospfd -d $ospfd_options -f /etc/quagga/ospfd.conf
11Restart=on-abort
12
13[Install]
14WantedBy=multi-user.target
diff --git a/meta-networking/recipes-protocols/quagga/files/quagga-Avoid-duplicate-connected-address.patch b/meta-networking/recipes-protocols/quagga/files/quagga-Avoid-duplicate-connected-address.patch
new file mode 100644
index 000000000..a07e33f9f
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/quagga-Avoid-duplicate-connected-address.patch
@@ -0,0 +1,54 @@
1quagga: Avoid duplicate connected address adding to the list
2
3commit 27ba970b9("quagga/ripd: Fix two bugs after received SIGHUP signal")
4introduces an regression: ifp->connected list is cleaned up when ripd is
5restarting, however, for interface addresses which are not specified in
6ripd configuration file, they are never to be added into ifp->connected
7again, this will lead to some abnormal behavior for route advertising.
8
9Instead of cleaning up the ifp->connected list to avoid duplicated
10connected address being added into this list, we can check this
11condition during interface address adding process and return early
12when an identical address has already been added.
13
14Upstream-Status: Pending
15
16Signed-off-by: Hu Yadi <Yadi.hu@windriver.com>
17Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com>
18Signed-off-by: Joe MacDonald <joe@deserted.net>
19---
20--- a/lib/if.c
21+++ b/lib/if.c
22@@ -738,6 +738,16 @@ connected_add_by_prefix (struct interfac
23 struct prefix *destination)
24 {
25 struct connected *ifc;
26+ struct listnode *cnode;
27+ struct connected *c;
28+ int ret = 0;
29+
30+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c))
31+ {
32+ ret = connected_same_prefix (p, (c->address));
33+ if(ret == 1)
34+ return NULL;
35+ }
36
37 /* Allocate new connected address. */
38 ifc = connected_new ();
39--- a/ripd/rip_interface.c
40+++ b/ripd/rip_interface.c
41@@ -516,13 +516,6 @@ rip_interface_clean (void)
42 thread_cancel (ri->t_wakeup);
43 ri->t_wakeup = NULL;
44 }
45-
46- for (conn_node = listhead (ifp->connected); conn_node; conn_node = next)
47- {
48- ifc = listgetdata (conn_node);
49- next = conn_node->next;
50- listnode_delete (ifp->connected, ifc);
51- }
52 }
53 }
54
diff --git a/meta-networking/recipes-protocols/quagga/files/quagga.default b/meta-networking/recipes-protocols/quagga/files/quagga.default
new file mode 100644
index 000000000..0c1ce6c04
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/quagga.default
@@ -0,0 +1,13 @@
1# If this option is set the /etc/init.d/quagga script automatically loads
2# the config via "vtysh -b" when the servers are started.
3vtysh_enable=yes
4
5# Bind all daemons to loopback only by default
6zebra_options=" --daemon -A 127.0.0.1"
7babeld_options="--daemon -A 127.0.0.1"
8bgpd_options=" --daemon -A 127.0.0.1"
9ospfd_options=" --daemon -A 127.0.0.1"
10ospf6d_options="--daemon -A ::1"
11ripd_options=" --daemon -A 127.0.0.1"
12ripngd_options="--daemon -A ::1"
13isisd_options=" --daemon -A 127.0.0.1"
diff --git a/meta-networking/recipes-protocols/quagga/files/quagga.init b/meta-networking/recipes-protocols/quagga/files/quagga.init
new file mode 100644
index 000000000..60b5ab01a
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/quagga.init
@@ -0,0 +1,200 @@
1#!/bin/sh
2#
3# /etc/init.d/quagga -- start/stop the Quagga routing daemons
4#
5# Based on debian version by Endre Hirling <endre@mail.elte.hu> and
6# Christian Hammers <ch@debian.org>.
7#
8
9### BEGIN INIT INFO
10# Provides: quagga
11# Required-Start: $local_fs $network $remote_fs $syslog
12# Required-Stop: $local_fs $network $remote_fs $syslog
13# Default-Start: 2 3 4 5
14# Default-Stop: 0 1 6
15# Short-Description: start and stop the Quagga routing suite
16# Description: Quagga is a routing suite for IP routing protocols like
17# BGP, OSPF, RIP and others. This script contols the main
18# daemon "quagga" as well as the individual protocol daemons.
19### END INIT INFO
20
21# NOTE: sbin must be before bin so we get the iproute2 ip and not the
22# busybox ip command. The busybox one flushes all routes instead of just
23# the dynamic routes
24PATH=/sbin:/usr/sbin:/bin:/usr/bin:/sbin
25D_PATH=/usr/sbin
26C_PATH=/etc/quagga
27
28# Keep zebra first and do not list watchquagga!
29DAEMONS="zebra bgpd ripd ripngd ospfd ospf6d isisd babeld"
30
31# Print the name of the pidfile.
32pidfile()
33{
34 echo "/var/run/quagga/$1.pid"
35}
36
37# Check if daemon is started by using the pidfile.
38started()
39{
40 [ -e `pidfile $1` ] && kill -0 `cat \`pidfile $1\`` 2> /dev/null && return 0
41 return 1
42}
43
44# Loads the config via vtysh -b if configured to do so.
45vtysh_b ()
46{
47 # Rember, that all variables have been incremented by 1 in convert_daemon_prios()
48 if [ "$vtysh_enable" = 2 -a -f $C_PATH/Quagga.conf ]; then
49 /usr/bin/vtysh -b
50 fi
51}
52
53# Check if the daemon is activated and if its executable and config files
54# are in place.
55# params: daemon name
56# returns: 0=ok, 1=error
57check_daemon()
58{
59 # If the integrated config file is used the others are not checked.
60 if [ -r "$C_PATH/Quagga.conf" ]; then
61 return 0
62 fi
63
64 # check for config file
65 if [ ! -r "$C_PATH/$1.conf" ]; then
66 return 1
67 fi
68 return 0
69}
70
71# Starts the server if it's not alrady running according to the pid file.
72# The Quagga daemons creates the pidfile when starting.
73start()
74{
75 if ! check_daemon $1; then echo -n " (!$1)"; return; fi
76 echo -n " $1"
77 start-stop-daemon \
78 --start \
79 --pidfile=`pidfile $1` \
80 --exec "$D_PATH/$1" \
81 -- \
82 `eval echo "$""$1""_options"`
83
84}
85
86# Stop the daemon given in the parameter, printing its name to the terminal.
87stop()
88{
89 if ! started "$1" ; then
90 echo -n " (!$1)"
91 return 0
92 else
93 PIDFILE=`pidfile $1`
94 PID=`cat $PIDFILE 2>/dev/null`
95 start-stop-daemon --stop --quiet --exec "$D_PATH/$1"
96 #
97 # Now we have to wait until $DAEMON has _really_ stopped.
98 #
99 if test -n "$PID" && kill -0 $PID 2>/dev/null; then
100 echo -n " (waiting) ."
101 cnt=0
102 while kill -0 $PID 2>/dev/null; do
103 cnt=`expr $cnt + 1`
104 if [ $cnt -gt 60 ]; then
105 # Waited 120 secs now, fail.
106 echo -n "Failed.. "
107 break
108 fi
109 sleep 2
110 echo -n "."
111 done
112 fi
113 echo -n " $1"
114 rm -f `pidfile $1`
115 fi
116}
117
118stop_all()
119{
120 local daemon_list
121 daemon_list=${1:-$DAEMONS}
122
123 echo -n "Stopping Quagga daemons:"
124 for daemon_name in $daemon_list; do
125 stop "$daemon_name"
126 done
127 echo "."
128}
129
130start_all()
131{
132 local daemon_list
133 daemon_list=${1:-$DAEMONS}
134
135 echo -n "Starting Quagga daemons:"
136 for daemon_name in $daemon_list; do
137 start "$daemon_name"
138 done
139 echo "."
140}
141
142status_all()
143{
144 local daemon_list
145 daemon_list=${1:-$DAEMONS}
146 res=1
147
148 echo -n "quagga: "
149 for daemon_name in $daemon_list; do
150 if started "$daemon_name" ; then
151 id=`cat \`pidfile $daemon_name\``
152 echo -n "$daemon_name (pid $id) "
153 res=0
154 fi
155 done
156 if [ $res -eq 0 ]; then
157 echo "is running..."
158 else
159 echo "is stopped..."
160 fi
161 exit $res
162}
163
164#########################################################
165# Main program #
166#########################################################
167
168# Load configuration
169test -f /etc/default/quagga && . /etc/default/quagga
170
171case "$1" in
172 start)
173 cd $C_PATH/
174 start_all $2
175 vtysh_b
176 ;;
177
178 stop)
179 stop_all $2
180 echo "Removing all routes made by zebra."
181 ip route flush proto zebra
182 ;;
183
184 status)
185 status_all $2
186 ;;
187
188 restart|force-reload)
189 $0 stop $2
190 sleep 1
191 $0 start $2
192 ;;
193
194 *)
195 echo "Usage: /etc/init.d/quagga {start|stop|restart|status|force-reload} [daemon]"
196 exit 1
197 ;;
198esac
199
200exit 0
diff --git a/meta-networking/recipes-protocols/quagga/files/quagga.pam b/meta-networking/recipes-protocols/quagga/files/quagga.pam
new file mode 100644
index 000000000..3541a975a
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/quagga.pam
@@ -0,0 +1,13 @@
1#
2# The PAM configuration file for the quagga `vtysh' service
3#
4
5# This allows root to change user infomation without being
6# prompted for a password
7auth sufficient pam_rootok.so
8
9# The standard Unix authentication modules, used with
10# NIS (man nsswitch) as well as normal /etc/passwd and
11# /etc/shadow entries.
12auth include common-auth
13
diff --git a/meta-networking/recipes-protocols/quagga/files/ripd-fix-two-bugs-after-received-SIGHUP.patch b/meta-networking/recipes-protocols/quagga/files/ripd-fix-two-bugs-after-received-SIGHUP.patch
new file mode 100644
index 000000000..4b8c9a929
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/ripd-fix-two-bugs-after-received-SIGHUP.patch
@@ -0,0 +1,50 @@
1ripd: Fix two bugs after received SIGHUP signal
2
3There are two problems for ripd implementation after received
4SIGHUP signal:
51). ripd didn't clean up ifp->connected list before reload
6 configuration file.
72). ripd reset ri->split_horizon flag to RIP_NO_SPLIT_HORIZON
8 which lead to the unnecessary route to be advertised.
9
10Upstream-Status: Submitted [http://patchwork.diac24.net/patch/604/]
11
12Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com>
13Signed-off-by: Joe MacDonald <joe@deserted.net>
14---
15--- a/ripd/rip_interface.c
16+++ b/ripd/rip_interface.c
17@@ -500,6 +500,8 @@
18 struct listnode *node;
19 struct interface *ifp;
20 struct rip_interface *ri;
21+ struct connected *ifc;
22+ struct listnode *conn_node, *next;
23
24 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
25 {
26@@ -514,6 +516,13 @@
27 thread_cancel (ri->t_wakeup);
28 ri->t_wakeup = NULL;
29 }
30+
31+ for (conn_node = listhead (ifp->connected); conn_node; conn_node = next)
32+ {
33+ ifc = listgetdata (conn_node);
34+ next = conn_node->next;
35+ listnode_delete (ifp->connected, ifc);
36+ }
37 }
38 }
39
40@@ -548,8 +557,8 @@
41 ri->key_chain = NULL;
42 }
43
44- ri->split_horizon = RIP_NO_SPLIT_HORIZON;
45- ri->split_horizon_default = RIP_NO_SPLIT_HORIZON;
46+ ri->split_horizon = RIP_SPLIT_HORIZON;
47+ ri->split_horizon_default = RIP_SPLIT_HORIZON;
48
49 ri->list[RIP_FILTER_IN] = NULL;
50 ri->list[RIP_FILTER_OUT] = NULL;
diff --git a/meta-networking/recipes-protocols/quagga/files/ripd.service b/meta-networking/recipes-protocols/quagga/files/ripd.service
new file mode 100644
index 000000000..5dfd28b3a
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/ripd.service
@@ -0,0 +1,14 @@
1[Unit]
2Description=RIP routing daemon
3BindTo=zebra.service
4After=zebra.service
5ConditionPathExists=@SYSCONFDIR@/quagga/ripd.conf
6
7[Service]
8Type=forking
9EnvironmentFile=-@SYSCONFDIR@/default/quagga
10ExecStart=@SBINDIR@/ripd -d $ripd_options -f /etc/quagga/ripd.conf
11Restart=on-abort
12
13[Install]
14WantedBy=multi-user.target
diff --git a/meta-networking/recipes-protocols/quagga/files/ripngd.service b/meta-networking/recipes-protocols/quagga/files/ripngd.service
new file mode 100644
index 000000000..936b81fb9
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/ripngd.service
@@ -0,0 +1,14 @@
1i[Unit]
2Description=RIP routing daemon for IPv6
3BindTo=zebra.service
4After=zebra.service
5ConditionPathExists=@SYSCONFDIR@/quagga/ripngd.conf
6
7[Service]
8Type=forking
9EnvironmentFile=-@SYSCONFDIR@/default/quagga
10ExecStart=@SBINDIR@/ripngd -d $ripngd_options -f /etc/quagga/ripngd.conf
11Restart=on-abort
12
13[Install]
14WantedBy=multi-user.target
diff --git a/meta-networking/recipes-protocols/quagga/files/volatiles.03_quagga b/meta-networking/recipes-protocols/quagga/files/volatiles.03_quagga
new file mode 100644
index 000000000..1f28c0b24
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/volatiles.03_quagga
@@ -0,0 +1,3 @@
1# <type> <owner> <group> <mode> <path> <linksource>
2d quagga quagga 0755 /var/run/quagga none
3d quagga quagga 0755 /var/log/quagga none
diff --git a/meta-networking/recipes-protocols/quagga/files/watchquagga.default b/meta-networking/recipes-protocols/quagga/files/watchquagga.default
new file mode 100644
index 000000000..2d601ec97
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/watchquagga.default
@@ -0,0 +1,12 @@
1# Watchquagga configuration
2#watch_daemons="zebra bgpd ospfd ospf6d ripd ripngd"
3watch_daemons="zebra"
4
5# To enable restarts when multiple daemons are being used, uncomment this line (but first be sure to edit
6# the WATCH_DAEMONS line to reflect the daemons you are actually using):
7#watch_options="-Az -b_ -r/etc/init.d/quagga_restart_%s -s/etc/init.d/quagga_start_%s -k/etc/init.d/quagga_stop_%s"
8
9# Since we are using one quagga daemon for now, use the following line. If using
10# multiple daemons, comment the line below and uncoment the line mentioned
11# above.
12watch_options="-z -b_ -r/etc/init.d/quagga_restart_%s"
diff --git a/meta-networking/recipes-protocols/quagga/files/watchquagga.init b/meta-networking/recipes-protocols/quagga/files/watchquagga.init
new file mode 100644
index 000000000..5ddd94a3d
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/watchquagga.init
@@ -0,0 +1,64 @@
1#!/bin/sh
2#
3### BEGIN INIT INFO
4# Provides: watchquagga
5# Required-Start: $local_fs $network $remote_fs $syslog
6# Required-Stop: $local_fs $network $remote_fs $syslog
7# Default-Start: 2 3 4 5
8# Default-Stop: 0 1 6
9# Short-Description: start and stop the Quagga watchdog
10### END INIT INFO
11
12PATH=/bin:/usr/bin:/sbin:/usr/sbin
13
14# Load configuration
15test -f /etc/default/watchquagga && . /etc/default/watchquagga
16
17# Check that there are daemons to be monitored.
18[ -z "$watch_daemons" ] && exit 0
19
20pidfile="/var/run/quagga/watchquagga.pid"
21
22case "$1" in
23 start)
24 echo -n "Starting quagga watchdog daemon: watchquagga"
25 start-stop-daemon --start \
26 --pidfile $pidfile \
27 --exec /usr/sbin/watchquagga \
28 -- -d $watch_options $watch_daemons
29 echo "."
30 ;;
31
32 stop)
33 echo -n "Stopping quagga watchdog daemon: watchquagga"
34 start-stop-daemon --stop --quiet \
35 --pidfile $pidfile
36 echo "."
37 ;;
38
39 status)
40 echo -n "watchquagga "
41 res=1
42 [ -e $pidfile ] && kill -0 `cat $pidfile` 2> /dev/null
43 if [ $? -eq 0 ]; then
44 echo "(pid `cat $pidfile`) is running..."
45 res=0
46 else
47 echo "is stopped..."
48 fi
49 exit $res
50 ;;
51
52 restart|force-reload)
53 $0 stop $2
54 sleep 1
55 $0 start $2
56 ;;
57
58 *)
59 echo "Usage: /etc/init.d/watchquagga {start|stop|restart|force-reload}"
60 exit 1
61 ;;
62esac
63
64exit 0
diff --git a/meta-networking/recipes-protocols/quagga/files/zebra.service b/meta-networking/recipes-protocols/quagga/files/zebra.service
new file mode 100644
index 000000000..afdd9e52d
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/files/zebra.service
@@ -0,0 +1,15 @@
1[Unit]
2Description=GNU Zebra routing manager
3Wants=network.target
4Before=network.target
5ConditionPathExists=@SYSCONFDIR@/quagga/zebra.conf
6
7[Service]
8Type=forking
9EnvironmentFile=-@SYSCONFDIR@/default/quagga
10ExecStartPre=@BASE_SBINDIR@/ip route flush proto zebra
11ExecStart=@SBINDIR@/zebra -d $zebra_options -f /etc/quagga/zebra.conf
12Restart=on-abort
13
14[Install]
15WantedBy=multi-user.target
diff --git a/meta-networking/recipes-protocols/quagga/quagga.inc b/meta-networking/recipes-protocols/quagga/quagga.inc
new file mode 100644
index 000000000..2c0817b83
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/quagga.inc
@@ -0,0 +1,250 @@
1SUMMARY = "BGP/OSPF/RIP routing daemon"
2DESCRIPTION = "Quagga is a routing software suite, providing \
3implementations of OSPFv2, OSPFv3, RIP v1 and v2, RIPv3 and BGPv4 for \
4Unix platforms, particularly FreeBSD, Linux, Solaris and NetBSD. \
5Quagga is a fork of GNU Zebra which was developed by Kunihiro \
6Ishiguro. The Quagga tree aims to build a more involved community \
7around Quagga than the current centralised model of GNU Zebra."
8HOMEPAGE = "http://www.nongnu.org/quagga/"
9SECTION = "network"
10LICENSE = "GPL-2.0 & LGPL-2.0"
11DEPENDS = "readline ncurses perl-native"
12DEPENDS += "${@base_contains('DISTRO_FEATURES', 'snmp', 'net-snmp', '', d)}"
13SNMP_CONF="${@base_contains('DISTRO_FEATURES', 'snmp', '--enable-snmp', '', d)}"
14
15LIC_FILES_CHKSUM = "file://COPYING;md5=81bcece21748c91ba9992349a91ec11d \
16 file://COPYING.LIB;md5=01ef24401ded36cd8e5d18bfe947240c"
17
18# the "ip" command from busybox is not sufficient (flush by protocol flushes all routes)
19RDEPENDS_${PN} += "iproute2"
20
21QUAGGASUBDIR = ""
22# ${QUAGGASUBDIR} is deal with old versions. Set to "/attic" for old
23# versions and leave it empty for recent versions.
24SRC_URI = "${SAVANNAH_GNU_MIRROR}/quagga${QUAGGASUBDIR}/quagga-${PV}.tar.gz; \
25 file://Zebra-sync-zebra-routing-table-with-the-kernel-one.patch \
26 file://quagga.init \
27 file://quagga.default \
28 file://watchquagga.init \
29 file://watchquagga.default \
30 file://volatiles.03_quagga \
31 file://quagga.pam \
32 file://ripd-fix-two-bugs-after-received-SIGHUP.patch \
33 file://quagga-Avoid-duplicate-connected-address.patch \
34 file://babeld.service \
35 file://bgpd.service \
36 file://isisd.service \
37 file://ospf6d.service \
38 file://ospfd.service \
39 file://ripd.service \
40 file://ripngd.service \
41 file://zebra.service \
42"
43
44PACKAGECONFIG ??= "${@base_contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}"
45PACKAGECONFIG[cap] = "--enable-capabilities,--disable-capabilities,libcap"
46PACKAGECONFIG[pam] = "--with-libpam, --without-libpam, libpam"
47
48inherit autotools update-rc.d useradd systemd
49
50SYSTEMD_PACKAGES = "${PN} ${PN}-babeld ${PN}-bgpd ${PN}-isisd ${PN}-ospf6d ${PN}-ospfd ${PN}-ripd ${PN}-ripngd"
51SYSTEMD_SERVICE_${PN}-babeld = "babeld.service"
52SYSTEMD_SERVICE_${PN}-bgpd = "bgpd.service"
53SYSTEMD_SERVICE_${PN}-isisd = "isisd.service"
54SYSTEMD_SERVICE_${PN}-ospf6d = "ospf6d.service"
55SYSTEMD_SERVICE_${PN}-ospfd = "ospfd.service"
56SYSTEMD_SERVICE_${PN}-ripd = "ripd.service"
57SYSTEMD_SERVICE_${PN}-ripngd = "ripngd.service"
58SYSTEMD_SERVICE_${PN} = "zebra.service"
59
60EXTRA_OECONF = "--sysconfdir=${sysconfdir}/quagga \
61 --localstatedir=${localstatedir}/run/quagga \
62 --enable-exampledir=${docdir}/quagga/examples/ \
63 --enable-vtysh \
64 --enable-isisd \
65 ${@base_contains('DISTRO_FEATURES', 'sysvinit', '--enable-watchquagga', '--disable-watchquagga', d)} \
66 --enable-ospf-te \
67 --enable-opaque-lsa \
68 --enable-ipv6 \
69 --enable-ospfclient=yes \
70 --enable-multipath=64 \
71 --enable-user=quagga \
72 --enable-group=quagga \
73 --enable-vty-group=quaggavty \
74 --enable-configfile-mask=0640 \
75 --enable-logfile-mask=0640 \
76 --enable-rtadv \
77 --enable-linux24-tcp-md5 \
78 ap_cv_cc_pie=no \
79 ${SNMP_CONF}"
80
81do_install () {
82 # Install init script and default settings
83 install -m 0755 -d ${D}${sysconfdir}/default ${D}${sysconfdir}/init.d \
84 ${D}${sysconfdir}/quagga ${D}${sysconfdir}/default/volatiles
85 install -m 0644 ${WORKDIR}/quagga.default ${D}${sysconfdir}/default/quagga
86 install -m 0644 ${WORKDIR}/watchquagga.default ${D}${sysconfdir}/default/watchquagga
87 install -m 0755 ${WORKDIR}/quagga.init ${D}${sysconfdir}/init.d/quagga
88 install -m 0755 ${WORKDIR}/watchquagga.init ${D}${sysconfdir}/init.d/watchquagga
89 install -m 0644 ${WORKDIR}/volatiles.03_quagga ${D}${sysconfdir}/default/volatiles/volatiles.03_quagga
90
91 # Install sample configurations for the daemons
92 for f in bgpd vtysh babeld isisd ospfd ripngd zebra ripd ospf6d; do
93 install -m 0640 ${S}/$f/$f.conf.sample ${D}${sysconfdir}/quagga/$f.conf.sample
94 done
95
96 for f in bgpd vtysh babeld isisd ospfd ripngd zebra ripd ospf6d; do
97 touch ${D}${sysconfdir}/quagga/$f.conf
98 done
99 chown quagga:quaggavty ${D}${sysconfdir}/quagga
100 chown quagga:quagga ${D}${sysconfdir}/quagga/*.conf
101 chmod 750 ${D}${sysconfdir}/quagga
102 chmod 640 ${D}${sysconfdir}/quagga/*.conf
103
104 # Install quagga
105 oe_runmake install DESTDIR=${D} prefix=${prefix} \
106 sbindir=${sbindir} \
107 sysconfdir=${sysconfdir}/quagga \
108 localstatedir=${localstatedir}/run/quagga
109
110 # Fix hardcoded paths
111 sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/*
112 sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/quagga
113 sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/* ${D}${sysconfdir}/default/watchquagga
114 sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/* ${D}${sysconfdir}/default/volatiles/volatiles.03_quagga
115 sed -i 's!^PATH=.*!PATH=${base_sbindir}:${sbindir}:${base_bindir}:${bindir}!' ${D}${sysconfdir}/init.d/*
116
117 # Remove generated info dir file, it doesn't belong in the generated
118 # package.
119 rm -f ${D}${infodir}/dir
120
121 # For PAM
122 for feature in ${DISTRO_FEATURES}; do
123 if [ "$feature" = "pam" ]; then
124 install -D -m 644 ${WORKDIR}/quagga.pam ${D}/${sysconfdir}/pam.d/quagga
125 break
126 fi
127 done
128
129 if ${@base_contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
130 install -d ${D}${sysconfdir}/tmpfiles.d
131 echo "d /var/run/quagga 0755 quagga quagga -" \
132 > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
133 fi
134
135 # Remove sysinit script if sysvinit is not in DISTRO_FEATURES
136 if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'false', 'true', d)}; then
137 rm -rf ${D}${sysconfdir}/init.d/
138 rm -f ${D}${sysconfdir}/default/watchquagga
139 fi
140
141 install -d ${D}${systemd_unitdir}/system
142 for i in babeld bgpd isisd ospf6d ospfd ripd ripngd zebra; do
143 install -m 0644 ${WORKDIR}/$i.service ${D}${systemd_unitdir}/system
144 done
145 sed -e 's,@BASE_SBINDIR@,${base_sbindir},g' \
146 -e 's,@SYSCONFDIR@,${sysconfdir},g' \
147 -e 's,@SBINDIR@,${sbindir},g' \
148 -i ${D}${systemd_unitdir}/system/*.service
149}
150
151DEPENDS_append = " ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd-systemctl-native', '', d)}"
152pkg_postinst_${PN} () {
153 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd sysvinit', 'true', 'false', d)}; then
154 if [ -n "$D" ]; then
155 OPTS="--root=$D"
156 fi
157 systemctl $OPTS mask quagga.service
158 fi
159}
160
161# Split into a main package and separate per-protocol packages
162PACKAGE_BEFORE_PN = "${PN}-ospfd ${PN}-ospf6d ${PN}-babeld ${PN}-bgpd \
163 ${PN}-ripd ${PN}-ripngd ${PN}-isisd \
164 ${PN}-ospfclient ${@base_contains('DISTRO_FEATURES', 'sysvinit', '${PN}-watchquagga', '', d)}"
165
166RDEPENDS_${PN} += "${PN}-babeld ${PN}-bgpd ${PN}-isisd ${PN}-ospf6d ${PN}-ospfd ${PN}-ripd ${PN}-ripngd"
167
168FILES_${PN}-ospfd = "${sbindir}/ospfd ${libdir}/libospf.so.*"
169FILES_${PN}-ospf6d = "${sbindir}/ospf6d"
170FILES_${PN}-babeld = "${sbindir}/babeld"
171FILES_${PN}-bgpd = "${sbindir}/bgpd"
172FILES_${PN}-ripd = "${sbindir}/ripd"
173FILES_${PN}-ripngd = "${sbindir}/ripngd"
174FILES_${PN}-isisd = "${sbindir}/isisd"
175FILES_${PN}-ospfclient = "${sbindir}/ospfclient ${libdir}/libospfapiclient.so.*"
176FILES_${PN}-watchquagga = "${sbindir}/watchquagga ${sysconfdir}/default/watchquagga \
177 ${sysconfdir}/init.d/watchquagga"
178
179# Indicate that the default files are configuration files
180CONFFILES_${PN} = "${sysconfdir}/default/quagga \
181 ${sysconfdir}/quagga/bgpd.conf \
182 ${sysconfdir}/quagga/vtysh.conf \
183 ${sysconfdir}/quagga/babeld.conf \
184 ${sysconfdir}/quagga/isisd.conf \
185 ${sysconfdir}/quagga/ospfd.conf \
186 ${sysconfdir}/quagga/ripngd.conf \
187 ${sysconfdir}/quagga/zebra.conf \
188 ${sysconfdir}/quagga/ripd.conf \
189 ${sysconfdir}/quagga/ospf6d.conf \
190 "
191CONFFILES_${PN}-watchquagga = "${sysconfdir}/default/watchquagga"
192
193# Stop the names being rewritten due to the internal shared libraries
194DEBIAN_NOAUTONAME_${PN}-ospfd = "1"
195DEBIAN_NOAUTONAME_${PN}-ospfclient = "1"
196
197# the "ip" command from busybox is not sufficient (flush by protocol flushes all routes)
198RDEPENDS_${PN} += "iproute2"
199
200# Main init script starts all deamons
201# Seperate init script for watchquagga
202INITSCRIPT_PACKAGES = "${PN} ${PN}-watchquagga"
203INITSCRIPT_NAME_${PN} = "quagga"
204INITSCRIPT_PARAMS_${PN} = "defaults 15 85"
205INITSCRIPT_NAME_${PN}-watchquagga = "watchquagga"
206INITSCRIPT_PARAMS_${PN}-watchquagga = "defaults 90 10"
207
208# Add quagga's user and group
209USERADD_PACKAGES = "${PN}"
210GROUPADD_PARAM_${PN} = "--system quagga ; --system quaggavty"
211USERADD_PARAM_${PN} = "--system --home ${localstatedir}/run/quagga/ -M -g quagga --shell /bin/false quagga"
212
213pkg_postinst_${PN} () {
214 if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then
215 ${sysconfdir}/init.d/populate-volatile.sh update
216 fi
217}
218
219# Stop apps before uninstall
220pkg_prerm_${PN} () {
221 ${sysconfdir}/init.d/quagga stop
222}
223
224pkg_prerm_${PN}-ospfd () {
225 ${sysconfdir}/init.d/quagga stop ospfd
226}
227
228pkg_prerm_${PN}-ospf6d () {
229 ${sysconfdir}/init.d/quagga stop ospf6d
230}
231
232pkg_prerm_${PN}-babeld () {
233 ${sysconfdir}/init.d/quagga stop babeld
234}
235
236pkg_prerm_${PN}-bgpd () {
237 ${sysconfdir}/init.d/quagga stop bgpd
238}
239
240pkg_prerm_${PN}-ripd () {
241 ${sysconfdir}/init.d/quagga stop ripd
242}
243
244pkg_prerm_${PN}-ripngd () {
245 ${sysconfdir}/init.d/quagga stop ripngd
246}
247
248pkg_prerm_${PN}-isisd () {
249 ${sysconfdir}/init.d/quagga stop isisd
250}
diff --git a/meta-networking/recipes-protocols/quagga/quagga_0.99.23.bb b/meta-networking/recipes-protocols/quagga/quagga_0.99.23.bb
new file mode 100644
index 000000000..a56767e51
--- /dev/null
+++ b/meta-networking/recipes-protocols/quagga/quagga_0.99.23.bb
@@ -0,0 +1,9 @@
1require quagga.inc
2
3SRC_URI += "file://babel-close-the-stdout-stderr-as-in-other-daemons.patch \
4"
5
6SRC_URI[md5sum] = "d17145e62b6ea14f0f13bb63f59e5166"
7SRC_URI[sha256sum] = "2c7798204f35dc7acea9f206647e8aa3957cae3b21733cdff413b506481a101c"
8
9QUAGGASUBDIR = ""
diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure.patch
new file mode 100644
index 000000000..1380ba489
--- /dev/null
+++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure.patch
@@ -0,0 +1,11 @@
1Index: rp-pppoe-3.8/configure.in
2===================================================================
3--- rp-pppoe-3.8.orig/configure.in 2014-07-16 19:31:33.549991388 +0000
4+++ rp-pppoe-3.8/configure.in 2014-07-17 22:01:18.116590827 +0000
5@@ -1,4 +1,4 @@
6-AC_INIT(src/pppoe.c)
7-AM_INIT_AUTOMAKE([rp-pppoe], [3.8])
8+AC_INIT([rp-pppoe], [3.8])
9+AM_INIT_AUTOMAKE([foreign])
10 AC_CONFIG_SUBDIRS(src)
11 AC_OUTPUT(Makefile)
diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure_in_cross.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure_in_cross.patch
new file mode 100644
index 000000000..189675942
--- /dev/null
+++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/configure_in_cross.patch
@@ -0,0 +1,142 @@
1Update the configure script to cross-compiling with OE. This hard-codes
2a few target paths, reworks a few tests to be more friendly for cross
3and drops other tests.
4
5Upstream-Status: Inappropriate [build system specific changes]
6
7Index: src/configure.in
8===================================================================
9--- rp-pppoe-3.8.orig/src/configure.in 2006-04-03 00:29:42.000000000 +1000
10+++ rp-pppoe-3.8/src/configure.in 2007-06-07 22:19:36.000000000 +1000
11@@ -5,6 +5,13 @@
12 dnl pppd directory for kernel-mode PPPoE
13 PPPD_DIR=ppp-2.4.1.pppoe2
14
15+dnl hard code some paths
16+PPPD=/usr/sbin/pppd
17+ID=/usr/bin/id
18+ECHO=/bin/echo
19+AC_ARG_VAR(PPPD)
20+AC_ARG_VAR(ID)
21+
22 AC_CONFIG_HEADER(config.h)
23
24 AC_PREFIX_DEFAULT(/usr)
25@@ -44,7 +51,7 @@
26 AC_MSG_RESULT($ac_cv_struct_sockaddr_ll)
27
28 if test "$ac_cv_struct_sockaddr_ll" = yes ; then
29-AC_DEFINE(HAVE_STRUCT_SOCKADDR_LL)
30+AC_DEFINE([HAVE_STRUCT_SOCKADDR_LL], [], [Have struct SOCKADDR_LL])
31 fi
32
33 dnl Check for N_HDLC line discipline
34@@ -55,7 +62,7 @@
35 ac_cv_n_hdlc=no)
36 AC_MSG_RESULT($ac_cv_n_hdlc)
37 if test "$ac_cv_n_hdlc" = yes ; then
38-AC_DEFINE(HAVE_N_HDLC)
39+AC_DEFINE([HAVE_N_HDLC], [], [Have N_HDLC])
40 fi
41
42 AC_ARG_ENABLE(plugin, [ --enable-plugin=pppd_src_path build pppd plugin], ac_cv_pluginpath=$enableval, ac_cv_pluginpath=no)
43@@ -100,13 +107,13 @@
44 if test "$ac_cv_header_linux_if_pppox_h" = yes ; then
45 if test "$ac_cv_pluginpath" != no ; then
46 LINUX_KERNELMODE_PLUGIN=rp-pppoe.so
47- AC_DEFINE(HAVE_LINUX_KERNEL_PPPOE)
48+ AC_DEFINE([HAVE_LINUX_KERNEL_PPPOE], [], [Have kernel PPPoE])
49 PPPD_INCDIR=$ac_cv_pluginpath
50 fi
51 fi
52
53 if test "$ac_cv_debugging" = "yes" ; then
54- AC_DEFINE(DEBUGGING_ENABLED)
55+ AC_DEFINE([DEBUGGING_ENABLED], [], [Debugging enabled])
56 fi
57
58 AC_SUBST(LINUX_KERNELMODE_PLUGIN)
59@@ -131,15 +138,8 @@
60 AC_CHECK_SIZEOF(unsigned int)
61 AC_CHECK_SIZEOF(unsigned long)
62
63-dnl Check for location of pppd
64-AC_PATH_PROG(PPPD, pppd, NOTFOUND, $PATH:/sbin:/usr/sbin:/usr/local/sbin)
65-AC_PATH_PROG(ECHO, echo, echo)
66-
67-dnl Check for setsid (probably Linux-specific)
68-AC_PATH_PROG(SETSID, setsid, "", $PATH:/sbin:/usr/sbin:/usr/local/sbin)
69-
70 dnl Check for an "id" which accepts "-u" option -- hack for Solaris.
71-AC_PATH_PROG(ID, id, "", /usr/xpg4/bin:$PATH)
72+dnl AC_PATH_PROG(ID, id, "", /usr/xpg4/bin:$PATH)
73
74 dnl Check for Linux-specific kernel support for PPPoE
75 AC_MSG_CHECKING(for Linux 2.4.X kernel-mode PPPoE support)
76@@ -183,44 +183,8 @@
77 CFLAGS="$CFLAGS -Wall -Wstrict-prototypes -ansi"
78 fi
79
80-dnl If we couldn't find pppd, die
81-if test "$PPPD" = "NOTFOUND"; then
82- AC_MSG_WARN([*** Oops! I couldn't find pppd, the PPP daemon anywhere.])
83- AC_MSG_WARN([*** You must install pppd, version 2.3.10 or later.])
84- AC_MSG_WARN([*** I will keep going, but it may not work.])
85- PPPD=pppd
86-fi
87-
88-dnl Figure out pppd version. 2.3.7 to 2.3.9 -- issue warning. Less than
89-dnl 2.3.7 -- stop
90-
91-PPPD_VERSION=`$PPPD --version 2>&1 | awk ' /version/ {print $NF}'`
92-
93-case "$PPPD_VERSION" in
94-1.*|2.0.*|2.1.*|2.2.*|2.3.0|2.3.1|2.3.2|2.3.3|2.3.4|2.3.5|2.3.6)
95- AC_MSG_WARN([*** Oops! Your version of pppd is $PPPD_VERSION, which is too old.])
96- AC_MSG_WARN([*** You need at least 2.3.7 (2.3.10 or newer recommended.])
97- AC_MSG_WARN([*** I will keep going, but it may not work.])
98- ;;
99-
100-2.3.7|2.3.8|2.3.9)
101- AC_MSG_WARN([*** Warning. Your version of pppd is $PPPD_VERSION. You will])
102- AC_MSG_WARN([*** not be able to use connect-on-demand. Upgrade to pppd])
103- AC_MSG_WARN([*** 2.3.10 or newer if you need connect-on-demand.])
104- ;;
105-
106-2*|3*|4*|5*|6*|7*|8*|9*)
107- ;;
108-
109-*)
110- AC_MSG_WARN([*** Oops. I cannot figure out what version of pppd you have.])
111- AC_MSG_WARN([*** All I got back was '$PPPD_VERSION'])
112- AC_MSG_WARN([*** I will keep going, but it may not work.])
113- ;;
114-esac
115-
116 dnl Figure out packing order of structures
117-AC_MSG_CHECKING([packing order of bit fields])
118+AC_CACHE_CHECK([packing order of bit fields],rpppoe_cv_pack_bitfields,[
119 AC_TRY_RUN([
120 union foo {
121 struct bar {
122@@ -245,10 +209,11 @@
123 }
124 }], rpppoe_cv_pack_bitfields=normal, rpppoe_cv_pack_bitfields=rev,
125 $ECHO "no defaults for cross-compiling"; exit 0)
126+])
127
128 if test "$rpppoe_cv_pack_bitfields" = "rev" ; then
129 AC_MSG_RESULT(reversed)
130- AC_DEFINE(PACK_BITFIELDS_REVERSED)
131+ AC_DEFINE([PACK_BITFIELDS_REVERSED], [], [Reversed bitfields])
132 else
133 AC_MSG_RESULT(normal)
134 fi
135@@ -312,6 +277,7 @@
136 AC_SUBST(RDYNAMIC)
137 AC_SUBST(LIBEVENT)
138 AC_SUBST(ECHO)
139+AC_SUBST(HAVE_STRUCT_SOCKADDR_LL)
140
141 datadir_evaluated=`eval echo $datadir`
142 AC_SUBST(datadir_evaluated)
diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/discard-use-of-dnl-in-Makefile.am.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/discard-use-of-dnl-in-Makefile.am.patch
new file mode 100644
index 000000000..8b7886485
--- /dev/null
+++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/discard-use-of-dnl-in-Makefile.am.patch
@@ -0,0 +1,27 @@
1From 611c9fe719c5aa264a2ad2eb920cf4522ae2ddec Mon Sep 17 00:00:00 2001
2From: Ting Liu <b28495@freescale.com>
3Date: Tue, 12 Jun 2012 14:26:16 -0400
4Subject: [PATCH] discard use of dnl in Makefile.am
5
6Since Makefile.am is not processed by m4, but by automake, 'dnl' does
7not introduce a comment.
8
9Signed-off-by: Ting Liu <b28495@freescale.com>
10---
11 Makefile.am | 2 +-
12 1 files changed, 1 insertions(+), 1 deletions(-)
13
14diff --git a/Makefile.am b/Makefile.am
15index eff6977..3091c33 100644
16--- a/Makefile.am
17+++ b/Makefile.am
18@@ -1,5 +1,5 @@
19 PACKAGE = rp-pppoe
20 VERSION = 3.8
21
22-dnl AM_CFLAGS = -Wall -DDEBUG
23+##dnl AM_CFLAGS = -Wall -DDEBUG
24 SUBDIRS = src
25--
261.7.6.5
27
diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/dont-swallow-errors.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/dont-swallow-errors.patch
new file mode 100644
index 000000000..c7fc9cfac
--- /dev/null
+++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/dont-swallow-errors.patch
@@ -0,0 +1,15 @@
1Further fixup to the configure scripts to not swallow errors
2
3Upstream-Status: Pending
4
5--- a/src/configure.in.org 2008-01-14 21:08:38.000000000 +0200
6+++ a/src/configure.in 2008-01-14 21:20:09.000000000 +0200
7@@ -208,7 +208,7 @@
8 return 2;
9 }
10 }], rpppoe_cv_pack_bitfields=normal, rpppoe_cv_pack_bitfields=rev,
11-$ECHO "no defaults for cross-compiling"; exit 0)
12+$ECHO "no defaults for cross-compiling"; exit 1)
13 ])
14
15 if test "$rpppoe_cv_pack_bitfields" = "rev" ; then
diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.default b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.default
new file mode 100644
index 000000000..996d57f3c
--- /dev/null
+++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.default
@@ -0,0 +1,22 @@
1# PPPoE Server options
2
3# Maximum segment size, not used for in kernel PPPoE
4#MSS=1412
5
6# Device(s) - Space seperated list of devices to listen on
7#DEVICES="eth1"
8
9# Local IP
10#LOCAL_IP=10.0.0.1
11
12# Starting remote IP
13#REMOTE_IP=10.67.15.1
14
15# Service name
16#SERVICE_NAME="acme"
17
18# Maximum number of sessions, default is 16
19#MAX_SESSIONS=64
20
21# Access concentrator name, default is the hostname
22#ACCESS_CONCENTRATOR_NAME="pppoe-rtr-1"
diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.init b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.init
new file mode 100755
index 000000000..21afe0be3
--- /dev/null
+++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-server.init
@@ -0,0 +1,59 @@
1#! /bin/sh
2
3test -f /usr/sbin/pppoe-server || exit 0
4test -f /etc/default/pppoe-server && . /etc/default/pppoe-server
5
6case $1 in
7 start)
8 OPTIONS=""
9 if [ -n "$MSS" ]; then
10 OPTIONS="$OPTIONS -m $MSS"
11 fi
12 if [ -n "$DEVICES" ]; then
13 for i in $DEVICES; do
14 OPTIONS="$OPTIONS -I $i"
15 done
16 fi
17 if [ -n "$LOCAL_IP" ]; then
18 OPTIONS="$OPTIONS -L $LOCAL_IP"
19 fi
20 if [ -n "$REMOTE_IP" ]; then
21 OPTIONS="$OPTIONS -R $REMOTE_IP"
22 fi
23 if [ -n "$SERVICE_NAME" ]; then
24 OPTIONS="$OPTIONS -S $SERVICE_NAME"
25 fi
26 if [ -n "$MAX_SESSIONS" ]; then
27 OPTIONS="$OPTIONS -N $MAX_SESSIONS"
28 fi
29 if [ -n "$ACCESS_CONCENTRATOR_NAME" ]; then
30 OPTIONS="$OPTIONS -C $ACCESS_CONCENTRATOR_NAME"
31 fi
32 echo -n "Starting PPPoE server: pppoe-server"
33 start-stop-daemon --start --quiet --exec /usr/sbin/pppoe-server -- $OPTIONS
34 echo "."
35 ;;
36 stop)
37 echo -n "Stopping PPPoE server: pppoe-server"
38 start-stop-daemon --stop --quiet --exec /usr/sbin/pppoe-server -- $OPTIONS
39 echo "."
40 ;;
41 status)
42 pid=$(pidof pppoe-server)
43 if [ -n "$pid" ] ; then
44 echo "Running with pid $pid"
45 else
46 echo "Not running"
47 fi
48 ;;
49 restart|force-reload)
50 $0 stop
51 $0 start
52 ;;
53 *)
54 echo "Usage: /etc/init.d/pppoe-server {start|stop|restart|force-reload}"
55 exit 1
56 ;;
57esac
58
59exit 0
diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-src-restrictions.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-src-restrictions.patch
new file mode 100644
index 000000000..bcf4d1164
--- /dev/null
+++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/pppoe-src-restrictions.patch
@@ -0,0 +1,20 @@
1Relax restrictions on the PPPoE src address, as per debian bug
2293811:
3
4 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=293811
5
6Upstream-Status: Inappropriate [Backport from Debian]
7
8--- rp-pppoe-3.8.orig/src/discovery.c
9+++ rp-pppoe-3.8/src/discovery.c
10@@ -376,8 +376,8 @@
11 if (!packetIsForMe(conn, &packet)) continue;
12
13 if (packet.code == CODE_PADO) {
14- if (NOT_UNICAST(packet.ethHdr.h_source)) {
15- printErr("Ignoring PADO packet from non-unicast MAC address");
16+ if (BROADCAST(packet.ethHdr.h_source)) {
17+ printErr("Ignoring broadcast PADO packet");
18 continue;
19 }
20 parsePacket(&packet, parsePADOTags, &pc);
diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/top-autoconf.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/top-autoconf.patch
new file mode 100644
index 000000000..4fe73d017
--- /dev/null
+++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/top-autoconf.patch
@@ -0,0 +1,27 @@
1The autoconf stuff is all in a subdirectory, which is rather annoying
2as OE expects patches to be applied and autoconf stuff to be done in
3S. This adds enough autoconf at the top level to allow it to be
4called there - all it does is run a sub autoconf stuff in the src
5directory.
6
7Upstream-Status: Inappropriate [build system specific change]
8
9Index: rp-pppoe-3.8/Makefile.am
10===================================================================
11--- /dev/null 1970-01-01 00:00:00.000000000 +0000
12+++ rp-pppoe-3.8/Makefile.am 2007-06-08 15:58:16.000000000 +1000
13@@ -0,0 +1,5 @@
14+PACKAGE = rp-pppoe
15+VERSION = 3.8
16+
17+dnl AM_CFLAGS = -Wall -DDEBUG
18+SUBDIRS = src
19Index: rp-pppoe-3.8/configure.in
20===================================================================
21--- /dev/null 1970-01-01 00:00:00.000000000 +0000
22+++ rp-pppoe-3.8/configure.in 2007-06-08 15:58:16.000000000 +1000
23@@ -0,0 +1,4 @@
24+AC_INIT(src/pppoe.c)
25+AM_INIT_AUTOMAKE([rp-pppoe], [3.8])
26+AC_CONFIG_SUBDIRS(src)
27+AC_OUTPUT(Makefile)
diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/update-config.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/update-config.patch
new file mode 100644
index 000000000..42a3bc62c
--- /dev/null
+++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/update-config.patch
@@ -0,0 +1,32 @@
1Set the timeout to 0 since we don't want pppoe to try reconnecting,
2we want whatever is calling it to reconnect. Lots of odd things
3happen when you have pppoe retrying itself.
4
5The path for the plugin is wrong, it's now part of ppp and is in a
6ppp's plugin lib directory. If no path is specified then that's where
7ppp looks, so that's what we do here.
8
9Upstream-Status: Inappropriate [configuration]
10
11Index: rp-pppoe-3.8/configs/pppoe.conf
12===================================================================
13--- rp-pppoe-3.8.orig/configs/pppoe.conf 2006-04-03 00:29:41.000000000 +1000
14+++ rp-pppoe-3.8/configs/pppoe.conf 2007-06-08 16:02:47.000000000 +1000
15@@ -66,7 +66,7 @@
16 # to connect forever after pppoe-start is called. Otherwise, it will
17 # give out after CONNECT_TIMEOUT seconds and will not attempt to
18 # connect again, making it impossible to reach.
19-CONNECT_TIMEOUT=30
20+CONNECT_TIMEOUT=0
21
22 # How often in seconds pppoe-start polls to check if link is up
23 CONNECT_POLL=2
24@@ -115,7 +115,7 @@
25 FIREWALL=NONE
26
27 # Linux kernel-mode plugin for pppd. If you want to try the kernel-mode
28-# plugin, use LINUX_PLUGIN=/etc/ppp/plugins/rp-pppoe.so
29+# plugin, use LINUX_PLUGIN=rp-pppoe.so
30 LINUX_PLUGIN=
31
32 # Any extra arguments to pass to pppoe. Normally, use a blank string
diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/use-ldflags.patch b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/use-ldflags.patch
new file mode 100644
index 000000000..95f629298
--- /dev/null
+++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe-3.8/use-ldflags.patch
@@ -0,0 +1,27 @@
1Make the Makefile obey LDFLAGS.
2
3Upstream-Status: Pending
4
5--- a/src/Makefile.in 2006-04-02 18:29:42.000000000 +0400
6+++ b/src/Makefile.in 2010-04-16 17:51:31.000000000 +0400
7@@ -67,16 +67,16 @@ all: $(TARGETS)
8 @echo "Type 'make install' as root to install the software."
9
10 pppoe-sniff: pppoe-sniff.o if.o common.o debug.o
11- @CC@ -o pppoe-sniff pppoe-sniff.o if.o common.o debug.o
12+ @CC@ -o pppoe-sniff pppoe-sniff.o if.o common.o debug.o $(LDFLAGS)
13
14 pppoe-server: pppoe-server.o if.o debug.o common.o md5.o libevent/libevent.a @PPPOE_SERVER_DEPS@
15- @CC@ -o pppoe-server @RDYNAMIC@ pppoe-server.o if.o debug.o common.o md5.o $(PPPOE_SERVER_LIBS) -Llibevent -levent
16+ @CC@ -o pppoe-server @RDYNAMIC@ pppoe-server.o if.o debug.o common.o md5.o $(PPPOE_SERVER_LIBS) -Llibevent -levent $(LDFLAGS)
17
18 pppoe: pppoe.o if.o debug.o common.o ppp.o discovery.o
19- @CC@ -o pppoe pppoe.o if.o debug.o common.o ppp.o discovery.o
20+ @CC@ -o pppoe pppoe.o if.o debug.o common.o ppp.o discovery.o $(LDFLAGS)
21
22 pppoe-relay: relay.o if.o debug.o common.o
23- @CC@ -o pppoe-relay relay.o if.o debug.o common.o
24+ @CC@ -o pppoe-relay relay.o if.o debug.o common.o $(LDFLAGS)
25
26 pppoe.o: pppoe.c pppoe.h
27 @CC@ $(CFLAGS) '-DVERSION="$(VERSION)"' -c -o pppoe.o pppoe.c
diff --git a/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe_3.8.bb b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe_3.8.bb
new file mode 100644
index 000000000..d1b0481b9
--- /dev/null
+++ b/meta-networking/recipes-protocols/rp-pppoe/rp-pppoe_3.8.bb
@@ -0,0 +1,59 @@
1SUMMARY = "A user-mode PPPoE client and server suite for Linux"
2HOMEPAGE = "http://www.roaringpenguin.com/products/pppoe"
3SECTION = "console/network"
4LICENSE = "GPLv2"
5LIC_FILES_CHKSUM = "file://doc/LICENSE;md5=a194eaefae2be54ee3221339b10d0581"
6
7PR = "r10"
8
9SRC_URI = "http://www.roaringpenguin.com/files/download/${BP}.tar.gz \
10 file://top-autoconf.patch \
11 file://configure_in_cross.patch \
12 file://pppoe-src-restrictions.patch \
13 file://update-config.patch \
14 file://dont-swallow-errors.patch \
15 file://discard-use-of-dnl-in-Makefile.am.patch \
16 file://use-ldflags.patch \
17 file://configure.patch \
18 file://pppoe-server.default \
19 file://pppoe-server.init"
20
21SRC_URI[md5sum] = "0e32760f498f9cde44081ee6aafc823b"
22SRC_URI[sha256sum] = "d916e9cfe1e62395f63a5361936fa855f6d0f0a37dc7227b394cdb725f553479"
23
24inherit autotools-brokensep update-rc.d
25
26do_install() {
27 # Install init script and default settings
28 install -m 0755 -d ${D}${sysconfdir}/default ${D}${sysconfdir}/init.d
29 install -m 0644 ${WORKDIR}/pppoe-server.default ${D}${sysconfdir}/default/pppoe-server
30 install -m 0755 ${WORKDIR}/pppoe-server.init ${D}${sysconfdir}/init.d/pppoe-server
31 # Install
32 oe_runmake -C ${S} RPM_INSTALL_ROOT=${D} docdir=${docdir} install
33 chmod 4755 ${D}${sbindir}/pppoe
34}
35
36# Insert server package before main package
37PACKAGES = "${PN}-dbg ${PN}-server ${PN}-relay ${PN}-sniff ${PN} ${PN}-doc"
38
39FILES_${PN}-server = "${sysconfdir}/default/pppoe-server \
40 ${sysconfdir}/init.d/pppoe-server \
41 ${sbindir}/pppoe-server \
42 ${sysconfdir}/ppp/pppoe-server-options"
43FILES_${PN}-relay = "${sbindir}/pppoe-relay"
44FILES_${PN}-sniff = "${sbindir}/pppoe-sniff"
45
46CONFFILES_${PN} = "${sysconfdir}/ppp/pppoe.conf \
47 ${sysconfdir}/ppp/firewall-standalone \
48 ${sysconfdir}/ppp/firewall-masq"
49CONFFILES_${PN}-server = "${sysconfdir}/ppp/pppoe-server-options \
50 ${sysconfdir}/default/pppoe-server"
51
52INITSCRIPT_PACKAGES = "${PN}-server"
53INITSCRIPT_NAME_${PN}-server = "pppoe-server"
54INITSCRIPT_PARAMS_${PN}-server = "defaults 92 8"
55
56RDEPENDS_${PN} = "ppp"
57RDEPENDS_${PN}-server = "${PN}"
58RRECOMMENDS_${PN} = "ppp-oe"
59
diff --git a/meta-networking/recipes-protocols/xl2tpd/xl2tpd.inc b/meta-networking/recipes-protocols/xl2tpd/xl2tpd.inc
new file mode 100644
index 000000000..f4ea2b826
--- /dev/null
+++ b/meta-networking/recipes-protocols/xl2tpd/xl2tpd.inc
@@ -0,0 +1,40 @@
1SUMMARY = "Xelerance version of the Layer 2 Tunneling Protocol (L2TP) daemon"
2HOMEPAGE = "http://www.xelerance.com/software/xl2tpd/"
3SECTION = "network"
4DEPENDS = "ppp virtual/kernel"
5
6LICENSE = "GPLv2"
7LIC_FILES_CHKSUM = "file://LICENSE;md5=0636e73ff0215e8d672dc4c32c317bb3"
8
9INC_PR = "r0"
10
11SRC_URI = "git://github.com/xelerance/xl2tpd.git"
12
13S = "${WORKDIR}/git"
14
15inherit update-rc.d
16
17do_compile () {
18 oe_runmake CFLAGS="${CFLAGS} -DLINUX" LDFLAGS="${LDFLAGS}" PREFIX="${prefix}" KERNELSRC=${STAGING_KERNEL_DIR} all
19}
20
21do_install () {
22 oe_runmake PREFIX="${D}${prefix}" install
23
24 install -d ${D}${sysconfdir}/init.d
25 touch ${D}${sysconfdir}/xl2tpd.conf
26 install -m 0755 debian/xl2tpd.init ${D}${sysconfdir}/init.d/xl2tpd
27 sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/xl2tpd
28 sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/xl2tpd
29 sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/xl2tpd
30 sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${sysconfdir}/init.d/xl2tpd
31
32 install -d ${D}${sysconfdir}/default
33 install -m 0644 debian/xl2tpd.default ${D}${sysconfdir}/default/xl2tpd
34}
35
36CONFFILES_${PN} += "${sysconfdir}/xl2tpd.conf ${sysconfdir}/default/xl2tpd"
37
38INITSCRIPT_PACKAGES = "${PN}"
39INITSCRIPT_NAME_${PN} = "xl2tpd"
40
diff --git a/meta-networking/recipes-protocols/xl2tpd/xl2tpd_git.bb b/meta-networking/recipes-protocols/xl2tpd/xl2tpd_git.bb
new file mode 100644
index 000000000..bd084aa00
--- /dev/null
+++ b/meta-networking/recipes-protocols/xl2tpd/xl2tpd_git.bb
@@ -0,0 +1,5 @@
1require xl2tpd.inc
2PR = "${INC_PR}.0"
3
4SRCREV = "df7e30eb199fc5710faa83866381aea18b66e60c"
5
diff --git a/meta-networking/recipes-protocols/zeroconf/zeroconf/compilefix.patch b/meta-networking/recipes-protocols/zeroconf/zeroconf/compilefix.patch
new file mode 100644
index 000000000..328e574a9
--- /dev/null
+++ b/meta-networking/recipes-protocols/zeroconf/zeroconf/compilefix.patch
@@ -0,0 +1,19 @@
1| zeroconf.c: In function 'main':
2| zeroconf.c:145: error: 'PATH_MAX' undeclared (first use in this function)
3
4RP - 4/9/09
5
6Upstream-Status: Pending
7
8Index: zeroconf-0.9/zeroconf.c
9===================================================================
10--- zeroconf-0.9.orig/zeroconf.c 2009-09-04 10:05:25.000000000 +0100
11+++ zeroconf-0.9/zeroconf.c 2009-09-04 10:05:42.000000000 +0100
12@@ -33,6 +33,7 @@
13 #include <net/if_arp.h>
14 #include <sys/time.h>
15 #include <signal.h>
16+#include <limits.h>
17
18 #include "delay.h"
19
diff --git a/meta-networking/recipes-protocols/zeroconf/zeroconf/debian-zeroconf b/meta-networking/recipes-protocols/zeroconf/zeroconf/debian-zeroconf
new file mode 100644
index 000000000..0c9d15ba1
--- /dev/null
+++ b/meta-networking/recipes-protocols/zeroconf/zeroconf/debian-zeroconf
@@ -0,0 +1,51 @@
1#!/bin/sh
2
3if [ ! -x /usr/sbin/zeroconf ]; then
4 exit 0
5fi
6
7# IPv4 link-local addresses (zeroconf) are
8# only applicable on the 'inet' address family
9[ "X$ADDRFAM" != "Xinet" ] && exit 0
10
11# However there are some methods where it doesn't
12# make any sense to configure an IPv4LL address
13
14# not on loopback
15[ "X$METHOD" = "Xloopback" ] && exit 0
16
17# not on ppp or wvdial either
18[ "X$METHOD" = "Xppp" ] && exit 0
19[ "X$METHOD" = "Xwvdial" ] && exit 0
20
21# The administrator may have blacklisted interfaces
22# or only want zeroconf in a fallback situation
23[ -f /etc/default/zeroconf ] &&
24 . /etc/default/zeroconf
25
26[ -n "$DISABLE" ] && exit 0
27
28for BLACK in $IFBLACKLIST; do
29 case $IFACE in
30 $BLACK)
31 exit 0
32 ;;
33 esac
34done
35
36# should we only allocate an address if we do not already have one?
37if [ -n "$FALLBACK" ]; then
38 /sbin/ip addr show $IFACE scope global | grep -q "inet"
39 IP=$?
40 if [ $IP -eq 0 ]; then
41 /sbin/ip route add 169.254.0.0/16 dev $IFACE
42 exit 0
43 fi
44fi
45
46# otherwise, run if we aren't already going
47if [ ! -r /var/run/zeroconf.$IFACE.pid ]; then
48 /usr/sbin/zeroconf -i $IFACE
49fi
50
51exit 0
diff --git a/meta-networking/recipes-protocols/zeroconf/zeroconf/zeroconf-default b/meta-networking/recipes-protocols/zeroconf/zeroconf/zeroconf-default
new file mode 100644
index 000000000..cc07b275f
--- /dev/null
+++ b/meta-networking/recipes-protocols/zeroconf/zeroconf/zeroconf-default
@@ -0,0 +1,17 @@
1# Default for zeroconf
2
3# disable zeroconf
4# If you want to disable zeroconf completely, uncomment the following line
5# this may be useful if you are debugging zeroconf or starting it manually
6#DISABLE=yes
7
8# black-listed interfaces
9# Interfaces which you never wish to have zeroconf run on should
10# be listed here. e.g. "eth2 wlan1" in a space seperated string
11IFBLACKLIST=""
12
13# fallback only
14# If you would only like a link-local address if you were unable to
15# obtain an address via DHCP then uncomment the following line
16#FALLBACK=yes
17
diff --git a/meta-networking/recipes-protocols/zeroconf/zeroconf_0.9.bb b/meta-networking/recipes-protocols/zeroconf/zeroconf_0.9.bb
new file mode 100644
index 000000000..9307263c7
--- /dev/null
+++ b/meta-networking/recipes-protocols/zeroconf/zeroconf_0.9.bb
@@ -0,0 +1,34 @@
1SUMMARY = "IPv4 link-local address allocator"
2DESCRIPTION = "Zeroconf is a program that is used to claim IPv4 \
3link-local addresses. IPv4 link-local addresses are useful when setting \
4up ad-hoc networking between devices without the involvement of a either \
5a DHCP server or network administrator. \
6These addresses are allocated from the 169.254.0.0/16 address range and \
7are normally attached to each Ethernet device in your computer. \
8Addresses are assigned randomly by each host and, in case of collision, \
9both hosts (are supposed to) renumber."
10AUTHOR = "Anand Kumria <wildfire@progsoc.uts.edu.au>"
11HOMEPAGE = "http://www.progsoc.org/~wildfire/zeroconf/"
12LICENSE = "GPLv2+"
13LIC_FILES_CHKSUM = "file://COPYING;md5=4325afd396febcb659c36b49533135d4 \
14 file://zeroconf.c;beginline=1;endline=13;md5=a5bada96e1e34b08eb7446b28e2630b2"
15SECTION = "net"
16
17PR = "r1"
18
19SRC_URI = "http://www.progsoc.org/~wildfire/zeroconf/download/${BPN}-${PV}.tar.gz \
20 file://compilefix.patch \
21 file://zeroconf-default \
22 file://debian-zeroconf"
23
24SRC_URI[md5sum] = "bdafb16b008ebb5633e4e581f77821d2"
25SRC_URI[sha256sum] = "a8c74df127753e2310fa1e072f3c9ca44a404bb0bbce9cfec7a84c6dff8bec7b"
26
27do_install () {
28 install -d ${D}${sbindir}
29 install -d ${D}${sysconfdir}/network/if-up.d
30 install -d ${D}${sysconfdir}/default
31 install -c -m 755 ${S}/zeroconf ${D}${sbindir}/zeroconf
32 install -c -m 755 ${WORKDIR}/debian-zeroconf ${D}${sysconfdir}/network/if-up.d/zeroconf
33 install -c ${WORKDIR}/zeroconf-default ${D}${sysconfdir}/default/zeroconf
34}