67 lines
3.6 KiB
C
67 lines
3.6 KiB
C
/*
|
|
SIA-HS Alarm Monitoring Service
|
|
Copyright (C) Wilco Baan Hofman <wilco@baanhofman.nl> 2012
|
|
|
|
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; 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 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/>.
|
|
*/
|
|
struct siahs_packet {
|
|
uint32_t len;
|
|
char unknown1; /* 0x01 */
|
|
char unknown2; /* 0x01 */
|
|
uint16_t unknown3; /* '0xcfff' big endian */
|
|
|
|
/* From this point XOR encoded with either 0xB6 or 0x85 */
|
|
char *device;
|
|
uint16_t prom;
|
|
uint8_t unknown4; /* 0x01 */
|
|
uint8_t unknown5; /* 0x2C */
|
|
uint8_t unknown6; /* 0x01 */
|
|
char *message;
|
|
uint16_t checksum;
|
|
};
|
|
|
|
const uint8_t xor_table[] = { 0x51, 0x7a, 0x26, 0x3d, 0x22, 0x21, 0x3b, 0x74,
|
|
0x31, 0x30, 0x74, 0x27, 0x3b, 0x30, 0x3d, 0x22,
|
|
0x21, 0x3b, 0x74, 0x27, 0x3b, 0x74, 0x39, 0x31,
|
|
0x3c, 0x37, 0x3a, 0x31, 0x74, 0x31, 0x27, 0x74,
|
|
0x39, 0x31, 0x3a, 0x74, 0x78, 0x26, 0x31, 0x22,
|
|
0x74, 0x31, 0x30, 0x74, 0x39, 0x35, 0x20, 0x26,
|
|
0x35, 0x32, 0x74, 0x31, 0x27, 0x74, 0x3b, 0xb7,
|
|
0x3a, 0x74, 0x27, 0x3b, 0x3c, 0x38, 0x3b, 0x74,
|
|
0x27, 0x3b, 0x6f, 0xc1, 0x26, 0x3d, 0x39, 0x3d,
|
|
0x26, 0x24, 0x2c, 0x31, 0x74, 0x31, 0x30, 0x3b,
|
|
0x24, 0x74, 0x27, 0x35, 0x74, 0x39, 0xbd, 0x21,
|
|
0x33, 0x3a, 0x3d, 0x3a, 0x74, 0x31, 0x21, 0x25,
|
|
0x74, 0x78, 0x27, 0x3d, 0x35, 0x20, 0x74, 0x27,
|
|
0x35, 0x26, 0x3d, 0x31, 0x27, 0x3a, 0x35, 0x37,
|
|
0x74, 0x3b, 0xb7, 0x27, 0x74, 0x27, 0x35, 0x27,
|
|
0x3d, 0x3b, 0x37, 0x74, 0x27, 0x35, 0x74, 0x27,
|
|
0x35, 0x30, 0x3b, 0x00, 0xfb, 0x7a, 0x26, 0x31,
|
|
0x26, 0x26, 0x3b, 0x37, 0x74, 0x35, 0x74, 0x27,
|
|
0x31, 0x38, 0x31, 0x74, 0x39, 0x35, 0x3a, 0x26,
|
|
0x3b, 0x20, 0x74, 0xb5, 0x38, 0x74, 0x35, 0x26,
|
|
0x35, 0x24, 0x74, 0x78, 0x27, 0x3b, 0x3d, 0x26,
|
|
0x74, 0x27, 0x3b, 0x74, 0x39, 0x31, 0x26, 0x26,
|
|
0x3b, 0x37, 0x74, 0x31, 0x30, 0x3a, 0x3b, 0x74,
|
|
0x35, 0x26, 0x35, 0x24, 0x74, 0x26, 0x35, 0x33,
|
|
0x21, 0x38, 0x74, 0x3b, 0x35, 0x9a, 0x6f, 0x31,
|
|
0x3c, 0x37, 0x3a, 0x31, 0x74, 0x31, 0x27, 0x74,
|
|
0x3b, 0xb7, 0x3a, 0x74, 0x26, 0x35, 0x39, 0x74,
|
|
0x3b, 0x74, 0x31, 0x74, 0x78, 0x26, 0x35, 0x39,
|
|
0x74, 0x3b, 0x74, 0x35, 0x26, 0x35, 0x24, 0x74,
|
|
0x39, 0x31, 0x26, 0x26, 0x3b, 0x37, 0x74, 0x27,
|
|
0x3b, 0x3d, 0x26, 0x74, 0x27, 0x3b, 0x74, 0x27,
|
|
0x3b, 0x30, 0x3b, 0x00, 0xaa, 0x11, 0x46, 0x54,
|
|
};
|
|
STATUS parse_siahs_message(TALLOC_CTX *mem_ctx, const char *pkt_prom, const char *message);
|