system.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * netifd - network interface daemon
  3. * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2
  7. * as published by the Free Software Foundation
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #include "netifd.h"
  15. #include "system.h"
  16. #include <fcntl.h>
  17. static const struct blobmsg_policy tunnel_attrs[__TUNNEL_ATTR_MAX] = {
  18. [TUNNEL_ATTR_TYPE] = { "mode", BLOBMSG_TYPE_STRING },
  19. [TUNNEL_ATTR_LOCAL] = { "local", BLOBMSG_TYPE_STRING },
  20. [TUNNEL_ATTR_REMOTE] = { "remote", BLOBMSG_TYPE_STRING },
  21. [TUNNEL_ATTR_TTL] = { "ttl", BLOBMSG_TYPE_INT32 },
  22. [TUNNEL_ATTR_6RD_PREFIX] = { "6rd-prefix", BLOBMSG_TYPE_STRING },
  23. [TUNNEL_ATTR_6RD_RELAY_PREFIX] = { "6rd-relay-prefix", BLOBMSG_TYPE_STRING },
  24. [TUNNEL_ATTR_LINK] = { "link", BLOBMSG_TYPE_STRING },
  25. };
  26. const struct uci_blob_param_list tunnel_attr_list = {
  27. .n_params = __TUNNEL_ATTR_MAX,
  28. .params = tunnel_attrs,
  29. };
  30. void system_fd_set_cloexec(int fd)
  31. {
  32. #ifdef FD_CLOEXEC
  33. fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
  34. #endif
  35. }