Xenomai  3.0.8
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 
31 #define RTMAC_VERSION 0x02
32 #define ETH_RTMAC 0x9021
33 
34 #define RTMAC_FLAG_TUNNEL 0x01
35 
36 
37 struct rtmac_hdr {
38  u16 type;
39  u8 ver;
40  u8 flags;
41 } __attribute__ ((packed));
42 
43 
44 
45 static inline int rtmac_add_header(struct rtnet_device *rtdev, void *daddr,
46  struct rtskb *skb, u16 type, u8 flags)
47 {
48  struct rtmac_hdr *hdr =
49  (struct rtmac_hdr *)rtskb_push(skb, sizeof(struct rtmac_hdr));
50 
51 
52  hdr->type = htons(type);
53  hdr->ver = RTMAC_VERSION;
54  hdr->flags = flags;
55 
56  skb->rtdev = rtdev;
57 
58  if (rtdev->hard_header &&
59  (rtdev->hard_header(skb, rtdev, ETH_RTMAC, daddr,
60  rtdev->dev_addr, skb->len) < 0))
61  return -1;
62 
63  return 0;
64 }
65 
66 
67 
68 static inline int rtmac_xmit(struct rtskb *skb)
69 {
70  struct rtnet_device *rtdev = skb->rtdev;
71  int ret;
72 
73 
74  ret = rtdev->hard_start_xmit(skb, rtdev);
75  if (ret != 0)
76  kfree_rtskb(skb);
77 
78  return ret;
79 }
80 
81 
82 extern struct rtpacket_type rtmac_packet_type;
83 
84 #define rtmac_proto_init() rtdev_add_pack(&rtmac_packet_type)
85 void rtmac_proto_release(void);
86 
87 #endif /* __RTMAC_PROTO_H_ */