1/*
2 * Copyright (c) 2016  Intel Corporation.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef TEST_TLE_UDP_DEV_H_
17#define TEST_TLE_UDP_DEV_H_
18
19#include <algorithm>
20#include <arpa/inet.h>
21#include <gtest/gtest.h>
22
23#include <rte_errno.h>
24#include <tle_ctx.h>
25
26#define RX_NO_OFFLOAD 0
27#define TX_NO_OFFLOAD 0
28
29using namespace std;
30
31class udp_dev : public ::testing::Test {
32
33public:
34	struct tle_ctx *ctx;
35	struct tle_dev *dev;
36	struct tle_ctx_param prm;
37	struct tle_dev_param dev_prm;
38	vector<tle_dev *> devs;
39
40	virtual void SetUp(void)
41	{
42		rte_errno = 0;
43		memset(&prm, 0, sizeof(prm));
44		prm.socket_id = SOCKET_ID_ANY;
45		prm.max_streams = 0x1;
46		prm.max_stream_rbufs = 0x1;
47		prm.max_stream_sbufs = 0x1;
48
49		memset(&dev_prm, 0, sizeof(dev_prm));
50
51		/* Offload irrelevant in these tests, set to 0 */
52		dev_prm.rx_offload = RX_NO_OFFLOAD;
53		dev_prm.tx_offload = TX_NO_OFFLOAD;
54		inet_pton(AF_INET, "192.168.2.1", &(dev_prm).local_addr4);
55		inet_pton(AF_INET6, "fe80::21e:67ff:fec2:2568",
56				&(dev_prm).local_addr6);
57
58		ctx = tle_ctx_create(&prm);
59		ASSERT_NE(ctx, (void *) NULL);
60	}
61
62	virtual void TearDown(void)
63	{
64		for (auto d : devs)
65			tle_del_dev(d);
66
67		tle_ctx_destroy(ctx);
68	}
69};
70
71#endif /* TEST_TLE_UDP_DEV_H_ */
72