]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/contrib/ngatm/netnatm/api/unisap.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / contrib / ngatm / netnatm / api / unisap.h
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.6 2005/05/23 11:49:17 brandt_h Exp $
30  */
31 #ifndef _NETNATM_API_UNISAP_H_
32 #define _NETNATM_API_UNISAP_H_
33
34 #include <netnatm/msg/uni_config.h>
35
36 enum unisve_tag {
37         UNISVE_ABSENT,          /* Element is absent */
38         UNISVE_PRESENT,         /* Element is present with specific value */
39         UNISVE_ANY              /* Any values is acceptable */
40 };
41
42 struct unisve_addr {
43         enum unisve_tag         tag;
44         enum uni_addr_type      type;   /* type of address */
45         enum uni_addr_plan      plan;   /* addressing plan */
46         uint32_t                len;    /* length of address */
47         u_char                  addr[UNI_ADDR_MAXLEN];
48 };
49
50 struct unisve_selector {
51         enum unisve_tag tag;
52         uint8_t         selector;
53 };
54
55 struct unisve_blli_id2 {
56         enum unisve_tag tag;
57         u_int           proto:5;        /* the protocol */
58         u_int           user:7;         /* user specific protocol */
59 };
60
61 struct unisve_blli_id3 {
62         enum unisve_tag tag;
63         u_int           proto:5;        /* L3 protocol */
64         u_int           user:7;         /* user specific protocol */
65         u_int           ipi:8;          /* ISO/IEC TR 9557 IPI */
66         u_int           oui:24;         /* IEEE 802.1 OUI */
67         u_int           pid:16;         /* IEEE 802.1 PID */
68         uint32_t        noipi;          /* ISO/IEC TR 9557 per frame */
69 };
70
71 struct unisve_bhli {
72         enum unisve_tag tag;
73         enum uni_bhli   type;           /* type of info */
74         uint32_t        len;            /* length of info */
75         uint8_t         info[8];        /* info itself */
76 };
77
78 struct uni_sap {
79         struct unisve_addr      addr;
80         struct unisve_selector  selector;
81         struct unisve_blli_id2  blli_id2;
82         struct unisve_blli_id3  blli_id3;
83         struct unisve_bhli      bhli;
84 };
85
86 int unisve_check_addr(const struct unisve_addr *);
87 int unisve_check_selector(const struct unisve_selector *);
88 int unisve_check_blli_id2(const struct unisve_blli_id2 *);
89 int unisve_check_blli_id3(const struct unisve_blli_id3 *);
90 int unisve_check_bhli(const struct unisve_bhli *);
91
92 int unisve_check_sap(const struct uni_sap *);
93
94 int unisve_overlap_addr(const struct unisve_addr *, const struct unisve_addr *);
95 int unisve_overlap_selector(const struct unisve_selector *,
96     const struct unisve_selector *);
97 int unisve_overlap_blli_id2(const struct unisve_blli_id2 *,
98     const struct unisve_blli_id2 *);
99 int unisve_overlap_blli_id3(const struct unisve_blli_id3 *,
100     const struct unisve_blli_id3 *);
101 int unisve_overlap_bhli(const struct unisve_bhli *,
102     const struct unisve_bhli *);
103 int unisve_overlap_sap(const struct uni_sap *, const struct uni_sap *);
104
105 int unisve_is_catchall(const struct uni_sap *);
106 int unisve_match(const struct uni_sap *, const struct uni_ie_called *,
107         const struct uni_ie_blli *, const struct uni_ie_bhli *);
108
109 enum {
110         UNISVE_OK = 0,
111         UNISVE_ERROR_BAD_TAG,
112         UNISVE_ERROR_TYPE_PLAN_CONFLICT,
113         UNISVE_ERROR_ADDR_SEL_CONFLICT,
114         UNISVE_ERROR_ADDR_LEN,
115         UNISVE_ERROR_BAD_ADDR_TYPE,
116         UNISVE_ERROR_BAD_BHLI_TYPE,
117         UNISVE_ERROR_BAD_BHLI_LEN,
118 };
119
120 #define UNISVE_ERRSTR                                   \
121         "no error",                                     \
122         "bad SVE tag",                                  \
123         "bad address type/plan combination",            \
124         "bad address plan/selector tag combination",    \
125         "bad address length in SVE",                    \
126         "unknown address type in SVE",                  \
127         "bad BHLI type in SVE",                         \
128         "BHLI info too long in SVE",
129
130 #endif