5083fea9bd6393de3436bc69b77f90735f47280b
[samplevnf.git] / VNFs / DPPD-PROX / handle_gen.h
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #ifndef _HANDLE_GEN_H_
18 #define _HANDLE_GEN_H_
19
20 struct unique_id {
21         uint8_t  generator_id;
22         uint32_t packet_id;
23 } __attribute__((packed));
24
25 static void unique_id_init(struct unique_id *unique_id, uint8_t generator_id, uint32_t packet_id)
26 {
27         unique_id->generator_id = generator_id;
28         unique_id->packet_id = packet_id;
29 }
30
31 static void unique_id_get(struct unique_id *unique_id, uint8_t *generator_id, uint32_t *packet_id)
32 {
33         *generator_id = unique_id->generator_id;
34         *packet_id = unique_id->packet_id;
35 }
36
37 struct task_base;
38
39 void task_gen_set_pkt_count(struct task_base *tbase, uint32_t count);
40 int task_gen_set_pkt_size(struct task_base *tbase, uint32_t pkt_size);
41 void task_gen_set_rate(struct task_base *tbase, uint64_t bps);
42 void task_gen_reset_randoms(struct task_base *tbase);
43 void task_gen_reset_values(struct task_base *tbase);
44 int task_gen_set_value(struct task_base *tbase, uint32_t value, uint32_t offset, uint32_t len);
45 int task_gen_add_rand(struct task_base *tbase, const char *rand_str, uint32_t offset, uint32_t rand_id);
46
47 uint32_t task_gen_get_n_randoms(struct task_base *tbase);
48 uint32_t task_gen_get_n_values(struct task_base *tbase);
49
50 #endif /* _HANDLE_GEN_H_ */