summaryrefslogtreecommitdiffstats
path: root/lib/src/ops.c
blob: 20362d69d342d183209c734df6320b1eb9350bb1 (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
108
109
110
111
112
/*
 * Copyright (c) 2021 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file ops.c
 * @brief Initializers for protocol-independent packet operations
 */

#ifndef _WIN32
#include <netinet/in.h>
#endif
#include <stdlib.h>
#include <hicn/ops.h>
#include <hicn/header.h>

extern const hicn_ops_t hicn_ops_ipv4;
extern const hicn_ops_t hicn_ops_icmp;
extern const hicn_ops_t hicn_ops_udp;
extern const hicn_ops_t hicn_ops_tcp;
extern const hicn_ops_t hicn_ops_ipv6;
extern const hicn_ops_t hicn_ops_new;
extern const hicn_ops_t hicn_ops_ah;

/* Declare empty operations (terminates recursion on protocol layers) */
DECLARE_init_packet_header (none, NONE);
DECLARE_get_interest_locator (none, NONE);
DECLARE_set_interest_locator (none, NONE);
DECLARE_get_interest_name (none, NONE);
DECLARE_set_interest_name (none, NONE);
DECLARE_get_interest_name_suffix (none, NONE);
DECLARE_set_interest_name_suffix (none, NONE);
DECLARE_is_interest (none, NONE);
DECLARE_mark_packet_as_interest (none, NONE);
DECLARE_mark_packet_as_data (none, NONE);
DECLARE_reset_interest_for_hash (none, NONE);
DECLARE_get_data_locator (none, NONE);
DECLARE_set_data_locator (none, NONE);
DECLARE_get_data_name (none, NONE);
DECLARE_set_data_name (none, NONE);
DECLARE_get_data_name_suffix (none, NONE);
DECLARE_set_data_name_suffix (none, NONE);
DECLARE_get_data_pathlabel (none, NONE);
DECLARE_set_data_pathlabel (none, NONE);
DECLARE_update_data_pathlabel (none, NONE);
DECLARE_reset_data_for_hash (none, NONE);
DECLARE_get_lifetime (none, NONE);
DECLARE_set_lifetime (none, NONE);
DECLARE_get_source_port (none, NONE);
DECLARE_get_dest_port (none, NONE);
DECLARE_set_source_port (none, NONE);
DECLARE_set_dest_port (none, NONE);
DECLARE_update_checksums (none, NONE);
DECLARE_verify_checksums (none, NONE);
DECLARE_rewrite_interest (none, NONE);
DECLARE_rewrite_data (none, NONE);
DECLARE_get_length (none, NONE);
DECLARE_get_header_length (none, NONE);
DECLARE_get_current_header_length (none, NONE);
DECLARE_get_payload_length (none, NONE);
DECLARE_set_payload_length (none, NONE);
DECLARE_get_payload_type (none, NONE);
DECLARE_set_payload_type (none, NONE);
DECLARE_get_signature_size (none, NONE);
DECLARE_set_signature_size (none, NONE);
DECLARE_set_signature_timestamp (none, NONE);
DECLARE_get_signature_timestamp (none, NONE);
DECLARE_set_validation_algorithm (none, NONE);
DECLARE_get_validation_algorithm (none, NONE);
DECLARE_set_key_id (none, NONE);
DECLARE_get_key_id (none, NONE);
DECLARE_get_signature (none, NONE);
DECLARE_get_signature_padding (none, NONE);
DECLARE_set_signature_padding (none, NONE);
DECLARE_is_last_data (none, NONE);
DECLARE_set_last_data (none, NONE);
DECLARE_HICN_OPS (none);

/**
 * @brief Virtual function table for packet operations
 * NOTE: protocol numbers have to be kept in order
 */
const hicn_ops_t *const hicn_ops_vft[] = {
  /*  0 */ [IPPROTO_IP] = &hicn_ops_ipv4,
  /*  1 */[IPPROTO_ICMP] = &hicn_ops_icmp,
  /*  6 */[IPPROTO_TCP] = &hicn_ops_tcp,
  /*  6 */[IPPROTO_UDP] = &hicn_ops_udp,
  /* 41 */[IPPROTO_IPV6] = &hicn_ops_ipv6,
  /* 51 */[IPPROTO_AH] = &hicn_ops_ah,
  /* 58 */[IPPROTO_ICMPV6] = &hicn_ops_icmp,
  /* 98 */[IPPROTO_ENCAP] = &hicn_ops_new,
  [IPPROTO_NONE] = &hicn_ops_none,
};

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */