Xenomai 3.3.2
Loading...
Searching...
No Matches
rtmac_proto.h
1/***
2 *
3 * include/rtmac/rtmac_proto.h
4 *
5 * rtmac - real-time networking media access control subsystem
6 * Copyright (C) 2002 Marc Kleine-Budde <kleine-budde@gmx.de>,
7 * 2003, 2004 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 __RTMAC_PROTO_H_
26#define __RTMAC_PROTO_H_
27
28#include <stack_mgr.h>
29
30#define RTMAC_VERSION 0x02
31#define ETH_RTMAC 0x9021
32
33#define RTMAC_FLAG_TUNNEL 0x01
34
35struct rtmac_hdr {
36 u16 type;
37 u8 ver;
38 u8 flags;
39} __attribute__((packed));
40
41static inline int rtmac_add_header(struct rtnet_device *rtdev, void *daddr,
42 struct rtskb *skb, u16 type, u8 flags)
43{
44 struct rtmac_hdr *hdr =
45 (struct rtmac_hdr *)rtskb_push(skb, sizeof(struct rtmac_hdr));
46
47 hdr->type = htons(type);
48 hdr->ver = RTMAC_VERSION;
49 hdr->flags = flags;
50
51 skb->rtdev = rtdev;
52
53 if (rtdev->hard_header &&
54 (rtdev->hard_header(skb, rtdev, ETH_RTMAC, daddr, rtdev->dev_addr,
55 skb->len) < 0))
56 return -1;
57
58 return 0;
59}
60
61static inline int rtmac_xmit(struct rtskb *skb)
62{
63 struct rtnet_device *rtdev = skb->rtdev;
64 int ret;
65
66 ret = rtdev->hard_start_xmit(skb, rtdev);
67 if (ret != 0)
68 kfree_rtskb(skb);
69
70 return ret;
71}
72
73extern struct rtpacket_type rtmac_packet_type;
74
75#define rtmac_proto_init() rtdev_add_pack(&rtmac_packet_type)
76void rtmac_proto_release(void);
77
78#endif /* __RTMAC_PROTO_H_ */