Developer Area

dottelutils - a C/C++ library

Introduction

If you want to embed .tel functionality in your C or C++ application, for example, to resolve .tel domains and process contact data, your code would need to communicate with the DNS system, which may not always be trivial. Libraries, such as LDNS, simplify interaction with the DNS, but to use the library in multiple parts of your code, you'd need to abstract its usage. For this purpose, the dottelutils library has been created, which builds a small set of functions on top of LDNS.

The library is available through the SVN repository of Kiax Softphone, an open-source VoIP client that you can connect to your Asterisk PBX.

Below you will find a HOWTO for checking out and compiling dottelutils.

A complete tutorial on using dotteltutils for C and C++ applications is available on Forschung-Direkt's website.

Requirements

License

You can use the code shown in this tutorial for your own programs if you accept the terms and conditions of the LGPL license.

Operating Systems

The code is tested and verified to work on the following operating systems: Windows XP/Vista, Mac OS 10.5.x, Ubuntu Linux 8.10. For the compilation on Windows you will need MinGW or Cygwin. The code is tested with MinGW 3.4.5.

The LDNS library

The code which is used in this tutorial assumes you have been able to compile the LDNS library, which is available for download from http://www.nlnetlabs.nl/projects/ldns. LDNS is an open-source library, written in C and available under non-restrictive license (BSD, LGPL). You can embed it in your own applications and build functionality on top of it. The full requirements of LDNS include the OpenSSL library, but you can omit it.

Checkout from SVN:

svn co https://kiax.svn.sourceforge.net/svnroot/kiax/trunk/kiax2core/dottelutils dottelutils

This will fetch several files:

  • dottelutils.h - Declarations of the C interface
  • dottelutils.c - Implementation of the C routines
  • dottelresolver.c - A C example for a .tel resolver tool
  • CppDotTelUtils.h - Declaration of the C++ wrapper
  • CppDotTelUtils.cpp - Implementation of the wrapper
  • CppDotTelResolver.cpp - A C++ example of a .tel resolver tool

Compiling dotelutils:

Please adjust values of path_to_ldns_headers and path_to_ldns_static_lib according to your set up of the LDNS library.

Creating a DLL (Windows)

The Windows part of the code uses iphlp to query network parameters and detect DNS servers to be used in LDNS queries. Additionally, the communication relies on winsock32 library.

To compile and link on MinGW, run:

gcc -Ipath_to_ldns_headers -I. -shared -o dottelutils.dll dottelutils.c \
        path_to_ldns_static_lib/libldns.a -lwsock32 -liphlpapi -DWIN32DEP

Creating a dylib (Mac OS X)

The Mac compilation and linking requires the crypto lib, as follows:

gcc -Ipath_to_ldns_headers -I. -dynamiclib -o libdottelutils.dylib dottelutils.c \
        path_to_ldns_static_lib/libldns.a -lcrypto

Creating a Shared Object (Linux)

On Linux, you can create a shared object using the gcc and linker by running:

gcc -Ipath_to_ldns_headers -I. -shared -o libdottelutils.so dottelutils.c \
       path_to_ldns_static_lib/libldns.a

There are two examples for using dottelutils: a C resolver and a C++ resolver.

Compiling the C resolver:

Once you have the dottelutils.dll compiled successfully, you can compile the C example it this way:

gcc -I. -L. dottelresolver.c -o dottelresolver -ldottelutils

This creates an executable file dottelresolver.exe. If you type in your command shell, you should get contact data of the domain of "Your Company".

./dottelresolver yourcompany.tel

On Windows, the executable is called dottelresolver.exe.

Compiling the C++ resolver:

You can compile this example on Windows, Linux and Mac OS X by running the following commands:

Mac OS X Executable (console application):

g++ -Ipath_to_ldns_includes -I. -L. -o CppDotTelResolver CppDotTelResolver.cpp \
        CppDotTelUtils.cpp -ldottelutils

Windows Executable:

g++ -Ipath_to_ldns_includes -I. -L. CppDotTelUtils.cpp CppDotTelResolver.cpp \ 
       -o CppDotTelResolver -ldottelutils

Linux Executable:

g++ -Ipath_to_ldns_includes -I. -L. -o CppDotTelResolver CppDotTelResolver.cpp \
       CppDotTelUtils.cpp -ldottelutils

The dotteltutils library is used in Kiax Softphone to retrieve .tel information and enable dynamic contact data lookup. You can check it out its project page.

Check out the project page and a detailed tutorial on using dottelutils at the project site.

Contacts

If you are interested in contributing or giving feedback, please contact Forschung-Direkt using email: info at forschung-direkt.eu

Telnic
Search This Site
Partners
Neustar
ICANN
Main site | WHOIS | Sell .tel | FAQ | Archived Site | About Telnic | Contact Us