/smpp34pdu

SMPP 3.4 PDU library in erlang

Primary LanguageErlang

smpp34pdu is an erlang library for the SMPP 3.4 wire protocol

Brief History
--------------
This library is a take two of a ad-hoc implementation of just
the wire protocol packing and unpacking routines. It is inspired
in part by OSERL's approach and my desire to implement this from
first principles after the lessons learnt implementing this in an
ad-hoc style, it will eventually replace the version used in my
SMPP library.

Another goal of this library is to be fully tested and provably
"trustworthy".

The hidden goal of this library is to serve as boiler plate on
my research into binary protocol compiler compilers, which is 
one of my current areas of interest, as I want to implement this
from first principles without too much refactorings, so I can see
how easy it would be to autogenerate all this code based on an EBNF
type grammar.

I choosen to support SMPP 3.4 since its the most widely deployed
variant of the protocol currently, and SMPP is designed to be backwardly
compatible, so any compliant system speaking SMPP 5 will accept and work
with SMPP 3.4 systems.

Note that this library assumes a familiarity with the SMPP 3.4 PDU
specification, and is a one-to-one mapping of the PDUs onto erlang.  

Uhh... typically, this familarity comes from reading the spec :)

Building
--------
smpp34pdu is built with rebar, the awesome erlang build tool.

There is a Makefile wrapping up its use, so it plays nice with other
build environments.

First clone the sources from git hub:

   $ git clone git://github.com/essiene/smpp34pdu.git

Then build:
   $ cd smpp34pdu
   $ make

To run the unittests:
   $ make tests

To run dialyzer analysis:
   $ make analyze


Installation
------------
Deploy like any other erlang library


Usage/Examples
--------------
-module(smpp34pdu_example).
-export([start/0]).

% Include the resource file defining all the 
% Records

-include_lib("smpp34pdu/include/smpp34pdu.hrl").

start() ->
	% Create a bind_receiver PDU record
	BindReceiverBody = #bind_receiver{system_id="abcdefghij", 
							password="abcd", system_type="", 
							interface_version=?VERSION, addr_ton=2, 
							addr_npi=1,address_range=""},

	% Pack this PDU into binary
	% Note that this calculates all the neccessary header fields
	% like command_id, command_length, command_status and builds a complete
	% PDU


	PackedBinary = smpp34pdu:pack(?ESME_ROK, 1, BindReceiverBody),

	{ok, [Pdu], <<>>} = smpp34pdu:unpack(PackedBinary),

	Pdu#pdu.body = BindReceiverBody,

	io:format("PDU packing/unpacking works properly").

Docs
-----

A more complete documentation will be included soon


Current Status
--------------

This is currently pre-alpha software and is not yet feature complete.
I am working through an earlier implementation and reimplementing here.
This situation shouldn't last for too long though.

	Supported PDUs:
		GENERIC_NACK
		BIND_RECEIVER
		BIND_RECEIVER_RESP
		BIND_TRANSMITTER
		BIND_TRANSMITTER_RESP
		QUERY_SM
		QUERY_SM_RESP
		SUBMIT_SM
		SUBMIT_SM_RESP
		DELIVER_SM
		DELIVER_SM_RESP
		UNBIND
		UNBIND_RESP
		REPLACE_SM
		REPLACE_SM_RESP
		CANCEL_SM
		CANCEL_SM_RESP
		BIND_TRANSCEIVER
		BIND_TRANSCEIVER_RESP
		OUTBIND
		ENQUIRE_LINK
		ENQUIRE_LINK_RESP
		ALERT_NOTIFICATION



	Unsupported PDUs:
		SUBMIT_MULTI
		SUBMIT_MULTI_RESP
		DATA_SM