Add optional support for RFC863, Discard Protocol

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-07-18 09:55:19 +02:00
1 parent eb57457522
commit 90497af7bb
6 files changed
+109 -20

No files matched your search

+19 -6
View File
@@ -73,8 +73,9 @@ interface, reducing the need for a full blown firewall.
Built-in optional inetd services:
- time (rdate) RFC862
- echo RFC868
- echo RFC862
- discard RFC863
- time (rdate) RFC868
**Runlevels**
@@ -484,10 +485,11 @@ The original `inetd` had a few standard services built-in:
- chargen
- discard
Finit currently supports the `time` and `echo` services. Both of which
are realized as plugins to provide a simple means of testing the inetd
functionality stand-alone. But this also provides both a useful network
testing/availability and a rudimentary time server for rdate clients.
Finit currently supports the `time`, `echo`, and `discard` services.
Both of which are realized as plugins to provide a simple means of
testing the inetd functionality stand-alone. But this also provides
both a useful network testing/availability and a rudimentary time server
for rdate clients.
Internal inetd services are set up as follows:
@@ -496,6 +498,8 @@ Internal inetd services are set up as follows:
inetd time/tcp nowait [2345] internal
inetd echo/udp wait [2345] internal
inetd echo/tcp nowait [2345] internal
inetd discard/udp wait [2345] internal
inetd discard/tcp nowait [2345] internal
```
Then call `rdate` from a remote machine (or use localhost):
@@ -512,6 +516,13 @@ Or `echoping` to reach the echo service:
echoping -uv <IP>
```
Or `echoping -d` to reach the discard service:
```shell
echoping -dv <IP>
echoping -duv <IP>
```
If you use `time/udp` you must use the standard rdate implementation and
then call it with `rdate -up` to connect using UDP. Without the `-p`
argument rdate will try to set the system clock. Please note that rdate
@@ -554,6 +565,8 @@ For your convenience a set of *optional* plugins are available:
* *echo.so*: RFC 862 plugin. Start as inetd service, like time below.
* *discard.so*: RFC 863 plugin. Start as inetd service, like time below.
* *hwclock.so*: Restore and save system clock from/to RTC on
startup/shutdown.
+9 -8
View File
@@ -53,14 +53,15 @@ AC_ARG_ENABLE(quiet,
# Check for extra plugins to enable
enable_all_plugins=auto
AC_PLUGIN([alsa-utils], [no], [Save and restore ALSA sound settings using alsactl])
AC_PLUGIN([dbus], [no], [Setup and start system message bus, D-Bus])
AC_PLUGIN([inetd-echo], [no], [Inetd plugin: echo server, RFC862])
AC_PLUGIN([inetd-time], [no], [Inetd plugin: time (rdate) server, RFC868])
AC_PLUGIN([lost], [no], [Example HOOK_SVC_LOST plugin, very noisy as-is!])
AC_PLUGIN([resolvconf], [no], [Setup necessary files for resolvconf])
AC_PLUGIN([x11-common], [no], [Console setup (for X)])
AC_PLUGIN([netlink], [yes], [Basic netlink plugin for IFUP/IFDN and GW events. Can be replaced with externally built plugin that links with libnl or similar.])
AC_PLUGIN([alsa-utils], [no], [Save and restore ALSA sound settings using alsactl])
AC_PLUGIN([dbus], [no], [Setup and start system message bus, D-Bus])
AC_PLUGIN([inetd-echo], [no], [Inetd plugin: echo server, RFC862])
AC_PLUGIN([inetd-discard], [no], [Inetd plugin: discard server, RFC862])
AC_PLUGIN([inetd-time], [no], [Inetd plugin: time (rdate) server, RFC868])
AC_PLUGIN([lost], [no], [Example HOOK_SVC_LOST plugin, very noisy as-is!])
AC_PLUGIN([resolvconf], [no], [Setup necessary files for resolvconf])
AC_PLUGIN([x11-common], [no], [Console setup (for X)])
AC_PLUGIN([netlink], [yes], [Basic netlink plugin for IFUP/IFDN and GW events. Can be replaced with externally built plugin that links with libnl or similar.])
# Check for extra arguments or packages
AC_ARG_WITH(heading,
+8
View File
@@ -19,6 +19,10 @@ if BUILD_INETD_ECHO_PLUGIN
libplug_la_SOURCES += echo.c
endif
if BUILD_INETD_DISCARD_PLUGIN
libplug_la_SOURCES += discard.c
endif
if BUILD_INETD_TIME_PLUGIN
libplug_la_SOURCES += time.c
endif
@@ -50,6 +54,10 @@ if BUILD_INETD_ECHO_PLUGIN
pkglib_LTLIBRARIES += echo.la
endif
if BUILD_INETD_DISCARD_PLUGIN
pkglib_LTLIBRARIES += discard.la
endif
if BUILD_INETD_TIME_PLUGIN
pkglib_LTLIBRARIES += time.la
endif
+67
View File
@@ -0,0 +1,67 @@
/* Optional inetd plugin for the Discard Protocol, RFC 863
*
* Copyright (c) 2016 Joachim Nilsson <troglobit@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <arpa/inet.h>
#include <unistd.h> /* STDIN_FILENO */
#include <sys/socket.h>
#include "../plugin.h"
static int cb(int type)
{
int sd = STDIN_FILENO;
char buf[BUFSIZ];
ssize_t len;
struct sockaddr_storage sa;
socklen_t sa_len = sizeof(sa);
len = recvfrom(sd, buf, sizeof(buf), MSG_DONTWAIT, (struct sockaddr *)&sa, &sa_len);
if (-1 == len)
return -1; /* On error, close connection. */
return 0;
}
static plugin_t plugin = {
.name = "discard", /* Must match the inetd /etc/services entry */
.inetd = {
.cmd = cb
},
};
PLUGIN_INIT(plugin_init)
{
plugin_register(&plugin);
}
PLUGIN_EXIT(plugin_exit)
{
plugin_unregister(&plugin);
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+3 -3
View File
@@ -1,4 +1,4 @@
/* Optional inetd plugin for the echo protocol RFC 862
/* Optional inetd plugin for the Echo Protocol, RFC 862
*
* Copyright (c) 2016 Joachim Nilsson <troglobit@gmail.com>
*
@@ -27,7 +27,7 @@
#include "../plugin.h"
static int echo_cb(int type)
static int cb(int type)
{
int sd = STDIN_FILENO;
char buf[BUFSIZ];
@@ -45,7 +45,7 @@ static int echo_cb(int type)
static plugin_t plugin = {
.name = "echo", /* Must match the inetd /etc/services entry */
.inetd = {
.cmd = echo_cb
.cmd = cb
},
};
+3 -3
View File
@@ -1,4 +1,4 @@
/* Optional inetd plugin for time (rdate) protocol RFC 868
/* Optional inetd plugin for Time Protocol (rdate), RFC 868
*
* Copyright (c) 2015 Joachim Nilsson <troglobit@gmail.com>
*
@@ -32,7 +32,7 @@
#define EPOCH_OFFSET 2208988800ULL
/* Return number of seconds since midnight, 1st Jan, 1900 */
static int rfc868(int type)
static int cb(int type)
{
int sd = STDIN_FILENO;
time_t now;
@@ -64,7 +64,7 @@ static int rfc868(int type)
static plugin_t plugin = {
.name = "time", /* Must match the inetd /etc/services entry */
.inetd = {
.cmd = rfc868
.cmd = cb
}
};