The Corelatus Blog
Blog posts from January 2010
Archives
2011 2010 2009
Categories

19th January 2010
New blog software

This blog now uses chronicle to compile the blog.

Before, I used Wordpress. Wordpress is OK and mostly 'just works'. But, after a year, I wanted something which followed my normal workflow, i.e. edit-compile-test-checkin-publish. It's easier for me to write posts in emacs, build the blog with a Makefile, version-control with git and publish via scp.

I've made all comments go via mail, comment spam was getting overwhelming.

Permalink
20th January 2010
GTH 'C' API

This post is for people who want to use C to control a GTH. Other languages (e.g. Erlang, Java, Python and Perl) are easier to work with, but in some applications you want the complete control that C gives you.

Corelatus provides a C API for GTH. The C API lets you control a GTH using plain C function calls---all of the XML wire format is taken care of.

Here's an example of how to use it to record speech on an E1/T1 timeslot, something you'd typically do in a voicemail system:


#include "gth_apilib.h"
...

  GTH_api api;                     // GTH_api represents one GTH API connection
  int result;
  int data_socket;
  char buffer[2000];
  char job_id[MAX_JOB_ID];
  int octet_count;

  result = gth_connect(&api, "172.16.1.10");    // Assuming the default GTH IP 
  assert(result == 0);

  // We want to record audio on the E1/T1 called "1A", on timeslot 3.
  data_socket = gth_new_recorder(api, "1A", 3, job_id);

  while ( (octet_count = recv(data_socket, buffer, sizeof buffer, 0)) ) {
    // do whatever you want with the received data
  }

...

The recording above happens in the 'while' loop. It continues forever (i.e. until you abort it). The audio data is bit-for-bit identical to what was on the E1/T1 timeslot, so this can be used for recording both voice and signalling.

Further examples

The C API code includes further examples to:

  • Record audio or signalling from a timeslot to a .wav file
  • Play back previously recorded files
  • Install (upgrade) the firmware on a GTH
  • Monitor (sniff) SS7 MTP-2 and save the signalling to a wireshark (PCAP) compatible file.
  • Monitor CAS R2 signalling.

Standalone Parser

Aside: the C API code includes a standalone parser for the XML responses the GTH emits. You can use the parser without using the rest of the API library, if you want to.

Permalink | c, gth.