• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/netifd/netifd.h

  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 #ifndef __NETIFD_H
 15 #define __NETIFD_H
 16 
 17 #include <sys/socket.h>
 18 #include <net/if.h>
 19 
 20 #include <stdbool.h>
 21 #include <stdio.h>
 22 
 23 #include <libubox/uloop.h>
 24 #include <libubox/ustream.h>
 25 #include <libubox/utils.h>
 26 
 27 #include <libubus.h>
 28 
 29 #ifdef linux
 30 #include <netinet/ether.h>
 31 #else
 32 #include <net/ethernet.h>
 33 #endif
 34 
 35 #include "utils.h"
 36 
 37 #ifdef DUMMY_MODE
 38 #define DEFAULT_MAIN_PATH       "./examples"
 39 #define DEFAULT_CONFIG_PATH     "./config"
 40 #define DEFAULT_HOTPLUG_PATH    "./examples/hotplug-cmd"
 41 #define DEFAULT_RESOLV_CONF     "./tmp/resolv.conf"
 42 #define DEFAULT_BOARD_JSON      "./config/board.json"
 43 #else
 44 #define DEFAULT_MAIN_PATH       "/lib/netifd"
 45 #define DEFAULT_CONFIG_PATH     NULL /* use the default set in libuci */
 46 #define DEFAULT_HOTPLUG_PATH    "/sbin/hotplug-call"
 47 #define DEFAULT_RESOLV_CONF     "/tmp/resolv.conf.d/resolv.conf.auto"
 48 #define DEFAULT_BOARD_JSON      "/etc/board.json"
 49 #endif
 50 
 51 extern const char *resolv_conf;
 52 extern char *hotplug_cmd_path;
 53 extern unsigned int debug_mask;
 54 
 55 enum {
 56         L_CRIT,
 57         L_WARNING,
 58         L_NOTICE,
 59         L_INFO,
 60         L_DEBUG
 61 };
 62 
 63 enum {
 64         DEBUG_SYSTEM    = 0,
 65         DEBUG_DEVICE    = 1,
 66         DEBUG_INTERFACE = 2,
 67         DEBUG_WIRELESS  = 3,
 68 };
 69 
 70 #ifdef DEBUG
 71 #define DPRINTF(format, ...) fprintf(stderr, "%s(%d): " format, __func__, __LINE__, ## __VA_ARGS__)
 72 #define D(level, format, ...) do { \
 73                 if (debug_mask & (1 << (DEBUG_ ## level))) \
 74                                 DPRINTF(format, ##__VA_ARGS__); \
 75         } while (0)
 76 #else
 77 #define DPRINTF(format, ...) no_debug(0, format, ## __VA_ARGS__)
 78 #define D(level, format, ...) no_debug(DEBUG_ ## level, format, ## __VA_ARGS__)
 79 #endif
 80 
 81 #define LOG_BUF_SIZE    256
 82 
 83 static inline void no_debug(int level, const char *fmt, ...)
 84 {
 85 }
 86 
 87 struct netifd_process {
 88         struct list_head list;
 89         struct uloop_process uloop;
 90         void (*cb)(struct netifd_process *, int ret);
 91         int dir_fd;
 92 
 93         struct ustream_fd log;
 94         const char *log_prefix;
 95         bool log_overflow;
 96 };
 97 
 98 void netifd_log_message(int priority, const char *format, ...);
 99 
100 int netifd_start_process(const char **argv, char **env, struct netifd_process *proc);
101 void netifd_kill_process(struct netifd_process *proc);
102 
103 struct device;
104 struct interface;
105 
106 extern const char *main_path;
107 extern const char *config_path;
108 void netifd_restart(void);
109 int netifd_reload(void);
110 
111 #endif
112 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt