p80211conv.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */
  2. /* p80211conv.h
  3. *
  4. * Ether/802.11 conversions and packet buffer routines
  5. *
  6. * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
  7. * --------------------------------------------------------------------
  8. *
  9. * linux-wlan
  10. *
  11. * The contents of this file are subject to the Mozilla Public
  12. * License Version 1.1 (the "License"); you may not use this file
  13. * except in compliance with the License. You may obtain a copy of
  14. * the License at http://www.mozilla.org/MPL/
  15. *
  16. * Software distributed under the License is distributed on an "AS
  17. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  18. * implied. See the License for the specific language governing
  19. * rights and limitations under the License.
  20. *
  21. * Alternatively, the contents of this file may be used under the
  22. * terms of the GNU Public License version 2 (the "GPL"), in which
  23. * case the provisions of the GPL are applicable instead of the
  24. * above. If you wish to allow the use of your version of this file
  25. * only under the terms of the GPL and not to allow others to use
  26. * your version of this file under the MPL, indicate your decision
  27. * by deleting the provisions above and replace them with the notice
  28. * and other provisions required by the GPL. If you do not delete
  29. * the provisions above, a recipient may use your version of this
  30. * file under either the MPL or the GPL.
  31. *
  32. * --------------------------------------------------------------------
  33. *
  34. * Inquiries regarding the linux-wlan Open Source project can be
  35. * made directly to:
  36. *
  37. * AbsoluteValue Systems Inc.
  38. * info@linux-wlan.com
  39. * http://www.linux-wlan.com
  40. *
  41. * --------------------------------------------------------------------
  42. *
  43. * Portions of the development of this software were funded by
  44. * Intersil Corporation as part of PRISM(R) chipset product development.
  45. *
  46. * --------------------------------------------------------------------
  47. *
  48. * This file declares the functions, types and macros that perform
  49. * Ethernet to/from 802.11 frame conversions.
  50. *
  51. * --------------------------------------------------------------------
  52. */
  53. #ifndef _LINUX_P80211CONV_H
  54. #define _LINUX_P80211CONV_H
  55. #define WLAN_IEEE_OUI_LEN 3
  56. #define WLAN_ETHCONV_ENCAP 1
  57. #define WLAN_ETHCONV_8021h 3
  58. #define P80211CAPTURE_VERSION 0x80211001
  59. #define P80211_FRMMETA_MAGIC 0x802110
  60. struct p80211_rxmeta {
  61. struct wlandevice *wlandev;
  62. u64 mactime; /* Hi-rez MAC-supplied time value */
  63. u64 hosttime; /* Best-rez host supplied time value */
  64. unsigned int rxrate; /* Receive data rate in 100kbps */
  65. unsigned int priority; /* 0-15, 0=contention, 6=CF */
  66. int signal; /* An SSI, see p80211netdev.h */
  67. int noise; /* An SSI, see p80211netdev.h */
  68. unsigned int channel; /* Receive channel (mostly for snifs) */
  69. unsigned int preamble; /* P80211ENUM_preambletype_* */
  70. unsigned int encoding; /* P80211ENUM_encoding_* */
  71. };
  72. struct p80211_frmmeta {
  73. unsigned int magic;
  74. struct p80211_rxmeta *rx;
  75. };
  76. void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb);
  77. int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb);
  78. void p80211skb_rxmeta_detach(struct sk_buff *skb);
  79. static inline struct p80211_frmmeta *p80211skb_frmmeta(struct sk_buff *skb)
  80. {
  81. struct p80211_frmmeta *frmmeta = (struct p80211_frmmeta *)skb->cb;
  82. return frmmeta->magic == P80211_FRMMETA_MAGIC ? frmmeta : NULL;
  83. }
  84. static inline struct p80211_rxmeta *p80211skb_rxmeta(struct sk_buff *skb)
  85. {
  86. struct p80211_frmmeta *frmmeta = p80211skb_frmmeta(skb);
  87. return frmmeta ? frmmeta->rx : NULL;
  88. }
  89. /*
  90. * Frame capture header. (See doc/capturefrm.txt)
  91. */
  92. struct p80211_caphdr {
  93. __be32 version;
  94. __be32 length;
  95. __be64 mactime;
  96. __be64 hosttime;
  97. __be32 phytype;
  98. __be32 channel;
  99. __be32 datarate;
  100. __be32 antenna;
  101. __be32 priority;
  102. __be32 ssi_type;
  103. __be32 ssi_signal;
  104. __be32 ssi_noise;
  105. __be32 preamble;
  106. __be32 encoding;
  107. };
  108. /* buffer free method pointer type */
  109. typedef void (*freebuf_method_t) (void *buf, int size);
  110. struct p80211_metawep {
  111. void *data;
  112. u8 iv[4];
  113. u8 icv[4];
  114. };
  115. /* local ether header type */
  116. struct wlan_ethhdr {
  117. u8 daddr[ETH_ALEN];
  118. u8 saddr[ETH_ALEN];
  119. __be16 type;
  120. } __packed;
  121. /* local llc header type */
  122. struct wlan_llc {
  123. u8 dsap;
  124. u8 ssap;
  125. u8 ctl;
  126. } __packed;
  127. /* local snap header type */
  128. struct wlan_snap {
  129. u8 oui[WLAN_IEEE_OUI_LEN];
  130. __be16 type;
  131. } __packed;
  132. /* Circular include trick */
  133. struct wlandevice;
  134. int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv,
  135. struct sk_buff *skb);
  136. int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv,
  137. struct sk_buff *skb, union p80211_hdr *p80211_hdr,
  138. struct p80211_metawep *p80211_wep);
  139. int p80211_stt_findproto(u16 proto);
  140. #endif