Deleted Added
full compact
cc_dump.c (131826) cc_dump.c (133492)
1/*
2 * Copyright (c) 2003-2004
3 * Hartmut Brandt
4 * All rights reserved.
5 *
6 * Author: Harti Brandt <harti@freebsd.org>
7 *
8 * Redistribution of this software and documentation and use in source and

--- 13 unchanged lines hidden (view full) ---

22 * THE AUTHOR OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
25 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
1/*
2 * Copyright (c) 2003-2004
3 * Hartmut Brandt
4 * All rights reserved.
5 *
6 * Author: Harti Brandt <harti@freebsd.org>
7 *
8 * Redistribution of this software and documentation and use in source and

--- 13 unchanged lines hidden (view full) ---

22 * THE AUTHOR OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
25 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $Begemot: libunimsg/netnatm/api/cc_dump.c,v 1.1 2004/07/08 08:21:51 brandt Exp $
30 * $Begemot: libunimsg/netnatm/api/cc_dump.c,v 1.3 2004/08/05 07:10:56 brandt Exp $
31 *
32 * ATM API as defined per af-saa-0108
33 */
34
35#include <netnatm/unimsg.h>
36#include <netnatm/msg/unistruct.h>
37#include <netnatm/msg/unimsglib.h>
38#include <netnatm/api/unisap.h>
39#include <netnatm/sig/unidef.h>
40#include <netnatm/api/atmapi.h>
41#include <netnatm/api/ccatm.h>
42#include <netnatm/api/ccpriv.h>
43
44#ifdef _KERNEL
45#ifdef __FreeBSD__
31 *
32 * ATM API as defined per af-saa-0108
33 */
34
35#include <netnatm/unimsg.h>
36#include <netnatm/msg/unistruct.h>
37#include <netnatm/msg/unimsglib.h>
38#include <netnatm/api/unisap.h>
39#include <netnatm/sig/unidef.h>
40#include <netnatm/api/atmapi.h>
41#include <netnatm/api/ccatm.h>
42#include <netnatm/api/ccpriv.h>
43
44#ifdef _KERNEL
45#ifdef __FreeBSD__
46#include <sys/stdarg.h>
46#include <machine/stdarg.h>
47#endif
48#else /* !_KERNEL */
49#include <stdarg.h>
50#endif
51
52/*
53 * local structure to reduce number of arguments to functions
54 */

--- 24 unchanged lines hidden (view full) ---

79 d->buf[0] = '\0';
80 d->len = 0;
81 }
82 va_start(ap, fmt);
83 n = vsnprintf(d->buf + d->len, d->maxsiz - d->len, fmt, ap);
84 va_end(ap);
85
86 if (n < 0) {
47#endif
48#else /* !_KERNEL */
49#include <stdarg.h>
50#endif
51
52/*
53 * local structure to reduce number of arguments to functions
54 */

--- 24 unchanged lines hidden (view full) ---

79 d->buf[0] = '\0';
80 d->len = 0;
81 }
82 va_start(ap, fmt);
83 n = vsnprintf(d->buf + d->len, d->maxsiz - d->len, fmt, ap);
84 va_end(ap);
85
86 if (n < 0) {
87 d->ret = errno;
87 d->ret = CCGETERRNO();
88 return;
89 }
90 if ((size_t)n < d->maxsiz - d->len) {
91 d->len += n;
92 return;
93 }
94
95 /* undo the vsnprintf() and flush */

--- 4 unchanged lines hidden (view full) ---

100 d->buf[0] = '\0';
101 d->len = 0;
102
103 va_start(ap, fmt);
104 n = vsnprintf(d->buf, d->maxsiz, fmt, ap);
105 va_end(ap);
106
107 if (n < 0) {
88 return;
89 }
90 if ((size_t)n < d->maxsiz - d->len) {
91 d->len += n;
92 return;
93 }
94
95 /* undo the vsnprintf() and flush */

--- 4 unchanged lines hidden (view full) ---

100 d->buf[0] = '\0';
101 d->len = 0;
102
103 va_start(ap, fmt);
104 n = vsnprintf(d->buf, d->maxsiz, fmt, ap);
105 va_end(ap);
106
107 if (n < 0) {
108 d->ret = errno;
108 d->ret = CCGETERRNO();
109 return;
110 }
111 if ((size_t)n >= d->maxsiz) {
112 /* ok, truncate */
113 d->len = d->maxsiz - 1;
114 return;
115 }
116 d->len = n;
117}
118
119/*
120 * Dump a SAP
121 */
122static void
123cc_dump_sap(struct dump *d, const struct uni_sap *sap)
124{
125 static const char *const tagtab[] = {
109 return;
110 }
111 if ((size_t)n >= d->maxsiz) {
112 /* ok, truncate */
113 d->len = d->maxsiz - 1;
114 return;
115 }
116 d->len = n;
117}
118
119/*
120 * Dump a SAP
121 */
122static void
123cc_dump_sap(struct dump *d, const struct uni_sap *sap)
124{
125 static const char *const tagtab[] = {
126 [UNISVE_ABSENT] "absent",
127 [UNISVE_ANY] "any",
128 [UNISVE_PRESENT]"present"
126 [UNISVE_ABSENT] = "absent",
127 [UNISVE_ANY] = "any",
128 [UNISVE_PRESENT] = "present"
129 };
130 static const char *const plantab[] = {
129 };
130 static const char *const plantab[] = {
131 [UNI_ADDR_E164] "E164",
132 [UNI_ADDR_ATME] "ATME",
131 [UNI_ADDR_E164] = "E164",
132 [UNI_ADDR_ATME] = "ATME",
133 };
134 static const char *const hlitab[] = {
133 };
134 static const char *const hlitab[] = {
135 [UNI_BHLI_ISO] "ISO",
136 [UNI_BHLI_VENDOR] "VENDOR",
137 [UNI_BHLI_USER] "USER"
135 [UNI_BHLI_ISO] = "ISO",
136 [UNI_BHLI_VENDOR] = "VENDOR",
137 [UNI_BHLI_USER] = "USER"
138 };
139 u_int i;
140
141 cc_dumpf(d, " sap(%p):\n", sap);
142 cc_dumpf(d, " addr=%s", tagtab[sap->addr.tag]);
143 if (sap->addr.tag == UNISVE_PRESENT) {
144 cc_dumpf(d, " %s %u ", plantab[sap->addr.plan], sap->addr.len);
145 if (sap->addr.plan == UNI_ADDR_E164)

--- 189 unchanged lines hidden ---
138 };
139 u_int i;
140
141 cc_dumpf(d, " sap(%p):\n", sap);
142 cc_dumpf(d, " addr=%s", tagtab[sap->addr.tag]);
143 if (sap->addr.tag == UNISVE_PRESENT) {
144 cc_dumpf(d, " %s %u ", plantab[sap->addr.plan], sap->addr.len);
145 if (sap->addr.plan == UNI_ADDR_E164)

--- 189 unchanged lines hidden ---