#ifndef OPENUF_CONFIG_H #define OPENUF_CONFIG_H /* ─── Build-time defaults (override with /etc/openuf/openuf.conf) ─── */ #define OPENUF_VERSION "0.4.0-r1" #define OPENUF_STATE_FILE "/etc/openuf/state.json" #define OPENUF_CONF_FILE "/etc/openuf/openuf.conf" #ifndef ENABLE_LOGGING #define ENABLE_LOGGING 1 #endif #define DEFAULT_CONTROLLER_IP "" #define DEFAULT_LAN_IF "br-lan" #define DEFAULT_UFMODEL "uapg2-ac-lr" #define DEFAULT_INFORM_INTERVAL 10 #define ANNOUNCE_INTERVAL 10 #define ANNOUNCE_PORT 10001 #define INFORM_PORT 8080 #define INFORM_PATH "/inform" #define DEFAULT_AUTH_KEY "ba86f2bbe107c7c57eb5f2690775c712" #if ENABLE_LOGGING #include #include #include extern FILE *log_fp; static inline void openuf_log_emit(FILE *stream, const char *prefix, const char *fmt, ...) { char ts[32]; time_t now = time(NULL); struct tm tm; localtime_r(&now, &tm); strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S", &tm); fprintf(stream, "[%s]", ts); if (prefix && prefix[0]) fprintf(stream, " [%s]", prefix); fputc(' ', stream); va_list ap; va_start(ap, fmt); vfprintf(stream, fmt, ap); va_end(ap); fputc('\n', stream); fflush(stream); } #define LOG(fmt, ...) do { if (log_fp) openuf_log_emit(log_fp, __func__, fmt, ##__VA_ARGS__); } while(0) #define LOGF(stream, fmt, ...) openuf_log_emit(stream, "openuf", fmt, ##__VA_ARGS__) #else #define LOG(fmt, ...) do {} while(0) #define LOGF(stream, fmt, ...) do { (void)(stream); } while(0) #endif typedef struct { char controller_ip[64]; char lan_if[32]; char ufmodel[32]; /* "u6-inwall" | "u6-lite" */ int inform_interval; int enable_announce; int enable_inform; int enable_logging; int protocol_debug_level; } openuf_config_t; /* Parse /etc/openuf/openuf.conf (simple key=value). * Fills *cfg with defaults first, then overrides from file. * An empty controller_ip selects default-gateway autodetection. */ void config_load(openuf_config_t *cfg); #endif /* OPENUF_CONFIG_H */