1131826Sharti/*
2131826Sharti * Copyright (c) 2001-2003
3131826Sharti *	Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4131826Sharti * 	All rights reserved.
5131826Sharti *
6131826Sharti * Author: Hartmut Brandt <harti@freebsd.org>
7131826Sharti *
8131826Sharti * Redistribution and use in source and binary forms, with or without
9131826Sharti * modification, are permitted provided that the following conditions
10131826Sharti * are met:
11131826Sharti * 1. Redistributions of source code must retain the above copyright
12131826Sharti *    notice, this list of conditions and the following disclaimer.
13131826Sharti * 2. Redistributions in binary form must reproduce the above copyright
14131826Sharti *    notice, this list of conditions and the following disclaimer in the
15131826Sharti *    documentation and/or other materials provided with the distribution.
16131826Sharti *
17131826Sharti * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18131826Sharti * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19131826Sharti * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20131826Sharti * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21131826Sharti * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22131826Sharti * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23131826Sharti * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24131826Sharti * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25131826Sharti * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26131826Sharti * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27131826Sharti * SUCH DAMAGE.
28131826Sharti *
29146539Sharti * $Begemot: libunimsg/netnatm/api/unisap.h,v 1.6 2005/05/23 11:49:17 brandt_h Exp $
30131826Sharti */
31131826Sharti#ifndef _NETNATM_API_UNISAP_H_
32131826Sharti#define _NETNATM_API_UNISAP_H_
33131826Sharti
34131826Sharti#include <netnatm/msg/uni_config.h>
35131826Sharti
36131826Shartienum unisve_tag {
37131826Sharti	UNISVE_ABSENT,		/* Element is absent */
38131826Sharti	UNISVE_PRESENT,		/* Element is present with specific value */
39131826Sharti	UNISVE_ANY		/* Any values is acceptable */
40131826Sharti};
41131826Sharti
42131826Shartistruct unisve_addr {
43131826Sharti	enum unisve_tag		tag;
44131826Sharti	enum uni_addr_type	type;	/* type of address */
45131826Sharti	enum uni_addr_plan	plan;	/* addressing plan */
46131826Sharti	uint32_t		len;	/* length of address */
47131826Sharti	u_char			addr[UNI_ADDR_MAXLEN];
48131826Sharti};
49131826Sharti
50131826Shartistruct unisve_selector {
51131826Sharti	enum unisve_tag	tag;
52131826Sharti	uint8_t		selector;
53131826Sharti};
54131826Sharti
55131826Shartistruct unisve_blli_id2 {
56131826Sharti	enum unisve_tag	tag;
57131826Sharti	u_int		proto:5;	/* the protocol */
58131826Sharti	u_int		user:7;		/* user specific protocol */
59131826Sharti};
60131826Sharti
61131826Shartistruct unisve_blli_id3 {
62131826Sharti	enum unisve_tag	tag;
63131826Sharti	u_int		proto:5;	/* L3 protocol */
64131826Sharti	u_int		user:7;		/* user specific protocol */
65131826Sharti	u_int		ipi:8;		/* ISO/IEC TR 9557 IPI */
66131826Sharti	u_int		oui:24;		/* IEEE 802.1 OUI */
67131826Sharti	u_int		pid:16;		/* IEEE 802.1 PID */
68131826Sharti	uint32_t	noipi;		/* ISO/IEC TR 9557 per frame */
69131826Sharti};
70131826Sharti
71131826Shartistruct unisve_bhli {
72131826Sharti	enum unisve_tag	tag;
73131826Sharti	enum uni_bhli	type;		/* type of info */
74131826Sharti	uint32_t	len;		/* length of info */
75131826Sharti	uint8_t		info[8];	/* info itself */
76131826Sharti};
77131826Sharti
78131826Shartistruct uni_sap {
79131826Sharti	struct unisve_addr	addr;
80131826Sharti	struct unisve_selector	selector;
81131826Sharti	struct unisve_blli_id2	blli_id2;
82131826Sharti	struct unisve_blli_id3	blli_id3;
83131826Sharti	struct unisve_bhli	bhli;
84131826Sharti};
85131826Sharti
86131826Shartiint unisve_check_addr(const struct unisve_addr *);
87131826Shartiint unisve_check_selector(const struct unisve_selector *);
88131826Shartiint unisve_check_blli_id2(const struct unisve_blli_id2 *);
89131826Shartiint unisve_check_blli_id3(const struct unisve_blli_id3 *);
90131826Shartiint unisve_check_bhli(const struct unisve_bhli *);
91131826Sharti
92131826Shartiint unisve_check_sap(const struct uni_sap *);
93131826Sharti
94131826Shartiint unisve_overlap_addr(const struct unisve_addr *, const struct unisve_addr *);
95131826Shartiint unisve_overlap_selector(const struct unisve_selector *,
96131826Sharti    const struct unisve_selector *);
97131826Shartiint unisve_overlap_blli_id2(const struct unisve_blli_id2 *,
98131826Sharti    const struct unisve_blli_id2 *);
99131826Shartiint unisve_overlap_blli_id3(const struct unisve_blli_id3 *,
100131826Sharti    const struct unisve_blli_id3 *);
101131826Shartiint unisve_overlap_bhli(const struct unisve_bhli *,
102131826Sharti    const struct unisve_bhli *);
103131826Shartiint unisve_overlap_sap(const struct uni_sap *, const struct uni_sap *);
104131826Sharti
105131826Shartiint unisve_is_catchall(const struct uni_sap *);
106131826Shartiint unisve_match(const struct uni_sap *, const struct uni_ie_called *,
107131826Sharti	const struct uni_ie_blli *, const struct uni_ie_bhli *);
108131826Sharti
109131826Shartienum {
110131826Sharti	UNISVE_OK = 0,
111131826Sharti	UNISVE_ERROR_BAD_TAG,
112131826Sharti	UNISVE_ERROR_TYPE_PLAN_CONFLICT,
113131826Sharti	UNISVE_ERROR_ADDR_SEL_CONFLICT,
114131826Sharti	UNISVE_ERROR_ADDR_LEN,
115131826Sharti	UNISVE_ERROR_BAD_ADDR_TYPE,
116131826Sharti	UNISVE_ERROR_BAD_BHLI_TYPE,
117131826Sharti	UNISVE_ERROR_BAD_BHLI_LEN,
118131826Sharti};
119131826Sharti
120131826Sharti#define UNISVE_ERRSTR					\
121131826Sharti	"no error",					\
122131826Sharti	"bad SVE tag",					\
123131826Sharti	"bad address type/plan combination",		\
124131826Sharti	"bad address plan/selector tag combination",	\
125131826Sharti	"bad address length in SVE",			\
126131826Sharti	"unknown address type in SVE",			\
127131826Sharti	"bad BHLI type in SVE",				\
128131826Sharti	"BHLI info too long in SVE",
129131826Sharti
130131826Sharti#endif
131