unisap.h revision 131826
1/* 2 * Copyright (c) 2001-2003 3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4 * All rights reserved. 5 * 6 * Author: Hartmut Brandt <harti@freebsd.org> 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $Begemot: libunimsg/netnatm/api/unisap.h,v 1.5 2004/07/08 08:22:01 brandt Exp $ 30 * $FreeBSD: vendor-sys/ngatm/dist/sys/contrib/ngatm/netnatm/api/unisap.h 131826 2004-07-08 16:39:03Z harti $ 31 */ 32#ifndef _NETNATM_API_UNISAP_H_ 33#define _NETNATM_API_UNISAP_H_ 34 35#include <netnatm/msg/uni_config.h> 36 37enum unisve_tag { 38 UNISVE_ABSENT, /* Element is absent */ 39 UNISVE_PRESENT, /* Element is present with specific value */ 40 UNISVE_ANY /* Any values is acceptable */ 41}; 42 43struct unisve_addr { 44 enum unisve_tag tag; 45 enum uni_addr_type type; /* type of address */ 46 enum uni_addr_plan plan; /* addressing plan */ 47 uint32_t len; /* length of address */ 48 u_char addr[UNI_ADDR_MAXLEN]; 49}; 50 51struct unisve_selector { 52 enum unisve_tag tag; 53 uint8_t selector; 54}; 55 56struct unisve_blli_id2 { 57 enum unisve_tag tag; 58 u_int proto:5; /* the protocol */ 59 u_int user:7; /* user specific protocol */ 60}; 61 62struct unisve_blli_id3 { 63 enum unisve_tag tag; 64 u_int proto:5; /* L3 protocol */ 65 u_int user:7; /* user specific protocol */ 66 u_int ipi:8; /* ISO/IEC TR 9557 IPI */ 67 u_int oui:24; /* IEEE 802.1 OUI */ 68 u_int pid:16; /* IEEE 802.1 PID */ 69 uint32_t noipi; /* ISO/IEC TR 9557 per frame */ 70}; 71 72struct unisve_bhli { 73 enum unisve_tag tag; 74 enum uni_bhli type; /* type of info */ 75 uint32_t len; /* length of info */ 76 uint8_t info[8]; /* info itself */ 77}; 78 79struct uni_sap { 80 struct unisve_addr addr; 81 struct unisve_selector selector; 82 struct unisve_blli_id2 blli_id2; 83 struct unisve_blli_id3 blli_id3; 84 struct unisve_bhli bhli; 85}; 86 87int unisve_check_addr(const struct unisve_addr *); 88int unisve_check_selector(const struct unisve_selector *); 89int unisve_check_blli_id2(const struct unisve_blli_id2 *); 90int unisve_check_blli_id3(const struct unisve_blli_id3 *); 91int unisve_check_bhli(const struct unisve_bhli *); 92 93int unisve_check_sap(const struct uni_sap *); 94 95int unisve_overlap_addr(const struct unisve_addr *, const struct unisve_addr *); 96int unisve_overlap_selector(const struct unisve_selector *, 97 const struct unisve_selector *); 98int unisve_overlap_blli_id2(const struct unisve_blli_id2 *, 99 const struct unisve_blli_id2 *); 100int unisve_overlap_blli_id3(const struct unisve_blli_id3 *, 101 const struct unisve_blli_id3 *); 102int unisve_overlap_bhli(const struct unisve_bhli *, 103 const struct unisve_bhli *); 104int unisve_overlap_sap(const struct uni_sap *, const struct uni_sap *); 105 106int unisve_is_catchall(const struct uni_sap *); 107int unisve_match(const struct uni_sap *, const struct uni_ie_called *, 108 const struct uni_ie_blli *, const struct uni_ie_bhli *); 109 110enum { 111 UNISVE_OK = 0, 112 UNISVE_ERROR_BAD_TAG, 113 UNISVE_ERROR_TYPE_PLAN_CONFLICT, 114 UNISVE_ERROR_ADDR_SEL_CONFLICT, 115 UNISVE_ERROR_ADDR_LEN, 116 UNISVE_ERROR_BAD_ADDR_TYPE, 117 UNISVE_ERROR_BAD_BHLI_TYPE, 118 UNISVE_ERROR_BAD_BHLI_LEN, 119}; 120 121#define UNISVE_ERRSTR \ 122 "no error", \ 123 "bad SVE tag", \ 124 "bad address type/plan combination", \ 125 "bad address plan/selector tag combination", \ 126 "bad address length in SVE", \ 127 "unknown address type in SVE", \ 128 "bad BHLI type in SVE", \ 129 "BHLI info too long in SVE", 130 131#endif 132