2 * Author: Steven Barth <steven at midlink.org>
4 * Copyright 2015 Deutsche Telekom AG
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 #define OMGPROXY_DEFAULT_L_LEVEL 7
26 #define L_LEVEL OMGPROXY_DEFAULT_L_LEVEL
31 #endif /* !L_PREFIX */
35 #define __APPLE_USE_RFC_3542
36 #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
37 #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
39 #include <sys/queue.h>
42 #endif /* LIST_HEAD */
44 #endif /* __APPLE__ */
50 #include <sys/types.h>
51 #include <libubox/utils.h>
53 #define STR_EXPAND(tok) #tok
54 #define STR(tok) STR_EXPAND(tok)
56 typedef int64_t omgp_time_t
;
57 #define OMGP_TIME_MAX INT64_MAX
58 #define OMGP_TIME_PER_SECOND INT64_C(1000)
60 static inline omgp_time_t
omgp_time(void) {
62 clock_gettime(CLOCK_MONOTONIC
, &ts
);
63 return ((omgp_time_t
)ts
.tv_sec
* OMGP_TIME_PER_SECOND
) +
64 ((omgp_time_t
)ts
.tv_nsec
/ (1000000000 / OMGP_TIME_PER_SECOND
));
71 #define L_INTERNAL(level, ...) \
73 if (log_level >= level) \
74 syslog(level, L_PREFIX __VA_ARGS__); \
77 #if L_LEVEL >= LOG_ERR
78 #define L_ERR(...) L_INTERNAL(LOG_ERR, __VA_ARGS__)
80 #define L_ERR(...) do {} while(0)
83 #if L_LEVEL >= LOG_WARNING
84 #define L_WARN(...) L_INTERNAL(LOG_WARNING, __VA_ARGS__)
86 #define L_WARN(...) do {} while(0)
89 #if L_LEVEL >= LOG_NOTICE
90 #define L_NOTICE(...) L_INTERNAL(LOG_NOTICE, __VA_ARGS__)
92 #define L_NOTICE(...) do {} while(0)
95 #if L_LEVEL >= LOG_INFO
96 #define L_INFO(...) L_INTERNAL(LOG_INFO, __VA_ARGS__)
98 #define L_INFO(...) do {} while(0)
101 #if L_LEVEL >= LOG_DEBUG
102 #define L_DEBUG(...) L_INTERNAL(LOG_DEBUG, __VA_ARGS__)
104 #define L_DEBUG(...) do {} while(0)
108 // Some C99 compatibility
110 #define typeof __typeof
114 #define container_of(ptr, type, member) ( \
115 (type *)( (char *)ptr - offsetof(type,member) ))
119 #define __unused __attribute__((unused))
122 #endif /* PIMBD_H_ */