17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*166fae49Spk34663 * Common Development and Distribution License (the "License"). 6*166fae49Spk34663 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*166fae49Spk34663 227c478bd9Sstevel@tonic-gate /* 23*166fae49Spk34663 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <stdio.h> 307c478bd9Sstevel@tonic-gate #include <ctype.h> 317c478bd9Sstevel@tonic-gate #include <string.h> 327c478bd9Sstevel@tonic-gate #include <fcntl.h> 337c478bd9Sstevel@tonic-gate #include <string.h> 347c478bd9Sstevel@tonic-gate #include <sys/types.h> 357c478bd9Sstevel@tonic-gate #include <sys/time.h> 367c478bd9Sstevel@tonic-gate #include <sys/stat.h> 377c478bd9Sstevel@tonic-gate #include <sys/uio.h> 387c478bd9Sstevel@tonic-gate #include <unistd.h> 397c478bd9Sstevel@tonic-gate #include <signal.h> 407c478bd9Sstevel@tonic-gate #include <errno.h> 417c478bd9Sstevel@tonic-gate #include <stdlib.h> 427c478bd9Sstevel@tonic-gate #include <sys/wait.h> 437c478bd9Sstevel@tonic-gate #include <sys/socket.h> 447c478bd9Sstevel@tonic-gate #include <sys/sockio.h> 457c478bd9Sstevel@tonic-gate #include <net/if.h> 467c478bd9Sstevel@tonic-gate #include <netinet/in_systm.h> 477c478bd9Sstevel@tonic-gate #include <netinet/in.h> 487c478bd9Sstevel@tonic-gate #include <netinet/ip.h> 497c478bd9Sstevel@tonic-gate #include <netinet/if_ether.h> 507c478bd9Sstevel@tonic-gate #include <netinet/udp.h> 517c478bd9Sstevel@tonic-gate #include "snoop.h" 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #ifndef MIN 547c478bd9Sstevel@tonic-gate #define MIN(a, b) ((a) < (b) ? (a) : (b)) 557c478bd9Sstevel@tonic-gate #endif 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate extern char *src_name; 587c478bd9Sstevel@tonic-gate extern char *dst_name; 597c478bd9Sstevel@tonic-gate #define MAX_CTX (10) 607c478bd9Sstevel@tonic-gate #define LINE_LEN (255) 617c478bd9Sstevel@tonic-gate #define BUF_SIZE (16000) 627c478bd9Sstevel@tonic-gate static int ldap = 0; /* flag to control initialization */ 637c478bd9Sstevel@tonic-gate struct ctx { 647c478bd9Sstevel@tonic-gate int src; 657c478bd9Sstevel@tonic-gate int dst; 667c478bd9Sstevel@tonic-gate char *src_name; 677c478bd9Sstevel@tonic-gate char *dst_name; 687c478bd9Sstevel@tonic-gate }; 697c478bd9Sstevel@tonic-gate char *osibuff = NULL; 707c478bd9Sstevel@tonic-gate int osilen = 0; 717c478bd9Sstevel@tonic-gate char scrbuffer[BUF_SIZE]; /* buffer to accumulate data until a */ 727c478bd9Sstevel@tonic-gate /* complete LDAPmessage is received */ 737c478bd9Sstevel@tonic-gate char resultcode[LINE_LEN]; /* These are used */ 747c478bd9Sstevel@tonic-gate char operation[LINE_LEN]; /* by -V option. */ 757c478bd9Sstevel@tonic-gate char bb[LINE_LEN]; 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate int gi_osibuf[MAX_CTX]; 787c478bd9Sstevel@tonic-gate int otyp[MAX_CTX]; 797c478bd9Sstevel@tonic-gate int olen[MAX_CTX]; 807c478bd9Sstevel@tonic-gate int level[MAX_CTX]; 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate void decode_ldap(char *buf, int len); 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate #define X unsigned char 857c478bd9Sstevel@tonic-gate typedef X * A; 867c478bd9Sstevel@tonic-gate #define INT(a) ((int)(a)) 877c478bd9Sstevel@tonic-gate #define SCRUB (void) strcat(scrbuffer, bb); 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate static X hex; /* input hex octet */ 907c478bd9Sstevel@tonic-gate static A *PTRaclass; /* application tag table pointer */ 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* 932e3b6467Skcpoon * ASN.1 Message Printing Macros 947c478bd9Sstevel@tonic-gate */ 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #define asnshw1(a) {(void)sprintf(bb, a); SCRUB } 977c478bd9Sstevel@tonic-gate #define asnshw2(a, b) {(void)sprintf(bb, a, b); SCRUB } 987c478bd9Sstevel@tonic-gate #define asnshw3(a, b, c) {(void)sprintf(bb, a, b, c); SCRUB } 997c478bd9Sstevel@tonic-gate #define asnshw4(a, b, c, d) {(void)sprintf(bb, a, b, c, d); SCRUB } 1007c478bd9Sstevel@tonic-gate #define asnshw5(a, b, c, d, e) {(void)sprintf(bb, a, b, c, d, e); SCRUB } 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* 1032e3b6467Skcpoon * Local Types And Variables 1047c478bd9Sstevel@tonic-gate */ 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1072e3b6467Skcpoon * Object identifier oid to name mapping description type 1087c478bd9Sstevel@tonic-gate */ 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate typedef struct { 1117c478bd9Sstevel@tonic-gate A oidname; /* object identifier string name */ 1127c478bd9Sstevel@tonic-gate X oidcode[16]; /* object identifier hexa code */ 1137c478bd9Sstevel@tonic-gate } oidelmT; 1147c478bd9Sstevel@tonic-gate typedef oidelmT *oidelmTp; 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* 1172e3b6467Skcpoon * Snoop's entry point to ldap decoding 1187c478bd9Sstevel@tonic-gate */ 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate void 1217c478bd9Sstevel@tonic-gate interpret_ldap(flags, data, fraglen, src, dst) 1227c478bd9Sstevel@tonic-gate int flags; 1237c478bd9Sstevel@tonic-gate char *data; 1247c478bd9Sstevel@tonic-gate int fraglen; 1257c478bd9Sstevel@tonic-gate int src; 1267c478bd9Sstevel@tonic-gate int dst; 1277c478bd9Sstevel@tonic-gate { 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate if (!ldap) { 1307c478bd9Sstevel@tonic-gate init_ldap(); 1317c478bd9Sstevel@tonic-gate ldap = 1; 1327c478bd9Sstevel@tonic-gate } 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate (void) decode_ldap(data, fraglen); 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate if (flags & F_DTAIL) { 1377c478bd9Sstevel@tonic-gate /* i.e. when snoop is run with -v (verbose) */ 1387c478bd9Sstevel@tonic-gate show_header("LDAP: ", 1397c478bd9Sstevel@tonic-gate "Lightweight Directory Access Protocol Header", fraglen); 1407c478bd9Sstevel@tonic-gate show_space(); 1417c478bd9Sstevel@tonic-gate printf("%s", scrbuffer); 1427c478bd9Sstevel@tonic-gate } 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate if (flags & F_SUM) { 1457c478bd9Sstevel@tonic-gate /* i.e. when snoop is run with -V (summary) */ 1467c478bd9Sstevel@tonic-gate (void) strcpy(data, ""); 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate if (strlen(operation) != 0) { 1497c478bd9Sstevel@tonic-gate (void) strcat(data, " "); 1507c478bd9Sstevel@tonic-gate (void) strncat(data, operation, 30); 1517c478bd9Sstevel@tonic-gate (void) strcpy(operation, ""); 1527c478bd9Sstevel@tonic-gate } 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate if (strlen(resultcode) != 0) { 1557c478bd9Sstevel@tonic-gate (void) strcat(data, " "); 1567c478bd9Sstevel@tonic-gate (void) strncat(data, resultcode, 30); 1577c478bd9Sstevel@tonic-gate (void) strcpy(resultcode, ""); 1587c478bd9Sstevel@tonic-gate } 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate if (dst == 389) { 1617c478bd9Sstevel@tonic-gate (void) sprintf(get_sum_line(), 1627c478bd9Sstevel@tonic-gate "LDAP C port=%d%s", src, data); 1637c478bd9Sstevel@tonic-gate } 1647c478bd9Sstevel@tonic-gate if (src == 389) { 1657c478bd9Sstevel@tonic-gate (void) sprintf(get_sum_line(), 1667c478bd9Sstevel@tonic-gate "LDAP R port=%d%s", dst, data); 1677c478bd9Sstevel@tonic-gate } 1687c478bd9Sstevel@tonic-gate } 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate (void) strcpy(scrbuffer, ""); 1717c478bd9Sstevel@tonic-gate } 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate /* 1742e3b6467Skcpoon * Known object identifiers: customize to add your own oids 1757c478bd9Sstevel@tonic-gate */ 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate static oidelmT OidTab[] = { 1787c478bd9Sstevel@tonic-gate /* 1792e3b6467Skcpoon * X.500 Standardized Attribute Types 1807c478bd9Sstevel@tonic-gate */ 1817c478bd9Sstevel@tonic-gate {(A)"ObjectClass", { 0x03, 0x55, 0x04, 0x00 }}, 1827c478bd9Sstevel@tonic-gate {(A)"AliasObjectName", { 0x03, 0x55, 0x04, 0x01 }}, 1837c478bd9Sstevel@tonic-gate {(A)"KnowledgeInfo", { 0x03, 0x55, 0x04, 0x02 }}, 1847c478bd9Sstevel@tonic-gate {(A)"CommonName", { 0x03, 0x55, 0x04, 0x03 }}, 1857c478bd9Sstevel@tonic-gate {(A)"Surname", { 0x03, 0x55, 0x04, 0x04 }}, 1867c478bd9Sstevel@tonic-gate {(A)"SerialNumber", { 0x03, 0x55, 0x04, 0x05 }}, 1877c478bd9Sstevel@tonic-gate {(A)"CountryName", { 0x03, 0x55, 0x04, 0x06 }}, 1887c478bd9Sstevel@tonic-gate {(A)"LocalityName", { 0x03, 0x55, 0x04, 0x07 }}, 1897c478bd9Sstevel@tonic-gate {(A)"StateOrProvinceName", { 0x03, 0x55, 0x04, 0x08 }}, 1907c478bd9Sstevel@tonic-gate {(A)"StreetAddress", { 0x03, 0x55, 0x04, 0x09 }}, 1917c478bd9Sstevel@tonic-gate {(A)"OrganizationName", { 0x03, 0x55, 0x04, 0x0a }}, 1927c478bd9Sstevel@tonic-gate {(A)"OrganizationUnitName", { 0x03, 0x55, 0x04, 0x0b }}, 1937c478bd9Sstevel@tonic-gate {(A)"Title", { 0x03, 0x55, 0x04, 0x0c }}, 1947c478bd9Sstevel@tonic-gate {(A)"Description", { 0x03, 0x55, 0x04, 0x0d }}, 1957c478bd9Sstevel@tonic-gate {(A)"SearchGuide", { 0x03, 0x55, 0x04, 0x0e }}, 1967c478bd9Sstevel@tonic-gate {(A)"BusinessCategory", { 0x03, 0x55, 0x04, 0x0f }}, 1977c478bd9Sstevel@tonic-gate {(A)"PostalAddress", { 0x03, 0x55, 0x04, 0x10 }}, 1987c478bd9Sstevel@tonic-gate {(A)"PostalCode", { 0x03, 0x55, 0x04, 0x11 }}, 1997c478bd9Sstevel@tonic-gate {(A)"PostOfficeBox", { 0x03, 0x55, 0x04, 0x12 }}, 2007c478bd9Sstevel@tonic-gate {(A)"PhysicalDeliveryOffice", { 0x03, 0x55, 0x04, 0x13 }}, 2017c478bd9Sstevel@tonic-gate {(A)"TelephoneNUmber", { 0x03, 0x55, 0x04, 0x14 }}, 2027c478bd9Sstevel@tonic-gate {(A)"TelexNumber", { 0x03, 0x55, 0x04, 0x15 }}, 2037c478bd9Sstevel@tonic-gate {(A)"TeletexTerminalId", { 0x03, 0x55, 0x04, 0x16 }}, 2047c478bd9Sstevel@tonic-gate {(A)"FaxTelephoneNumber", { 0x03, 0x55, 0x04, 0x17 }}, 2057c478bd9Sstevel@tonic-gate {(A)"X121Address", { 0x03, 0x55, 0x04, 0x18 }}, 2067c478bd9Sstevel@tonic-gate {(A)"IsdnAddress", { 0x03, 0x55, 0x04, 0x19 }}, 2077c478bd9Sstevel@tonic-gate {(A)"RegisteredAddress", { 0x03, 0x55, 0x04, 0x1a }}, 2087c478bd9Sstevel@tonic-gate {(A)"DestinationIndicator", { 0x03, 0x55, 0x04, 0x1b }}, 2097c478bd9Sstevel@tonic-gate {(A)"PreferDeliveryMethod", { 0x03, 0x55, 0x04, 0x1c }}, 2107c478bd9Sstevel@tonic-gate {(A)"PresentationAddress", { 0x03, 0x55, 0x04, 0x1d }}, 2117c478bd9Sstevel@tonic-gate {(A)"SupportedApplContext", { 0x03, 0x55, 0x04, 0x1e }}, 2127c478bd9Sstevel@tonic-gate {(A)"Member", { 0x03, 0x55, 0x04, 0x1f }}, 2137c478bd9Sstevel@tonic-gate {(A)"Owner", { 0x03, 0x55, 0x04, 0x20 }}, 2147c478bd9Sstevel@tonic-gate {(A)"RoleOccupant", { 0x03, 0x55, 0x04, 0x21 }}, 2157c478bd9Sstevel@tonic-gate {(A)"SeeAlso", { 0x03, 0x55, 0x04, 0x22 }}, 2167c478bd9Sstevel@tonic-gate {(A)"Password", { 0x03, 0x55, 0x04, 0x23 }}, 2177c478bd9Sstevel@tonic-gate {(A)"UserCertificate", { 0x03, 0x55, 0x04, 0x24 }}, 2187c478bd9Sstevel@tonic-gate {(A)"CaCertificate", { 0x03, 0x55, 0x04, 0x25 }}, 2197c478bd9Sstevel@tonic-gate {(A)"AuthorityRevList", { 0x03, 0x55, 0x04, 0x26 }}, 2207c478bd9Sstevel@tonic-gate {(A)"CertificateRevList", { 0x03, 0x55, 0x04, 0x27 }}, 2217c478bd9Sstevel@tonic-gate {(A)"CrossCertificatePair", { 0x03, 0x55, 0x04, 0x28 }}, 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate /* 2242e3b6467Skcpoon * X.500 Standardized Object Classes 2257c478bd9Sstevel@tonic-gate */ 2267c478bd9Sstevel@tonic-gate {(A)"Top", { 0x03, 0x55, 0x06, 0x00 }}, 2277c478bd9Sstevel@tonic-gate {(A)"Alias", { 0x03, 0x55, 0x06, 0x01 }}, 2287c478bd9Sstevel@tonic-gate {(A)"Country", { 0x03, 0x55, 0x06, 0x02 }}, 2297c478bd9Sstevel@tonic-gate {(A)"Locality", { 0x03, 0x55, 0x06, 0x03 }}, 2307c478bd9Sstevel@tonic-gate {(A)"Organization", { 0x03, 0x55, 0x06, 0x04 }}, 2317c478bd9Sstevel@tonic-gate {(A)"OrganizationUnit", { 0x03, 0x55, 0x06, 0x05 }}, 2327c478bd9Sstevel@tonic-gate {(A)"Person", { 0x03, 0x55, 0x06, 0x06 }}, 2337c478bd9Sstevel@tonic-gate {(A)"OrganizationPersion", { 0x03, 0x55, 0x06, 0x07 }}, 2347c478bd9Sstevel@tonic-gate {(A)"OrganizationRole", { 0x03, 0x55, 0x06, 0x08 }}, 2357c478bd9Sstevel@tonic-gate {(A)"Group", { 0x03, 0x55, 0x06, 0x09 }}, 2367c478bd9Sstevel@tonic-gate {(A)"ResidentialPerson", { 0x03, 0x55, 0x06, 0x0A }}, 2377c478bd9Sstevel@tonic-gate {(A)"ApplicationProcess", { 0x03, 0x55, 0x06, 0x0B }}, 2387c478bd9Sstevel@tonic-gate {(A)"ApplicationEntity", { 0x03, 0x55, 0x06, 0x0C }}, 2397c478bd9Sstevel@tonic-gate {(A)"Dsa", { 0x03, 0x55, 0x06, 0x0D }}, 2407c478bd9Sstevel@tonic-gate {(A)"Device", { 0x03, 0x55, 0x06, 0x0E }}, 2417c478bd9Sstevel@tonic-gate {(A)"StrongAuthenticUser", { 0x03, 0x55, 0x06, 0x0F }}, 2427c478bd9Sstevel@tonic-gate {(A)"CaAuthority", { 0x03, 0x55, 0x06, 0x10 }}, 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate /* 2452e3b6467Skcpoon * ACSE Protocol Object Identifiers 2467c478bd9Sstevel@tonic-gate */ 2477c478bd9Sstevel@tonic-gate {(A)"Asn1BER-TS", { 0x02, 0x51, 0x01 }}, 2487c478bd9Sstevel@tonic-gate {(A)"Private-TS", { 0x06, 0x2b, 0xce, 0x06, 0x01, 0x04, 0x06 }}, 2497c478bd9Sstevel@tonic-gate {(A)"ACSE-AS", { 0x04, 0x52, 0x01, 0x00, 0x01 }}, 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate /* 2522e3b6467Skcpoon * Directory Protocol Oids 2537c478bd9Sstevel@tonic-gate */ 2547c478bd9Sstevel@tonic-gate {(A)"DirAccess-AC", { 0x03, 0x55, 0x03, 0x01 }}, 2557c478bd9Sstevel@tonic-gate {(A)"DirSystem-AC", { 0x03, 0x55, 0x03, 0x02 }}, 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate {(A)"DirAccess-AS", { 0x03, 0x55, 0x09, 0x01 }}, 2587c478bd9Sstevel@tonic-gate {(A)"DirSystem-AS", { 0x03, 0x55, 0x09, 0x02 }}, 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate /* 2612e3b6467Skcpoon * and add your private object identifiers here ... 2627c478bd9Sstevel@tonic-gate */ 2637c478bd9Sstevel@tonic-gate }; 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate #define OIDNB (sizeof (OidTab) / sizeof (oidelmT)) /* total oid nb */ 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate /* 2682e3b6467Skcpoon * asn.1 tag class definition 2697c478bd9Sstevel@tonic-gate */ 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate static A class[] = { /* tag class */ 2727c478bd9Sstevel@tonic-gate (A)"UNIV ", 2737c478bd9Sstevel@tonic-gate (A)"APPL ", 2747c478bd9Sstevel@tonic-gate (A)"CTXs ", 2757c478bd9Sstevel@tonic-gate (A)"PRIV " 2767c478bd9Sstevel@tonic-gate }; 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate /* 2792e3b6467Skcpoon * universal tag definition 2807c478bd9Sstevel@tonic-gate */ 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate static A uclass[] = { /* universal tag assignment */ 2837c478bd9Sstevel@tonic-gate (A)"EndOfContents", /* 0 */ 2847c478bd9Sstevel@tonic-gate (A)"Boolean", /* 1 */ 2857c478bd9Sstevel@tonic-gate (A)"Integer", /* 2 */ 2867c478bd9Sstevel@tonic-gate (A)"BitString", /* 3 */ 2877c478bd9Sstevel@tonic-gate (A)"OctetString", /* 4 */ 2887c478bd9Sstevel@tonic-gate (A)"Null", /* 5 */ 2897c478bd9Sstevel@tonic-gate (A)"Oid", /* 6 */ 2907c478bd9Sstevel@tonic-gate (A)"ObjDescriptor", /* 7 */ 2917c478bd9Sstevel@tonic-gate (A)"External", /* 8 */ 2927c478bd9Sstevel@tonic-gate (A)"Real", /* 9 */ 2937c478bd9Sstevel@tonic-gate (A)"Enumerated", /* 10 */ 2947c478bd9Sstevel@tonic-gate (A)"Reserved", /* 11 */ 2957c478bd9Sstevel@tonic-gate (A)"Reserved", /* 12 */ 2967c478bd9Sstevel@tonic-gate (A)"Reserved", /* 13 */ 2977c478bd9Sstevel@tonic-gate (A)"Reserved", /* 14 */ 2987c478bd9Sstevel@tonic-gate (A)"Reserved", /* 15 */ 2997c478bd9Sstevel@tonic-gate (A)"Sequence", /* 16 */ 3007c478bd9Sstevel@tonic-gate (A)"Set", /* 17 */ 3017c478bd9Sstevel@tonic-gate (A)"NumericString", /* 18 */ 3027c478bd9Sstevel@tonic-gate (A)"PrintableString", /* 19 */ 3037c478bd9Sstevel@tonic-gate (A)"T.61String", /* 20 */ 3047c478bd9Sstevel@tonic-gate (A)"VideotexString", /* 21 */ 3057c478bd9Sstevel@tonic-gate (A)"IA5String", /* 22 */ 3067c478bd9Sstevel@tonic-gate (A)"UTCTime", /* 23 */ 3077c478bd9Sstevel@tonic-gate (A)"GeneralizedTime", /* 24 */ 3087c478bd9Sstevel@tonic-gate (A)"GraphicString", /* 25 */ 3097c478bd9Sstevel@tonic-gate (A)"VisibleString", /* 26 */ 3107c478bd9Sstevel@tonic-gate (A)"GeneralString", /* 27 */ 3117c478bd9Sstevel@tonic-gate (A)"Reserved", /* 28 */ 3127c478bd9Sstevel@tonic-gate (A)"Reserved", /* 29 */ 3137c478bd9Sstevel@tonic-gate (A)"Reserved", /* 30 */ 3147c478bd9Sstevel@tonic-gate (A)"Reserved" /* 31 */ 3157c478bd9Sstevel@tonic-gate }; 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate static A MHSaclass[] = { /* mhs application tag assignment */ 3187c478bd9Sstevel@tonic-gate (A)"Bind Request", /* 0 */ 3197c478bd9Sstevel@tonic-gate (A)"Bind Response", 3207c478bd9Sstevel@tonic-gate (A)"Unbind Request", 3217c478bd9Sstevel@tonic-gate (A)"Search Request", 3227c478bd9Sstevel@tonic-gate (A)"Search ResEntry", 3237c478bd9Sstevel@tonic-gate (A)"Search ResDone", /* 5 */ 3247c478bd9Sstevel@tonic-gate (A)"Modify Request", 3257c478bd9Sstevel@tonic-gate (A)"Modify Response", 3267c478bd9Sstevel@tonic-gate (A)"Add Request", 3277c478bd9Sstevel@tonic-gate (A)"Add Response", /* 9 */ 3287c478bd9Sstevel@tonic-gate (A)"Del Request", 3297c478bd9Sstevel@tonic-gate (A)"Del Response", 3307c478bd9Sstevel@tonic-gate (A)"ModDN Request", 3317c478bd9Sstevel@tonic-gate (A)"ModDN Response", 3327c478bd9Sstevel@tonic-gate (A)"Compare Request", /* 14 */ 3337c478bd9Sstevel@tonic-gate (A)"Compare Response", 3347c478bd9Sstevel@tonic-gate (A)"Abandon Request", 3357c478bd9Sstevel@tonic-gate (A)"", /* 17 */ 3367c478bd9Sstevel@tonic-gate (A)"", /* 18 */ 3377c478bd9Sstevel@tonic-gate (A)"Search ResRef", /* 19 */ 3387c478bd9Sstevel@tonic-gate (A)"", /* 20 */ 3397c478bd9Sstevel@tonic-gate (A)"", /* 21 */ 3407c478bd9Sstevel@tonic-gate (A)"", /* 22 */ 3417c478bd9Sstevel@tonic-gate (A)"Extended Request", 3427c478bd9Sstevel@tonic-gate (A)"Extended Response", 3437c478bd9Sstevel@tonic-gate (A)"", /* 25 */ 3447c478bd9Sstevel@tonic-gate (A)"", /* 26 */ 3457c478bd9Sstevel@tonic-gate (A)"", /* 27 */ 3467c478bd9Sstevel@tonic-gate (A)"", /* 28 */ 3477c478bd9Sstevel@tonic-gate (A)"", /* 29 */ 3487c478bd9Sstevel@tonic-gate (A)"", /* 30 */ 3497c478bd9Sstevel@tonic-gate (A)"" /* 31 */ 3507c478bd9Sstevel@tonic-gate }; 3517c478bd9Sstevel@tonic-gate 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate static A DFTaclass[] = { /* Default Application Tag Assignment */ 3547c478bd9Sstevel@tonic-gate (A)"", /* 0 */ 3557c478bd9Sstevel@tonic-gate (A)"", /* 1 */ 3567c478bd9Sstevel@tonic-gate (A)"", /* 2 */ 3577c478bd9Sstevel@tonic-gate (A)"", /* 3 */ 3587c478bd9Sstevel@tonic-gate (A)"", /* 4 */ 3597c478bd9Sstevel@tonic-gate (A)"", /* 5 */ 3607c478bd9Sstevel@tonic-gate (A)"", /* 6 */ 3617c478bd9Sstevel@tonic-gate (A)"", /* 7 */ 3627c478bd9Sstevel@tonic-gate (A)"", /* 8 */ 3637c478bd9Sstevel@tonic-gate (A)"", /* 9 */ 3647c478bd9Sstevel@tonic-gate (A)"", /* 10 */ 3657c478bd9Sstevel@tonic-gate (A)"", /* 11 */ 3667c478bd9Sstevel@tonic-gate (A)"", /* 12 */ 3677c478bd9Sstevel@tonic-gate (A)"", /* 13 */ 3687c478bd9Sstevel@tonic-gate (A)"", /* 14 */ 3697c478bd9Sstevel@tonic-gate (A)"", /* 15 */ 3707c478bd9Sstevel@tonic-gate (A)"", /* 16 */ 3717c478bd9Sstevel@tonic-gate (A)"", /* 17 */ 3727c478bd9Sstevel@tonic-gate (A)"", /* 18 */ 3737c478bd9Sstevel@tonic-gate (A)"", /* 19 */ 3747c478bd9Sstevel@tonic-gate (A)"", /* 20 */ 3757c478bd9Sstevel@tonic-gate (A)"", /* 21 */ 3767c478bd9Sstevel@tonic-gate (A)"", /* 22 */ 3777c478bd9Sstevel@tonic-gate (A)"", /* 23 */ 3787c478bd9Sstevel@tonic-gate (A)"", /* 24 */ 3797c478bd9Sstevel@tonic-gate (A)"", /* 25 */ 3807c478bd9Sstevel@tonic-gate (A)"", /* 26 */ 3817c478bd9Sstevel@tonic-gate (A)"", /* 27 */ 3827c478bd9Sstevel@tonic-gate (A)"", /* 28 */ 3837c478bd9Sstevel@tonic-gate (A)"", /* 29 */ 3847c478bd9Sstevel@tonic-gate (A)"", /* 30 */ 3857c478bd9Sstevel@tonic-gate (A)"" /* 31 */ 3867c478bd9Sstevel@tonic-gate }; 3877c478bd9Sstevel@tonic-gate 3887c478bd9Sstevel@tonic-gate typedef struct asndefS { 3897c478bd9Sstevel@tonic-gate char *name; 3907c478bd9Sstevel@tonic-gate int type; 3917c478bd9Sstevel@tonic-gate int application; 3927c478bd9Sstevel@tonic-gate int nbson; 3937c478bd9Sstevel@tonic-gate struct { 3947c478bd9Sstevel@tonic-gate char *sonname; 3957c478bd9Sstevel@tonic-gate struct asndefS *sondef; 3967c478bd9Sstevel@tonic-gate long tag; 3977c478bd9Sstevel@tonic-gate } son[50]; 3987c478bd9Sstevel@tonic-gate } asndefT, * asndefTp; 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate #define SEQUENCE 0x0002 4017c478bd9Sstevel@tonic-gate #define SEQUENCEOF 0x0003 4027c478bd9Sstevel@tonic-gate #define SET 0x0004 4037c478bd9Sstevel@tonic-gate #define PRINTABLE 0x0008 4047c478bd9Sstevel@tonic-gate #define ENUM 0x0010 4057c478bd9Sstevel@tonic-gate #define BITSTRING 0x0020 4067c478bd9Sstevel@tonic-gate #define EXTENSION 0x0040 4077c478bd9Sstevel@tonic-gate #define CONTENTTYPE 0x0080 4087c478bd9Sstevel@tonic-gate #define CONTENT 0x0100 4097c478bd9Sstevel@tonic-gate #define CHOICE 0x0200 4107c478bd9Sstevel@tonic-gate 4117c478bd9Sstevel@tonic-gate static asndefT RTSpasswd = { "RTS Authentification data", SET, -1, 2, { 4127c478bd9Sstevel@tonic-gate {"MTA Name", 0, 0}, 4137c478bd9Sstevel@tonic-gate {"MTA Password", 0, 1}}}; 4147c478bd9Sstevel@tonic-gate static asndefT RTSudata = { "RTS User data", SET, -1, 1, { 4157c478bd9Sstevel@tonic-gate {0, &RTSpasswd, 1}}}; 4167c478bd9Sstevel@tonic-gate 4177c478bd9Sstevel@tonic-gate static asndefT baseObject = {"Base Object", PRINTABLE, -1, 0, {0}}; 4187c478bd9Sstevel@tonic-gate 4197c478bd9Sstevel@tonic-gate static asndefT scope = {"Scope", ENUM, -1, 3, { 4207c478bd9Sstevel@tonic-gate {"BaseObject", 0, 0}, 4217c478bd9Sstevel@tonic-gate {"singleLevel", 0, 1}, 4227c478bd9Sstevel@tonic-gate {"wholeSubtree", 0, 2}}}; 4237c478bd9Sstevel@tonic-gate 4247c478bd9Sstevel@tonic-gate static asndefT derefAliases = {"DerefAliases", ENUM, -1, 4, { 4257c478bd9Sstevel@tonic-gate {"neverDerefAliases", 0, 0}, 4267c478bd9Sstevel@tonic-gate {"derefInSearching", 0, 1}, 4277c478bd9Sstevel@tonic-gate {"derefFindingBaseObj", 0, 2}, 4287c478bd9Sstevel@tonic-gate {"derefAlways", 0, 3}}}; 4297c478bd9Sstevel@tonic-gate 4307c478bd9Sstevel@tonic-gate static asndefT filter; 4317c478bd9Sstevel@tonic-gate static asndefT and = {"And", SET, -1, 1, { 4327c478bd9Sstevel@tonic-gate {0, &filter, -1}}}; 4337c478bd9Sstevel@tonic-gate static asndefT or = {"Or", SET, -1, 1, { 4347c478bd9Sstevel@tonic-gate {0, &filter, -1}}}; 4357c478bd9Sstevel@tonic-gate static asndefT not = {"Not", SET, -1, 1, { 4367c478bd9Sstevel@tonic-gate {0, &filter, -1}}}; 4377c478bd9Sstevel@tonic-gate static asndefT equalityMatch = {"Equality Match", SEQUENCE, -1, 2, { 4387c478bd9Sstevel@tonic-gate {"Attr Descr", 0, -1}, 4397c478bd9Sstevel@tonic-gate {"Value", 0, -1}}}; 4407c478bd9Sstevel@tonic-gate static asndefT substrings = {"Substring", SEQUENCE, -1, 2, { 4417c478bd9Sstevel@tonic-gate {"Type", 0, -1}, 4427c478bd9Sstevel@tonic-gate {"Substrings (initial)", 0, 0}, 4437c478bd9Sstevel@tonic-gate {"Substrings (any)", 0, 1}, 4447c478bd9Sstevel@tonic-gate {"Substring (final)", 0, 2}}}; 4457c478bd9Sstevel@tonic-gate static asndefT greaterOrEqual = {"Greater Or Equal", SEQUENCE, -1, 2, { 4467c478bd9Sstevel@tonic-gate {"Attr Descr", 0, -1}, 4477c478bd9Sstevel@tonic-gate {"Value", 0, -1}}}; 4487c478bd9Sstevel@tonic-gate static asndefT lessOrEqual = {"Less Or Equal", SEQUENCE, -1, 2, { 4497c478bd9Sstevel@tonic-gate {"Attr Descr", 0, -1}, 4507c478bd9Sstevel@tonic-gate {"Value", 0, -1}}}; 4517c478bd9Sstevel@tonic-gate static asndefT approxMatch = {"Approx Match", SEQUENCE, -1, 2, { 4527c478bd9Sstevel@tonic-gate {"Attr Descr", 0, -1}, 4537c478bd9Sstevel@tonic-gate {"Value", 0, -1}}}; 4547c478bd9Sstevel@tonic-gate static asndefT extensibleMatch = {"Extensible Match", SEQUENCE, -1, 4, { 4557c478bd9Sstevel@tonic-gate {"MatchingRule", 0, 1}, 4567c478bd9Sstevel@tonic-gate {"Type", 0, 2}, 4577c478bd9Sstevel@tonic-gate {"MatchValue", 0, 3}, 4587c478bd9Sstevel@tonic-gate {"dnAttributes", 0, 4}}}; 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate static asndefT filter = {"Filter", CHOICE, -1, 10, { 4617c478bd9Sstevel@tonic-gate {0, &and, 0}, 4627c478bd9Sstevel@tonic-gate {0, &or, 1}, 4637c478bd9Sstevel@tonic-gate {0, ¬, 2}, 4647c478bd9Sstevel@tonic-gate {0, &equalityMatch, 3}, 4657c478bd9Sstevel@tonic-gate {0, &substrings, 4}, 4667c478bd9Sstevel@tonic-gate {0, &greaterOrEqual, 5}, 4677c478bd9Sstevel@tonic-gate {0, &lessOrEqual, 6}, 4687c478bd9Sstevel@tonic-gate {"Filter: Present", 0, 7}, 4697c478bd9Sstevel@tonic-gate {0, &approxMatch, 8}, 4707c478bd9Sstevel@tonic-gate {0, &extensibleMatch, 9}}}; 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate static asndefT attributedescription = \ 4737c478bd9Sstevel@tonic-gate {"Attribute Description", PRINTABLE, -1, 0, {0}}; 4747c478bd9Sstevel@tonic-gate static asndefT attributes = {"Attribute List", SEQUENCEOF, -1, 1, { 4757c478bd9Sstevel@tonic-gate {0, &attributedescription, -1}}}; 4767c478bd9Sstevel@tonic-gate 4777c478bd9Sstevel@tonic-gate static asndefT searchRequest = {"Operation", SEQUENCE, 3, 8, { 4787c478bd9Sstevel@tonic-gate {0, &baseObject, -1}, 4797c478bd9Sstevel@tonic-gate {0, &scope, -1}, 4807c478bd9Sstevel@tonic-gate {0, &derefAliases, -1}, 4817c478bd9Sstevel@tonic-gate {"SizeLimit", 0, -1}, 4827c478bd9Sstevel@tonic-gate {"TimeLimit", 0, -1}, 4837c478bd9Sstevel@tonic-gate {"TypesOnly", 0, -1}, 4847c478bd9Sstevel@tonic-gate {0, &filter, -1}, 4857c478bd9Sstevel@tonic-gate {0, &attributes, -1}}}; 4867c478bd9Sstevel@tonic-gate 4877c478bd9Sstevel@tonic-gate static asndefT objectName = {"Object Name", PRINTABLE, -1, 0, {0}}; 4887c478bd9Sstevel@tonic-gate 4897c478bd9Sstevel@tonic-gate static asndefT ldapEntry = {"Entry", PRINTABLE, -1, 0, {0}}; 4907c478bd9Sstevel@tonic-gate static asndefT relativeLdapEntry = \ 4917c478bd9Sstevel@tonic-gate {"Relative LDAP Entry", PRINTABLE, -1, 0, {0}}; 4927c478bd9Sstevel@tonic-gate static asndefT newSuperior = {"New Superior", PRINTABLE, -1, 0, {0}}; 4937c478bd9Sstevel@tonic-gate 4947c478bd9Sstevel@tonic-gate static asndefT vals = {"Vals", SET, -1, 1, { 4957c478bd9Sstevel@tonic-gate {"Value", 0, -1}}}; 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate static asndefT attribute = {"Attribute", SEQUENCE, -1, 2, { 4987c478bd9Sstevel@tonic-gate {"Type", 0, -1}, 4997c478bd9Sstevel@tonic-gate {0, &vals, -1}}}; 5007c478bd9Sstevel@tonic-gate 5017c478bd9Sstevel@tonic-gate static asndefT partialAttributes = {"Partial Attributes", SEQUENCEOF, -1, 1, { 5027c478bd9Sstevel@tonic-gate {0, &attribute, -1}}}; 5037c478bd9Sstevel@tonic-gate 5047c478bd9Sstevel@tonic-gate static asndefT searchResEntry = {"Operation", SEQUENCE, 4, 2, { 5057c478bd9Sstevel@tonic-gate {0, &objectName, -1}, 5067c478bd9Sstevel@tonic-gate {0, &partialAttributes, -1}}}; 5077c478bd9Sstevel@tonic-gate 5087c478bd9Sstevel@tonic-gate static asndefT authChoice = {"Authentication Choice", CHOICE, -1, 2, { 5097c478bd9Sstevel@tonic-gate {"Authentication: Simple", 0, 0}, 5107c478bd9Sstevel@tonic-gate {"Authentication: SASL", 0, 3}}}; 5117c478bd9Sstevel@tonic-gate 5127c478bd9Sstevel@tonic-gate static asndefT bindRequest = {"Operation", SEQUENCE, 0, 3, { 5137c478bd9Sstevel@tonic-gate {"Version", 0, -1}, 5147c478bd9Sstevel@tonic-gate {0, &objectName, -1}, 5157c478bd9Sstevel@tonic-gate {0, &authChoice, -1}}}; 5167c478bd9Sstevel@tonic-gate 5177c478bd9Sstevel@tonic-gate static asndefT resultCode = {"Result Code", ENUM, -1, 39, { 5187c478bd9Sstevel@tonic-gate {"Success", 0, 0}, 5197c478bd9Sstevel@tonic-gate {"Operation Error", 0, 1}, 5207c478bd9Sstevel@tonic-gate {"Protocol Error", 0, 2}, 5217c478bd9Sstevel@tonic-gate {"Time Limit Exceeded", 0, 3}, 5227c478bd9Sstevel@tonic-gate {"Size Limit Exceeded", 0, 4}, 5237c478bd9Sstevel@tonic-gate {"Compare False", 0, 5}, 5247c478bd9Sstevel@tonic-gate {"Compare True", 0, 6}, 5257c478bd9Sstevel@tonic-gate {"Auth Method Not supported", 0, 7}, 5267c478bd9Sstevel@tonic-gate {"Strong Auth Required", 0, 8}, 5277c478bd9Sstevel@tonic-gate {"Referral", 0, 10}, 5287c478bd9Sstevel@tonic-gate {"Admin Limit Exceeded", 0, 11}, 5297c478bd9Sstevel@tonic-gate {"Unavailable Critical Extension", 0, 12}, 5307c478bd9Sstevel@tonic-gate {"Confidentiality required", 0, 13}, 5317c478bd9Sstevel@tonic-gate {"SASL Bind In Progress", 0, 14}, 5327c478bd9Sstevel@tonic-gate {"No Such Attribute", 0, 16}, 5337c478bd9Sstevel@tonic-gate {"Undefined Attribute Type", 0, 17}, 5347c478bd9Sstevel@tonic-gate {"Inappropriate Matching", 0, 18}, 5357c478bd9Sstevel@tonic-gate {"Constraint violation", 0, 19}, 5367c478bd9Sstevel@tonic-gate {"Attribute or Value Exists", 0, 20}, 5377c478bd9Sstevel@tonic-gate {"Invalid Attribute Syntax", 0, 21}, 5387c478bd9Sstevel@tonic-gate {"No Such Object", 0, 32}, 5397c478bd9Sstevel@tonic-gate {"Alias Problem", 0, 33}, 5407c478bd9Sstevel@tonic-gate {"Invalid DN Syntax", 0, 34}, 5417c478bd9Sstevel@tonic-gate {"Alias Dereferencing Problem", 0, 36}, 5427c478bd9Sstevel@tonic-gate {"Inappropriate Authentication", 0, 48}, 5437c478bd9Sstevel@tonic-gate {"Invalid Credentials", 0, 49}, 5447c478bd9Sstevel@tonic-gate {"Insufficient Access Rights", 0, 50}, 5457c478bd9Sstevel@tonic-gate {"Busy", 0, 51}, 5467c478bd9Sstevel@tonic-gate {"Unavailable", 0, 52}, 5477c478bd9Sstevel@tonic-gate {"Unwilling To Perform", 0, 53}, 5487c478bd9Sstevel@tonic-gate {"Loop Detect", 0, 54}, 5497c478bd9Sstevel@tonic-gate {"Naming Violation", 0, 64}, 5507c478bd9Sstevel@tonic-gate {"ObjectClass violation", 0, 65}, 5517c478bd9Sstevel@tonic-gate {"Not Allowed On Non Leaf", 0, 66}, 5527c478bd9Sstevel@tonic-gate {"Not Allowed On RDN", 0, 67}, 5537c478bd9Sstevel@tonic-gate {"Entry Already Exists", 0, 68}, 5547c478bd9Sstevel@tonic-gate {"ObjectClass Mods Prohibited", 0, 69}, 5557c478bd9Sstevel@tonic-gate {"Affects Multiple DSAs", 0, 71}, 5567c478bd9Sstevel@tonic-gate {"Other", 0, 80}}}; 5577c478bd9Sstevel@tonic-gate 5587c478bd9Sstevel@tonic-gate 5597c478bd9Sstevel@tonic-gate static asndefT referral = {"Referral", SEQUENCEOF, -1, 1, { 5607c478bd9Sstevel@tonic-gate {"LDAP URL", 0, -1}}}; 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate static asndefT ldapResult = {"LDAP Result", SEQUENCE, -1, 4, { 5637c478bd9Sstevel@tonic-gate {0, &resultCode, -1}, 5647c478bd9Sstevel@tonic-gate {"Matched DN", 0, -1}, 5657c478bd9Sstevel@tonic-gate {"Error Message", 0, -1}, 5667c478bd9Sstevel@tonic-gate {0, &referral, 3}}}; 5677c478bd9Sstevel@tonic-gate 5687c478bd9Sstevel@tonic-gate static asndefT bindResponse = {"Operation", SEQUENCE, 1, 5, { 5697c478bd9Sstevel@tonic-gate {0, &resultCode, -1}, 5707c478bd9Sstevel@tonic-gate {"Matched DN", 0, -1}, 5717c478bd9Sstevel@tonic-gate {"Error Message", 0, -1}, 5727c478bd9Sstevel@tonic-gate {0, &referral, 3}, 5737c478bd9Sstevel@tonic-gate {"SASL Credentials", 0, 7}}}; 5747c478bd9Sstevel@tonic-gate 5757c478bd9Sstevel@tonic-gate static asndefT unbindRequest = {"Operation", SEQUENCE, 2, 0, {0}}; 5767c478bd9Sstevel@tonic-gate 5777c478bd9Sstevel@tonic-gate static asndefT searchResDone = {"Operation", SEQUENCE, 5, 4, { 5787c478bd9Sstevel@tonic-gate {0, &resultCode, -1}, 5797c478bd9Sstevel@tonic-gate {"Matched DN", 0, -1}, 5807c478bd9Sstevel@tonic-gate {"Error Message", 0, -1}, 5817c478bd9Sstevel@tonic-gate {0, &referral, 3}}}; 5827c478bd9Sstevel@tonic-gate 5837c478bd9Sstevel@tonic-gate static asndefT seqModOperation = {"Operation", ENUM, -1, 4, { 5847c478bd9Sstevel@tonic-gate {"Add", 0, 0}, 5857c478bd9Sstevel@tonic-gate {"Delete", 0, 1}, 5867c478bd9Sstevel@tonic-gate {"Replace", 0, 2}}}; 5877c478bd9Sstevel@tonic-gate 5887c478bd9Sstevel@tonic-gate static asndefT seqModModification = {"Modification", SEQUENCE, -1, 1, { 5897c478bd9Sstevel@tonic-gate {0, &attribute, -1}}}; 5907c478bd9Sstevel@tonic-gate 5917c478bd9Sstevel@tonic-gate static asndefT seqModification = {"", SEQUENCE, -1, 2, { 5927c478bd9Sstevel@tonic-gate {0, &seqModOperation, -1}, 5937c478bd9Sstevel@tonic-gate {0, &seqModModification, -1}}}; 5947c478bd9Sstevel@tonic-gate 5957c478bd9Sstevel@tonic-gate static asndefT modification = {"Modification", SEQUENCEOF, -1, 1, { 5967c478bd9Sstevel@tonic-gate {0, &seqModification, -1}}}; 5977c478bd9Sstevel@tonic-gate 5987c478bd9Sstevel@tonic-gate static asndefT modifyRequest = {"Operation", SEQUENCE, 6, 2, { 5997c478bd9Sstevel@tonic-gate {0, &objectName, -1}, 6007c478bd9Sstevel@tonic-gate {0, &modification, -1}}}; 6017c478bd9Sstevel@tonic-gate 6027c478bd9Sstevel@tonic-gate static asndefT modifyResponse = {"Operation", SEQUENCE, 7, 4, { 6037c478bd9Sstevel@tonic-gate {0, &resultCode, -1}, 6047c478bd9Sstevel@tonic-gate {"Matched DN", 0, -1}, 6057c478bd9Sstevel@tonic-gate {"Error Message", 0, -1}, 6067c478bd9Sstevel@tonic-gate {0, &referral, 3}}}; 6077c478bd9Sstevel@tonic-gate 6087c478bd9Sstevel@tonic-gate static asndefT addAttributes = {"Attributes", SEQUENCEOF, -1, 1, { 6097c478bd9Sstevel@tonic-gate {0, &attribute, -1}}}; 6107c478bd9Sstevel@tonic-gate 6117c478bd9Sstevel@tonic-gate static asndefT addRequest = {"Operation", SEQUENCE, 8, 2, { 6127c478bd9Sstevel@tonic-gate {0, &ldapEntry, -1}, 6137c478bd9Sstevel@tonic-gate {0, &addAttributes, -1}}}; 6147c478bd9Sstevel@tonic-gate 6157c478bd9Sstevel@tonic-gate static asndefT addResponse = {"Operation", SEQUENCE, 9, 4, { 6167c478bd9Sstevel@tonic-gate {0, &resultCode, -1}, 6177c478bd9Sstevel@tonic-gate {"Matched DN", 0, -1}, 6187c478bd9Sstevel@tonic-gate {"Error Message", 0, -1}, 6197c478bd9Sstevel@tonic-gate {0, &referral, 3}}}; 6207c478bd9Sstevel@tonic-gate 6217c478bd9Sstevel@tonic-gate static asndefT delRequest = {"Operation", SEQUENCE, 10, 1, { 6227c478bd9Sstevel@tonic-gate {0, &ldapEntry, -1}}}; 6237c478bd9Sstevel@tonic-gate 6247c478bd9Sstevel@tonic-gate static asndefT delResponse = {"Operation", SEQUENCE, 11, 4, { 6257c478bd9Sstevel@tonic-gate {0, &resultCode, -1}, 6267c478bd9Sstevel@tonic-gate {"Matched DN", 0, -1}, 6277c478bd9Sstevel@tonic-gate {"Error Message", 0, -1}, 6287c478bd9Sstevel@tonic-gate {0, &referral, 3}}}; 6297c478bd9Sstevel@tonic-gate 6307c478bd9Sstevel@tonic-gate static asndefT modifyDNRequest = {"Operation", SEQUENCE, 12, 4, { 6317c478bd9Sstevel@tonic-gate {0, &ldapEntry, -1}, 6327c478bd9Sstevel@tonic-gate {0, &relativeLdapEntry, -1}, 6337c478bd9Sstevel@tonic-gate {"Delete Old RDN", 0, -1}, 6347c478bd9Sstevel@tonic-gate {0, &newSuperior, 0}}}; 6357c478bd9Sstevel@tonic-gate 6367c478bd9Sstevel@tonic-gate static asndefT modifyDNResponse = {"Operation", SEQUENCE, 13, 4, { 6377c478bd9Sstevel@tonic-gate {0, &resultCode, -1}, 6387c478bd9Sstevel@tonic-gate {"Matched DN", 0, -1}, 6397c478bd9Sstevel@tonic-gate {"Error Message", 0, -1}, 6407c478bd9Sstevel@tonic-gate {0, &referral, 3}}}; 6417c478bd9Sstevel@tonic-gate 6427c478bd9Sstevel@tonic-gate static asndefT ava = {"Ava", SEQUENCE, -1, 2, { 6437c478bd9Sstevel@tonic-gate {"Attr Descr", 0, -1}, 6447c478bd9Sstevel@tonic-gate {"Value", 0, -1}}}; 6457c478bd9Sstevel@tonic-gate 6467c478bd9Sstevel@tonic-gate static asndefT compareRequest = {"Operation", SEQUENCE, 14, 2, { 6477c478bd9Sstevel@tonic-gate {0, &ldapEntry, -1}, 6487c478bd9Sstevel@tonic-gate {0, &ava, 0}}}; 6497c478bd9Sstevel@tonic-gate 6507c478bd9Sstevel@tonic-gate static asndefT compareResponse = {"Operation", SEQUENCE, 15, 4, { 6517c478bd9Sstevel@tonic-gate {0, &resultCode, -1}, 6527c478bd9Sstevel@tonic-gate {"Matched DN", 0, -1}, 6537c478bd9Sstevel@tonic-gate {"Error Message", 0, -1}, 6547c478bd9Sstevel@tonic-gate {0, &referral, 3}}}; 6557c478bd9Sstevel@tonic-gate 6567c478bd9Sstevel@tonic-gate static asndefT abandonRequest = {"Operation", SEQUENCE, 16, 1, { 6577c478bd9Sstevel@tonic-gate {"Message ID", 0, -1}}}; 6587c478bd9Sstevel@tonic-gate 6597c478bd9Sstevel@tonic-gate static asndefT searchResRef = {"Operation", SEQUENCEOF, 19, 1, { 6607c478bd9Sstevel@tonic-gate {"LDAP URL", 0, -1}}}; 6617c478bd9Sstevel@tonic-gate 6627c478bd9Sstevel@tonic-gate static asndefT extendedRequest = {"Operation", SEQUENCE, 14, 2, { 6637c478bd9Sstevel@tonic-gate {"Request Name", 0, 0}, 6647c478bd9Sstevel@tonic-gate {"Request Value", 0, 1}}}; 6657c478bd9Sstevel@tonic-gate 6667c478bd9Sstevel@tonic-gate static asndefT extendedResponse = {"Operation", SEQUENCE, 24, 6, { 6677c478bd9Sstevel@tonic-gate {0, &resultCode, -1}, 6687c478bd9Sstevel@tonic-gate {"Matched DN", 0, -1}, 6697c478bd9Sstevel@tonic-gate {"Error Message", 0, -1}, 6707c478bd9Sstevel@tonic-gate {0, &referral, 3}, 6717c478bd9Sstevel@tonic-gate {"Response Name", 0, 10}, 6727c478bd9Sstevel@tonic-gate {"Response", 0, 11}}}; 6737c478bd9Sstevel@tonic-gate 6747c478bd9Sstevel@tonic-gate static asndefT protocolOp = {"Protocol Op", CHOICE, -1, 20, { 6757c478bd9Sstevel@tonic-gate {0, &bindRequest, 0}, 6767c478bd9Sstevel@tonic-gate {0, &bindResponse, 1}, 6777c478bd9Sstevel@tonic-gate {0, &unbindRequest, 2}, 6787c478bd9Sstevel@tonic-gate {0, &searchRequest, 3}, 6797c478bd9Sstevel@tonic-gate {0, &searchResEntry, 4}, 6807c478bd9Sstevel@tonic-gate {0, &searchResDone, 5}, 6817c478bd9Sstevel@tonic-gate {0, &modifyRequest, 6}, 6827c478bd9Sstevel@tonic-gate {0, &modifyResponse, 7}, 6837c478bd9Sstevel@tonic-gate {0, &addRequest, 8}, 6847c478bd9Sstevel@tonic-gate {0, &addResponse, 9}, 6857c478bd9Sstevel@tonic-gate {0, &delRequest, 10}, 6867c478bd9Sstevel@tonic-gate {0, &delResponse, 11}, 6877c478bd9Sstevel@tonic-gate {0, &modifyDNRequest, 12}, 6887c478bd9Sstevel@tonic-gate {0, &modifyDNResponse, 13}, 6897c478bd9Sstevel@tonic-gate {0, &compareRequest, 14}, 6907c478bd9Sstevel@tonic-gate {0, &compareResponse, 15}, 6917c478bd9Sstevel@tonic-gate {0, &abandonRequest, 16}, 6927c478bd9Sstevel@tonic-gate {0, &searchResRef, 19}, 6937c478bd9Sstevel@tonic-gate {0, &extendedRequest, 23}, 6947c478bd9Sstevel@tonic-gate {0, &extendedResponse, 24}}}; 6957c478bd9Sstevel@tonic-gate 6967c478bd9Sstevel@tonic-gate static asndefT control = {"Control", SEQUENCE, -1, 3, { 6977c478bd9Sstevel@tonic-gate {"LDAP OID", 0, -1}, 6987c478bd9Sstevel@tonic-gate {"Criticality", 0, -1}, 6997c478bd9Sstevel@tonic-gate {"Control value", 0, -1}}}; 7007c478bd9Sstevel@tonic-gate 7017c478bd9Sstevel@tonic-gate static asndefT controls = {"Controls List", SEQUENCEOF, -1, 1, { 7027c478bd9Sstevel@tonic-gate {0, &control, -1}}}; 7037c478bd9Sstevel@tonic-gate 7047c478bd9Sstevel@tonic-gate static asndefT LDAPMessage = { "LDAPMessage", SEQUENCE, -1, 3, { 7057c478bd9Sstevel@tonic-gate {"Message ID", 0, -1}, 7067c478bd9Sstevel@tonic-gate {0, &protocolOp, -1}, 7077c478bd9Sstevel@tonic-gate {0, &controls, 0}}}; 7087c478bd9Sstevel@tonic-gate 7097c478bd9Sstevel@tonic-gate static asndefT MPDU = { "MPDU", SET, -1, 1, 7107c478bd9Sstevel@tonic-gate {{0, &LDAPMessage, 0}}}; 7117c478bd9Sstevel@tonic-gate 7127c478bd9Sstevel@tonic-gate static int mytype[] = { 7137c478bd9Sstevel@tonic-gate 0, /* EndOfContents */ 7147c478bd9Sstevel@tonic-gate 0, /* Boolean */ 7157c478bd9Sstevel@tonic-gate 0, /* Integer */ 7167c478bd9Sstevel@tonic-gate BITSTRING, /* BitString */ 7177c478bd9Sstevel@tonic-gate 0, /* OctetString */ 7187c478bd9Sstevel@tonic-gate 0, /* Null */ 7197c478bd9Sstevel@tonic-gate 0, /* Oid */ 7207c478bd9Sstevel@tonic-gate 0, /* ObjDescriptor */ 7217c478bd9Sstevel@tonic-gate 0, /* External */ 7227c478bd9Sstevel@tonic-gate 0, /* Real */ 7237c478bd9Sstevel@tonic-gate ENUM, /* Enumerated */ 7247c478bd9Sstevel@tonic-gate 0, /* Reserved */ 7257c478bd9Sstevel@tonic-gate 0, /* Reserved */ 7267c478bd9Sstevel@tonic-gate 0, /* Reserved */ 7277c478bd9Sstevel@tonic-gate 0, /* Reserved */ 7287c478bd9Sstevel@tonic-gate 0, /* Reserved */ 7297c478bd9Sstevel@tonic-gate SEQUENCE, /* Sequence */ 7307c478bd9Sstevel@tonic-gate SET, /* Set */ 7317c478bd9Sstevel@tonic-gate 0, /* NumericString */ 7327c478bd9Sstevel@tonic-gate 0, /* PrintableString */ 7337c478bd9Sstevel@tonic-gate 0, /* T.61String */ 7347c478bd9Sstevel@tonic-gate 0, /* VideotexString */ 7357c478bd9Sstevel@tonic-gate 0, /* IA5String */ 7367c478bd9Sstevel@tonic-gate 0, /* UTCTime */ 7377c478bd9Sstevel@tonic-gate 0, /* GeneralizedTime */ 7387c478bd9Sstevel@tonic-gate 0, /* GraphicString */ 7397c478bd9Sstevel@tonic-gate 0, /* VisibleString */ 7407c478bd9Sstevel@tonic-gate 0, /* GeneralString */ 7417c478bd9Sstevel@tonic-gate 0, /* Reserved */ 7427c478bd9Sstevel@tonic-gate 0, /* Reserved */ 7437c478bd9Sstevel@tonic-gate 0, /* Reserved */ 7447c478bd9Sstevel@tonic-gate 0, /* Reserved */ 7457c478bd9Sstevel@tonic-gate }; 7467c478bd9Sstevel@tonic-gate 7477c478bd9Sstevel@tonic-gate /* 7482e3b6467Skcpoon * Find object identifier in known oid table 7492e3b6467Skcpoon * A oid - oid hexa string 7502e3b6467Skcpoon * int olg - oid length 7517c478bd9Sstevel@tonic-gate */ 7522e3b6467Skcpoon static int 7532e3b6467Skcpoon oidmap(A oid, int olg) 7547c478bd9Sstevel@tonic-gate { 7557c478bd9Sstevel@tonic-gate register int ix, goon; 7567c478bd9Sstevel@tonic-gate register A oidptr, tabptr, tabend; 7577c478bd9Sstevel@tonic-gate 7587c478bd9Sstevel@tonic-gate /* returns (oid table size) if not found */ 7597c478bd9Sstevel@tonic-gate 7607c478bd9Sstevel@tonic-gate for (ix = 0; ix < OIDNB; ix++) { 7617c478bd9Sstevel@tonic-gate oidptr = oid; tabptr = (&(OidTab[ix].oidcode[0])); 7627c478bd9Sstevel@tonic-gate if (olg == INT(*tabptr++)) { 7632e3b6467Skcpoon tabend = tabptr + olg; 7642e3b6467Skcpoon goon = 1; 7652e3b6467Skcpoon while (goon != 0 && tabptr < tabend) { 7662e3b6467Skcpoon if (*tabptr++ != *oidptr++) 7672e3b6467Skcpoon goon = 0; 7687c478bd9Sstevel@tonic-gate } 7692e3b6467Skcpoon if (goon != 0) 7707c478bd9Sstevel@tonic-gate return (ix); 7717c478bd9Sstevel@tonic-gate } 7727c478bd9Sstevel@tonic-gate } 7737c478bd9Sstevel@tonic-gate return (OIDNB); 7747c478bd9Sstevel@tonic-gate } 7757c478bd9Sstevel@tonic-gate 7767c478bd9Sstevel@tonic-gate /* 7772e3b6467Skcpoon * Read an hexacode and convert it into ASCII 7787c478bd9Sstevel@tonic-gate */ 7797c478bd9Sstevel@tonic-gate static int getnext(int ctxnum) 7807c478bd9Sstevel@tonic-gate { 7817c478bd9Sstevel@tonic-gate static X c[3]; /* c[0-3] will contain ascii values on exit */ 7827c478bd9Sstevel@tonic-gate hex = 0; 7837c478bd9Sstevel@tonic-gate if (gi_osibuf[ctxnum] == osilen) 7847c478bd9Sstevel@tonic-gate return (-1); 7857c478bd9Sstevel@tonic-gate hex = osibuff[gi_osibuf[ctxnum]++]; 7867c478bd9Sstevel@tonic-gate (void) sprintf((char *)c, "%02x", (hex&0x00FF)); 7877c478bd9Sstevel@tonic-gate return (0); 7887c478bd9Sstevel@tonic-gate } 7897c478bd9Sstevel@tonic-gate 7907c478bd9Sstevel@tonic-gate /* 7912e3b6467Skcpoon * Skip everything that is not an LDAPMessage 7927c478bd9Sstevel@tonic-gate */ 7937c478bd9Sstevel@tonic-gate static char *skipjunk(len, pdu) 7947c478bd9Sstevel@tonic-gate int len; 7957c478bd9Sstevel@tonic-gate char *pdu; 7967c478bd9Sstevel@tonic-gate { 7977c478bd9Sstevel@tonic-gate int tag; 7987c478bd9Sstevel@tonic-gate char *buf = pdu; 7997c478bd9Sstevel@tonic-gate int offset = 0; 8007c478bd9Sstevel@tonic-gate while (len > 0) { 8017c478bd9Sstevel@tonic-gate /* size minumum for a sequence + integer = 5 */ 8027c478bd9Sstevel@tonic-gate /* LDAPMessage::= SEQUENCE */ 8037c478bd9Sstevel@tonic-gate if ((len > 5) && (buf[0] == 0x30)) { 8047c478bd9Sstevel@tonic-gate tag = buf[1]&0x00ff; 8057c478bd9Sstevel@tonic-gate if (tag < 0x80) { 8067c478bd9Sstevel@tonic-gate /* length is one one octet */ 8077c478bd9Sstevel@tonic-gate offset = 1; 8087c478bd9Sstevel@tonic-gate } else { 8097c478bd9Sstevel@tonic-gate /* length is multiple octet. */ 8107c478bd9Sstevel@tonic-gate offset = 1+ tag&0x007f; 8117c478bd9Sstevel@tonic-gate } 8127c478bd9Sstevel@tonic-gate /* Make sure we don't read past the end */ 8137c478bd9Sstevel@tonic-gate /* of the buffer */ 8147c478bd9Sstevel@tonic-gate if (len - (1+offset) > 0) { 8157c478bd9Sstevel@tonic-gate /* skip after the length */ 8167c478bd9Sstevel@tonic-gate tag = buf[1+offset]&0x00ff; 8177c478bd9Sstevel@tonic-gate if (tag == 0x02) { /* INTEGER */ 8187c478bd9Sstevel@tonic-gate /* looks like a valid PDU */ 8197c478bd9Sstevel@tonic-gate return (buf); 8207c478bd9Sstevel@tonic-gate } 8217c478bd9Sstevel@tonic-gate } 8227c478bd9Sstevel@tonic-gate } 8237c478bd9Sstevel@tonic-gate len --; 8247c478bd9Sstevel@tonic-gate buf++; 8257c478bd9Sstevel@tonic-gate } 8267c478bd9Sstevel@tonic-gate return (buf); 8277c478bd9Sstevel@tonic-gate } 8282e3b6467Skcpoon 8292e3b6467Skcpoon 8307c478bd9Sstevel@tonic-gate #define GETNEXT(a) (void)getnext(a); 8312e3b6467Skcpoon 8322e3b6467Skcpoon /* 8332e3b6467Skcpoon * main routine: decode a TLV; to be called recursively 8342e3b6467Skcpoon * 8352e3b6467Skcpoon * pdulen: current pdu's length 8362e3b6467Skcpoon */ 8372e3b6467Skcpoon static int 8382e3b6467Skcpoon decpdu(int pdulen, asndefTp ASNDESC, int ctxnum) 8397c478bd9Sstevel@tonic-gate { 8407c478bd9Sstevel@tonic-gate X scrlin[99]; /* screen line */ 8417c478bd9Sstevel@tonic-gate X oidstr[80]; /* oid hexa string */ 8427c478bd9Sstevel@tonic-gate int slen; /* screen line length */ 8437c478bd9Sstevel@tonic-gate int stlv; /* sub-tlv length */ 8447c478bd9Sstevel@tonic-gate int oix; /* oid table index */ 8457c478bd9Sstevel@tonic-gate int effnb; /* effectively traced octet nb */ 846*166fae49Spk34663 int i = 0, j = 0; 8477c478bd9Sstevel@tonic-gate int ai = -2; 8487c478bd9Sstevel@tonic-gate asndefTp SASNDESC = 0; 8497c478bd9Sstevel@tonic-gate asndefTp TMPDESC = 0; 8507c478bd9Sstevel@tonic-gate asndefTp GR_TMPDESC = 0; 8517c478bd9Sstevel@tonic-gate int tmpai = 0; 8527c478bd9Sstevel@tonic-gate int gr_tmpai = 0; 8537c478bd9Sstevel@tonic-gate int dontprint = 0; 8547c478bd9Sstevel@tonic-gate int already = 0; 8557c478bd9Sstevel@tonic-gate static int rlen = 0; /* tlv's real length */ 8567c478bd9Sstevel@tonic-gate 8577c478bd9Sstevel@tonic-gate ++level[ctxnum]; /* level indicator */ 8587c478bd9Sstevel@tonic-gate effnb = 0; 8597c478bd9Sstevel@tonic-gate 8607c478bd9Sstevel@tonic-gate /* 8612e3b6467Skcpoon * Decode the current TLV segment 8627c478bd9Sstevel@tonic-gate */ 8637c478bd9Sstevel@tonic-gate while (pdulen > 1) { 8647c478bd9Sstevel@tonic-gate 8657c478bd9Sstevel@tonic-gate if (getnext(ctxnum)) { 8667c478bd9Sstevel@tonic-gate break; 8677c478bd9Sstevel@tonic-gate } 8687c478bd9Sstevel@tonic-gate if (strlen(scrbuffer)) asnshw2("%s ", "LDAP:"); 8697c478bd9Sstevel@tonic-gate /* screen printing according to level indicator */ 8707c478bd9Sstevel@tonic-gate for (i = 1; i < level[ctxnum]; ++i) asnshw1(" "); 8717c478bd9Sstevel@tonic-gate 8727c478bd9Sstevel@tonic-gate /* get tag */ 8737c478bd9Sstevel@tonic-gate otyp[ctxnum] = INT(hex); /* single octet type only */ 8747c478bd9Sstevel@tonic-gate --pdulen; 8757c478bd9Sstevel@tonic-gate ++effnb; 8767c478bd9Sstevel@tonic-gate 8777c478bd9Sstevel@tonic-gate /* get length */ 8787c478bd9Sstevel@tonic-gate GETNEXT(ctxnum); 8797c478bd9Sstevel@tonic-gate olen[ctxnum] = INT(hex); /* tlv length */ 8807c478bd9Sstevel@tonic-gate --pdulen; 8817c478bd9Sstevel@tonic-gate ++effnb; 8827c478bd9Sstevel@tonic-gate 8837c478bd9Sstevel@tonic-gate /* Continuing decoding of current TLV... */ 8847c478bd9Sstevel@tonic-gate /* 8852e3b6467Skcpoon * Snoop's lower layers do not allow us 8862e3b6467Skcpoon * to know the true length for 8872e3b6467Skcpoon * datastream protocols like LDAP. 8887c478bd9Sstevel@tonic-gate */ 8897c478bd9Sstevel@tonic-gate 8902e3b6467Skcpoon /* 8912e3b6467Skcpoon * if length is less than 128, we 8922e3b6467Skcpoon * already have the real TLV length. 8932e3b6467Skcpoon */ 8947c478bd9Sstevel@tonic-gate if (olen[ctxnum] < 128) { /* short length form */ 8957c478bd9Sstevel@tonic-gate rlen = olen[ctxnum]; 8967c478bd9Sstevel@tonic-gate } else { /* long and any form length */ 8977c478bd9Sstevel@tonic-gate /* else we do more getnext()'s */ 8987c478bd9Sstevel@tonic-gate for (rlen = 0, olen[ctxnum] &= 0x0F; 8997c478bd9Sstevel@tonic-gate (olen[ctxnum]) && (pdulen > 0); 9007c478bd9Sstevel@tonic-gate --olen[ctxnum], --pdulen, ++effnb) { 9017c478bd9Sstevel@tonic-gate GETNEXT(ctxnum); 9027c478bd9Sstevel@tonic-gate rlen = (rlen << 8) | INT(hex); 9037c478bd9Sstevel@tonic-gate } 9047c478bd9Sstevel@tonic-gate if (!rlen) { 9057c478bd9Sstevel@tonic-gate pdulen = 0x7fffffff; 9067c478bd9Sstevel@tonic-gate } 9077c478bd9Sstevel@tonic-gate } 9087c478bd9Sstevel@tonic-gate 9097c478bd9Sstevel@tonic-gate /* 9102e3b6467Skcpoon * print the tag class and number 9117c478bd9Sstevel@tonic-gate */ 9127c478bd9Sstevel@tonic-gate i = otyp[ctxnum]&0x1F; 9137c478bd9Sstevel@tonic-gate switch (otyp[ctxnum] >> 6) { /* class */ 9147c478bd9Sstevel@tonic-gate case 0: /* universal */ 9157c478bd9Sstevel@tonic-gate if (ASNDESC && i != 0) { 9167c478bd9Sstevel@tonic-gate int dobreak = 0; 9177c478bd9Sstevel@tonic-gate switch (ASNDESC->type) { 9187c478bd9Sstevel@tonic-gate case CONTENT: 9197c478bd9Sstevel@tonic-gate SASNDESC = ASNDESC; 9207c478bd9Sstevel@tonic-gate break; 9217c478bd9Sstevel@tonic-gate case SET: 9227c478bd9Sstevel@tonic-gate for (ai = 0; 9237c478bd9Sstevel@tonic-gate ai < ASNDESC->nbson && i < 32 && 9247c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef && 9257c478bd9Sstevel@tonic-gate /* 9262e3b6467Skcpoon * For this test SEQUENCE & SEQUENCE OF 9272e3b6467Skcpoon * are same, so suppress the last bit 9287c478bd9Sstevel@tonic-gate */ 9297c478bd9Sstevel@tonic-gate (ASNDESC->son[ai].sondef 9307c478bd9Sstevel@tonic-gate ->type&0xFE) 9317c478bd9Sstevel@tonic-gate != mytype[i]; ++ai); 9327c478bd9Sstevel@tonic-gate if (ai < ASNDESC->nbson) { 9337c478bd9Sstevel@tonic-gate SASNDESC = 9347c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef; 9352e3b6467Skcpoon if (ASNDESC->son[ai].sonname != NULL) { 9362e3b6467Skcpoon 9372e3b6467Skcpoon if (ASNDESC->son[ai].sondef != NULL && 9382e3b6467Skcpoon ASNDESC->son[ai].sondef->name != 9392e3b6467Skcpoon NULL) { 9402e3b6467Skcpoon asnshw2("%s ", "LDAP:"); 9412e3b6467Skcpoon asnshw4(" %c[%s %s]", 9422e3b6467Skcpoon ((otyp[ctxnum]&0x20)?'*':' '), 9432e3b6467Skcpoon ASNDESC->son[ai].sonname, 9447c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name); 9457c478bd9Sstevel@tonic-gate } else { 9462e3b6467Skcpoon asnshw2("%s ", ""); 9472e3b6467Skcpoon asnshw3(" %c[%s]", 9487c478bd9Sstevel@tonic-gate ((otyp[ctxnum]&0x20)?'*':' '), 9497c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sonname); 9507c478bd9Sstevel@tonic-gate } /* end if */ 9512e3b6467Skcpoon 9527c478bd9Sstevel@tonic-gate dobreak = 1; 9532e3b6467Skcpoon 9542e3b6467Skcpoon } else if (ASNDESC->son[ai].sondef != 9552e3b6467Skcpoon NULL && 9562e3b6467Skcpoon ASNDESC->son[ai].sondef->name != 9572e3b6467Skcpoon NULL) { 9582e3b6467Skcpoon asnshw2("%s ", "LDAP:"); 9592e3b6467Skcpoon asnshw3(" %c[%s]", 9602e3b6467Skcpoon ((otyp[ctxnum]&0x20)?'*':' '), 9617c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name); 9627c478bd9Sstevel@tonic-gate dobreak = 1; 9637c478bd9Sstevel@tonic-gate } /* end if */ 9647c478bd9Sstevel@tonic-gate } /* end if */ 9657c478bd9Sstevel@tonic-gate break; 9667c478bd9Sstevel@tonic-gate case CHOICE: 9677c478bd9Sstevel@tonic-gate if (GR_TMPDESC) { 9687c478bd9Sstevel@tonic-gate ASNDESC = TMPDESC; 9697c478bd9Sstevel@tonic-gate TMPDESC = GR_TMPDESC; 9707c478bd9Sstevel@tonic-gate GR_TMPDESC = 0; 9717c478bd9Sstevel@tonic-gate } else if (TMPDESC) { 9727c478bd9Sstevel@tonic-gate ASNDESC = TMPDESC; 9737c478bd9Sstevel@tonic-gate TMPDESC = 0; 9747c478bd9Sstevel@tonic-gate } 9757c478bd9Sstevel@tonic-gate if (gr_tmpai) { 9767c478bd9Sstevel@tonic-gate ai = tmpai; 9777c478bd9Sstevel@tonic-gate tmpai = gr_tmpai; 9787c478bd9Sstevel@tonic-gate gr_tmpai = 0; 9797c478bd9Sstevel@tonic-gate } else if (tmpai) { 9807c478bd9Sstevel@tonic-gate ai = tmpai; 9817c478bd9Sstevel@tonic-gate tmpai = 0; 9827c478bd9Sstevel@tonic-gate } 9837c478bd9Sstevel@tonic-gate break; 9847c478bd9Sstevel@tonic-gate 9857c478bd9Sstevel@tonic-gate case SEQUENCE: 9867c478bd9Sstevel@tonic-gate if (ai == -2) { 9877c478bd9Sstevel@tonic-gate ai = 0; 9887c478bd9Sstevel@tonic-gate } else { 9897c478bd9Sstevel@tonic-gate do { 9907c478bd9Sstevel@tonic-gate ai++; 9917c478bd9Sstevel@tonic-gate } while \ 9927c478bd9Sstevel@tonic-gate (ai < ASNDESC->nbson && i < 32 && mytype[i] && \ 9937c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef && 9947c478bd9Sstevel@tonic-gate /* 9952e3b6467Skcpoon * For this test SEQUENCE & SEQUENCE OF 9962e3b6467Skcpoon * are the same, so suppress last bit 9977c478bd9Sstevel@tonic-gate */ 9987c478bd9Sstevel@tonic-gate (ASNDESC->son[ai].sondef->type&0xFE) != mytype[i]); 9997c478bd9Sstevel@tonic-gate } /* end if */ 10007c478bd9Sstevel@tonic-gate if (ai < ASNDESC->nbson) { 10017c478bd9Sstevel@tonic-gate SASNDESC = \ 10027c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef; 10037c478bd9Sstevel@tonic-gate if (ASNDESC->son[ai].sonname) { 10047c478bd9Sstevel@tonic-gate if \ 10057c478bd9Sstevel@tonic-gate (ASNDESC->son[ai].sondef && 10067c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name) { 10077c478bd9Sstevel@tonic-gate asnshw4 \ 10087c478bd9Sstevel@tonic-gate (" %c[%s %s]", ((otyp[ctxnum]&0x20)?'*':' '), 10097c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sonname, 10107c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name); 10117c478bd9Sstevel@tonic-gate } else { 10127c478bd9Sstevel@tonic-gate asnshw3 \ 10137c478bd9Sstevel@tonic-gate (" %c[%s]", ((otyp[ctxnum]&0x20)?'*':' '), 10147c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sonname); 10157c478bd9Sstevel@tonic-gate } /* end if */ 10167c478bd9Sstevel@tonic-gate dobreak = 1; 10177c478bd9Sstevel@tonic-gate } else if \ 10187c478bd9Sstevel@tonic-gate (ASNDESC->son[ai].sondef && 10197c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name) { 10207c478bd9Sstevel@tonic-gate asnshw3 \ 10217c478bd9Sstevel@tonic-gate (" %c[%s]", ((otyp[ctxnum]&0x20)?'*':' '), 10227c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name); 10237c478bd9Sstevel@tonic-gate dobreak = 1; 10247c478bd9Sstevel@tonic-gate } /* end if */ 10257c478bd9Sstevel@tonic-gate } /* end if */ 10267c478bd9Sstevel@tonic-gate break; 10277c478bd9Sstevel@tonic-gate case SEQUENCEOF: 10287c478bd9Sstevel@tonic-gate ai = 0; 10297c478bd9Sstevel@tonic-gate SASNDESC = ASNDESC->son[ai].sondef; 10307c478bd9Sstevel@tonic-gate if (ASNDESC->son[ai].sonname) { 10317c478bd9Sstevel@tonic-gate if (ASNDESC->son[ai].sondef && \ 10327c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name) { 10337c478bd9Sstevel@tonic-gate asnshw4 \ 10347c478bd9Sstevel@tonic-gate (" %c[%s %s]", ((otyp[ctxnum]&0x20)?'*':' '), 10357c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sonname, 10367c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name); 10377c478bd9Sstevel@tonic-gate } else { 10387c478bd9Sstevel@tonic-gate asnshw3 \ 10397c478bd9Sstevel@tonic-gate (" %c[%s]", ((otyp[ctxnum]&0x20)?'*':' '), 10407c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sonname); 10417c478bd9Sstevel@tonic-gate } /* end if */ 10427c478bd9Sstevel@tonic-gate dobreak = 1; 10437c478bd9Sstevel@tonic-gate } else if \ 10447c478bd9Sstevel@tonic-gate (ASNDESC->son[ai].sondef && 10457c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name) { 10467c478bd9Sstevel@tonic-gate asnshw3 \ 10477c478bd9Sstevel@tonic-gate (" %c[%s]", ((otyp[ctxnum]&0x20)?'*':' '), 10487c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name); 10497c478bd9Sstevel@tonic-gate dobreak = 1; 10507c478bd9Sstevel@tonic-gate } /* end if */ 10517c478bd9Sstevel@tonic-gate } /* end switch */ 10527c478bd9Sstevel@tonic-gate if (dobreak) { 10537c478bd9Sstevel@tonic-gate break; 10547c478bd9Sstevel@tonic-gate } /* end if */ 10557c478bd9Sstevel@tonic-gate } /* end if */ 10567c478bd9Sstevel@tonic-gate if (uclass[i]) { 10577c478bd9Sstevel@tonic-gate asnshw3 \ 10587c478bd9Sstevel@tonic-gate (" %c[%s]", ((otyp[ctxnum]&0x20)?'*':' '), uclass[i]); 10597c478bd9Sstevel@tonic-gate } else { 10607c478bd9Sstevel@tonic-gate asnshw4 \ 10617c478bd9Sstevel@tonic-gate (" %c[%s%d]", ((otyp[ctxnum]&0x20)?'*':' '), 10627c478bd9Sstevel@tonic-gate class[0], i); 10637c478bd9Sstevel@tonic-gate } 10647c478bd9Sstevel@tonic-gate break; 10657c478bd9Sstevel@tonic-gate case 1: /* application */ 10667c478bd9Sstevel@tonic-gate 10677c478bd9Sstevel@tonic-gate if (ASNDESC) { 10687c478bd9Sstevel@tonic-gate 10697c478bd9Sstevel@tonic-gate for (ai = 0; ai < ASNDESC->nbson; ++ai) { 10707c478bd9Sstevel@tonic-gate int i2 = 0; 10717c478bd9Sstevel@tonic-gate 10727c478bd9Sstevel@tonic-gate if \ 10737c478bd9Sstevel@tonic-gate (ASNDESC->son[ai].sondef && 10747c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->type == CHOICE) { 10757c478bd9Sstevel@tonic-gate while \ 10767c478bd9Sstevel@tonic-gate (i2 < ASNDESC->son[ai].sondef->nbson && 10777c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->son[i2].sondef && \ 10787c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->son[i2].sondef->application != i) { 10797c478bd9Sstevel@tonic-gate i2++; 10807c478bd9Sstevel@tonic-gate continue; 10817c478bd9Sstevel@tonic-gate } 10827c478bd9Sstevel@tonic-gate if \ 10837c478bd9Sstevel@tonic-gate (i2 == ASNDESC->son[ai].sondef->nbson) { 10847c478bd9Sstevel@tonic-gate ai = ASNDESC->nbson; 10857c478bd9Sstevel@tonic-gate break; 10867c478bd9Sstevel@tonic-gate } 10877c478bd9Sstevel@tonic-gate if (TMPDESC) { 10887c478bd9Sstevel@tonic-gate GR_TMPDESC = TMPDESC; 10897c478bd9Sstevel@tonic-gate gr_tmpai = tmpai; 10907c478bd9Sstevel@tonic-gate } 10917c478bd9Sstevel@tonic-gate TMPDESC = ASNDESC; 10927c478bd9Sstevel@tonic-gate ASNDESC = ASNDESC->son[ai].sondef; 10937c478bd9Sstevel@tonic-gate tmpai = ai; 10947c478bd9Sstevel@tonic-gate ai = i2; 10957c478bd9Sstevel@tonic-gate } 10967c478bd9Sstevel@tonic-gate 10977c478bd9Sstevel@tonic-gate if (ASNDESC->son[ai].sondef && \ 10987c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->application == i) { 10997c478bd9Sstevel@tonic-gate SASNDESC = \ 11007c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef; 11017c478bd9Sstevel@tonic-gate if (ASNDESC->son[ai].sonname) { 11027c478bd9Sstevel@tonic-gate if \ 11037c478bd9Sstevel@tonic-gate (ASNDESC->son[ai].sondef->name) { 11047c478bd9Sstevel@tonic-gate asnshw3 \ 11057c478bd9Sstevel@tonic-gate (" %s %s", ASNDESC->son[ai].sonname, 11067c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name); 11077c478bd9Sstevel@tonic-gate } else { 11087c478bd9Sstevel@tonic-gate asnshw2 \ 11097c478bd9Sstevel@tonic-gate (" %s", ASNDESC->son[ai].sonname); 11107c478bd9Sstevel@tonic-gate } /* end if */ 11117c478bd9Sstevel@tonic-gate } else if \ 11127c478bd9Sstevel@tonic-gate (ASNDESC->son[ai].sondef->name) { 11137c478bd9Sstevel@tonic-gate asnshw2 \ 11147c478bd9Sstevel@tonic-gate (" %s", ASNDESC->son[ai].sondef->name); 11157c478bd9Sstevel@tonic-gate } /* end if */ 11167c478bd9Sstevel@tonic-gate break; 11177c478bd9Sstevel@tonic-gate } /* end if */ 11187c478bd9Sstevel@tonic-gate } /* end for */ 11197c478bd9Sstevel@tonic-gate if (ai >= ASNDESC->nbson) { 11207c478bd9Sstevel@tonic-gate ai = -1; /* not found */ 11217c478bd9Sstevel@tonic-gate } /* end if */ 11227c478bd9Sstevel@tonic-gate } /* end if */ 11237c478bd9Sstevel@tonic-gate if (PTRaclass[i]) { 11247c478bd9Sstevel@tonic-gate asnshw5 \ 11257c478bd9Sstevel@tonic-gate (" %c[%s%d: %s]", ((otyp[ctxnum]&0x20)?'*':' '), 11267c478bd9Sstevel@tonic-gate class[1], i, PTRaclass[i]); 11277c478bd9Sstevel@tonic-gate (void) strcpy(operation, (char *)PTRaclass[i]); 11287c478bd9Sstevel@tonic-gate } else { 11297c478bd9Sstevel@tonic-gate asnshw4 \ 11307c478bd9Sstevel@tonic-gate (" %c[%s%d]", ((otyp[ctxnum]&0x20)?'*':' '), \ 11317c478bd9Sstevel@tonic-gate class[1], i); 11327c478bd9Sstevel@tonic-gate } 11337c478bd9Sstevel@tonic-gate break; 11347c478bd9Sstevel@tonic-gate 11357c478bd9Sstevel@tonic-gate case 2: /* context-specific */ 11367c478bd9Sstevel@tonic-gate 11377c478bd9Sstevel@tonic-gate if (TMPDESC) { 11387c478bd9Sstevel@tonic-gate ASNDESC = TMPDESC; 11397c478bd9Sstevel@tonic-gate TMPDESC = GR_TMPDESC; 11407c478bd9Sstevel@tonic-gate already = 1; 11417c478bd9Sstevel@tonic-gate } 11427c478bd9Sstevel@tonic-gate if (ASNDESC) { 11437c478bd9Sstevel@tonic-gate 11447c478bd9Sstevel@tonic-gate for (ai = 0; ai < ASNDESC->nbson; ++ai) { 11457c478bd9Sstevel@tonic-gate if \ 11467c478bd9Sstevel@tonic-gate (!already && ASNDESC->son[ai].sondef && 11477c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->type == CHOICE) { 11487c478bd9Sstevel@tonic-gate int i2 = 0; 11497c478bd9Sstevel@tonic-gate while \ 11507c478bd9Sstevel@tonic-gate (i2 < ASNDESC->son[ai].sondef->nbson && 11517c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->son[i2].tag != i) { 11527c478bd9Sstevel@tonic-gate i2++; 11537c478bd9Sstevel@tonic-gate continue; 11547c478bd9Sstevel@tonic-gate } 11557c478bd9Sstevel@tonic-gate if (i2 == \ 11567c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->nbson) { 11577c478bd9Sstevel@tonic-gate ai = ASNDESC->nbson; 11587c478bd9Sstevel@tonic-gate break; 11597c478bd9Sstevel@tonic-gate } 11607c478bd9Sstevel@tonic-gate if (TMPDESC) { 11617c478bd9Sstevel@tonic-gate GR_TMPDESC = TMPDESC; 11627c478bd9Sstevel@tonic-gate gr_tmpai = tmpai; 11637c478bd9Sstevel@tonic-gate } 11647c478bd9Sstevel@tonic-gate TMPDESC = ASNDESC; 11657c478bd9Sstevel@tonic-gate ASNDESC = \ 11667c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef; 11677c478bd9Sstevel@tonic-gate tmpai = ai; 11687c478bd9Sstevel@tonic-gate ai = i2; 11697c478bd9Sstevel@tonic-gate } 11707c478bd9Sstevel@tonic-gate 11717c478bd9Sstevel@tonic-gate if \ 11727c478bd9Sstevel@tonic-gate (ASNDESC->son[ai].tag == i) { 11737c478bd9Sstevel@tonic-gate SASNDESC = \ 11747c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef; 11757c478bd9Sstevel@tonic-gate if (ASNDESC->son[ai].sonname) { 11767c478bd9Sstevel@tonic-gate if \ 11777c478bd9Sstevel@tonic-gate (ASNDESC->son[ai].sondef && 11787c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name) { 11797c478bd9Sstevel@tonic-gate asnshw3 \ 11807c478bd9Sstevel@tonic-gate (" %s %s", ASNDESC->son[ai].sonname, 11817c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name); 11827c478bd9Sstevel@tonic-gate } else { 11837c478bd9Sstevel@tonic-gate asnshw2 \ 11847c478bd9Sstevel@tonic-gate (" %s", ASNDESC->son[ai].sonname); 11857c478bd9Sstevel@tonic-gate } /* end if */ 11867c478bd9Sstevel@tonic-gate } else if \ 11877c478bd9Sstevel@tonic-gate (ASNDESC->son[ai].sondef && 11887c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef->name) { 11897c478bd9Sstevel@tonic-gate asnshw2 \ 11907c478bd9Sstevel@tonic-gate (" %s", ASNDESC->son[ai].sondef->name); 11917c478bd9Sstevel@tonic-gate } /* end if */ 11927c478bd9Sstevel@tonic-gate break; 11937c478bd9Sstevel@tonic-gate } /* end if */ 11947c478bd9Sstevel@tonic-gate } /* end for */ 11957c478bd9Sstevel@tonic-gate if (ai >= ASNDESC->nbson) { 11967c478bd9Sstevel@tonic-gate ai = -1; /* not found */ 11977c478bd9Sstevel@tonic-gate } /* end if */ 11987c478bd9Sstevel@tonic-gate } /* end if */ 11997c478bd9Sstevel@tonic-gate asnshw3 \ 12007c478bd9Sstevel@tonic-gate (" %c[%d]", ((otyp[ctxnum]&0x20)?'*':' '), i); 12017c478bd9Sstevel@tonic-gate break; 12027c478bd9Sstevel@tonic-gate 12037c478bd9Sstevel@tonic-gate case 3: /* private */ 12047c478bd9Sstevel@tonic-gate asnshw4 \ 12057c478bd9Sstevel@tonic-gate (" %c[%s%d]", ((otyp[ctxnum]&0x20)?'*':' '), \ 12067c478bd9Sstevel@tonic-gate class[3], i); 12077c478bd9Sstevel@tonic-gate } /* esac: tag */ 12087c478bd9Sstevel@tonic-gate 12097c478bd9Sstevel@tonic-gate /* 12102e3b6467Skcpoon * print the length - as a debug tool only. 12117c478bd9Sstevel@tonic-gate */ 12127c478bd9Sstevel@tonic-gate /* asnshw2(" Length=%d ",rlen); */ 12137c478bd9Sstevel@tonic-gate asnshw1("\n"); 12147c478bd9Sstevel@tonic-gate if (rlen > pdulen) { 12157c478bd9Sstevel@tonic-gate asnshw1("*** Decode length error,"); 12167c478bd9Sstevel@tonic-gate asnshw2(" PDU length = %d ***\n", pdulen); 12177c478bd9Sstevel@tonic-gate rlen = pdulen; 12187c478bd9Sstevel@tonic-gate } 12197c478bd9Sstevel@tonic-gate 12207c478bd9Sstevel@tonic-gate /* 12212e3b6467Skcpoon * recursive interpretation of the value if constructor 12227c478bd9Sstevel@tonic-gate */ 12237c478bd9Sstevel@tonic-gate if (otyp[ctxnum]&0x20) { /* constructor */ 12247c478bd9Sstevel@tonic-gate 12257c478bd9Sstevel@tonic-gate stlv = decpdu((rlen?rlen:pdulen), \ 12267c478bd9Sstevel@tonic-gate ASNDESC && ai != -1 ?(ai == -2 ? ASNDESC: 12277c478bd9Sstevel@tonic-gate ASNDESC->son[ai].sondef):0, ctxnum); 12287c478bd9Sstevel@tonic-gate /* recursive decoding */ 12297c478bd9Sstevel@tonic-gate pdulen -= stlv; 12307c478bd9Sstevel@tonic-gate effnb += stlv; 12317c478bd9Sstevel@tonic-gate } else if (otyp[ctxnum] == 0x06) { 12327c478bd9Sstevel@tonic-gate /* 12332e3b6467Skcpoon * interpretation of the object identifier 12347c478bd9Sstevel@tonic-gate */ 12357c478bd9Sstevel@tonic-gate for (j = 0; (rlen) && (pdulen > 0); \ 12367c478bd9Sstevel@tonic-gate --rlen, --pdulen, ++effnb) { 12377c478bd9Sstevel@tonic-gate GETNEXT(ctxnum); 12387c478bd9Sstevel@tonic-gate oidstr[j++] = hex; 12397c478bd9Sstevel@tonic-gate } 12407c478bd9Sstevel@tonic-gate 12417c478bd9Sstevel@tonic-gate /* interpret the object identifier */ 12427c478bd9Sstevel@tonic-gate oidstr[j++] = '\0'; 12437c478bd9Sstevel@tonic-gate oix = oidmap(oidstr, j-1); 12447c478bd9Sstevel@tonic-gate asnshw1("\n"); 12457c478bd9Sstevel@tonic-gate if (oix >= 0 && oix < OIDNB) { /* recognized obj id */ 12467c478bd9Sstevel@tonic-gate asnshw2("%s\n", OidTab[oix].oidname); 12477c478bd9Sstevel@tonic-gate } else { 12487c478bd9Sstevel@tonic-gate asnshw1("Unknown Oid\n"); 12497c478bd9Sstevel@tonic-gate } 12507c478bd9Sstevel@tonic-gate } else { 12517c478bd9Sstevel@tonic-gate /* 12522e3b6467Skcpoon * interpretation of other primitive tags 12537c478bd9Sstevel@tonic-gate */ 12547c478bd9Sstevel@tonic-gate if (!otyp[ctxnum] && !rlen) { 12557c478bd9Sstevel@tonic-gate /* end of contents: any form length */ 12567c478bd9Sstevel@tonic-gate pdulen = 0; 12577c478bd9Sstevel@tonic-gate } else { 12587c478bd9Sstevel@tonic-gate X hexstr[5]; 12597c478bd9Sstevel@tonic-gate int k = 0; 12607c478bd9Sstevel@tonic-gate int klen = rlen; 12617c478bd9Sstevel@tonic-gate if (SASNDESC && SASNDESC->type == CONTENT && \ 12627c478bd9Sstevel@tonic-gate SASNDESC->nbson && SASNDESC->son[0].sondef) { 12637c478bd9Sstevel@tonic-gate (void) 12647c478bd9Sstevel@tonic-gate decpdu(rlen, SASNDESC->son[0].sondef, ctxnum); 12657c478bd9Sstevel@tonic-gate } else { 12667c478bd9Sstevel@tonic-gate if (rlen < 200) { 12677c478bd9Sstevel@tonic-gate for (j = 0, slen = 0; \ 12687c478bd9Sstevel@tonic-gate (rlen) && (pdulen > 0); 12692e3b6467Skcpoon --rlen, --pdulen, ++effnb) { 12707c478bd9Sstevel@tonic-gate if (!slen) { 12717c478bd9Sstevel@tonic-gate (void) \ 12727c478bd9Sstevel@tonic-gate strcpy((char *)scrlin, "LDAP: "); j += 7; 12737c478bd9Sstevel@tonic-gate for \ 12747c478bd9Sstevel@tonic-gate (i = 0; i < level[ctxnum]; ++i) { 12757c478bd9Sstevel@tonic-gate scrlin[j++] = ' '; 12767c478bd9Sstevel@tonic-gate scrlin[j++] = ' '; 12777c478bd9Sstevel@tonic-gate scrlin[j++] = ' '; 12787c478bd9Sstevel@tonic-gate scrlin[j++] = ' '; 12797c478bd9Sstevel@tonic-gate } 12807c478bd9Sstevel@tonic-gate } 12817c478bd9Sstevel@tonic-gate 12827c478bd9Sstevel@tonic-gate GETNEXT(ctxnum); 12837c478bd9Sstevel@tonic-gate if (k < 5) { 12847c478bd9Sstevel@tonic-gate hexstr[k++] = hex; 12857c478bd9Sstevel@tonic-gate } /* end if */ 12867c478bd9Sstevel@tonic-gate if (!isprint(hex)) { 12877c478bd9Sstevel@tonic-gate hex = '_'; 12887c478bd9Sstevel@tonic-gate dontprint = 1; 12897c478bd9Sstevel@tonic-gate } 12907c478bd9Sstevel@tonic-gate scrlin[j++] = hex; 12917c478bd9Sstevel@tonic-gate if ((slen += 2) >= \ 12927c478bd9Sstevel@tonic-gate (72 - (level[ctxnum] * 3))) { 12937c478bd9Sstevel@tonic-gate slen = 0; 12947c478bd9Sstevel@tonic-gate scrlin[j] = 0; 12957c478bd9Sstevel@tonic-gate if (!dontprint) { 12967c478bd9Sstevel@tonic-gate asnshw2 \ 12977c478bd9Sstevel@tonic-gate ("%s\n", scrlin); 12987c478bd9Sstevel@tonic-gate } 12997c478bd9Sstevel@tonic-gate j = 0; 13007c478bd9Sstevel@tonic-gate } 13017c478bd9Sstevel@tonic-gate } /* rof: primitive values */ 13027c478bd9Sstevel@tonic-gate if (slen) { 13037c478bd9Sstevel@tonic-gate scrlin[j] = 0; 13047c478bd9Sstevel@tonic-gate if (!dontprint) { 13057c478bd9Sstevel@tonic-gate asnshw2("%s\n", scrlin); 13067c478bd9Sstevel@tonic-gate } 13077c478bd9Sstevel@tonic-gate } 13087c478bd9Sstevel@tonic-gate dontprint = 0; 13097c478bd9Sstevel@tonic-gate } else { 13107c478bd9Sstevel@tonic-gate asnshw2("%s ", "LDAP:"); 13117c478bd9Sstevel@tonic-gate for (i = 0; i < level[ctxnum]; ++i) { 13127c478bd9Sstevel@tonic-gate asnshw1(" "); 13137c478bd9Sstevel@tonic-gate scrlin[j++] = ' '; 13147c478bd9Sstevel@tonic-gate scrlin[j++] = ' '; 13157c478bd9Sstevel@tonic-gate scrlin[j++] = ' '; 13167c478bd9Sstevel@tonic-gate } 13177c478bd9Sstevel@tonic-gate 13187c478bd9Sstevel@tonic-gate for (j = 0; (rlen) && (pdulen > 0); \ 13197c478bd9Sstevel@tonic-gate --rlen, --pdulen, ++effnb) { 13207c478bd9Sstevel@tonic-gate GETNEXT(ctxnum); 13217c478bd9Sstevel@tonic-gate if (k < 5) { 13227c478bd9Sstevel@tonic-gate hexstr[k++] = hex; 13237c478bd9Sstevel@tonic-gate } 13247c478bd9Sstevel@tonic-gate } 13257c478bd9Sstevel@tonic-gate (void) strcpy \ 13267c478bd9Sstevel@tonic-gate ((char *)scrlin, \ 13277c478bd9Sstevel@tonic-gate "*** NOT PRINTED - Too long value ***"); 13287c478bd9Sstevel@tonic-gate asnshw2("%s\n", scrlin); 13297c478bd9Sstevel@tonic-gate } 13307c478bd9Sstevel@tonic-gate 13317c478bd9Sstevel@tonic-gate if \ 13327c478bd9Sstevel@tonic-gate (SASNDESC && SASNDESC->type == BITSTRING &&\ 13337c478bd9Sstevel@tonic-gate klen <= 5) { 13347c478bd9Sstevel@tonic-gate unsigned long bitstr = 0; 13357c478bd9Sstevel@tonic-gate for (i = 1; i < 5; ++i) { 13367c478bd9Sstevel@tonic-gate bitstr = \ 13377c478bd9Sstevel@tonic-gate ((bitstr) << 8) + ((i < klen)?hexstr[i]:0); 13387c478bd9Sstevel@tonic-gate } /* end for */ 13397c478bd9Sstevel@tonic-gate for \ 13407c478bd9Sstevel@tonic-gate (i = 0; i < SASNDESC->nbson; ++i) { 13417c478bd9Sstevel@tonic-gate if ((bitstr & \ 13427c478bd9Sstevel@tonic-gate ((unsigned long)SASNDESC->son[i].sondef)) == 13437c478bd9Sstevel@tonic-gate ((unsigned long)SASNDESC->son[i].tag)) { 13447c478bd9Sstevel@tonic-gate if \ 13457c478bd9Sstevel@tonic-gate (SASNDESC->son[i].sonname) { 13467c478bd9Sstevel@tonic-gate int k; 13477c478bd9Sstevel@tonic-gate asnshw2 \ 13487c478bd9Sstevel@tonic-gate ("%s ", "LDAP:"); 13497c478bd9Sstevel@tonic-gate for \ 13507c478bd9Sstevel@tonic-gate (k = 0; k < level[ctxnum]; ++k) { 13517c478bd9Sstevel@tonic-gate asnshw1(" "); 13527c478bd9Sstevel@tonic-gate } 13537c478bd9Sstevel@tonic-gate asnshw2 \ 13547c478bd9Sstevel@tonic-gate ("%s", SASNDESC->son[i].sonname); 13557c478bd9Sstevel@tonic-gate } /* end if */ 13567c478bd9Sstevel@tonic-gate } /* end if */ 13577c478bd9Sstevel@tonic-gate } /* end for */ 13587c478bd9Sstevel@tonic-gate } /* end if */ 13597c478bd9Sstevel@tonic-gate if (SASNDESC && \ 13607c478bd9Sstevel@tonic-gate (SASNDESC->type == ENUM || 13617c478bd9Sstevel@tonic-gate SASNDESC->type == CONTENTTYPE) && klen <= 5) { 13627c478bd9Sstevel@tonic-gate unsigned long value = 0; 13637c478bd9Sstevel@tonic-gate for (i = 0; i < klen; ++i) { 13647c478bd9Sstevel@tonic-gate value = \ 13657c478bd9Sstevel@tonic-gate ((value) << 8) + hexstr[i]; 13667c478bd9Sstevel@tonic-gate } /* end for */ 13677c478bd9Sstevel@tonic-gate for \ 13687c478bd9Sstevel@tonic-gate (i = 0; i < SASNDESC->nbson; ++i) { 13697c478bd9Sstevel@tonic-gate if \ 13707c478bd9Sstevel@tonic-gate (value == ((unsigned long)SASNDESC->son[i].tag)) { 13717c478bd9Sstevel@tonic-gate if \ 13727c478bd9Sstevel@tonic-gate (SASNDESC->son[i].sonname) { 13737c478bd9Sstevel@tonic-gate int k; 13747c478bd9Sstevel@tonic-gate asnshw2 \ 13757c478bd9Sstevel@tonic-gate ("%s ", "LDAP:"); 13767c478bd9Sstevel@tonic-gate for \ 13777c478bd9Sstevel@tonic-gate (k = 0; k < level[ctxnum]; ++k) { 13787c478bd9Sstevel@tonic-gate asnshw1(" "); 13797c478bd9Sstevel@tonic-gate } 13807c478bd9Sstevel@tonic-gate asnshw2 \ 13817c478bd9Sstevel@tonic-gate ("%s\n", SASNDESC->son[i].sonname); 13827c478bd9Sstevel@tonic-gate (void) \ 13837c478bd9Sstevel@tonic-gate strcpy(resultcode, SASNDESC->son[i].sonname); 13847c478bd9Sstevel@tonic-gate } /* end if */ 13857c478bd9Sstevel@tonic-gate break; 13867c478bd9Sstevel@tonic-gate } /* end if */ 13877c478bd9Sstevel@tonic-gate } /* end for */ 13887c478bd9Sstevel@tonic-gate } /* end if */ 13897c478bd9Sstevel@tonic-gate 13907c478bd9Sstevel@tonic-gate } /* end if */ 13917c478bd9Sstevel@tonic-gate } /* fi: constructor/obj-id/primitive */ 13927c478bd9Sstevel@tonic-gate } /* fi: tag analysis */ 13937c478bd9Sstevel@tonic-gate } /* elihw: len>1 */ 13947c478bd9Sstevel@tonic-gate --level[ctxnum]; 13957c478bd9Sstevel@tonic-gate return (effnb); 13967c478bd9Sstevel@tonic-gate } 13977c478bd9Sstevel@tonic-gate 13987c478bd9Sstevel@tonic-gate 13997c478bd9Sstevel@tonic-gate /* init_ldap initializes various buffers and variables */ 14007c478bd9Sstevel@tonic-gate /* it is called one-time (in snoop_filter.c) only. */ 14017c478bd9Sstevel@tonic-gate 14027c478bd9Sstevel@tonic-gate void 14037c478bd9Sstevel@tonic-gate init_ldap() 14047c478bd9Sstevel@tonic-gate { 14057c478bd9Sstevel@tonic-gate int i; 14067c478bd9Sstevel@tonic-gate 14077c478bd9Sstevel@tonic-gate for (i = 0; i < MAX_CTX; i++) { 14087c478bd9Sstevel@tonic-gate gi_osibuf[i] = 0; 14097c478bd9Sstevel@tonic-gate level[i] = 0; 14107c478bd9Sstevel@tonic-gate } 14117c478bd9Sstevel@tonic-gate } 14127c478bd9Sstevel@tonic-gate static void 14137c478bd9Sstevel@tonic-gate ldapdump(char *data, int datalen) 14147c478bd9Sstevel@tonic-gate { 14157c478bd9Sstevel@tonic-gate char *p; 14167c478bd9Sstevel@tonic-gate ushort_t *p16 = (ushort_t *)data; 14177c478bd9Sstevel@tonic-gate char *p8 = data; 14187c478bd9Sstevel@tonic-gate int i, left, len; 14197c478bd9Sstevel@tonic-gate int chunk = 16; /* 16 bytes per line */ 14207c478bd9Sstevel@tonic-gate 14217c478bd9Sstevel@tonic-gate asnshw1("LDAP: Skipping until next full LDAPMessage\n"); 14227c478bd9Sstevel@tonic-gate 14237c478bd9Sstevel@tonic-gate for (p = data; p < data + datalen; p += chunk) { 14247c478bd9Sstevel@tonic-gate asnshw2("LDAP:\t%4d: ", p - data); 14257c478bd9Sstevel@tonic-gate left = (data + datalen) - p; 14267c478bd9Sstevel@tonic-gate len = MIN(chunk, left); 14277c478bd9Sstevel@tonic-gate for (i = 0; i < (len / 2); i++) 14287c478bd9Sstevel@tonic-gate asnshw2("%04x ", ntohs(*p16++) & 0xffff); 14297c478bd9Sstevel@tonic-gate if (len % 2) { 14307c478bd9Sstevel@tonic-gate asnshw2("%02x ", *((unsigned char *)p16)); 14317c478bd9Sstevel@tonic-gate } 14327c478bd9Sstevel@tonic-gate for (i = 0; i < (chunk - left) / 2; i++) 14337c478bd9Sstevel@tonic-gate asnshw1(" "); 14347c478bd9Sstevel@tonic-gate 14357c478bd9Sstevel@tonic-gate asnshw1(" "); 14367c478bd9Sstevel@tonic-gate for (i = 0; i < len; i++, p8++) 14377c478bd9Sstevel@tonic-gate asnshw2("%c", isprint(*p8) ? *p8 : '.'); 14387c478bd9Sstevel@tonic-gate asnshw1("\n"); 14397c478bd9Sstevel@tonic-gate } 14407c478bd9Sstevel@tonic-gate 14417c478bd9Sstevel@tonic-gate asnshw1("LDAP:\n"); 14427c478bd9Sstevel@tonic-gate } 14437c478bd9Sstevel@tonic-gate 14447c478bd9Sstevel@tonic-gate /* decode_ldap is the entry point for the main decoding function */ 14457c478bd9Sstevel@tonic-gate /* decpdu(). decode_ldap() is only called by interpret_ldap. */ 14467c478bd9Sstevel@tonic-gate 14477c478bd9Sstevel@tonic-gate void 14487c478bd9Sstevel@tonic-gate decode_ldap(char *buf, int len) 14497c478bd9Sstevel@tonic-gate { 14507c478bd9Sstevel@tonic-gate asndefTp ASNDESC = 0; 14517c478bd9Sstevel@tonic-gate char *newbuf; 14527c478bd9Sstevel@tonic-gate int skipped = 0; 14537c478bd9Sstevel@tonic-gate 14547c478bd9Sstevel@tonic-gate PTRaclass = MHSaclass; 14557c478bd9Sstevel@tonic-gate ASNDESC = &MPDU; 14567c478bd9Sstevel@tonic-gate 14577c478bd9Sstevel@tonic-gate 14587c478bd9Sstevel@tonic-gate newbuf = skipjunk(len, buf); 14597c478bd9Sstevel@tonic-gate if (newbuf > buf) { 14607c478bd9Sstevel@tonic-gate skipped = newbuf-buf; 14617c478bd9Sstevel@tonic-gate ldapdump(buf, newbuf-buf); 14627c478bd9Sstevel@tonic-gate } 14637c478bd9Sstevel@tonic-gate buf = newbuf; 14647c478bd9Sstevel@tonic-gate len = len-skipped; 14657c478bd9Sstevel@tonic-gate osibuff = buf; /* Undecoded buf is passed by interpret_ldap */ 14667c478bd9Sstevel@tonic-gate osilen = len; /* length of tcp data is also passed */ 14677c478bd9Sstevel@tonic-gate 14687c478bd9Sstevel@tonic-gate (void) decpdu(len, ASNDESC, 0); 14697c478bd9Sstevel@tonic-gate gi_osibuf[0] = 0; 14707c478bd9Sstevel@tonic-gate } 1471