DNET_DAEMON(3)
β¨ DNET_DAEMON(3) β¨
okay bestie, welcome to the DECnet daemon functions page π this is a library functions manual, and honestly? it's giving "the entire personality of your DECnet daemon lives here." let's get into it π«Ά
πΈ NAME πΈ
dnet_daemon, dnet_accept, dnet_reject β DECnet daemon functions π
π SYNOPSIS π
#include <netdnet/dn.h>
#include <netdnet/dnetdb.h>
-ldnet -ldnet_daemon -lcrypt
int dnet_daemon (int object, char *named_object, int verbosity, int
do_fork)
void dnet_accept (int sockfd, short status, char *data, int len)
void dnet_reject (int sockfd, short status, char *data, int len)
like. look at those signatures. immaculate. π
π DESCRIPTION π
These functions are literally the core of writing a DECnet daemon under Linux, no cap. They hand you every single thing you need to have a daemon that either runs standalone or gets forked out of the dnetd(8) DECnet super-server. (peep dnetd.conf(3) if you wanna know how to configure dnetd β iykyk.)
dnet_daemon() returns a connected file descriptor, and that's the fd your daemon program uses to talk to the remote client. And if your daemon got launched from dnetd? then that fd is just gonna be its standard input. slay.
objectβ the numbered object your daemon binds to. or, alternatively, you can bind to anamed_objectinstead, and in that case the object number should be zero. zero. zip. nada. πverbosityβ determines how much logging the daemon functions will do.0means no logging,1is fairly verbose logging. anything higher than that is useful only for debugging, fr fr.do_forkβ if this is set, then when running standalone, the daemon will fork and detach itself from the parent process. main character energy, honestly.
dnet_accept() β You MUST call this, or dnetd_reject(), after receiving a valid file descriptor from dnet_daemon. The optional data and status parameters provide extra information to the connecting host. See below for status values. π
dnet_reject() β if you wanna reject the connection for any reason, then call this function instead of dnet_accept(), with the status set to the reason (see below) that you're rejecting the connection. And heads up: if your daemon is authenticated by dnetd, then connections will already be rejected if they're not correctly authorized by either a valid username/password or the proxy database (see decnet.proxy(3)).
Here is a list of status codes available in dnetd.conf:
#define DNSTAT_REJECTED 0 /* Rejected by object */
#define DNSTAT_RESOURCES 1 /* No resources available */
#define DNSTAT_NODENAME 2 /* Unrecognised node name */
#define DNSTAT_LOCNODESHUT 3 /* Local Node is shut down */
#define DNSTAT_OBJECT 4 /* Unrecognised object */
#define DNSTAT_OBJNAMEFORMAT 5 /* Invalid object name format */
#define DNSTAT_TOOBUSY 6 /* Object too busy */
#define DNSTAT_NODENAMEFORMAT 10 /* Invalid node name format */
#define DNSTAT_REMNODESHUT 11 /* Remote Node is shut down */
#define DNSTAT_ACCCONTROL 34 /* Access control rejection */
#define DNSTAT_NORESPONSE 38 /* No response from object */
#define DNSTAT_NODEUNREACH 39 /* Node Unreachable */
/* Disconnect notification errors */
#define DNSTAT_MANAGEMENT 8 /* Abort by management/third party */
#define DNSTAT_ABORTOBJECT 9 /* Remote object aborted the link */
#define DNSTAT_FAILED 38 /* Node or object failed */
#define DNSTAT_NODERESOURCES 32 /* Node does not have sufficient resources for a new link */
#define DNSTAT_OBJRESOURCES 33 /* Object does not have sufficient resources for a new link */
#define DNSTAT_BADACCOUNT 36 /* The Account field in unacceptable */
#define DNSTAT_TOOLONG 43 /* A field in the access control message was too long */
π₯ EXAMPLE π₯
okay here's an example MIRROR server πͺ the real mirror server is built into dnetd. This also illustrates the logging functions in libdnetd_daemon. obsessed.
#include <sys/types.h>
#include <sys/socket.h>
#include <stdarg.h>
#include <syslog.h>
#include <netdnet/dnetdb.h>
#include <netdnet/dn.h>
int main(int argc, char *argv[])
{
int insock;
/* Set up logging. The parameters are:
* daemon name to use
* 's' means log to syslog
*/
init_daemon_logging("mirror", 's');
// Wait for something to happen (or check to see if it already has)
insock = dnet_daemon(DNOBJECT_MIRROR, NULL, 0, 1);
// Make sure we got a valid socket
if (insock > -1)
{
int readnum;
char condata[] = {0x00, 0x20}; // Actually 4096 as a LE word
char ibuf[4096];
/* We must accept the connection */
dnet_accept(insock, 0, condata, 2);
while ( (readnum=read(insock,ibuf,sizeof(ibuf))) > 0)
{
ibuf[0]=0x01;
if (write(insock,ibuf,readnum) < 0)
{
DNETLOG((LOG_WARNING, "mirror, write failed: %m\n"));
close(insock);
break;
}
}
close(insock);
}
return 0;
}
To compile:
gcc mirror.c -omirror -ldnet -ldnet_daemon -lcrypt
like, compile it and go. periodt. π
π SEE ALSO π
dnetd(8), dnet_addr(3), dnet_ntoa(3), dnet_conn(3), getnodeadd(3), getnodebyname(3), getnodebyaddr(3), setnodeent(3), decnet.proxy(5)
go read those too bestie, the lore is deep π¦
and that's the whole page!! this was the DECnet daemon functions manual page, dated May 3, 1999 β yeah she's vintage, she's iconic, she ate π mwah, go write a daemon π
π¦ where this page comes from
- ubuntu jammy: libdnet-dev 2.65build2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms