phonet.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * File: af_phonet.h
  3. *
  4. * Phonet sockets kernel definitions
  5. *
  6. * Copyright (C) 2008 Nokia Corporation.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. */
  22. #ifndef AF_PHONET_H
  23. #define AF_PHONET_H
  24. /*
  25. * The lower layers may not require more space, ever. Make sure it's
  26. * enough.
  27. */
  28. #define MAX_PHONET_HEADER 8
  29. static inline struct phonethdr *pn_hdr(struct sk_buff *skb)
  30. {
  31. return (struct phonethdr *)skb_network_header(skb);
  32. }
  33. /*
  34. * Get the other party's sockaddr from received skb. The skb begins
  35. * with a Phonet header.
  36. */
  37. static inline
  38. void pn_skb_get_src_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
  39. {
  40. struct phonethdr *ph = pn_hdr(skb);
  41. u16 obj = pn_object(ph->pn_sdev, ph->pn_sobj);
  42. sa->spn_family = AF_PHONET;
  43. pn_sockaddr_set_object(sa, obj);
  44. pn_sockaddr_set_resource(sa, ph->pn_res);
  45. memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
  46. }
  47. static inline
  48. void pn_skb_get_dst_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
  49. {
  50. struct phonethdr *ph = pn_hdr(skb);
  51. u16 obj = pn_object(ph->pn_rdev, ph->pn_robj);
  52. sa->spn_family = AF_PHONET;
  53. pn_sockaddr_set_object(sa, obj);
  54. pn_sockaddr_set_resource(sa, ph->pn_res);
  55. memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
  56. }
  57. /* Protocols in Phonet protocol family. */
  58. struct phonet_protocol {
  59. struct proto *prot;
  60. int sock_type;
  61. };
  62. int phonet_proto_register(int protocol, struct phonet_protocol *pp);
  63. void phonet_proto_unregister(int protocol, struct phonet_protocol *pp);
  64. void phonet_netlink_register(void);
  65. #endif