New Features in Brooktrout SDK 6.7.4 - API Support to Monitor Gateway Status

New Features in Brooktrout SDK 6.7.4 - API Support to Monitor Gateway Status

  • Comments 1
  • Likes

SDK 6.7.4 is the latest Brooktrout development kit providing feature rich capabilities to our partners.  We’ve added some new features that will be quite useful, and I will discuss a few of them on what they do and why they can help you.

The previous blog post - Multiple SIP Default Gateways - described the new feature we added in SDK 6.7.4 to allow multiple default gateways to be configured for the SR140.

There’s more to the feature though.  In addition to the ability to configure multiple gateways, the application can also actively check the status of each gateway to know which gateways are Up or Down, and from there which gateway will be the one that calls are directed to.

We’ve added a new API function called BfvIPCallControlNotify.  BfvIPCallControlNotify operates similarly to an existing API function, BfvBoardNotify, which is used to tell the T1/E1 status of a TR1034 board.   BfvIPCallControlNotify allows an application to set up a callback function that will be called any time one of the configured gateways changes from an Up to a Down state, or vice versa.  The function can also be called as a one-shot to gather the current gateway statuses any time the application wants.

In the callback function (or from the output of the one-shot call), the status of each gateway will be provided in an array of gateway_status structures.  The gateway_status structure contains two elements in it: “status” which tells if the gateway is Up (1) or Down (0), and “response” which gives the gateway’s response code it uses to reject the SR140’s OPTIONS message.  So to bring back our OPTIONS sequence example (below), Gateway2 and Gateway3 are both in the Up state.  Their status fields will be 1 for Up and their response fields will be 200 because each gateway sent a 200 OK message in response to the OPTIONS message.  Gateway1’s status field will be 0 because it is in a Down state and its response field will be 502 because of the 502 Service Unavailable message Gateway1 sent to the SR140.



One thing to note is that the array will always contain four sets of the gateway_status structure even if you have fewer than four gateways configured in callctrl.cfg.  The elements for any non-configured gateways will be 0 for both status and response.

When calling BfvIPCallControlNotify, as with most Brooktrout API functions, a line pointer is needed.  You would need to use BfvSessionAttach to create this line pointer.  However, to generate the line pointer you need the module number as input.  The IP call control has no actual module number, but it does have a host module number that you set in callctrl.cfg.  (The host module number is typically 1.)  We’ve created a new macro called HOST_MODULE() which would be used to translate the host_module number into a value that BfvSessionAttach can use.  The following code shows a simple example application using host_module.1 set in callctrl.cfg:


#include "btlib.h"
#include <string.h>

void notify_func(BTLINE *lp, unsigned notify_type, struct args_ipcallcontrol_notify *args)
  int gw = 0;

  printf("Got notify for type %d\n", notify_type);
  if (notify_type == IP_CC_NOTIFY_GATEWAY_STATUS_DEF)
      for (gw=0; gw<BT_MAX_GATEWAYS; gw++)
         printf("Gateway [%d] Status: %d, Response: %d\n", gw, args->gateway_status[gw].status, args->gateway_status[gw].response);


void main()
   BTLINE *lp;
   struct args_line_admin admin_args;
   struct args_ipcallcontrol_notify notify_args;
   struct args_packet args_pkt;
   BTERR bterr;
   // Using host_module.1 from callctrl.cfg
   admin_args.dest_addr.mm_bModule = HOST_MODULE(1);
   admin_args.dest_addr.mm_bChannel = 1;
   admin_args.present = 1;
   admin_args.unique = 0;
   if ((lp = BfvSessionAttach(&admin_args)) == NULL)
      printf("BfvSessionAttach: %s\n",bterr.long_msg);
   notify_args.enable = 1;
   notify_args.notify_type = IP_CC_NOTIFY_GATEWAY_STATUS_DEF;
   notify_args.func = notify_func;
   BfvIPCallControlNotify(lp, &notify_args);
   for (;;)
      args_pkt.timeout = 5000;
      BfvRcvProcessPkt(lp, &args_pkt);

Views: 3353
Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Basantjiphonutow