]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/contrib/ngatm/netnatm/sig/unimkmsg.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / contrib / ngatm / netnatm / sig / unimkmsg.h
1 /*
2  * Copyright (c) 2001-2003
3  *      Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4  *      All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * Author: Hartmut Brandt <harti@freebsd.org>
28  *
29  * $Begemot: libunimsg/netnatm/sig/unimkmsg.h,v 1.4 2003/09/19 12:03:34 hbb Exp $
30  *
31  * Macros to make messages.
32  */
33
34 #define MK_MSG_ORIG(MSG,TYPE,CREF,FLAG)                                 \
35     do {                                                                \
36         (MSG)->mtype = (TYPE);                                          \
37         (MSG)->u.hdr.cref.cref = (CREF);                                \
38         (MSG)->u.hdr.cref.flag = (FLAG);                                \
39         (MSG)->u.hdr.act = UNI_MSGACT_DEFAULT;                          \
40     } while(0)
41
42 #define MK_MSG_RESP(MSG,TYPE,CREF)                                      \
43     do {                                                                \
44         (MSG)->mtype = (TYPE);                                          \
45         (MSG)->u.hdr.cref.cref = (CREF)->cref;                          \
46         (MSG)->u.hdr.cref.flag = !(CREF)->flag;                         \
47         (MSG)->u.hdr.act = UNI_MSGACT_DEFAULT;                          \
48     } while(0)
49
50 #define MK_IE_CALLSTATE(IE,CS)                                          \
51     do {                                                                \
52         (IE).h.present = 0;                                             \
53         IE_SETPRESENT(IE);                                              \
54         (IE).h.coding = UNI_CODING_ITU;                                 \
55         (IE).h.act = UNI_IEACT_DEFAULT;                                 \
56         (IE).state = CS;                                                \
57     } while(0)
58
59 #define MK_IE_EPREF(IE,EPREF,FLAG)                                      \
60     do {                                                                \
61         (IE).h.present = 0;                                             \
62         IE_SETPRESENT(IE);                                              \
63         (IE).h.coding = UNI_CODING_ITU;                                 \
64         (IE).h.act = UNI_IEACT_DEFAULT;                                 \
65         (IE).epref = EPREF;                                             \
66         (IE).flag = FLAG;                                               \
67     } while(0)
68
69 #define MK_IE_EPSTATE(IE,STATE)                                         \
70     do {                                                                \
71         (IE).h.present = 0;                                             \
72         IE_SETPRESENT(IE);                                              \
73         (IE).h.coding = UNI_CODING_ITU;                                 \
74         (IE).h.act = UNI_IEACT_DEFAULT;                                 \
75         (IE).state = STATE;                                             \
76     } while(0)
77
78 #define MK_IE_CAUSE(IE,LOC,CAUSE)                                       \
79     do {                                                                \
80         (IE).h.present = 0;                                             \
81         IE_SETPRESENT(IE);                                              \
82         (IE).h.coding = UNI_CODING_ITU;                                 \
83         (IE).h.act = UNI_IEACT_DEFAULT;                                 \
84         (IE).loc = LOC;                                                 \
85         (IE).cause = CAUSE;                                             \
86     } while(0)
87
88 #define ADD_CAUSE_MTYPE(IE,MTYPE)                                       \
89     do {                                                                \
90         (IE).h.present |= UNI_CAUSE_MTYPE_P;                            \
91         (IE).u.mtype = MTYPE;                                           \
92     } while(0)
93
94 #define ADD_CAUSE_CHANNID(IE,VPI,VCI)                                   \
95     do {                                                                \
96         (IE).h.present |= UNI_CAUSE_VPCI_P;                             \
97         (IE).u.vpci.vpci = VPI;                                         \
98         (IE).u.vpci.vci = VCI;                                          \
99     } while(0)
100
101 #define ADD_CAUSE_TIMER(IE,TIMER)                                       \
102     do {                                                                \
103         (IE).h.present |= UNI_CAUSE_TIMER_P;                            \
104         (IE).u.timer[0] = (TIMER)[0];                                   \
105         (IE).u.timer[1] = (TIMER)[1];                                   \
106         (IE).u.timer[2] = (TIMER)[2];                                   \
107     } while(0)
108
109 /************************************************************/
110
111 #define COPY_FROM_RELEASE_COMPL(U,DEST)                                 \
112     do {                                                                \
113         u_int _i, _j;                                                   \
114                                                                         \
115         for(_i = _j = 0; _i < 2; _i++)                                  \
116                 if(IE_ISGOOD((U)->u.release_compl.cause[_i]))           \
117                         (DEST)->cause[_j++] =                           \
118                             (U)->u.release_compl.cause[_i];             \
119         for(_i = _j = 0; _i < UNI_NUM_IE_GIT; _i++)                     \
120                 if(IE_ISGOOD((U)->u.release_compl.git[_i]))             \
121                         (DEST)->git[_j++] =                             \
122                             (U)->u.release_compl.git[_i];               \
123         if(IE_ISGOOD((U)->u.release_compl.uu))                          \
124                 (DEST)->uu = (U)->u.release_compl.uu;                   \
125         if(IE_ISGOOD((U)->u.release_compl.crankback))                   \
126                 (DEST)->crankback = (U)->u.release_compl.crankback;     \
127     } while(0)
128
129 #define COPY_FROM_DROP_ACK(U,DEST)                                      \
130     do {                                                                \
131         u_int _i, _j;                                                   \
132                                                                         \
133         if(IE_ISGOOD((U)->u.drop_party_ack.epref))                      \
134                 (DEST)->epref = (U)->u.drop_party_ack.epref;            \
135         if(IE_ISGOOD((U)->u.drop_party_ack.cause))                      \
136                 (DEST)->cause = (U)->u.drop_party_ack.cause;            \
137         if(IE_ISGOOD((U)->u.drop_party_ack.uu))                         \
138                 (DEST)->uu = (U)->u.drop_party_ack.uu;                  \
139         for(_i = _j = 0; _i < UNI_NUM_IE_GIT; _i++)                     \
140                 if(IE_ISGOOD((U)->u.drop_party_ack.git[_i]))            \
141                         (DEST)->git[_j++] =                             \
142                             (U)->u.drop_party_ack.git[_i];              \
143     } while(0)
144
145 #define COPY_FROM_ADD_REJ(U,DEST)                                       \
146     do {                                                                \
147         u_int _i, _j;                                                   \
148                                                                         \
149         if(IE_ISGOOD((U)->u.add_party_rej.epref))                       \
150                 (DEST)->epref = (U)->u.add_party_rej.epref;             \
151         if(IE_ISGOOD((U)->u.add_party_rej.cause))                       \
152                 (DEST)->cause = (U)->u.add_party_rej.cause;             \
153         if(IE_ISGOOD((U)->u.add_party_rej.uu))                          \
154                 (DEST)->uu = (U)->u.add_party_rej.uu;                   \
155         for(_i = _j = 0; _i < UNI_NUM_IE_GIT; _i++)                     \
156                 if(IE_ISGOOD((U)->u.add_party_rej.git[_i]))             \
157                         (DEST)->git[_j++] =                             \
158                             (U)->u.add_party_rej.git[_i];               \
159     } while(0)