anjana_sreekumar@infosys.com | 991c206 | 2020-01-08 11:42:57 +0530 | [diff] [blame^] | 1 | #include "gtpV2Stack.h" |
| 2 | #include "msgBuffer.h" |
| 3 | #include "gtpV2StackWrappers.h" |
| 4 | |
| 5 | extern "C" |
| 6 | { |
| 7 | GtpV2Stack* createGtpV2Stack() |
| 8 | { |
| 9 | return new GtpV2Stack(); |
| 10 | } |
| 11 | |
| 12 | MsgBuffer* createMsgBuffer(uint16_t size) |
| 13 | { |
| 14 | return new MsgBuffer(); |
| 15 | } |
| 16 | |
| 17 | void MsgBuffer_free(MsgBuffer* buf_p) |
| 18 | { |
| 19 | delete buf_p; |
| 20 | } |
| 21 | |
| 22 | void* MsgBuffer_getDataPointer(MsgBuffer* buf_p) |
| 23 | { |
| 24 | return buf_p->getDataPointer(); |
| 25 | } |
| 26 | |
| 27 | uint16_t MsgBuffer_getBufLen(MsgBuffer* buf_p) |
| 28 | { |
| 29 | return buf_p->getLength(); |
| 30 | } |
| 31 | |
| 32 | void MsgBuffer_reset(MsgBuffer* buf_p) |
| 33 | { |
| 34 | return buf_p->reset(); |
| 35 | } |
| 36 | |
| 37 | bool MsgBuffer_writeBytes(MsgBuffer* msgBuf_p, Uint8* data, Uint16 size, bool append) |
| 38 | { |
| 39 | return msgBuf_p->writeBytes(data, size, append); |
| 40 | } |
| 41 | |
| 42 | void MsgBuffer_rewind(MsgBuffer* msgBuf_p) |
| 43 | { |
| 44 | return msgBuf_p->rewind(); |
| 45 | } |
| 46 | |
| 47 | bool GtpV2Stack_buildGtpV2Message( |
| 48 | GtpV2Stack* stack_p, |
| 49 | MsgBuffer* buf_p, |
| 50 | GtpV2MessageHeader* msgHeader_p, |
| 51 | void* data_p) |
| 52 | { |
| 53 | bool rc = stack_p->encodeMessage(*msgHeader_p, *buf_p, data_p); |
| 54 | if (rc == false) |
| 55 | { |
| 56 | errorStream.printDebugStream(); |
| 57 | } else |
| 58 | { |
| 59 | cout << "GTP Encode Success" << endl; |
| 60 | } |
| 61 | return rc; |
| 62 | } |
| 63 | |
| 64 | bool GtpV2Stack_decodeMessageHeader(GtpV2Stack* stack_p, GtpV2MessageHeader* hdr_p, MsgBuffer* msgBuf_p) |
| 65 | { |
| 66 | return stack_p->decodeGtpMessageHeader(*hdr_p, *msgBuf_p); |
| 67 | } |
| 68 | |
| 69 | bool GtpV2Stack_decodeMessage(GtpV2Stack* stack_p, |
| 70 | GtpV2MessageHeader* msgHeader, |
| 71 | MsgBuffer* buffer, |
| 72 | void* data_p) |
| 73 | { |
| 74 | bool rc = stack_p->decodeMessage(*msgHeader, *buffer, data_p); |
| 75 | if (rc == false) |
| 76 | { |
| 77 | errorStream.printDebugStream(); |
| 78 | } else |
| 79 | { |
| 80 | cout << "GTP Decode Success" << endl; |
| 81 | } |
| 82 | return rc; |
| 83 | } |
| 84 | |
| 85 | } |