4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <sys/socket.h>
32 #include <netinet/in.h>
33 #include <protocols/routed.h>
35 #include <arpa/inet.h>
37 #include "snoop_mip.h"
40 * This defines the length of internal, unbounded buffers. We set
41 * this to be MAXLINE (the maximum verbose display line length) -
42 * 64, which should be enough for all necessary descriptions.
44 #define BUFLEN MAXLINE - 64
46 extern char *dlc_header
;
47 extern char *addrtoname();
49 enum EXT_TYPE
{ ADV
, REG
};
52 * This defines the interface for all extention interpreter
53 * functions. The function will be called with following
56 * type: IN The type code for this extention
57 * len IN The length of the payload (i.e. the
58 * length field in an extension header)
59 * payload IN A pointer to the beginning of the
62 typedef void interpreter_f(uint8_t type
, uint8_t len
, uchar_t
*payload
);
69 /* Description structure -- maps type to description */
76 * Interpreter function prototypes for both adv and reg. These
77 * all must implement the interpret_f interface defined above.
79 static void spi_ext(uint8_t, uint8_t, uchar_t
*);
80 static void key_ext(uint8_t, uint8_t, uchar_t
*);
81 static void trav_ext(uint8_t, uint8_t, uchar_t
*);
82 static void empty_ext(uint8_t, uint8_t, uchar_t
*);
83 static void nai_ext(uint8_t, uint8_t, uchar_t
*);
84 static void chall_ext(uint8_t, uint8_t, uchar_t
*);
85 static void ma_ext(uint8_t, uint8_t, uchar_t
*);
86 static void prefix_ext(uint8_t, uint8_t, uchar_t
*);
87 static void unk_ext(uint8_t, uint8_t, uchar_t
*);
89 /* R E G I S T R A T I O N */
91 #define REG_TBL_LEN 10 /* update this when adding to the table */
93 /* Reg: type to description mapping table */
94 static struct ext_desc reg_desc
[] = {
95 MN_HA_AUTH
, "(Mobile-Home Authentication Extension)",
96 MN_FA_AUTH
, "(Mobile-Foreign Authentication Extension",
97 FA_HA_AUTH
, "(Foreign-Home Authentication Extension)",
98 GEN_AUTH
, "(Generalized Authentication Extension)",
99 MN_HA_KEY
, "(Mobile-Home Key Extension)",
100 MN_FA_KEY
, "(Mobile-Foreign Key Extension)",
101 MN_HA_TRAVERSE
, "(Firewall Traversal Extension)",
102 ENCAP_DELIV
, "(Encapsulating Delivery Style Extension)",
103 MN_NAI
, "(Mobile Node Network Access Identifier)",
104 FA_CHALLENGE
, "(Mobile-Foreign Agent Challenge)",
105 0, "(Unrecognized Extension)"
108 #define GENAUTH_TBL_LEN 1 /* update this when adding to the table */
110 /* Subtypes for Generic Authentication Extension type (type 36) */
111 static struct ext_desc genauth_desc
[] = {
112 GEN_AUTH_MN_AAA
, "(MN-AAA Authentication Subtype)",
113 0, "(Unrecognized Subtype)"
116 /* Reg: type to function mapping table */
117 static struct ext_dispatch reg_dispatch
[] = {
124 MN_HA_TRAVERSE
, trav_ext
,
125 ENCAP_DELIV
, empty_ext
,
127 FA_CHALLENGE
, chall_ext
,
131 /* A D V E R T I S E M E N T */
133 #define ADV_TBL_LEN 5 /* update this when adding to the table */
135 /* Adv: type to description mapping table */
136 static struct ext_desc adv_desc
[] = {
137 ICMP_ADV_MSG_PADDING_EXT
, "(Padding)",
138 ICMP_ADV_MSG_MOBILITY_AGT_EXT
, "(Mobility Agent Extension)",
139 ICMP_ADV_MSG_PREFIX_LENGTH_EXT
, "(Prefix Lengths)",
140 ICMP_ADV_MSG_FA_CHALLENGE
, "(Foreign Agent Challenge)",
141 ICMP_ADV_MSG_FA_NAI
, "(Foreign Agent NAI)",
142 0, "(Unrecognized Extension)"
145 /* Adv: type to function mapping table */
146 static struct ext_dispatch adv_dispatch
[] = {
147 ICMP_ADV_MSG_PADDING_EXT
, NULL
, /* never called */
148 ICMP_ADV_MSG_MOBILITY_AGT_EXT
, ma_ext
,
149 ICMP_ADV_MSG_PREFIX_LENGTH_EXT
, prefix_ext
,
150 ICMP_ADV_MSG_FA_CHALLENGE
, chall_ext
,
151 ICMP_ADV_MSG_FA_NAI
, nai_ext
,
155 #define GETSPI(payload, hi, low) \
156 (void) memcpy(&hi, payload, sizeof (hi)); \
157 (void) memcpy(&low, payload + sizeof (hi), sizeof (low))
159 static void dumphex(uchar_t
*payload
, int payload_len
, char *buf
, char *msg
) {
162 for (index
= 0; index
< payload_len
; index
++) {
163 (void) sprintf(&buf
[index
* 3], " %.2x", payload
[index
]);
166 (void) sprintf(get_line((char *)payload
-dlc_header
, 1), msg
, buf
);
169 static const char *get_desc(struct ext_desc table
[], uint8_t type
, int max
) {
172 for (i
= 0; i
< max
&& table
[i
].type
!= type
; i
++)
175 return (table
[i
].desc
);
179 * The following is an accessor for the description table, used by
180 * snoop_icmp.c. This maintains the encapsulation of the internal
183 const char *get_mip_adv_desc(uint8_t type
) {
184 return (get_desc(adv_desc
, type
, ADV_TBL_LEN
));
187 static interpreter_f
*get_interpreter(struct ext_dispatch table
[],
192 for (i
= 0; i
< max
&& table
[i
].type
!= type
; i
++)
195 return (table
[i
].pfunc
);
199 interpret_extensions(uchar_t
*ext
,
201 enum EXT_TYPE etype
) {
203 int curr_size
= regext_size
; /* remaining total for all exts */
205 gen_exthdr_t
*gen_exthdr
;
214 exthdr
= (exthdr_t
*)ALIGN(ext
);
218 ext_type
= exthdr
->type
;
219 if (ext_type
== GEN_AUTH
) {
220 gen_exthdr
= (gen_exthdr_t
*)exthdr
;
221 ext_hdrlen
= sizeof (gen_exthdr_t
);
222 ext_len
= ntohs(gen_exthdr
->length
);
224 ext_hdrlen
= sizeof (exthdr_t
);
225 ext_len
= exthdr
->length
;
228 if (!((etype
== ADV
&& ext_type
== ICMP_ADV_MSG_PADDING_EXT
&&
230 curr_size
>= ext_hdrlen
+ ext_len
))
233 /* Print description for this extension */
235 st
= get_desc(adv_desc
, ext_type
, ADV_TBL_LEN
);
237 st
= get_desc(reg_desc
, ext_type
, REG_TBL_LEN
);
240 (void) sprintf(get_line((char *)exthdr
-dlc_header
, 1),
241 "Extension header type = %d %s", ext_type
, st
);
243 if (ext_type
== GEN_AUTH
) {
244 st
= get_desc(genauth_desc
, gen_exthdr
->subtype
,
246 (void) sprintf(get_line((char *)exthdr
-dlc_header
, 1),
247 "Subtype = %d %s", gen_exthdr
->subtype
, st
);
250 /* Special case for 1-byte padding */
251 if (etype
== ADV
&& ext_type
== ICMP_ADV_MSG_PADDING_EXT
) {
252 exthdr
= (exthdr_t
*)((uchar_t
*)exthdr
+ 1);
257 (void) sprintf(get_line((char *)&exthdr
->length
-dlc_header
, 1),
258 "Length = %d", ext_len
);
260 /* Parse out the extension's payload */
261 p
= (uchar_t
*)exthdr
+ ext_hdrlen
;
262 curr_size
-= (ext_hdrlen
+ ext_len
);
265 f
= get_interpreter(adv_dispatch
, ext_type
, ADV_TBL_LEN
);
267 f
= get_interpreter(reg_dispatch
, ext_type
, REG_TBL_LEN
);
270 f(ext_type
, ext_len
, p
);
273 exthdr
= (exthdr_t
*)(p
+ ext_len
);
279 void interpret_icmp_mip_ext(uchar_t
*p
, int len
) {
281 show_header("ICMP: ", " MIP Advertisement Extensions ", len
);
284 interpret_extensions(p
, len
, ADV
);
288 interpret_mip_cntrlmsg(int flags
, uchar_t
*msg
, int fraglen
) {
289 char *pt
, *pc
= NULL
;
294 uchar_t
*regext_data
;
295 struct in_addr addr_temp
;
298 /* First byte of the message should be the type */
301 if (fraglen
< sizeof (regreq_t
))
303 pt
= (flags
& F_DTAIL
? "registration request ":"reg rqst ");
305 (void) memcpy(rreq
, msg
, sizeof (*rreq
));
306 regext_size
= fraglen
- sizeof (regreq_t
);
307 regext_data
= msg
+ sizeof (*rreq
);
310 if (fraglen
< sizeof (regrep_t
))
312 pt
= (flags
& F_DTAIL
? "registration reply ":"reg reply ");
314 (void) memcpy(rrep
, msg
, sizeof (*rrep
));
315 regext_size
= fraglen
- sizeof (regrep_t
);
316 regext_data
= msg
+ sizeof (*rrep
);
318 switch (rrep
->code
) {
320 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
)) ?
323 case REPLY_CODE_ACK_NO_SIMULTANEOUS
:
324 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
325 "OK simultaneous bindings" : "OK code 1";
327 case REPLY_CODE_FA_NACK_UNSPECIFIED
:
328 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
329 "FA denial: unspecified":"FA denial: code 64";
331 case REPLY_CODE_FA_NACK_PROHIBITED
:
332 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
333 "FA denial: prohibited":"FA denial: code 65";
335 case REPLY_CODE_FA_NACK_RESOURCES
:
336 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
337 "FA denial: no resources":"FA denial: code 66";
339 case REPLY_CODE_FA_NACK_MN_AUTH
:
340 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
341 "FA denial: MN auth failed":"FA denial: code 67";
343 case REPLY_CODE_FA_NACK_HA_AUTH
:
344 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
345 "FA denial: HA auth failed":
346 "FA denial: code 68";
348 case REPLY_CODE_FA_NACK_LIFETIME
:
349 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
350 "FA denial: lifetime":"FA denial: code 69";
352 case REPLY_CODE_FA_NACK_BAD_REQUEST
:
353 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
354 "FA denial: bad request": "FA: code 70";
356 case REPLY_CODE_FA_NACK_BAD_REPLY
:
357 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
358 "FA denial: bad Reply":"FA denial: code 71";
360 case REPLY_CODE_FA_NACK_ENCAP_UNAVAILABLE
:
361 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
362 "FA denial: encapsulation":"FA denial: code 72";
364 case REPLY_CODE_FA_NACK_VJ_UNAVAILABLE
:
365 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
366 "FA denial: VJ compression":"FA denial: code 73";
368 case REPLY_CODE_FA_NACK_BIDIR_TUNNEL_UNAVAILABLE
:
369 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
370 "FA denial: reverse tunnel unavailable":
371 "FA denial: code 74";
373 case REPLY_CODE_FA_NACK_BIDIR_TUNNEL_NO_TBIT
:
374 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
375 "FA denial: reverse tunnel: missing T-bit":
376 "FA denial: code 75";
378 case REPLY_CODE_FA_NACK_BIDIR_TUNNEL_TOO_DISTANT
:
379 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
380 "FA denial: reverse tunnel: too distant":
381 "FA denial: code 76";
383 case REPLY_CODE_FA_NACK_ICMP_HA_NET_UNREACHABLE
:
384 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
385 "FA denial: home network unreachable":
386 "FA denial: code 80";
388 case REPLY_CODE_FA_NACK_ICMP_HA_HOST_UNREACHABLE
:
389 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
390 "FA denial: HA host unreachable":
391 "FA denial: code 81";
393 case REPLY_CODE_FA_NACK_ICMP_HA_PORT_UNREACHABLE
:
394 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
395 "FA denial: HA port unreachable":
396 "FA denial: code 82";
398 case REPLY_CODE_FA_NACK_ICMP_HA_UNREACHABLE
:
399 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
400 "FA denial: HA unreachable":"FA denial: code 88";
402 case REPLY_CODE_FA_NACK_UNIQUE_HOMEADDR_REQD
:
403 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
404 "FA denial: Unique Home Addr Required":
405 "FA denial: code 96";
407 case REPLY_CODE_FA_NACK_MISSING_NAI
:
408 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
409 "FA denial: Missing NAI":
410 "FA denial: code 97";
412 case REPLY_CODE_FA_NACK_MISSING_HOME_AGENT
:
413 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
414 "FA denial: Missing Home Agent":
415 "FA denial: code 98";
417 case REPLY_CODE_FA_NACK_UNKNOWN_CHALLENGE
:
418 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
419 "FA denial: Unknown Challenge":
420 "FA denial: code 104";
422 case REPLY_CODE_FA_NACK_MISSING_CHALLENGE
:
423 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
424 "FA denial: Missing Challenge":
425 "FA denial: code 105";
427 case REPLY_CODE_FA_NACK_MISSING_MN_FA
:
428 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
429 "FA denial: Missing Mobile-Foreign Key Extension":
430 "FA denial: code 106";
432 case REPLY_CODE_HA_NACK_UNSPECIFIED
:
433 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
434 "HA denial: unspecified":"HA denial: code 128";
436 case REPLY_CODE_HA_NACK_PROHIBITED
:
437 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
438 "HA denial: prohibited":"HA denial: code 129";
440 case REPLY_CODE_HA_NACK_RESOURCES
:
441 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
442 "HA denial: no resources":"HA denial: code 130";
444 case REPLY_CODE_HA_NACK_MN_AUTH
:
445 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
446 "HA denial: MN auth failed":"HA denial: code 131";
448 case REPLY_CODE_HA_NACK_FA_AUTH
:
449 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
450 "HA denial: FA auth failed":"HA denial: code 132";
452 case REPLY_CODE_HA_NACK_ID_MISMATCH
:
453 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
454 "HA denial: ID mismatch":"HA denial: code 133";
456 case REPLY_CODE_HA_NACK_BAD_REQUEST
:
457 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
458 "HA denial: bad request":"HA denial: code 134";
460 case REPLY_CODE_HA_NACK_TOO_MANY_BINDINGS
:
461 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
462 "HA denial: too many bindings":
463 "HA denial: code 135";
465 case REPLY_CODE_HA_NACK_BAD_HA_ADDRESS
:
466 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
467 "HA denial: bad HA address":"HA denial: code 136";
469 case REPLY_CODE_HA_NACK_BIDIR_TUNNEL_UNAVAILABLE
:
470 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
471 "HA denial: no reverse tunnel":
472 "HA denial: code 137";
474 case REPLY_CODE_HA_NACK_BIDIR_TUNNEL_NO_TBIT
:
475 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
476 "HA denial: reverse tunnel: no T-bit":
477 "HA denial: code 138";
479 case REPLY_CODE_HA_NACK_BIDIR_ENCAP_UNAVAILABLE
:
480 pc
= ((flags
& F_ALLSUM
) || (flags
& F_DTAIL
))?
481 "HA denial: encapsulation unavailable":
482 "HA denial: code 139";
494 line
= get_sum_line();
497 (void) sprintf(line
, "Mobile IP %s(%s)", pt
, pc
);
499 (void) sprintf(line
, "Mobile IP %s", pt
);
502 if (flags
& F_DTAIL
) {
503 show_header("MIP: ", "Mobile IP Header", fraglen
);
506 if (*msg
== REG_TYPE_REQ
) {
507 (void) sprintf(get_line((char *)&rreq
-
508 dlc_header
, 1), "Registration header type = %s",
510 (void) sprintf(get_line(
511 (char *)(((uchar_t
*)&rreq
) + 1) - dlc_header
, 1),
512 "%d... .... = %s simultaneous bindings ",
513 (rreq
->Simultaneous_registration
== 1)? 1 : 0,
514 (rreq
->Simultaneous_registration
== 1)? "":"no");
515 (void) sprintf(get_line(
516 (char *)(((uchar_t
*)&rreq
) + 1) - dlc_header
, 1),
517 ".%d.. .... = %s broadcast datagrams ",
518 (rreq
->Broadcasts_desired
== 1) ? 1 : 0,
519 (rreq
->Broadcasts_desired
== 1) ? "":"no");
520 (void) sprintf(get_line(
521 (char *)(((uchar_t
*)&rreq
) + 1) - dlc_header
, 1),
522 "..%d. .... = %s decapsulation by MN",
523 (rreq
->Decapsulation_done_locally
== 1) ? 1 : 0,
524 (rreq
->Decapsulation_done_locally
== 1) ?
526 (void) sprintf(get_line(
527 (char *)(((uchar_t
*)&rreq
) + 1) - dlc_header
, 1),
528 "...%d .... = %s minimum encapsulation ",
529 (rreq
->Minimal_encap_desired
== 1) ? 1 : 0,
530 (rreq
->Minimal_encap_desired
== 1) ? "" : "no");
531 (void) sprintf(get_line(
532 (char *)(((uchar_t
*)&rreq
) + 1) - dlc_header
, 1),
533 ".... %d... = %s GRE encapsulation ",
534 (rreq
->GRE_encap_desired
== 1) ? 1 : 0,
535 (rreq
->GRE_encap_desired
== 1) ? "" : "no");
536 (void) sprintf(get_line(
537 (char *)(((uchar_t
*)&rreq
) + 1) - dlc_header
, 1),
538 ".... .%d.. = %s VJ hdr Compression ",
539 (rreq
->VJ_compression_desired
== 1) ? 1 : 0,
540 (rreq
->VJ_compression_desired
== 1) ? "" : "no");
541 (void) sprintf(get_line(
542 (char *)(((uchar_t
*)&rreq
) + 1) - dlc_header
, 1),
543 ".... ..%d. = %s reverse tunnel",
544 (rreq
->BiDirectional_Tunnel_desired
== 1) ? 1 : 0,
545 (rreq
->BiDirectional_Tunnel_desired
== 1) ?
547 if (ntohs(rreq
->lifetime
) == 0xffff) {
548 (void) sprintf(get_line(
549 (char *)&rreq
->lifetime
- dlc_header
, 1),
550 "Life Time = 0xFFFF (infinity)");
551 } else if (ntohs(rreq
->lifetime
) == 0) {
552 (void) sprintf(get_line(
553 (char *)&rreq
->lifetime
- dlc_header
, 1),
555 "(request for de-registration)");
557 (void) sprintf(get_line(
558 (char *)&rreq
->lifetime
- dlc_header
, 1),
559 "Life time = %d seconds",
560 ntohs(rreq
->lifetime
));
562 addr_temp
.s_addr
= rreq
->home_addr
;
563 (void) sprintf(get_line(
564 (char *)&rreq
->home_addr
- dlc_header
, 1),
565 "Home address = %s, %s",
566 inet_ntoa(addr_temp
),
567 addrtoname(AF_INET
, &addr_temp
));
568 addr_temp
.s_addr
= rreq
->home_agent_addr
;
569 (void) sprintf(get_line(
570 (char *)&rreq
->home_agent_addr
- dlc_header
, 1),
571 "Home Agent address = %s, %s",
572 inet_ntoa(addr_temp
),
573 addrtoname(AF_INET
, &addr_temp
));
574 addr_temp
.s_addr
= rreq
->care_of_addr
;
575 (void) sprintf(get_line(
576 (char *)&rreq
->care_of_addr
- dlc_header
, 1),
577 "Care of address = %s, %s",
578 inet_ntoa(addr_temp
),
579 addrtoname(AF_INET
, &addr_temp
));
580 (void) sprintf(get_line(
581 (char *)&rreq
->identification
- dlc_header
, 1),
582 "Identification = 0x%x-%x",
583 ntohl(rreq
->identification
.high_bits
),
584 ntohl(rreq
->identification
.low_bits
));
585 } else if (*msg
== REG_TYPE_REP
) {
587 get_line((char *)&rrep
->type
- dlc_header
, 1),
588 "Registration header type = %d (%s)",
589 (int)rrep
->type
, pt
);
590 (void) sprintf(get_line((char *)&rrep
- dlc_header
, 1),
591 "Code = %d %s", (int)rrep
->code
, pc
);
592 if (ntohs(rrep
->lifetime
) == 0xffff) {
593 (void) sprintf(get_line(
594 (char *)&rrep
->lifetime
- dlc_header
, 1),
595 "Life time = 0xFFFF (infinity)");
596 } else if (ntohs(rrep
->lifetime
) == 0) {
597 (void) sprintf(get_line(
598 (char *)&rrep
->lifetime
- dlc_header
, 1),
599 ((rrep
->code
== REPLY_CODE_ACK
) ||
601 REPLY_CODE_ACK_NO_SIMULTANEOUS
))?
602 "Life time = 0 (de-registeration success)" :
603 "Life time = 0 (de-registration failed)");
605 (void) sprintf(get_line(
606 (char *)&rrep
->lifetime
- dlc_header
, 1),
607 "Life time = %d seconds",
608 ntohs(rrep
->lifetime
));
610 addr_temp
.s_addr
= rrep
->home_addr
;
612 get_line((char *)&rrep
->home_addr
- dlc_header
, 1),
613 "Home address = %s, %s",
614 inet_ntoa(addr_temp
),
615 addrtoname(AF_INET
, &addr_temp
));
616 addr_temp
.s_addr
= rrep
->home_agent_addr
;
617 (void) sprintf(get_line(
618 (char *)&rrep
->home_agent_addr
- dlc_header
, 1),
619 "Home Agent address = %s, %s",
620 inet_ntoa(addr_temp
),
621 addrtoname(AF_INET
, &addr_temp
));
622 (void) sprintf(get_line(
623 (char *)&rrep
->identification
- dlc_header
, 1),
624 "Identification = 0x%x-%x",
625 ntohl(rrep
->identification
.high_bits
),
626 ntohl(rrep
->identification
.low_bits
));
628 fraglen
= interpret_extensions(regext_data
, regext_size
, REG
);
633 static void spi_ext(uint8_t type
, uint8_t this_ext_len
, uchar_t
*p
) {
634 uint16_t spi_hi
, spi_low
;
635 char auth_prn_str
[BUFLEN
];
638 GETSPI(p
, spi_hi
, spi_low
);
639 (void) sprintf(get_line((char *)p
- dlc_header
, 1),
640 "Security Parameter Index = 0x%x%x",
641 ntohs(spi_hi
), ntohs(spi_low
));
642 p
+= sizeof (spi_hi
) + sizeof (spi_low
);
643 this_ext_len
-= sizeof (spi_hi
) + sizeof (spi_low
);
645 /* The rest is the authenticator; dump it in hex */
647 /* don't write past our string buffer ... */
648 (this_ext_len
*3 > BUFLEN
? BUFLEN
: this_ext_len
),
650 "Authenticator = %s");
653 static void key_ext(uint8_t type
, uint8_t this_ext_len
, uchar_t
*p
) {
654 uint16_t alg
, spi_hi
, spi_low
;
656 char *hafa
= (type
== MN_HA_KEY
? "HA" : "FA");
658 char auth_prn_str
[BUFLEN
];
661 (void) memcpy(&alg
, p
, sizeof (alg
));
667 case SA_MD5_MODE_PREF_SUF
:
668 alg_string
= "MD5/prefix+suffix";
671 alg_string
= "HMAC MD5";
674 alg_string
= "Unknown";
677 (void) sprintf(get_line((char *)p
-dlc_header
, 1),
678 "Algorithm = 0x%x: %s", alg
, alg_string
);
680 this_ext_len
-= sizeof (alg
);
683 GETSPI(p
, spi_hi
, spi_low
);
684 (void) sprintf(get_line((char *)p
- dlc_header
, 1),
685 "AAA Security Parameter Index = 0x%x%x",
686 ntohs(spi_hi
), ntohs(spi_low
));
687 p
+= sizeof (spi_hi
) + sizeof (spi_low
);
688 this_ext_len
-= sizeof (spi_hi
) + sizeof (spi_low
);
691 GETSPI(p
, spi_hi
, spi_low
);
692 (void) sprintf(get_line((char *)p
- dlc_header
, 1),
693 "%s Security Parameter Index = 0x%x%x",
694 hafa
, ntohs(spi_hi
), ntohs(spi_low
));
695 p
+= sizeof (spi_hi
) + sizeof (spi_low
);
696 this_ext_len
-= sizeof (spi_hi
) + sizeof (spi_low
);
698 /* The rest is the security info; dump it in hex */
699 sprintf(sec_msg
, "%s Security Info = %%s", hafa
);
701 /* don't write past our string buffer ... */
702 (this_ext_len
*3 > BUFLEN
? BUFLEN
: this_ext_len
),
708 static void trav_ext(uint8_t type
, uint8_t this_ext_len
, uchar_t
*p
) {
709 struct in_addr addr_temp
;
715 /* Mobile-Home Traversal Address */
716 (void) memcpy(&(addr_temp
.s_addr
), p
, sizeof (addr_temp
.s_addr
));
717 (void) sprintf(get_line((char *)p
-dlc_header
, 1),
718 "Mobile-Home Traversal Address= %s, %s",
719 inet_ntoa(addr_temp
),
720 addrtoname(AF_INET
, &addr_temp
));
721 p
+= sizeof (addr_temp
.s_addr
);
722 this_ext_len
-= sizeof (addr_temp
.s_addr
);
724 /* Home-Mobile Traversal Address */
725 (void) memcpy(&(addr_temp
.s_addr
), p
, sizeof (addr_temp
.s_addr
));
726 (void) sprintf(get_line((char *)p
-dlc_header
, 1),
727 "Home-Mobile Traversal Address= %s, %s",
728 inet_ntoa(addr_temp
),
729 addrtoname(AF_INET
, &addr_temp
));
733 static void empty_ext(uint8_t type
, uint8_t this_ext_len
, uchar_t
*p
) {
738 static void nai_ext(uint8_t type
, uint8_t this_ext_len
, uchar_t
*p
) {
739 /* payload points to the NAI */
740 char *desc
= "Network Access Identifier = ";
741 size_t desclen
= strlen(desc
) + 1 + this_ext_len
;
743 (void) snprintf(get_line((char *)p
-dlc_header
, 1),
744 desclen
> MAXLINE
? MAXLINE
: desclen
,
749 static void chall_ext(uint8_t type
, uint8_t this_ext_len
, uchar_t
*p
) {
750 char auth_prn_str
[BUFLEN
];
752 /* payload points to the challenge */
754 /* don't write past our string buffer ... */
755 (this_ext_len
*3 > BUFLEN
? BUFLEN
/ 3 : this_ext_len
),
761 static void ma_ext(uint8_t type
, uint8_t this_ext_len
, uchar_t
*p
) {
762 mobagtadvext_t adv_ext
[1];
764 struct in_addr temp_addr
;
766 (void) memcpy(adv_ext
, p
- sizeof (exthdr_t
), sizeof (*adv_ext
));
767 (void) sprintf(get_line(0, 0), "Sequence number = %d",
768 ntohs(adv_ext
->sequence_num
));
769 (void) sprintf(get_line(0, 0),
770 "Registration lifetime = %d seconds",
771 ntohs(adv_ext
->reg_lifetime
));
772 if (adv_ext
->reg_bit
) {
773 (void) sprintf(get_line(0, 0),
774 "1... .... = registration required "
777 (void) sprintf(get_line(0, 0),
778 "0... .... = registration not required "
781 if (adv_ext
->busy_bit
) {
782 (void) sprintf(get_line(0, 0), ".1.. .... = FA busy");
784 (void) sprintf(get_line(0, 0), ".0.. .... = FA not busy");
786 if (adv_ext
->ha_bit
) {
787 (void) sprintf(get_line(0, 0), "..1. .... = node is HA");
789 (void) sprintf(get_line(0, 0), "..0. .... = node not HA");
791 if (adv_ext
->fa_bit
) {
792 (void) sprintf(get_line(0, 0), "...1 .... = node is FA ");
794 (void) sprintf(get_line(0, 0), "...0 .... = node not FA ");
796 if (adv_ext
->minencap_bit
) {
797 (void) sprintf(get_line(0, 0), ".... 1... = minimal encapsulation "
800 (void) sprintf(get_line(0, 0),
801 ".... 0... = no minimal encapsulation");
803 if (adv_ext
->greencap_bit
) {
804 (void) sprintf(get_line(0, 0),
805 ".... .1.. = GRE encapsulation supported");
807 (void) sprintf(get_line(0, 0),
808 ".... .0.. = no GRE encapsulation");
810 if (adv_ext
->vanjacob_hdr_comp_bit
) {
811 (void) sprintf(get_line(0, 0),
812 ".... ..1. = VJ header compression");
814 (void) sprintf(get_line(0, 0),
815 ".... ..0. = no VJ header compression");
817 if (adv_ext
->reverse_tunnel_bit
) {
818 (void) sprintf(get_line(0, 0),
819 ".... ...1 = reverse tunneling supported");
821 (void) sprintf(get_line(0, 0),
822 ".... ...0 = no reverse tunneling");
824 (void) sprintf(get_line(0, 0),
825 "Reserved Byte = 0x%x", adv_ext
->reserved
);
827 /* Parse out COA's */
828 p
+= sizeof (*adv_ext
);
829 len
= this_ext_len
+ sizeof (exthdr_t
);
830 /* this_ext_len is unsigned, and here we need a signed number */
831 len
-= sizeof (*adv_ext
);
833 for (i
= 0; len
>= sizeof (temp_addr
.s_addr
); i
++) {
834 memcpy(&(temp_addr
.s_addr
), p
- sizeof (exthdr_t
),
835 sizeof (temp_addr
.s_addr
));
837 (void) sprintf(get_line(0, 0),
838 "Care of address-%d = %s, %s", i
,
839 inet_ntoa(temp_addr
),
840 addrtoname(AF_INET
, &temp_addr
));
842 p
+= sizeof (temp_addr
);
843 len
-= sizeof (temp_addr
);
848 static void prefix_ext(uint8_t type
, uint8_t this_ext_len
, uchar_t
*p
) {
851 for (i
= 0; i
< this_ext_len
; i
++) {
852 (void) sprintf(get_line(0, 0),
853 "Prefix length of router address[%d] "
860 static void unk_ext(uint8_t type
, uint8_t this_ext_len
, uchar_t
*p
) {
861 char auth_prn_str
[BUFLEN
];
863 /* Unknown extension; just dump the rest of the payload */
865 /* don't write past our string buffer ... */
866 (this_ext_len
*3 > BUFLEN
? BUFLEN
: this_ext_len
),