netlabel.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * SELinux interface to the NetLabel subsystem
  3. *
  4. * Author : Paul Moore <paul.moore@hp.com>
  5. *
  6. */
  7. /*
  8. * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  18. * the GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. *
  24. */
  25. #ifndef _SELINUX_NETLABEL_H_
  26. #define _SELINUX_NETLABEL_H_
  27. #include <linux/types.h>
  28. #include <linux/fs.h>
  29. #include <linux/net.h>
  30. #include <linux/skbuff.h>
  31. #include <net/sock.h>
  32. #include "avc.h"
  33. #include "objsec.h"
  34. #ifdef CONFIG_NETLABEL
  35. void selinux_netlbl_cache_invalidate(void);
  36. void selinux_netlbl_err(struct sk_buff *skb, int error, int gateway);
  37. void selinux_netlbl_sk_security_free(struct sk_security_struct *ssec);
  38. void selinux_netlbl_sk_security_reset(struct sk_security_struct *ssec,
  39. int family);
  40. int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
  41. u16 family,
  42. u32 *type,
  43. u32 *sid);
  44. int selinux_netlbl_skbuff_setsid(struct sk_buff *skb,
  45. u16 family,
  46. u32 sid);
  47. void selinux_netlbl_inet_conn_established(struct sock *sk, u16 family);
  48. int selinux_netlbl_socket_post_create(struct socket *sock);
  49. int selinux_netlbl_inode_permission(struct inode *inode, int mask);
  50. int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
  51. struct sk_buff *skb,
  52. u16 family,
  53. struct avc_audit_data *ad);
  54. int selinux_netlbl_socket_setsockopt(struct socket *sock,
  55. int level,
  56. int optname);
  57. int selinux_netlbl_socket_connect(struct sock *sk, struct sockaddr *addr);
  58. #else
  59. static inline void selinux_netlbl_cache_invalidate(void)
  60. {
  61. return;
  62. }
  63. static inline void selinux_netlbl_err(struct sk_buff *skb,
  64. int error,
  65. int gateway)
  66. {
  67. return;
  68. }
  69. static inline void selinux_netlbl_sk_security_free(
  70. struct sk_security_struct *ssec)
  71. {
  72. return;
  73. }
  74. static inline void selinux_netlbl_sk_security_reset(
  75. struct sk_security_struct *ssec,
  76. int family)
  77. {
  78. return;
  79. }
  80. static inline int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
  81. u16 family,
  82. u32 *type,
  83. u32 *sid)
  84. {
  85. *type = NETLBL_NLTYPE_NONE;
  86. *sid = SECSID_NULL;
  87. return 0;
  88. }
  89. static inline int selinux_netlbl_skbuff_setsid(struct sk_buff *skb,
  90. u16 family,
  91. u32 sid)
  92. {
  93. return 0;
  94. }
  95. static inline int selinux_netlbl_conn_setsid(struct sock *sk,
  96. struct sockaddr *addr)
  97. {
  98. return 0;
  99. }
  100. static inline void selinux_netlbl_inet_conn_established(struct sock *sk,
  101. u16 family)
  102. {
  103. return;
  104. }
  105. static inline int selinux_netlbl_socket_post_create(struct socket *sock)
  106. {
  107. return 0;
  108. }
  109. static inline int selinux_netlbl_inode_permission(struct inode *inode,
  110. int mask)
  111. {
  112. return 0;
  113. }
  114. static inline int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
  115. struct sk_buff *skb,
  116. u16 family,
  117. struct avc_audit_data *ad)
  118. {
  119. return 0;
  120. }
  121. static inline int selinux_netlbl_socket_setsockopt(struct socket *sock,
  122. int level,
  123. int optname)
  124. {
  125. return 0;
  126. }
  127. static inline int selinux_netlbl_socket_connect(struct sock *sk,
  128. struct sockaddr *addr)
  129. {
  130. return 0;
  131. }
  132. #endif /* CONFIG_NETLABEL */
  133. #endif