~ubuntu-branches/ubuntu/saucy/libpri/saucy

« back to all changes in this revision

Viewing changes to pridump.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2005-12-07 21:25:46 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051207212546-lv02jlyw3pm9ho0q
Tags: 1.2.1-1
* New upstream release
* Disable bristuff for new upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * libpri: An implementation of Primary Rate ISDN
3
3
 *
4
 
 * Written by Mark Spencer <markster@linux-support.net>
 
4
 * Written by Mark Spencer <markster@digium.com>
5
5
 *
6
 
 * Copyright (C) 2001, Linux Support Services, Inc.
 
6
 * Copyright (C) 2001-2005, Digium
7
7
 * All Rights Reserved.
8
8
 *
9
9
 * This program is free software; you can redistribute it and/or modify
67
67
        return dfd;
68
68
}
69
69
 
70
 
static void dump_packet(char *buf, int len, int txrx)
 
70
static void dump_packet(struct pri *pri, char *buf, int len, int txrx)
71
71
{
72
72
        q921_h *h = (q921_h *)buf;
73
 
        q921_dump(h, len, 1, txrx);
 
73
        q921_dump(pri, h, len, 1, txrx);
74
74
        if (!((h->h.data[0] & Q921_FRAMETYPE_MASK) & 0x3)) {
75
 
                q931_dump((q931_h *)(h->i.data), len - 4, txrx);
 
75
                q931_dump(pri, (q931_h *)(h->i.data), len - 4 - 2 /* FCS */, txrx);
76
76
        }
77
77
        fflush(stdout);
78
78
        fflush(stderr);
103
103
                if (FD_ISSET(d1, &fds)) {
104
104
                        /* Copy from d1 to d2 */
105
105
                        res = read(d1, buf, sizeof(buf));
106
 
                        dump_packet(buf, res, 1);
 
106
                        dump_packet((struct pri *)NULL, buf, res, 1);
107
107
                        res = write(d2, buf, res);
108
108
                }
109
109
                if (FD_ISSET(d2, &fds)) {
110
110
                        /* Copy from d2 to d1 */
111
111
                        res = read(d2, buf, sizeof(buf));
112
 
                        dump_packet(buf, res, 0);
 
112
                        dump_packet((struct pri *)NULL, buf, res, 0);
113
113
                        res = write(d1, buf, res);
114
114
                }
115
115
        }
116
116
}
117
117
 
 
118
static void my_pri_message(struct pri *pri, char *stuff)
 
119
{
 
120
        fprintf(stdout, "%s", stuff);
 
121
}
 
122
 
 
123
static void my_pri_error(struct pri *pri, char *stuff)
 
124
{
 
125
        fprintf(stderr, "%s", stuff);
 
126
}
 
127
 
118
128
int main(int argc, char *argv[])
119
129
{
120
130
        int d1, d2;
124
134
                exit(1);
125
135
        }
126
136
        
 
137
        pri_set_message(my_pri_message);
 
138
        pri_set_error(my_pri_error);
 
139
        
127
140
        d1 = pri_open(argv[1]);
128
141
        if (d1 < 0)
129
142
                exit(1);