summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/nl80211.h10
-rw-r--r--include/ucode/lexer.h9
-rw-r--r--include/ucode/types.h40
-rw-r--r--include/ucode/util.h226
4 files changed, 213 insertions, 72 deletions
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index f97f5ad..6d11437 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -2868,6 +2868,9 @@ enum nl80211_commands {
* nested item, it contains attributes defined in
* &enum nl80211_if_combination_attrs.
*
+ * @NL80211_ATTR_VIF_RADIO_MASK: Bitmask of allowed radios (u32).
+ * A value of 0 means all radios.
+ *
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3416,6 +3419,8 @@ enum nl80211_attrs {
NL80211_ATTR_WIPHY_RADIOS,
NL80211_ATTR_WIPHY_INTERFACE_COMBINATIONS,
+ NL80211_ATTR_VIF_RADIO_MASK,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
@@ -4698,6 +4703,7 @@ enum nl80211_survey_info {
* overrides all other flags.
* @NL80211_MNTR_FLAG_ACTIVE: use the configured MAC address
* and ACK incoming unicast packets.
+ * @NL80211_MNTR_FLAG_SKIP_TX: do not pass local tx packets
*
* @__NL80211_MNTR_FLAG_AFTER_LAST: internal use
* @NL80211_MNTR_FLAG_MAX: highest possible monitor flag
@@ -4710,6 +4716,7 @@ enum nl80211_mntr_flags {
NL80211_MNTR_FLAG_OTHER_BSS,
NL80211_MNTR_FLAG_COOK_FRAMES,
NL80211_MNTR_FLAG_ACTIVE,
+ NL80211_MNTR_FLAG_SKIP_TX,
/* keep last */
__NL80211_MNTR_FLAG_AFTER_LAST,
@@ -8031,6 +8038,8 @@ enum nl80211_ap_settings_flags {
* @NL80211_WIPHY_RADIO_ATTR_INTERFACE_COMBINATION: Supported interface
* combination for this radio. Attribute may be present multiple times
* and contains attributes defined in &enum nl80211_if_combination_attrs.
+ * @NL80211_WIPHY_RADIO_ATTR_ANTENNA_MASK: bitmask (u32) of antennas
+ * connected to this radio.
*
* @__NL80211_WIPHY_RADIO_ATTR_LAST: Internal
* @NL80211_WIPHY_RADIO_ATTR_MAX: Highest attribute
@@ -8041,6 +8050,7 @@ enum nl80211_wiphy_radio_attrs {
NL80211_WIPHY_RADIO_ATTR_INDEX,
NL80211_WIPHY_RADIO_ATTR_FREQ_RANGE,
NL80211_WIPHY_RADIO_ATTR_INTERFACE_COMBINATION,
+ NL80211_WIPHY_RADIO_ATTR_ANTENNA_MASK,
/* keep last */
__NL80211_WIPHY_RADIO_ATTR_LAST,
diff --git a/include/ucode/lexer.h b/include/ucode/lexer.h
index 1728aa3..fd375b8 100644
--- a/include/ucode/lexer.h
+++ b/include/ucode/lexer.h
@@ -121,12 +121,14 @@ typedef enum {
TK_EXPORT,
TK_EOF,
+ TK_COMMENT,
TK_ERROR
} uc_tokentype_t;
typedef enum {
UC_LEX_IDENTIFY_BLOCK,
UC_LEX_BLOCK_EXPRESSION_EMIT_TAG,
+ UC_LEX_BLOCK_STATEMENT_EMIT_TAG,
UC_LEX_BLOCK_COMMENT,
UC_LEX_IDENTIFY_TOKEN,
UC_LEX_PLACEHOLDER_START,
@@ -138,6 +140,7 @@ typedef struct {
uc_tokentype_t type;
uc_value_t *uv;
size_t pos;
+ size_t end;
} uc_token_t;
typedef struct {
@@ -174,10 +177,10 @@ typedef struct {
} uc_lexer_t;
-__hidden void uc_lexer_init(uc_lexer_t *lex, uc_parse_config_t *config, uc_source_t *source);
-__hidden void uc_lexer_free(uc_lexer_t *lex);
+void uc_lexer_init(uc_lexer_t *lex, uc_parse_config_t *config, uc_source_t *source);
+void uc_lexer_free(uc_lexer_t *lex);
-__hidden uc_token_t *uc_lexer_next_token(uc_lexer_t *lex);
+uc_token_t *uc_lexer_next_token(uc_lexer_t *lex);
__hidden bool uc_lexer_is_keyword(uc_value_t *label);
diff --git a/include/ucode/types.h b/include/ucode/types.h
index c0ccd38..f149b98 100644
--- a/include/ucode/types.h
+++ b/include/ucode/types.h
@@ -206,14 +206,16 @@ typedef struct {
uc_declare_vector(uc_resource_types_t, uc_resource_type_t *);
-
-/* Object iteration */
-
-extern uc_list_t uc_object_iterators;
-
typedef struct {
uc_list_t list;
- struct lh_entry *pos;
+ struct lh_table *table;
+ union {
+ struct lh_entry *pos;
+ struct {
+ const void *k;
+ unsigned long hash;
+ } kh;
+ } u;
} uc_object_iterator_t;
@@ -263,6 +265,19 @@ uc_search_path_free(uc_search_path_t *search_path) {
}
+/* TLS data */
+
+typedef struct {
+ /* VM owning installed signal handlers */
+ uc_vm_t *signal_handler_vm;
+
+ /* Object iteration */
+ uc_list_t object_iterators;
+} uc_thread_context_t;
+
+__hidden uc_thread_context_t *uc_thread_context_get(void);
+
+
/* VM definitions */
typedef enum {
@@ -381,6 +396,7 @@ uc_value_t *ucv_array_push(uc_value_t *, uc_value_t *);
uc_value_t *ucv_array_shift(uc_value_t *);
uc_value_t *ucv_array_unshift(uc_value_t *, uc_value_t *);
void ucv_array_sort(uc_value_t *, int (*)(const void *, const void *));
+void ucv_array_sort_r(uc_value_t *, int (*)(uc_value_t *, uc_value_t *, void *), void *);
bool ucv_array_delete(uc_value_t *, size_t, size_t);
bool ucv_array_set(uc_value_t *, size_t, uc_value_t *);
size_t ucv_array_length(uc_value_t *);
@@ -389,6 +405,7 @@ uc_value_t *ucv_object_new(uc_vm_t *);
uc_value_t *ucv_object_get(uc_value_t *, const char *, bool *);
bool ucv_object_add(uc_value_t *, const char *, uc_value_t *);
void ucv_object_sort(uc_value_t *, int (*)(const void *, const void *));
+void ucv_object_sort_r(uc_value_t *, int (*)(const char *, uc_value_t *, const char *, uc_value_t *, void *), void *);
bool ucv_object_delete(uc_value_t *, const char *);
size_t ucv_object_length(uc_value_t *);
@@ -415,6 +432,17 @@ uc_value_t *ucv_resource_new(uc_resource_type_t *, void *);
void *ucv_resource_data(uc_value_t *uv, const char *);
void **ucv_resource_dataptr(uc_value_t *, const char *);
+static inline uc_value_t *
+ucv_resource_create(uc_vm_t *vm, const char *type, void *value)
+{
+ uc_resource_type_t *t = NULL;
+
+ if (type && (t = ucv_resource_type_lookup(vm, type)) == NULL)
+ return NULL;
+
+ return ucv_resource_new(t, value);
+}
+
uc_value_t *ucv_regexp_new(const char *, bool, bool, bool, char **);
uc_value_t *ucv_upvalref_new(size_t);
diff --git a/include/ucode/util.h b/include/ucode/util.h
index a3692d5..1360d28 100644
--- a/include/ucode/util.h
+++ b/include/ucode/util.h
@@ -30,6 +30,14 @@
#define __hidden __attribute__((visibility("hidden")))
#endif
+#ifndef localfunc
+# if defined(__GNUC__) || defined(__clang__)
+# define localfunc static __attribute__((noinline,unused))
+# else
+# define localfunc static inline
+# endif
+#endif
+
/* alignment & array size */
@@ -42,69 +50,6 @@
#endif
-/* vector macros */
-
-#define UC_VECTOR_CHUNK_SIZE 8
-
-#define uc_declare_vector(name, type) \
- typedef struct { \
- size_t count; \
- type *entries; \
- } name
-
-#define uc_vector_grow(vec) \
- do { \
- if (((vec)->count % UC_VECTOR_CHUNK_SIZE) == 0) { \
- (vec)->entries = xrealloc((vec)->entries, sizeof((vec)->entries[0]) * ((vec)->count + UC_VECTOR_CHUNK_SIZE)); \
- memset(&(vec)->entries[(vec)->count], 0, sizeof((vec)->entries[0]) * UC_VECTOR_CHUNK_SIZE); \
- } \
- } while(0)
-
-#define uc_vector_clear(vec) \
- do { \
- free((vec)->entries); \
- (vec)->entries = NULL; \
- (vec)->count = 0; \
- } while(0)
-
-#define uc_vector_first(vec) \
- (&((vec)->entries[0]))
-
-#define uc_vector_last(vec) \
- (&((vec)->entries[(vec)->count - 1]))
-
-#define uc_vector_push(vec, val) do { \
- uc_vector_grow(vec); \
- (vec)->entries[(vec)->count++] = (val); \
-} while(0)
-
-
-/* linked lists */
-
-typedef struct uc_list {
- struct uc_list *prev;
- struct uc_list *next;
-} uc_list_t;
-
-static inline void uc_list_insert(uc_list_t *list, uc_list_t *item)
-{
- list->next->prev = item;
- item->next = list->next;
- item->prev = list;
- list->next = item;
-}
-
-static inline void uc_list_remove(uc_list_t *item)
-{
- item->next->prev = item->prev;
- item->prev->next = item->next;
- item->prev = item->next = item;
-}
-
-#define uc_list_foreach(item, list) \
- for (uc_list_t *item = (list)->next; item != (list); item = item->next)
-
-
/* "failsafe" utility functions */
static inline void *xcalloc(size_t size, size_t nmemb) {
@@ -195,4 +140,159 @@ static inline struct printbuf *xprintbuf_new(void) {
return pb;
}
+
+/* linked lists */
+
+typedef struct uc_list {
+ struct uc_list *prev;
+ struct uc_list *next;
+} uc_list_t;
+
+static inline void uc_list_insert(uc_list_t *list, uc_list_t *item)
+{
+ list->next->prev = item;
+ item->next = list->next;
+ item->prev = list;
+ list->next = item;
+}
+
+static inline void uc_list_remove(uc_list_t *item)
+{
+ item->next->prev = item->prev;
+ item->prev->next = item->next;
+ item->prev = item->next = item;
+}
+
+#define uc_list_foreach(item, list) \
+ for (uc_list_t *item = (list)->next; item != (list); item = item->next)
+
+
+/* vector macros */
+
+#define UC_VECTOR_INIT_SIZE 8
+
+#define uc_declare_vector(name, type) \
+ typedef struct { \
+ size_t count; \
+ type *entries; \
+ } name
+
+localfunc size_t
+uc_vector_capacity(size_t init, size_t count)
+{
+ if (count == 0)
+ return init;
+
+ size_t capacity = init;
+
+ while (capacity <= count)
+ capacity += (capacity >> 1);
+
+ return capacity;
+}
+
+localfunc void
+uc_vector_reduce_(char **base, size_t itemsize, size_t count, size_t remove)
+{
+ if (*base == NULL)
+ return;
+
+ if (remove > count)
+ remove = count;
+
+ size_t next_capacity = uc_vector_capacity(UC_VECTOR_INIT_SIZE, count - remove);
+
+ if (uc_vector_capacity(next_capacity, count) != next_capacity)
+ *base = (__typeof__(*base))xrealloc(*base, itemsize * next_capacity);
+}
+
+localfunc void *
+uc_vector_extend_(char **base, size_t itemsize, size_t count, size_t add)
+{
+ size_t curr_capacity = uc_vector_capacity(UC_VECTOR_INIT_SIZE, count);
+
+ if (*base == NULL || count + add >= curr_capacity) {
+ size_t next_capacity = uc_vector_capacity(curr_capacity, count + add);
+
+ *base = (__typeof__(*base))xrealloc(*base, itemsize * next_capacity);
+
+ memset(*base + itemsize * count, 0,
+ itemsize * (next_capacity - count));
+ }
+
+ return *base + itemsize * count;
+}
+
+#define uc_vector_reduce(vec, remove) \
+ uc_vector_reduce_((char **)&(vec)->entries, sizeof((vec)->entries[0]), (vec)->count, (remove))
+
+#define uc_vector_extend(vec, add) \
+ (__typeof__((vec)->entries + 0)) uc_vector_extend_( \
+ (char **)&(vec)->entries, \
+ sizeof((vec)->entries[0]), \
+ (vec)->count, (add))
+
+#define uc_vector_grow(vec) \
+ uc_vector_extend_((char **)&(vec)->entries, sizeof((vec)->entries[0]), (vec)->count, 1)
+
+#define uc_vector_clear(vec) \
+ do { \
+ free((vec)->entries); \
+ (vec)->entries = NULL; \
+ (vec)->count = 0; \
+ } while(0)
+
+#define uc_vector_first(vec) \
+ (&((vec)->entries[0]))
+
+#define uc_vector_last(vec) \
+ ((vec)->count ? &((vec)->entries[(vec)->count - 1]) : NULL)
+
+#define uc_vector_push(vec, ...) ({ \
+ *uc_vector_extend((vec), 1) = ((__typeof__((vec)->entries[0]))__VA_ARGS__); \
+ &(vec)->entries[(vec)->count++]; \
+})
+
+#define uc_vector_pop(vec) \
+ ((vec)->count ? &(vec)->entries[--(vec)->count] : NULL)
+
+#define uc_vector_foreach(vec, iter) \
+ for (__typeof__((vec)->entries + 0) iter = (vec)->entries; \
+ iter < (vec)->entries + (vec)->count; \
+ iter++)
+
+#define uc_vector_foreach_reverse(vec, iter) \
+ for (__typeof__((vec)->entries + 0) iter = (vec)->count \
+ ? (vec)->entries + (vec)->count - 1 : NULL; \
+ iter != NULL && iter >= (vec)->entries; \
+ iter--)
+
+#ifdef __APPLE__
+
+# define uc_vector_sort_cb(fn_, optype_, udtype_, ...) \
+ int fn_(void *ud, const void *k1, const void *k2) { \
+ optype_ v1 = *(optype_ *)k1; \
+ optype_ v2 = *(optype_ *)k2; \
+ udtype_ ctx = (udtype_)ud; \
+ __VA_ARGS__ \
+ }
+
+# define uc_vector_sort(v_, cmp_, ud_) \
+ qsort_r((v_)->entries, (v_)->count, sizeof((v_)->entries[0]), ud_, cmp_)
+
+#else
+
+# define uc_vector_sort_cb(fn_, optype_, udtype_, ...) \
+ int fn_(const void *k1, const void *k2, void *ud) { \
+ optype_ v1 = *(optype_ *)k1; \
+ optype_ v2 = *(optype_ *)k2; \
+ udtype_ ctx = (udtype_)ud; \
+ __VA_ARGS__ \
+ }
+
+# define uc_vector_sort(v_, cmp_, ud_) \
+ qsort_r((v_)->entries, (v_)->count, sizeof((v_)->entries[0]), cmp_, ud_)
+
+#endif
+
#endif /* UCODE_UTIL_H */