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
/*
 * Copyright (C) 2016 Gilles Chanteperdrix <gch@xenomai.org>.
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
#include <asm/xenomai/syscall.h>
#include <xenomai/posix/corectl.h>
 
static int rtnet_corectl_call(struct notifier_block *self, unsigned long arg,
                 void *cookie)
{
   struct cobalt_config_vector *vec = cookie;
   int ret = 0;
 
   if (arg != _CC_COBALT_GET_NET_CONFIG)
       return NOTIFY_DONE;
 
   if (vec->u_bufsz < sizeof(ret))
       return notifier_from_errno(-EINVAL);
 
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET))
       ret |= _CC_COBALT_NET;
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_ETH_P_ALL))
       ret |= _CC_COBALT_NET_ETH_P_ALL;
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTIPV4))
       ret |= _CC_COBALT_NET_IPV4;
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTIPV4_ICMP))
       ret |= _CC_COBALT_NET_ICMP;
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTIPV4_NETROUTING))
       ret |= _CC_COBALT_NET_NETROUTING;
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTIPV4_ROUTE))
       ret |= _CC_COBALT_NET_ROUTER;
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTIPV4_UDP))
       ret |= _CC_COBALT_NET_UDP;
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTPACKET))
       ret |= _CC_COBALT_NET_AF_PACKET;
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_TDMA))
       ret |= _CC_COBALT_NET_TDMA;
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_NOMAC))
       ret |= _CC_COBALT_NET_NOMAC;
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTCFG))
       ret |= _CC_COBALT_NET_CFG;
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_ADDON_RTCAP))
       ret |= _CC_COBALT_NET_CAP;
   if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_ADDON_PROXY))
       ret |= _CC_COBALT_NET_PROXY;
 
   ret = cobalt_copy_to_user(vec->u_buf, &ret, sizeof(ret));
 
   return ret ? notifier_from_errno(-EFAULT) : NOTIFY_STOP;
}
 
static struct notifier_block rtnet_corectl_notifier = {
   .notifier_call = rtnet_corectl_call,
};
 
void rtnet_corectl_register(void)
{
   cobalt_add_config_chain(&rtnet_corectl_notifier);
}
 
void rtnet_corectl_unregister(void)
{
   cobalt_remove_config_chain(&rtnet_corectl_notifier);
}