j1939.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * j1939.h
  4. *
  5. * Copyright (c) 2010-2011 EIA Electronics
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef _UAPI_CAN_J1939_H_
  12. #define _UAPI_CAN_J1939_H_
  13. #include <linux/types.h>
  14. #include <linux/socket.h>
  15. #include <linux/can.h>
  16. #define J1939_IDLE_ADDR 0xfe
  17. #define J1939_NO_ADDR 0xff
  18. #define J1939_NO_NAME 0
  19. #define J1939_NO_PGN 0x40000
  20. /* J1939 Parameter Group Number
  21. *
  22. * bit 0-7 : PDU Specific (PS)
  23. * bit 8-15 : PDU Format (PF)
  24. * bit 16 : Data Page (DP)
  25. * bit 17 : Reserved (R)
  26. * bit 19-31 : set to zero
  27. */
  28. typedef __u32 pgn_t;
  29. /* J1939 Priority
  30. *
  31. * bit 0-2 : Priority (P)
  32. * bit 3-7 : set to zero
  33. */
  34. typedef __u8 priority_t;
  35. /* J1939 NAME
  36. *
  37. * bit 0-20 : Identity Number
  38. * bit 21-31 : Manufacturer Code
  39. * bit 32-34 : ECU Instance
  40. * bit 35-39 : Function Instance
  41. * bit 40-47 : Function
  42. * bit 48 : Reserved
  43. * bit 49-55 : Vehicle System
  44. * bit 56-59 : Vehicle System Instance
  45. * bit 60-62 : Industry Group
  46. * bit 63 : Arbitrary Address Capable
  47. */
  48. typedef __u64 name_t;
  49. /* J1939 socket options */
  50. #define SOL_CAN_J1939 (SOL_CAN_BASE + CAN_J1939)
  51. enum {
  52. SO_J1939_FILTER = 1, /* set filters */
  53. SO_J1939_PROMISC = 2, /* set/clr promiscuous mode */
  54. SO_J1939_RECV_OWN = 3,
  55. SO_J1939_SEND_PRIO = 4,
  56. };
  57. enum {
  58. SCM_J1939_DEST_ADDR = 1,
  59. SCM_J1939_DEST_NAME = 2,
  60. SCM_J1939_PRIO = 3,
  61. };
  62. struct j1939_filter {
  63. name_t name;
  64. name_t name_mask;
  65. __u8 addr;
  66. __u8 addr_mask;
  67. pgn_t pgn;
  68. pgn_t pgn_mask;
  69. };
  70. #define J1939_FILTER_MAX 512 /* maximum number of j1939_filter set via setsockopt() */
  71. #endif /* !_UAPI_CAN_J1939_H_ */