Adding the first implementation of the OBAMP plugin. See README file for documentation.
3 Written by Saverio Proto <zioproto@gmail.com> and Claudio Pisa <clauz@ninux.org>.
5 This file is part of OLSR OBAMP PLUGIN.
7 The OLSR OBAMP PLUGIN is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 The OLSR OBAMP PLUGIN is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with the OLSR OBAMP PLUGIN. If not, see <http://www.gnu.org/licenses/>.
22 //This stuff was from the Kernel, with minor modifications was added here
28 * XXX: Resolve conflict between this file and <sys/queue.h> on BSD systems.
35 * Simple doubly linked list implementation.
37 * Some of the internal functions ("__xxx") are useful when
38 * manipulating whole lists rather than single entries, as
39 * sometimes we already know the next/prev entries and we can
40 * generate better code by using them directly rather than
41 * using the generic single-entry routines.
45 struct list_head *next, *prev;
48 #define LIST_HEAD_INIT(name) { &(name), &(name) }
50 #define LIST_HEAD(name) \
51 struct list_head name = LIST_HEAD_INIT(name)
53 #define INIT_LIST_HEAD(ptr) do { \
54 (ptr)->next = (ptr); (ptr)->prev = (ptr); \
58 * Insert a new entry between two known consecutive entries.
60 * This is only for internal list manipulation where we know
61 * the prev/next entries already!
63 static inline void __list_add(struct list_head *new,
64 struct list_head *prev,
65 struct list_head *next)
74 * list_add - add a new entry
75 * @new: new entry to be added
76 * @head: list head to add it after
78 * Insert a new entry after the specified head.
79 * This is good for implementing stacks.
81 static inline void list_add(struct list_head *new, struct list_head *head)
83 __list_add(new, head, head->next);
87 * list_add_tail - add a new entry
88 * @new: new entry to be added
89 * @head: list head to add it before
91 * Insert a new entry before the specified head.
92 * This is useful for implementing queues.
94 static inline void list_add_tail(struct list_head *new, struct list_head *head)
96 __list_add(new, head->prev, head);
100 * Delete a list entry by making the prev/next entries
101 * point to each other.
103 * This is only for internal list manipulation where we know
104 * the prev/next entries already!
106 static inline void __list_del(struct list_head *prev, struct list_head *next)
113 * list_del - deletes entry from list.
114 * @entry: the element to delete from the list.
115 * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
117 static inline void list_del(struct list_head *entry)
119 __list_del(entry->prev, entry->next);
120 //entry->next = (void *) 0;
121 //entry->prev = (void *) 0;
125 * list_del_init - deletes entry from list and reinitialize it.
126 * @entry: the element to delete from the list.
128 static inline void list_del_init(struct list_head *entry)
130 __list_del(entry->prev, entry->next);
131 INIT_LIST_HEAD(entry);
135 * list_move - delete from one list and add as another's head
136 * @list: the entry to move
137 * @head: the head that will precede our entry
139 static inline void list_move(struct list_head *list, struct list_head *head)
141 __list_del(list->prev, list->next);
142 list_add(list, head);
146 * list_move_tail - delete from one list and add as another's tail
147 * @list: the entry to move
148 * @head: the head that will follow our entry
150 static inline void list_move_tail(struct list_head *list,
151 struct list_head *head)
153 __list_del(list->prev, list->next);
154 list_add_tail(list, head);
158 * list_empty - tests whether a list is empty
159 * @head: the list to test.
161 static inline int list_empty(struct list_head *head)
163 return head->next == head;
166 static inline void __list_splice(struct list_head *list,
167 struct list_head *head)
169 struct list_head *first = list->next;
170 struct list_head *last = list->prev;
171 struct list_head *at = head->next;
181 * list_splice - join two lists
182 * @list: the new list to add.
183 * @head: the place to add it in the first list.
185 static inline void list_splice(struct list_head *list, struct list_head *head)
187 if (!list_empty(list))
188 __list_splice(list, head);
192 * list_splice_init - join two lists and reinitialise the emptied list.
193 * @list: the new list to add.
194 * @head: the place to add it in the first list.
196 * The list at @list is reinitialised
198 static inline void list_splice_init(struct list_head *list,
199 struct list_head *head)
201 if (!list_empty(list)) {
202 __list_splice(list, head);
203 INIT_LIST_HEAD(list);
208 * list_entry - get the struct for this entry
209 * @ptr: the &struct list_head pointer.
210 * @type: the type of the struct this is embedded in.
211 * @member: the name of the list_struct within the struct.
213 #define list_entry(ptr, type, member) \
214 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
217 * list_for_each - iterate over a list
218 * @pos: the &struct list_head to use as a loop counter.
219 * @head: the head for your list.
221 #define list_for_each(pos, head) \
222 for (pos = (head)->next; pos != (head); \
225 * list_for_each_prev - iterate over a list backwards
226 * @pos: the &struct list_head to use as a loop counter.
227 * @head: the head for your list.
229 #define list_for_each_prev(pos, head) \
230 for (pos = (head)->prev; pos != (head); \
234 * list_for_each_safe - iterate over a list safe against removal of list entry
235 * @pos: the &struct list_head to use as a loop counter.
236 * @n: another &struct list_head to use as temporary storage
237 * @head: the head for your list.
239 #define list_for_each_safe(pos, n, head) \
240 for (pos = (head)->next, n = pos->next; pos != (head); \
241 pos = n, n = pos->next)
244 * list_for_each_entry - iterate over list of given type
245 * @pos: the type * to use as a loop counter.
246 * @head: the head for your list.
247 * @member: the name of the list_struct within the struct.
249 #define list_for_each_entry(pos, head, member) \
250 for (pos = list_entry((head)->next, typeof(*pos), member); \
251 &pos->member != (head); \
252 pos = list_entry(pos->member.next, typeof(*pos), member))
255 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
256 * @pos: the type * to use as a loop counter.
257 * @n: another type * to use as temporary storage
258 * @head: the head for your list.
259 * @member: the name of the list_struct within the struct.
261 #define list_for_each_entry_safe(pos, n, head, member) \
262 for (pos = list_entry((head)->next, typeof(*pos), member), \
263 n = list_entry(pos->member.next, typeof(*pos), member); \
264 &pos->member != (head); \
265 pos = n, n = list_entry(n->member.next, typeof(*n), member))
268 * list_for_each_entry_continue - iterate over list of given type
269 * continuing after existing point
270 * @pos: the type * to use as a loop counter.
271 * @head: the head for your list.
272 * @member: the name of the list_struct within the struct.
274 #define list_for_each_entry_continue(pos, head, member) \
275 for (pos = list_entry(pos->member.next, typeof(*pos), member); \
276 &pos->member != (head); \
277 pos = list_entry(pos->member.next, typeof(*pos), member))