procd.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
  3. * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License version 2.1
  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. #ifndef __PROCD_H
  15. #define __PROCD_H
  16. #include <libubox/uloop.h>
  17. #include <libubox/utils.h>
  18. #include <libubus.h>
  19. #include <stdio.h>
  20. #include <syslog.h>
  21. #include "syslog.h"
  22. #define __init __attribute__((constructor))
  23. #define DEBUG(level, fmt, ...) do { \
  24. if (debug >= level) \
  25. fprintf(stderr, "procd: %s(%d): " fmt, __func__, __LINE__, ## __VA_ARGS__); \
  26. } while (0)
  27. #define LOG(fmt, ...) do { \
  28. log_printf(fmt, ## __VA_ARGS__); \
  29. fprintf(stderr, "procd: "fmt, ## __VA_ARGS__); \
  30. } while (0)
  31. #define ERROR(fmt, ...) do { \
  32. log_printf(fmt, ## __VA_ARGS__); \
  33. fprintf(stderr, "procd: "fmt, ## __VA_ARGS__); \
  34. } while (0)
  35. extern char *ubus_socket;
  36. extern unsigned int debug;
  37. void debug_init(void);
  38. void procd_connect_ubus(void);
  39. void procd_reconnect_ubus(int reconnect);
  40. void ubus_init_service(struct ubus_context *ctx);
  41. void ubus_init_log(struct ubus_context *ctx);
  42. void ubus_init_system(struct ubus_context *ctx);
  43. void ubus_notify_log(struct log_head *l);
  44. void procd_state_next(void);
  45. void procd_shutdown(int event);
  46. void procd_early(void);
  47. void procd_preinit(void);
  48. void procd_coldplug(void);
  49. void procd_signal(void);
  50. void procd_signal_preinit(void);
  51. void procd_inittab(void);
  52. void procd_inittab_run(const char *action);
  53. int mkdev(const char *progname, int progmode);
  54. struct trigger;
  55. void trigger_init(void);
  56. void trigger_event(char *type, struct blob_attr *data);
  57. void trigger_add(struct blob_attr *rule, void *id);
  58. void trigger_del(void *id);
  59. struct pid_info {
  60. char stat;
  61. uint32_t ppid;
  62. uint32_t fdcount;
  63. uint32_t vmsize;
  64. uint16_t uid;
  65. };
  66. int measure_process(pid_t pid, struct pid_info *pi);
  67. #endif