sdt.c

Implementation of SDT (Session Data Transport) protocol

Summary
sdt.cImplementation of SDT (Session Data Transport) protocol
Command codes and classification.See acnstd.h, SDT Constants.
Enumerations
Lcomp_fLocal component flags LCF_OPEN - Component is registered with SDT.
Functions
sdt_register
sdt_deregisterDe-register a component from SDT.
sdt_addClientRegister a client protocol with SDT.
sdt_dropClientDe-register a client protocol from the SDT layer.
readrxqueueRead the received wrapper queue (properly received wrappers only, there may be others awaiting sequencing) and dispatch to client protocol handlers.
disconnectAll
startWrapperCreate and initialize a txwrap.
cancelWrapperCancel a txwrap
startProtoMsgInitialize the next message block in the wrapper
endProtoMsgClose a message after adding data
rptProtoMsgRepeat the previous message to another member of the same group.
addMemberCreate a new member and add it to a channel and send a cold Join.

Command codes and classification.

See acnstd.h, SDT Constants.

Ad-hoc

  • SDT_JOIN
  • SDT_GET_SESSIONS
  • SDT_SESSIONS

Channel out

  • SDT_REL_WRAP
  • SDT_UNREL_WRAP
  • SDT_NAK (outbound from member)

Channel In

  • SDT_JOIN_REFUSE
  • SDT_JOIN_ACCEPT
  • SDT_LEAVING
  • SDT_NAK

Channel out wrapped

  • SDT_CHANNEL_PARAMS
  • SDT_LEAVE
  • SDT_CONNECT
  • SDT_DISCONNECT

Channel in wrapped

  • SDT_ACK
  • SDT_CONNECT_ACCEPT
  • SDT_CONNECT_REFUSE
  • SDT_DISCONNECTING

Enumerations

Lcomp_f

Local component flags LCF_OPEN - Component is registered with SDT.  LCF_LISTEN - Component is listening for Joins.

Functions

sdt_register

int sdt_register(ifMC(struct Lcomponent_s *Lcomp,) memberevent_fn *membevent,
netx_addr_t *adhocip,
chanOpen_fn *joinRx)
Lcompthe component registering (only if CF_MULTI_COMPONENT).
membeventcall back for handling session and membership events
adhocipin/out parameter specifying local address and/or port.  If NULL RLP defaults to ephemeral port and any local interface.  If adhocip is explicitly specified as ephemeral port (netx_PORT_EPHEM) and any local interface (INADDR_ANY) then adhocip gets filled in with the actual port used which can then be advertised for discovery.
joinRxApplication supplied callback function to handle ad-hoc join requests.  Alternatively specify ADHOCJOIN_NONE (refuse all requests) or ADHOCJOIN_ANY (accept all requests).

sdt_deregister

void sdt_deregister(ifMC(struct Lcomponent_s *Lcomp))

De-register a component from SDT.  Lcomp - the component to de-register (only if CF_MULTI_COMPONENT).

sdt_addClient

int sdt_addClient(ifMC(struct Lcomponent_s *Lcomp,) clientRx_fn *rxfn,
void *cookie)

Register a client protocol with SDT.

Lcompthe component registering (only if CF_MULTI_COMPONENT).
rxfncallback function to handle successfully received data for this protocol (for DMP pass dmp_sdtRx).
cookieApplication data pointer which is passed to rxfn.

sdt_dropClient

sdt_dropClient(ifMC(struct Lcomponent_s *Lcomp))

De-register a client protocol from the SDT layer.

readrxqueue

void readrxqueue()

Read the received wrapper queue (properly received wrappers only, there may be others awaiting sequencing) and dispatch to client protocol handlers.

If CF_SDTRX_AUTOCALL is true this is called automatically, otherwise the application must call this function to process the queue.  Among other reasons this provides a hook for multi-threaded implementation.

Note: the SDT layer will already have processed SDT wrapped messages so this function just dispatches client protocol messages.

disconnectAll

static int disconnectAll(struct Lchannel_s *Lchan,
uint8_t reason)

startWrapper

struct txwrap_s * startWrapper(int size)

Create and initialize a txwrap.

Returns

New txwrap on success, NULL on error.

Errors

EMSGSIZEsize is too big

cancelWrapper

void cancelWrapper(struct txwrap_s *txwrap)

Cancel a txwrap

startProtoMsg

uint8_t * startProtoMsg(struct txwrap_s **txwrapp,
void *dest,
protocolID_t proto,
uint16_t wflags,
int *sizep)

Initialize the next message block in the wrapper

returns

Pointer to place to put the data

endProtoMsg

int endProtoMsg(struct txwrap_s *txwrap,
uint8_t *endp)

Close a message after adding data

endppoints to the end of the PDUs you have added

rptProtoMsg

int rptProtoMsg(struct txwrap_s **txwrapp,
struct member_s *memb,
uint16_t wflags)

Repeat the previous message to another member of the same group.

Returns

The remaining space (positive) on success, or -1 on error.

addMember

int addMember(struct Lchannel_s *Lchan,
struct Rcomponent_s *Rcomp)

Create a new member and add it to a channel and send a cold Join.

Note: Completion of the add-member process is asynchronous.  A successful return status from addMember indicates only that the member structure was successfully created and the Join request sent.  The status of the complete process is received by callbacks to membevent which was passed to sdt_register.  On success a EV_JOINSUCCESS message is passed (with the new member structure).  On failure EV_JOINFAIL will be sent.

These constants represent requirements defined in standard documents of ANSI E1.17
Constants from Session Data Transport
int sdt_register(ifMC(struct Lcomponent_s *Lcomp,) memberevent_fn *membevent,
netx_addr_t *adhocip,
chanOpen_fn *joinRx)
void sdt_deregister(ifMC(struct Lcomponent_s *Lcomp))
De-register a component from SDT.
int sdt_addClient(ifMC(struct Lcomponent_s *Lcomp,) clientRx_fn *rxfn,
void *cookie)
Register a client protocol with SDT.
sdt_dropClient(ifMC(struct Lcomponent_s *Lcomp))
De-register a client protocol from the SDT layer.
void readrxqueue()
Read the received wrapper queue (properly received wrappers only, there may be others awaiting sequencing) and dispatch to client protocol handlers.
static int disconnectAll(struct Lchannel_s *Lchan,
uint8_t reason)
struct txwrap_s * startWrapper(int size)
Create and initialize a txwrap.
void cancelWrapper(struct txwrap_s *txwrap)
Cancel a txwrap
uint8_t * startProtoMsg(struct txwrap_s **txwrapp,
void *dest,
protocolID_t proto,
uint16_t wflags,
int *sizep)
Initialize the next message block in the wrapper
int endProtoMsg(struct txwrap_s *txwrap,
uint8_t *endp)
Close a message after adding data
int rptProtoMsg(struct txwrap_s **txwrapp,
struct member_s *memb,
uint16_t wflags)
Repeat the previous message to another member of the same group.
int addMember(struct Lchannel_s *Lchan,
struct Rcomponent_s *Rcomp)
Create a new member and add it to a channel and send a cold Join.
One or many components?
void dmp_sdtRx(struct member_s *memb,
const uint8_t *pdus,
int blocksize,
void *ref)
This is a callback function which must be passed to SDT to have Acacian’s DMP code parse and handle incoming DMP.
When an sdt wrapper is correctly received it is placed in an ordered queue.
Close