DNET_ADDR(3)
π DNET_ADDR(3) π
okay bestie, so this is a page from the Library Functions Manual β section 3, the "functions" section, the one where all the cool callable stuff lives. and today's main character is dnet_addr. she's giving DECnet glow-up energy and honestly? we're obsessed. β¨
πΈ NAME πΈ
dnet_addr β DECnet nodename to address translation
like... you give her a name, she gives you back the address. it's the matchmaker of the DECnet world fr fr. π
π SYNOPSIS π
#include <netdnet/dn.h>
#include <netdnet/dnetdb.h>
struct dn_naddr *dnet_addr (char *nodename)
two headers, one function, zero drama. you include both, you call her with a nodename, she hands you a pointer to a struct dn_naddr. that's the whole vibe. π¦
β¨ DESCRIPTION β¨
so here's the tea, bestie: dnet_addr goes and searches the decnet hosts file for nodename, and when she finds it she returns the DECnet address inside the dn_naddr structure. π
and if there's no entry found? she returns NULL. no notes, no explanation, just NULL. it's giving ghosted, but like, documented ghosting. π
heads up: always check for that NULL before you go using the result, okay? she will not warn you twice. π«Ά
π₯ EXAMPLE π₯
here's a whole little program showing her off. look at the main character energy:
#include <netdnet/dn.h>
#include <netdnet/dnetdb.h>
#include <sys/socket.h>
main(void)
{
struct dn_naddr *binaddr;
struct sockaddr_dn sockaddr;
int sockfd;
if ( (binaddr=dnet_addr("mv3100")) == NULL)
{
printf("No entry in /etc/decnet.conf for mv3100\n");
exit(0);
}
if ((sockfd=socket(AF_DECnet,SOCK_SEQPACKET,DNPROTO_NSP)) == -1)
{
perror("socket");
exit(-1);
}
sockaddr.sdn_family = AF_DECnet;
sockaddr.sdn_flags = 0x00;
sockaddr.sdn_objnum = 0x19; /* MIRROR */
sockaddr.sdn_objnamel = 0x00;
memcpy(sockaddr.sdn_add.a_addr, binaddr->a_addr,binaddr->a_len);
if (connect(sockfd, (struct sockaddr *)&sockaddr,
sizeof(sockaddr)) < 0)
{
perror("connect");
exit(-1);
}
close(sockfd);
}
the way this does the whole thing β look up "mv3100", bail out politely with No entry in /etc/decnet.conf for mv3100 if it's not there, then open a socket with socket(AF_DECnet,SOCK_SEQPACKET,DNPROTO_NSP), build a struct sockaddr_dn with sdn_family = AF_DECnet, sdn_flags = 0x00, sdn_objnum = 0x19 (that's MIRROR, bestie, she told us in a comment π), sdn_objnamel = 0x00, then memcpy the address bytes over from binaddr->a_addr for binaddr->a_len bytes, connect it up, and close(sockfd). iconic. no notes. periodt. π
π SEE ALSO π
the whole friend group, go say hi:
dnet_htoa(3)dnet_ntoa(3)dnet_conn(3)getnodeadd(3)getnodebyname(3)getnodebyaddr(3)setnodeent(3)
and that's the whole page, bestie!! this one came from the DECnet database functions corner of the manual, dated July 28, 1998 β yes she's vintage, yes she still ate, we love a legacy queen ππ
π¦ 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