structs.h 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801
  1. /* SCTP kernel reference Implementation
  2. * (C) Copyright IBM Corp. 2001, 2004
  3. * Copyright (c) 1999-2000 Cisco, Inc.
  4. * Copyright (c) 1999-2001 Motorola, Inc.
  5. * Copyright (c) 2001 Intel Corp.
  6. *
  7. * This file is part of the SCTP kernel reference Implementation
  8. *
  9. * The SCTP reference implementation is free software;
  10. * you can redistribute it and/or modify it under the terms of
  11. * the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2, or (at your option)
  13. * any later version.
  14. *
  15. * The SCTP reference implementation is distributed in the hope that it
  16. * will be useful, but WITHOUT ANY WARRANTY; without even the implied
  17. * ************************
  18. * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  19. * See the GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with GNU CC; see the file COPYING. If not, write to
  23. * the Free Software Foundation, 59 Temple Place - Suite 330,
  24. * Boston, MA 02111-1307, USA.
  25. *
  26. * Please send any bug reports or fixes you make to the
  27. * email addresses:
  28. * lksctp developers <lksctp-developers@lists.sourceforge.net>
  29. *
  30. * Or submit a bug report through the following website:
  31. * http://www.sf.net/projects/lksctp
  32. *
  33. * Written or modified by:
  34. * Randall Stewart <randall@sctp.chicago.il.us>
  35. * Ken Morneau <kmorneau@cisco.com>
  36. * Qiaobing Xie <qxie1@email.mot.com>
  37. * La Monte H.P. Yarroll <piggy@acm.org>
  38. * Karl Knutson <karl@athena.chicago.il.us>
  39. * Jon Grimm <jgrimm@us.ibm.com>
  40. * Xingang Guo <xingang.guo@intel.com>
  41. * Hui Huang <hui.huang@nokia.com>
  42. * Sridhar Samudrala <sri@us.ibm.com>
  43. * Daisy Chang <daisyc@us.ibm.com>
  44. * Dajiang Zhang <dajiang.zhang@nokia.com>
  45. * Ardelle Fan <ardelle.fan@intel.com>
  46. * Ryan Layer <rmlayer@us.ibm.com>
  47. * Anup Pemmaiah <pemmaiah@cc.usu.edu>
  48. * Kevin Gao <kevin.gao@intel.com>
  49. *
  50. * Any bugs reported given to us we will try to fix... any fixes shared will
  51. * be incorporated into the next SCTP release.
  52. */
  53. #ifndef __sctp_structs_h__
  54. #define __sctp_structs_h__
  55. #include <linux/time.h> /* We get struct timespec. */
  56. #include <linux/socket.h> /* linux/in.h needs this!! */
  57. #include <linux/in.h> /* We get struct sockaddr_in. */
  58. #include <linux/in6.h> /* We get struct in6_addr */
  59. #include <linux/ipv6.h>
  60. #include <asm/param.h> /* We get MAXHOSTNAMELEN. */
  61. #include <asm/atomic.h> /* This gets us atomic counters. */
  62. #include <linux/skbuff.h> /* We need sk_buff_head. */
  63. #include <linux/workqueue.h> /* We need tq_struct. */
  64. #include <linux/sctp.h> /* We need sctp* header structs. */
  65. /* A convenience structure for handling sockaddr structures.
  66. * We should wean ourselves off this.
  67. */
  68. union sctp_addr {
  69. struct sockaddr_in v4;
  70. struct sockaddr_in6 v6;
  71. struct sockaddr sa;
  72. };
  73. /* Forward declarations for data structures. */
  74. struct sctp_globals;
  75. struct sctp_endpoint;
  76. struct sctp_association;
  77. struct sctp_transport;
  78. struct sctp_packet;
  79. struct sctp_chunk;
  80. struct sctp_inq;
  81. struct sctp_outq;
  82. struct sctp_bind_addr;
  83. struct sctp_ulpq;
  84. struct sctp_ep_common;
  85. struct sctp_ssnmap;
  86. #include <net/sctp/tsnmap.h>
  87. #include <net/sctp/ulpevent.h>
  88. #include <net/sctp/ulpqueue.h>
  89. /* Structures useful for managing bind/connect. */
  90. struct sctp_bind_bucket {
  91. unsigned short port;
  92. unsigned short fastreuse;
  93. struct sctp_bind_bucket *next;
  94. struct sctp_bind_bucket **pprev;
  95. struct hlist_head owner;
  96. };
  97. struct sctp_bind_hashbucket {
  98. spinlock_t lock;
  99. struct sctp_bind_bucket *chain;
  100. };
  101. /* Used for hashing all associations. */
  102. struct sctp_hashbucket {
  103. rwlock_t lock;
  104. struct sctp_ep_common *chain;
  105. } __attribute__((__aligned__(8)));
  106. /* The SCTP globals structure. */
  107. extern struct sctp_globals {
  108. /* RFC2960 Section 14. Suggested SCTP Protocol Parameter Values
  109. *
  110. * The following protocol parameters are RECOMMENDED:
  111. *
  112. * RTO.Initial - 3 seconds
  113. * RTO.Min - 1 second
  114. * RTO.Max - 60 seconds
  115. * RTO.Alpha - 1/8 (3 when converted to right shifts.)
  116. * RTO.Beta - 1/4 (2 when converted to right shifts.)
  117. */
  118. __u32 rto_initial;
  119. __u32 rto_min;
  120. __u32 rto_max;
  121. /* Note: rto_alpha and rto_beta are really defined as inverse
  122. * powers of two to facilitate integer operations.
  123. */
  124. int rto_alpha;
  125. int rto_beta;
  126. /* Max.Burst - 4 */
  127. int max_burst;
  128. /* Valid.Cookie.Life - 60 seconds */
  129. int valid_cookie_life;
  130. /* Whether Cookie Preservative is enabled(1) or not(0) */
  131. int cookie_preserve_enable;
  132. /* Association.Max.Retrans - 10 attempts
  133. * Path.Max.Retrans - 5 attempts (per destination address)
  134. * Max.Init.Retransmits - 8 attempts
  135. */
  136. int max_retrans_association;
  137. int max_retrans_path;
  138. int max_retrans_init;
  139. /*
  140. * Policy for preforming sctp/socket accounting
  141. * 0 - do socket level accounting, all assocs share sk_sndbuf
  142. * 1 - do sctp accounting, each asoc may use sk_sndbuf bytes
  143. */
  144. int sndbuf_policy;
  145. /*
  146. * Policy for preforming sctp/socket accounting
  147. * 0 - do socket level accounting, all assocs share sk_rcvbuf
  148. * 1 - do sctp accounting, each asoc may use sk_rcvbuf bytes
  149. */
  150. int rcvbuf_policy;
  151. /* Delayed SACK timeout 200ms default*/
  152. int sack_timeout;
  153. /* HB.interval - 30 seconds */
  154. int hb_interval;
  155. /* The following variables are implementation specific. */
  156. /* Default initialization values to be applied to new associations. */
  157. __u16 max_instreams;
  158. __u16 max_outstreams;
  159. /* This is a list of groups of functions for each address
  160. * family that we support.
  161. */
  162. struct list_head address_families;
  163. /* This is the hash of all endpoints. */
  164. int ep_hashsize;
  165. struct sctp_hashbucket *ep_hashtable;
  166. /* This is the hash of all associations. */
  167. int assoc_hashsize;
  168. struct sctp_hashbucket *assoc_hashtable;
  169. /* This is the sctp port control hash. */
  170. int port_hashsize;
  171. int port_rover;
  172. spinlock_t port_alloc_lock; /* Protects port_rover. */
  173. struct sctp_bind_hashbucket *port_hashtable;
  174. /* This is the global local address list.
  175. * We actively maintain this complete list of interfaces on
  176. * the system by catching routing events.
  177. *
  178. * It is a list of sctp_sockaddr_entry.
  179. */
  180. struct list_head local_addr_list;
  181. spinlock_t local_addr_lock;
  182. /* Flag to indicate if addip is enabled. */
  183. int addip_enable;
  184. /* Flag to indicate if PR-SCTP is enabled. */
  185. int prsctp_enable;
  186. } sctp_globals;
  187. #define sctp_rto_initial (sctp_globals.rto_initial)
  188. #define sctp_rto_min (sctp_globals.rto_min)
  189. #define sctp_rto_max (sctp_globals.rto_max)
  190. #define sctp_rto_alpha (sctp_globals.rto_alpha)
  191. #define sctp_rto_beta (sctp_globals.rto_beta)
  192. #define sctp_max_burst (sctp_globals.max_burst)
  193. #define sctp_valid_cookie_life (sctp_globals.valid_cookie_life)
  194. #define sctp_cookie_preserve_enable (sctp_globals.cookie_preserve_enable)
  195. #define sctp_max_retrans_association (sctp_globals.max_retrans_association)
  196. #define sctp_sndbuf_policy (sctp_globals.sndbuf_policy)
  197. #define sctp_rcvbuf_policy (sctp_globals.rcvbuf_policy)
  198. #define sctp_max_retrans_path (sctp_globals.max_retrans_path)
  199. #define sctp_max_retrans_init (sctp_globals.max_retrans_init)
  200. #define sctp_sack_timeout (sctp_globals.sack_timeout)
  201. #define sctp_hb_interval (sctp_globals.hb_interval)
  202. #define sctp_max_instreams (sctp_globals.max_instreams)
  203. #define sctp_max_outstreams (sctp_globals.max_outstreams)
  204. #define sctp_address_families (sctp_globals.address_families)
  205. #define sctp_ep_hashsize (sctp_globals.ep_hashsize)
  206. #define sctp_ep_hashtable (sctp_globals.ep_hashtable)
  207. #define sctp_assoc_hashsize (sctp_globals.assoc_hashsize)
  208. #define sctp_assoc_hashtable (sctp_globals.assoc_hashtable)
  209. #define sctp_port_hashsize (sctp_globals.port_hashsize)
  210. #define sctp_port_rover (sctp_globals.port_rover)
  211. #define sctp_port_alloc_lock (sctp_globals.port_alloc_lock)
  212. #define sctp_port_hashtable (sctp_globals.port_hashtable)
  213. #define sctp_local_addr_list (sctp_globals.local_addr_list)
  214. #define sctp_local_addr_lock (sctp_globals.local_addr_lock)
  215. #define sctp_addip_enable (sctp_globals.addip_enable)
  216. #define sctp_prsctp_enable (sctp_globals.prsctp_enable)
  217. /* SCTP Socket type: UDP or TCP style. */
  218. typedef enum {
  219. SCTP_SOCKET_UDP = 0,
  220. SCTP_SOCKET_UDP_HIGH_BANDWIDTH,
  221. SCTP_SOCKET_TCP
  222. } sctp_socket_type_t;
  223. /* Per socket SCTP information. */
  224. struct sctp_sock {
  225. /* inet_sock has to be the first member of sctp_sock */
  226. struct inet_sock inet;
  227. /* What kind of a socket is this? */
  228. sctp_socket_type_t type;
  229. /* PF_ family specific functions. */
  230. struct sctp_pf *pf;
  231. /* Access to HMAC transform. */
  232. struct crypto_tfm *hmac;
  233. /* What is our base endpointer? */
  234. struct sctp_endpoint *ep;
  235. struct sctp_bind_bucket *bind_hash;
  236. /* Various Socket Options. */
  237. __u16 default_stream;
  238. __u32 default_ppid;
  239. __u16 default_flags;
  240. __u32 default_context;
  241. __u32 default_timetolive;
  242. struct sctp_initmsg initmsg;
  243. struct sctp_rtoinfo rtoinfo;
  244. struct sctp_paddrparams paddrparam;
  245. struct sctp_event_subscribe subscribe;
  246. struct sctp_assocparams assocparams;
  247. int user_frag;
  248. __u32 autoclose;
  249. __u8 nodelay;
  250. __u8 disable_fragments;
  251. __u8 pd_mode;
  252. __u8 v4mapped;
  253. __u32 adaption_ind;
  254. /* Receive to here while partial delivery is in effect. */
  255. struct sk_buff_head pd_lobby;
  256. };
  257. static inline struct sctp_sock *sctp_sk(const struct sock *sk)
  258. {
  259. return (struct sctp_sock *)sk;
  260. }
  261. static inline struct sock *sctp_opt2sk(const struct sctp_sock *sp)
  262. {
  263. return (struct sock *)sp;
  264. }
  265. #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
  266. struct sctp6_sock {
  267. struct sctp_sock sctp;
  268. struct ipv6_pinfo inet6;
  269. };
  270. #endif /* CONFIG_IPV6 */
  271. /* This is our APPLICATION-SPECIFIC state cookie.
  272. * THIS IS NOT DICTATED BY THE SPECIFICATION.
  273. */
  274. /* These are the parts of an association which we send in the cookie.
  275. * Most of these are straight out of:
  276. * RFC2960 12.2 Parameters necessary per association (i.e. the TCB)
  277. *
  278. */
  279. struct sctp_cookie {
  280. /* My : Tag expected in every inbound packet and sent
  281. * Verification: in the INIT or INIT ACK chunk.
  282. * Tag :
  283. */
  284. __u32 my_vtag;
  285. /* Peer's : Tag expected in every outbound packet except
  286. * Verification: in the INIT chunk.
  287. * Tag :
  288. */
  289. __u32 peer_vtag;
  290. /* The rest of these are not from the spec, but really need to
  291. * be in the cookie.
  292. */
  293. /* My Tie Tag : Assist in discovering a restarting association. */
  294. __u32 my_ttag;
  295. /* Peer's Tie Tag: Assist in discovering a restarting association. */
  296. __u32 peer_ttag;
  297. /* When does this cookie expire? */
  298. struct timeval expiration;
  299. /* Number of inbound/outbound streams which are set
  300. * and negotiated during the INIT process.
  301. */
  302. __u16 sinit_num_ostreams;
  303. __u16 sinit_max_instreams;
  304. /* This is the first sequence number I used. */
  305. __u32 initial_tsn;
  306. /* This holds the originating address of the INIT packet. */
  307. union sctp_addr peer_addr;
  308. /* IG Section 2.35.3
  309. * Include the source port of the INIT-ACK
  310. */
  311. __u16 my_port;
  312. __u8 prsctp_capable;
  313. /* Padding for future use */
  314. __u8 padding;
  315. __u32 adaption_ind;
  316. /* This is a shim for my peer's INIT packet, followed by
  317. * a copy of the raw address list of the association.
  318. * The length of the raw address list is saved in the
  319. * raw_addr_list_len field, which will be used at the time when
  320. * the association TCB is re-constructed from the cookie.
  321. */
  322. __u32 raw_addr_list_len;
  323. struct sctp_init_chunk peer_init[0];
  324. };
  325. /* The format of our cookie that we send to our peer. */
  326. struct sctp_signed_cookie {
  327. __u8 signature[SCTP_SECRET_SIZE];
  328. struct sctp_cookie c;
  329. };
  330. /* This is another convenience type to allocate memory for address
  331. * params for the maximum size and pass such structures around
  332. * internally.
  333. */
  334. union sctp_addr_param {
  335. struct sctp_ipv4addr_param v4;
  336. struct sctp_ipv6addr_param v6;
  337. };
  338. /* A convenience type to allow walking through the various
  339. * parameters and avoid casting all over the place.
  340. */
  341. union sctp_params {
  342. void *v;
  343. struct sctp_paramhdr *p;
  344. struct sctp_cookie_preserve_param *life;
  345. struct sctp_hostname_param *dns;
  346. struct sctp_cookie_param *cookie;
  347. struct sctp_supported_addrs_param *sat;
  348. struct sctp_ipv4addr_param *v4;
  349. struct sctp_ipv6addr_param *v6;
  350. union sctp_addr_param *addr;
  351. struct sctp_adaption_ind_param *aind;
  352. };
  353. /* RFC 2960. Section 3.3.5 Heartbeat.
  354. * Heartbeat Information: variable length
  355. * The Sender-specific Heartbeat Info field should normally include
  356. * information about the sender's current time when this HEARTBEAT
  357. * chunk is sent and the destination transport address to which this
  358. * HEARTBEAT is sent (see Section 8.3).
  359. */
  360. typedef struct sctp_sender_hb_info {
  361. struct sctp_paramhdr param_hdr;
  362. union sctp_addr daddr;
  363. unsigned long sent_at;
  364. } __attribute__((packed)) sctp_sender_hb_info_t;
  365. /*
  366. * RFC 2960 1.3.2 Sequenced Delivery within Streams
  367. *
  368. * The term "stream" is used in SCTP to refer to a sequence of user
  369. * messages that are to be delivered to the upper-layer protocol in
  370. * order with respect to other messages within the same stream. This is
  371. * in contrast to its usage in TCP, where it refers to a sequence of
  372. * bytes (in this document a byte is assumed to be eight bits).
  373. * ...
  374. *
  375. * This is the structure we use to track both our outbound and inbound
  376. * SSN, or Stream Sequence Numbers.
  377. */
  378. struct sctp_stream {
  379. __u16 *ssn;
  380. unsigned int len;
  381. };
  382. struct sctp_ssnmap {
  383. struct sctp_stream in;
  384. struct sctp_stream out;
  385. int malloced;
  386. };
  387. struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
  388. gfp_t gfp);
  389. void sctp_ssnmap_free(struct sctp_ssnmap *map);
  390. void sctp_ssnmap_clear(struct sctp_ssnmap *map);
  391. /* What is the current SSN number for this stream? */
  392. static inline __u16 sctp_ssn_peek(struct sctp_stream *stream, __u16 id)
  393. {
  394. return stream->ssn[id];
  395. }
  396. /* Return the next SSN number for this stream. */
  397. static inline __u16 sctp_ssn_next(struct sctp_stream *stream, __u16 id)
  398. {
  399. return stream->ssn[id]++;
  400. }
  401. /* Skip over this ssn and all below. */
  402. static inline void sctp_ssn_skip(struct sctp_stream *stream, __u16 id,
  403. __u16 ssn)
  404. {
  405. stream->ssn[id] = ssn+1;
  406. }
  407. /*
  408. * Pointers to address related SCTP functions.
  409. * (i.e. things that depend on the address family.)
  410. */
  411. struct sctp_af {
  412. int (*sctp_xmit) (struct sk_buff *skb,
  413. struct sctp_transport *,
  414. int ipfragok);
  415. int (*setsockopt) (struct sock *sk,
  416. int level,
  417. int optname,
  418. char __user *optval,
  419. int optlen);
  420. int (*getsockopt) (struct sock *sk,
  421. int level,
  422. int optname,
  423. char __user *optval,
  424. int __user *optlen);
  425. struct dst_entry *(*get_dst) (struct sctp_association *asoc,
  426. union sctp_addr *daddr,
  427. union sctp_addr *saddr);
  428. void (*get_saddr) (struct sctp_association *asoc,
  429. struct dst_entry *dst,
  430. union sctp_addr *daddr,
  431. union sctp_addr *saddr);
  432. void (*copy_addrlist) (struct list_head *,
  433. struct net_device *);
  434. void (*dst_saddr) (union sctp_addr *saddr,
  435. struct dst_entry *dst,
  436. unsigned short port);
  437. int (*cmp_addr) (const union sctp_addr *addr1,
  438. const union sctp_addr *addr2);
  439. void (*addr_copy) (union sctp_addr *dst,
  440. union sctp_addr *src);
  441. void (*from_skb) (union sctp_addr *,
  442. struct sk_buff *skb,
  443. int saddr);
  444. void (*from_sk) (union sctp_addr *,
  445. struct sock *sk);
  446. void (*to_sk_saddr) (union sctp_addr *,
  447. struct sock *sk);
  448. void (*to_sk_daddr) (union sctp_addr *,
  449. struct sock *sk);
  450. void (*from_addr_param) (union sctp_addr *,
  451. union sctp_addr_param *,
  452. __u16 port, int iif);
  453. int (*to_addr_param) (const union sctp_addr *,
  454. union sctp_addr_param *);
  455. int (*addr_valid) (union sctp_addr *,
  456. struct sctp_sock *);
  457. sctp_scope_t (*scope) (union sctp_addr *);
  458. void (*inaddr_any) (union sctp_addr *, unsigned short);
  459. int (*is_any) (const union sctp_addr *);
  460. int (*available) (union sctp_addr *,
  461. struct sctp_sock *);
  462. int (*skb_iif) (const struct sk_buff *sk);
  463. int (*is_ce) (const struct sk_buff *sk);
  464. void (*seq_dump_addr)(struct seq_file *seq,
  465. union sctp_addr *addr);
  466. __u16 net_header_len;
  467. int sockaddr_len;
  468. sa_family_t sa_family;
  469. struct list_head list;
  470. };
  471. struct sctp_af *sctp_get_af_specific(sa_family_t);
  472. int sctp_register_af(struct sctp_af *);
  473. /* Protocol family functions. */
  474. struct sctp_pf {
  475. void (*event_msgname)(struct sctp_ulpevent *, char *, int *);
  476. void (*skb_msgname) (struct sk_buff *, char *, int *);
  477. int (*af_supported) (sa_family_t, struct sctp_sock *);
  478. int (*cmp_addr) (const union sctp_addr *,
  479. const union sctp_addr *,
  480. struct sctp_sock *);
  481. int (*bind_verify) (struct sctp_sock *, union sctp_addr *);
  482. int (*send_verify) (struct sctp_sock *, union sctp_addr *);
  483. int (*supported_addrs)(const struct sctp_sock *, __u16 *);
  484. struct sock *(*create_accept_sk) (struct sock *sk,
  485. struct sctp_association *asoc);
  486. void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
  487. struct sctp_af *af;
  488. };
  489. /* Structure to track chunk fragments that have been acked, but peer
  490. * fragments of the same message have not.
  491. */
  492. struct sctp_datamsg {
  493. /* Chunks waiting to be submitted to lower layer. */
  494. struct list_head chunks;
  495. /* Chunks that have been transmitted. */
  496. struct list_head track;
  497. /* Reference counting. */
  498. atomic_t refcnt;
  499. /* When is this message no longer interesting to the peer? */
  500. unsigned long expires_at;
  501. /* Did the messenge fail to send? */
  502. int send_error;
  503. char send_failed;
  504. /* Control whether chunks from this message can be abandoned. */
  505. char can_abandon;
  506. };
  507. struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *,
  508. struct sctp_sndrcvinfo *,
  509. struct msghdr *, int len);
  510. void sctp_datamsg_put(struct sctp_datamsg *);
  511. void sctp_datamsg_free(struct sctp_datamsg *);
  512. void sctp_datamsg_track(struct sctp_chunk *);
  513. void sctp_chunk_fail(struct sctp_chunk *, int error);
  514. int sctp_chunk_abandoned(struct sctp_chunk *);
  515. /* RFC2960 1.4 Key Terms
  516. *
  517. * o Chunk: A unit of information within an SCTP packet, consisting of
  518. * a chunk header and chunk-specific content.
  519. *
  520. * As a matter of convenience, we remember the SCTP common header for
  521. * each chunk as well as a few other header pointers...
  522. */
  523. struct sctp_chunk {
  524. struct list_head list;
  525. atomic_t refcnt;
  526. /* This is our link to the per-transport transmitted list. */
  527. struct list_head transmitted_list;
  528. /* This field is used by chunks that hold fragmented data.
  529. * For the first fragment this is the list that holds the rest of
  530. * fragments. For the remaining fragments, this is the link to the
  531. * frag_list maintained in the first fragment.
  532. */
  533. struct list_head frag_list;
  534. /* This points to the sk_buff containing the actual data. */
  535. struct sk_buff *skb;
  536. /* These are the SCTP headers by reverse order in a packet.
  537. * Note that some of these may happen more than once. In that
  538. * case, we point at the "current" one, whatever that means
  539. * for that level of header.
  540. */
  541. /* We point this at the FIRST TLV parameter to chunk_hdr. */
  542. union sctp_params param_hdr;
  543. union {
  544. __u8 *v;
  545. struct sctp_datahdr *data_hdr;
  546. struct sctp_inithdr *init_hdr;
  547. struct sctp_sackhdr *sack_hdr;
  548. struct sctp_heartbeathdr *hb_hdr;
  549. struct sctp_sender_hb_info *hbs_hdr;
  550. struct sctp_shutdownhdr *shutdown_hdr;
  551. struct sctp_signed_cookie *cookie_hdr;
  552. struct sctp_ecnehdr *ecne_hdr;
  553. struct sctp_cwrhdr *ecn_cwr_hdr;
  554. struct sctp_errhdr *err_hdr;
  555. struct sctp_addiphdr *addip_hdr;
  556. struct sctp_fwdtsn_hdr *fwdtsn_hdr;
  557. } subh;
  558. __u8 *chunk_end;
  559. struct sctp_chunkhdr *chunk_hdr;
  560. struct sctphdr *sctp_hdr;
  561. /* This needs to be recoverable for SCTP_SEND_FAILED events. */
  562. struct sctp_sndrcvinfo sinfo;
  563. /* Which association does this belong to? */
  564. struct sctp_association *asoc;
  565. /* What endpoint received this chunk? */
  566. struct sctp_ep_common *rcvr;
  567. /* We fill this in if we are calculating RTT. */
  568. unsigned long sent_at;
  569. /* What is the origin IP address for this chunk? */
  570. union sctp_addr source;
  571. /* Destination address for this chunk. */
  572. union sctp_addr dest;
  573. /* For outbound message, track all fragments for SEND_FAILED. */
  574. struct sctp_datamsg *msg;
  575. /* For an inbound chunk, this tells us where it came from.
  576. * For an outbound chunk, it tells us where we'd like it to
  577. * go. It is NULL if we have no preference.
  578. */
  579. struct sctp_transport *transport;
  580. __u8 rtt_in_progress; /* Is this chunk used for RTT calculation? */
  581. __u8 resent; /* Has this chunk ever been retransmitted. */
  582. __u8 has_tsn; /* Does this chunk have a TSN yet? */
  583. __u8 has_ssn; /* Does this chunk have a SSN yet? */
  584. __u8 singleton; /* Was this the only chunk in the packet? */
  585. __u8 end_of_packet; /* Was this the last chunk in the packet? */
  586. __u8 ecn_ce_done; /* Have we processed the ECN CE bit? */
  587. __u8 pdiscard; /* Discard the whole packet now? */
  588. __u8 tsn_gap_acked; /* Is this chunk acked by a GAP ACK? */
  589. __u8 fast_retransmit; /* Is this chunk fast retransmitted? */
  590. __u8 tsn_missing_report; /* Data chunk missing counter. */
  591. };
  592. void sctp_chunk_hold(struct sctp_chunk *);
  593. void sctp_chunk_put(struct sctp_chunk *);
  594. int sctp_user_addto_chunk(struct sctp_chunk *chunk, int off, int len,
  595. struct iovec *data);
  596. void sctp_chunk_free(struct sctp_chunk *);
  597. void *sctp_addto_chunk(struct sctp_chunk *, int len, const void *data);
  598. struct sctp_chunk *sctp_chunkify(struct sk_buff *,
  599. const struct sctp_association *,
  600. struct sock *);
  601. void sctp_init_addrs(struct sctp_chunk *, union sctp_addr *,
  602. union sctp_addr *);
  603. const union sctp_addr *sctp_source(const struct sctp_chunk *chunk);
  604. /* This is a structure for holding either an IPv6 or an IPv4 address. */
  605. /* sin_family -- AF_INET or AF_INET6
  606. * sin_port -- ordinary port number
  607. * sin_addr -- cast to either (struct in_addr) or (struct in6_addr)
  608. */
  609. struct sctp_sockaddr_entry {
  610. struct list_head list;
  611. union sctp_addr a;
  612. };
  613. typedef struct sctp_chunk *(sctp_packet_phandler_t)(struct sctp_association *);
  614. /* This structure holds lists of chunks as we are assembling for
  615. * transmission.
  616. */
  617. struct sctp_packet {
  618. /* These are the SCTP header values (host order) for the packet. */
  619. __u16 source_port;
  620. __u16 destination_port;
  621. __u32 vtag;
  622. /* This contains the payload chunks. */
  623. struct list_head chunk_list;
  624. /* This is the overhead of the sctp and ip headers. */
  625. size_t overhead;
  626. /* This is the total size of all chunks INCLUDING padding. */
  627. size_t size;
  628. /* The packet is destined for this transport address.
  629. * The function we finally use to pass down to the next lower
  630. * layer lives in the transport structure.
  631. */
  632. struct sctp_transport *transport;
  633. /* This packet contains a COOKIE-ECHO chunk. */
  634. char has_cookie_echo;
  635. /* This packet containsa SACK chunk. */
  636. char has_sack;
  637. /* SCTP cannot fragment this packet. So let ip fragment it. */
  638. char ipfragok;
  639. int malloced;
  640. };
  641. struct sctp_packet *sctp_packet_init(struct sctp_packet *,
  642. struct sctp_transport *,
  643. __u16 sport, __u16 dport);
  644. struct sctp_packet *sctp_packet_config(struct sctp_packet *, __u32 vtag, int);
  645. sctp_xmit_t sctp_packet_transmit_chunk(struct sctp_packet *,
  646. struct sctp_chunk *);
  647. sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *,
  648. struct sctp_chunk *);
  649. int sctp_packet_transmit(struct sctp_packet *);
  650. void sctp_packet_free(struct sctp_packet *);
  651. static inline int sctp_packet_empty(struct sctp_packet *packet)
  652. {
  653. return (packet->size == packet->overhead);
  654. }
  655. /* This represents a remote transport address.
  656. * For local transport addresses, we just use union sctp_addr.
  657. *
  658. * RFC2960 Section 1.4 Key Terms
  659. *
  660. * o Transport address: A Transport Address is traditionally defined
  661. * by Network Layer address, Transport Layer protocol and Transport
  662. * Layer port number. In the case of SCTP running over IP, a
  663. * transport address is defined by the combination of an IP address
  664. * and an SCTP port number (where SCTP is the Transport protocol).
  665. *
  666. * RFC2960 Section 7.1 SCTP Differences from TCP Congestion control
  667. *
  668. * o The sender keeps a separate congestion control parameter set for
  669. * each of the destination addresses it can send to (not each
  670. * source-destination pair but for each destination). The parameters
  671. * should decay if the address is not used for a long enough time
  672. * period.
  673. *
  674. */
  675. struct sctp_transport {
  676. /* A list of transports. */
  677. struct list_head transports;
  678. /* Reference counting. */
  679. atomic_t refcnt;
  680. int dead;
  681. /* This is the peer's IP address and port. */
  682. union sctp_addr ipaddr;
  683. /* These are the functions we call to handle LLP stuff. */
  684. struct sctp_af *af_specific;
  685. /* Which association do we belong to? */
  686. struct sctp_association *asoc;
  687. /* RFC2960
  688. *
  689. * 12.3 Per Transport Address Data
  690. *
  691. * For each destination transport address in the peer's
  692. * address list derived from the INIT or INIT ACK chunk, a
  693. * number of data elements needs to be maintained including:
  694. */
  695. __u32 rtt; /* This is the most recent RTT. */
  696. /* RTO : The current retransmission timeout value. */
  697. __u32 rto;
  698. /* RTTVAR : The current RTT variation. */
  699. __u32 rttvar;
  700. /* SRTT : The current smoothed round trip time. */
  701. __u32 srtt;
  702. /* RTO-Pending : A flag used to track if one of the DATA
  703. * chunks sent to this address is currently being
  704. * used to compute a RTT. If this flag is 0,
  705. * the next DATA chunk sent to this destination
  706. * should be used to compute a RTT and this flag
  707. * should be set. Every time the RTT
  708. * calculation completes (i.e. the DATA chunk
  709. * is SACK'd) clear this flag.
  710. */
  711. int rto_pending;
  712. /*
  713. * These are the congestion stats.
  714. */
  715. /* cwnd : The current congestion window. */
  716. __u32 cwnd; /* This is the actual cwnd. */
  717. /* ssthresh : The current slow start threshold value. */
  718. __u32 ssthresh;
  719. /* partial : The tracking method for increase of cwnd when in
  720. * bytes acked : congestion avoidance mode (see Section 6.2.2)
  721. */
  722. __u32 partial_bytes_acked;
  723. /* Data that has been sent, but not acknowledged. */
  724. __u32 flight_size;
  725. /* PMTU : The current known path MTU. */
  726. __u32 pmtu;
  727. /* Destination */
  728. struct dst_entry *dst;
  729. /* Source address. */
  730. union sctp_addr saddr;
  731. /* When was the last time(in jiffies) that a data packet was sent on
  732. * this transport? This is used to adjust the cwnd when the transport
  733. * becomes inactive.
  734. */
  735. unsigned long last_time_used;
  736. /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to
  737. * the destination address every heartbeat interval.
  738. */
  739. int hb_interval;
  740. /* When was the last time (in jiffies) that we heard from this
  741. * transport? We use this to pick new active and retran paths.
  742. */
  743. unsigned long last_time_heard;
  744. /* Last time(in jiffies) when cwnd is reduced due to the congestion
  745. * indication based on ECNE chunk.
  746. */
  747. unsigned long last_time_ecne_reduced;
  748. /* The number of times INIT has been sent on this transport. */
  749. int init_sent_count;
  750. /* state : The current state of this destination,
  751. * : i.e. SCTP_ACTIVE, SCTP_INACTIVE, SCTP_UNKOWN.
  752. */
  753. int state;
  754. /* hb_allowed : The current heartbeat state of this destination,
  755. * : i.e. ALLOW-HB, NO-HEARTBEAT, etc.
  756. */
  757. int hb_allowed;
  758. /* These are the error stats for this destination. */
  759. /* Error count : The current error count for this destination. */
  760. unsigned short error_count;
  761. /* This is the max_retrans value for the transport and will
  762. * be initialized to proto.max_retrans.path. This can be changed
  763. * using SCTP_SET_PEER_ADDR_PARAMS socket option.
  764. */
  765. int max_retrans;
  766. /* Per : A timer used by each destination.
  767. * Destination :
  768. * Timer :
  769. *
  770. * [Everywhere else in the text this is called T3-rtx. -ed]
  771. */
  772. struct timer_list T3_rtx_timer;
  773. /* Heartbeat timer is per destination. */
  774. struct timer_list hb_timer;
  775. /* Since we're using per-destination retransmission timers
  776. * (see above), we're also using per-destination "transmitted"
  777. * queues. This probably ought to be a private struct
  778. * accessible only within the outqueue, but it's not, yet.
  779. */
  780. struct list_head transmitted;
  781. /* We build bundle-able packets for this transport here. */
  782. struct sctp_packet packet;
  783. /* This is the list of transports that have chunks to send. */
  784. struct list_head send_ready;
  785. int malloced; /* Is this structure kfree()able? */
  786. /* State information saved for SFR_CACC algorithm. The key
  787. * idea in SFR_CACC is to maintain state at the sender on a
  788. * per-destination basis when a changeover happens.
  789. * char changeover_active;
  790. * char cycling_changeover;
  791. * __u32 next_tsn_at_change;
  792. * char cacc_saw_newack;
  793. */
  794. struct {
  795. /* An unsigned integer, which stores the next TSN to be
  796. * used by the sender, at the moment of changeover.
  797. */
  798. __u32 next_tsn_at_change;
  799. /* A flag which indicates the occurrence of a changeover */
  800. char changeover_active;
  801. /* A flag which indicates whether the change of primary is
  802. * the first switch to this destination address during an
  803. * active switch.
  804. */
  805. char cycling_changeover;
  806. /* A temporary flag, which is used during the processing of
  807. * a SACK to estimate the causative TSN(s)'s group.
  808. */
  809. char cacc_saw_newack;
  810. } cacc;
  811. };
  812. struct sctp_transport *sctp_transport_new(const union sctp_addr *,
  813. gfp_t);
  814. void sctp_transport_set_owner(struct sctp_transport *,
  815. struct sctp_association *);
  816. void sctp_transport_route(struct sctp_transport *, union sctp_addr *,
  817. struct sctp_sock *);
  818. void sctp_transport_pmtu(struct sctp_transport *);
  819. void sctp_transport_free(struct sctp_transport *);
  820. void sctp_transport_reset_timers(struct sctp_transport *);
  821. void sctp_transport_hold(struct sctp_transport *);
  822. void sctp_transport_put(struct sctp_transport *);
  823. void sctp_transport_update_rto(struct sctp_transport *, __u32);
  824. void sctp_transport_raise_cwnd(struct sctp_transport *, __u32, __u32);
  825. void sctp_transport_lower_cwnd(struct sctp_transport *, sctp_lower_cwnd_t);
  826. unsigned long sctp_transport_timeout(struct sctp_transport *);
  827. /* This is the structure we use to queue packets as they come into
  828. * SCTP. We write packets to it and read chunks from it.
  829. */
  830. struct sctp_inq {
  831. /* This is actually a queue of sctp_chunk each
  832. * containing a partially decoded packet.
  833. */
  834. struct list_head in_chunk_list;
  835. /* This is the packet which is currently off the in queue and is
  836. * being worked on through the inbound chunk processing.
  837. */
  838. struct sctp_chunk *in_progress;
  839. /* This is the delayed task to finish delivering inbound
  840. * messages.
  841. */
  842. struct work_struct immediate;
  843. int malloced; /* Is this structure kfree()able? */
  844. };
  845. void sctp_inq_init(struct sctp_inq *);
  846. void sctp_inq_free(struct sctp_inq *);
  847. void sctp_inq_push(struct sctp_inq *, struct sctp_chunk *packet);
  848. struct sctp_chunk *sctp_inq_pop(struct sctp_inq *);
  849. void sctp_inq_set_th_handler(struct sctp_inq *, void (*)(void *), void *);
  850. /* This is the structure we use to hold outbound chunks. You push
  851. * chunks in and they automatically pop out the other end as bundled
  852. * packets (it calls (*output_handler)()).
  853. *
  854. * This structure covers sections 6.3, 6.4, 6.7, 6.8, 6.10, 7., 8.1,
  855. * and 8.2 of the v13 draft.
  856. *
  857. * It handles retransmissions. The connection to the timeout portion
  858. * of the state machine is through sctp_..._timeout() and timeout_handler.
  859. *
  860. * If you feed it SACKs, it will eat them.
  861. *
  862. * If you give it big chunks, it will fragment them.
  863. *
  864. * It assigns TSN's to data chunks. This happens at the last possible
  865. * instant before transmission.
  866. *
  867. * When free()'d, it empties itself out via output_handler().
  868. */
  869. struct sctp_outq {
  870. struct sctp_association *asoc;
  871. /* Data pending that has never been transmitted. */
  872. struct list_head out_chunk_list;
  873. unsigned out_qlen; /* Total length of queued data chunks. */
  874. /* Error of send failed, may used in SCTP_SEND_FAILED event. */
  875. unsigned error;
  876. /* These are control chunks we want to send. */
  877. struct list_head control_chunk_list;
  878. /* These are chunks that have been sacked but are above the
  879. * CTSN, or cumulative tsn ack point.
  880. */
  881. struct list_head sacked;
  882. /* Put chunks on this list to schedule them for
  883. * retransmission.
  884. */
  885. struct list_head retransmit;
  886. /* Put chunks on this list to save them for FWD TSN processing as
  887. * they were abandoned.
  888. */
  889. struct list_head abandoned;
  890. /* How many unackd bytes do we have in-flight? */
  891. __u32 outstanding_bytes;
  892. /* Corked? */
  893. char cork;
  894. /* Is this structure empty? */
  895. char empty;
  896. /* Are we kfree()able? */
  897. char malloced;
  898. };
  899. void sctp_outq_init(struct sctp_association *, struct sctp_outq *);
  900. void sctp_outq_teardown(struct sctp_outq *);
  901. void sctp_outq_free(struct sctp_outq*);
  902. int sctp_outq_tail(struct sctp_outq *, struct sctp_chunk *chunk);
  903. int sctp_outq_flush(struct sctp_outq *, int);
  904. int sctp_outq_sack(struct sctp_outq *, struct sctp_sackhdr *);
  905. int sctp_outq_is_empty(const struct sctp_outq *);
  906. void sctp_outq_restart(struct sctp_outq *);
  907. void sctp_retransmit(struct sctp_outq *, struct sctp_transport *,
  908. sctp_retransmit_reason_t);
  909. void sctp_retransmit_mark(struct sctp_outq *, struct sctp_transport *, __u8);
  910. int sctp_outq_uncork(struct sctp_outq *);
  911. /* Uncork and flush an outqueue. */
  912. static inline void sctp_outq_cork(struct sctp_outq *q)
  913. {
  914. q->cork = 1;
  915. }
  916. /* These bind address data fields common between endpoints and associations */
  917. struct sctp_bind_addr {
  918. /* RFC 2960 12.1 Parameters necessary for the SCTP instance
  919. *
  920. * SCTP Port: The local SCTP port number the endpoint is
  921. * bound to.
  922. */
  923. __u16 port;
  924. /* RFC 2960 12.1 Parameters necessary for the SCTP instance
  925. *
  926. * Address List: The list of IP addresses that this instance
  927. * has bound. This information is passed to one's
  928. * peer(s) in INIT and INIT ACK chunks.
  929. */
  930. struct list_head address_list;
  931. int malloced; /* Are we kfree()able? */
  932. };
  933. void sctp_bind_addr_init(struct sctp_bind_addr *, __u16 port);
  934. void sctp_bind_addr_free(struct sctp_bind_addr *);
  935. int sctp_bind_addr_copy(struct sctp_bind_addr *dest,
  936. const struct sctp_bind_addr *src,
  937. sctp_scope_t scope, gfp_t gfp,
  938. int flags);
  939. int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *,
  940. gfp_t gfp);
  941. int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *);
  942. int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *,
  943. struct sctp_sock *);
  944. union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp,
  945. const union sctp_addr *addrs,
  946. int addrcnt,
  947. struct sctp_sock *opt);
  948. union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp,
  949. int *addrs_len,
  950. gfp_t gfp);
  951. int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len,
  952. __u16 port, gfp_t gfp);
  953. sctp_scope_t sctp_scope(const union sctp_addr *);
  954. int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope);
  955. int sctp_is_any(const union sctp_addr *addr);
  956. int sctp_addr_is_valid(const union sctp_addr *addr);
  957. /* What type of endpoint? */
  958. typedef enum {
  959. SCTP_EP_TYPE_SOCKET,
  960. SCTP_EP_TYPE_ASSOCIATION,
  961. } sctp_endpoint_type_t;
  962. /*
  963. * A common base class to bridge the implmentation view of a
  964. * socket (usually listening) endpoint versus an association's
  965. * local endpoint.
  966. * This common structure is useful for several purposes:
  967. * 1) Common interface for lookup routines.
  968. * a) Subfunctions work for either endpoint or association
  969. * b) Single interface to lookup allows hiding the lookup lock rather
  970. * than acquiring it externally.
  971. * 2) Common interface for the inbound chunk handling/state machine.
  972. * 3) Common object handling routines for reference counting, etc.
  973. * 4) Disentangle association lookup from endpoint lookup, where we
  974. * do not have to find our endpoint to find our association.
  975. *
  976. */
  977. struct sctp_ep_common {
  978. /* Fields to help us manage our entries in the hash tables. */
  979. struct sctp_ep_common *next;
  980. struct sctp_ep_common **pprev;
  981. int hashent;
  982. /* Runtime type information. What kind of endpoint is this? */
  983. sctp_endpoint_type_t type;
  984. /* Some fields to help us manage this object.
  985. * refcnt - Reference count access to this object.
  986. * dead - Do not attempt to use this object.
  987. * malloced - Do we need to kfree this object?
  988. */
  989. atomic_t refcnt;
  990. char dead;
  991. char malloced;
  992. /* What socket does this endpoint belong to? */
  993. struct sock *sk;
  994. /* This is where we receive inbound chunks. */
  995. struct sctp_inq inqueue;
  996. /* This substructure includes the defining parameters of the
  997. * endpoint:
  998. * bind_addr.port is our shared port number.
  999. * bind_addr.address_list is our set of local IP addresses.
  1000. */
  1001. struct sctp_bind_addr bind_addr;
  1002. /* Protection during address list comparisons. */
  1003. rwlock_t addr_lock;
  1004. };
  1005. /* RFC Section 1.4 Key Terms
  1006. *
  1007. * o SCTP endpoint: The logical sender/receiver of SCTP packets. On a
  1008. * multi-homed host, an SCTP endpoint is represented to its peers as a
  1009. * combination of a set of eligible destination transport addresses to
  1010. * which SCTP packets can be sent and a set of eligible source
  1011. * transport addresses from which SCTP packets can be received.
  1012. * All transport addresses used by an SCTP endpoint must use the
  1013. * same port number, but can use multiple IP addresses. A transport
  1014. * address used by an SCTP endpoint must not be used by another
  1015. * SCTP endpoint. In other words, a transport address is unique
  1016. * to an SCTP endpoint.
  1017. *
  1018. * From an implementation perspective, each socket has one of these.
  1019. * A TCP-style socket will have exactly one association on one of
  1020. * these. An UDP-style socket will have multiple associations hanging
  1021. * off one of these.
  1022. */
  1023. struct sctp_endpoint {
  1024. /* Common substructure for endpoint and association. */
  1025. struct sctp_ep_common base;
  1026. /* Associations: A list of current associations and mappings
  1027. * to the data consumers for each association. This
  1028. * may be in the form of a hash table or other
  1029. * implementation dependent structure. The data
  1030. * consumers may be process identification
  1031. * information such as file descriptors, named pipe
  1032. * pointer, or table pointers dependent on how SCTP
  1033. * is implemented.
  1034. */
  1035. /* This is really a list of struct sctp_association entries. */
  1036. struct list_head asocs;
  1037. /* Secret Key: A secret key used by this endpoint to compute
  1038. * the MAC. This SHOULD be a cryptographic quality
  1039. * random number with a sufficient length.
  1040. * Discussion in [RFC1750] can be helpful in
  1041. * selection of the key.
  1042. */
  1043. __u8 secret_key[SCTP_HOW_MANY_SECRETS][SCTP_SECRET_SIZE];
  1044. int current_key;
  1045. int last_key;
  1046. int key_changed_at;
  1047. /* sendbuf acct. policy. */
  1048. __u32 sndbuf_policy;
  1049. /* rcvbuf acct. policy. */
  1050. __u32 rcvbuf_policy;
  1051. };
  1052. /* Recover the outter endpoint structure. */
  1053. static inline struct sctp_endpoint *sctp_ep(struct sctp_ep_common *base)
  1054. {
  1055. struct sctp_endpoint *ep;
  1056. ep = container_of(base, struct sctp_endpoint, base);
  1057. return ep;
  1058. }
  1059. /* These are function signatures for manipulating endpoints. */
  1060. struct sctp_endpoint *sctp_endpoint_new(struct sock *, gfp_t);
  1061. void sctp_endpoint_free(struct sctp_endpoint *);
  1062. void sctp_endpoint_put(struct sctp_endpoint *);
  1063. void sctp_endpoint_hold(struct sctp_endpoint *);
  1064. void sctp_endpoint_add_asoc(struct sctp_endpoint *, struct sctp_association *);
  1065. struct sctp_association *sctp_endpoint_lookup_assoc(
  1066. const struct sctp_endpoint *ep,
  1067. const union sctp_addr *paddr,
  1068. struct sctp_transport **);
  1069. int sctp_endpoint_is_peeled_off(struct sctp_endpoint *,
  1070. const union sctp_addr *);
  1071. struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *,
  1072. const union sctp_addr *);
  1073. int sctp_has_association(const union sctp_addr *laddr,
  1074. const union sctp_addr *paddr);
  1075. int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t,
  1076. sctp_init_chunk_t *peer_init, struct sctp_chunk *chunk,
  1077. struct sctp_chunk **err_chunk);
  1078. int sctp_process_init(struct sctp_association *, sctp_cid_t cid,
  1079. const union sctp_addr *peer,
  1080. sctp_init_chunk_t *init, gfp_t gfp);
  1081. __u32 sctp_generate_tag(const struct sctp_endpoint *);
  1082. __u32 sctp_generate_tsn(const struct sctp_endpoint *);
  1083. /* RFC2960
  1084. *
  1085. * 12. Recommended Transmission Control Block (TCB) Parameters
  1086. *
  1087. * This section details a recommended set of parameters that should
  1088. * be contained within the TCB for an implementation. This section is
  1089. * for illustrative purposes and should not be deemed as requirements
  1090. * on an implementation or as an exhaustive list of all parameters
  1091. * inside an SCTP TCB. Each implementation may need its own additional
  1092. * parameters for optimization.
  1093. */
  1094. /* Here we have information about each individual association. */
  1095. struct sctp_association {
  1096. /* A base structure common to endpoint and association.
  1097. * In this context, it represents the associations's view
  1098. * of the local endpoint of the association.
  1099. */
  1100. struct sctp_ep_common base;
  1101. /* Associations on the same socket. */
  1102. struct list_head asocs;
  1103. /* association id. */
  1104. sctp_assoc_t assoc_id;
  1105. /* This is our parent endpoint. */
  1106. struct sctp_endpoint *ep;
  1107. /* These are those association elements needed in the cookie. */
  1108. struct sctp_cookie c;
  1109. /* This is all information about our peer. */
  1110. struct {
  1111. /* rwnd
  1112. *
  1113. * Peer Rwnd : Current calculated value of the peer's rwnd.
  1114. */
  1115. __u32 rwnd;
  1116. /* transport_addr_list
  1117. *
  1118. * Peer : A list of SCTP transport addresses that the
  1119. * Transport : peer is bound to. This information is derived
  1120. * Address : from the INIT or INIT ACK and is used to
  1121. * List : associate an inbound packet with a given
  1122. * : association. Normally this information is
  1123. * : hashed or keyed for quick lookup and access
  1124. * : of the TCB.
  1125. * : The list is also initialized with the list
  1126. * : of addresses passed with the sctp_connectx()
  1127. * : call.
  1128. *
  1129. * It is a list of SCTP_transport's.
  1130. */
  1131. struct list_head transport_addr_list;
  1132. /* transport_count
  1133. *
  1134. * Peer : A count of the number of peer addresses
  1135. * Transport : in the Peer Transport Address List.
  1136. * Address :
  1137. * Count :
  1138. */
  1139. __u16 transport_count;
  1140. /* port
  1141. * The transport layer port number.
  1142. */
  1143. __u16 port;
  1144. /* primary_path
  1145. *
  1146. * Primary : This is the current primary destination
  1147. * Path : transport address of the peer endpoint. It
  1148. * : may also specify a source transport address
  1149. * : on this endpoint.
  1150. *
  1151. * All of these paths live on transport_addr_list.
  1152. *
  1153. * At the bakeoffs, we discovered that the intent of
  1154. * primaryPath is that it only changes when the ULP
  1155. * asks to have it changed. We add the activePath to
  1156. * designate the connection we are currently using to
  1157. * transmit new data and most control chunks.
  1158. */
  1159. struct sctp_transport *primary_path;
  1160. /* Cache the primary path address here, when we
  1161. * need a an address for msg_name.
  1162. */
  1163. union sctp_addr primary_addr;
  1164. /* active_path
  1165. * The path that we are currently using to
  1166. * transmit new data and most control chunks.
  1167. */
  1168. struct sctp_transport *active_path;
  1169. /* retran_path
  1170. *
  1171. * RFC2960 6.4 Multi-homed SCTP Endpoints
  1172. * ...
  1173. * Furthermore, when its peer is multi-homed, an
  1174. * endpoint SHOULD try to retransmit a chunk to an
  1175. * active destination transport address that is
  1176. * different from the last destination address to
  1177. * which the DATA chunk was sent.
  1178. */
  1179. struct sctp_transport *retran_path;
  1180. /* Pointer to last transport I have sent on. */
  1181. struct sctp_transport *last_sent_to;
  1182. /* This is the last transport I have received DATA on. */
  1183. struct sctp_transport *last_data_from;
  1184. /*
  1185. * Mapping An array of bits or bytes indicating which out of
  1186. * Array order TSN's have been received (relative to the
  1187. * Last Rcvd TSN). If no gaps exist, i.e. no out of
  1188. * order packets have been received, this array
  1189. * will be set to all zero. This structure may be
  1190. * in the form of a circular buffer or bit array.
  1191. *
  1192. * Last Rcvd : This is the last TSN received in
  1193. * TSN : sequence. This value is set initially by
  1194. * : taking the peer's Initial TSN, received in
  1195. * : the INIT or INIT ACK chunk, and subtracting
  1196. * : one from it.
  1197. *
  1198. * Throughout most of the specification this is called the
  1199. * "Cumulative TSN ACK Point". In this case, we
  1200. * ignore the advice in 12.2 in favour of the term
  1201. * used in the bulk of the text. This value is hidden
  1202. * in tsn_map--we get it by calling sctp_tsnmap_get_ctsn().
  1203. */
  1204. struct sctp_tsnmap tsn_map;
  1205. __u8 _map[sctp_tsnmap_storage_size(SCTP_TSN_MAP_SIZE)];
  1206. /* Ack State : This flag indicates if the next received
  1207. * : packet is to be responded to with a
  1208. * : SACK. This is initializedto 0. When a packet
  1209. * : is received it is incremented. If this value
  1210. * : reaches 2 or more, a SACK is sent and the
  1211. * : value is reset to 0. Note: This is used only
  1212. * : when no DATA chunks are received out of
  1213. * : order. When DATA chunks are out of order,
  1214. * : SACK's are not delayed (see Section 6).
  1215. */
  1216. __u8 sack_needed; /* Do we need to sack the peer? */
  1217. /* These are capabilities which our peer advertised. */
  1218. __u8 ecn_capable; /* Can peer do ECN? */
  1219. __u8 ipv4_address; /* Peer understands IPv4 addresses? */
  1220. __u8 ipv6_address; /* Peer understands IPv6 addresses? */
  1221. __u8 hostname_address;/* Peer understands DNS addresses? */
  1222. __u8 asconf_capable; /* Does peer support ADDIP? */
  1223. __u8 prsctp_capable; /* Can peer do PR-SCTP? */
  1224. __u32 adaption_ind; /* Adaption Code point. */
  1225. /* This mask is used to disable sending the ASCONF chunk
  1226. * with specified parameter to peer.
  1227. */
  1228. __u16 addip_disabled_mask;
  1229. struct sctp_inithdr i;
  1230. int cookie_len;
  1231. void *cookie;
  1232. /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk.
  1233. * C1) ... "Peer-Serial-Number'. This value MUST be initialized to the
  1234. * Initial TSN Value minus 1
  1235. */
  1236. __u32 addip_serial;
  1237. } peer;
  1238. /* State : A state variable indicating what state the
  1239. * : association is in, i.e. COOKIE-WAIT,
  1240. * : COOKIE-ECHOED, ESTABLISHED, SHUTDOWN-PENDING,
  1241. * : SHUTDOWN-SENT, SHUTDOWN-RECEIVED, SHUTDOWN-ACK-SENT.
  1242. *
  1243. * Note: No "CLOSED" state is illustrated since if a
  1244. * association is "CLOSED" its TCB SHOULD be removed.
  1245. *
  1246. * In this implementation we DO have a CLOSED
  1247. * state which is used during initiation and shutdown.
  1248. *
  1249. * State takes values from SCTP_STATE_*.
  1250. */
  1251. sctp_state_t state;
  1252. /* The cookie life I award for any cookie. */
  1253. struct timeval cookie_life;
  1254. /* Overall : The overall association error count.
  1255. * Error Count : [Clear this any time I get something.]
  1256. */
  1257. int overall_error_count;
  1258. /* These are the association's initial, max, and min RTO values.
  1259. * These values will be initialized by system defaults, but can
  1260. * be modified via the SCTP_RTOINFO socket option.
  1261. */
  1262. __u32 rto_initial;
  1263. __u32 rto_max;
  1264. __u32 rto_min;
  1265. /* Maximum number of new data packets that can be sent in a burst. */
  1266. int max_burst;
  1267. /* This is the max_retrans value for the association. This value will
  1268. * be initialized initialized from system defaults, but can be
  1269. * modified by the SCTP_ASSOCINFO socket option.
  1270. */
  1271. int max_retrans;
  1272. /* Maximum number of times the endpoint will retransmit INIT */
  1273. __u16 max_init_attempts;
  1274. /* How many times have we resent an INIT? */
  1275. __u16 init_retries;
  1276. /* The largest timeout or RTO value to use in attempting an INIT */
  1277. __u16 max_init_timeo;
  1278. int timeouts[SCTP_NUM_TIMEOUT_TYPES];
  1279. struct timer_list timers[SCTP_NUM_TIMEOUT_TYPES];
  1280. /* Transport to which SHUTDOWN chunk was last sent. */
  1281. struct sctp_transport *shutdown_last_sent_to;
  1282. /* Transport to which INIT chunk was last sent. */
  1283. struct sctp_transport *init_last_sent_to;
  1284. /* Next TSN : The next TSN number to be assigned to a new
  1285. * : DATA chunk. This is sent in the INIT or INIT
  1286. * : ACK chunk to the peer and incremented each
  1287. * : time a DATA chunk is assigned a TSN
  1288. * : (normally just prior to transmit or during
  1289. * : fragmentation).
  1290. */
  1291. __u32 next_tsn;
  1292. /*
  1293. * Last Rcvd : This is the last TSN received in sequence. This value
  1294. * TSN : is set initially by taking the peer's Initial TSN,
  1295. * : received in the INIT or INIT ACK chunk, and
  1296. * : subtracting one from it.
  1297. *
  1298. * Most of RFC 2960 refers to this as the Cumulative TSN Ack Point.
  1299. */
  1300. __u32 ctsn_ack_point;
  1301. /* PR-SCTP Advanced.Peer.Ack.Point */
  1302. __u32 adv_peer_ack_point;
  1303. /* Highest TSN that is acknowledged by incoming SACKs. */
  1304. __u32 highest_sacked;
  1305. /* The number of unacknowledged data chunks. Reported through
  1306. * the SCTP_STATUS sockopt.
  1307. */
  1308. __u16 unack_data;
  1309. /* This is the association's receive buffer space. This value is used
  1310. * to set a_rwnd field in an INIT or a SACK chunk.
  1311. */
  1312. __u32 rwnd;
  1313. /* This is the last advertised value of rwnd over a SACK chunk. */
  1314. __u32 a_rwnd;
  1315. /* Number of bytes by which the rwnd has slopped. The rwnd is allowed
  1316. * to slop over a maximum of the association's frag_point.
  1317. */
  1318. __u32 rwnd_over;
  1319. /* This is the sndbuf size in use for the association.
  1320. * This corresponds to the sndbuf size for the association,
  1321. * as specified in the sk->sndbuf.
  1322. */
  1323. int sndbuf_used;
  1324. /* This is the amount of memory that this association has allocated
  1325. * in the receive path at any given time.
  1326. */
  1327. atomic_t rmem_alloc;
  1328. /* This is the wait queue head for send requests waiting on
  1329. * the association sndbuf space.
  1330. */
  1331. wait_queue_head_t wait;
  1332. /* Association : The smallest PMTU discovered for all of the
  1333. * PMTU : peer's transport addresses.
  1334. */
  1335. __u32 pmtu;
  1336. /* The message size at which SCTP fragmentation will occur. */
  1337. __u32 frag_point;
  1338. /* Counter used to count INIT errors. */
  1339. int init_err_counter;
  1340. /* Count the number of INIT cycles (for doubling timeout). */
  1341. int init_cycle;
  1342. /* Default send parameters. */
  1343. __u16 default_stream;
  1344. __u16 default_flags;
  1345. __u32 default_ppid;
  1346. __u32 default_context;
  1347. __u32 default_timetolive;
  1348. /* This tracks outbound ssn for a given stream. */
  1349. struct sctp_ssnmap *ssnmap;
  1350. /* All outbound chunks go through this structure. */
  1351. struct sctp_outq outqueue;
  1352. /* A smart pipe that will handle reordering and fragmentation,
  1353. * as well as handle passing events up to the ULP.
  1354. */
  1355. struct sctp_ulpq ulpq;
  1356. /* Last TSN that caused an ECNE Chunk to be sent. */
  1357. __u32 last_ecne_tsn;
  1358. /* Last TSN that caused a CWR Chunk to be sent. */
  1359. __u32 last_cwr_tsn;
  1360. /* How many duplicated TSNs have we seen? */
  1361. int numduptsns;
  1362. /* Number of seconds of idle time before an association is closed. */
  1363. __u32 autoclose;
  1364. /* These are to support
  1365. * "SCTP Extensions for Dynamic Reconfiguration of IP Addresses
  1366. * and Enforcement of Flow and Message Limits"
  1367. * <draft-ietf-tsvwg-addip-sctp-02.txt>
  1368. * or "ADDIP" for short.
  1369. */
  1370. /* ADDIP Section 4.1.1 Congestion Control of ASCONF Chunks
  1371. *
  1372. * R1) One and only one ASCONF Chunk MAY be in transit and
  1373. * unacknowledged at any one time. If a sender, after sending
  1374. * an ASCONF chunk, decides it needs to transfer another
  1375. * ASCONF Chunk, it MUST wait until the ASCONF-ACK Chunk
  1376. * returns from the previous ASCONF Chunk before sending a
  1377. * subsequent ASCONF. Note this restriction binds each side,
  1378. * so at any time two ASCONF may be in-transit on any given
  1379. * association (one sent from each endpoint).
  1380. *
  1381. * [This is our one-and-only-one ASCONF in flight. If we do
  1382. * not have an ASCONF in flight, this is NULL.]
  1383. */
  1384. struct sctp_chunk *addip_last_asconf;
  1385. /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk.
  1386. *
  1387. * IMPLEMENTATION NOTE: As an optimization a receiver may wish
  1388. * to save the last ASCONF-ACK for some predetermined period
  1389. * of time and instead of re-processing the ASCONF (with the
  1390. * same serial number) it may just re-transmit the
  1391. * ASCONF-ACK. It may wish to use the arrival of a new serial
  1392. * number to discard the previously saved ASCONF-ACK or any
  1393. * other means it may choose to expire the saved ASCONF-ACK.
  1394. *
  1395. * [This is our saved ASCONF-ACK. We invalidate it when a new
  1396. * ASCONF serial number arrives.]
  1397. */
  1398. struct sctp_chunk *addip_last_asconf_ack;
  1399. /* These ASCONF chunks are waiting to be sent.
  1400. *
  1401. * These chunaks can't be pushed to outqueue until receiving
  1402. * ASCONF_ACK for the previous ASCONF indicated by
  1403. * addip_last_asconf, so as to guarantee that only one ASCONF
  1404. * is in flight at any time.
  1405. *
  1406. * ADDIP Section 4.1.1 Congestion Control of ASCONF Chunks
  1407. *
  1408. * In defining the ASCONF Chunk transfer procedures, it is
  1409. * essential that these transfers MUST NOT cause congestion
  1410. * within the network. To achieve this, we place these
  1411. * restrictions on the transfer of ASCONF Chunks:
  1412. *
  1413. * R1) One and only one ASCONF Chunk MAY be in transit and
  1414. * unacknowledged at any one time. If a sender, after sending
  1415. * an ASCONF chunk, decides it needs to transfer another
  1416. * ASCONF Chunk, it MUST wait until the ASCONF-ACK Chunk
  1417. * returns from the previous ASCONF Chunk before sending a
  1418. * subsequent ASCONF. Note this restriction binds each side,
  1419. * so at any time two ASCONF may be in-transit on any given
  1420. * association (one sent from each endpoint).
  1421. *
  1422. *
  1423. * [I really think this is EXACTLY the sort of intelligence
  1424. * which already resides in sctp_outq. Please move this
  1425. * queue and its supporting logic down there. --piggy]
  1426. */
  1427. struct list_head addip_chunk_list;
  1428. /* ADDIP Section 4.1 ASCONF Chunk Procedures
  1429. *
  1430. * A2) A serial number should be assigned to the Chunk. The
  1431. * serial number SHOULD be a monotonically increasing
  1432. * number. The serial number SHOULD be initialized at
  1433. * the start of the association to the same value as the
  1434. * Initial TSN and every time a new ASCONF chunk is created
  1435. * it is incremented by one after assigning the serial number
  1436. * to the newly created chunk.
  1437. *
  1438. * ADDIP
  1439. * 3.1.1 Address/Stream Configuration Change Chunk (ASCONF)
  1440. *
  1441. * Serial Number : 32 bits (unsigned integer)
  1442. *
  1443. * This value represents a Serial Number for the ASCONF
  1444. * Chunk. The valid range of Serial Number is from 0 to
  1445. * 4294967295 (2^32 - 1). Serial Numbers wrap back to 0
  1446. * after reaching 4294967295.
  1447. */
  1448. __u32 addip_serial;
  1449. /* Need to send an ECNE Chunk? */
  1450. char need_ecne;
  1451. /* Is it a temporary association? */
  1452. char temp;
  1453. };
  1454. /* An eyecatcher for determining if we are really looking at an
  1455. * association data structure.
  1456. */
  1457. enum {
  1458. SCTP_ASSOC_EYECATCHER = 0xa550c123,
  1459. };
  1460. /* Recover the outter association structure. */
  1461. static inline struct sctp_association *sctp_assoc(struct sctp_ep_common *base)
  1462. {
  1463. struct sctp_association *asoc;
  1464. asoc = container_of(base, struct sctp_association, base);
  1465. return asoc;
  1466. }
  1467. /* These are function signatures for manipulating associations. */
  1468. struct sctp_association *
  1469. sctp_association_new(const struct sctp_endpoint *, const struct sock *,
  1470. sctp_scope_t scope, gfp_t gfp);
  1471. void sctp_association_free(struct sctp_association *);
  1472. void sctp_association_put(struct sctp_association *);
  1473. void sctp_association_hold(struct sctp_association *);
  1474. struct sctp_transport *sctp_assoc_choose_init_transport(
  1475. struct sctp_association *);
  1476. struct sctp_transport *sctp_assoc_choose_shutdown_transport(
  1477. struct sctp_association *);
  1478. void sctp_assoc_update_retran_path(struct sctp_association *);
  1479. struct sctp_transport *sctp_assoc_lookup_paddr(const struct sctp_association *,
  1480. const union sctp_addr *);
  1481. int sctp_assoc_lookup_laddr(struct sctp_association *asoc,
  1482. const union sctp_addr *laddr);
  1483. struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *,
  1484. const union sctp_addr *address,
  1485. const gfp_t gfp,
  1486. const int peer_state);
  1487. void sctp_assoc_del_peer(struct sctp_association *asoc,
  1488. const union sctp_addr *addr);
  1489. void sctp_assoc_rm_peer(struct sctp_association *asoc,
  1490. struct sctp_transport *peer);
  1491. void sctp_assoc_control_transport(struct sctp_association *,
  1492. struct sctp_transport *,
  1493. sctp_transport_cmd_t, sctp_sn_error_t);
  1494. struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *, __u32);
  1495. struct sctp_transport *sctp_assoc_is_match(struct sctp_association *,
  1496. const union sctp_addr *,
  1497. const union sctp_addr *);
  1498. void sctp_assoc_migrate(struct sctp_association *, struct sock *);
  1499. void sctp_assoc_update(struct sctp_association *old,
  1500. struct sctp_association *new);
  1501. __u32 sctp_association_get_next_tsn(struct sctp_association *);
  1502. void sctp_assoc_sync_pmtu(struct sctp_association *);
  1503. void sctp_assoc_rwnd_increase(struct sctp_association *, unsigned);
  1504. void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned);
  1505. void sctp_assoc_set_primary(struct sctp_association *,
  1506. struct sctp_transport *);
  1507. int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *,
  1508. gfp_t);
  1509. int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *,
  1510. struct sctp_cookie*,
  1511. gfp_t gfp);
  1512. int sctp_cmp_addr_exact(const union sctp_addr *ss1,
  1513. const union sctp_addr *ss2);
  1514. struct sctp_chunk *sctp_get_ecne_prepend(struct sctp_association *asoc);
  1515. /* A convenience structure to parse out SCTP specific CMSGs. */
  1516. typedef struct sctp_cmsgs {
  1517. struct sctp_initmsg *init;
  1518. struct sctp_sndrcvinfo *info;
  1519. } sctp_cmsgs_t;
  1520. /* Structure for tracking memory objects */
  1521. typedef struct {
  1522. char *label;
  1523. atomic_t *counter;
  1524. } sctp_dbg_objcnt_entry_t;
  1525. #endif /* __sctp_structs_h__ */