| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- /*
- * Copyright (C) 2007-2010 Siemens AG
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /*******************************************************************
- *
- * @author Sebastian.Kaebisch.EXT@siemens.com
- * @version 0.3
- * @contact Joerg.Heuer@siemens.com
- *
- ********************************************************************/
- #include "v2g_server.h"
- #include "v2g_service.h"
- #include "v2g_serviceDispatcher.h"
- #include "doIP.h"
- #define MAX_BYTE_SIZE 128
- #define MAX_STRING_SIZE 256
- #define MAX_STREAM_SIZE 60
- int testV2GService(uint8_t* inStream, size_t inStreamLength, uint8_t* outStream, size_t* outStreamLength)
- {
- static uint8_t byte_array[MAX_BYTE_SIZE]; /* define MAX_BYTE_SIZE before*/
- static uint32_t string_array[MAX_STRING_SIZE]; /* define MAX_STRING_SIZE before*/
- size_t exiMsgLength;
- struct v2gService service;
- /* BINARY memory setup */
- bytes_t bytes = { MAX_BYTE_SIZE, byte_array, 0 };
- /* STRING memory setup */
- string_ucs_t string = { MAX_STRING_SIZE, string_array, 0 };
- /**********************************************
- * Init V2G server and initialize array types *
- * for the EXI decoding as well as the offset *
- * for the transportation header *
- **********************************************/
- init_v2gservice(&service, bytes, string, DOIP_HEADER_LENGTH);
- /* check, if the DoIP header is correct and determine payload */
- if(read_doIPHeader(inStream,inStreamLength, &exiMsgLength))
- {
- /* DoIP header not correct */
- write_doIPNack(outStream, outStreamLength, service.errorCode);
- return -1;
- }
- /****************************************************************************
- * Pass the received EXI message stream (inStream + exiMsgLength) to the *
- * v2g message dispatcher. The outStream contains the response message *
- * stream. *
- ****************************************************************************/
- if(messageDispatcher(&service, inStream, exiMsgLength, outStream, MAX_STREAM_SIZE, outStreamLength))
- {
- /* write DoIP failure */
- write_doIPNack(outStream, outStreamLength, service.errorCode);
- }
- else
- {
- /* write DoIP header */
- write_doIPHeader(outStream, outStreamLength, DOIP_EXI_TYPE);
- }
- return 0;
- }
|