Actually hook powernow.4 into the build.
[dragonfly.git] / sys / netinet / sctputil.h
blob85c0d9ec38d9ac2f4a0b288c09a713dc557725f9
1 /* $KAME: sctputil.h,v 1.14 2004/08/17 04:06:21 itojun Exp $ */
2 /* $DragonFly: src/sys/netinet/sctputil.h,v 1.6 2007/04/22 01:13:14 dillon Exp $ */
4 #ifndef _NETINET_SCTPUTIL_H_
5 #define _NETINET_SCTPUTIL_H_
7 /*
8 * Copyright (C) 2002, 2003, 2004 Cisco Systems Inc,
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the project nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
36 #ifndef _SYS_TYPES_H_
37 #include <sys/types.h>
38 #endif
39 #ifndef _SYS_SOCKET_H_
40 #include <sys/socket.h>
41 #endif
43 #if defined(_KERNEL) || (defined(__APPLE__) && defined(KERNEL))
45 #ifdef SCTP_MBUF_DEBUG
46 #define sctp_m_freem(m) do { \
47 kprintf("m_freem(%p) m->nxtpkt:%p at %s[%d]\n", \
48 (m), (m)->m_next, __FILE__, __LINE__); \
49 m_freem(m); \
50 } while (0);
51 #else
52 #define sctp_m_freem m_freem
53 #endif
55 #ifdef __APPLE__
56 struct mbuf *sctp_m_copym(struct mbuf *m, int off, int len, int wait);
57 #else
58 #define sctp_m_copym m_copym
59 #endif /* __APPLE__ */
62 * Zone(pool) allocation routines: MUST be defined for each OS
63 * zone = zone/pool pointer
64 * name = string name of the zone/pool
65 * size = size of each zone/pool element
66 * number = number of elements in zone/pool
68 #if defined(__FreeBSD__) || defined(__DragonFly__)
69 #if __FreeBSD_version >= 500000
70 #include <vm/uma.h>
71 #endif
72 #elif defined(__NetBSD__) || defined(__OpenBSD__)
73 #include <sys/pool.h>
74 #endif
76 /* SCTP_ZONE_INIT: initialize the zone */
77 #if defined(__FreeBSD__) || defined(__DragonFly__)
78 #if __FreeBSD_version >= 500000
79 #define UMA_ZFLAG_FULL 0x0020
80 #define SCTP_ZONE_INIT(zone, name, size, number) { \
81 zone = uma_zcreate(name, size, NULL, NULL, NULL, NULL, UMA_ALIGN_PTR,\
82 UMA_ZFLAG_FULL); \
83 uma_zone_set_max(zone, number); \
85 #else
86 #define SCTP_ZONE_INIT(zone, name, size, number) \
87 do { \
88 zone.ks_shortdesc = name; \
89 zone.ks_size = size; \
90 zone.ks_magic = M_MAGIC; \
91 malloc_init(&zone); \
92 } while(0)
93 #endif
94 #elif defined(__APPLE__)
95 #define SCTP_ZONE_INIT(zone, name, size, number) \
96 zone = (void *)zinit(size, number * size, number, name);
97 #elif defined(__OpenBSD__) || defined(__NetBSD__)
98 #define SCTP_ZONE_INIT(zone, name, size, number) \
99 pool_init(&(zone), size, 0, 0, 0, name, NULL);
100 #else
101 /* don't know this OS! */
102 force_comile_error;
103 #endif
105 /* SCTP_ZONE_GET: allocate element from the zone */
106 #if defined(__FreeBSD__)
107 #if __FreeBSD_version >= 500000
108 #define SCTP_ZONE_GET(zone) \
109 uma_zalloc(zone, M_NOWAIT);
110 #else
111 #define SCTP_ZONE_GET(zone) \
112 zalloci(zone);
113 #endif
114 #elif defined(__DragonFly__)
115 #define SCTP_ZONE_GET(zone) \
116 kmalloc(zone.ks_size, &zone, M_WAITOK|M_ZERO)
117 #elif defined(__APPLE__)
118 #define SCTP_ZONE_GET(zone) \
119 zalloc(zone);
120 #elif defined(__NetBSD__) || defined(__OpenBSD__)
121 #define SCTP_ZONE_GET(zone) \
122 pool_get(&zone, PR_NOWAIT);
123 #else
124 /* don't know this OS! */
125 force_comile_error;
126 #endif
128 /* SCTP_ZONE_FREE: free element from the zone */
129 #if defined(__FreeBSD__)
130 #if __FreeBSD_version >= 500000
131 #define SCTP_ZONE_FREE(zone, element) \
132 uma_zfree(zone, element);
133 #else
134 #define SCTP_ZONE_FREE(zone, element) \
135 zfreei(zone, element);
136 #endif
137 #elif defined(__DragonFly__)
138 #define SCTP_ZONE_FREE(zone, element) \
139 kfree(element, &zone)
140 #elif defined(__APPLE__)
141 #define SCTP_ZONE_FREE(zone, element) \
142 zfree(zone, element);
143 #elif defined(__NetBSD__) || defined(__OpenBSD__)
144 #define SCTP_ZONE_FREE(zone, element) \
145 pool_put(&zone, element);
146 #else
147 /* don't know this OS! */
148 force_comile_error;
149 #endif
151 #define sctp_get_associd(stcb) ((sctp_assoc_t)stcb->asoc.my_vtag)
154 * Function prototypes
157 struct mbuf;
158 struct ip;
159 struct sockbuf;
160 struct socket;
161 struct sockaddr_in6;
162 struct sctp_pcb;
163 struct sctp_tcb;
164 struct sctp_tmit_chunk;
165 struct sctpchunk_listhead;
166 struct sctphdr;
167 struct sctp_inpcb;
168 struct sctp_association;
169 struct sctp_nets;
171 struct ifaddr *sctp_find_ifa_by_addr(struct sockaddr *sa);
173 u_int32_t sctp_select_initial_TSN(struct sctp_pcb *);
175 u_int32_t sctp_select_a_tag(struct sctp_inpcb *);
177 int sctp_init_asoc(struct sctp_inpcb *, struct sctp_association *, int, uint32_t);
179 void sctp_fill_random_store(struct sctp_pcb *);
181 int sctp_timer_start(int, struct sctp_inpcb *, struct sctp_tcb *,
182 struct sctp_nets *);
184 int sctp_timer_stop(int, struct sctp_inpcb *, struct sctp_tcb *,
185 struct sctp_nets *);
187 u_int32_t sctp_calculate_sum(struct mbuf *, int32_t *, u_int32_t);
189 void sctp_mtu_size_reset(struct sctp_inpcb *, struct sctp_association *,
190 u_long);
192 int find_next_best_mtu(int);
194 u_int32_t sctp_calculate_rto(struct sctp_tcb *, struct sctp_association *,
195 struct sctp_nets *, struct timeval *);
197 u_int32_t sctp_calculate_len(struct mbuf *);
199 caddr_t sctp_m_getptr(struct mbuf *, int, int, u_int8_t *);
201 struct sctp_paramhdr *sctp_get_next_param(struct mbuf *, int,
202 struct sctp_paramhdr *, int);
204 int sctp_add_pad_tombuf(struct mbuf *, int);
206 int sctp_pad_lastmbuf(struct mbuf *, int);
208 void sctp_ulp_notify(u_int32_t, struct sctp_tcb *, u_int32_t, void *);
210 void sctp_report_all_outbound(struct sctp_tcb *);
212 int sctp_expand_mapping_array(struct sctp_association *);
214 void sctp_abort_notification(struct sctp_tcb *, int);
216 /* We abort responding to an IP packet for some reason */
217 void sctp_abort_association(struct sctp_inpcb *, struct sctp_tcb *,
218 struct mbuf *, int, struct sctphdr *, struct mbuf *);
220 /* We choose to abort via user input */
221 void sctp_abort_an_association(struct sctp_inpcb *, struct sctp_tcb *, int,
222 struct mbuf *);
224 void sctp_handle_ootb(struct mbuf *, int, int, struct sctphdr *,
225 struct sctp_inpcb *, struct mbuf *);
227 int sctp_is_there_an_abort_here(struct mbuf *, int, int *);
228 uint32_t sctp_is_same_scope(struct sockaddr_in6 *, struct sockaddr_in6 *);
229 struct sockaddr_in6 *sctp_recover_scope(struct sockaddr_in6 *,
230 struct sockaddr_in6 *);
232 int sctp_cmpaddr(struct sockaddr *, struct sockaddr *);
234 void sctp_print_address(struct sockaddr *);
235 void sctp_print_address_pkt(struct ip *, struct sctphdr *);
237 int sctp_sbappendaddr_nocheck(struct signalsockbuf *, struct sockaddr *,
238 struct mbuf *, struct mbuf *, u_int32_t, struct sctp_inpcb *);
241 int sctp_release_pr_sctp_chunk(struct sctp_tcb *, struct sctp_tmit_chunk *,
242 int, struct sctpchunk_listhead *);
244 struct mbuf *sctp_generate_invmanparam(int);
247 * this is an evil layer violation that I think is a hack.. but I stand
248 * alone on the tsvwg in this thought... everyone else considers it part
249 * of the sockets layer (along with all of the peeloff code :<)
251 u_int32_t sctp_get_first_vtag_from_sb(struct socket *);
254 void sctp_grub_through_socket_buffer(struct sctp_inpcb *, struct socket *,
255 struct socket *, struct sctp_tcb *);
257 void sctp_free_bufspace(struct sctp_tcb *, struct sctp_association *,
258 struct sctp_tmit_chunk *);
260 #ifdef SCTP_STAT_LOGGING
261 void sctp_log_strm_del_alt(u_int32_t, u_int16_t, int);
263 void sctp_log_strm_del(struct sctp_tmit_chunk *, struct sctp_tmit_chunk *, int);
264 void sctp_log_cwnd(struct sctp_nets *, int, uint8_t);
265 void sctp_log_maxburst(struct sctp_nets *, int, int, uint8_t);
266 void sctp_log_block(uint8_t, struct socket *, struct sctp_association *);
267 void sctp_log_rwnd(uint8_t, u_int32_t, u_int32_t, u_int32_t );
268 void sctp_log_mbcnt(uint8_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t);
269 void sctp_log_rwnd_set(uint8_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t);
270 int sctp_fill_stat_log(struct mbuf *);
271 void sctp_log_fr(uint32_t, uint32_t, uint32_t, int);
272 void sctp_log_map(uint32_t, uint32_t, uint32_t, int);
274 void sctp_clr_stat_log(void);
276 #endif
278 #ifdef SCTP_AUDITING_ENABLED
279 void sctp_auditing(int, struct sctp_inpcb *, struct sctp_tcb *,
280 struct sctp_nets *);
281 void sctp_audit_log(u_int8_t, u_int8_t);
283 #endif
285 #if defined(SCTP_BASE_FREEBSD) || defined(__DragonFly__)
286 /* Note: these are in <sys/time.h>, but not in kernel space */
287 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
288 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
289 #define timercmp(tvp, uvp, cmp) \
290 (((tvp)->tv_sec == (uvp)->tv_sec) ? \
291 ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
292 ((tvp)->tv_sec cmp (uvp)->tv_sec))
293 #define timeradd(tvp, uvp, vvp) \
294 do { \
295 (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
296 (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
297 if ((vvp)->tv_usec >= 1000000) { \
298 (vvp)->tv_sec++; \
299 (vvp)->tv_usec -= 1000000; \
301 } while (/* CONSTCOND */ 0)
302 #define timersub(tvp, uvp, vvp) \
303 do { \
304 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
305 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
306 if ((vvp)->tv_usec < 0) { \
307 (vvp)->tv_sec--; \
308 (vvp)->tv_usec += 1000000; \
310 } while (/* CONSTCOND */ 0)
311 #endif /* SCTP_BASE_FREEBSD */
313 #endif /* _KERNEL */
314 #endif