For all functions, the variable IsdnErrno indicates the type of error on return.
#include <IsdnLib.h> int IsdnInitialize (void (*callback)());
callback is a callback function that has to be registered by the application. This function will be called if a Q.931 message is received that could be of interest to the application.
After the library has been initialized, other IsdnLib functions are available for using ISDN.
Before the application terminates, it should call IsdnFini() in order to free all resources that have been reserved.
0x0001 Ouput of schedular information 0x0002 Output of the IsdnLib CallId 0x0008 Output of timer information 0x0010 Indication of incoming and outgoing Q.931 messages 0x0020 Indication of incoming and outgoing Q.921 messages 0x0040 Indication of internal Q.931 requests und indikations 0x1000 Trace of functions when leaved 0x2000 Trace of functions when started 0x4000 Output of warnings 0x8000 Error output
#include <IsdnLib.h> void (*IsdnCallback) (IsdnInd *ind); main () { /* initalize the application */ if (IsdnInitialize (IsdnCallback)) < 0) { /* handle error */ exit (1); } IsdnMainLoop (); IsdnFini(); exit (0); }
#include <IsdnLib.h> void IsdnFini();
#include <IsdnLib.h&> int IsdnMainLoop();
At any time after the ISDN device has been activated, Q.931 messages may arrive. Therefore, IsdnMainLoop should be called immediately after IsdnInitialize. Otherwise, old messages that have not been handled may appear in the queue and lead to confusion.
The call to IsdnMainLoop returns only when the global variable schedulerStop is set to a non-zero value.
#include <IsdnLib.h&> void (*IsdnCallback) (tIsdnInd *ind); main () { IsdnInitialize(IsdnCallback); IsdnMainLoop(); IsdnFini(); exit (0); }
#include <IsdnLib.h> void IsdnError(const char *str, ...);
#include <IsdnLib.h> void cb (int mode, void *data); int IsdnCreateFileHandler(int fd, int mode, void (*cb) (), void *data);
A file handler that is installed can be removed with IsdnDeleteFileHandler.
#include <IsdnLib.h> Echo(void *data, int mode) {} int main() { IsdnCreateFileHandler(0, ISDN_READABLE, Echo, NULL); IsdnDeleteFileHandler(0); }
#include <IsdnLib.h> void IsdnDeleteFileHandler(int fd);
#include <IsdnLib.h> void cb (int mode, void *data); int IsdnCreateTimerHandler (int ms, void (*cb) (), void *data);
#include <IsdnLib.h> Cb (void *data, int mode) ... timerId = IsdnCreateTimerHandler (1000, Cb, NULL); IsdnDeleteTimerHandler(timerId);
#include <IsdnLib.h> void IsdnDeleteTimerHandler (int timerId);
#include <IsdnLib.h> int IsdnAlertingReq (const t_IsdnAlertingReq *ireq);
typedef struct { int callId; } t_IsdnAlertingReq;callId identifies the logical connection.
HandleIncomingCall(int callId) { t_IsdnAlertingReq req; req.callId = callId; if (IsdnAlertingReq(&req)) IsdnError("Error in IncomingCall"); }
#include <IsdnLib.h> int IsdnCallReq (t_IsdnCallReq *req);
The parameter ireq defines the request:j
typedef struct { int callId; t_CalledPartyNo calledNo; /* opt. number to be called */ t_CalledPartySubAddr calledSubAddr; /* opt. subAddr to be called */ t_CallingPartyNo callingNo; /* opt. calling number */ t_CallingPartySubAddr callingSubAddr; /* opt. calling subAddr */ t_IsdnService service; /* opt. complete service */ t_BearerCap bearerCap[2]; /* opt. bearer cap */ t_HighLayerComp highLayerComp[4]; /* opt. HLC */ t_LowLayerComp lowLayerComp[4]; /* opt. LLC */ } t_IsdnCallReq;
The successful use of this request does not mean that a connection was established, but only that connection establishment was requested. The connection is completely established if the IsdnLib generates a IsdnConnectInd.
The initiated call can be canceled at any time by IsdnReleaseReq.
InitiateCall () { t_IsdnCallReq req; memset(&req, '\0', sizeof (req)); strcpy(req.calledNo.number, "+493025499203"); strcpy(req.callingNo.number, "+4930999888777"); req.service = ISDN_S_VOICE_ALAW; if (IsdnCallReq(&req)) IsdnError("Error in InitiateCall"); else return req.callId; /* return the callId */ }
#include <IsdnLib.h> int IsdnConnectReq(const t_IsdnConnectReq *ireq);
typedef struct /* connect to incomming call */ int callId; /* request */ t_IsdnService service; /* opt. service */ t_BearerCap bearerCap; /* opt. selected bearer cap */ t_HighLayerComp highLayerComp; /* opt. selected HLC */ t_LowLayerComp lowLayerComp; /* opt. selected LLC */ } t_IsdnConnectReq;
After a successful request, the connection is not completely established. Only if the IsdnLib indicates an IsdnConnectInd the connection is established.
ConnectToCaller (int callId, int service) t_IsdnConnectReq req; memset(&req, '\0', sizeof (req)); req.callId = callId; req.service = service; if (IsdnConnectReq (&req)) IsdnError ("Error in ConnectToCaller"); else ... /* ok */ }
#include <IsdnLib.h> int IsdnDialReq (const t_IsdnDialReq *req)
typedef struct { int callId; /* req. */ t_CalledPartyNo calledPartyNo; /* req. */ } t_IsdnDialReq;
Dial(int callId, char *number) { t_IsdnDialReq req; memset(&req, '\0', sizeof (req)); req.callId = callId; strcpy(req.calledPartyNo.number, number); if (IsdnCallReq (&req)) IsdnError ("Error in Dial"); else ... /* OK */ }
#include <IsdnLib.h> int IsdnKeypadReq (const t_IsdnKeypadReq *req)
The parameter ireq defines the request:
typedef struct { int callId; /* req. */ char keypad[20+1]; /* req. 1..20 chars, terminated */ } t_IsdnKeypadReq;
SendKeypad (int callId, char *keypad) { t_IsdnKeypadReq req; memset (&req, '\0', sizeof (req)); req.callId = callId; strcpy (req.keypad, keypad); if (IsdnKeypadReq (&req)) IsdnError ("Error in SendKeypad"); else ... /* OK */ }
#include <IsdnLib.h> int IsdnReleaseReq (const t_IsdnReleaseReq *req);
The parameter ireq defines the request:
typedef struct { int callId; /* req. */ t_Cause cause; /* opt. reason */ } t_IsdnReleaseReq;Meaning of the fields:
The connection release is completed only if the IsdnLib generates an IsdnReleaseInd.
Disconnect (int callId, int cause) { t_IsdnReleaseReq req; memset (&req, '\0', sizeof (req)); req.callId = callId; req.cause.value = cause; req.cause.location = CA_L_USER; if (IsdnReleaseReq(&req)) IsdnError ("Error in Disconnect"); else ... /* OK */ }
#include <IsdnLib.h> IsdnCallback(t_IsdnInd *ind);
typedef struct /* alerting indication */ t_sdnIndType indType; /* type of inication */ int callId; /* unique ID of the call */ } t_IsdnAlertInd;Meaning of the fields:
IsdnCallback (t_IdnInd *ind) { t_IsdnAlertInd *alert = (t_IsdnAlertInd *)ind; if (ind->indType == ISDN_ALERT_IND) printf("Alerting for %d\n", alert->callId) }
#include <IsdnLib.h> IsdnCallback(t_IsdnInd *ind);
typedef struct { t_IsdnIndType indType; /* type of indication */ int callId; /* unique ID of the call */ t_CalledPartyNo calledPartyNo; t_CalledPartySubAddr calledPartySubAddr; t_CallingPartyNo callingPartyNo; t_CallingPartySubAddr callingPartySubAddr; t_ChannelId channelId; /* identifies the B* channels */ t_BearerCap bearerCap[2]; t_HighLayerComp highLayerComp[4]; t_LowLayerComp lowLayerComp[4]; } t_IsdnCallInd;
IsdnCallback (t_IsdnInd *ind) { t_IsdnCallInd *call = (t_IsdnCallInd *)ind; if (ind->indType == ISDN_CALL_IND) { printf("Incoming CALL for %d\n", call->callId); printf(" called no = %s\n", call->calledPartyNo.number); printf(" calling no = %s\n", call->calledPartyNo.number); } }
#include <IsdnLib.h> IsdnCallback (t_IsdnInd *ind);
typedef struct /* indicates the available channel(s) */ t_IsdnIndType indType; /* type of inication */ int callId; /* unique ID of the call */ t_ChannelId channelId; /* the ID of the selected channel(s) */ int fd; /* file descriptor for the selected channel */ } t_IsdnChannelInd;
void DataCb(); IsdnCallback (t_IsdnInd *ind) { t_IsdnChannelInd *channel = (t_IsdnChannelInd *)ind; if (ind->indType == ISDN_CHANNEL_IND) { printf("Channel for %d\n", channel->callId); IsdnCreateFileHandler(channel->fd, DataCb, ISDN_READABLE, NULL); } }
IsdnCallback(t_IsdnInd *ind);
typedef struct { t_IsdnIndType indType; /* type of inication */ int callId; /* unique ID of the call */ int units; /* # of charge units */ } t_IsdnChargeInd;
IsdnCallback (t_IsdnInd *ind) { t_IsdnChargeInd *charge = (t_IsdnChargeInd *)ind; if (charge->indType == ISDN_CHARGE_IND) { printf("Charging for %d\n", charge->callInd); printf("The call costs %d\n units.\n", charge->units); } }
#include <IsdnLib.h> IsdnCallback (t_IsdnInd *ind);
typedef struct { /* indicates that the call is connected (active) now */ t_IsdnIndType indType; /* type of inication */ int callId; /* unique ID of the call */ } t_IsdnConnectInd;
IsdnCallback (t_IsdnInd *ind) { t_IsdnConnectInd *ci = (t_IsdnConnectInd *)ind; if (ci->indType == ISDN_CONNECT_IND) printf ("Call %d is now connected.\n", ci->callId); }
#include <IsdnLib.h>
typedef struct { t_IsdnIndType indType; /* type of inication */ int callId; /* unique ID of the call */ t_Cause cause; } t_IsdnDisconnectInd;
After receiving this indication, the application should close the data channel and terminate the connection via IsdnReleaseReq. If this is not done within 15 seconds, it is initiated by the central office.
IsdnCallback (t_IsdnInd *ind) { t_IsdnDisconnectInd *disc = (t_IsdnDisconnectInd *)ind; if (ind->indType == ISDN_DISCONNECT_IND) { printf ("%d disconnected\n", disc->callId); printf ("Cause:"); DumpCause (stdout, &disc->cause); } }
#include <IsdnLib.h> IsdnCallback (t_IsdnInd *ind);
typedef struct { t_IsdnIndType indType; /* type of inication */ int callId; /* unique ID of the call */ t_Cause cause; } t_IsdnReleaseInd;
After receiving this message, the application should close the file descriptor for the data channel if still open. After this indication the application should not initiate further messages for this callId. Otherwise, an error is reported. No further messages for this callId can be expected from the IsdnLib. The message can be sent at any time for each valid callId
IsdnCallback (t_IsdnInd *ind) { t_IsdnReleaseInd *rel = (t_IsdnReleaseInd *)ind; if (rel->indType == ISDN_RELEASE_IND) { printf("%d released now", rel->callId); printf ("Cause:"); DumpCause (stdout, &rel->cause); } }