Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
gseDecodePacket.c
00001 /** 00002 * Rapid-prototyping protection schemes with IEC 61850 00003 * 00004 * Copyright (c) 2011 Steven Blair 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include "gseDecodeBasic.h" 00022 #include "ied.h" 00023 #include "gseDecode.h" 00024 #include "gsePacketData.h" 00025 #include "decodePacket.h" 00026 #include <stddef.h> 00027 00028 00029 unsigned char datasetName[65] = {0}; // maximum length of 65 bytes 00030 CTYPE_INT16U datasetNameLength = 0; 00031 00032 00033 void gseDecodePDU(unsigned char *buf) { 00034 unsigned char tag = (unsigned char) buf[0]; // assumes only one byte is used 00035 CTYPE_INT16U lengthFieldSize = getLengthFieldSize((unsigned char) buf[1]); 00036 CTYPE_INT16U lengthValue = decodeLength((unsigned char *) &buf[1]); 00037 CTYPE_INT16U offsetForSequence = 1 + lengthFieldSize; 00038 CTYPE_INT16U offsetForNonSequence = 1 + lengthFieldSize + lengthValue; 00039 00040 //printf("tag: %x, lengthFieldSize: %i, lengthValue: %i, offset: %i\n", tag, lengthFieldSize, lengthValue, offsetForNonSequence); 00041 00042 switch (tag) { 00043 case 0x61: 00044 gseDecodePDU(&buf[offsetForSequence]); 00045 break; 00046 case 0x82: 00047 // save dataset name 00048 memcpy(datasetName, &buf[offsetForSequence], lengthValue); 00049 datasetNameLength = lengthValue; 00050 //printf("%s, %d\n", datasetName, datasetNameLength); 00051 //fflush(stdout); 00052 00053 gseDecodePDU(&buf[offsetForNonSequence]); 00054 break; 00055 case 0xAB: 00056 gseDecodeDataset(&buf[offsetForSequence], lengthValue, datasetName, datasetNameLength); 00057 return; 00058 //break; 00059 default: 00060 gseDecodePDU(&buf[offsetForNonSequence]); 00061 break; 00062 } 00063 } 00064 00065 void gseDecode(unsigned char *buf, int len) { 00066 gseDecodePDU(&buf[26]); // cuts out frame header (fixed size of 26 bytes before start of APDU) 00067 }
Generated on Mon Jul 18 2022 18:17:52 by
1.7.2