Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
BamDNS.h
1/*
2 * COPYRIGHT: Real Time Logic LLC, 2026
3 *
4 * This software is copyrighted by and is the sole property of Real
5 * Time Logic LLC. All rights, title, ownership, or other interests in
6 * the software remain the property of Real Time Logic LLC. This
7 * software may only be used in accordance with the terms and
8 * conditions stipulated in the corresponding license agreement under
9 * which the software has been supplied. Any unauthorized use,
10 * duplication, transmission, distribution, or disclosure of this
11 * software is expressly forbidden.
12 *
13 * This Copyright notice may not be removed or modified without prior
14 * written consent of Real Time Logic LLC.
15 * Real Time Logic LLC reserves the right to modify this software
16 * without notice. https://realtimelogic.com
17 */
18
19#ifndef _BamDNS_h
20#define _BamDNS_h
21
22#include <SoDispCon.h>
23#include <BaTimer.h>
24
31typedef struct
32{
33 U32 ifIndex4;
34 U8 addr4[4];
35 U8 prefix4;
36#ifdef USE_IPV6
37 U32 ifIndex6;
38 U8 addr6[16];
39 U8 prefix6;
40#endif
42
44typedef struct
45{
46 const char* name;
50
51struct BamDNS;
52
53/* Private storage and socket-port contract. Applications must not use these
54 * members. No native socket structures or Lua types occur in native storage.
55 */
56typedef struct
57{
58 HttpSockaddr addr;
59 U16 port;
60 BaBool multicast;
61} BamDNS_Peer;
62
63typedef struct
64{
65 SoDispCon con; /* First: receive callback casts back to this structure. */
66 struct BamDNS* owner;
67 void (*portData[2])(void); /* Opaque socket-port function pointers. */
68 BamDNS_Peer tcPeer;
69 U32 due, tcDue, lastSend;
70 U8 pending, tcPending, retries;
71 BaBool ipv6;
72} BamDNS_Channel;
73
78typedef struct BamDNS
79{
80#ifdef __cplusplus
81 BamDNS(SoDisp* disp, BaTimer* timer, const BamDNS_Config* cfg);
82 ~BamDNS();
83 int status() const;
84#endif
85 /* Private implementation storage, public only to permit caller allocation. */
86 BamDNS_Channel channel[
87#ifdef USE_IPV6
88 2
89#else
90 1
91#endif
92 ];
94 BaTimer* timer;
95 struct BamDNS_Timer* timerCtx;
96 size_t timerKey;
97 U32 announceDue, timerDue, refreshDue;
98 int result;
99 U8 name[71]; /* Length label + 63 bytes + length/local/root. */
100 U8 nameLen, records, announcements;
101 BaBool automatic;
102#ifdef __cplusplus
103private:
104 BamDNS(const BamDNS&);
105 BamDNS& operator=(const BamDNS&);
106#endif
107} BamDNS;
108
109#ifdef __cplusplus
110extern "C" {
111#endif
112
121BA_API void BamDNS_constructor(BamDNS* o, SoDisp* disp, BaTimer* timer,
122 const BamDNS_Config* cfg);
129BA_API int BamDNS_status(const BamDNS* o);
131BA_API void BamDNS_destructor(BamDNS* o);
132
143BA_API int BamDNS_getNetInfo(BamDNS_NetInfo* net);
144
145#ifdef BAS_LOADED
146struct lua_State;
153BA_API void BamDNS_luaopen(struct lua_State* L,
154 const BamDNS_NetInfo* netInfo);
155#endif
156
157/* Port implementers only; supplied BSD implementation is in
158 * src/arch/bsdSocket/BamDNS-Sock.c. setup configures and binds an open socket;
159 * returns 0, E_BIND, or -1. recv returns byte count,
160 * 0 for a discarded packet, -2 for would-block, -1 for a local error.
161 * send returns byte count, -2 for would-block, -1 for a local error.
162 * All operations must be nonblocking. NULL send peer selects multicast.
163 */
164int BamDNS_socketSetup(BamDNS_Channel* c, const BamDNS_NetInfo* net);
165int BamDNS_socketRecv(BamDNS_Channel* c, const BamDNS_NetInfo* net,
166 void* data, int size, BamDNS_Peer* peer);
167int BamDNS_socketSend(BamDNS_Channel* c, const BamDNS_NetInfo* net,
168 const void* data, int size, const BamDNS_Peer* peer);
169
170#ifdef __cplusplus
171}
172inline BamDNS::BamDNS(SoDisp* disp, BaTimer* timer, const BamDNS_Config* cfg)
173{ BamDNS_constructor(this, disp, timer, cfg); }
174inline BamDNS::~BamDNS() { BamDNS_destructor(this); }
175inline int BamDNS::status() const { return BamDNS_status(this); }
176#endif
177
178#endif
uint16_t U16
Unsigned 16-bit integer.
Definition: GenPrimT.h:91
uint32_t U32
Unsigned 32-bit integer.
Definition: GenPrimT.h:93
uint8_t U8
Unsigned 8-bit integer.
Definition: GenPrimT.h:89
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:118
Timer manager used for one-shot and periodic callbacks.
Definition: BaTimer.h:67
Inputs are borrowed only until construction returns, then fully copied.
Definition: BamDNS.h:45
const BamDNS_NetInfo * netInfo
Optional fixed snapshot; NULL selects automatic discovery and five-second refresh.
Definition: BamDNS.h:47
const char * name
Required ASCII host label, 1..63 bytes, no .local.
Definition: BamDNS.h:46
Host-selected network snapshot.
Definition: BamDNS.h:32
Minimal one-name responder.
Definition: BamDNS.h:79
Contains information about the physical socket connection.
Definition: SoDispCon.h:120
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:91