Harald Welte | 4b233b4 | 2012-11-07 08:32:31 +0100 | [diff] [blame^] | 1 | |
| 2 | /* |
| 3 | * Copyright (C) 2006 Raul Tremsal |
| 4 | * File : core.c |
| 5 | * Author: Raul Tremsal <ultraismo@yahoo.com> |
| 6 | * |
| 7 | * This file is part of libsmpp34 (c-open-smpp3.4 library). |
| 8 | * |
| 9 | * The libsmpp34 library is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU Lesser General Public License as |
| 11 | * published by the Free Software Foundation; either version 2.1 of the |
| 12 | * License, or (at your option) any later version. |
| 13 | * |
| 14 | * This library is distributed in the hope that it will be useful, but |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 16 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 17 | * License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Lesser General Public License |
| 20 | * along with this library; if not, write to the Free Software Foundation, |
| 21 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <string.h> |
| 27 | #include <sys/types.h> |
| 28 | #include <netinet/in.h> |
| 29 | |
| 30 | #ifdef __linux__ |
| 31 | #include <stdint.h> |
| 32 | #endif |
| 33 | |
| 34 | #include "smpp34.h" |
| 35 | #include "smpp34_structs.h" |
| 36 | #include "smpp34_params.h" |
| 37 | |
| 38 | extern int smpp34_errno; |
| 39 | extern char smpp34_strerror[2048]; |
| 40 | |
| 41 | |
| 42 | int |
| 43 | doTest( uint32_t id, void* dst, void* src ) |
| 44 | { |
| 45 | |
| 46 | int ret = 0; |
| 47 | uint8_t bufPDU[2048]; |
| 48 | int bufPDULen = 0; |
| 49 | uint8_t bPrint[2048]; |
| 50 | |
| 51 | /* Linealize PDU to buffer ********************************************/ |
| 52 | memset(&bufPDU, 0, sizeof(bufPDU)); |
| 53 | ret = smpp34_pack(id, bufPDU, sizeof(bufPDU), &bufPDULen, (void*)src); |
| 54 | if( ret != 0 ){ |
| 55 | printf("Error in smpp34_pack():%d:\n%s\n", |
| 56 | smpp34_errno, smpp34_strerror); |
| 57 | return( 0 ); |
| 58 | }; |
| 59 | printf("parse smpp34_pack()\n%s\n", smpp34_strerror); |
| 60 | |
| 61 | /* Print PDU **********************************************************/ |
| 62 | memset(&bPrint, 0, sizeof(bPrint)); |
| 63 | ret = smpp34_dumpPdu(id, bPrint, sizeof(bPrint), (void*)src); |
| 64 | if( ret != 0){ |
| 65 | printf("Error in smpp34_dumpPdu():%d:\n%s\n", |
| 66 | smpp34_errno, smpp34_strerror); |
| 67 | return( -1 ); |
| 68 | }; |
| 69 | printf("parse smpp34_dumpPdu()\n%s\n", smpp34_strerror); |
| 70 | printf("-----------------------------------------------------------\n"); |
| 71 | printf("%s\n", bPrint); |
| 72 | printf("-----------------------------------------------------------\n"); |
| 73 | |
| 74 | /* Print Buffer *******************************************************/ |
| 75 | memset(bPrint, 0, sizeof(bPrint)); |
| 76 | ret = smpp34_dumpBuf(bPrint, sizeof(bPrint), bufPDU, bufPDULen); |
| 77 | if( ret != 0 ){ |
| 78 | printf("Error in smpp34_dumpBuf():%d:\n%s\n", |
| 79 | smpp34_errno, smpp34_strerror ); |
| 80 | return( -1 ); |
| 81 | }; |
| 82 | printf("parse smpp34_dumpBuf()\n%s\n", smpp34_strerror); |
| 83 | printf("-----------------------------------------------------------\n"); |
| 84 | printf("%s", bPrint); |
| 85 | printf("-----------------------------------------------------------\n"); |
| 86 | |
| 87 | /* Copy PDU from Buffer ***********************************************/ |
| 88 | ret = smpp34_unpack(id, (void*)dst, bufPDU, bufPDULen); |
| 89 | if( ret != 0 ){ |
| 90 | printf("Error in smpp34_unpack():%d:\n%s\n", |
| 91 | smpp34_errno, smpp34_strerror); |
| 92 | return( -1 ); |
| 93 | }; |
| 94 | printf("parse smpp34_unpack()\n%s\n", smpp34_strerror); |
| 95 | |
| 96 | /* Print PDU **********************************************************/ |
| 97 | memset(bPrint, 0, sizeof(bPrint)); |
| 98 | ret = smpp34_dumpPdu(id, bPrint, sizeof(bPrint), (void*)dst ); |
| 99 | if( ret != 0){ |
| 100 | printf("Error in smpp34_dumpPdu():%d:\n%s\n", |
| 101 | smpp34_errno, smpp34_strerror); |
| 102 | return( -1 ); |
| 103 | }; |
| 104 | printf("parse smpp34_dumpPdu()\n%s\n", smpp34_strerror); |
| 105 | printf("-----------------------------------------------------------\n"); |
| 106 | printf("%s\n", bPrint); |
| 107 | printf("-----------------------------------------------------------\n"); |
| 108 | return( 0 ); |
| 109 | }; |