Added a tool to test the incoming PDU parser
This commit is contained in:
parent
24bd4936a8
commit
684b10c9b0
1
Makefile
1
Makefile
|
@ -63,6 +63,7 @@ dist:
|
||||||
$(PACKAGE)-$(VERSION)/src/plugins/smscrypt.c \
|
$(PACKAGE)-$(VERSION)/src/plugins/smscrypt.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/plugins/Makefile \
|
$(PACKAGE)-$(VERSION)/src/plugins/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/src/plugins/project.conf \
|
$(PACKAGE)-$(VERSION)/src/plugins/project.conf \
|
||||||
|
$(PACKAGE)-$(VERSION)/tools/pdu.c \
|
||||||
$(PACKAGE)-$(VERSION)/tools/smscrypt.c \
|
$(PACKAGE)-$(VERSION)/tools/smscrypt.c \
|
||||||
$(PACKAGE)-$(VERSION)/tools/Makefile \
|
$(PACKAGE)-$(VERSION)/tools/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/tools/project.conf \
|
$(PACKAGE)-$(VERSION)/tools/project.conf \
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
.cvsignore
|
.cvsignore
|
||||||
|
pdu
|
||||||
smscrypt
|
smscrypt
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
TARGETS = smscrypt
|
TARGETS = pdu smscrypt
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
|
@ -15,6 +15,13 @@ INSTALL = install
|
||||||
|
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
pdu_OBJS = pdu.o
|
||||||
|
pdu_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) -I $(PREFIX)/include $(CFLAGSF) $(CFLAGS) `pkg-config --cflags glib-2.0`
|
||||||
|
pdu_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) `pkg-config --libs glib-2.0` -lSystem -L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib ../src/command.o ../src/modem.o
|
||||||
|
|
||||||
|
pdu: $(pdu_OBJS)
|
||||||
|
$(CC) -o pdu $(pdu_OBJS) $(pdu_LDFLAGS)
|
||||||
|
|
||||||
smscrypt_OBJS = smscrypt.o
|
smscrypt_OBJS = smscrypt.o
|
||||||
smscrypt_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) -I $(PREFIX)/include $(CFLAGSF) $(CFLAGS) `pkg-config --cflags glib-2.0`
|
smscrypt_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) -I $(PREFIX)/include $(CFLAGSF) $(CFLAGS) `pkg-config --cflags glib-2.0`
|
||||||
smscrypt_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) -lSystem -L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib
|
smscrypt_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) -lSystem -L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib
|
||||||
|
@ -22,11 +29,14 @@ smscrypt_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) -lSystem -L $(PREFIX)/lib -Wl,-rpath,$
|
||||||
smscrypt: $(smscrypt_OBJS)
|
smscrypt: $(smscrypt_OBJS)
|
||||||
$(CC) -o smscrypt $(smscrypt_OBJS) $(smscrypt_LDFLAGS)
|
$(CC) -o smscrypt $(smscrypt_OBJS) $(smscrypt_LDFLAGS)
|
||||||
|
|
||||||
|
pdu.o: pdu.c ../include/Phone.h ../src/gsm.c
|
||||||
|
$(CC) $(pdu_CFLAGS) -c pdu.c
|
||||||
|
|
||||||
smscrypt.o: smscrypt.c ../include/Phone.h ../src/plugins/smscrypt.c
|
smscrypt.o: smscrypt.c ../include/Phone.h ../src/plugins/smscrypt.c
|
||||||
$(CC) $(smscrypt_CFLAGS) -c smscrypt.c
|
$(CC) $(smscrypt_CFLAGS) -c smscrypt.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(smscrypt_OBJS)
|
$(RM) $(pdu_OBJS) $(smscrypt_OBJS)
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) $(TARGETS)
|
$(RM) $(TARGETS)
|
||||||
|
|
66
tools/pdu.c
Normal file
66
tools/pdu.c
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */
|
||||||
|
/* This file is part of DeforaOS Desktop Phone */
|
||||||
|
/* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "../src/gsm.c"
|
||||||
|
|
||||||
|
|
||||||
|
/* hexdump */
|
||||||
|
static void _hexdump(char const * buf, size_t len)
|
||||||
|
{
|
||||||
|
unsigned char const * b = (unsigned char *)buf;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for(i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
printf(" %02x", b[i]);
|
||||||
|
if((i % 16) == 7)
|
||||||
|
fputc(' ', stdout);
|
||||||
|
else if((i % 16) == 15)
|
||||||
|
fputc('\n', stdout);
|
||||||
|
}
|
||||||
|
fputc('\n', stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* main */
|
||||||
|
int main(int argc, char * argv[])
|
||||||
|
{
|
||||||
|
time_t timestamp;
|
||||||
|
char number[32];
|
||||||
|
GSMEncoding encoding;
|
||||||
|
char * p;
|
||||||
|
struct tm t;
|
||||||
|
char buf[32];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if(argc != 2)
|
||||||
|
return 1;
|
||||||
|
if((p = _cmgr_pdu_parse(argv[1], ×tamp, number, &encoding, &len))
|
||||||
|
!= NULL)
|
||||||
|
{
|
||||||
|
printf("Number: %s\n", number);
|
||||||
|
gmtime_r(×tamp, &t);
|
||||||
|
strftime(buf, sizeof(buf), "%d/%m/%Y %H:%M:%S", &t);
|
||||||
|
printf("Timestamp: %s\n", buf);
|
||||||
|
printf("Encoding: %u\n", encoding);
|
||||||
|
_hexdump(p, len);
|
||||||
|
if(encoding == GSM_ENCODING_UTF8)
|
||||||
|
printf("Message: %s\n", p);
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,9 +1,19 @@
|
||||||
targets=smscrypt
|
targets=pdu,smscrypt
|
||||||
cppflags_force=-I ../include
|
cppflags_force=-I ../include
|
||||||
cflags_force=-W
|
cflags_force=-W
|
||||||
cflags=-Wall -g -O2
|
cflags=-Wall -g -O2
|
||||||
dist=Makefile
|
dist=Makefile
|
||||||
|
|
||||||
|
[pdu]
|
||||||
|
type=binary
|
||||||
|
sources=pdu.c
|
||||||
|
cppflags=-I $(PREFIX)/include
|
||||||
|
cflags=`pkg-config --cflags glib-2.0`
|
||||||
|
ldflags=`pkg-config --libs glib-2.0` -lSystem -L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib ../src/command.o ../src/modem.o
|
||||||
|
|
||||||
|
[pdu.c]
|
||||||
|
depends=../include/Phone.h,../src/gsm.c
|
||||||
|
|
||||||
[smscrypt]
|
[smscrypt]
|
||||||
type=binary
|
type=binary
|
||||||
sources=smscrypt.c
|
sources=smscrypt.c
|
||||||
|
|
Loading…
Reference in New Issue
Block a user