1 /*
2 NETWIB
3 Network library
4 Copyright(c) 1999-2010 Laurent Constantin
5 -----
6
7 Main server : http://www.laurentconstantin.com/
8 Backup server : http://laurentconstantin.free.fr/
9 [my current email address is on the web servers]
10
11 -----
12 This file is part of Netwib.
13
14 Netwib is free software: you can redistribute it and/or modify
15 it under the terms of the GNU General Public License version 3
16 as published by the Free Software Foundation.
17
18 Netwib is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details (http://www.gnu.org/).
22
23 ------------------------------------------------------------------------
24 */
25
26 #include <netwib/inc/maininc.h>
27
28 /*-------------------------------------------------------------*/
netwib_pkt_data_show(netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype encodetype,netwib_buf * pbuf)29 netwib_err netwib_pkt_data_show(netwib_constbuf *ppkt,
30 netwib_encodetype_context *pctx,
31 netwib_encodetype encodetype,
32 netwib_buf *pbuf)
33 {
34 netwib_er(netwib_buf_encode_transition(pctx, encodetype, pbuf));
35 netwib_er(netwib_buf_encode(ppkt, encodetype, pbuf));
36
37 return(NETWIB_ERR_OK);
38 }
39
40 /*-------------------------------------------------------------*/
netwib_pkt_data_display(netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype encodetype)41 netwib_err netwib_pkt_data_display(netwib_constbuf *ppkt,
42 netwib_encodetype_context *pctx,
43 netwib_encodetype encodetype)
44 {
45 netwib_err ret;
46 netwib_string pc;
47 netwib_buf buf;
48
49 netwib_er(netwib_buf_init_mallocdefault(&buf));
50 ret = netwib_pkt_data_show(ppkt, pctx, encodetype, &buf);
51 if (ret == NETWIB_ERR_OK) {
52 netwib_er(netwib_buf_encode_transition_end(pctx, &buf));
53 netwib_er(netwib_buf_ref_string(&buf, &pc));
54 fprintf(stdout, "%s", pc);
55 fflush(stdout);
56 }
57 netwib_er(netwib_buf_close(&buf));
58
59 return(ret);
60 }
61
62 /*-------------------------------------------------------------*/
netwib_pkt_link_show(netwib_device_dlttype dlttype,netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype hdrencodetype,netwib_encodetype dataencodetype,netwib_buf * pbuf)63 netwib_err netwib_pkt_link_show(netwib_device_dlttype dlttype,
64 netwib_constbuf *ppkt,
65 netwib_encodetype_context *pctx,
66 netwib_encodetype hdrencodetype,
67 netwib_encodetype dataencodetype,
68 netwib_buf *pbuf)
69 {
70 netwib_linkhdr linkhdr;
71 netwib_arphdr arpheader;
72 netwib_linkhdrproto linkhdrproto;
73 netwib_buf pkt;
74 netwib_encodetype_context *pctxtouse, ctx;
75 netwib_err ret;
76
77 pctxtouse = pctx;
78 if (pctx == NULL) {
79 netwib_er(netwib_buf_encode_transition_init(&ctx));
80 pctxtouse = &ctx;
81 }
82
83 pkt = *ppkt;
84 ret = netwib_pkt_decode_layer_link(dlttype, &pkt, &linkhdr);
85 if (ret == NETWIB_ERR_NOTCONVERTED || ret == NETWIB_ERR_DATAMISSING) {
86 netwib_er(netwib_pkt_data_show(&pkt, pctxtouse, dataencodetype, pbuf));
87 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
88 return(NETWIB_ERR_OK);
89 } else if (ret != NETWIB_ERR_OK) {
90 return(ret);
91 }
92
93 if (dlttype != NETWIB_DEVICE_DLTTYPE_RAW &&
94 dlttype != NETWIB_DEVICE_DLTTYPE_RAW4 &&
95 dlttype != NETWIB_DEVICE_DLTTYPE_RAW6) {
96 netwib_er(netwib_buf_encode_transition(pctxtouse, hdrencodetype, pbuf));
97 netwib_er(netwib_linkhdr_show(&linkhdr, hdrencodetype, pbuf));
98 }
99
100 netwib_er(netwib_linkhdr_get_proto(&linkhdr, &linkhdrproto));
101 switch(linkhdrproto) {
102 case NETWIB_LINKHDRPROTO_ARP :
103 case NETWIB_LINKHDRPROTO_RARP :
104 ret = netwib_pkt_decode_layer_arp(&pkt, &arpheader);
105 if (ret == NETWIB_ERR_NOTCONVERTED || ret == NETWIB_ERR_DATAMISSING) {
106 netwib_er(netwib_pkt_data_show(&pkt, pctxtouse, dataencodetype, pbuf));
107 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
108 return(NETWIB_ERR_OK);
109 } else if (ret != NETWIB_ERR_OK) {
110 return(ret);
111 }
112 netwib_er(netwib_buf_encode_transition(pctxtouse, hdrencodetype, pbuf));
113 netwib_er(netwib_arphdr_show(&arpheader, hdrencodetype, pbuf));
114 netwib_er(netwib_buf_encode_transition(pctxtouse,
115 NETWIB_ENCODETYPE_TRANSITION_END,
116 pbuf));
117 break;
118 case NETWIB_LINKHDRPROTO_IP4 :
119 case NETWIB_LINKHDRPROTO_IP6 :
120 netwib_er(netwib_pkt_ip_show(&pkt, pctxtouse, hdrencodetype,
121 dataencodetype, pbuf));
122 break;
123 default :
124 netwib_er(netwib_pkt_data_show(&pkt, pctxtouse, dataencodetype, pbuf));
125 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
126 break;
127 }
128
129 return(NETWIB_ERR_OK);
130 }
131
132 /*-------------------------------------------------------------*/
netwib_pkt_link_display(netwib_device_dlttype dlttype,netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype hdrencodetype,netwib_encodetype dataencodetype)133 netwib_err netwib_pkt_link_display(netwib_device_dlttype dlttype,
134 netwib_constbuf *ppkt,
135 netwib_encodetype_context *pctx,
136 netwib_encodetype hdrencodetype,
137 netwib_encodetype dataencodetype)
138 {
139 netwib_err ret;
140 netwib_string pc;
141 netwib_buf buf;
142
143 netwib_er(netwib_buf_init_mallocdefault(&buf));
144 ret = netwib_pkt_link_show(dlttype, ppkt, pctx, hdrencodetype,
145 dataencodetype, &buf);
146 if (ret == NETWIB_ERR_OK) {
147 netwib_er(netwib_buf_ref_string(&buf, &pc));
148 fprintf(stdout, "%s", pc);
149 fflush(stdout);
150 }
151 netwib_er(netwib_buf_close(&buf));
152
153 return(ret);
154 }
155
156
157 /*-------------------------------------------------------------*/
netwib_pkt_ip_show_isfrag(netwib_constiphdr * piphdr,netwib_bool * pisfrag)158 static netwib_err netwib_pkt_ip_show_isfrag(netwib_constiphdr *piphdr,
159 netwib_bool *pisfrag)
160 {
161 netwib_uint32 skipsize;
162 netwib_ipproto pktproto;
163 netwib_ip6ext ip6ext;
164 netwib_buf pkt;
165 netwib_err ret;
166
167 *pisfrag = NETWIB_FALSE;
168
169 ret = NETWIB_ERR_OK;
170 switch(piphdr->iptype) {
171 case NETWIB_IPTYPE_IP4 :
172 if (piphdr->header.ip4.offsetfrag) {
173 *pisfrag = NETWIB_TRUE;
174 }
175 break;
176 case NETWIB_IPTYPE_IP6 :
177 if (netwib__buf_ref_data_size(&piphdr->header.ip6.exts) != 0) {
178 pktproto = piphdr->protocol;
179 pkt = piphdr->header.ip6.exts;
180 while (NETWIB_TRUE) {
181 if (pktproto == NETWIB_IPPROTO_FRAGMENT) {
182 ret = netwib_pkt_decode_ip6ext(pktproto, &pkt, &ip6ext, NULL);
183 if (ret == NETWIB_ERR_OK) {
184 if (ip6ext.ext.fragment.fragmentoffset) {
185 *pisfrag = NETWIB_TRUE;
186 }
187 }
188 break;
189 }
190 ret = netwib_priv_ip6exts_skip_ip6ext(pktproto, &pkt,
191 &pktproto, &skipsize);
192 if (ret != NETWIB_ERR_OK) {
193 if (ret == NETWIB_ERR_NOTCONVERTED) ret = NETWIB_ERR_OK;
194 if (ret == NETWIB_ERR_DATAMISSING) ret = NETWIB_ERR_OK;
195 break;
196 }
197 pkt.beginoffset += skipsize;
198 }
199 }
200 break;
201 default :
202 return(NETWIB_ERR_PAIPTYPE);
203 }
204
205 return(ret);
206 }
207
208 /*-------------------------------------------------------------*/
netwib_pkt_ip_show(netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype hdrencodetype,netwib_encodetype dataencodetype,netwib_buf * pbuf)209 netwib_err netwib_pkt_ip_show(netwib_constbuf *ppkt,
210 netwib_encodetype_context *pctx,
211 netwib_encodetype hdrencodetype,
212 netwib_encodetype dataencodetype,
213 netwib_buf *pbuf)
214 {
215 netwib_iphdr iphdr;
216 netwib_buf pkt;
217 netwib_encodetype_context *pctxtouse, ctx;
218 netwib_bool isfragment;
219 netwib_ipproto ipproto;
220 netwib_err ret;
221
222 pctxtouse = pctx;
223 if (pctx == NULL) {
224 netwib_er(netwib_buf_encode_transition_init(&ctx));
225 pctxtouse = &ctx;
226 }
227
228 pkt = *ppkt;
229 ret = netwib_pkt_decode_layer_ip(&pkt, &iphdr);
230 if (ret == NETWIB_ERR_NOTCONVERTED || ret == NETWIB_ERR_DATAMISSING) {
231 netwib_er(netwib_pkt_data_show(&pkt, pctxtouse, dataencodetype, pbuf));
232 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
233 return(NETWIB_ERR_OK);
234 } else if (ret != NETWIB_ERR_OK) {
235 return(ret);
236 }
237
238 netwib_er(netwib_buf_encode_transition(pctxtouse, hdrencodetype, pbuf));
239 netwib_er(netwib_iphdr_show(&iphdr, hdrencodetype, pbuf));
240
241 /* fragments cannot be displayed */
242 netwib_er(netwib_pkt_ip_show_isfrag(&iphdr, &isfragment));
243 if (isfragment) {
244 netwib_er(netwib_pkt_data_show(&pkt, pctxtouse, dataencodetype, pbuf));
245 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
246 return(NETWIB_ERR_OK);
247 }
248
249 netwib_er(netwib_iphdr_get_proto(&iphdr, &ipproto));
250 switch(ipproto) {
251 case NETWIB_IPPROTO_UDP :
252 netwib_er(netwib_pkt_udp_show(&pkt, pctxtouse, hdrencodetype,
253 dataencodetype, pbuf));
254 break;
255 case NETWIB_IPPROTO_TCP :
256 netwib_er(netwib_pkt_tcp_show(&pkt, pctxtouse, hdrencodetype,
257 dataencodetype, pbuf));
258 break;
259 case NETWIB_IPPROTO_ICMP4 :
260 netwib_er(netwib_pkt_icmp4_show(&pkt, pctxtouse, hdrencodetype,
261 dataencodetype, pbuf));
262 break;
263 case NETWIB_IPPROTO_ICMP6 :
264 netwib_er(netwib_pkt_icmp6_show(&pkt, pctxtouse, hdrencodetype,
265 dataencodetype, pbuf));
266 break;
267 default :
268 netwib_er(netwib_pkt_data_show(&pkt, pctxtouse, dataencodetype,
269 pbuf));
270 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
271 break;
272 }
273
274 return(NETWIB_ERR_OK);
275 }
276
277 /*-------------------------------------------------------------*/
netwib_pkt_ip_display(netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype hdrencodetype,netwib_encodetype dataencodetype)278 netwib_err netwib_pkt_ip_display(netwib_constbuf *ppkt,
279 netwib_encodetype_context *pctx,
280 netwib_encodetype hdrencodetype,
281 netwib_encodetype dataencodetype)
282 {
283 netwib_err ret;
284 netwib_string pc;
285 netwib_buf buf;
286
287 netwib_er(netwib_buf_init_mallocdefault(&buf));
288 ret = netwib_pkt_ip_show(ppkt, pctx, hdrencodetype, dataencodetype,
289 &buf);
290 if (ret == NETWIB_ERR_OK) {
291 netwib_er(netwib_buf_ref_string(&buf, &pc));
292 fprintf(stdout, "%s", pc);
293 fflush(stdout);
294 }
295 netwib_er(netwib_buf_close(&buf));
296
297 return(ret);
298 }
299
300 /*-------------------------------------------------------------*/
netwib_pkt_udp_show(netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype hdrencodetype,netwib_encodetype dataencodetype,netwib_buf * pbuf)301 netwib_err netwib_pkt_udp_show(netwib_constbuf *ppkt,
302 netwib_encodetype_context *pctx,
303 netwib_encodetype hdrencodetype,
304 netwib_encodetype dataencodetype,
305 netwib_buf *pbuf)
306 {
307 netwib_udphdr udpheader;
308 netwib_buf pkt;
309 netwib_encodetype_context *pctxtouse, ctx;
310 netwib_err ret;
311
312 pctxtouse = pctx;
313 if (pctx == NULL) {
314 netwib_er(netwib_buf_encode_transition_init(&ctx));
315 pctxtouse = &ctx;
316 }
317
318 pkt = *ppkt;
319 ret = netwib_pkt_decode_layer_udp(&pkt, &udpheader);
320 if (ret == NETWIB_ERR_NOTCONVERTED || ret == NETWIB_ERR_DATAMISSING) {
321 netwib_er(netwib_pkt_data_show(&pkt, pctxtouse, dataencodetype, pbuf));
322 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
323 return(NETWIB_ERR_OK);
324 } else if (ret != NETWIB_ERR_OK) {
325 return(ret);
326 }
327
328 netwib_er(netwib_buf_encode_transition(pctxtouse, hdrencodetype, pbuf));
329 netwib_er(netwib_udphdr_show(&udpheader, hdrencodetype, pbuf));
330
331 netwib_er(netwib_pkt_data_show(&pkt, pctxtouse, dataencodetype, pbuf));
332 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
333
334 return(NETWIB_ERR_OK);
335 }
336
337 /*-------------------------------------------------------------*/
netwib_pkt_udp_display(netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype hdrencodetype,netwib_encodetype dataencodetype)338 netwib_err netwib_pkt_udp_display(netwib_constbuf *ppkt,
339 netwib_encodetype_context *pctx,
340 netwib_encodetype hdrencodetype,
341 netwib_encodetype dataencodetype)
342 {
343 netwib_err ret;
344 netwib_string pc;
345 netwib_buf buf;
346
347 netwib_er(netwib_buf_init_mallocdefault(&buf));
348 ret = netwib_pkt_udp_show(ppkt, pctx, hdrencodetype, dataencodetype, &buf);
349 if (ret == NETWIB_ERR_OK) {
350 netwib_er(netwib_buf_ref_string(&buf, &pc));
351 fprintf(stdout, "%s", pc);
352 fflush(stdout);
353 }
354 netwib_er(netwib_buf_close(&buf));
355
356 return(ret);
357 }
358
359 /*-------------------------------------------------------------*/
netwib_pkt_tcp_show(netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype hdrencodetype,netwib_encodetype dataencodetype,netwib_buf * pbuf)360 netwib_err netwib_pkt_tcp_show(netwib_constbuf *ppkt,
361 netwib_encodetype_context *pctx,
362 netwib_encodetype hdrencodetype,
363 netwib_encodetype dataencodetype,
364 netwib_buf *pbuf)
365 {
366 netwib_tcphdr tcpheader;
367 netwib_buf pkt;
368 netwib_encodetype_context *pctxtouse, ctx;
369 netwib_err ret;
370
371 pctxtouse = pctx;
372 if (pctx == NULL) {
373 netwib_er(netwib_buf_encode_transition_init(&ctx));
374 pctxtouse = &ctx;
375 }
376
377 pkt = *ppkt;
378 ret = netwib_pkt_decode_layer_tcp(&pkt, &tcpheader);
379 if (ret == NETWIB_ERR_NOTCONVERTED || ret == NETWIB_ERR_DATAMISSING) {
380 netwib_er(netwib_pkt_data_show(&pkt, pctxtouse, dataencodetype, pbuf));
381 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
382 return(NETWIB_ERR_OK);
383 } else if (ret != NETWIB_ERR_OK) {
384 return(ret);
385 }
386
387 netwib_er(netwib_buf_encode_transition(pctxtouse, hdrencodetype, pbuf));
388 netwib_er(netwib_tcphdr_show(&tcpheader, hdrencodetype, pbuf));
389
390 netwib_er(netwib_pkt_data_show(&pkt, pctxtouse, dataencodetype, pbuf));
391 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
392
393 return(NETWIB_ERR_OK);
394 }
395
396 /*-------------------------------------------------------------*/
netwib_pkt_tcp_display(netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype hdrencodetype,netwib_encodetype dataencodetype)397 netwib_err netwib_pkt_tcp_display(netwib_constbuf *ppkt,
398 netwib_encodetype_context *pctx,
399 netwib_encodetype hdrencodetype,
400 netwib_encodetype dataencodetype)
401 {
402 netwib_err ret;
403 netwib_string pc;
404 netwib_buf buf;
405
406 netwib_er(netwib_buf_init_mallocdefault(&buf));
407 ret = netwib_pkt_tcp_show(ppkt, pctx, hdrencodetype, dataencodetype, &buf);
408 if (ret == NETWIB_ERR_OK) {
409 netwib_er(netwib_buf_ref_string(&buf, &pc));
410 fprintf(stdout, "%s", pc);
411 fflush(stdout);
412 }
413 netwib_er(netwib_buf_close(&buf));
414
415 return(ret);
416 }
417
418 /*-------------------------------------------------------------*/
netwib_pkt_icmp4_show(netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype hdrencodetype,netwib_encodetype dataencodetype,netwib_buf * pbuf)419 netwib_err netwib_pkt_icmp4_show(netwib_constbuf *ppkt,
420 netwib_encodetype_context *pctx,
421 netwib_encodetype hdrencodetype,
422 netwib_encodetype dataencodetype,
423 netwib_buf *pbuf)
424 {
425 netwib_icmp4 icmp4;
426 netwib_buf pkt;
427 netwib_encodetype_context *pctxtouse, ctx;
428 netwib_err ret;
429
430 pctxtouse = pctx;
431 if (pctx == NULL) {
432 netwib_er(netwib_buf_encode_transition_init(&ctx));
433 pctxtouse = &ctx;
434 }
435
436 pkt = *ppkt;
437 ret = netwib_pkt_decode_layer_icmp4(&pkt, &icmp4);
438 if (ret == NETWIB_ERR_NOTCONVERTED || ret == NETWIB_ERR_DATAMISSING) {
439 netwib_er(netwib_pkt_data_show(&pkt, pctxtouse, dataencodetype, pbuf));
440 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
441 return(NETWIB_ERR_OK);
442 } else if (ret != NETWIB_ERR_OK) {
443 return(ret);
444 }
445
446 netwib_er(netwib_buf_encode_transition(pctxtouse, hdrencodetype, pbuf));
447 netwib_er(netwib_icmp4_show(&icmp4, hdrencodetype, pbuf));
448 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
449
450 return(NETWIB_ERR_OK);
451 }
452
453 /*-------------------------------------------------------------*/
netwib_pkt_icmp4_display(netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype hdrencodetype,netwib_encodetype dataencodetype)454 netwib_err netwib_pkt_icmp4_display(netwib_constbuf *ppkt,
455 netwib_encodetype_context *pctx,
456 netwib_encodetype hdrencodetype,
457 netwib_encodetype dataencodetype)
458 {
459 netwib_err ret;
460 netwib_string pc;
461 netwib_buf buf;
462
463 netwib_er(netwib_buf_init_mallocdefault(&buf));
464 ret = netwib_pkt_icmp4_show(ppkt, pctx, hdrencodetype, dataencodetype, &buf);
465 if (ret == NETWIB_ERR_OK) {
466 netwib_er(netwib_buf_ref_string(&buf, &pc));
467 fprintf(stdout, "%s", pc);
468 fflush(stdout);
469 }
470 netwib_er(netwib_buf_close(&buf));
471
472 return(ret);
473 }
474
475 /*-------------------------------------------------------------*/
netwib_pkt_icmp6_show(netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype hdrencodetype,netwib_encodetype dataencodetype,netwib_buf * pbuf)476 netwib_err netwib_pkt_icmp6_show(netwib_constbuf *ppkt,
477 netwib_encodetype_context *pctx,
478 netwib_encodetype hdrencodetype,
479 netwib_encodetype dataencodetype,
480 netwib_buf *pbuf)
481 {
482 netwib_icmp6 icmp6;
483 netwib_buf pkt;
484 netwib_encodetype_context *pctxtouse, ctx;
485 netwib_err ret;
486
487 pctxtouse = pctx;
488 if (pctx == NULL) {
489 netwib_er(netwib_buf_encode_transition_init(&ctx));
490 pctxtouse = &ctx;
491 }
492
493 pkt = *ppkt;
494 ret = netwib_pkt_decode_layer_icmp6(&pkt, &icmp6);
495 if (ret == NETWIB_ERR_NOTCONVERTED || ret == NETWIB_ERR_DATAMISSING) {
496 netwib_er(netwib_pkt_data_show(&pkt, pctxtouse, dataencodetype, pbuf));
497 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
498 return(NETWIB_ERR_OK);
499 } else if (ret != NETWIB_ERR_OK) {
500 return(ret);
501 }
502
503 netwib_er(netwib_buf_encode_transition(pctxtouse, hdrencodetype, pbuf));
504 netwib_er(netwib_icmp6_show(&icmp6, hdrencodetype, pbuf));
505 netwib_er(netwib_buf_encode_transition_end(pctxtouse, pbuf));
506
507 return(NETWIB_ERR_OK);
508 }
509
510 /*-------------------------------------------------------------*/
netwib_pkt_icmp6_display(netwib_constbuf * ppkt,netwib_encodetype_context * pctx,netwib_encodetype hdrencodetype,netwib_encodetype dataencodetype)511 netwib_err netwib_pkt_icmp6_display(netwib_constbuf *ppkt,
512 netwib_encodetype_context *pctx,
513 netwib_encodetype hdrencodetype,
514 netwib_encodetype dataencodetype)
515 {
516 netwib_err ret;
517 netwib_string pc;
518 netwib_buf buf;
519
520 netwib_er(netwib_buf_init_mallocdefault(&buf));
521 ret = netwib_pkt_icmp6_show(ppkt, pctx, hdrencodetype, dataencodetype, &buf);
522 if (ret == NETWIB_ERR_OK) {
523 netwib_er(netwib_buf_ref_string(&buf, &pc));
524 fprintf(stdout, "%s", pc);
525 fflush(stdout);
526 }
527 netwib_er(netwib_buf_close(&buf));
528
529 return(ret);
530 }
531
532
533