mtip32xx: fix error handling in mtip_init()
[zen-stable.git] / net / ieee802154 / nl-mac.c
blobadaf46214905964f76bef59f7f660808c982054d
1 /*
2 * Netlink inteface for IEEE 802.15.4 stack
4 * Copyright 2007, 2008 Siemens AG
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 * Written by:
20 * Sergey Lapin <slapin@ossfans.org>
21 * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
22 * Maxim Osipov <maxim.osipov@siemens.com>
25 #include <linux/gfp.h>
26 #include <linux/kernel.h>
27 #include <linux/if_arp.h>
28 #include <linux/netdevice.h>
29 #include <net/netlink.h>
30 #include <net/genetlink.h>
31 #include <net/sock.h>
32 #include <linux/nl802154.h>
33 #include <linux/export.h>
34 #include <net/af_ieee802154.h>
35 #include <net/nl802154.h>
36 #include <net/ieee802154.h>
37 #include <net/ieee802154_netdev.h>
38 #include <net/wpan-phy.h>
40 #include "ieee802154.h"
42 static struct genl_multicast_group ieee802154_coord_mcgrp = {
43 .name = IEEE802154_MCAST_COORD_NAME,
46 static struct genl_multicast_group ieee802154_beacon_mcgrp = {
47 .name = IEEE802154_MCAST_BEACON_NAME,
50 int ieee802154_nl_assoc_indic(struct net_device *dev,
51 struct ieee802154_addr *addr, u8 cap)
53 struct sk_buff *msg;
55 pr_debug("%s\n", __func__);
57 if (addr->addr_type != IEEE802154_ADDR_LONG) {
58 pr_err("%s: received non-long source address!\n", __func__);
59 return -EINVAL;
62 msg = ieee802154_nl_create(0, IEEE802154_ASSOCIATE_INDIC);
63 if (!msg)
64 return -ENOBUFS;
66 NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name);
67 NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex);
68 NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
69 dev->dev_addr);
71 NLA_PUT(msg, IEEE802154_ATTR_SRC_HW_ADDR, IEEE802154_ADDR_LEN,
72 addr->hwaddr);
74 NLA_PUT_U8(msg, IEEE802154_ATTR_CAPABILITY, cap);
76 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id);
78 nla_put_failure:
79 nlmsg_free(msg);
80 return -ENOBUFS;
82 EXPORT_SYMBOL(ieee802154_nl_assoc_indic);
84 int ieee802154_nl_assoc_confirm(struct net_device *dev, u16 short_addr,
85 u8 status)
87 struct sk_buff *msg;
89 pr_debug("%s\n", __func__);
91 msg = ieee802154_nl_create(0, IEEE802154_ASSOCIATE_CONF);
92 if (!msg)
93 return -ENOBUFS;
95 NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name);
96 NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex);
97 NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
98 dev->dev_addr);
100 NLA_PUT_U16(msg, IEEE802154_ATTR_SHORT_ADDR, short_addr);
101 NLA_PUT_U8(msg, IEEE802154_ATTR_STATUS, status);
103 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id);
105 nla_put_failure:
106 nlmsg_free(msg);
107 return -ENOBUFS;
109 EXPORT_SYMBOL(ieee802154_nl_assoc_confirm);
111 int ieee802154_nl_disassoc_indic(struct net_device *dev,
112 struct ieee802154_addr *addr, u8 reason)
114 struct sk_buff *msg;
116 pr_debug("%s\n", __func__);
118 msg = ieee802154_nl_create(0, IEEE802154_DISASSOCIATE_INDIC);
119 if (!msg)
120 return -ENOBUFS;
122 NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name);
123 NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex);
124 NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
125 dev->dev_addr);
127 if (addr->addr_type == IEEE802154_ADDR_LONG)
128 NLA_PUT(msg, IEEE802154_ATTR_SRC_HW_ADDR, IEEE802154_ADDR_LEN,
129 addr->hwaddr);
130 else
131 NLA_PUT_U16(msg, IEEE802154_ATTR_SRC_SHORT_ADDR,
132 addr->short_addr);
134 NLA_PUT_U8(msg, IEEE802154_ATTR_REASON, reason);
136 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id);
138 nla_put_failure:
139 nlmsg_free(msg);
140 return -ENOBUFS;
142 EXPORT_SYMBOL(ieee802154_nl_disassoc_indic);
144 int ieee802154_nl_disassoc_confirm(struct net_device *dev, u8 status)
146 struct sk_buff *msg;
148 pr_debug("%s\n", __func__);
150 msg = ieee802154_nl_create(0, IEEE802154_DISASSOCIATE_CONF);
151 if (!msg)
152 return -ENOBUFS;
154 NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name);
155 NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex);
156 NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
157 dev->dev_addr);
159 NLA_PUT_U8(msg, IEEE802154_ATTR_STATUS, status);
161 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id);
163 nla_put_failure:
164 nlmsg_free(msg);
165 return -ENOBUFS;
167 EXPORT_SYMBOL(ieee802154_nl_disassoc_confirm);
169 int ieee802154_nl_beacon_indic(struct net_device *dev,
170 u16 panid, u16 coord_addr)
172 struct sk_buff *msg;
174 pr_debug("%s\n", __func__);
176 msg = ieee802154_nl_create(0, IEEE802154_BEACON_NOTIFY_INDIC);
177 if (!msg)
178 return -ENOBUFS;
180 NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name);
181 NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex);
182 NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
183 dev->dev_addr);
184 NLA_PUT_U16(msg, IEEE802154_ATTR_COORD_SHORT_ADDR, coord_addr);
185 NLA_PUT_U16(msg, IEEE802154_ATTR_COORD_PAN_ID, panid);
187 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id);
189 nla_put_failure:
190 nlmsg_free(msg);
191 return -ENOBUFS;
193 EXPORT_SYMBOL(ieee802154_nl_beacon_indic);
195 int ieee802154_nl_scan_confirm(struct net_device *dev,
196 u8 status, u8 scan_type, u32 unscanned, u8 page,
197 u8 *edl/* , struct list_head *pan_desc_list */)
199 struct sk_buff *msg;
201 pr_debug("%s\n", __func__);
203 msg = ieee802154_nl_create(0, IEEE802154_SCAN_CONF);
204 if (!msg)
205 return -ENOBUFS;
207 NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name);
208 NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex);
209 NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
210 dev->dev_addr);
212 NLA_PUT_U8(msg, IEEE802154_ATTR_STATUS, status);
213 NLA_PUT_U8(msg, IEEE802154_ATTR_SCAN_TYPE, scan_type);
214 NLA_PUT_U32(msg, IEEE802154_ATTR_CHANNELS, unscanned);
215 NLA_PUT_U8(msg, IEEE802154_ATTR_PAGE, page);
217 if (edl)
218 NLA_PUT(msg, IEEE802154_ATTR_ED_LIST, 27, edl);
220 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id);
222 nla_put_failure:
223 nlmsg_free(msg);
224 return -ENOBUFS;
226 EXPORT_SYMBOL(ieee802154_nl_scan_confirm);
228 int ieee802154_nl_start_confirm(struct net_device *dev, u8 status)
230 struct sk_buff *msg;
232 pr_debug("%s\n", __func__);
234 msg = ieee802154_nl_create(0, IEEE802154_START_CONF);
235 if (!msg)
236 return -ENOBUFS;
238 NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name);
239 NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex);
240 NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
241 dev->dev_addr);
243 NLA_PUT_U8(msg, IEEE802154_ATTR_STATUS, status);
245 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id);
247 nla_put_failure:
248 nlmsg_free(msg);
249 return -ENOBUFS;
251 EXPORT_SYMBOL(ieee802154_nl_start_confirm);
253 static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 pid,
254 u32 seq, int flags, struct net_device *dev)
256 void *hdr;
257 struct wpan_phy *phy;
259 pr_debug("%s\n", __func__);
261 hdr = genlmsg_put(msg, 0, seq, &nl802154_family, flags,
262 IEEE802154_LIST_IFACE);
263 if (!hdr)
264 goto out;
266 phy = ieee802154_mlme_ops(dev)->get_phy(dev);
267 BUG_ON(!phy);
269 NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name);
270 NLA_PUT_STRING(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy));
271 NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex);
273 NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
274 dev->dev_addr);
275 NLA_PUT_U16(msg, IEEE802154_ATTR_SHORT_ADDR,
276 ieee802154_mlme_ops(dev)->get_short_addr(dev));
277 NLA_PUT_U16(msg, IEEE802154_ATTR_PAN_ID,
278 ieee802154_mlme_ops(dev)->get_pan_id(dev));
279 wpan_phy_put(phy);
280 return genlmsg_end(msg, hdr);
282 nla_put_failure:
283 wpan_phy_put(phy);
284 genlmsg_cancel(msg, hdr);
285 out:
286 return -EMSGSIZE;
289 /* Requests from userspace */
290 static struct net_device *ieee802154_nl_get_dev(struct genl_info *info)
292 struct net_device *dev;
294 if (info->attrs[IEEE802154_ATTR_DEV_NAME]) {
295 char name[IFNAMSIZ + 1];
296 nla_strlcpy(name, info->attrs[IEEE802154_ATTR_DEV_NAME],
297 sizeof(name));
298 dev = dev_get_by_name(&init_net, name);
299 } else if (info->attrs[IEEE802154_ATTR_DEV_INDEX])
300 dev = dev_get_by_index(&init_net,
301 nla_get_u32(info->attrs[IEEE802154_ATTR_DEV_INDEX]));
302 else
303 return NULL;
305 if (!dev)
306 return NULL;
308 if (dev->type != ARPHRD_IEEE802154) {
309 dev_put(dev);
310 return NULL;
313 return dev;
316 static int ieee802154_associate_req(struct sk_buff *skb,
317 struct genl_info *info)
319 struct net_device *dev;
320 struct ieee802154_addr addr;
321 u8 page;
322 int ret = -EINVAL;
324 if (!info->attrs[IEEE802154_ATTR_CHANNEL] ||
325 !info->attrs[IEEE802154_ATTR_COORD_PAN_ID] ||
326 (!info->attrs[IEEE802154_ATTR_COORD_HW_ADDR] &&
327 !info->attrs[IEEE802154_ATTR_COORD_SHORT_ADDR]) ||
328 !info->attrs[IEEE802154_ATTR_CAPABILITY])
329 return -EINVAL;
331 dev = ieee802154_nl_get_dev(info);
332 if (!dev)
333 return -ENODEV;
335 if (info->attrs[IEEE802154_ATTR_COORD_HW_ADDR]) {
336 addr.addr_type = IEEE802154_ADDR_LONG;
337 nla_memcpy(addr.hwaddr,
338 info->attrs[IEEE802154_ATTR_COORD_HW_ADDR],
339 IEEE802154_ADDR_LEN);
340 } else {
341 addr.addr_type = IEEE802154_ADDR_SHORT;
342 addr.short_addr = nla_get_u16(
343 info->attrs[IEEE802154_ATTR_COORD_SHORT_ADDR]);
345 addr.pan_id = nla_get_u16(info->attrs[IEEE802154_ATTR_COORD_PAN_ID]);
347 if (info->attrs[IEEE802154_ATTR_PAGE])
348 page = nla_get_u8(info->attrs[IEEE802154_ATTR_PAGE]);
349 else
350 page = 0;
352 ret = ieee802154_mlme_ops(dev)->assoc_req(dev, &addr,
353 nla_get_u8(info->attrs[IEEE802154_ATTR_CHANNEL]),
354 page,
355 nla_get_u8(info->attrs[IEEE802154_ATTR_CAPABILITY]));
357 dev_put(dev);
358 return ret;
361 static int ieee802154_associate_resp(struct sk_buff *skb,
362 struct genl_info *info)
364 struct net_device *dev;
365 struct ieee802154_addr addr;
366 int ret = -EINVAL;
368 if (!info->attrs[IEEE802154_ATTR_STATUS] ||
369 !info->attrs[IEEE802154_ATTR_DEST_HW_ADDR] ||
370 !info->attrs[IEEE802154_ATTR_DEST_SHORT_ADDR])
371 return -EINVAL;
373 dev = ieee802154_nl_get_dev(info);
374 if (!dev)
375 return -ENODEV;
377 addr.addr_type = IEEE802154_ADDR_LONG;
378 nla_memcpy(addr.hwaddr, info->attrs[IEEE802154_ATTR_DEST_HW_ADDR],
379 IEEE802154_ADDR_LEN);
380 addr.pan_id = ieee802154_mlme_ops(dev)->get_pan_id(dev);
383 ret = ieee802154_mlme_ops(dev)->assoc_resp(dev, &addr,
384 nla_get_u16(info->attrs[IEEE802154_ATTR_DEST_SHORT_ADDR]),
385 nla_get_u8(info->attrs[IEEE802154_ATTR_STATUS]));
387 dev_put(dev);
388 return ret;
391 static int ieee802154_disassociate_req(struct sk_buff *skb,
392 struct genl_info *info)
394 struct net_device *dev;
395 struct ieee802154_addr addr;
396 int ret = -EINVAL;
398 if ((!info->attrs[IEEE802154_ATTR_DEST_HW_ADDR] &&
399 !info->attrs[IEEE802154_ATTR_DEST_SHORT_ADDR]) ||
400 !info->attrs[IEEE802154_ATTR_REASON])
401 return -EINVAL;
403 dev = ieee802154_nl_get_dev(info);
404 if (!dev)
405 return -ENODEV;
407 if (info->attrs[IEEE802154_ATTR_DEST_HW_ADDR]) {
408 addr.addr_type = IEEE802154_ADDR_LONG;
409 nla_memcpy(addr.hwaddr,
410 info->attrs[IEEE802154_ATTR_DEST_HW_ADDR],
411 IEEE802154_ADDR_LEN);
412 } else {
413 addr.addr_type = IEEE802154_ADDR_SHORT;
414 addr.short_addr = nla_get_u16(
415 info->attrs[IEEE802154_ATTR_DEST_SHORT_ADDR]);
417 addr.pan_id = ieee802154_mlme_ops(dev)->get_pan_id(dev);
419 ret = ieee802154_mlme_ops(dev)->disassoc_req(dev, &addr,
420 nla_get_u8(info->attrs[IEEE802154_ATTR_REASON]));
422 dev_put(dev);
423 return ret;
427 * PANid, channel, beacon_order = 15, superframe_order = 15,
428 * PAN_coordinator, battery_life_extension = 0,
429 * coord_realignment = 0, security_enable = 0
431 static int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info)
433 struct net_device *dev;
434 struct ieee802154_addr addr;
436 u8 channel, bcn_ord, sf_ord;
437 u8 page;
438 int pan_coord, blx, coord_realign;
439 int ret;
441 if (!info->attrs[IEEE802154_ATTR_COORD_PAN_ID] ||
442 !info->attrs[IEEE802154_ATTR_COORD_SHORT_ADDR] ||
443 !info->attrs[IEEE802154_ATTR_CHANNEL] ||
444 !info->attrs[IEEE802154_ATTR_BCN_ORD] ||
445 !info->attrs[IEEE802154_ATTR_SF_ORD] ||
446 !info->attrs[IEEE802154_ATTR_PAN_COORD] ||
447 !info->attrs[IEEE802154_ATTR_BAT_EXT] ||
448 !info->attrs[IEEE802154_ATTR_COORD_REALIGN]
450 return -EINVAL;
452 dev = ieee802154_nl_get_dev(info);
453 if (!dev)
454 return -ENODEV;
456 addr.addr_type = IEEE802154_ADDR_SHORT;
457 addr.short_addr = nla_get_u16(
458 info->attrs[IEEE802154_ATTR_COORD_SHORT_ADDR]);
459 addr.pan_id = nla_get_u16(info->attrs[IEEE802154_ATTR_COORD_PAN_ID]);
461 channel = nla_get_u8(info->attrs[IEEE802154_ATTR_CHANNEL]);
462 bcn_ord = nla_get_u8(info->attrs[IEEE802154_ATTR_BCN_ORD]);
463 sf_ord = nla_get_u8(info->attrs[IEEE802154_ATTR_SF_ORD]);
464 pan_coord = nla_get_u8(info->attrs[IEEE802154_ATTR_PAN_COORD]);
465 blx = nla_get_u8(info->attrs[IEEE802154_ATTR_BAT_EXT]);
466 coord_realign = nla_get_u8(info->attrs[IEEE802154_ATTR_COORD_REALIGN]);
468 if (info->attrs[IEEE802154_ATTR_PAGE])
469 page = nla_get_u8(info->attrs[IEEE802154_ATTR_PAGE]);
470 else
471 page = 0;
474 if (addr.short_addr == IEEE802154_ADDR_BROADCAST) {
475 ieee802154_nl_start_confirm(dev, IEEE802154_NO_SHORT_ADDRESS);
476 dev_put(dev);
477 return -EINVAL;
480 ret = ieee802154_mlme_ops(dev)->start_req(dev, &addr, channel, page,
481 bcn_ord, sf_ord, pan_coord, blx, coord_realign);
483 dev_put(dev);
484 return ret;
487 static int ieee802154_scan_req(struct sk_buff *skb, struct genl_info *info)
489 struct net_device *dev;
490 int ret;
491 u8 type;
492 u32 channels;
493 u8 duration;
494 u8 page;
496 if (!info->attrs[IEEE802154_ATTR_SCAN_TYPE] ||
497 !info->attrs[IEEE802154_ATTR_CHANNELS] ||
498 !info->attrs[IEEE802154_ATTR_DURATION])
499 return -EINVAL;
501 dev = ieee802154_nl_get_dev(info);
502 if (!dev)
503 return -ENODEV;
505 type = nla_get_u8(info->attrs[IEEE802154_ATTR_SCAN_TYPE]);
506 channels = nla_get_u32(info->attrs[IEEE802154_ATTR_CHANNELS]);
507 duration = nla_get_u8(info->attrs[IEEE802154_ATTR_DURATION]);
509 if (info->attrs[IEEE802154_ATTR_PAGE])
510 page = nla_get_u8(info->attrs[IEEE802154_ATTR_PAGE]);
511 else
512 page = 0;
515 ret = ieee802154_mlme_ops(dev)->scan_req(dev, type, channels, page,
516 duration);
518 dev_put(dev);
519 return ret;
522 static int ieee802154_list_iface(struct sk_buff *skb,
523 struct genl_info *info)
525 /* Request for interface name, index, type, IEEE address,
526 PAN Id, short address */
527 struct sk_buff *msg;
528 struct net_device *dev = NULL;
529 int rc = -ENOBUFS;
531 pr_debug("%s\n", __func__);
533 dev = ieee802154_nl_get_dev(info);
534 if (!dev)
535 return -ENODEV;
537 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
538 if (!msg)
539 goto out_dev;
541 rc = ieee802154_nl_fill_iface(msg, info->snd_pid, info->snd_seq,
542 0, dev);
543 if (rc < 0)
544 goto out_free;
546 dev_put(dev);
548 return genlmsg_reply(msg, info);
549 out_free:
550 nlmsg_free(msg);
551 out_dev:
552 dev_put(dev);
553 return rc;
557 static int ieee802154_dump_iface(struct sk_buff *skb,
558 struct netlink_callback *cb)
560 struct net *net = sock_net(skb->sk);
561 struct net_device *dev;
562 int idx;
563 int s_idx = cb->args[0];
565 pr_debug("%s\n", __func__);
567 idx = 0;
568 for_each_netdev(net, dev) {
569 if (idx < s_idx || (dev->type != ARPHRD_IEEE802154))
570 goto cont;
572 if (ieee802154_nl_fill_iface(skb, NETLINK_CB(cb->skb).pid,
573 cb->nlh->nlmsg_seq, NLM_F_MULTI, dev) < 0)
574 break;
575 cont:
576 idx++;
578 cb->args[0] = idx;
580 return skb->len;
583 static struct genl_ops ieee802154_coordinator_ops[] = {
584 IEEE802154_OP(IEEE802154_ASSOCIATE_REQ, ieee802154_associate_req),
585 IEEE802154_OP(IEEE802154_ASSOCIATE_RESP, ieee802154_associate_resp),
586 IEEE802154_OP(IEEE802154_DISASSOCIATE_REQ, ieee802154_disassociate_req),
587 IEEE802154_OP(IEEE802154_SCAN_REQ, ieee802154_scan_req),
588 IEEE802154_OP(IEEE802154_START_REQ, ieee802154_start_req),
589 IEEE802154_DUMP(IEEE802154_LIST_IFACE, ieee802154_list_iface,
590 ieee802154_dump_iface),
594 * No need to unregister as family unregistration will do it.
596 int nl802154_mac_register(void)
598 int i;
599 int rc;
601 rc = genl_register_mc_group(&nl802154_family,
602 &ieee802154_coord_mcgrp);
603 if (rc)
604 return rc;
606 rc = genl_register_mc_group(&nl802154_family,
607 &ieee802154_beacon_mcgrp);
608 if (rc)
609 return rc;
611 for (i = 0; i < ARRAY_SIZE(ieee802154_coordinator_ops); i++) {
612 rc = genl_register_ops(&nl802154_family,
613 &ieee802154_coordinator_ops[i]);
614 if (rc)
615 return rc;
618 return 0;