wlan_nlink_srv.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 2012-2017, 2019-2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /******************************************************************************
  19. * wlan_nlink_srv.h
  20. *
  21. * wlan_nlink_srv is used to RX/TX Netlink messages from user space to kernel
  22. * modules and vice versa. Kernel modules must register a message handler for a
  23. * message type so that the wlan_nlink_srv can invoke the corresponding msg handler
  24. * whenever a Netlink message of a particular type has been received from an
  25. * application. In the opposite direction, wlan_nlink_srv provides a mechanism
  26. * which kernel modules can use to send Netlink messages to applications.
  27. *
  28. ******************************************************************************/
  29. #ifndef WLAN_NLINK_SRV_H
  30. #define WLAN_NLINK_SRV_H
  31. #include <linux/skbuff.h>
  32. #include <net/netlink.h>
  33. #include <wlan_nlink_common.h>
  34. #define INVALID_PID -1
  35. #define NLINK_MAX_CALLBACKS (WLAN_NL_MSG_MAX - WLAN_NL_MSG_BASE)
  36. typedef int (*nl_srv_msg_callback)(struct sk_buff *skb);
  37. /**
  38. * cld80211_oem_send_reply() - API to send cld80211 msg
  39. * @skb: Sk buffer
  40. * @hdr: nl80211hdr pointer
  41. * @nest: pointer of vendor nested attribute
  42. * @flags: Flags
  43. *
  44. * API to send cld80211 msg to applications
  45. *
  46. * Return: None
  47. */
  48. void cld80211_oem_send_reply(struct sk_buff *msg, void *hdr,
  49. struct nlattr *nest, int flags);
  50. /**
  51. * nl80211hdr_put() - API to allocate skb for cld80211 msg
  52. * @hdr: nl80211hdr pointer
  53. * @portid: Port ID
  54. * @nest: pointer of vendor nested attribute
  55. * @flags: Flags
  56. *
  57. * API to allocate skb for cld80211 msg
  58. *
  59. * Return: Pointer to skbuff
  60. */
  61. struct sk_buff *
  62. cld80211_oem_rsp_alloc_skb(uint32_t portid, void **hdr, struct nlattr **nest,
  63. int *flags);
  64. int nl_srv_init(void *wiphy, int proto);
  65. void nl_srv_exit(void);
  66. int nl_srv_register(tWlanNlModTypes msg_type, nl_srv_msg_callback msg_handler);
  67. int nl_srv_unregister(tWlanNlModTypes msg_type,
  68. nl_srv_msg_callback msg_handler);
  69. #ifdef CNSS_GENL
  70. int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag,
  71. int app_id, int mcgroup_id);
  72. int nl_srv_bcast(struct sk_buff *skb, int mcgroup_id, int app_id);
  73. /**
  74. * nl80211hdr_put() - API to fill genlmsg header
  75. * @skb: Sk buffer
  76. * @portid: Port ID
  77. * @seq: Sequence number
  78. * @flags: Flags
  79. * @cmd: Command id
  80. *
  81. * API to fill genl message header for brodcast events to user space
  82. *
  83. * Return: Pointer to user specific header/payload
  84. */
  85. void *nl80211hdr_put(struct sk_buff *skb, uint32_t portid,
  86. uint32_t seq, int flags, uint8_t cmd);
  87. #else
  88. int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag);
  89. int nl_srv_bcast(struct sk_buff *skb);
  90. #endif
  91. int nl_srv_is_initialized(void);
  92. void nl_srv_ucast_oem(struct sk_buff *skb, int dst_pid, int flag);
  93. #endif