-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathparser_debug.c
91 lines (75 loc) · 2.1 KB
/
parser_debug.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* libss7: An implementation of Signalling System 7
*
* Written by Matthew Fredrickson <[email protected]>
*
* scheduling routines taken from libpri by Mark Spencer <[email protected]>
*
* Copyright (C) 2006-2008, Digium, Inc
* All Rights Reserved.
*/
/*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2 as published by the
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
*
* In addition, when this program is distributed with Asterisk in
* any form that would qualify as a 'combined work' or as a
* 'derivative work' (but not mere aggregation), you can redistribute
* and/or modify the combination under the terms of the license
* provided with that copy of Asterisk, instead of the license
* terms granted here.
*/
#include <stdio.h>
#include <string.h>
#include "libss7.h"
#include "ss7_internal.h"
#include "mtp2.h"
#include "isup.h"
#include "mtp3.h"
int main(int argc, char **argv)
{
FILE *fp;
struct ss7 *ss7;
unsigned char mybuf[512];
unsigned int tmp;
int ss7type;
int res = 0, i = 0, size;
ss7_event *e;
if (argc != 3) {
return -1;
}
if (!strcasecmp(argv[1], "ansi")) {
ss7type = SS7_ANSI;
} else if (!strcasecmp(argv[1], "itu")) {
ss7type = SS7_ITU;
} else {
return -1;
}
ss7 = ss7_new(ss7type);
fp = fopen(argv[2], "r");
while (res != EOF) {
res = fscanf(fp, "%x ", &tmp);
mybuf[i++] = (unsigned char) tmp;
}
size = i + 1;
for (i = 0; i < size; i++) {
printf("%.2x ", mybuf[i]);
}
printf("\n");
ss7_add_link(ss7, SS7_TRANSPORT_DAHDIDCHAN, 10, -1, 0);
ss7->debug = SS7_DEBUG_MTP2 | SS7_DEBUG_MTP3 | SS7_DEBUG_ISUP;
ss7->links[0]->state = MTP_INSERVICE;
mtp2_receive(ss7->links[0], mybuf, size);
if ((e = ss7_check_event(ss7))) {
printf("Got event: %s\n", ss7_event2str(e->e));
}
return 0;
}