#ifndef _SmsSmpp_Header
#define _SmsSmpp_Header
#include "smslib.h"

struct sms_smpp;
typedef struct sms_smpp SmsSmpp;

struct smpp_message;
typedef struct smpp_message SmppMessage;

typedef struct smpp_init {
	char *host,*id,*pass,*type,*addr_range;
	int port,addr_ton,addr_npi;
} SmppInit;

SmsSmpp *sms_smpp_init(Sms *sms, SmppInit *init, int *errcode);
void sms_smpp_free(SmsSmpp **smpp);

SmppMessage *sms_smpp_wait(SmsSmpp *smpp, long timeout_msec, int *errcode);

int sms_smpp_send(SmsSmpp *smpp, void *data, char *from, char *to, char *message);

int sms_smpp_recv(SmsSmpp *smpp, SmppMessage *msg);
int sms_smpp_accept(SmsSmpp *smpp, SmppMessage *msg, int code, char *reason);
int sms_smpp_reject(SmsSmpp *smpp, SmppMessage *msg, int code, char *reason);

char *sms_smpp_error(SmsSmpp *smpp, int errcode, char *bf, int bfsz);
char *sms_smpp_fromip(SmsSmpp *smpp, SmppMessage *msg);
char *sms_smpp_from(SmsSmpp *smpp, SmppMessage *msg);
char *sms_smpp_to(SmsSmpp *smpp, SmppMessage *msg);
char *sms_smpp_body(SmsSmpp *smpp, SmppMessage *msg);

void sms_smpp_msgfree(SmsSmpp *smpp, SmppMessage **msg);

#define SMS_SMPP_CONNECT_ERROR			SMS_NO_ERROR+1
#define SMS_SMPP_BIND_TRANSMITTER_ERROR	SMS_NO_ERROR+2
#define SMS_SMPP_BIND_RECEIVER_ERROR	SMS_NO_ERROR+3
#define SMS_SMPP_SEND_ERROR				SMS_NO_ERROR+4
#define SMS_SMPP_RECV_ERROR				SMS_NO_ERROR+5
#endif
