ulpevent.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. * Copyright (c) 2001 Nokia, Inc.
  7. * Copyright (c) 2001 La Monte H.P. Yarroll
  8. *
  9. * These are the definitions needed for the sctp_ulpevent type. The
  10. * sctp_ulpevent type is used to carry information from the state machine
  11. * upwards to the ULP.
  12. *
  13. * This file is part of the SCTP kernel reference Implementation
  14. *
  15. * The SCTP reference implementation is free software;
  16. * you can redistribute it and/or modify it under the terms of
  17. * the GNU General Public License as published by
  18. * the Free Software Foundation; either version 2, or (at your option)
  19. * any later version.
  20. *
  21. * The SCTP reference implementation is distributed in the hope that it
  22. * will be useful, but WITHOUT ANY WARRANTY; without even the implied
  23. * ************************
  24. * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  25. * See the GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with GNU CC; see the file COPYING. If not, write to
  29. * the Free Software Foundation, 59 Temple Place - Suite 330,
  30. * Boston, MA 02111-1307, USA.
  31. *
  32. * Please send any bug reports or fixes you make to the
  33. * email address(es):
  34. * lksctp developers <lksctp-developers@lists.sourceforge.net>
  35. *
  36. * Or submit a bug report through the following website:
  37. * http://www.sf.net/projects/lksctp
  38. *
  39. * Written or modified by:
  40. * Jon Grimm <jgrimm@us.ibm.com>
  41. * La Monte H.P. Yarroll <piggy@acm.org>
  42. * Karl Knutson <karl@athena.chicago.il.us>
  43. * Sridhar Samudrala <sri@us.ibm.com>
  44. *
  45. * Any bugs reported given to us we will try to fix... any fixes shared will
  46. * be incorporated into the next SCTP release.
  47. */
  48. #ifndef __sctp_ulpevent_h__
  49. #define __sctp_ulpevent_h__
  50. /* A structure to carry information to the ULP (e.g. Sockets API) */
  51. /* Warning: This sits inside an skb.cb[] area. Be very careful of
  52. * growing this structure as it is at the maximum limit now.
  53. */
  54. struct sctp_ulpevent {
  55. struct sctp_association *asoc;
  56. __u16 stream;
  57. __u16 ssn;
  58. __u16 flags;
  59. __u32 ppid;
  60. __u32 tsn;
  61. __u32 cumtsn;
  62. int msg_flags;
  63. int iif;
  64. };
  65. /* Retrieve the skb this event sits inside of. */
  66. static inline struct sk_buff *sctp_event2skb(struct sctp_ulpevent *ev)
  67. {
  68. return container_of((void *)ev, struct sk_buff, cb);
  69. }
  70. /* Retrieve & cast the event sitting inside the skb. */
  71. static inline struct sctp_ulpevent *sctp_skb2event(struct sk_buff *skb)
  72. {
  73. return (struct sctp_ulpevent *)skb->cb;
  74. }
  75. void sctp_ulpevent_free(struct sctp_ulpevent *);
  76. int sctp_ulpevent_is_notification(const struct sctp_ulpevent *);
  77. void sctp_queue_purge_ulpevents(struct sk_buff_head *list);
  78. struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
  79. const struct sctp_association *asoc,
  80. __u16 flags,
  81. __u16 state,
  82. __u16 error,
  83. __u16 outbound,
  84. __u16 inbound,
  85. gfp_t gfp);
  86. struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change(
  87. const struct sctp_association *asoc,
  88. const struct sockaddr_storage *aaddr,
  89. int flags,
  90. int state,
  91. int error,
  92. gfp_t gfp);
  93. struct sctp_ulpevent *sctp_ulpevent_make_remote_error(
  94. const struct sctp_association *asoc,
  95. struct sctp_chunk *chunk,
  96. __u16 flags,
  97. gfp_t gfp);
  98. struct sctp_ulpevent *sctp_ulpevent_make_send_failed(
  99. const struct sctp_association *asoc,
  100. struct sctp_chunk *chunk,
  101. __u16 flags,
  102. __u32 error,
  103. gfp_t gfp);
  104. struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event(
  105. const struct sctp_association *asoc,
  106. __u16 flags,
  107. gfp_t gfp);
  108. struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
  109. const struct sctp_association *asoc,
  110. __u32 indication, gfp_t gfp);
  111. struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication(
  112. const struct sctp_association *asoc, gfp_t gfp);
  113. struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
  114. struct sctp_chunk *chunk,
  115. gfp_t gfp);
  116. void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
  117. struct msghdr *);
  118. __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
  119. /* Is this event type enabled? */
  120. static inline int sctp_ulpevent_type_enabled(__u16 sn_type,
  121. struct sctp_event_subscribe *mask)
  122. {
  123. char *amask = (char *) mask;
  124. return amask[sn_type - SCTP_SN_TYPE_BASE];
  125. }
  126. /* Given an event subscription, is this event enabled? */
  127. static inline int sctp_ulpevent_is_enabled(const struct sctp_ulpevent *event,
  128. struct sctp_event_subscribe *mask)
  129. {
  130. __u16 sn_type;
  131. int enabled = 1;
  132. if (sctp_ulpevent_is_notification(event)) {
  133. sn_type = sctp_ulpevent_get_notification_type(event);
  134. enabled = sctp_ulpevent_type_enabled(sn_type, mask);
  135. }
  136. return enabled;
  137. }
  138. #endif /* __sctp_ulpevent_h__ */