@@ -6,27 +6,112 @@ extern "C" {
6
6
7
7
#include <csp/csp.h>
8
8
9
+ /**
10
+ * Prepend CSP header fields into the packet's data buffer.
11
+ *
12
+ * This function encodes the CSP ID header into the packet and adjusts the data offset.
13
+ *
14
+ * @param packet Pointer to the packet to modify.
15
+ */
9
16
void csp_id_prepend (csp_packet_t * packet );
17
+
18
+ /**
19
+ * Strip CSP header fields from the packet's data buffer.
20
+ *
21
+ * This function decodes the CSP ID header from the packet and adjusts the data offset.
22
+ *
23
+ * @param packet Pointer to the packet to modify.
24
+ * @return 0 on success, -1 on failure.
25
+ */
10
26
int csp_id_strip (csp_packet_t * packet );
27
+
28
+ /**
29
+ * Setup reception information from CSP ID header.
30
+ *
31
+ * Typically called after stripping the header to configure addressing fields.
32
+ *
33
+ * @param packet Pointer to the received packet.
34
+ * @return 0 on success, -1 on failure.
35
+ */
11
36
int csp_id_setup_rx (csp_packet_t * packet );
37
+
38
+ /**
39
+ * Get number of bits allocated for the host part of the address.
40
+ *
41
+ * @return Number of bits used for the host ID.
42
+ */
12
43
unsigned int csp_id_get_host_bits (void );
44
+
45
+ /**
46
+ * Get maximum allowed node ID.
47
+ *
48
+ * @return Maximum node ID based on current configuration.
49
+ */
13
50
unsigned int csp_id_get_max_nodeid (void );
51
+
52
+ /**
53
+ * Get maximum allowed port number.
54
+ *
55
+ * @return Maximum port number.
56
+ */
14
57
unsigned int csp_id_get_max_port (void );
15
58
59
+ /**
60
+ * Check whether a given address is a broadcast address.
61
+ *
62
+ * @param addr The address to test.
63
+ * @param iface Interface to use for context (netmask, etc.).
64
+ * @return 1 if broadcast, 0 otherwise.
65
+ */
16
66
int csp_id_is_broadcast (uint16_t addr , csp_iface_t * iface );
17
67
68
+ /**
69
+ * Get the size of the CSP header based on the configured version.
70
+ *
71
+ * This function returns the size in bytes of the CSP packet header,
72
+ * depending on whether CSP version 1 or 2 is configured.
73
+ *
74
+ * @return The header size in bytes.
75
+ */
18
76
int csp_id_get_header_size (void );
19
77
20
78
#if (CSP_FIXUP_V1_ZMQ_LITTLE_ENDIAN )
79
+
80
+ /**
81
+ * Prepend CSPv1-compatible ID header (ZMQ fixup).
82
+ *
83
+ * Used when sending CSPv1 packets on little-endian ZMQ transport.
84
+ *
85
+ * @param packet Pointer to the packet to modify.
86
+ */
21
87
void csp_id_prepend_fixup_cspv1 (csp_packet_t * packet );
88
+
89
+ /**
90
+ * Strip CSPv1-compatible ID header (ZMQ fixup).
91
+ *
92
+ * Used when receiving CSPv1 packets on little-endian ZMQ transport.
93
+ *
94
+ * @param packet Pointer to the packet to modify.
95
+ * @return 0 on success, -1 on failure.
96
+ */
22
97
int csp_id_strip_fixup_cspv1 (csp_packet_t * packet );
98
+
23
99
#else
100
+
101
+ /**
102
+ * Wrapper for csp_id_prepend when no fixup is required.
103
+ */
24
104
static inline void csp_id_prepend_fixup_cspv1 (csp_packet_t * packet ) {
25
105
csp_id_prepend (packet );
26
106
}
107
+
108
+ /**
109
+ * Wrapper for csp_id_strip when no fixup is required.
110
+ */
27
111
static inline int csp_id_strip_fixup_cspv1 (csp_packet_t * packet ) {
28
112
return csp_id_strip (packet );
29
113
}
114
+
30
115
#endif
31
116
32
117
#ifdef __cplusplus
0 commit comments