make: fix build error in curvetun due to empty env var
[netsniff-ng.git] / src / llist.h
blob49a87c7d8810f09e9354d8eaa20169072b5c7e1f
1 /*
2 * Mausezahn - A fast versatile traffic generator
3 * Copyright (C) 2010 Herbert Haas
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 * details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, see http://www.gnu.org/licenses/gpl-2.0.html
21 #ifndef MZ_LINKED_LIST
22 #define MZ_LINKED_LIST
24 #define MAX_PACKET_SEQUENCE_LEN 20 // how many packets can be defined in a sequence at maximum
26 // A packet sequence -- this is the list data (each list element corresponds to one sequence)
27 struct pseq {
28 struct mops *packet[MAX_PACKET_SEQUENCE_LEN]; // pointer to the packets
29 struct timespec gap[MAX_PACKET_SEQUENCE_LEN]; // optional delay between different packets
30 int count; // total number of current members (=packets)
34 // --------------- Mausezahn Multipurpose Linked List: -------------------
36 #define MZ_LL_NAME_LEN 64
38 // one list element
39 struct mz_ll {
40 struct mz_ll *prev;
41 struct mz_ll *next;
42 struct mz_ll *head; // always points to head element
43 int refcount; // head element: total number of list items! (Otherwise can be used as refcount.)
44 char name[MZ_LL_NAME_LEN];
45 pthread_t sequence_thread;
46 int state; // 0 = inactive, 1 = active
47 int index; // monotonically increasing;
48 int index_last; //head always stores the last value!
49 void *data; // points to your data
52 struct mz_ll *packet_sequences;
53 struct mz_ll *cli_seq; // currently edited packet sequence used by CLI
55 // prototypes
56 struct mz_ll * mz_ll_create_new_element(struct mz_ll *list);
57 int mz_ll_delete_element (struct mz_ll *cur);
58 int mz_ll_delete_list(struct mz_ll *list);
59 struct mz_ll * mz_ll_search_name (struct mz_ll *list, char *str);
60 void _mz_ll_set_default (struct mz_ll *cur);
61 int mz_ll_dump_all(struct mz_ll *list);
62 int mops_tx_sequence (struct mz_ll *seq);
64 // convenience functions using the above in a more intelligent way
65 int mops_delete_sequence(char *name);
66 struct mz_ll * mops_create_sequence (char *name);
67 int mops_dump_sequence (char* str);
68 int mops_add_packet_to_sequence (struct mz_ll *seq, struct mops *mp);
69 int mops_add_delay_to_sequence (struct mz_ll *seq, struct timespec *t);
70 int mops_delete_packet_from_pseq (struct mz_ll *seq, int index);
71 int mops_delete_all_packets_from_pseq (struct mz_ll *seq);
72 int stop_sequence (char *name);
73 int stop_all_sequences ();
74 #endif