10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
70Sstevel@tonic-gate * with the License.
80Sstevel@tonic-gate *
90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate * See the License for the specific language governing permissions
120Sstevel@tonic-gate * and limitations under the License.
130Sstevel@tonic-gate *
140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate *
200Sstevel@tonic-gate * CDDL HEADER END
210Sstevel@tonic-gate */
220Sstevel@tonic-gate /*
23*410Skcpoon * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24*410Skcpoon * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
280Sstevel@tonic-gate
290Sstevel@tonic-gate #include <stdio.h>
300Sstevel@tonic-gate #include <fcntl.h>
310Sstevel@tonic-gate #include <sys/socket.h>
320Sstevel@tonic-gate #include <netinet/in.h>
330Sstevel@tonic-gate #include <protocols/routed.h>
340Sstevel@tonic-gate #include <string.h>
350Sstevel@tonic-gate #include <arpa/inet.h>
360Sstevel@tonic-gate #include "snoop.h"
370Sstevel@tonic-gate #include "snoop_mip.h"
380Sstevel@tonic-gate
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate * This defines the length of internal, unbounded buffers. We set
410Sstevel@tonic-gate * this to be MAXLINE (the maximum verbose display line length) -
420Sstevel@tonic-gate * 64, which should be enough for all necessary descriptions.
430Sstevel@tonic-gate */
440Sstevel@tonic-gate #define BUFLEN MAXLINE - 64
450Sstevel@tonic-gate
460Sstevel@tonic-gate extern char *dlc_header;
470Sstevel@tonic-gate extern char *addrtoname();
480Sstevel@tonic-gate
49*410Skcpoon enum EXT_TYPE { ADV, REG };
500Sstevel@tonic-gate
510Sstevel@tonic-gate /*
520Sstevel@tonic-gate * This defines the interface for all extention interpreter
530Sstevel@tonic-gate * functions. The function will be called with following
540Sstevel@tonic-gate * parameters:
550Sstevel@tonic-gate *
560Sstevel@tonic-gate * type: IN The type code for this extention
570Sstevel@tonic-gate * len IN The length of the payload (i.e. the
580Sstevel@tonic-gate * length field in an extension header)
590Sstevel@tonic-gate * payload IN A pointer to the beginning of the
600Sstevel@tonic-gate * extension payload
610Sstevel@tonic-gate */
620Sstevel@tonic-gate typedef void interpreter_f(uint8_t type, uint8_t len, uchar_t *payload);
630Sstevel@tonic-gate
640Sstevel@tonic-gate struct ext_dispatch {
650Sstevel@tonic-gate uint8_t type;
660Sstevel@tonic-gate interpreter_f *pfunc;
670Sstevel@tonic-gate };
680Sstevel@tonic-gate
690Sstevel@tonic-gate /* Description structure -- maps type to description */
700Sstevel@tonic-gate struct ext_desc {
710Sstevel@tonic-gate uint8_t type;
720Sstevel@tonic-gate const char *desc;
730Sstevel@tonic-gate };
740Sstevel@tonic-gate
750Sstevel@tonic-gate /*
760Sstevel@tonic-gate * Interpreter function prototypes for both adv and reg. These
770Sstevel@tonic-gate * all must implement the interpret_f interface defined above.
780Sstevel@tonic-gate */
790Sstevel@tonic-gate static void spi_ext(uint8_t, uint8_t, uchar_t *);
800Sstevel@tonic-gate static void key_ext(uint8_t, uint8_t, uchar_t *);
810Sstevel@tonic-gate static void trav_ext(uint8_t, uint8_t, uchar_t *);
820Sstevel@tonic-gate static void empty_ext(uint8_t, uint8_t, uchar_t *);
830Sstevel@tonic-gate static void nai_ext(uint8_t, uint8_t, uchar_t *);
840Sstevel@tonic-gate static void chall_ext(uint8_t, uint8_t, uchar_t *);
850Sstevel@tonic-gate static void ma_ext(uint8_t, uint8_t, uchar_t *);
860Sstevel@tonic-gate static void prefix_ext(uint8_t, uint8_t, uchar_t *);
870Sstevel@tonic-gate static void unk_ext(uint8_t, uint8_t, uchar_t *);
880Sstevel@tonic-gate
890Sstevel@tonic-gate /* R E G I S T R A T I O N */
900Sstevel@tonic-gate
910Sstevel@tonic-gate #define REG_TBL_LEN 10 /* update this when adding to the table */
920Sstevel@tonic-gate
930Sstevel@tonic-gate /* Reg: type to description mapping table */
940Sstevel@tonic-gate static struct ext_desc reg_desc[] = {
950Sstevel@tonic-gate MN_HA_AUTH, "(Mobile-Home Authentication Extension)",
960Sstevel@tonic-gate MN_FA_AUTH, "(Mobile-Foreign Authentication Extension",
970Sstevel@tonic-gate FA_HA_AUTH, "(Foreign-Home Authentication Extension)",
980Sstevel@tonic-gate GEN_AUTH, "(Generalized Authentication Extension)",
990Sstevel@tonic-gate MN_HA_KEY, "(Mobile-Home Key Extension)",
1000Sstevel@tonic-gate MN_FA_KEY, "(Mobile-Foreign Key Extension)",
1010Sstevel@tonic-gate MN_HA_TRAVERSE, "(Firewall Traversal Extension)",
1020Sstevel@tonic-gate ENCAP_DELIV, "(Encapsulating Delivery Style Extension)",
1030Sstevel@tonic-gate MN_NAI, "(Mobile Node Network Access Identifier)",
1040Sstevel@tonic-gate FA_CHALLENGE, "(Mobile-Foreign Agent Challenge)",
1050Sstevel@tonic-gate 0, "(Unrecognized Extension)"
1060Sstevel@tonic-gate };
1070Sstevel@tonic-gate
1080Sstevel@tonic-gate #define GENAUTH_TBL_LEN 1 /* update this when adding to the table */
1090Sstevel@tonic-gate
1100Sstevel@tonic-gate /* Subtypes for Generic Authentication Extension type (type 36) */
1110Sstevel@tonic-gate static struct ext_desc genauth_desc[] = {
1120Sstevel@tonic-gate GEN_AUTH_MN_AAA, "(MN-AAA Authentication Subtype)",
1130Sstevel@tonic-gate 0, "(Unrecognized Subtype)"
1140Sstevel@tonic-gate };
1150Sstevel@tonic-gate
1160Sstevel@tonic-gate /* Reg: type to function mapping table */
1170Sstevel@tonic-gate static struct ext_dispatch reg_dispatch[] = {
1180Sstevel@tonic-gate MN_HA_AUTH, spi_ext,
1190Sstevel@tonic-gate MN_FA_AUTH, spi_ext,
1200Sstevel@tonic-gate FA_HA_AUTH, spi_ext,
1210Sstevel@tonic-gate GEN_AUTH, spi_ext,
1220Sstevel@tonic-gate MN_HA_KEY, key_ext,
1230Sstevel@tonic-gate MN_FA_KEY, key_ext,
1240Sstevel@tonic-gate MN_HA_TRAVERSE, trav_ext,
1250Sstevel@tonic-gate ENCAP_DELIV, empty_ext,
1260Sstevel@tonic-gate MN_NAI, nai_ext,
1270Sstevel@tonic-gate FA_CHALLENGE, chall_ext,
1280Sstevel@tonic-gate 0, unk_ext
1290Sstevel@tonic-gate };
1300Sstevel@tonic-gate
1310Sstevel@tonic-gate /* A D V E R T I S E M E N T */
1320Sstevel@tonic-gate
1330Sstevel@tonic-gate #define ADV_TBL_LEN 5 /* update this when adding to the table */
1340Sstevel@tonic-gate
1350Sstevel@tonic-gate /* Adv: type to description mapping table */
1360Sstevel@tonic-gate static struct ext_desc adv_desc[] = {
1370Sstevel@tonic-gate ICMP_ADV_MSG_PADDING_EXT, "(Padding)",
1380Sstevel@tonic-gate ICMP_ADV_MSG_MOBILITY_AGT_EXT, "(Mobility Agent Extension)",
1390Sstevel@tonic-gate ICMP_ADV_MSG_PREFIX_LENGTH_EXT, "(Prefix Lengths)",
1400Sstevel@tonic-gate ICMP_ADV_MSG_FA_CHALLENGE, "(Foreign Agent Challenge)",
1410Sstevel@tonic-gate ICMP_ADV_MSG_FA_NAI, "(Foreign Agent NAI)",
1420Sstevel@tonic-gate 0, "(Unrecognized Extension)"
1430Sstevel@tonic-gate };
1440Sstevel@tonic-gate
1450Sstevel@tonic-gate /* Adv: type to function mapping table */
1460Sstevel@tonic-gate static struct ext_dispatch adv_dispatch[] = {
1470Sstevel@tonic-gate ICMP_ADV_MSG_PADDING_EXT, NULL, /* never called */
1480Sstevel@tonic-gate ICMP_ADV_MSG_MOBILITY_AGT_EXT, ma_ext,
1490Sstevel@tonic-gate ICMP_ADV_MSG_PREFIX_LENGTH_EXT, prefix_ext,
1500Sstevel@tonic-gate ICMP_ADV_MSG_FA_CHALLENGE, chall_ext,
1510Sstevel@tonic-gate ICMP_ADV_MSG_FA_NAI, nai_ext,
1520Sstevel@tonic-gate 0, unk_ext
1530Sstevel@tonic-gate };
1540Sstevel@tonic-gate
1550Sstevel@tonic-gate #define GETSPI(payload, hi, low) \
1560Sstevel@tonic-gate (void) memcpy(&hi, payload, sizeof (hi)); \
1570Sstevel@tonic-gate (void) memcpy(&low, payload + sizeof (hi), sizeof (low))
1580Sstevel@tonic-gate
dumphex(uchar_t * payload,int payload_len,char * buf,char * msg)1590Sstevel@tonic-gate static void dumphex(uchar_t *payload, int payload_len, char *buf, char *msg) {
1600Sstevel@tonic-gate int index;
1610Sstevel@tonic-gate
1620Sstevel@tonic-gate for (index = 0; index < payload_len; index++) {
1630Sstevel@tonic-gate (void) sprintf(&buf[index * 3], " %.2x", payload[index]);
1640Sstevel@tonic-gate }
1650Sstevel@tonic-gate
1660Sstevel@tonic-gate (void) sprintf(get_line((char *)payload-dlc_header, 1), msg, buf);
1670Sstevel@tonic-gate }
1680Sstevel@tonic-gate
get_desc(struct ext_desc table[],uint8_t type,int max)1690Sstevel@tonic-gate static const char *get_desc(struct ext_desc table[], uint8_t type, int max) {
1700Sstevel@tonic-gate int i;
1710Sstevel@tonic-gate
1720Sstevel@tonic-gate for (i = 0; i < max && table[i].type != type; i++)
1730Sstevel@tonic-gate /* NO_OP */;
1740Sstevel@tonic-gate
1750Sstevel@tonic-gate return (table[i].desc);
1760Sstevel@tonic-gate }
1770Sstevel@tonic-gate
1780Sstevel@tonic-gate /*
1790Sstevel@tonic-gate * The following is an accessor for the description table, used by
1800Sstevel@tonic-gate * snoop_icmp.c. This maintains the encapsulation of the internal
1810Sstevel@tonic-gate * description table.
1820Sstevel@tonic-gate */
get_mip_adv_desc(uint8_t type)1830Sstevel@tonic-gate const char *get_mip_adv_desc(uint8_t type) {
1840Sstevel@tonic-gate return (get_desc(adv_desc, type, ADV_TBL_LEN));
1850Sstevel@tonic-gate }
1860Sstevel@tonic-gate
get_interpreter(struct ext_dispatch table[],uint8_t type,int max)1870Sstevel@tonic-gate static interpreter_f *get_interpreter(struct ext_dispatch table[],
1880Sstevel@tonic-gate uint8_t type,
1890Sstevel@tonic-gate int max) {
1900Sstevel@tonic-gate int i;
1910Sstevel@tonic-gate
1920Sstevel@tonic-gate for (i = 0; i < max && table[i].type != type; i++)
1930Sstevel@tonic-gate /* NO_OP */;
1940Sstevel@tonic-gate
1950Sstevel@tonic-gate return (table[i].pfunc);
1960Sstevel@tonic-gate }
1970Sstevel@tonic-gate
1980Sstevel@tonic-gate static int
interpret_extensions(uchar_t * ext,int regext_size,enum EXT_TYPE etype)1990Sstevel@tonic-gate interpret_extensions(uchar_t *ext,
2000Sstevel@tonic-gate int regext_size,
2010Sstevel@tonic-gate enum EXT_TYPE etype) {
2020Sstevel@tonic-gate
2030Sstevel@tonic-gate int curr_size = regext_size; /* remaining total for all exts */
2040Sstevel@tonic-gate exthdr_t *exthdr;
2050Sstevel@tonic-gate gen_exthdr_t *gen_exthdr;
2060Sstevel@tonic-gate const char *st;
2070Sstevel@tonic-gate uchar_t *p;
2080Sstevel@tonic-gate interpreter_f *f;
2090Sstevel@tonic-gate uint8_t ext_type;
2100Sstevel@tonic-gate uint16_t ext_len;
2110Sstevel@tonic-gate uint_t ext_hdrlen;
2120Sstevel@tonic-gate
2130Sstevel@tonic-gate show_space();
2140Sstevel@tonic-gate exthdr = (exthdr_t *)ALIGN(ext);
2150Sstevel@tonic-gate
2160Sstevel@tonic-gate
2170Sstevel@tonic-gate do {
2180Sstevel@tonic-gate ext_type = exthdr->type;
2190Sstevel@tonic-gate if (ext_type == GEN_AUTH) {
2200Sstevel@tonic-gate gen_exthdr = (gen_exthdr_t *)exthdr;
2210Sstevel@tonic-gate ext_hdrlen = sizeof (gen_exthdr_t);
2220Sstevel@tonic-gate ext_len = ntohs(gen_exthdr->length);
2230Sstevel@tonic-gate } else {
2240Sstevel@tonic-gate ext_hdrlen = sizeof (exthdr_t);
2250Sstevel@tonic-gate ext_len = exthdr->length;
2260Sstevel@tonic-gate }
2270Sstevel@tonic-gate
2280Sstevel@tonic-gate if (!((etype == ADV && ext_type == ICMP_ADV_MSG_PADDING_EXT &&
2290Sstevel@tonic-gate curr_size >= 1) ||
2300Sstevel@tonic-gate curr_size >= ext_hdrlen + ext_len))
2310Sstevel@tonic-gate break;
2320Sstevel@tonic-gate
2330Sstevel@tonic-gate /* Print description for this extension */
2340Sstevel@tonic-gate if (etype == ADV) {
2350Sstevel@tonic-gate st = get_desc(adv_desc, ext_type, ADV_TBL_LEN);
2360Sstevel@tonic-gate } else /* REG */ {
2370Sstevel@tonic-gate st = get_desc(reg_desc, ext_type, REG_TBL_LEN);
2380Sstevel@tonic-gate }
2390Sstevel@tonic-gate
2400Sstevel@tonic-gate (void) sprintf(get_line((char *)exthdr-dlc_header, 1),
2410Sstevel@tonic-gate "Extension header type = %d %s", ext_type, st);
2420Sstevel@tonic-gate
2430Sstevel@tonic-gate if (ext_type == GEN_AUTH) {
2440Sstevel@tonic-gate st = get_desc(genauth_desc, gen_exthdr->subtype,
2450Sstevel@tonic-gate GENAUTH_TBL_LEN);
2460Sstevel@tonic-gate (void) sprintf(get_line((char *)exthdr-dlc_header, 1),
2470Sstevel@tonic-gate "Subtype = %d %s", gen_exthdr->subtype, st);
2480Sstevel@tonic-gate }
2490Sstevel@tonic-gate
2500Sstevel@tonic-gate /* Special case for 1-byte padding */
2510Sstevel@tonic-gate if (etype == ADV && ext_type == ICMP_ADV_MSG_PADDING_EXT) {
2520Sstevel@tonic-gate exthdr = (exthdr_t *)((uchar_t *)exthdr + 1);
2530Sstevel@tonic-gate curr_size--;
2540Sstevel@tonic-gate continue;
2550Sstevel@tonic-gate }
2560Sstevel@tonic-gate
2570Sstevel@tonic-gate (void) sprintf(get_line((char *)&exthdr->length-dlc_header, 1),
2580Sstevel@tonic-gate "Length = %d", ext_len);
2590Sstevel@tonic-gate
2600Sstevel@tonic-gate /* Parse out the extension's payload */
2610Sstevel@tonic-gate p = (uchar_t *)exthdr + ext_hdrlen;
2620Sstevel@tonic-gate curr_size -= (ext_hdrlen + ext_len);
2630Sstevel@tonic-gate
2640Sstevel@tonic-gate if (etype == ADV) {
2650Sstevel@tonic-gate f = get_interpreter(adv_dispatch, ext_type, ADV_TBL_LEN);
2660Sstevel@tonic-gate } else /* REG */ {
2670Sstevel@tonic-gate f = get_interpreter(reg_dispatch, ext_type, REG_TBL_LEN);
2680Sstevel@tonic-gate }
2690Sstevel@tonic-gate
2700Sstevel@tonic-gate f(ext_type, ext_len, p);
2710Sstevel@tonic-gate
2720Sstevel@tonic-gate show_space();
2730Sstevel@tonic-gate exthdr = (exthdr_t *)(p + ext_len);
2740Sstevel@tonic-gate } while (B_TRUE);
2750Sstevel@tonic-gate
2760Sstevel@tonic-gate return (0);
2770Sstevel@tonic-gate }
2780Sstevel@tonic-gate
interpret_icmp_mip_ext(uchar_t * p,int len)2790Sstevel@tonic-gate void interpret_icmp_mip_ext(uchar_t *p, int len) {
2800Sstevel@tonic-gate show_space();
2810Sstevel@tonic-gate show_header("ICMP: ", " MIP Advertisement Extensions ", len);
2820Sstevel@tonic-gate show_space();
2830Sstevel@tonic-gate
2840Sstevel@tonic-gate interpret_extensions(p, len, ADV);
2850Sstevel@tonic-gate }
2860Sstevel@tonic-gate
2870Sstevel@tonic-gate void
interpret_mip_cntrlmsg(int flags,uchar_t * msg,int fraglen)2880Sstevel@tonic-gate interpret_mip_cntrlmsg(int flags, uchar_t *msg, int fraglen) {
2890Sstevel@tonic-gate char *pt, *pc = NULL;
2900Sstevel@tonic-gate char *line;
2910Sstevel@tonic-gate regreq_t rreq[1];
2920Sstevel@tonic-gate regrep_t rrep[1];
2930Sstevel@tonic-gate int regext_size;
2940Sstevel@tonic-gate uchar_t *regext_data;
2950Sstevel@tonic-gate struct in_addr addr_temp;
2960Sstevel@tonic-gate
2970Sstevel@tonic-gate
2980Sstevel@tonic-gate /* First byte of the message should be the type */
2990Sstevel@tonic-gate switch (*msg) {
3000Sstevel@tonic-gate case REG_TYPE_REQ:
3010Sstevel@tonic-gate if (fraglen < sizeof (regreq_t))
3020Sstevel@tonic-gate return;
3030Sstevel@tonic-gate pt = (flags & F_DTAIL ? "registration request ":"reg rqst ");
3040Sstevel@tonic-gate
3050Sstevel@tonic-gate (void) memcpy(rreq, msg, sizeof (*rreq));
3060Sstevel@tonic-gate regext_size = fraglen - sizeof (regreq_t);
3070Sstevel@tonic-gate regext_data = msg + sizeof (*rreq);
3080Sstevel@tonic-gate break;
3090Sstevel@tonic-gate case REG_TYPE_REP:
3100Sstevel@tonic-gate if (fraglen < sizeof (regrep_t))
3110Sstevel@tonic-gate return;
3120Sstevel@tonic-gate pt = (flags & F_DTAIL ? "registration reply ":"reg reply ");
3130Sstevel@tonic-gate
3140Sstevel@tonic-gate (void) memcpy(rrep, msg, sizeof (*rrep));
3150Sstevel@tonic-gate regext_size = fraglen - sizeof (regrep_t);
3160Sstevel@tonic-gate regext_data = msg + sizeof (*rrep);
3170Sstevel@tonic-gate
3180Sstevel@tonic-gate switch (rrep->code) {
3190Sstevel@tonic-gate case REPLY_CODE_ACK:
3200Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL)) ?
3210Sstevel@tonic-gate "OK" : "OK code 0";
3220Sstevel@tonic-gate break;
3230Sstevel@tonic-gate case REPLY_CODE_ACK_NO_SIMULTANEOUS:
3240Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3250Sstevel@tonic-gate "OK simultaneous bindings" : "OK code 1";
3260Sstevel@tonic-gate break;
3270Sstevel@tonic-gate case REPLY_CODE_FA_NACK_UNSPECIFIED:
3280Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3290Sstevel@tonic-gate "FA denial: unspecified":"FA denial: code 64";
3300Sstevel@tonic-gate break;
3310Sstevel@tonic-gate case REPLY_CODE_FA_NACK_PROHIBITED:
3320Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3330Sstevel@tonic-gate "FA denial: prohibited":"FA denial: code 65";
3340Sstevel@tonic-gate break;
3350Sstevel@tonic-gate case REPLY_CODE_FA_NACK_RESOURCES:
3360Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3370Sstevel@tonic-gate "FA denial: no resources":"FA denial: code 66";
3380Sstevel@tonic-gate break;
3390Sstevel@tonic-gate case REPLY_CODE_FA_NACK_MN_AUTH:
3400Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3410Sstevel@tonic-gate "FA denial: MN auth failed":"FA denial: code 67";
3420Sstevel@tonic-gate break;
3430Sstevel@tonic-gate case REPLY_CODE_FA_NACK_HA_AUTH:
3440Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3450Sstevel@tonic-gate "FA denial: HA auth failed":
3460Sstevel@tonic-gate "FA denial: code 68";
3470Sstevel@tonic-gate break;
3480Sstevel@tonic-gate case REPLY_CODE_FA_NACK_LIFETIME:
3490Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3500Sstevel@tonic-gate "FA denial: lifetime":"FA denial: code 69";
3510Sstevel@tonic-gate break;
3520Sstevel@tonic-gate case REPLY_CODE_FA_NACK_BAD_REQUEST:
3530Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3540Sstevel@tonic-gate "FA denial: bad request": "FA: code 70";
3550Sstevel@tonic-gate break;
3560Sstevel@tonic-gate case REPLY_CODE_FA_NACK_BAD_REPLY:
3570Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3580Sstevel@tonic-gate "FA denial: bad Reply":"FA denial: code 71";
3590Sstevel@tonic-gate break;
3600Sstevel@tonic-gate case REPLY_CODE_FA_NACK_ENCAP_UNAVAILABLE:
3610Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3620Sstevel@tonic-gate "FA denial: encapsulation":"FA denial: code 72";
3630Sstevel@tonic-gate break;
3640Sstevel@tonic-gate case REPLY_CODE_FA_NACK_VJ_UNAVAILABLE:
3650Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3660Sstevel@tonic-gate "FA denial: VJ compression":"FA denial: code 73";
3670Sstevel@tonic-gate break;
3680Sstevel@tonic-gate case REPLY_CODE_FA_NACK_BIDIR_TUNNEL_UNAVAILABLE:
3690Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3700Sstevel@tonic-gate "FA denial: reverse tunnel unavailable":
3710Sstevel@tonic-gate "FA denial: code 74";
3720Sstevel@tonic-gate break;
3730Sstevel@tonic-gate case REPLY_CODE_FA_NACK_BIDIR_TUNNEL_NO_TBIT:
3740Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3750Sstevel@tonic-gate "FA denial: reverse tunnel: missing T-bit":
3760Sstevel@tonic-gate "FA denial: code 75";
3770Sstevel@tonic-gate break;
3780Sstevel@tonic-gate case REPLY_CODE_FA_NACK_BIDIR_TUNNEL_TOO_DISTANT:
3790Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3800Sstevel@tonic-gate "FA denial: reverse tunnel: too distant":
3810Sstevel@tonic-gate "FA denial: code 76";
3820Sstevel@tonic-gate break;
3830Sstevel@tonic-gate case REPLY_CODE_FA_NACK_ICMP_HA_NET_UNREACHABLE:
3840Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3850Sstevel@tonic-gate "FA denial: home network unreachable":
3860Sstevel@tonic-gate "FA denial: code 80";
3870Sstevel@tonic-gate break;
3880Sstevel@tonic-gate case REPLY_CODE_FA_NACK_ICMP_HA_HOST_UNREACHABLE:
3890Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3900Sstevel@tonic-gate "FA denial: HA host unreachable":
3910Sstevel@tonic-gate "FA denial: code 81";
3920Sstevel@tonic-gate break;
3930Sstevel@tonic-gate case REPLY_CODE_FA_NACK_ICMP_HA_PORT_UNREACHABLE:
3940Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
3950Sstevel@tonic-gate "FA denial: HA port unreachable":
3960Sstevel@tonic-gate "FA denial: code 82";
3970Sstevel@tonic-gate break;
3980Sstevel@tonic-gate case REPLY_CODE_FA_NACK_ICMP_HA_UNREACHABLE:
3990Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4000Sstevel@tonic-gate "FA denial: HA unreachable":"FA denial: code 88";
4010Sstevel@tonic-gate break;
4020Sstevel@tonic-gate case REPLY_CODE_FA_NACK_UNIQUE_HOMEADDR_REQD:
4030Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4040Sstevel@tonic-gate "FA denial: Unique Home Addr Required":
4050Sstevel@tonic-gate "FA denial: code 96";
4060Sstevel@tonic-gate break;
4070Sstevel@tonic-gate case REPLY_CODE_FA_NACK_MISSING_NAI:
4080Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4090Sstevel@tonic-gate "FA denial: Missing NAI":
4100Sstevel@tonic-gate "FA denial: code 97";
4110Sstevel@tonic-gate break;
4120Sstevel@tonic-gate case REPLY_CODE_FA_NACK_MISSING_HOME_AGENT:
4130Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4140Sstevel@tonic-gate "FA denial: Missing Home Agent":
4150Sstevel@tonic-gate "FA denial: code 98";
4160Sstevel@tonic-gate break;
4170Sstevel@tonic-gate case REPLY_CODE_FA_NACK_UNKNOWN_CHALLENGE:
4180Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4190Sstevel@tonic-gate "FA denial: Unknown Challenge":
4200Sstevel@tonic-gate "FA denial: code 104";
4210Sstevel@tonic-gate break;
4220Sstevel@tonic-gate case REPLY_CODE_FA_NACK_MISSING_CHALLENGE:
4230Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4240Sstevel@tonic-gate "FA denial: Missing Challenge":
4250Sstevel@tonic-gate "FA denial: code 105";
4260Sstevel@tonic-gate break;
4270Sstevel@tonic-gate case REPLY_CODE_FA_NACK_MISSING_MN_FA:
4280Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4290Sstevel@tonic-gate "FA denial: Missing Mobile-Foreign Key Extension":
4300Sstevel@tonic-gate "FA denial: code 106";
4310Sstevel@tonic-gate break;
4320Sstevel@tonic-gate case REPLY_CODE_HA_NACK_UNSPECIFIED:
4330Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4340Sstevel@tonic-gate "HA denial: unspecified":"HA denial: code 128";
4350Sstevel@tonic-gate break;
4360Sstevel@tonic-gate case REPLY_CODE_HA_NACK_PROHIBITED:
4370Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4380Sstevel@tonic-gate "HA denial: prohibited":"HA denial: code 129";
4390Sstevel@tonic-gate break;
4400Sstevel@tonic-gate case REPLY_CODE_HA_NACK_RESOURCES:
4410Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4420Sstevel@tonic-gate "HA denial: no resources":"HA denial: code 130";
4430Sstevel@tonic-gate break;
4440Sstevel@tonic-gate case REPLY_CODE_HA_NACK_MN_AUTH:
4450Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4460Sstevel@tonic-gate "HA denial: MN auth failed":"HA denial: code 131";
4470Sstevel@tonic-gate break;
4480Sstevel@tonic-gate case REPLY_CODE_HA_NACK_FA_AUTH:
4490Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4500Sstevel@tonic-gate "HA denial: FA auth failed":"HA denial: code 132";
4510Sstevel@tonic-gate break;
4520Sstevel@tonic-gate case REPLY_CODE_HA_NACK_ID_MISMATCH:
4530Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4540Sstevel@tonic-gate "HA denial: ID mismatch":"HA denial: code 133";
4550Sstevel@tonic-gate break;
4560Sstevel@tonic-gate case REPLY_CODE_HA_NACK_BAD_REQUEST:
4570Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4580Sstevel@tonic-gate "HA denial: bad request":"HA denial: code 134";
4590Sstevel@tonic-gate break;
4600Sstevel@tonic-gate case REPLY_CODE_HA_NACK_TOO_MANY_BINDINGS:
4610Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4620Sstevel@tonic-gate "HA denial: too many bindings":
4630Sstevel@tonic-gate "HA denial: code 135";
4640Sstevel@tonic-gate break;
4650Sstevel@tonic-gate case REPLY_CODE_HA_NACK_BAD_HA_ADDRESS:
4660Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4670Sstevel@tonic-gate "HA denial: bad HA address":"HA denial: code 136";
4680Sstevel@tonic-gate break;
4690Sstevel@tonic-gate case REPLY_CODE_HA_NACK_BIDIR_TUNNEL_UNAVAILABLE:
4700Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4710Sstevel@tonic-gate "HA denial: no reverse tunnel":
4720Sstevel@tonic-gate "HA denial: code 137";
4730Sstevel@tonic-gate break;
4740Sstevel@tonic-gate case REPLY_CODE_HA_NACK_BIDIR_TUNNEL_NO_TBIT:
4750Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4760Sstevel@tonic-gate "HA denial: reverse tunnel: no T-bit":
4770Sstevel@tonic-gate "HA denial: code 138";
4780Sstevel@tonic-gate break;
4790Sstevel@tonic-gate case REPLY_CODE_HA_NACK_BIDIR_ENCAP_UNAVAILABLE:
4800Sstevel@tonic-gate pc = ((flags & F_ALLSUM) || (flags & F_DTAIL))?
4810Sstevel@tonic-gate "HA denial: encapsulation unavailable":
4820Sstevel@tonic-gate "HA denial: code 139";
4830Sstevel@tonic-gate break;
4840Sstevel@tonic-gate default:
4850Sstevel@tonic-gate pc = "?";
4860Sstevel@tonic-gate break;
4870Sstevel@tonic-gate }
4880Sstevel@tonic-gate break;
4890Sstevel@tonic-gate
4900Sstevel@tonic-gate default :
4910Sstevel@tonic-gate break;
4920Sstevel@tonic-gate }
4930Sstevel@tonic-gate if (flags & F_SUM) {
4940Sstevel@tonic-gate line = get_sum_line();
4950Sstevel@tonic-gate
4960Sstevel@tonic-gate if (pc != NULL)
4970Sstevel@tonic-gate (void) sprintf(line, "Mobile IP %s(%s)", pt, pc);
4980Sstevel@tonic-gate else
4990Sstevel@tonic-gate (void) sprintf(line, "Mobile IP %s", pt);
5000Sstevel@tonic-gate }
5010Sstevel@tonic-gate
5020Sstevel@tonic-gate if (flags & F_DTAIL) {
5030Sstevel@tonic-gate show_header("MIP: ", "Mobile IP Header", fraglen);
5040Sstevel@tonic-gate show_space();
5050Sstevel@tonic-gate
5060Sstevel@tonic-gate if (*msg == REG_TYPE_REQ) {
5070Sstevel@tonic-gate (void) sprintf(get_line((char *)&rreq -
5080Sstevel@tonic-gate dlc_header, 1), "Registration header type = %s",
5090Sstevel@tonic-gate pt);
5100Sstevel@tonic-gate (void) sprintf(get_line(
5110Sstevel@tonic-gate (char *)(((uchar_t *)&rreq) + 1) - dlc_header, 1),
5120Sstevel@tonic-gate "%d... .... = %s simultaneous bindings ",
5130Sstevel@tonic-gate (rreq->Simultaneous_registration == 1)? 1 : 0,
5140Sstevel@tonic-gate (rreq->Simultaneous_registration == 1)? "":"no");
5150Sstevel@tonic-gate (void) sprintf(get_line(
5160Sstevel@tonic-gate (char *)(((uchar_t *)&rreq) + 1) - dlc_header, 1),
5170Sstevel@tonic-gate ".%d.. .... = %s broadcast datagrams ",
5180Sstevel@tonic-gate (rreq->Broadcasts_desired == 1) ? 1 : 0,
5190Sstevel@tonic-gate (rreq->Broadcasts_desired == 1) ? "":"no");
5200Sstevel@tonic-gate (void) sprintf(get_line(
5210Sstevel@tonic-gate (char *)(((uchar_t *)&rreq) + 1) - dlc_header, 1),
5220Sstevel@tonic-gate "..%d. .... = %s decapsulation by MN",
5230Sstevel@tonic-gate (rreq->Decapsulation_done_locally == 1) ? 1 : 0,
5240Sstevel@tonic-gate (rreq->Decapsulation_done_locally == 1) ?
5250Sstevel@tonic-gate "" : "no");
5260Sstevel@tonic-gate (void) sprintf(get_line(
5270Sstevel@tonic-gate (char *)(((uchar_t *)&rreq) + 1) - dlc_header, 1),
5280Sstevel@tonic-gate "...%d .... = %s minimum encapsulation ",
5290Sstevel@tonic-gate (rreq->Minimal_encap_desired == 1) ? 1 : 0,
5300Sstevel@tonic-gate (rreq->Minimal_encap_desired == 1) ? "" : "no");
5310Sstevel@tonic-gate (void) sprintf(get_line(
5320Sstevel@tonic-gate (char *)(((uchar_t *)&rreq) + 1) - dlc_header, 1),
5330Sstevel@tonic-gate ".... %d... = %s GRE encapsulation ",
5340Sstevel@tonic-gate (rreq->GRE_encap_desired == 1) ? 1 : 0,
5350Sstevel@tonic-gate (rreq->GRE_encap_desired == 1) ? "" : "no");
5360Sstevel@tonic-gate (void) sprintf(get_line(
5370Sstevel@tonic-gate (char *)(((uchar_t *)&rreq) + 1) - dlc_header, 1),
5380Sstevel@tonic-gate ".... .%d.. = %s VJ hdr Compression ",
5390Sstevel@tonic-gate (rreq->VJ_compression_desired == 1) ? 1 : 0,
5400Sstevel@tonic-gate (rreq->VJ_compression_desired == 1) ? "" : "no");
5410Sstevel@tonic-gate (void) sprintf(get_line(
5420Sstevel@tonic-gate (char *)(((uchar_t *)&rreq) + 1) - dlc_header, 1),
5430Sstevel@tonic-gate ".... ..%d. = %s reverse tunnel",
5440Sstevel@tonic-gate (rreq->BiDirectional_Tunnel_desired == 1) ? 1 : 0,
5450Sstevel@tonic-gate (rreq->BiDirectional_Tunnel_desired == 1) ?
5460Sstevel@tonic-gate "" : "no");
5470Sstevel@tonic-gate if (ntohs(rreq->lifetime) == 0xffff) {
5480Sstevel@tonic-gate (void) sprintf(get_line(
5490Sstevel@tonic-gate (char *)&rreq->lifetime - dlc_header, 1),
5500Sstevel@tonic-gate "Life Time = 0xFFFF (infinity)");
5510Sstevel@tonic-gate } else if (ntohs(rreq->lifetime) == 0) {
5520Sstevel@tonic-gate (void) sprintf(get_line(
5530Sstevel@tonic-gate (char *)&rreq->lifetime - dlc_header, 1),
5540Sstevel@tonic-gate "Life Time = 0 "
5550Sstevel@tonic-gate "(request for de-registration)");
5560Sstevel@tonic-gate } else {
5570Sstevel@tonic-gate (void) sprintf(get_line(
5580Sstevel@tonic-gate (char *)&rreq->lifetime - dlc_header, 1),
5590Sstevel@tonic-gate "Life time = %d seconds",
5600Sstevel@tonic-gate ntohs(rreq->lifetime));
5610Sstevel@tonic-gate }
5620Sstevel@tonic-gate addr_temp.s_addr = rreq->home_addr;
5630Sstevel@tonic-gate (void) sprintf(get_line(
5640Sstevel@tonic-gate (char *)&rreq->home_addr - dlc_header, 1),
5650Sstevel@tonic-gate "Home address = %s, %s",
5660Sstevel@tonic-gate inet_ntoa(addr_temp),
5670Sstevel@tonic-gate addrtoname(AF_INET, &addr_temp));
5680Sstevel@tonic-gate addr_temp.s_addr = rreq->home_agent_addr;
5690Sstevel@tonic-gate (void) sprintf(get_line(
5700Sstevel@tonic-gate (char *)&rreq->home_agent_addr - dlc_header, 1),
5710Sstevel@tonic-gate "Home Agent address = %s, %s",
5720Sstevel@tonic-gate inet_ntoa(addr_temp),
5730Sstevel@tonic-gate addrtoname(AF_INET, &addr_temp));
5740Sstevel@tonic-gate addr_temp.s_addr = rreq->care_of_addr;
5750Sstevel@tonic-gate (void) sprintf(get_line(
5760Sstevel@tonic-gate (char *)&rreq->care_of_addr - dlc_header, 1),
5770Sstevel@tonic-gate "Care of address = %s, %s",
5780Sstevel@tonic-gate inet_ntoa(addr_temp),
5790Sstevel@tonic-gate addrtoname(AF_INET, &addr_temp));
5800Sstevel@tonic-gate (void) sprintf(get_line(
5810Sstevel@tonic-gate (char *)&rreq->identification - dlc_header, 1),
5820Sstevel@tonic-gate "Identification = 0x%x-%x",
5830Sstevel@tonic-gate ntohl(rreq->identification.high_bits),
5840Sstevel@tonic-gate ntohl(rreq->identification.low_bits));
5850Sstevel@tonic-gate } else if (*msg == REG_TYPE_REP) {
5860Sstevel@tonic-gate (void) sprintf(
5870Sstevel@tonic-gate get_line((char *)&rrep->type - dlc_header, 1),
5880Sstevel@tonic-gate "Registration header type = %d (%s)",
5890Sstevel@tonic-gate (int)rrep->type, pt);
5900Sstevel@tonic-gate (void) sprintf(get_line((char *)&rrep - dlc_header, 1),
5910Sstevel@tonic-gate "Code = %d %s", (int)rrep->code, pc);
5920Sstevel@tonic-gate if (ntohs(rrep->lifetime) == 0xffff) {
5930Sstevel@tonic-gate (void) sprintf(get_line(
5940Sstevel@tonic-gate (char *)&rrep->lifetime - dlc_header, 1),
5950Sstevel@tonic-gate "Life time = 0xFFFF (infinity)");
5960Sstevel@tonic-gate } else if (ntohs(rrep->lifetime) == 0) {
5970Sstevel@tonic-gate (void) sprintf(get_line(
5980Sstevel@tonic-gate (char *)&rrep->lifetime - dlc_header, 1),
5990Sstevel@tonic-gate ((rrep->code == REPLY_CODE_ACK) ||
6000Sstevel@tonic-gate (rrep->code ==
6010Sstevel@tonic-gate REPLY_CODE_ACK_NO_SIMULTANEOUS))?
6020Sstevel@tonic-gate "Life time = 0 (de-registeration success)" :
6030Sstevel@tonic-gate "Life time = 0 (de-registration failed)");
6040Sstevel@tonic-gate } else {
6050Sstevel@tonic-gate (void) sprintf(get_line(
6060Sstevel@tonic-gate (char *)&rrep->lifetime - dlc_header, 1),
6070Sstevel@tonic-gate "Life time = %d seconds",
6080Sstevel@tonic-gate ntohs(rrep->lifetime));
6090Sstevel@tonic-gate }
6100Sstevel@tonic-gate addr_temp.s_addr = rrep->home_addr;
6110Sstevel@tonic-gate (void) sprintf(
6120Sstevel@tonic-gate get_line((char *)&rrep->home_addr - dlc_header, 1),
6130Sstevel@tonic-gate "Home address = %s, %s",
6140Sstevel@tonic-gate inet_ntoa(addr_temp),
6150Sstevel@tonic-gate addrtoname(AF_INET, &addr_temp));
6160Sstevel@tonic-gate addr_temp.s_addr = rrep->home_agent_addr;
6170Sstevel@tonic-gate (void) sprintf(get_line(
6180Sstevel@tonic-gate (char *)&rrep->home_agent_addr - dlc_header, 1),
6190Sstevel@tonic-gate "Home Agent address = %s, %s",
6200Sstevel@tonic-gate inet_ntoa(addr_temp),
6210Sstevel@tonic-gate addrtoname(AF_INET, &addr_temp));
6220Sstevel@tonic-gate (void) sprintf(get_line(
6230Sstevel@tonic-gate (char *)&rrep->identification - dlc_header, 1),
6240Sstevel@tonic-gate "Identification = 0x%x-%x",
6250Sstevel@tonic-gate ntohl(rrep->identification.high_bits),
6260Sstevel@tonic-gate ntohl(rrep->identification.low_bits));
6270Sstevel@tonic-gate }
6280Sstevel@tonic-gate fraglen = interpret_extensions(regext_data, regext_size, REG);
6290Sstevel@tonic-gate }
6300Sstevel@tonic-gate }
6310Sstevel@tonic-gate
6320Sstevel@tonic-gate /*ARGSUSED*/
spi_ext(uint8_t type,uint8_t this_ext_len,uchar_t * p)6330Sstevel@tonic-gate static void spi_ext(uint8_t type, uint8_t this_ext_len, uchar_t *p) {
6340Sstevel@tonic-gate uint16_t spi_hi, spi_low;
6350Sstevel@tonic-gate char auth_prn_str[BUFLEN];
6360Sstevel@tonic-gate
6370Sstevel@tonic-gate /* SPI */
6380Sstevel@tonic-gate GETSPI(p, spi_hi, spi_low);
6390Sstevel@tonic-gate (void) sprintf(get_line((char *)p - dlc_header, 1),
6400Sstevel@tonic-gate "Security Parameter Index = 0x%x%x",
6410Sstevel@tonic-gate ntohs(spi_hi), ntohs(spi_low));
6420Sstevel@tonic-gate p += sizeof (spi_hi) + sizeof (spi_low);
6430Sstevel@tonic-gate this_ext_len -= sizeof (spi_hi) + sizeof (spi_low);
6440Sstevel@tonic-gate
6450Sstevel@tonic-gate /* The rest is the authenticator; dump it in hex */
6460Sstevel@tonic-gate dumphex(p,
6470Sstevel@tonic-gate /* don't write past our string buffer ... */
6480Sstevel@tonic-gate (this_ext_len*3 > BUFLEN ? BUFLEN : this_ext_len),
6490Sstevel@tonic-gate auth_prn_str,
6500Sstevel@tonic-gate "Authenticator = %s");
6510Sstevel@tonic-gate }
6520Sstevel@tonic-gate
key_ext(uint8_t type,uint8_t this_ext_len,uchar_t * p)6530Sstevel@tonic-gate static void key_ext(uint8_t type, uint8_t this_ext_len, uchar_t *p) {
6540Sstevel@tonic-gate uint16_t alg, spi_hi, spi_low;
6550Sstevel@tonic-gate char *alg_string;
6560Sstevel@tonic-gate char *hafa = (type == MN_HA_KEY ? "HA" : "FA");
6570Sstevel@tonic-gate char sec_msg[32];
6580Sstevel@tonic-gate char auth_prn_str[BUFLEN];
6590Sstevel@tonic-gate
6600Sstevel@tonic-gate /* Algorithm Type */
6610Sstevel@tonic-gate (void) memcpy(&alg, p, sizeof (alg));
6620Sstevel@tonic-gate alg = ntohs(alg);
6630Sstevel@tonic-gate switch (alg) {
6640Sstevel@tonic-gate case KEY_ALG_NONE:
6650Sstevel@tonic-gate alg_string = "None";
6660Sstevel@tonic-gate break;
6670Sstevel@tonic-gate case SA_MD5_MODE_PREF_SUF:
6680Sstevel@tonic-gate alg_string = "MD5/prefix+suffix";
6690Sstevel@tonic-gate break;
6700Sstevel@tonic-gate case SA_HMAC_MD5:
6710Sstevel@tonic-gate alg_string = "HMAC MD5";
6720Sstevel@tonic-gate break;
6730Sstevel@tonic-gate default:
6740Sstevel@tonic-gate alg_string = "Unknown";
6750Sstevel@tonic-gate break;
6760Sstevel@tonic-gate }
6770Sstevel@tonic-gate (void) sprintf(get_line((char *)p-dlc_header, 1),
6780Sstevel@tonic-gate "Algorithm = 0x%x: %s", alg, alg_string);
6790Sstevel@tonic-gate p += sizeof (alg);
6800Sstevel@tonic-gate this_ext_len -= sizeof (alg);
6810Sstevel@tonic-gate
6820Sstevel@tonic-gate /* AAA SPI */
6830Sstevel@tonic-gate GETSPI(p, spi_hi, spi_low);
6840Sstevel@tonic-gate (void) sprintf(get_line((char *)p - dlc_header, 1),
6850Sstevel@tonic-gate "AAA Security Parameter Index = 0x%x%x",
6860Sstevel@tonic-gate ntohs(spi_hi), ntohs(spi_low));
6870Sstevel@tonic-gate p += sizeof (spi_hi) + sizeof (spi_low);
6880Sstevel@tonic-gate this_ext_len -= sizeof (spi_hi) + sizeof (spi_low);
6890Sstevel@tonic-gate
6900Sstevel@tonic-gate /* HA / FA SPI */
6910Sstevel@tonic-gate GETSPI(p, spi_hi, spi_low);
6920Sstevel@tonic-gate (void) sprintf(get_line((char *)p - dlc_header, 1),
6930Sstevel@tonic-gate "%s Security Parameter Index = 0x%x%x",
6940Sstevel@tonic-gate hafa, ntohs(spi_hi), ntohs(spi_low));
6950Sstevel@tonic-gate p += sizeof (spi_hi) + sizeof (spi_low);
6960Sstevel@tonic-gate this_ext_len -= sizeof (spi_hi) + sizeof (spi_low);
6970Sstevel@tonic-gate
6980Sstevel@tonic-gate /* The rest is the security info; dump it in hex */
6990Sstevel@tonic-gate sprintf(sec_msg, "%s Security Info = %%s", hafa);
7000Sstevel@tonic-gate dumphex(p,
7010Sstevel@tonic-gate /* don't write past our string buffer ... */
7020Sstevel@tonic-gate (this_ext_len*3 > BUFLEN ? BUFLEN : this_ext_len),
7030Sstevel@tonic-gate auth_prn_str,
7040Sstevel@tonic-gate sec_msg);
7050Sstevel@tonic-gate }
7060Sstevel@tonic-gate
7070Sstevel@tonic-gate /*ARGSUSED*/
trav_ext(uint8_t type,uint8_t this_ext_len,uchar_t * p)7080Sstevel@tonic-gate static void trav_ext(uint8_t type, uint8_t this_ext_len, uchar_t *p) {
7090Sstevel@tonic-gate struct in_addr addr_temp;
7100Sstevel@tonic-gate
7110Sstevel@tonic-gate /* skip reserved */
7120Sstevel@tonic-gate p += 2;
7130Sstevel@tonic-gate this_ext_len -= 2;
7140Sstevel@tonic-gate
7150Sstevel@tonic-gate /* Mobile-Home Traversal Address */
7160Sstevel@tonic-gate (void) memcpy(&(addr_temp.s_addr), p, sizeof (addr_temp.s_addr));
7170Sstevel@tonic-gate (void) sprintf(get_line((char *)p-dlc_header, 1),
7180Sstevel@tonic-gate "Mobile-Home Traversal Address= %s, %s",
7190Sstevel@tonic-gate inet_ntoa(addr_temp),
7200Sstevel@tonic-gate addrtoname(AF_INET, &addr_temp));
7210Sstevel@tonic-gate p += sizeof (addr_temp.s_addr);
7220Sstevel@tonic-gate this_ext_len -= sizeof (addr_temp.s_addr);
7230Sstevel@tonic-gate
7240Sstevel@tonic-gate /* Home-Mobile Traversal Address */
7250Sstevel@tonic-gate (void) memcpy(&(addr_temp.s_addr), p, sizeof (addr_temp.s_addr));
7260Sstevel@tonic-gate (void) sprintf(get_line((char *)p-dlc_header, 1),
7270Sstevel@tonic-gate "Home-Mobile Traversal Address= %s, %s",
7280Sstevel@tonic-gate inet_ntoa(addr_temp),
7290Sstevel@tonic-gate addrtoname(AF_INET, &addr_temp));
7300Sstevel@tonic-gate }
7310Sstevel@tonic-gate
7320Sstevel@tonic-gate /*ARGSUSED*/
empty_ext(uint8_t type,uint8_t this_ext_len,uchar_t * p)7330Sstevel@tonic-gate static void empty_ext(uint8_t type, uint8_t this_ext_len, uchar_t *p) {
7340Sstevel@tonic-gate /* no payload */
7350Sstevel@tonic-gate }
7360Sstevel@tonic-gate
7370Sstevel@tonic-gate /*ARGSUSED*/
nai_ext(uint8_t type,uint8_t this_ext_len,uchar_t * p)7380Sstevel@tonic-gate static void nai_ext(uint8_t type, uint8_t this_ext_len, uchar_t *p) {
7390Sstevel@tonic-gate /* payload points to the NAI */
7400Sstevel@tonic-gate char *desc = "Network Access Identifier = ";
7410Sstevel@tonic-gate size_t desclen = strlen(desc) + 1 + this_ext_len;
7420Sstevel@tonic-gate
7430Sstevel@tonic-gate (void) snprintf(get_line((char *)p-dlc_header, 1),
7440Sstevel@tonic-gate desclen > MAXLINE ? MAXLINE : desclen,
7450Sstevel@tonic-gate "%s%s", desc, p);
7460Sstevel@tonic-gate }
7470Sstevel@tonic-gate
7480Sstevel@tonic-gate /*ARGSUSED*/
chall_ext(uint8_t type,uint8_t this_ext_len,uchar_t * p)7490Sstevel@tonic-gate static void chall_ext(uint8_t type, uint8_t this_ext_len, uchar_t *p) {
7500Sstevel@tonic-gate char auth_prn_str[BUFLEN];
7510Sstevel@tonic-gate
7520Sstevel@tonic-gate /* payload points to the challenge */
7530Sstevel@tonic-gate dumphex(p,
7540Sstevel@tonic-gate /* don't write past our string buffer ... */
7550Sstevel@tonic-gate (this_ext_len*3 > BUFLEN ? BUFLEN / 3 : this_ext_len),
7560Sstevel@tonic-gate auth_prn_str,
7570Sstevel@tonic-gate "Challenge = %s");
7580Sstevel@tonic-gate }
7590Sstevel@tonic-gate
7600Sstevel@tonic-gate /*ARGSUSED*/
ma_ext(uint8_t type,uint8_t this_ext_len,uchar_t * p)7610Sstevel@tonic-gate static void ma_ext(uint8_t type, uint8_t this_ext_len, uchar_t *p) {
7620Sstevel@tonic-gate mobagtadvext_t adv_ext[1];
7630Sstevel@tonic-gate int i, len;
7640Sstevel@tonic-gate struct in_addr temp_addr;
7650Sstevel@tonic-gate
7660Sstevel@tonic-gate (void) memcpy(adv_ext, p - sizeof (exthdr_t), sizeof (*adv_ext));
7670Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "Sequence number = %d",
7680Sstevel@tonic-gate ntohs(adv_ext->sequence_num));
7690Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
7700Sstevel@tonic-gate "Registration lifetime = %d seconds",
7710Sstevel@tonic-gate ntohs(adv_ext->reg_lifetime));
7720Sstevel@tonic-gate if (adv_ext->reg_bit) {
7730Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
7740Sstevel@tonic-gate "1... .... = registration required "
7750Sstevel@tonic-gate "through FA");
7760Sstevel@tonic-gate } else {
7770Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
7780Sstevel@tonic-gate "0... .... = registration not required "
7790Sstevel@tonic-gate "through FA");
7800Sstevel@tonic-gate }
7810Sstevel@tonic-gate if (adv_ext->busy_bit) {
7820Sstevel@tonic-gate (void) sprintf(get_line(0, 0), ".1.. .... = FA busy");
7830Sstevel@tonic-gate } else {
7840Sstevel@tonic-gate (void) sprintf(get_line(0, 0), ".0.. .... = FA not busy");
7850Sstevel@tonic-gate }
7860Sstevel@tonic-gate if (adv_ext->ha_bit) {
7870Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "..1. .... = node is HA");
7880Sstevel@tonic-gate } else {
7890Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "..0. .... = node not HA");
7900Sstevel@tonic-gate }
7910Sstevel@tonic-gate if (adv_ext->fa_bit) {
7920Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "...1 .... = node is FA ");
7930Sstevel@tonic-gate } else {
7940Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "...0 .... = node not FA ");
7950Sstevel@tonic-gate }
7960Sstevel@tonic-gate if (adv_ext->minencap_bit) {
7970Sstevel@tonic-gate (void) sprintf(get_line(0, 0), ".... 1... = minimal encapsulation "
7980Sstevel@tonic-gate "supported");
7990Sstevel@tonic-gate } else {
8000Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
8010Sstevel@tonic-gate ".... 0... = no minimal encapsulation");
8020Sstevel@tonic-gate }
8030Sstevel@tonic-gate if (adv_ext->greencap_bit) {
8040Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
8050Sstevel@tonic-gate ".... .1.. = GRE encapsulation supported");
8060Sstevel@tonic-gate } else {
8070Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
8080Sstevel@tonic-gate ".... .0.. = no GRE encapsulation");
8090Sstevel@tonic-gate }
8100Sstevel@tonic-gate if (adv_ext->vanjacob_hdr_comp_bit) {
8110Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
8120Sstevel@tonic-gate ".... ..1. = VJ header compression");
8130Sstevel@tonic-gate } else {
8140Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
8150Sstevel@tonic-gate ".... ..0. = no VJ header compression");
8160Sstevel@tonic-gate }
8170Sstevel@tonic-gate if (adv_ext->reverse_tunnel_bit) {
8180Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
8190Sstevel@tonic-gate ".... ...1 = reverse tunneling supported");
8200Sstevel@tonic-gate } else {
8210Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
8220Sstevel@tonic-gate ".... ...0 = no reverse tunneling");
8230Sstevel@tonic-gate }
8240Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
8250Sstevel@tonic-gate "Reserved Byte = 0x%x", adv_ext->reserved);
8260Sstevel@tonic-gate
8270Sstevel@tonic-gate /* Parse out COA's */
8280Sstevel@tonic-gate p += sizeof (*adv_ext);
8290Sstevel@tonic-gate len = this_ext_len + sizeof (exthdr_t);
8300Sstevel@tonic-gate /* this_ext_len is unsigned, and here we need a signed number */
8310Sstevel@tonic-gate len -= sizeof (*adv_ext);
8320Sstevel@tonic-gate
8330Sstevel@tonic-gate for (i = 0; len >= sizeof (temp_addr.s_addr); i++) {
8340Sstevel@tonic-gate memcpy(&(temp_addr.s_addr), p - sizeof (exthdr_t),
8350Sstevel@tonic-gate sizeof (temp_addr.s_addr));
8360Sstevel@tonic-gate
8370Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
8380Sstevel@tonic-gate "Care of address-%d = %s, %s", i,
8390Sstevel@tonic-gate inet_ntoa(temp_addr),
8400Sstevel@tonic-gate addrtoname(AF_INET, &temp_addr));
8410Sstevel@tonic-gate
8420Sstevel@tonic-gate p += sizeof (temp_addr);
8430Sstevel@tonic-gate len -= sizeof (temp_addr);
8440Sstevel@tonic-gate }
8450Sstevel@tonic-gate }
8460Sstevel@tonic-gate
8470Sstevel@tonic-gate /*ARGSUSED*/
prefix_ext(uint8_t type,uint8_t this_ext_len,uchar_t * p)8480Sstevel@tonic-gate static void prefix_ext(uint8_t type, uint8_t this_ext_len, uchar_t *p) {
8490Sstevel@tonic-gate int i;
8500Sstevel@tonic-gate
8510Sstevel@tonic-gate for (i = 0; i < this_ext_len; i++) {
8520Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
8530Sstevel@tonic-gate "Prefix length of router address[%d] "
8540Sstevel@tonic-gate "= %d bits",
8550Sstevel@tonic-gate i, p[i]);
8560Sstevel@tonic-gate }
8570Sstevel@tonic-gate }
8580Sstevel@tonic-gate
8590Sstevel@tonic-gate /*ARGSUSED*/
unk_ext(uint8_t type,uint8_t this_ext_len,uchar_t * p)8600Sstevel@tonic-gate static void unk_ext(uint8_t type, uint8_t this_ext_len, uchar_t *p) {
8610Sstevel@tonic-gate char auth_prn_str[BUFLEN];
8620Sstevel@tonic-gate
8630Sstevel@tonic-gate /* Unknown extension; just dump the rest of the payload */
8640Sstevel@tonic-gate dumphex(p,
8650Sstevel@tonic-gate /* don't write past our string buffer ... */
8660Sstevel@tonic-gate (this_ext_len*3 > BUFLEN ? BUFLEN : this_ext_len),
8670Sstevel@tonic-gate auth_prn_str,
8680Sstevel@tonic-gate "Payload = %s");
8690Sstevel@tonic-gate }
870