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