hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/***
 *
 *  include/rtcfg/rtcfg_frame.h
 *
 *  Real-Time Configuration Distribution Protocol
 *
 *  Copyright (C) 2003 Jan Kiszka <jan.kiszka@web.de>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
 
#ifndef __RTCFG_FRAME_H_
#define __RTCFG_FRAME_H_
 
#include <linux/init.h>
#include <linux/if_packet.h>
#include <asm/byteorder.h>
 
#include <rtcfg/rtcfg_event.h>
 
#define ETH_RTCFG 0x9022
 
#define RTCFG_SKB_PRIO                                                         \
   RTSKB_PRIO_VALUE(QUEUE_MIN_PRIO - 1, RTSKB_DEF_NRT_CHANNEL)
 
#define RTCFG_ID_STAGE_1_CFG 0
#define RTCFG_ID_ANNOUNCE_NEW 1
#define RTCFG_ID_ANNOUNCE_REPLY 2
#define RTCFG_ID_STAGE_2_CFG 3
#define RTCFG_ID_STAGE_2_CFG_FRAG 4
#define RTCFG_ID_ACK_CFG 5
#define RTCFG_ID_READY 6
#define RTCFG_ID_HEARTBEAT 7
#define RTCFG_ID_DEAD_STATION 8
 
#define RTCFG_ADDRSIZE_MAC 0
#define RTCFG_ADDRSIZE_IP 4
#define RTCFG_MAX_ADDRSIZE RTCFG_ADDRSIZE_IP
 
#define RTCFG_FLAG_STAGE_2_DATA 0
#define RTCFG_FLAG_READY 1
 
#define _RTCFG_FLAG_STAGE_2_DATA (1 << RTCFG_FLAG_STAGE_2_DATA)
#define _RTCFG_FLAG_READY (1 << RTCFG_FLAG_READY)
 
struct rtcfg_frm_head {
#if defined(__LITTLE_ENDIAN_BITFIELD)
   u8 id : 5;
   u8 version : 3;
#elif defined(__BIG_ENDIAN_BITFIELD)
   u8 version : 3;
   u8 id : 5;
#else
#error unsupported byte order
#endif
} __attribute__((packed));
 
struct rtcfg_frm_stage_1_cfg {
   struct rtcfg_frm_head head;
   u8 addr_type;
   u8 client_addr[0];
   u8 server_addr[0];
   u8 burstrate;
   u16 cfg_len;
   u8 cfg_data[0];
} __attribute__((packed));
 
struct rtcfg_frm_announce {
   struct rtcfg_frm_head head;
   u8 addr_type;
   u8 addr[0];
   u8 flags;
   u8 burstrate;
} __attribute__((packed));
 
struct rtcfg_frm_stage_2_cfg {
   struct rtcfg_frm_head head;
   u8 flags;
   u32 stations;
   u16 heartbeat_period;
   u32 cfg_len;
   u8 cfg_data[0];
} __attribute__((packed));
 
struct rtcfg_frm_stage_2_cfg_frag {
   struct rtcfg_frm_head head;
   u32 frag_offs;
   u8 cfg_data[0];
} __attribute__((packed));
 
struct rtcfg_frm_ack_cfg {
   struct rtcfg_frm_head head;
   u32 ack_len;
} __attribute__((packed));
 
struct rtcfg_frm_simple {
   struct rtcfg_frm_head head;
} __attribute__((packed));
 
struct rtcfg_frm_dead_station {
   struct rtcfg_frm_head head;
   u8 addr_type;
   u8 logical_addr[0];
   u8 physical_addr[32];
} __attribute__((packed));
 
int rtcfg_send_stage_1(struct rtcfg_connection *conn);
int rtcfg_send_stage_2(struct rtcfg_connection *conn, int send_data);
int rtcfg_send_stage_2_frag(struct rtcfg_connection *conn);
int rtcfg_send_announce_new(int ifindex);
int rtcfg_send_announce_reply(int ifindex, u8 *dest_mac_addr);
int rtcfg_send_ack(int ifindex);
int rtcfg_send_dead_station(struct rtcfg_connection *conn);
 
int rtcfg_send_simple_frame(int ifindex, int frame_id, u8 *dest_addr);
 
#define rtcfg_send_ready(ifindex)                                              \
   rtcfg_send_simple_frame(ifindex, RTCFG_ID_READY, NULL)
#define rtcfg_send_heartbeat(ifindex)                                          \
   rtcfg_send_simple_frame(ifindex, RTCFG_ID_HEARTBEAT,                   \
               device[ifindex].spec.clt.srv_mac_addr)
 
int __init rtcfg_init_frames(void);
void rtcfg_cleanup_frames(void);
 
#endif /* __RTCFG_FRAME_H_ */