summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/tests/libspid/utests/src/service_eoc_stub.c
blob: b00927433710a13b13ea5e811e086a2f77b63dc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* Cleopatre project {{{
 *
 * Copyright (C) 2009 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    service_eoc_stubs.c
 * \brief   Stubs for service related unitary tests for libspid
 * \ingroup Cleopatre - libspid
 *
 * This file contains stub functions used in unitary tests
 * for services in EoC libspid.
 */

#include <check.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <errno.h>
#include <inttypes.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <linux/if_tun.h>
#include <linux/if_ether.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <net/if.h>
#include <string.h>

#include "eoc_utests.h"


libspid_error_t
service_send_single_value (unsigned int mmtype, const void *value,
                           unsigned int length)
{
    unsigned char action1 = 0x00;
    unsigned char service_num = 0x01;
    unsigned char index1 = 0x02;
	unsigned char index2 = 0x01;
    /* using service type as classifier rule ID */
    unsigned char cl_rule1 = 0x01;
    /* using matching value as classifier rule value */
    unsigned char cl_value1[2] = {0x01, 0x00};
    unsigned char acs_en1 = 0x01;
    /* parameter number is always 7 */
    unsigned char param_nb1 = 0x07;
    /* latency */
    unsigned char param_value1[2] = {0x32, 0x00};
    /* jitter */
    unsigned char param_value2[2] = {0x14, 0x00};
    /* down PIR */
    unsigned char param_value3[2] = {0x64, 0x00};
    /* up PIR */
    unsigned char param_value4[2] = {0xC8, 0x00};
    /* down CIR */
    unsigned char param_value5[2] = {0x64, 0x00};
    /* up CIR */
    unsigned char param_value6[2] = {0xC8, 0x00};
    /* QOS prio */
    unsigned char param_value7[2] = {0x05, 0x00};

	if (memcmp (value, &action1, 1) != 0)
	{
		fail_if (memcmp (value + 2, &index2, 1) != 0,
                 "fail: wrong service index for remove" );
		return 0;
	}
    fail_if (memcmp (value, &action1, 1) != 0,
             "fail: wrong action" );
    fail_if (memcmp (value + 1, &service_num, 1) != 0,
             "fail: wrong number of services" );
    fail_if (memcmp (value + 2, &index1, 1) != 0,
             "fail: wrong service index1" );
    fail_if (memcmp (value + 3, &cl_rule1, 1) != 0,
             "fail: wrong cl_rule1 (service type)" );
    fail_if (memcmp (value + 4, cl_value1, 2) != 0,
             "fail: wrong cl_value1 (matching value)" );
    fail_if (memcmp (value + 6, &acs_en1, 1) != 0,
             "fail: wrong acs_en1" );
    fail_if (memcmp (value + 7, &param_nb1, 1) != 0,
             "fail: wrong number of parameters (param_nb1)" );
    fail_if (memcmp (value + 8, param_value1, 2) != 0,
             "fail: wrong parameter value1 (latency)" );
    fail_if (memcmp (value + 10, param_value2, 2) != 0,
             "fail: wrong parameter value2 (jitter)" );
    fail_if (memcmp (value + 12, param_value3, 2) != 0,
             "fail: wrong parameter value3 (down PIR)" );
    fail_if (memcmp (value + 14, param_value4, 2) != 0,
             "fail: wrong parameter value4 (up PIR)" );
    fail_if (memcmp (value + 16, param_value5, 2) != 0,
             "fail: wrong parameter value5 (down CIR)" );
    fail_if (memcmp (value + 18, param_value6, 2) != 0,
             "fail: wrong parameter value6 (up CIR)" );
    fail_if (memcmp (value + 20, param_value7, 2) != 0,
             "fail: wrong parameter value7 (QOS prio)" );

    return 0;
}