11de7b4b8SPedro F. Giffuni /*- 21de7b4b8SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 31de7b4b8SPedro F. Giffuni * 40738c00eSWarner Losh * Copyright (c) 1995 Andrew McRae. All rights reserved. 50738c00eSWarner Losh * 60738c00eSWarner Losh * Redistribution and use in source and binary forms, with or without 70738c00eSWarner Losh * modification, are permitted provided that the following conditions 80738c00eSWarner Losh * are met: 90738c00eSWarner Losh * 1. Redistributions of source code must retain the above copyright 100738c00eSWarner Losh * notice, this list of conditions and the following disclaimer. 110738c00eSWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 120738c00eSWarner Losh * notice, this list of conditions and the following disclaimer in the 130738c00eSWarner Losh * documentation and/or other materials provided with the distribution. 140738c00eSWarner Losh * 3. The name of the author may not be used to endorse or promote products 150738c00eSWarner Losh * derived from this software without specific prior written permission. 160738c00eSWarner Losh * 170738c00eSWarner Losh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 180738c00eSWarner Losh * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 190738c00eSWarner Losh * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 200738c00eSWarner Losh * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 210738c00eSWarner Losh * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 220738c00eSWarner Losh * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 230738c00eSWarner Losh * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 240738c00eSWarner Losh * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 250738c00eSWarner Losh * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 260738c00eSWarner Losh * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 270738c00eSWarner Losh */ 280738c00eSWarner Losh 290738c00eSWarner Losh struct tuple { 300738c00eSWarner Losh struct tuple *next; 310738c00eSWarner Losh unsigned char code; 32*5066eaebSWarner Losh unsigned char length; 330738c00eSWarner Losh unsigned char *data; 340738c00eSWarner Losh }; 350738c00eSWarner Losh 360738c00eSWarner Losh struct tuple_list { 370738c00eSWarner Losh struct tuple_list *next; 380738c00eSWarner Losh struct tuple *tuples; 390738c00eSWarner Losh off_t offs; 400738c00eSWarner Losh int flags; 410738c00eSWarner Losh }; 420738c00eSWarner Losh 430738c00eSWarner Losh struct tuple_info { 44c1d393d2SWarner Losh const char *name; 450738c00eSWarner Losh unsigned char code; 460738c00eSWarner Losh unsigned char length; /* 255 means variable length */ 470738c00eSWarner Losh }; 480738c00eSWarner Losh 490738c00eSWarner Losh #define tpl32(tp) ((*((tp) + 3) << 24) | \ 500738c00eSWarner Losh (*((tp) + 2) << 16) | \ 510738c00eSWarner Losh (*((tp) + 1) << 8) | *(tp)) 520738c00eSWarner Losh #define tpl24(tp) ((*((tp) + 2) << 16) | \ 530738c00eSWarner Losh (*((tp) + 1) << 8) | *(tp)) 540738c00eSWarner Losh #define tpl16(tp) ((*((tp) + 1) << 8) | *(tp)) 550738c00eSWarner Losh 562d134deaSWarner Losh void dumpcis(struct tuple_list *); 572d134deaSWarner Losh void freecis(struct tuple_list *); 582d134deaSWarner Losh struct tuple_list *readcis(int); 590738c00eSWarner Losh 60c1d393d2SWarner Losh const char *tuple_name(unsigned char); 610738c00eSWarner Losh u_int parse_num(int, u_char *, u_char **, int); 62