logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

j1939.h (2403B)


  1. /* SPDX-License-Identifier: GPL-2.0-only 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 _CAN_J1939_H_
  12. #define _CAN_J1939_H_
  13. #include <linux/types.h>
  14. #include <linux/socket.h>
  15. #include <linux/can.h>
  16. #define J1939_MAX_UNICAST_ADDR 0xfd
  17. #define J1939_IDLE_ADDR 0xfe
  18. #define J1939_NO_ADDR 0xff /* == broadcast or no addr */
  19. #define J1939_NO_NAME 0
  20. #define J1939_PGN_REQUEST 0x0ea00 /* Request PG */
  21. #define J1939_PGN_ADDRESS_CLAIMED 0x0ee00 /* Address Claimed */
  22. #define J1939_PGN_ADDRESS_COMMANDED 0x0fed8 /* Commanded Address */
  23. #define J1939_PGN_PDU1_MAX 0x3ff00
  24. #define J1939_PGN_MAX 0x3ffff
  25. #define J1939_NO_PGN 0x40000
  26. /* J1939 Parameter Group Number
  27. *
  28. * bit 0-7 : PDU Specific (PS)
  29. * bit 8-15 : PDU Format (PF)
  30. * bit 16 : Data Page (DP)
  31. * bit 17 : Reserved (R)
  32. * bit 19-31 : set to zero
  33. */
  34. typedef __u32 pgn_t;
  35. /* J1939 Priority
  36. *
  37. * bit 0-2 : Priority (P)
  38. * bit 3-7 : set to zero
  39. */
  40. typedef __u8 priority_t;
  41. /* J1939 NAME
  42. *
  43. * bit 0-20 : Identity Number
  44. * bit 21-31 : Manufacturer Code
  45. * bit 32-34 : ECU Instance
  46. * bit 35-39 : Function Instance
  47. * bit 40-47 : Function
  48. * bit 48 : Reserved
  49. * bit 49-55 : Vehicle System
  50. * bit 56-59 : Vehicle System Instance
  51. * bit 60-62 : Industry Group
  52. * bit 63 : Arbitrary Address Capable
  53. */
  54. typedef __u64 name_t;
  55. /* J1939 socket options */
  56. #define SOL_CAN_J1939 (SOL_CAN_BASE + CAN_J1939)
  57. enum {
  58. SO_J1939_FILTER = 1, /* set filters */
  59. SO_J1939_PROMISC = 2, /* set/clr promiscuous mode */
  60. SO_J1939_SEND_PRIO = 3,
  61. SO_J1939_ERRQUEUE = 4,
  62. };
  63. enum {
  64. SCM_J1939_DEST_ADDR = 1,
  65. SCM_J1939_DEST_NAME = 2,
  66. SCM_J1939_PRIO = 3,
  67. SCM_J1939_ERRQUEUE = 4,
  68. };
  69. enum {
  70. J1939_NLA_PAD,
  71. J1939_NLA_BYTES_ACKED,
  72. J1939_NLA_TOTAL_SIZE,
  73. J1939_NLA_PGN,
  74. J1939_NLA_SRC_NAME,
  75. J1939_NLA_DEST_NAME,
  76. J1939_NLA_SRC_ADDR,
  77. J1939_NLA_DEST_ADDR,
  78. };
  79. enum {
  80. J1939_EE_INFO_NONE,
  81. J1939_EE_INFO_TX_ABORT,
  82. J1939_EE_INFO_RX_RTS,
  83. J1939_EE_INFO_RX_DPO,
  84. J1939_EE_INFO_RX_ABORT,
  85. };
  86. struct j1939_filter {
  87. name_t name;
  88. name_t name_mask;
  89. pgn_t pgn;
  90. pgn_t pgn_mask;
  91. __u8 addr;
  92. __u8 addr_mask;
  93. };
  94. #define J1939_FILTER_MAX 512 /* maximum number of j1939_filter set via setsockopt() */
  95. #endif /* !_UAPI_CAN_J1939_H_ */