hipl-core team mailing list archive
-
hipl-core team
-
Mailing list archive
-
Message #00023
[Branch ~hipl-core/hipl/trunk] Rev 4898: Fixed 'cast discards qualifiers' warnings in hip_get_next_param()
------------------------------------------------------------
revno: 4898
committer: Artturi Karila <artturi.karila@xxxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-08-19 12:32:20 +0300
message:
Fixed 'cast discards qualifiers' warnings in hip_get_next_param()
Since the message to iterate through is passed as a const pointer, the return
value must be const as well. Fixing this necessitated a large number of
additional const declarations. I added *_readwrite() versions of the functions
also used in ways that require a non-const return.
modified:
firewall/cache.c
firewall/conntrack.c
firewall/esp_prot_conntrack.c
firewall/esp_prot_fw_msg.c
firewall/firewall.c
firewall/firewall_control.c
firewall/sysopp.c
firewall/user_ipsec_fw_msg.c
firewall/user_ipsec_sadb.c
firewall/user_ipsec_sadb.h
hipd/cert.c
hipd/close.c
hipd/cookie.c
hipd/cookie.h
hipd/esp_prot_anchordb.c
hipd/esp_prot_hipd_msg.c
hipd/esp_prot_light_update.c
hipd/esp_prot_light_update.h
hipd/hadb.c
hipd/hadb.h
hipd/hidb.c
hipd/hiprelay.c
hipd/hiprelay.h
hipd/hit_to_ip.c
hipd/hit_to_ip.h
hipd/input.c
hipd/netdev.c
hipd/netdev.h
hipd/oppdb.c
hipd/output.c
hipd/output.h
hipd/registration.c
hipd/user.c
hipd/user_ipsec_hipd_msg.c
lib/core/builder.c
lib/core/builder.h
lib/core/certtools.c
lib/core/conf.c
lib/core/debug.c
lib/core/debug.h
lib/core/hostsfiles.c
lib/core/hostsfiles.h
lib/core/prefix.c
lib/core/prefix.h
lib/core/solve.c
lib/core/solve.h
lib/core/transform.c
lib/core/transform.h
lib/tool/pk.c
modules/update/hipd/update.c
tools/pisacert.c
--
lp:hipl
https://code.launchpad.net/~hipl-core/hipl/trunk
Your team HIPL core team is subscribed to branch lp:hipl.
To unsubscribe from this branch go to https://code.launchpad.net/~hipl-core/hipl/trunk/+edit-subscription
=== modified file 'firewall/cache.c'
--- firewall/cache.c 2010-08-18 17:47:04 +0000
+++ firewall/cache.c 2010-08-19 09:32:20 +0000
@@ -120,10 +120,11 @@
fw_cache_query_type_t type)
{
int err = 0;
- fw_cache_hl_t *ha_match = NULL;
- fw_cache_hl_t *ha_curr = NULL;
- struct hip_common *msg = NULL;
- struct hip_tlv_common *current_param = NULL;
+ fw_cache_hl_t *ha_ret = NULL;
+ const fw_cache_hl_t *ha_match = NULL;
+ const fw_cache_hl_t *ha_curr = NULL;
+ struct hip_common *msg = NULL;
+ const struct hip_tlv_common *current_param = NULL;
HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1, "malloc failed\n");
hip_msg_init(msg);
@@ -154,7 +155,7 @@
}
if (ha_match) {
- ha_match = firewall_add_new_entry(ha_match);
+ ha_ret = firewall_add_new_entry(ha_match);
}
out_err:
@@ -163,7 +164,7 @@
free(msg);
}
- return ha_match;
+ return ha_ret;
}
/**
=== modified file 'firewall/conntrack.c'
--- firewall/conntrack.c 2010-08-18 16:21:16 +0000
+++ firewall/conntrack.c 2010-08-19 09:32:20 +0000
@@ -802,11 +802,11 @@
const hip_fw_context_t *ctx)
{
struct iphdr *iph = (struct iphdr *) ctx->ipq_packet->payload;
- struct hip_relay_to *relay_to = NULL; /* same format as relay_from */
+ const struct hip_relay_to *relay_to = NULL; /* same format as relay_from */
struct tuple *tuple, *reverse_tuple;
int err = 0;
uint32_t spi;
- struct hip_esp_info *esp_info;
+ const struct hip_esp_info *esp_info;
HIP_DEBUG_IN6ADDR("ctx->src", &ctx->src);
HIP_DEBUG_IN6ADDR("ctx->dst", &ctx->dst);
@@ -891,7 +891,7 @@
UNUSED const hip_fw_context_t *ctx)
{
struct in6_addr hit;
- struct hip_host_id *host_id = NULL;
+ const struct hip_host_id *host_id = NULL;
// assume correct packet
int err = 1;
hip_tlv_len_t len = 0;
@@ -925,10 +925,12 @@
// store the public key separately
// store function pointer for verification
if (hip_get_host_id_algo(tuple->hip_tuple->data->src_hi) == HIP_HI_RSA) {
- tuple->hip_tuple->data->src_pub_key = hip_key_rr_to_rsa((struct hip_host_id_priv *) host_id, 0);
+ tuple->hip_tuple->data->src_pub_key = hip_key_rr_to_rsa(
+ (const struct hip_host_id_priv *) host_id, 0);
tuple->hip_tuple->data->verify = hip_rsa_verify;
} else {
- tuple->hip_tuple->data->src_pub_key = hip_key_rr_to_dsa((struct hip_host_id_priv *) host_id, 0);
+ tuple->hip_tuple->data->src_pub_key = hip_key_rr_to_dsa(
+ (const struct hip_host_id_priv *) host_id, 0);
tuple->hip_tuple->data->verify = hip_dsa_verify;
}
@@ -960,11 +962,11 @@
static int handle_i2(struct hip_common *common, struct tuple *tuple,
const hip_fw_context_t *ctx)
{
- struct hip_esp_info *spi = NULL;
- struct tuple *other_dir = NULL;
- struct esp_tuple *esp_tuple = NULL;
- SList *other_dir_esps = NULL;
- struct hip_host_id *host_id = NULL;
+ const struct hip_esp_info *spi = NULL;
+ struct tuple *other_dir = NULL;
+ struct esp_tuple *esp_tuple = NULL;
+ SList *other_dir_esps = NULL;
+ const struct hip_host_id *host_id = NULL;
struct in6_addr hit;
// assume correct packet
int err = 1;
@@ -996,10 +998,12 @@
// store the public key separately
// store function pointer for verification
if (hip_get_host_id_algo(tuple->hip_tuple->data->src_hi) == HIP_HI_RSA) {
- tuple->hip_tuple->data->src_pub_key = hip_key_rr_to_rsa((struct hip_host_id_priv *) host_id, 0);
+ tuple->hip_tuple->data->src_pub_key = hip_key_rr_to_rsa(
+ (const struct hip_host_id_priv *) host_id, 0);
tuple->hip_tuple->data->verify = hip_rsa_verify;
} else {
- tuple->hip_tuple->data->src_pub_key = hip_key_rr_to_dsa((struct hip_host_id_priv *) host_id, 0);
+ tuple->hip_tuple->data->src_pub_key = hip_key_rr_to_dsa(
+ (const struct hip_host_id_priv *) host_id, 0);
tuple->hip_tuple->data->verify = hip_dsa_verify;
}
@@ -1068,10 +1072,10 @@
static int handle_r2(const struct hip_common *common, struct tuple *tuple,
const hip_fw_context_t *ctx)
{
- struct hip_esp_info *spi = NULL;
- struct tuple *other_dir = NULL;
- SList *other_dir_esps = NULL;
- struct esp_tuple *esp_tuple = NULL;
+ const struct hip_esp_info *spi = NULL;
+ struct tuple *other_dir = NULL;
+ SList *other_dir_esps = NULL;
+ struct esp_tuple *esp_tuple = NULL;
const struct in6_addr *ip6_src = &ctx->src;
int err = 1;
@@ -1260,14 +1264,14 @@
struct tuple *tuple,
const hip_fw_context_t *ctx)
{
- struct hip_seq *seq = NULL;
- struct hip_esp_info *esp_info = NULL;
- struct hip_ack *ack = NULL;
- struct hip_locator *locator = NULL;
- struct hip_spi *spi = NULL;
- struct tuple *other_dir_tuple = NULL;
- const struct in6_addr *ip6_src = &ctx->src;
- int err = 1;
+ const struct hip_seq *seq = NULL;
+ const struct hip_esp_info *esp_info = NULL;
+ const struct hip_ack *ack = NULL;
+ const struct hip_locator *locator = NULL;
+ const struct hip_spi *spi = NULL;
+ struct tuple *other_dir_tuple = NULL;
+ const struct in6_addr *ip6_src = &ctx->src;
+ int err = 1;
/* get params from UPDATE message */
seq = hip_get_param(common, HIP_PARAM_SEQ);
=== modified file 'firewall/esp_prot_conntrack.c'
--- firewall/esp_prot_conntrack.c 2010-08-18 16:14:20 +0000
+++ firewall/esp_prot_conntrack.c 2010-08-19 09:32:20 +0000
@@ -194,8 +194,8 @@
*/
static int esp_prot_conntrack_cache_anchor(const struct tuple *tuple,
const struct hip_seq *seq,
- struct esp_prot_anchor **esp_anchors,
- struct esp_prot_root **esp_roots)
+ const struct esp_prot_anchor **esp_anchors,
+ const struct esp_prot_root **esp_roots)
{
struct esp_anchor_item *anchor_item = NULL;
unsigned char *cmp_value = NULL;
@@ -425,9 +425,9 @@
* @return 0 on success, -1 on error
*/
static int esp_prot_conntrack_verify_branch(const struct tuple *tuple,
- struct esp_prot_anchor *esp_anchors[MAX_NUM_PARALLEL_HCHAINS],
- struct esp_prot_branch *esp_branches[MAX_NUM_PARALLEL_HCHAINS],
- struct esp_prot_secret *esp_secrets[MAX_NUM_PARALLEL_HCHAINS])
+ const struct esp_prot_anchor *esp_anchors[MAX_NUM_PARALLEL_HCHAINS],
+ const struct esp_prot_branch *esp_branches[MAX_NUM_PARALLEL_HCHAINS],
+ const struct esp_prot_secret *esp_secrets[MAX_NUM_PARALLEL_HCHAINS])
{
esp_prot_conntrack_tfm_t *conntrack_tfm = NULL;
int hash_length = 0;
@@ -564,9 +564,8 @@
int esp_prot_conntrack_R1_tfms(const struct hip_common *common,
const struct tuple *tuple)
{
- struct hip_param *param = NULL;
- struct esp_prot_preferred_tfms *prot_transforms = NULL;
- int err = 0, i;
+ const struct esp_prot_preferred_tfms *prot_transforms = NULL;
+ int err = 0, i;
HIP_DEBUG("\n");
@@ -575,11 +574,10 @@
memset(tuple->connection->esp_prot_tfms, 0, NUM_TRANSFORMS + 1);
// check if message contains optional ESP protection transforms
- if ((param = hip_get_param(common, HIP_PARAM_ESP_PROT_TRANSFORMS))) {
+ if ((prot_transforms = hip_get_param(common,
+ HIP_PARAM_ESP_PROT_TRANSFORMS))) {
HIP_DEBUG("ESP protection extension transforms found\n");
- prot_transforms = (struct esp_prot_preferred_tfms *) param;
-
// make sure we only process as many transforms as we can handle
if (prot_transforms->num_transforms > NUM_TRANSFORMS + 1) {
HIP_DEBUG("received more transforms than we can handle, " \
@@ -623,13 +621,13 @@
int esp_prot_conntrack_I2_anchor(const struct hip_common *common,
struct tuple *tuple)
{
- struct hip_tlv_common *param = NULL;
- struct esp_prot_anchor *prot_anchor = NULL;
- struct esp_tuple *esp_tuple = NULL;
- esp_prot_conntrack_tfm_t *conntrack_tfm = NULL;
- long i = 0;
- int hash_length = 0;
- int err = 0;
+ const struct hip_tlv_common *param = NULL;
+ const struct esp_prot_anchor *prot_anchor = NULL;
+ struct esp_tuple *esp_tuple = NULL;
+ esp_prot_conntrack_tfm_t *conntrack_tfm = NULL;
+ long i = 0;
+ int hash_length = 0;
+ int err = 0;
HIP_DEBUG("\n");
@@ -638,7 +636,7 @@
// check if message contains optional ESP protection anchors
if ((param = hip_get_param(common, HIP_PARAM_ESP_PROT_ANCHOR))) {
- prot_anchor = (struct esp_prot_anchor *) param;
+ prot_anchor = (const struct esp_prot_anchor *) param;
/* create esp_tuple for direction of this message only storing
* the sent anchor, no SPI known yet -> will be sent in R2
@@ -700,7 +698,7 @@
// get next anchor
param = hip_get_next_param(common, param);
- prot_anchor = (struct esp_prot_anchor *) param;
+ prot_anchor = (const struct esp_prot_anchor *) param;
}
// store number of parallel hchains
@@ -783,13 +781,13 @@
int esp_prot_conntrack_R2_anchor(const struct hip_common *common,
const struct tuple *tuple)
{
- struct hip_tlv_common *param = NULL;
- struct esp_prot_anchor *prot_anchor = NULL;
- struct esp_tuple *esp_tuple = NULL;
- esp_prot_conntrack_tfm_t *conntrack_tfm = NULL;
- long i = 0;
- int hash_length = 0;
- int err = 0;
+ const struct hip_tlv_common *param = NULL;
+ const struct esp_prot_anchor *prot_anchor = NULL;
+ struct esp_tuple *esp_tuple = NULL;
+ esp_prot_conntrack_tfm_t *conntrack_tfm = NULL;
+ long i = 0;
+ int hash_length = 0;
+ int err = 0;
HIP_DEBUG("\n");
@@ -798,7 +796,7 @@
// check if message contains optional ESP protection anchor
if ((param = hip_get_param(common, HIP_PARAM_ESP_PROT_ANCHOR))) {
- prot_anchor = (struct esp_prot_anchor *) param;
+ prot_anchor = (const struct esp_prot_anchor *) param;
// check if the anchor has a supported transform
if (esp_prot_check_transform(tuple->connection->num_esp_prot_tfms,
@@ -851,7 +849,7 @@
// get next anchor
param = hip_get_next_param(common, param);
- prot_anchor = (struct esp_prot_anchor *) param;
+ prot_anchor = (const struct esp_prot_anchor *) param;
}
// store number of parallel hchains
@@ -886,12 +884,12 @@
*/
int esp_prot_conntrack_update(const hip_common_t *update, const struct tuple *tuple)
{
- struct hip_tlv_common *param = NULL;
- struct hip_seq *seq = NULL;
- struct hip_ack *ack = NULL;
- struct hip_esp_info *esp_info = NULL;
- struct esp_prot_anchor *esp_anchors[MAX_NUM_PARALLEL_HCHAINS];
- struct esp_prot_root *esp_roots[MAX_NUM_PARALLEL_HCHAINS];
+ const struct hip_tlv_common *param = NULL;
+ const struct hip_seq *seq = NULL;
+ const struct hip_ack *ack = NULL;
+ const struct hip_esp_info *esp_info = NULL;
+ const struct esp_prot_anchor *esp_anchors[MAX_NUM_PARALLEL_HCHAINS];
+ const struct esp_prot_root *esp_roots[MAX_NUM_PARALLEL_HCHAINS];
int err = 0;
long i = 0;
@@ -915,7 +913,7 @@
// get all anchors
for (i = 0; i < num_parallel_hchains; i++) {
- esp_anchors[i] = (struct esp_prot_anchor *) param;
+ esp_anchors[i] = (const struct esp_prot_anchor *) param;
param = hip_get_next_param(update, param);
}
@@ -924,7 +922,7 @@
if (param) {
// get all roots
for (i = 0; i < num_parallel_hchains; i++) {
- esp_roots[i] = (struct esp_prot_root *) param;
+ esp_roots[i] = (const struct esp_prot_root *) param;
param = hip_get_next_param(update, param);
}
@@ -995,14 +993,14 @@
struct tuple *tuple,
const hip_fw_context_t *ctx)
{
- struct hip_seq *seq = NULL;
- struct hip_tlv_common *param = NULL;
- struct esp_prot_anchor *esp_anchors[MAX_NUM_PARALLEL_HCHAINS];
- struct esp_prot_branch *esp_branches[MAX_NUM_PARALLEL_HCHAINS];
- struct esp_prot_secret *esp_secrets[MAX_NUM_PARALLEL_HCHAINS];
- struct esp_prot_root *esp_roots[MAX_NUM_PARALLEL_HCHAINS];
- struct hip_ack *ack = NULL;
- struct hip_esp_info *esp_info = NULL;
+ const struct hip_seq *seq = NULL;
+ const struct hip_tlv_common *param = NULL;
+ const struct esp_prot_anchor *esp_anchors[MAX_NUM_PARALLEL_HCHAINS];
+ const struct esp_prot_branch *esp_branches[MAX_NUM_PARALLEL_HCHAINS];
+ const struct esp_prot_secret *esp_secrets[MAX_NUM_PARALLEL_HCHAINS];
+ const struct esp_prot_root *esp_roots[MAX_NUM_PARALLEL_HCHAINS];
+ const struct hip_ack *ack = NULL;
+ const struct hip_esp_info *esp_info = NULL;
const struct in6_addr *ip6_src = &ctx->src;
const struct in6_addr *ip6_dst = &ctx->dst;
int err = 0;
@@ -1026,21 +1024,21 @@
param = hip_get_param(common, HIP_PARAM_ESP_PROT_ANCHOR);
for (i = 0; i < num_parallel_hchains; i++) {
- esp_anchors[i] = (struct esp_prot_anchor *) param;
+ esp_anchors[i] = (const struct esp_prot_anchor *) param;
param = hip_get_next_param(common, param);
}
param = hip_get_param(common, HIP_PARAM_ESP_PROT_BRANCH);
for (i = 0; i < num_parallel_hchains; i++) {
- esp_branches[i] = (struct esp_prot_branch *) param;
+ esp_branches[i] = (const struct esp_prot_branch *) param;
param = hip_get_next_param(common, param);
}
param = hip_get_param(common, HIP_PARAM_ESP_PROT_SECRET);
for (i = 0; i < num_parallel_hchains; i++) {
- esp_secrets[i] = (struct esp_prot_secret *) param;
+ esp_secrets[i] = (const struct esp_prot_secret *) param;
param = hip_get_next_param(common, param);
}
@@ -1048,7 +1046,7 @@
param = hip_get_param(common, HIP_PARAM_ESP_PROT_ROOT);
if (param) {
for (i = 0; i < num_parallel_hchains; i++) {
- esp_roots[i] = (struct esp_prot_root *) param;
+ esp_roots[i] = (const struct esp_prot_root *) param;
param = hip_get_next_param(common, param);
}
=== modified file 'firewall/esp_prot_fw_msg.c'
--- firewall/esp_prot_fw_msg.c 2010-08-18 17:57:40 +0000
+++ firewall/esp_prot_fw_msg.c 2010-08-19 09:32:20 +0000
@@ -603,9 +603,9 @@
unsigned char (*esp_prot_anchors)[MAX_HASH_LENGTH],
uint32_t *hash_item_length)
{
- struct hip_tlv_common *param = NULL;
- int hash_length = 0, err = 0;
- unsigned char *anchor = NULL;
+ const struct hip_tlv_common *param = NULL;
+ int hash_length = 0, err = 0;
+ const unsigned char *anchor = NULL;
uint16_t i;
*num_anchors = 0;
*esp_prot_transform = 0;
@@ -616,7 +616,7 @@
HIP_IFEL(!(param = hip_get_param(msg, HIP_PARAM_ESP_PROT_TFM)),
-1, "esp prot transform missing\n");
- *esp_prot_transform = *((uint8_t *) hip_get_param_contents_direct(param));
+ *esp_prot_transform = *((const uint8_t *) hip_get_param_contents_direct(param));
HIP_DEBUG("esp protection transform is %u\n", *esp_prot_transform);
// this parameter is only included, if the esp extension is used
@@ -627,12 +627,12 @@
HIP_IFEL(!(param = hip_get_param(msg, HIP_PARAM_ITEM_LENGTH)),
-1, "transform suggests hash_item_length, but it is NOT included in msg\n");
- *hash_item_length = *((uint32_t *) hip_get_param_contents_direct(param));
+ *hash_item_length = *((const uint32_t *) hip_get_param_contents_direct(param));
HIP_DEBUG("esp protection item length: %u\n", *hash_item_length);
HIP_IFEL(!(param = hip_get_next_param(msg, param)),
-1, "transform suggests num_anchors, but it is NOT included in msg\n");
- *num_anchors = *((uint16_t *) hip_get_param_contents_direct(param));
+ *num_anchors = *((const uint16_t *) hip_get_param_contents_direct(param));
HIP_DEBUG("esp protection number of transferred anchors: %u\n", *num_anchors);
HIP_IFEL(!(param = hip_get_param(msg, HIP_PARAM_HCHAIN_ANCHOR)),
=== modified file 'firewall/firewall.c'
--- firewall/firewall.c 2010-08-18 16:59:20 +0000
+++ firewall/firewall.c 2010-08-19 09:32:20 +0000
@@ -589,11 +589,11 @@
*/
static int hip_query_default_local_hit_from_hipd(void)
{
- int err = 0;
- struct hip_common *msg = NULL;
- struct hip_tlv_common *param = NULL;
- hip_hit_t *hit = NULL;
- hip_lsi_t *lsi = NULL;
+ int err = 0;
+ struct hip_common *msg = NULL;
+ const struct hip_tlv_common *param = NULL;
+ const hip_hit_t *hit = NULL;
+ const hip_lsi_t *lsi = NULL;
HIP_IFE(!(msg = hip_msg_alloc()), -1);
HIP_IFEL(hip_build_user_hdr(msg, HIP_MSG_DEFAULT_HIT, 0), -1,
=== modified file 'firewall/firewall_control.c'
--- firewall/firewall_control.c 2010-07-04 17:54:18 +0000
+++ firewall/firewall_control.c 2010-08-19 09:32:20 +0000
@@ -59,8 +59,8 @@
*/
static int hip_handle_bex_state_update(struct hip_common *msg)
{
- struct in6_addr *src_hit = NULL, *dst_hit = NULL;
- struct hip_tlv_common *param = NULL;
+ const struct in6_addr *src_hit = NULL, *dst_hit = NULL;
+ const struct hip_tlv_common *param = NULL;
int err = 0, msg_type = 0;
msg_type = hip_get_msg_type(msg);
=== modified file 'firewall/sysopp.c'
--- firewall/sysopp.c 2010-07-07 16:48:07 +0000
+++ firewall/sysopp.c 2010-08-19 09:32:20 +0000
@@ -205,9 +205,9 @@
int hip_fw_sys_opp_set_peer_hit(const struct hip_common *msg)
{
int err = 0, state;
- hip_hit_t *local_hit, *peer_hit;
- struct in6_addr *peer_addr;
- struct in6_addr *local_addr;
+ const hip_hit_t *local_hit, *peer_hit;
+ const struct in6_addr *peer_addr;
+ const struct in6_addr *local_addr;
local_hit = hip_get_param_contents(msg, HIP_PARAM_HIT_LOCAL);
peer_hit = hip_get_param_contents(msg, HIP_PARAM_HIT_PEER);
=== modified file 'firewall/user_ipsec_fw_msg.c'
--- firewall/user_ipsec_fw_msg.c 2010-08-18 16:21:16 +0000
+++ firewall/user_ipsec_fw_msg.c 2010-08-19 09:32:20 +0000
@@ -111,16 +111,16 @@
*/
int handle_sa_add_request(const struct hip_common *msg)
{
- struct hip_tlv_common *param = NULL;
- struct in6_addr *src_addr = NULL, *dst_addr = NULL;
- struct in6_addr *src_hit = NULL, *dst_hit = NULL;
- uint32_t spi = 0;
- int ealg = 0, err = 0;
- struct hip_crypto_key *enc_key = NULL, *auth_key = NULL;
- int retransmission = 0, direction = 0, update = 0;
- uint16_t local_port = 0, peer_port = 0;
- uint8_t encap_mode = 0, esp_prot_transform = 0;
- uint32_t hash_item_length = 0;
+ const struct hip_tlv_common *param = NULL;
+ const struct in6_addr *src_addr = NULL, *dst_addr = NULL;
+ const struct in6_addr *src_hit = NULL, *dst_hit = NULL;
+ uint32_t spi = 0;
+ int ealg = 0, err = 0;
+ const struct hip_crypto_key *enc_key = NULL, *auth_key = NULL;
+ int retransmission = 0, direction = 0, update = 0;
+ uint16_t local_port = 0, peer_port = 0;
+ uint8_t encap_mode = 0, esp_prot_transform = 0;
+ uint32_t hash_item_length = 0;
uint16_t esp_num_anchors;
unsigned char esp_prot_anchors[MAX_NUM_PARALLEL_HCHAINS][MAX_HASH_LENGTH];
@@ -143,19 +143,19 @@
HIP_DEBUG_HIT("Destination HIT: ", dst_hit);
param = hip_get_param(msg, HIP_PARAM_UINT);
- spi = *((uint32_t *) hip_get_param_contents_direct(param));
+ spi = *((const uint32_t *) hip_get_param_contents_direct(param));
HIP_DEBUG("the spi value is : 0x%lx \n", spi);
param = hip_get_next_param(msg, param);
- encap_mode = *((uint8_t *) hip_get_param_contents_direct(param));
+ encap_mode = *((const uint8_t *) hip_get_param_contents_direct(param));
HIP_DEBUG("the nat_mode value is %u \n", encap_mode);
param = hip_get_next_param(msg, param);
- local_port = *((uint16_t *) hip_get_param_contents_direct(param));
+ local_port = *((const uint16_t *) hip_get_param_contents_direct(param));
HIP_DEBUG("the local_port value is %u \n", local_port);
param = hip_get_next_param(msg, param);
- peer_port = *((uint16_t *) hip_get_param_contents_direct(param));
+ peer_port = *((const uint16_t *) hip_get_param_contents_direct(param));
HIP_DEBUG("the peer_port value is %u \n", peer_port);
/* parse the esp protection extension parameters */
@@ -172,19 +172,19 @@
HIP_HEXDUMP("auth key:", auth_key, sizeof(struct hip_crypto_key));
param = hip_get_param(msg, HIP_PARAM_INT);
- ealg = *((int *) hip_get_param_contents_direct(param));
+ ealg = *((const int *) hip_get_param_contents_direct(param));
HIP_DEBUG("ealg value is %d \n", ealg);
param = hip_get_next_param(msg, param);
- retransmission = *((int *) hip_get_param_contents_direct(param));
+ retransmission = *((const int *) hip_get_param_contents_direct(param));
HIP_DEBUG("already_acquired value is %d \n", retransmission);
param = hip_get_next_param(msg, param);
- direction = *((int *) hip_get_param_contents_direct(param));
+ direction = *((const int *) hip_get_param_contents_direct(param));
HIP_DEBUG("the direction value is %d \n", direction);
param = hip_get_next_param(msg, param);
- update = *((int *) hip_get_param_contents_direct(param));
+ update = *((const int *) hip_get_param_contents_direct(param));
HIP_DEBUG("the update value is %d \n", update);
HIP_IFEL(hip_sadb_add(direction, spi, BEET_MODE, src_addr, dst_addr,
@@ -206,17 +206,17 @@
*/
int handle_sa_delete_request(const struct hip_common *msg)
{
- struct hip_tlv_common *param = NULL;
- uint32_t spi = 0;
- struct in6_addr *peer_addr = NULL;
- struct in6_addr *dst_addr = NULL;
- int family = 0, src_port = 0, dst_port = 0;
- int err = 0;
+ const struct hip_tlv_common *param = NULL;
+ uint32_t spi = 0;
+ const struct in6_addr *peer_addr = NULL;
+ const struct in6_addr *dst_addr = NULL;
+ int family = 0, src_port = 0, dst_port = 0;
+ int err = 0;
/* get all attributes from the message */
param = hip_get_param(msg, HIP_PARAM_UINT);
- spi = *((uint32_t *) hip_get_param_contents_direct(param));
+ spi = *((const uint32_t *) hip_get_param_contents_direct(param));
HIP_DEBUG("spi value: 0x%lx \n", spi);
param = hip_get_param(msg, HIP_PARAM_IPV6_ADDR);
@@ -228,15 +228,15 @@
HIP_DEBUG_IN6ADDR("dst address: ", dst_addr);
param = hip_get_param(msg, HIP_PARAM_INT);
- family = *((int *) hip_get_param_contents_direct(param));
+ family = *((const int *) hip_get_param_contents_direct(param));
HIP_DEBUG("family: %i\n", family);
param = hip_get_next_param(msg, param);
- src_port = *((int *) hip_get_param_contents_direct(param));
+ src_port = *((const int *) hip_get_param_contents_direct(param));
HIP_DEBUG("src_port: %i\n", src_port);
param = hip_get_next_param(msg, param);
- dst_port = *((int *) hip_get_param_contents_direct(param));
+ dst_port = *((const int *) hip_get_param_contents_direct(param));
HIP_DEBUG("dst_port: %i\n", dst_port);
/* work-around due to broken sa_delete in hipd */
=== modified file 'firewall/user_ipsec_sadb.c'
--- firewall/user_ipsec_sadb.c 2010-07-16 18:17:47 +0000
+++ firewall/user_ipsec_sadb.c 2010-08-19 09:32:20 +0000
@@ -380,15 +380,15 @@
int direction,
uint32_t spi,
uint32_t mode,
- struct in6_addr *src_addr,
- struct in6_addr *dst_addr,
- struct in6_addr *inner_src_addr,
- struct in6_addr *inner_dst_addr,
+ const struct in6_addr *src_addr,
+ const struct in6_addr *dst_addr,
+ const struct in6_addr *inner_src_addr,
+ const struct in6_addr *inner_dst_addr,
uint8_t encap_mode,
uint16_t src_port,
uint16_t dst_port,
- int ealg, struct hip_crypto_key *auth_key,
- struct hip_crypto_key *enc_key,
+ int ealg, const struct hip_crypto_key *auth_key,
+ const struct hip_crypto_key *enc_key,
uint64_t lifetime, uint8_t esp_prot_transform,
uint32_t hash_item_length,
uint16_t esp_num_anchors,
@@ -533,16 +533,16 @@
static int hip_sa_entry_update(int direction,
uint32_t spi,
uint32_t mode,
- struct in6_addr *src_addr,
- struct in6_addr *dst_addr,
- struct in6_addr *inner_src_addr,
- struct in6_addr *inner_dst_addr,
+ const struct in6_addr *src_addr,
+ const struct in6_addr *dst_addr,
+ const struct in6_addr *inner_src_addr,
+ const struct in6_addr *inner_dst_addr,
uint8_t encap_mode,
uint16_t src_port,
uint16_t dst_port,
int ealg,
- struct hip_crypto_key *auth_key,
- struct hip_crypto_key *enc_key,
+ const struct hip_crypto_key *auth_key,
+ const struct hip_crypto_key *enc_key,
uint64_t lifetime,
uint8_t esp_prot_transform,
uint32_t hash_item_length,
@@ -628,12 +628,18 @@
* @return 0 on success, else -1
*/
static int hip_sa_entry_add(int direction, uint32_t spi, uint32_t mode,
- struct in6_addr *src_addr, struct in6_addr *dst_addr,
- struct in6_addr *inner_src_addr, struct in6_addr *inner_dst_addr,
- uint8_t encap_mode, uint16_t src_port, uint16_t dst_port,
- int ealg, struct hip_crypto_key *auth_key, struct hip_crypto_key *enc_key,
- uint64_t lifetime, uint8_t esp_prot_transform, uint32_t hash_item_length,
- uint16_t esp_num_anchors, unsigned char (*esp_prot_anchors)[MAX_HASH_LENGTH],
+ const struct in6_addr *src_addr,
+ const struct in6_addr *dst_addr,
+ const struct in6_addr *inner_src_addr,
+ const struct in6_addr *inner_dst_addr,
+ uint8_t encap_mode, uint16_t src_port,
+ uint16_t dst_port,
+ int ealg, const struct hip_crypto_key *auth_key,
+ const struct hip_crypto_key *enc_key,
+ uint64_t lifetime, uint8_t esp_prot_transform,
+ uint32_t hash_item_length,
+ uint16_t esp_num_anchors,
+ unsigned char (*esp_prot_anchors)[MAX_HASH_LENGTH],
int update)
{
hip_sa_entry_t *entry = NULL;
@@ -787,17 +793,22 @@
* @return 0 on success, else -1
*/
int hip_sadb_add(int direction, uint32_t spi, uint32_t mode,
- struct in6_addr *src_addr, struct in6_addr *dst_addr,
- struct in6_addr *inner_src_addr, struct in6_addr *inner_dst_addr,
+ const struct in6_addr *src_addr,
+ const struct in6_addr *dst_addr,
+ const struct in6_addr *inner_src_addr,
+ const struct in6_addr *inner_dst_addr,
uint8_t encap_mode, uint16_t local_port, uint16_t peer_port,
- int ealg, struct hip_crypto_key *auth_key, struct hip_crypto_key *enc_key,
- uint64_t lifetime, uint8_t esp_prot_transform, uint32_t hash_item_length,
- uint16_t esp_num_anchors, unsigned char (*esp_prot_anchors)[MAX_HASH_LENGTH],
+ int ealg, const struct hip_crypto_key *auth_key,
+ const struct hip_crypto_key *enc_key,
+ uint64_t lifetime, uint8_t esp_prot_transform,
+ uint32_t hash_item_length,
+ uint16_t esp_num_anchors,
+ unsigned char (*esp_prot_anchors)[MAX_HASH_LENGTH],
UNUSED int retransmission, int update)
{
- int err = 0;
- struct in6_addr *check_local_hit = NULL;
- struct in6_addr *default_hit = NULL;
+ int err = 0;
+ const struct in6_addr *check_local_hit = NULL;
+ struct in6_addr *default_hit = NULL;
in_port_t src_port, dst_port;
/* TODO handle retransmission correctly */
@@ -848,7 +859,7 @@
* @param spi spi number of the entry
* @return -1, if error occurred, else 0
*/
-int hip_sadb_delete(struct in6_addr *dst_addr, uint32_t spi)
+int hip_sadb_delete(const struct in6_addr *dst_addr, uint32_t spi)
{
hip_sa_entry_t *entry = NULL;
int err = 0;
=== modified file 'firewall/user_ipsec_sadb.h'
--- firewall/user_ipsec_sadb.h 2010-07-04 17:54:18 +0000
+++ firewall/user_ipsec_sadb.h 2010-08-19 09:32:20 +0000
@@ -94,15 +94,15 @@
int hip_sadb_add(int direction,
uint32_t spi,
uint32_t mode,
- struct in6_addr *src_addr,
- struct in6_addr *dst_addr,
- struct in6_addr *inner_src_addr,
- struct in6_addr *inner_dst_addr,
+ const struct in6_addr *src_addr,
+ const struct in6_addr *dst_addr,
+ const struct in6_addr *inner_src_addr,
+ const struct in6_addr *inner_dst_addr,
uint8_t encap_mode, uint16_t local_port,
uint16_t peer_port,
int ealg,
- struct hip_crypto_key *auth_key,
- struct hip_crypto_key *enc_key,
+ const struct hip_crypto_key *auth_key,
+ const struct hip_crypto_key *enc_key,
uint64_t lifetime,
uint8_t esp_prot_transform,
uint32_t hash_item_length,
@@ -110,7 +110,7 @@
unsigned char (*esp_prot_anchors)[MAX_HASH_LENGTH],
int retransmission,
int update);
-int hip_sadb_delete(struct in6_addr *dst_addr,
+int hip_sadb_delete(const struct in6_addr *dst_addr,
uint32_t spi);
int hip_sadb_flush(void);
hip_sa_entry_t *hip_sa_entry_find_inbound(const struct in6_addr *dst_addr,
=== modified file 'hipd/cert.c'
--- hipd/cert.c 2010-08-10 07:24:52 +0000
+++ hipd/cert.c 2010-08-19 09:32:20 +0000
@@ -75,7 +75,7 @@
int hip_cert_spki_sign(struct hip_common *msg)
{
int err = 0, sig_len = 0, algo = 0, t = 0;
- struct hip_cert_spki_info *p_cert;
+ const struct hip_cert_spki_info *p_cert;
struct hip_cert_spki_info *cert;
struct hip_host_id *host_id = NULL;
unsigned char sha_digest[21];
@@ -362,7 +362,7 @@
unsigned char *signature_hash_b64 = NULL;
unsigned char *signature_b64 = NULL;
- struct hip_cert_spki_info *p_cert;
+ const struct hip_cert_spki_info *p_cert;
struct hip_cert_spki_info *cert = NULL;
unsigned char *signature = NULL;
@@ -719,7 +719,7 @@
const EVP_MD *digest = NULL;
X509 *cert;
X509V3_CTX ctx;
- struct hip_cert_x509_req *subject;
+ const struct hip_cert_x509_req *subject;
char subject_hit[41];
char issuer_hit[41];
char ialtname[45];
@@ -734,14 +734,10 @@
char arg1[21];
char arg2[21];
- HIP_IFEL(!(subject = malloc(sizeof(struct in6_addr))), -1,
- "Malloc for subject failed\n");
HIP_IFEL(!(issuer_hit_n = malloc(sizeof(struct in6_addr))), -1,
"Malloc for subject failed\n");
HIP_IFEL(!(pkey = malloc(sizeof(EVP_PKEY))), -1,
"Malloc for pkey failed\n");
- HIP_IFEL(!memset(subject, 0, sizeof(subject)), -1,
- "Failed to memset memory for subject\n");
HIP_IFEL(!memset(issuer_hit_n, 0, sizeof(issuer_hit_n)), -1,
"Failed to memset memory for issuer\n");
HIP_IFEL(!memset(subject_hit, '\0', sizeof(subject_hit)), -1,
@@ -1016,7 +1012,7 @@
{
int err = 0;
struct hip_cert_x509_resp verify;
- struct hip_cert_x509_resp *p;
+ const struct hip_cert_x509_resp *p;
X509 *cert = NULL;
X509_STORE *store = NULL;
X509_STORE_CTX *verify_ctx = NULL;
=== modified file 'hipd/close.c'
--- hipd/close.c 2010-08-02 07:51:03 +0000
+++ hipd/close.c 2010-08-19 09:32:20 +0000
@@ -172,7 +172,7 @@
{
int err = 0, retry, n;
char *opaque = NULL;
- hip_hit_t *hit = NULL;
+ const hip_hit_t *hit = NULL;
struct sockaddr_in6 sock_addr;
struct hip_common *msg_to_firewall = NULL;
@@ -308,7 +308,7 @@
struct hip_packet_context *ctx)
{
int err = 0, echo_len;
- struct hip_echo_request *request;
+ const struct hip_echo_request *request;
HIP_IFE(!(ctx->output_msg = hip_msg_alloc()), -ENOMEM);
@@ -432,7 +432,7 @@
struct hip_packet_context *ctx)
{
int err = 0;
- struct hip_echo_request *echo_resp = NULL;
+ const struct hip_echo_request *echo_resp = NULL;
#ifdef CONFIG_HIP_PERFORMANCE
HIP_DEBUG("Start PERF_HANDLE_CLOSE_ACK\n");
=== modified file 'hipd/cookie.c'
--- hipd/cookie.c 2010-08-17 17:23:18 +0000
+++ hipd/cookie.c 2010-08-19 09:32:20 +0000
@@ -96,8 +96,8 @@
*/
int hip_get_puzzle_difficulty_msg(struct hip_common *msg)
{
- int err = 0, diff = 0;
- hip_hit_t *dst_hit = NULL;
+ int err = 0, diff = 0;
+ const hip_hit_t *dst_hit = NULL;
hip_hit_t all_zero_hit;
bzero(&all_zero_hit, sizeof(all_zero_hit));
@@ -121,8 +121,9 @@
*/
int hip_set_puzzle_difficulty_msg(struct hip_common *msg)
{
- int err = 0, *newVal = NULL;
- hip_hit_t *dst_hit = NULL;
+ int err = 0;
+ const int *newVal = NULL;
+ const hip_hit_t *dst_hit = NULL;
hip_hit_t all_zero_hit;
bzero(&all_zero_hit, sizeof(all_zero_hit));
@@ -322,16 +323,16 @@
* otherwise.
*/
int hip_verify_cookie(struct in6_addr *ip_i, struct in6_addr *ip_r,
- hip_common_t *hdr, struct hip_solution *solution)
+ hip_common_t *hdr, const struct hip_solution *solution)
{
/* In a effort to conform the HIPL coding convention, the return value
* of this function was inverted. I.e. This function now returns
* negative for error conditions, zero otherwise. It used to be the
* other way around. -Lauri 23.07.2008. */
- struct hip_puzzle *puzzle = NULL;
- struct hip_r1entry *result = NULL;
- struct hip_host_id_entry *hid = NULL;
- int err = 0;
+ const struct hip_puzzle *puzzle = NULL;
+ struct hip_r1entry *result = NULL;
+ struct hip_host_id_entry *hid = NULL;
+ int err = 0;
/* Find the proper R1 table */
HIP_IFEL(!(hid = hip_get_hostid_entry_by_lhi_and_algo(
=== modified file 'hipd/cookie.h'
--- hipd/cookie.h 2010-08-17 17:23:18 +0000
+++ hipd/cookie.h 2010-08-19 09:32:20 +0000
@@ -54,7 +54,7 @@
void *privkey,
struct hip_host_id *pubkey);
int hip_verify_cookie(struct in6_addr *ip_i, struct in6_addr *ip_r, hip_common_t *hdr,
- struct hip_solution *cookie);
+ const struct hip_solution *cookie);
int hip_inc_cookie_difficulty(void);
int hip_dec_cookie_difficulty(void);
int hip_get_puzzle_difficulty_msg(struct hip_common *msg);
=== modified file 'hipd/esp_prot_anchordb.c'
--- hipd/esp_prot_anchordb.c 2010-08-18 17:57:40 +0000
+++ hipd/esp_prot_anchordb.c 2010-08-19 09:32:20 +0000
@@ -106,9 +106,9 @@
*/
int anchor_db_update(const struct hip_common *msg)
{
- struct hip_tlv_common *param = NULL;
- unsigned char *anchor = NULL;
- int err = 0, i, j;
+ const struct hip_tlv_common *param = NULL;
+ const unsigned char *anchor = NULL;
+ int err = 0, i, j;
uint8_t esp_transforms[MAX_NUM_TRANSFORMS];
HIP_ASSERT(msg != NULL);
@@ -131,17 +131,20 @@
// don't set up anything for UNUSED transform
for (i = 0; i < esp_prot_num_transforms - 1; i++) {
// needed for redirection to correct slot in anchor_db
- esp_transforms[i] = *(uint8_t *) hip_get_param_contents_direct(param);
+ esp_transforms[i] = *(const uint8_t *)
+ hip_get_param_contents_direct(param);
HIP_DEBUG("esp_transform is %u\n", esp_transforms[i]);
HIP_IFEL(!(param = hip_get_next_param(msg, param)),
-1, "parameter missing in user-message from fw\n");
- anchor_db.num_anchors[esp_transforms[i]] = *(int *) hip_get_param_contents_direct(param);
+ anchor_db.num_anchors[esp_transforms[i]] = *(const int *)
+ hip_get_param_contents_direct(param);
HIP_DEBUG("num_anchors is %i\n", anchor_db.num_anchors[esp_transforms[i]]);
HIP_IFEL(!(param = hip_get_next_param(msg, param)),
-1, "parameter missing in user-message from fw\n");
- anchor_db.anchor_lengths[esp_transforms[i]] = *(int *) hip_get_param_contents_direct(param);
+ anchor_db.anchor_lengths[esp_transforms[i]] = *(const int *)
+ hip_get_param_contents_direct(param);
HIP_DEBUG("anchor_length is %i\n", anchor_db.anchor_lengths[esp_transforms[i]]);
HIP_IFEL(!(param = hip_get_next_param(msg, param)),
@@ -164,8 +167,8 @@
HIP_IFEL(!(param = hip_get_next_param(msg, param)),
-1, "parameter missing in user-message from fw\n");
- anchor_db.hash_item_length[esp_transforms[i]] = *(int *)
- hip_get_param_contents_direct(param);
+ anchor_db.hash_item_length[esp_transforms[i]] = *(const int *)
+ hip_get_param_contents_direct(param);
HIP_DEBUG("adding hash_item_length: %i\n",
anchor_db.hash_item_length[esp_transforms[i]]);
=== modified file 'hipd/esp_prot_hipd_msg.c'
--- hipd/esp_prot_hipd_msg.c 2010-08-18 17:57:40 +0000
+++ hipd/esp_prot_hipd_msg.c 2010-08-19 09:32:20 +0000
@@ -73,7 +73,7 @@
const uint32_t spi)
{
hip_common_t *resp_update = NULL;
- struct hip_seq *seq = NULL;
+ const struct hip_seq *seq = NULL;
uint16_t mask = 0;
int err = 0;
@@ -172,26 +172,30 @@
*/
int esp_prot_set_preferred_transforms(const struct hip_common *msg)
{
- struct hip_tlv_common *param = NULL;
- int err = 0, i;
+ const struct hip_tlv_common *param = NULL;
+ int err = 0, i;
param = hip_get_param(msg, HIP_PARAM_INT);
- esp_prot_active = *((int *) hip_get_param_contents_direct(param));
+ esp_prot_active = *((const int *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("esp_prot_active: %i\n", esp_prot_active);
// process message and store the preferred transforms
param = hip_get_next_param(msg, param);
- esp_prot_num_transforms = *((int *) hip_get_param_contents_direct(param));
+ esp_prot_num_transforms = *((const int *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("esp protection num_transforms: %i\n", esp_prot_num_transforms);
param = hip_get_next_param(msg, param);
- esp_prot_num_parallel_hchains = *((long *) hip_get_param_contents_direct(param));
+ esp_prot_num_parallel_hchains = *((const long *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("esp_prot_num_parallel_hchains: %i\n", esp_prot_num_parallel_hchains);
for (i = 0; i < MAX_NUM_TRANSFORMS; i++) {
if (i < esp_prot_num_transforms) {
param = hip_get_next_param(msg, param);
- esp_prot_transforms[i] = *((uint8_t *) hip_get_param_contents_direct(param));
+ esp_prot_transforms[i] = *((const uint8_t *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("esp protection transform %i: %u\n", i + 1, esp_prot_transforms[i]);
} else {
esp_prot_transforms[i] = 0;
@@ -224,24 +228,24 @@
*/
int esp_prot_handle_trigger_update_msg(const struct hip_common *msg)
{
- struct hip_tlv_common *param = NULL;
- hip_hit_t *local_hit = NULL, *peer_hit = NULL;
- uint8_t esp_prot_tfm = 0;
- int hash_length = 0;
- unsigned char *esp_prot_anchor = NULL;
- int soft_update = 0;
+ const struct hip_tlv_common *param = NULL;
+ const hip_hit_t *local_hit = NULL, *peer_hit = NULL;
+ uint8_t esp_prot_tfm = 0;
+ int hash_length = 0;
+ const unsigned char *esp_prot_anchor = NULL;
+ int soft_update = 0;
int anchor_offset[MAX_NUM_PARALLEL_HCHAINS];
int secret_length[MAX_NUM_PARALLEL_HCHAINS];
int branch_length[MAX_NUM_PARALLEL_HCHAINS];
- int root_length = 0;
- unsigned char *secret[MAX_NUM_PARALLEL_HCHAINS];
- unsigned char *branch_nodes[MAX_NUM_PARALLEL_HCHAINS];
- unsigned char *root[MAX_NUM_PARALLEL_HCHAINS];
- hip_ha_t *entry = NULL;
- int hash_item_length = 0;
+ int root_length = 0;
+ const unsigned char *secret[MAX_NUM_PARALLEL_HCHAINS];
+ const unsigned char *branch_nodes[MAX_NUM_PARALLEL_HCHAINS];
+ const unsigned char *root[MAX_NUM_PARALLEL_HCHAINS];
+ hip_ha_t *entry = NULL;
+ int hash_item_length = 0;
unsigned char cmp_val[MAX_HASH_LENGTH];
- int err = 0;
- long num_parallel_hchains = 0, i;
+ int err = 0;
+ long num_parallel_hchains = 0, i;
memset(cmp_val, 0, MAX_HASH_LENGTH);
@@ -258,7 +262,8 @@
"failed to retrieve requested HA entry\n");
param = hip_get_param(msg, HIP_PARAM_ESP_PROT_TFM);
- esp_prot_tfm = *((uint8_t *) hip_get_param_contents_direct(param));
+ esp_prot_tfm = *((const uint8_t *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("esp_prot_transform: %u\n", esp_prot_tfm);
// check if transforms are matching and add anchor as new local_anchor
@@ -267,7 +272,8 @@
HIP_DEBUG("esp prot transforms match\n");
param = hip_get_param(msg, HIP_PARAM_INT);
- hash_item_length = *((int *) hip_get_param_contents_direct(param));
+ hash_item_length = *((const int *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("hash_item_length: %i\n", hash_item_length);
// set the hash_item_length of the item used for this update
@@ -277,7 +283,8 @@
hash_length = anchor_db_get_anchor_length(entry->esp_prot_transform);
param = hip_get_next_param(msg, param);
- num_parallel_hchains = *((long *) hip_get_param_contents_direct(param));
+ num_parallel_hchains = *((const long *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("num_parallel_hchains: %i\n", num_parallel_hchains);
// process all update anchors now
@@ -298,7 +305,8 @@
param = hip_get_next_param(msg, param);
}
- root_length = *((int *) hip_get_param_contents_direct(param));
+ root_length = *((const int *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("root_length: %i\n", root_length);
entry->esp_root_length = root_length;
@@ -315,21 +323,24 @@
}
}
- soft_update = *((int *) hip_get_param_contents_direct(param));
+ soft_update = *((const int *) hip_get_param_contents_direct(param));
HIP_DEBUG("soft_update: %i\n", soft_update);
if (soft_update) {
for (i = 0; i < num_parallel_hchains; i++) {
param = hip_get_next_param(msg, param);
- anchor_offset[i] = *((int *) hip_get_param_contents_direct(param));
+ anchor_offset[i] = *((const int *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("anchor_offset: %i\n", anchor_offset[i]);
param = hip_get_next_param(msg, param);
- secret_length[i] = *((int *) hip_get_param_contents_direct(param));
+ secret_length[i] = *((const int *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("secret_length: %i\n", secret_length[i]);
param = hip_get_next_param(msg, param);
- branch_length[i] = *((int *) hip_get_param_contents_direct(param));
+ branch_length[i] = *((const int *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("branch_length: %i\n", branch_length[i]);
param = hip_get_next_param(msg, param);
@@ -371,15 +382,15 @@
*/
int esp_prot_handle_anchor_change_msg(const struct hip_common *msg)
{
- struct hip_tlv_common *param = NULL;
- hip_hit_t *local_hit = NULL, *peer_hit = NULL;
- uint8_t esp_prot_tfm = 0;
- int hash_length = 0;
- unsigned char *esp_prot_anchor = NULL;
- hip_ha_t *entry = NULL;
- int direction = 0;
- long num_parallel_hchains = 0, i;
- int err = 0;
+ const struct hip_tlv_common *param = NULL;
+ const hip_hit_t *local_hit = NULL, *peer_hit = NULL;
+ uint8_t esp_prot_tfm = 0;
+ int hash_length = 0;
+ const unsigned char *esp_prot_anchor = NULL;
+ hip_ha_t *entry = NULL;
+ int direction = 0;
+ long num_parallel_hchains = 0, i;
+ int err = 0;
param = hip_get_param(msg, HIP_PARAM_HIT);
local_hit = hip_get_param_contents_direct(param);
@@ -390,15 +401,18 @@
HIP_DEBUG_HIT("dst_hit", peer_hit);
param = hip_get_param(msg, HIP_PARAM_INT);
- direction = *((int *) hip_get_param_contents_direct(param));
+ direction = *((const int *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("direction: %i\n", direction);
param = hip_get_param(msg, HIP_PARAM_ESP_PROT_TFM);
- esp_prot_tfm = *((uint8_t *) hip_get_param_contents_direct(param));
+ esp_prot_tfm = *((const uint8_t *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("esp_prot_transform: %u\n", esp_prot_tfm);
param = hip_get_param(msg, HIP_PARAM_INT);
- num_parallel_hchains = *((long *) hip_get_param_contents_direct(param));
+ num_parallel_hchains = *((const long *)
+ hip_get_param_contents_direct(param));
HIP_DEBUG("num_parallel_hchains: %u\n", num_parallel_hchains);
param = hip_get_param(msg, HIP_PARAM_HCHAIN_ANCHOR);
@@ -566,26 +580,24 @@
*/
int esp_prot_r1_handle_transforms(struct hip_packet_context *ctx)
{
- struct hip_param *param = NULL;
- struct esp_prot_preferred_tfms *prot_transforms = NULL;
- int err = 0;
+ const struct esp_prot_preferred_tfms *prot_transforms = NULL;
+ int err = 0;
/* this is only handled if we are using userspace ipsec,
* otherwise we just ignore it */
if (hip_use_userspace_ipsec) {
HIP_DEBUG("userspace IPsec hint: ESP extension might be in use\n");
- param = hip_get_param(ctx->input_msg, HIP_PARAM_ESP_PROT_TRANSFORMS);
+ prot_transforms = hip_get_param(ctx->input_msg,
+ HIP_PARAM_ESP_PROT_TRANSFORMS);
// check if the transform parameter was sent
- if (param) {
+ if (prot_transforms) {
HIP_DEBUG("received preferred transforms from peer\n");
// store that we received the param for further processing
ctx->hadb_entry->esp_prot_param = 1;
- prot_transforms = (struct esp_prot_preferred_tfms *) param;
-
// select transform and store it for this connection
ctx->hadb_entry->esp_prot_transform = esp_prot_select_transform(prot_transforms->num_transforms,
prot_transforms->transforms);
@@ -693,17 +705,17 @@
*/
int esp_prot_i2_handle_anchor(struct hip_packet_context *ctx)
{
- struct hip_tlv_common *param = NULL;
- struct esp_prot_anchor *prot_anchor = NULL;
- int hash_length = 0;
- int err = 0, i;
+ const struct hip_tlv_common *param = NULL;
+ const struct esp_prot_anchor *prot_anchor = NULL;
+ int hash_length = 0;
+ int err = 0, i;
/* only supported in user-mode ipsec and optional there */
if (hip_use_userspace_ipsec && esp_prot_num_transforms > 1) {
HIP_DEBUG("userspace IPsec hint: esp protection extension might be in use\n");
if ((param = hip_get_param(ctx->input_msg, HIP_PARAM_ESP_PROT_ANCHOR))) {
- prot_anchor = (struct esp_prot_anchor *) param;
+ prot_anchor = (const struct esp_prot_anchor *) param;
// check if the anchor has a supported transform
if (esp_prot_check_transform(esp_prot_num_transforms, esp_prot_transforms,
@@ -740,7 +752,7 @@
// get next anchor
param = hip_get_next_param(ctx->input_msg, param);
- prot_anchor = (struct esp_prot_anchor *) param;
+ prot_anchor = (const struct esp_prot_anchor *) param;
}
} else {
HIP_ERROR("received anchor with unknown transform, falling back\n");
@@ -836,15 +848,15 @@
int esp_prot_r2_handle_anchor(hip_ha_t *entry,
const struct hip_common *input_msg)
{
- struct hip_tlv_common *param = NULL;
- struct esp_prot_anchor *prot_anchor = NULL;
- int hash_length = 0;
- int err = 0, i;
+ const struct hip_tlv_common *param = NULL;
+ const struct esp_prot_anchor *prot_anchor = NULL;
+ int hash_length = 0;
+ int err = 0, i;
// only process anchor, if we agreed on using it before
if (entry->esp_prot_transform > ESP_PROT_TFM_UNUSED) {
if ((param = hip_get_param(input_msg, HIP_PARAM_ESP_PROT_ANCHOR))) {
- prot_anchor = (struct esp_prot_anchor *) param;
+ prot_anchor = (const struct esp_prot_anchor *) param;
// check if the anchor has got the negotiated transform
if (prot_anchor->transform == entry->esp_prot_transform) {
@@ -871,7 +883,7 @@
// get next anchor
param = hip_get_next_param(input_msg, param);
- prot_anchor = (struct esp_prot_anchor *) param;
+ prot_anchor = (const struct esp_prot_anchor *) param;
}
} else if (prot_anchor->transform == ESP_PROT_TFM_UNUSED) {
HIP_DEBUG("peer encountered problems and did fallback\n");
@@ -909,9 +921,9 @@
*/
int esp_prot_update_type(const hip_common_t *recv_update)
{
- struct hip_seq * seq = NULL;
- struct hip_ack * ack = NULL;
- struct hip_esp_info * esp_info = NULL;
+ const struct hip_seq * seq = NULL;
+ const struct hip_ack * ack = NULL;
+ const struct hip_esp_info * esp_info = NULL;
HIP_ASSERT(recv_update != NULL);
@@ -1017,9 +1029,9 @@
*/
int esp_prot_update_add_anchor(hip_common_t *update, hip_ha_t *entry)
{
- struct hip_seq *seq = NULL;
- int hash_length = 0;
- int err = 0, i;
+ const struct hip_seq *seq = NULL;
+ int hash_length = 0;
+ int err = 0, i;
// only do further processing when extension is in use
if (entry->esp_prot_transform > ESP_PROT_TFM_UNUSED) {
@@ -1085,18 +1097,18 @@
hip_ha_t *entry,
uint32_t *spi)
{
- struct esp_prot_anchor *prot_anchor = NULL;
- struct hip_tlv_common *param = NULL;
- int hash_length = 0;
+ const struct esp_prot_anchor *prot_anchor = NULL;
+ const struct hip_tlv_common *param = NULL;
+ int hash_length = 0;
unsigned char cmp_value[MAX_HASH_LENGTH];
- int err = 0, i;
+ int err = 0, i;
HIP_ASSERT(spi != NULL);
*spi = 0;
param = hip_get_param(recv_update, HIP_PARAM_ESP_PROT_ANCHOR);
- prot_anchor = (struct esp_prot_anchor *) param;
+ prot_anchor = (const struct esp_prot_anchor *) param;
if (prot_anchor) {
/* XX TODO find matching SA entry in host association for active_anchor
@@ -1131,8 +1143,8 @@
HIP_DEBUG("entry->esp_peer_update_length: %u\n",
entry->esp_peer_update_length);
- param = hip_get_next_param(recv_update, param);
- prot_anchor = (struct esp_prot_anchor *) param;
+ param = hip_get_next_param(recv_update, param);
+ prot_anchor = (const struct esp_prot_anchor *) param;
}
} else if (!memcmp(&entry->esp_peer_update_anchors[0][0], &prot_anchor->anchors[0],
hash_length)) {
@@ -1156,12 +1168,12 @@
HIP_DEBUG("entry->esp_peer_update_length: %u\n",
entry->esp_peer_update_length);
- param = hip_get_next_param(recv_update, param);
- prot_anchor = (struct esp_prot_anchor *) param;
+ param = hip_get_next_param(recv_update, param);
+ prot_anchor = (const struct esp_prot_anchor *) param;
}
} else {
for (i = 0; i < esp_prot_num_parallel_hchains; i++) {
- prot_anchor = (struct esp_prot_anchor *) param;
+ prot_anchor = (const struct esp_prot_anchor *) param;
HIP_IFEL(memcmp(&prot_anchor->anchors[0], &entry->esp_peer_anchors[i][0],
hash_length), -1, "received unverifiable anchor\n");
=== modified file 'hipd/esp_prot_light_update.c'
--- hipd/esp_prot_light_update.c 2010-08-17 17:23:18 +0000
+++ hipd/esp_prot_light_update.c 2010-08-19 09:32:20 +0000
@@ -115,9 +115,9 @@
*/
int esp_prot_send_light_update(hip_ha_t *entry,
const int anchor_offset[],
- unsigned char *secret[MAX_NUM_PARALLEL_HCHAINS],
+ const unsigned char *secret[MAX_NUM_PARALLEL_HCHAINS],
const int secret_length[],
- unsigned char *branch_nodes[MAX_NUM_PARALLEL_HCHAINS],
+ const unsigned char *branch_nodes[MAX_NUM_PARALLEL_HCHAINS],
const int branch_length[])
{
hip_common_t *light_update = NULL;
@@ -218,12 +218,12 @@
UNUSED const uint32_t ha_state,
struct hip_packet_context *ctx)
{
- struct hip_seq *seq = NULL;
- struct hip_ack *ack = NULL;
- uint32_t seq_no = 0;
- uint32_t ack_no = 0;
- uint32_t spi = 0;
- int err = 0;
+ const struct hip_seq *seq = NULL;
+ const struct hip_ack *ack = NULL;
+ uint32_t seq_no = 0;
+ uint32_t ack_no = 0;
+ uint32_t spi = 0;
+ int err = 0;
HIP_IFEL(!ctx->hadb_entry, -1,
"No entry in host association database when receiving " \
=== modified file 'hipd/esp_prot_light_update.h'
--- hipd/esp_prot_light_update.h 2010-07-04 17:54:18 +0000
+++ hipd/esp_prot_light_update.h 2010-08-19 09:32:20 +0000
@@ -41,9 +41,9 @@
int esp_prot_send_light_update(hip_ha_t *entry,
const int anchor_offset[],
- unsigned char *secret[MAX_NUM_PARALLEL_HCHAINS],
+ const unsigned char *secret[MAX_NUM_PARALLEL_HCHAINS],
const int secret_length[],
- unsigned char *branch_nodes[MAX_NUM_PARALLEL_HCHAINS],
+ const unsigned char *branch_nodes[MAX_NUM_PARALLEL_HCHAINS],
const int branch_length[]);
int esp_prot_handle_light_update(const uint8_t packet_type,
const uint32_t ha_state,
=== modified file 'hipd/hadb.c'
--- hipd/hadb.c 2010-08-17 17:23:18 +0000
+++ hipd/hadb.c 2010-08-19 09:32:20 +0000
@@ -560,8 +560,10 @@
* @param peer_hostname an optional host name for the remote host
* @return zero on success or negative on error
*/
-int hip_hadb_add_peer_info(hip_hit_t *peer_hit, struct in6_addr *peer_addr,
- hip_lsi_t *peer_lsi, const char *peer_hostname)
+int hip_hadb_add_peer_info(const hip_hit_t *peer_hit,
+ const struct in6_addr *peer_addr,
+ const hip_lsi_t *peer_lsi,
+ const char *peer_hostname)
{
int err = 0;
struct hip_peer_map_info peer_map;
@@ -618,22 +620,18 @@
*/
int hip_add_peer_map(const struct hip_common *input)
{
- struct in6_addr *hit = NULL, *ip = NULL;
- hip_lsi_t *lsi = NULL;
- char *peer_hostname = NULL;
- int err = 0;
-
- hit = (struct in6_addr *)
- hip_get_param_contents(input, HIP_PARAM_HIT);
-
- lsi = (hip_lsi_t *)
- hip_get_param_contents(input, HIP_PARAM_LSI);
-
- ip = (struct in6_addr *)
- hip_get_param_contents(input, HIP_PARAM_IPV6_ADDR);
-
- peer_hostname = (char *)
- hip_get_param_contents(input, HIP_PARAM_HOSTNAME);
+ const struct in6_addr *hit = NULL, *ip = NULL;
+ const hip_lsi_t *lsi = NULL;
+ const char *peer_hostname = NULL;
+ int err = 0;
+
+ hit = hip_get_param_contents(input, HIP_PARAM_HIT);
+
+ lsi = hip_get_param_contents(input, HIP_PARAM_LSI);
+
+ ip = hip_get_param_contents(input, HIP_PARAM_IPV6_ADDR);
+
+ peer_hostname = hip_get_param_contents(input, HIP_PARAM_HOSTNAME);
if (!ip && (!lsi || !hit)) {
HIP_ERROR("handle async map: no ip and maybe no lsi or hit\n");
@@ -965,7 +963,7 @@
* @return zero on success and negative on error
*/
int hip_init_peer(hip_ha_t *entry,
- struct hip_host_id *peer)
+ const struct hip_host_id *peer)
{
int err = 0;
int len = hip_get_param_total_len(peer);
@@ -1334,8 +1332,8 @@
* a matching host association was not found.
* @author Miika Komu
*/
-hip_ha_t *hip_hadb_find_rvs_candidate_entry(hip_hit_t *local_hit,
- hip_hit_t *rvs_ip)
+hip_ha_t *hip_hadb_find_rvs_candidate_entry(const hip_hit_t *local_hit,
+ const hip_hit_t *rvs_ip)
{
int i = 0;
hip_ha_t *this = NULL, *result = NULL;
@@ -1478,7 +1476,7 @@
* @param lsi_dst the remote LSI
* @return the HADB entry or NULL if not found
*/
-hip_ha_t *hip_hadb_try_to_find_by_peer_lsi(hip_lsi_t *lsi_dst)
+hip_ha_t *hip_hadb_try_to_find_by_peer_lsi(const hip_lsi_t *lsi_dst)
{
hip_list_t *item, *aux;
hip_ha_t *tmp;
=== modified file 'hipd/hadb.h'
--- hipd/hadb.h 2010-08-17 17:23:18 +0000
+++ hipd/hadb.h 2010-08-19 09:32:20 +0000
@@ -74,7 +74,7 @@
/* insert/create/delete */
int hip_hadb_insert_state(hip_ha_t *ha);
void hip_delete_security_associations_and_sp(struct hip_hadb_state *ha);
-int hip_init_peer(hip_ha_t *entry, struct hip_host_id *peer);
+int hip_init_peer(hip_ha_t *entry, const struct hip_host_id *peer);
int hip_init_us(hip_ha_t *entry, hip_hit_t *hit_our);
@@ -87,9 +87,9 @@
int hip_add_peer_map(const struct hip_common *input);
-int hip_hadb_add_peer_info(hip_hit_t *hit,
- struct in6_addr *addr,
- hip_lsi_t *peer_lsi,
+int hip_hadb_add_peer_info(const hip_hit_t *peer_hit,
+ const struct in6_addr *peer_addr,
+ const hip_lsi_t *peer_lsi,
const char *peer_hostname);
int hip_hadb_add_peer_info_complete(const hip_hit_t *local_hit,
@@ -119,13 +119,14 @@
int hip_count_open_connections(void);
-hip_ha_t *hip_hadb_find_rvs_candidate_entry(hip_hit_t *, hip_hit_t *);
+hip_ha_t *hip_hadb_find_rvs_candidate_entry(const hip_hit_t *,
+ const hip_hit_t *);
int hip_handle_get_ha_info(hip_ha_t *entry, void *);
/*lsi support functions*/
int hip_generate_peer_lsi(hip_lsi_t *lsi);
-hip_ha_t *hip_hadb_try_to_find_by_peer_lsi(hip_lsi_t *lsi);
+hip_ha_t *hip_hadb_try_to_find_by_peer_lsi(const hip_lsi_t *lsi);
hip_ha_t *hip_hadb_try_to_find_by_pair_lsi(hip_lsi_t *lsi_src, hip_lsi_t *lsi_dst);
int hip_recreate_security_associations_and_sp(struct hip_hadb_state *ha,
=== modified file 'hipd/hidb.c'
--- hipd/hidb.c 2010-07-29 10:40:44 +0000
+++ hipd/hidb.c 2010-08-19 09:32:20 +0000
@@ -519,11 +519,11 @@
*/
int hip_handle_add_local_hi(const struct hip_common *input)
{
- int err = 0;
- struct hip_host_id_priv *host_identity = NULL;
+ int err = 0;
+ const struct hip_host_id_priv *host_identity = NULL;
struct hip_lhi lhi;
- struct hip_tlv_common *param = NULL;
- struct hip_eid_endpoint *eid_endpoint = NULL;
+ const struct hip_tlv_common *param = NULL;
+ const struct hip_eid_endpoint *eid_endpoint = NULL;
struct in6_addr in6_lsi;
hip_lsi_t lsi;
@@ -544,7 +544,7 @@
}
HIP_DEBUG("host id found in the msg\n");
- eid_endpoint = (struct hip_eid_endpoint *) param;
+ eid_endpoint = (const struct hip_eid_endpoint *) param;
HIP_IFEL(!eid_endpoint, -ENOENT, "No host endpoint in input\n");
@@ -600,13 +600,12 @@
*/
int hip_handle_del_local_hi(const struct hip_common *input)
{
- struct in6_addr *hit;
+ const struct in6_addr *hit;
struct hip_lhi lhi;
char buf[46];
int err = 0;
- hit = (struct in6_addr *)
- hip_get_param_contents(input, HIP_PARAM_HIT);
+ hit = hip_get_param_contents(input, HIP_PARAM_HIT);
HIP_IFEL(!hit, -ENODATA, "no hit\n");
hip_in6_ntop(hit, buf);
=== modified file 'hipd/hiprelay.c'
--- hipd/hiprelay.c 2010-08-18 16:30:31 +0000
+++ hipd/hiprelay.c 2010-08-19 09:32:20 +0000
@@ -893,10 +893,10 @@
hip_relrec_t *rec,
const uint8_t type_hdr)
{
- hip_common_t *msg_to_be_relayed = NULL;
- hip_tlv_common_t *current_param = NULL;
- int err = 0, from_added = 0;
- hip_tlv_type_t param_type = 0;
+ hip_common_t *msg_to_be_relayed = NULL;
+ const hip_tlv_common_t *current_param = NULL;
+ int err = 0, from_added = 0;
+ hip_tlv_type_t param_type = 0;
HIP_DEBUG("Msg type : %s (%d)\n",
hip_message_type_name(hip_get_msg_type(ctx->input_msg)),
@@ -1020,9 +1020,9 @@
const struct in6_addr *relay_to_addr,
const in_port_t relay_to_port)
{
- struct hip_common *r_to_be_relayed = NULL;
- struct hip_tlv_common *current_param = NULL;
- int err = 0;
+ struct hip_common *r_to_be_relayed = NULL;
+ const struct hip_tlv_common *current_param = NULL;
+ int err = 0;
HIP_DEBUG_IN6ADDR("hip_relay_forward_response: source address", r_saddr);
HIP_DEBUG_IN6ADDR("hip_relay_forward_response: destination address", r_daddr);
@@ -1079,7 +1079,7 @@
{
int err = 0;
hip_relrec_t *rec = NULL, dummy;
- struct hip_relay_to *relay_to;
+ const struct hip_relay_to *relay_to;
//check if full relay service is active
if (hip_relay_get_status() == HIP_RELAY_OFF) {
@@ -1118,15 +1118,14 @@
case HIP_R2:
case HIP_UPDATE:
case HIP_NOTIFY:
- HIP_DEBUG_IN6ADDR("the relay to address: ",
- (struct in6_addr *) &relay_to->address);
+ HIP_DEBUG_IN6ADDR("the relay to address: ", &relay_to->address);
HIP_DEBUG("the relay to ntohs(port): %d",
ntohs(relay_to->port));
hip_relay_forward_response(ctx->input_msg,
packet_type,
ctx->src_addr,
ctx->dst_addr,
- (struct in6_addr *) &relay_to->address,
+ &relay_to->address,
ntohs(relay_to->port));
// state = HIP_STATE_NONE;
err = 1;
@@ -1146,14 +1145,13 @@
*
* @todo handle also the relay case
*/
-int hip_relay_add_rvs_to_ha(hip_common_t *source_msg, hip_ha_t *entry)
+int hip_relay_add_rvs_to_ha(const hip_common_t *source_msg, hip_ha_t *entry)
{
- struct hip_via_rvs *via_rvs = NULL;
+ const struct hip_via_rvs *via_rvs = NULL;
int err = 0;
// Get rendezvous server's IP addresses
- via_rvs = (struct hip_via_rvs *)
- hip_get_param(source_msg, HIP_PARAM_VIA_RVS);
+ via_rvs = hip_get_param(source_msg, HIP_PARAM_VIA_RVS);
if (!via_rvs) {
return -1;
@@ -1191,10 +1189,10 @@
struct in6_addr *dest_ip, in_port_t *dest_port)
{
int param_type;
- struct hip_relay_from *relay_from = NULL;
- struct hip_from *from = NULL;
+ const struct hip_relay_from *relay_from = NULL;
+ const struct hip_from *from = NULL;
#ifdef CONFIG_HIP_RVS
- hip_ha_t *relay_ha_entry = NULL;
+ hip_ha_t *relay_ha_entry = NULL;
#endif
/* Check if the incoming I1 packet has RELAY_FROM parameters. */
@@ -1292,7 +1290,7 @@
struct hip_packet_context *ctx)
{
int err = 0;
- struct hip_relay_to *relay_to;
+ const struct hip_relay_to *relay_to;
//check if full relay service is active
if (!ctx->hadb_entry) {
@@ -1312,13 +1310,11 @@
switch (packet_type) {
case HIP_R1:
case HIP_R2:
- HIP_DEBUG_IN6ADDR("the relay to address: ",
- (struct in6_addr *) &relay_to->address);
+ HIP_DEBUG_IN6ADDR("the relay to address: ", &relay_to->address);
HIP_DEBUG("the relay to ntohs(port): %d, local udp port %d\n",
ntohs(relay_to->port), ctx->hadb_entry->local_udp_port);
- if (ipv6_addr_cmp((struct in6_addr *) &relay_to->address,
- &ctx->hadb_entry->our_addr)) {
+ if (ipv6_addr_cmp(&relay_to->address, &ctx->hadb_entry->our_addr)) {
HIP_DEBUG("relay_to address is saved as reflexive addr. \n");
ctx->hadb_entry->local_reflexive_udp_port = ntohs(relay_to->port);
memcpy(&ctx->hadb_entry->local_reflexive_address,
=== modified file 'hipd/hiprelay.h'
--- hipd/hiprelay.h 2010-08-17 17:23:18 +0000
+++ hipd/hiprelay.h 2010-08-19 09:32:20 +0000
@@ -114,7 +114,7 @@
hip_relay_wl_status_t hip_relwl_get_status(void);
int hip_rvs_validate_lifetime(uint8_t requested_lifetime,
uint8_t *granted_lifetime);
-int hip_relay_add_rvs_to_ha(hip_common_t *source_msg, hip_ha_t *entry);
+int hip_relay_add_rvs_to_ha(const hip_common_t *source_msg, hip_ha_t *entry);
int hip_relay_handle_relay_from(hip_common_t *source_msg,
struct in6_addr *relay_ip,
struct in6_addr *dest_ip, in_port_t *dest_port);
=== modified file 'hipd/hit_to_ip.c'
--- hipd/hit_to_ip.c 2010-07-29 09:21:55 +0000
+++ hipd/hit_to_ip.c 2010-08-19 09:32:20 +0000
@@ -147,7 +147,7 @@
* @return 0 on success, -1 otherwise
*/
-int hip_hit_to_ip(hip_hit_t *hit, struct in6_addr *retval)
+int hip_hit_to_ip(const hip_hit_t *hit, struct in6_addr *retval)
{
struct addrinfo *rp = NULL; // no C99 :(
char hit_to_ip_hostname[64 + HIT_TO_IP_ZONE_MAX_LEN + 1];
=== modified file 'hipd/hit_to_ip.h'
--- hipd/hit_to_ip.h 2010-07-07 16:42:17 +0000
+++ hipd/hit_to_ip.h 2010-08-19 09:32:20 +0000
@@ -37,7 +37,7 @@
#include "lib/core/protodefs.h"
-int hip_hit_to_ip(hip_hit_t *hit, struct in6_addr *retval);
+int hip_hit_to_ip(const hip_hit_t *hit, struct in6_addr *retval);
void hip_set_hit_to_ip_status(const int status);
int hip_get_hit_to_ip_status(void);
=== modified file 'hipd/input.c'
--- hipd/input.c 2010-08-18 16:37:11 +0000
+++ hipd/input.c 2010-08-19 09:32:20 +0000
@@ -99,7 +99,7 @@
* @note Fix the packet len before calling this function!
*/
static int hip_verify_hmac(struct hip_common *buffer, uint16_t buf_len,
- uint8_t *hmac, void *hmac_key, int hmac_type)
+ const uint8_t *hmac, void *hmac_key, int hmac_type)
{
int err = 0;
uint8_t hmac_res[HIP_AH_SHA_LEN];
@@ -134,7 +134,7 @@
{
int err = 0, len = 0, orig_len = 0;
struct hip_crypto_key tmpkey;
- struct hip_hmac *hmac = NULL;
+ const struct hip_hmac *hmac = NULL;
uint8_t orig_checksum = 0;
HIP_DEBUG("hip_verify_packet_hmac() invoked.\n");
@@ -150,7 +150,7 @@
orig_checksum = hip_get_msg_checksum(msg);
hip_zero_msg_checksum(msg);
- len = (uint8_t *) hmac - (uint8_t *) msg;
+ len = (const uint8_t *) hmac - (const uint8_t *) msg;
hip_set_msg_total_len(msg, len);
memcpy(&tmpkey, crypto_key, sizeof(tmpkey));
@@ -196,7 +196,7 @@
struct hip_host_id *host_id)
{
struct hip_crypto_key tmpkey;
- struct hip_hmac *hmac;
+ const struct hip_hmac *hmac;
struct hip_common *msg_copy = NULL;
int err = 0;
@@ -244,26 +244,28 @@
int auth_transf_length, esp_transf_length, we_are_HITg = 0;
int hip_tfm, esp_tfm, err = 0, dh_shared_len = 1024;
struct hip_keymat_keymat km;
- struct hip_esp_info *esp_info;
- char *keymat = NULL;
+ const struct hip_esp_info *esp_info;
+ char *keymat = NULL;
size_t keymat_len_min; /* how many bytes we need at least for the KEYMAT */
size_t keymat_len; /* note SHA boundary */
- struct hip_tlv_common *param = NULL;
+ const struct hip_tlv_common *param = NULL;
uint16_t esp_keymat_index, esp_default_keymat_index;
struct hip_diffie_hellman *dhf;
- struct in6_addr *plain_local_hit = NULL;
+ struct in6_addr *plain_local_hit = NULL;
/* Perform light operations first before allocating memory or
* using lots of CPU time */
HIP_IFEL(!(param = hip_get_param(ctx->input_msg, HIP_PARAM_HIP_TRANSFORM)),
-EINVAL,
"Could not find HIP transform\n");
- HIP_IFEL((hip_tfm = hip_select_hip_transform((struct hip_hip_transform *) param)) == 0,
+ HIP_IFEL((hip_tfm = hip_select_hip_transform(
+ (const struct hip_hip_transform *) param)) == 0,
-EINVAL, "Could not select HIP transform\n");
HIP_IFEL(!(param = hip_get_param(ctx->input_msg, HIP_PARAM_ESP_TRANSFORM)),
-EINVAL,
"Could not find ESP transform\n");
- HIP_IFEL((esp_tfm = hip_select_esp_transform((struct hip_esp_transform *) param)) == 0,
+ HIP_IFEL((esp_tfm = hip_select_esp_transform(
+ (const struct hip_esp_transform *) param)) == 0,
-EINVAL, "Could not select proper ESP transform\n");
hip_transf_length = hip_transform_key_length(hip_tfm);
@@ -327,7 +329,8 @@
memset(dh_shared_key, 0, dh_shared_len);
- HIP_IFEL(!(dhf = hip_get_param(ctx->input_msg, HIP_PARAM_DIFFIE_HELLMAN)),
+ HIP_IFEL(!(dhf = hip_get_param_readwrite(ctx->input_msg,
+ HIP_PARAM_DIFFIE_HELLMAN)),
-ENOENT, "No Diffie-Hellman parameter found.\n");
/* If the message has two DH keys, select (the stronger, usually) one. */
@@ -658,8 +661,8 @@
}
//TODO doxygen header missing
-static int handle_locator(struct hip_locator *locator,
- hip_ha_t *entry)
+static int handle_locator(const struct hip_locator *locator,
+ hip_ha_t *entry)
{
int n_addrs = 0, loc_size = 0, err = 0;
@@ -696,8 +699,8 @@
{
int err = 0, mask = HIP_PACKET_CTRL_ANON, len;
struct in6_addr daddr;
- struct hip_host_id *peer_host_id = NULL;
- const char *str = NULL;
+ const struct hip_host_id *peer_host_id = NULL;
+ const char *str = NULL;
#ifdef CONFIG_HIP_PERFORMANCE
HIP_DEBUG("Start PERF_R1\n");
@@ -824,11 +827,11 @@
{
int err = 0, retransmission = 0, written = 0;
uint64_t solved_puzzle = 0, I = 0;
- struct hip_puzzle *pz = NULL;
- struct hip_diffie_hellman *dh_req = NULL;
- struct hip_r1_counter *r1cntr = NULL;
- struct hip_dh_public_value *dhpv = NULL;
- struct hip_locator *locator = NULL;
+ const struct hip_puzzle *pz = NULL;
+ const struct hip_diffie_hellman *dh_req = NULL;
+ const struct hip_r1_counter *r1cntr = NULL;
+ struct hip_dh_public_value *dhpv = NULL;
+ const struct hip_locator *locator = NULL;
uint16_t i2_mask = 0;
HIP_DEBUG("Received R1 in state %s\n", hip_state_str(ha_state));
@@ -882,7 +885,7 @@
/* Solve puzzle: if this is a retransmission, we have to preserve
* the old solution. */
if (!retransmission) {
- struct hip_puzzle *pz2 = NULL;
+ const struct hip_puzzle *pz2 = NULL;
HIP_IFEL(!(pz2 = hip_get_param(ctx->input_msg, HIP_PARAM_PUZZLE)), -EINVAL,
"Malformed R1 packet. PUZZLE parameter missing\n");
@@ -1097,8 +1100,8 @@
{
int err = 0, tfm = 0, retransmission = 0, idx = 0;
uint32_t spi_recvd = 0, spi_in = 0;
- struct hip_esp_info *esp_info = NULL;
- struct hip_locator *locator = NULL;
+ const struct hip_esp_info *esp_info = NULL;
+ const struct hip_locator *locator = NULL;
struct hip_spi_out_item spi_out_data;
if (ha_state == HIP_STATE_ESTABLISHED) {
@@ -1422,13 +1425,14 @@
{
int err = 0, is_loopback = 0;
uint16_t mask = HIP_PACKET_CTRL_ANON, crypto_len = 0;
- char *tmp_enc = NULL, *enc = NULL;
- unsigned char *iv = NULL;
- struct hip_solution *solution = NULL;
- struct hip_dh_public_value *dhpv = NULL;
- struct hip_r1_counter *r1cntr = NULL;
- struct hip_hip_transform *hip_transform = NULL;
- struct hip_host_id *host_id_in_enc = NULL;
+ char *tmp_enc = NULL;
+ const char *enc = NULL;
+ unsigned char *iv = NULL;
+ const struct hip_solution *solution = NULL;
+ struct hip_dh_public_value *dhpv = NULL;
+ const struct hip_r1_counter *r1cntr = NULL;
+ const struct hip_hip_transform *hip_transform = NULL;
+ struct hip_host_id *host_id_in_enc = NULL;
#ifdef CONFIG_HIP_PERFORMANCE
HIP_DEBUG("Start PERF_I2\n");
hip_perf_start_benchmark(perf_set, PERF_I2);
@@ -1555,7 +1559,8 @@
enc = hip_get_param(ctx->input_msg, HIP_PARAM_ENCRYPTED);
if (enc == NULL) {
HIP_DEBUG("ENCRYPTED parameter missing from I2 packet\n");
- host_id_in_enc = hip_get_param(ctx->input_msg, HIP_PARAM_HOST_ID);
+ host_id_in_enc = hip_get_param_readwrite(ctx->input_msg,
+ HIP_PARAM_HOST_ID);
HIP_IFEL(!host_id_in_enc, -1, "No host id in i2");
} else {
/* Little workaround...
@@ -1729,14 +1734,14 @@
{
int err = 0, retransmission = 0;
uint32_t spi_out = 0;
- struct hip_esp_info *esp_info = NULL;
+ const struct hip_esp_info *esp_info = NULL;
hip_transform_suite_t esp_tfm;
struct hip_spi_in_item spi_in_data;
- struct hip_locator *locator = NULL;
+ const struct hip_locator *locator = NULL;
int if_index = 0;
struct sockaddr_storage ss_addr;
struct sockaddr *addr = NULL;
- struct hip_esp_transform *esp_tf = NULL;
+ const struct hip_esp_transform *esp_tf = NULL;
struct hip_spi_out_item spi_out_data;
/* Get the interface index of the network device which has our
@@ -1966,13 +1971,13 @@
struct hip_packet_context *ctx)
{
int err = 0;
- struct hip_tlv_common *current_param = NULL;
- struct hip_notification *notification = NULL;
+ const struct hip_tlv_common *current_param = NULL;
+ const struct hip_notification *notification = NULL;
struct in6_addr responder_ip, responder_hit;
- hip_tlv_type_t param_type = 0, response;
- hip_tlv_len_t param_len = 0;
- uint16_t msgtype = 0;
- in_port_t port = 0;
+ hip_tlv_type_t param_type = 0, response;
+ hip_tlv_len_t param_len = 0;
+ uint16_t msgtype = 0;
+ in_port_t port = 0;
/* Loop through all the parameters in the received packet. */
while ((current_param =
@@ -1982,7 +1987,7 @@
if (param_type == HIP_PARAM_NOTIFICATION) {
HIP_INFO("Found NOTIFICATION parameter in NOTIFY " \
"packet.\n");
- notification = (struct hip_notification *) current_param;
+ notification = (const struct hip_notification *) current_param;
param_len = hip_get_param_contents_len(current_param);
msgtype = ntohs(notification->msgtype);
@@ -2052,9 +2057,9 @@
"RVS_NAT.\n");
/* responder_hit is not currently used. */
- ipv6_addr_copy(&responder_hit, (struct in6_addr *)
+ ipv6_addr_copy(&responder_hit, (const struct in6_addr *)
notification->data);
- ipv6_addr_copy(&responder_ip, (struct in6_addr *)
+ ipv6_addr_copy(&responder_ip, (const struct in6_addr *)
&(notification->
data[sizeof(struct in6_addr)]));
memcpy(&port, &(notification->
=== modified file 'hipd/netdev.c'
--- hipd/netdev.c 2010-07-29 13:41:29 +0000
+++ hipd/netdev.c 2010-08-19 09:32:20 +0000
@@ -688,7 +688,8 @@
* @note Either HIT or LSI must be given. If both are given, the HIT is preferred.
* @todo move this to some other file (this file contains local IP address management, not remote)
*/
-int hip_map_id_to_addr(hip_hit_t *hit, hip_lsi_t *lsi, struct in6_addr *addr)
+int hip_map_id_to_addr(const hip_hit_t *hit, const hip_lsi_t *lsi,
+ struct in6_addr *addr)
{
int err = -1, skip_namelookup = 0; /* Assume that resolving fails */
hip_hit_t hit2;
@@ -772,12 +773,12 @@
* will be used as a last resort.
* @todo move this function to some other file
*/
-static int hip_netdev_trigger_bex(hip_hit_t *src_hit,
- hip_hit_t *dst_hit,
- hip_lsi_t *src_lsi,
- hip_lsi_t *dst_lsi,
- struct in6_addr *src_addr,
- struct in6_addr *dst_addr)
+static int hip_netdev_trigger_bex(const hip_hit_t *src_hit_in,
+ const hip_hit_t *dst_hit_in,
+ const hip_lsi_t *src_lsi_in,
+ const hip_lsi_t *dst_lsi_in,
+ const struct in6_addr *src_addr_in,
+ const struct in6_addr *dst_addr_in)
{
int err = 0, if_index = 0, is_ipv4_locator;
int reuse_hadb_local_address = 0, ha_nat_mode = hip_nat_status;
@@ -788,6 +789,8 @@
int is_loopback = 0;
hip_lsi_t dlsi, slsi;
struct in6_addr dhit, shit, saddr, dst6_lsi;
+ struct in6_addr *src_hit, *dst_hit, *src_addr, *dst_addr;
+ struct in_addr *src_lsi, *dst_lsi;
struct in6_addr daddr;
struct sockaddr_storage ss_addr;
struct sockaddr *addr;
@@ -801,13 +804,13 @@
addr = (struct sockaddr *) &ss_addr;
/* Make sure that dst_hit is not a NULL pointer */
- hip_copy_in6addr_null_check(&dhit, dst_hit);
+ hip_copy_in6addr_null_check(&dhit, dst_hit_in);
dst_hit = &dhit;
HIP_DEBUG_HIT("dst hit", dst_hit);
/* Make sure that src_hit is not a NULL pointer */
- hip_copy_in6addr_null_check(&shit, src_hit);
- if (!src_hit) {
+ hip_copy_in6addr_null_check(&shit, src_hit_in);
+ if (!src_hit_in) {
hip_get_default_hit(&shit);
}
src_hit = &shit;
@@ -815,29 +818,29 @@
/* Initialize mapped format of dst lsi before pointer
* changes just below */
- if (dst_lsi) {
- IPV4_TO_IPV6_MAP(dst_lsi, &dst6_lsi);
+ if (dst_lsi_in) {
+ IPV4_TO_IPV6_MAP(dst_lsi_in, &dst6_lsi);
} else {
memset(&dst6_lsi, 0, sizeof(dst6_lsi));
}
/* Make sure that dst_lsi is not a NULL pointer */
- hip_copy_inaddr_null_check(&dlsi, dst_lsi);
+ hip_copy_inaddr_null_check(&dlsi, dst_lsi_in);
dst_lsi = &dlsi;
HIP_DEBUG_LSI("dst lsi", dst_lsi);
/* Make sure that src_lsi is not a NULL pointer */
- hip_copy_inaddr_null_check(&slsi, src_lsi);
+ hip_copy_inaddr_null_check(&slsi, src_lsi_in);
src_lsi = &slsi;
HIP_DEBUG_LSI("src lsi", src_lsi);
/* Make sure that dst_addr is not a NULL pointer */
- hip_copy_in6addr_null_check(&daddr, dst_addr);
+ hip_copy_in6addr_null_check(&daddr, dst_addr_in);
dst_addr = &daddr;
HIP_DEBUG_IN6ADDR("dst addr", dst_addr);
/* Make sure that src_addr is not a NULL pointer */
- hip_copy_in6addr_null_check(&saddr, src_addr);
+ hip_copy_in6addr_null_check(&saddr, src_addr_in);
src_addr = &saddr;
HIP_DEBUG_IN6ADDR("src addr", src_addr);
@@ -1067,10 +1070,10 @@
*/
int hip_netdev_trigger_bex_msg(const struct hip_common *msg)
{
- hip_hit_t *our_hit = NULL, *peer_hit = NULL;
- hip_lsi_t *our_lsi = NULL, *peer_lsi = NULL;
- struct in6_addr *our_addr = NULL, *peer_addr = NULL;
- struct hip_tlv_common *param;
+ const hip_hit_t *our_hit = NULL, *peer_hit = NULL;
+ const hip_lsi_t *our_lsi = NULL, *peer_lsi = NULL;
+ const struct in6_addr *our_addr = NULL, *peer_addr = NULL;
+ const struct hip_tlv_common *param;
int err = 0;
HIP_DUMP_MSG(msg);
=== modified file 'hipd/netdev.h'
--- hipd/netdev.h 2010-07-29 13:41:29 +0000
+++ hipd/netdev.h 2010-08-19 09:32:20 +0000
@@ -53,6 +53,7 @@
void hip_copy_peer_addrlist_changed(hip_ha_t *ha);
-int hip_map_id_to_addr(hip_hit_t *hit, hip_lsi_t *lsi, struct in6_addr *addr);
+int hip_map_id_to_addr(const hip_hit_t *hit, const hip_lsi_t *lsi,
+ struct in6_addr *addr);
#endif /* HIP_HIPD_NETDEV_H */
=== modified file 'hipd/oppdb.c'
--- hipd/oppdb.c 2010-07-29 09:11:04 +0000
+++ hipd/oppdb.c 2010-08-19 09:32:20 +0000
@@ -672,7 +672,7 @@
{
int err = 0;
struct in6_addr phit, dst_ip, our_hit, our_addr;
- struct in6_addr *ptr;
+ const struct in6_addr *ptr;
hip_ha_t *ha;
ptr = hip_get_param_contents(msg, HIP_PARAM_HIT_LOCAL);
=== modified file 'hipd/output.c'
--- hipd/output.c 2010-08-17 17:23:18 +0000
+++ hipd/output.c 2010-08-19 09:32:20 +0000
@@ -92,7 +92,7 @@
* @todo remove the dst_hit parameter? test with the opportunistic TCP extension
*/
static int hip_send_i1_pkt(struct hip_common *i1,
- UNUSED hip_hit_t *dst_hit,
+ UNUSED const hip_hit_t *dst_hit,
struct in6_addr *local_addr,
struct in6_addr *peer_addr,
in_port_t src_port,
@@ -141,7 +141,8 @@
* the peer.
* @return zero on success, or negative error value on error.
*/
-int hip_send_i1(hip_hit_t *src_hit, hip_hit_t *dst_hit, hip_ha_t *entry)
+int hip_send_i1(hip_hit_t *src_hit, const hip_hit_t *dst_hit,
+ hip_ha_t *entry)
{
struct hip_common *i1 = 0;
uint16_t mask = 0;
@@ -258,7 +259,7 @@
hip_transform_suite_t transform_hip_suite, transform_esp_suite;
struct hip_spi_in_item spi_in_data;
struct in6_addr daddr;
- struct hip_param *param = NULL;
+ const struct hip_param *param = NULL;
struct hip_esp_info *esp_info = NULL;
struct hip_host_id_entry *host_id_entry = NULL;
char *enc_in_msg = NULL, *host_id_in_enc = NULL;
@@ -305,7 +306,7 @@
HIP_IFE(!(param = hip_get_param(ctx->input_msg, HIP_PARAM_HIP_TRANSFORM)),
-ENOENT);
HIP_IFEL((transform_hip_suite =
- hip_select_hip_transform((struct hip_hip_transform *) param)) == 0,
+ hip_select_hip_transform((const struct hip_hip_transform *) param)) == 0,
-EINVAL,
"Could not find acceptable hip transform suite\n");
@@ -326,8 +327,8 @@
(struct hip_tlv_common *) ctx->hadb_entry->our_pub),
-1,
"Building of param encrypted failed.\n");
- enc_in_msg = hip_get_param(ctx->output_msg,
- HIP_PARAM_ENCRYPTED);
+ enc_in_msg = hip_get_param_readwrite(ctx->output_msg,
+ HIP_PARAM_ENCRYPTED);
HIP_ASSERT(enc_in_msg); /* Builder internal error. */
iv = ((struct hip_encrypted_aes_sha1 *) enc_in_msg)->iv;
get_random_bytes(iv, 16);
@@ -338,8 +339,8 @@
(struct hip_tlv_common *) ctx->hadb_entry->our_pub),
-1,
"Building of param encrypted failed.\n");
- enc_in_msg = hip_get_param(ctx->output_msg,
- HIP_PARAM_ENCRYPTED);
+ enc_in_msg = hip_get_param_readwrite(ctx->output_msg,
+ HIP_PARAM_ENCRYPTED);
HIP_ASSERT(enc_in_msg); /* Builder internal error. */
iv = ((struct hip_encrypted_3des_sha1 *) enc_in_msg)->iv;
get_random_bytes(iv, 8);
@@ -351,8 +352,8 @@
(struct hip_tlv_common *) ctx->hadb_entry->our_pub),
-1,
"Building of param encrypted failed.\n");
- enc_in_msg = hip_get_param(ctx->output_msg,
- HIP_PARAM_ENCRYPTED);
+ enc_in_msg = hip_get_param_readwrite(ctx->output_msg,
+ HIP_PARAM_ENCRYPTED);
HIP_ASSERT(enc_in_msg); /* Builder internal error. */
iv = NULL;
host_id_in_enc = enc_in_msg +
@@ -385,13 +386,12 @@
ctx->output_msg);
/********** ESP-ENC transform. **********/
- HIP_IFE(!(param = hip_get_param(ctx->input_msg,
- HIP_PARAM_ESP_TRANSFORM)),
+ HIP_IFE(!(param = hip_get_param(ctx->input_msg, HIP_PARAM_ESP_TRANSFORM)),
-ENOENT);
/* Select only one transform */
HIP_IFEL((transform_esp_suite =
- hip_select_esp_transform((struct hip_esp_transform *) param)) == 0,
+ hip_select_esp_transform((const struct hip_esp_transform *) param)) == 0,
-1, "Could not find acceptable hip transform suite\n");
HIP_IFEL(hip_build_param_esp_transform(ctx->output_msg,
&transform_esp_suite, 1), -1,
@@ -461,7 +461,7 @@
-1,
"Setting up SP pair failed\n");
- esp_info = hip_get_param(ctx->output_msg, HIP_PARAM_ESP_INFO);
+ esp_info = hip_get_param_readwrite(ctx->output_msg, HIP_PARAM_ESP_INFO);
HIP_ASSERT(esp_info); /* Builder internal error */
esp_info->new_spi = htonl(spi_in);
/* LSI not created, as it is local, and we do not support IPv4 */
@@ -469,7 +469,7 @@
/********** ECHO_RESPONSE_SIGN (OPTIONAL) **************/
/* must reply... */
{
- struct hip_echo_request *ping;
+ const struct hip_echo_request *ping;
ping = hip_get_param(ctx->input_msg, HIP_PARAM_ECHO_REQUEST_SIGN);
if (ping) {
@@ -504,7 +504,7 @@
/********** ECHO_RESPONSE (OPTIONAL) ************/
/* must reply */
{
- struct hip_echo_request *ping;
+ const struct hip_echo_request *ping;
ping = hip_get_param(ctx->input_msg, HIP_PARAM_ECHO_REQUEST);
if (ping) {
@@ -711,7 +711,7 @@
struct hip_puzzle *pz;
uint64_t random_i;
- HIP_IFEL(!(pz = hip_get_param(msg, HIP_PARAM_PUZZLE)), -1,
+ HIP_IFEL(!(pz = hip_get_param_readwrite(msg, HIP_PARAM_PUZZLE)), -1,
"Internal error\n");
/* hardcode kludge */
=== modified file 'hipd/output.h'
--- hipd/output.h 2010-07-07 16:42:17 +0000
+++ hipd/output.h 2010-08-19 09:32:20 +0000
@@ -65,7 +65,7 @@
hip_ha_t *entry,
hip_portpair_t *r2_info);
-int hip_send_i1(hip_hit_t *, hip_hit_t *, hip_ha_t *);
+int hip_send_i1(hip_hit_t *, const hip_hit_t *, hip_ha_t *);
int hip_send_i2(const uint8_t packet_type,
const uint32_t ha_state,
=== modified file 'hipd/registration.c'
--- hipd/registration.c 2010-07-07 16:42:17 +0000
+++ hipd/registration.c 2010-08-19 09:32:20 +0000
@@ -415,7 +415,8 @@
*/
static int hip_add_registration_server(hip_ha_t *entry, uint8_t lifetime,
- uint8_t *reg_types, int type_count,
+ const uint8_t *reg_types,
+ int type_count,
uint8_t accepted_requests[],
uint8_t accepted_lifetimes[],
int *accepted_count, uint8_t refused_requests[],
@@ -574,7 +575,8 @@
* @return zero on success, -1 otherwise.
* @see hip_del_registration_client().
*/
-static int hip_del_registration_server(hip_ha_t *entry, uint8_t *reg_types,
+static int hip_del_registration_server(hip_ha_t *entry,
+ const uint8_t *reg_types,
int type_count, uint8_t accepted_requests[],
int *accepted_count, uint8_t refused_requests[],
uint8_t failure_types[], int *refused_count)
@@ -697,7 +699,8 @@
* @see hip_add_registration_server().
*/
static int hip_add_registration_client(hip_ha_t *entry, uint8_t lifetime,
- uint8_t *reg_types, int type_count)
+ const uint8_t *reg_types,
+ int type_count)
{
int i = 0;
time_t seconds = 0;
@@ -786,7 +789,8 @@
* @return zero on success, -1 otherwise.
* @see hip_del_registration_client().
*/
-static int hip_del_registration_client(hip_ha_t *entry, uint8_t *reg_types,
+static int hip_del_registration_client(hip_ha_t *entry,
+ const uint8_t *reg_types,
int type_count)
{
int i = 0;
@@ -862,11 +866,11 @@
int hip_handle_param_reg_info(hip_ha_t *entry, hip_common_t *source_msg,
hip_common_t *target_msg)
{
- struct hip_reg_info *reg_info = NULL;
- uint8_t *reg_types = NULL;
- unsigned int type_count = 0;
+ const struct hip_reg_info *reg_info = NULL;
+ const uint8_t *reg_types = NULL;
+ unsigned int type_count = 0;
unsigned int i;
- int err = 0;
+ int err = 0;
reg_info = hip_get_param(source_msg, HIP_PARAM_REG_INFO);
@@ -1003,7 +1007,7 @@
* @return zero if there are no duplicate values, -1 otherwise.
*/
-static int hip_has_duplicate_services(uint8_t *reg_types, int type_count)
+static int hip_has_duplicate_services(const uint8_t *reg_types, int type_count)
{
if (reg_types == NULL || type_count <= 0) {
return -1;
@@ -1060,8 +1064,8 @@
hip_common_t *target_msg)
{
int err = 0, type_count = 0, accepted_count = 0, refused_count = 0;
- struct hip_reg_request *reg_request = NULL;
- uint8_t *reg_types = NULL;
+ const struct hip_reg_request *reg_request = NULL;
+ const uint8_t *reg_types = NULL;
/* Arrays for storing the type reg_types of the accepted and refused
* request types. */
uint8_t *accepted_requests = NULL, *accepted_lifetimes = NULL;
@@ -1089,7 +1093,7 @@
/* Allocate memory for types */
/* Get a pointer to the actual registration types. */
- reg_types = (uint8_t *) hip_get_param_contents_direct(reg_request) +
+ reg_types = (const uint8_t *) hip_get_param_contents_direct(reg_request) +
sizeof(reg_request->lifetime);
HIP_DEBUG("REG_REQUEST parameter found. Requested lifetime: 0x%x, " \
@@ -1210,8 +1214,8 @@
int hip_handle_param_reg_response(hip_ha_t *entry, hip_common_t *msg)
{
int err = 0, type_count = 0;
- struct hip_reg_response *reg_response = NULL;
- uint8_t *reg_types = NULL;
+ const struct hip_reg_response *reg_response = NULL;
+ const uint8_t *reg_types = NULL;
reg_response = hip_get_param(msg, HIP_PARAM_REG_RESPONSE);
@@ -1225,7 +1229,7 @@
type_count = hip_get_param_contents_len(reg_response) -
sizeof(reg_response->lifetime);
- reg_types = (uint8_t *) hip_get_param_contents_direct(reg_response) +
+ reg_types = (const uint8_t *) hip_get_param_contents_direct(reg_response) +
sizeof(reg_response->lifetime);
if (reg_response->lifetime == 0) {
@@ -1302,8 +1306,8 @@
int hip_handle_param_reg_failed(hip_ha_t *entry, hip_common_t *msg)
{
int err = 0, type_count = 0, i = 0;
- struct hip_reg_failed *reg_failed = NULL;
- uint8_t *reg_types = NULL;
+ const struct hip_reg_failed *reg_failed = NULL;
+ const uint8_t *reg_types = NULL;
char reason[256];
reg_failed = hip_get_param(msg, HIP_PARAM_REG_FAILED);
@@ -1320,7 +1324,7 @@
while (hip_get_param_type(reg_failed) == HIP_PARAM_REG_FAILED) {
type_count = hip_get_param_contents_len(reg_failed) -
sizeof(reg_failed->failure_type);
- reg_types = (uint8_t *) hip_get_param_contents_direct(reg_failed) +
+ reg_types = (const uint8_t *) hip_get_param_contents_direct(reg_failed) +
sizeof(reg_failed->failure_type);
hip_get_registration_failure_string(reg_failed->failure_type,
reason);
@@ -1378,8 +1382,8 @@
/* Iterate to the next parameter and break the loop if there are
* no more parameters left. */
i = 0;
- reg_failed = (struct hip_reg_failed *)
- hip_get_next_param(msg, (hip_tlv_common_t *) reg_failed);
+ reg_failed = (const struct hip_reg_failed *) hip_get_next_param(msg,
+ (const hip_tlv_common_t *) reg_failed);
if (reg_failed == NULL) {
break;
@@ -1402,8 +1406,8 @@
*/
int hip_handle_reg_from(hip_ha_t *entry, struct hip_common *msg)
{
- int err = 0;
- struct hip_reg_from *rfrom = NULL;
+ int err = 0;
+ const struct hip_reg_from *rfrom = NULL;
HIP_DEBUG("Checking msg for REG_FROM parameter.\n");
rfrom = hip_get_param(msg, HIP_PARAM_REG_FROM);
=== modified file 'hipd/user.c'
--- hipd/user.c 2010-08-18 16:30:31 +0000
+++ hipd/user.c 2010-08-19 09:32:20 +0000
@@ -219,11 +219,11 @@
struct sockaddr_in6 *src,
int *send_response)
{
- hip_hit_t *src_hit = NULL, *dst_hit = NULL;
- hip_ha_t *entry = NULL;
- int err = 0, msg_type = 0, n = 0, reti = 0;
- int access_ok = 0, is_root = 0;
- struct hip_tlv_common *param = NULL;
+ const hip_hit_t *src_hit = NULL, *dst_hit = NULL;
+ hip_ha_t *entry = NULL;
+ int err = 0, msg_type = 0, n = 0, reti = 0;
+ int access_ok = 0, is_root = 0;
+ const struct hip_tlv_common *param = NULL;
HIP_ASSERT(src->sin6_family == AF_INET6);
HIP_DEBUG("User message from port %d\n", htons(src->sin6_port));
@@ -379,7 +379,7 @@
case HIP_MSG_TRANSFORM_ORDER:
{
err = 0;
- struct hip_transformation_order *transorder;
+ const struct hip_transformation_order *transorder;
HIP_IFEL(!(transorder = hip_get_param(msg, HIP_PARAM_TRANSFORM_ORDER)), -1,
"no transform order struct found (should contain transform order)\n");
HIP_DEBUG("Transform order received from hipconf: %d\n", transorder->transorder);
@@ -395,13 +395,13 @@
* the hip daemon wants either to register to a server for
* additional services or it wants to cancel a registration.
* Cancellation is identified with a zero lifetime. */
- struct hip_reg_request *reg_req = NULL;
- hip_pending_request_t *pending_req = NULL;
- uint8_t *reg_types = NULL;
- struct in6_addr *dst_ip = NULL;
- int i = 0, type_count = 0;
- int opp_mode = 0;
- int add_to_global = 0;
+ const struct hip_reg_request *reg_req = NULL;
+ hip_pending_request_t *pending_req = NULL;
+ const uint8_t *reg_types = NULL;
+ const struct in6_addr *dst_ip = NULL;
+ int i = 0, type_count = 0;
+ int opp_mode = 0;
+ int add_to_global = 0;
struct sockaddr_in6 sock_addr6;
struct sockaddr_in sock_addr;
struct in6_addr server_addr, hitr;
@@ -849,7 +849,7 @@
break;
case HIP_MSG_SET_NAT_PORT:
{
- struct hip_port_info *nat_port;
+ const struct hip_port_info *nat_port;
nat_port = hip_get_param(msg, HIP_PARAM_LOCAL_NAT_PORT);
if (nat_port) {
@@ -885,8 +885,9 @@
{
err = 0;
struct hip_hit_to_ip_set *name_info;
- HIP_IFEL(!(name_info = hip_get_param(msg, HIP_PARAM_HIT_TO_IP_SET)), -1,
- "no name struct found\n");
+ HIP_IFEL(!(name_info = hip_get_param_readwrite(msg,
+ HIP_PARAM_HIT_TO_IP_SET)),
+ -1, "no name struct found\n");
HIP_DEBUG("Name in name_info %s\n", name_info->name);
int name_len = strlen(name_info->name);
if (name_len >= 1) {
@@ -918,8 +919,8 @@
break;
case HIP_MSG_MAP_ID_TO_ADDR:
{
- struct in6_addr *id = NULL;
- hip_hit_t *hit = NULL;
+ const struct in6_addr *id = NULL;
+ const hip_hit_t *hit = NULL;
hip_lsi_t lsi;
struct in6_addr addr;
@@ -957,7 +958,7 @@
break;
case HIP_MSG_LSI_TO_HIT:
{
- hip_lsi_t *lsi;
+ const hip_lsi_t *lsi;
hip_ha_t *ha;
HIP_IFE(!(param = hip_get_param(msg, HIP_PARAM_LSI)), -1);
=== modified file 'hipd/user_ipsec_hipd_msg.c'
--- hipd/user_ipsec_hipd_msg.c 2010-08-18 16:30:31 +0000
+++ hipd/user_ipsec_hipd_msg.c 2010-08-19 09:32:20 +0000
@@ -56,12 +56,12 @@
*/
int hip_userspace_ipsec_activate(const struct hip_common *msg)
{
- struct hip_tlv_common *param = NULL;
- int err = 0, activate = 0;
+ const struct hip_tlv_common *param = NULL;
+ int err = 0, activate = 0;
// process message and store anchor elements in the db
param = hip_get_param(msg, HIP_PARAM_INT);
- activate = *((int *) hip_get_param_contents_direct(param));
+ activate = *((const int *) hip_get_param_contents_direct(param));
// set global variable
hip_use_userspace_ipsec = activate;
=== modified file 'lib/core/builder.c'
--- lib/core/builder.c 2010-08-18 16:34:37 +0000
+++ lib/core/builder.c 2010-08-19 09:32:20 +0000
@@ -766,8 +766,55 @@
* @return the next parameter after the current_param in @c msg, or
* NULL if no parameters were found.
*/
-struct hip_tlv_common *hip_get_next_param(const struct hip_common *msg,
- const struct hip_tlv_common *current_param)
+const struct hip_tlv_common *hip_get_next_param(const struct hip_common *msg,
+ const struct hip_tlv_common *current_param)
+{
+ const struct hip_tlv_common *next_param = NULL;
+ const uint8_t *pos = (const uint8_t *) current_param;
+
+ if (!msg) {
+ HIP_ERROR("msg null\n");
+ goto out;
+ }
+
+ if (current_param == NULL) {
+ pos = (const uint8_t *) msg;
+ }
+
+ if (pos == (const uint8_t *) msg) {
+ pos += sizeof(struct hip_common);
+ } else {
+ pos += hip_get_param_total_len(current_param);
+ }
+
+ next_param = (const struct hip_tlv_common *) pos;
+
+ /* check that the next parameter does not point
+ * a) outside of the message
+ * b) out of the buffer with check_param_contents_len()
+ * c) to an empty slot in the message */
+ if (((const char *) next_param) - ((const char *) msg) >=
+ hip_get_msg_total_len(msg) || /* a */
+ !hip_check_param_contents_len(msg, next_param) || /* b */
+ hip_get_param_contents_len(next_param) == 0) { /* c */
+ next_param = NULL;
+ }
+
+out:
+ return next_param;
+}
+
+/**
+ * Iterate to the next parameter in the message
+ *
+ * @param msg a pointer to the beginning of the message header
+ * @param current_param a pointer to the current parameter, or NULL if the msg
+ * is to be searched from the beginning.
+ * @return the next parameter after the current_param in @c msg, or
+ * NULL if no parameters were found.
+ */
+struct hip_tlv_common *hip_get_next_param_readwrite(struct hip_common *msg,
+ struct hip_tlv_common *current_param)
{
struct hip_tlv_common *next_param = NULL;
uint8_t *pos = (uint8_t *) current_param;
@@ -816,7 +863,39 @@
* or NULL if no parameters of the type param_type were not
* found.
*/
-void *hip_get_param(const struct hip_common *msg, hip_tlv_type_t param_type)
+const void *hip_get_param(const struct hip_common *msg,
+ hip_tlv_type_t param_type)
+{
+ const void *matched = NULL;
+ const struct hip_tlv_common *current_param = NULL;
+
+ /** @todo Optimize: stop when next parameter's type is greater than the
+ * searched one. */
+
+ while ((current_param = hip_get_next_param(msg, current_param))) {
+ if (hip_get_param_type(current_param) == param_type) {
+ matched = current_param;
+ break;
+ }
+ }
+
+ return matched;
+}
+
+/**
+ * Get the first parameter of the given type. If there are multiple
+ * parameters of the same type, one should use hip_get_next_param()
+ * after calling this function to iterate through them all.
+ *
+ * @param msg a pointer to the beginning of the message header.
+ * @param param_type the type of the parameter to be searched from msg
+ * (in host byte order)
+ * @return a pointer to the first parameter of the type param_type,
+ * or NULL if no parameters of the type param_type were not
+ * found.
+ */
+void *hip_get_param_readwrite(struct hip_common *msg,
+ hip_tlv_type_t param_type)
{
void *matched = NULL;
struct hip_tlv_common *current_param = NULL;
@@ -824,7 +903,7 @@
/** @todo Optimize: stop when next parameter's type is greater than the
* searched one. */
- while ((current_param = hip_get_next_param(msg, current_param))
+ while ((current_param = hip_get_next_param_readwrite(msg, current_param))
!= NULL) {
if (hip_get_param_type(current_param) == param_type) {
matched = current_param;
@@ -847,10 +926,10 @@
* type @c param_type, or NULL if no parameters of type
* @c param_type were found.
*/
-void *hip_get_param_contents(const struct hip_common *msg,
- hip_tlv_type_t param_type)
+const void *hip_get_param_contents(const struct hip_common *msg,
+ hip_tlv_type_t param_type)
{
- uint8_t *contents = hip_get_param(msg, param_type);
+ const uint8_t *contents = hip_get_param(msg, param_type);
if (contents) {
contents += sizeof(struct hip_tlv_common);
}
@@ -864,12 +943,24 @@
* @return pointer to the contents of the tlv_common (just after the
* the type and length fields)
*/
-void *hip_get_param_contents_direct(void *tlv_common)
+void *hip_get_param_contents_direct_readwrite(void *tlv_common)
{
return ((uint8_t *) tlv_common) + sizeof(struct hip_tlv_common);
}
/**
+ * hip_get_param_contents_direct - get parameter contents direct from TLV
+ *
+ * @param tlv_common pointer to a parameter
+ * @return pointer to the contents of the tlv_common (just after the
+ * the type and length fields)
+ */
+const void *hip_get_param_contents_direct(const void *tlv_common)
+{
+ return ((const uint8_t *) tlv_common) + sizeof(struct hip_tlv_common);
+}
+
+/**
* @brief Find the first free parameter position in a message
*
* This function does not check whether the new parameter to be appended
@@ -903,7 +994,7 @@
goto out;
}
- while ((current_param = hip_get_next_param(msg, current_param))
+ while ((current_param = hip_get_next_param_readwrite(msg, current_param))
!= NULL) {
last_used_pos = current_param;
}
@@ -1206,8 +1297,8 @@
*/
void hip_dump_msg(const struct hip_common *msg)
{
- struct hip_tlv_common *current_param = NULL;
- uint8_t *contents = NULL;
+ const struct hip_tlv_common *current_param = NULL;
+ const uint8_t *contents = NULL;
/* The value of the "Length"-field in current parameter. */
hip_tlv_len_t len = 0;
/* Total length of the parameter (type+length+value+padding), and the
@@ -1250,8 +1341,8 @@
*/
int hip_check_userspace_msg(const struct hip_common *msg)
{
- struct hip_tlv_common *current_param = NULL;
- int err = 0;
+ const struct hip_tlv_common *current_param = NULL;
+ int err = 0;
if (!hip_check_user_msg_len(msg)) {
err = -EMSGSIZE;
@@ -1331,9 +1422,9 @@
*/
int hip_check_network_msg(const struct hip_common *msg)
{
- struct hip_tlv_common *current_param = NULL;
- hip_tlv_type_t current_param_type = 0, prev_param_type = 0;
- int err = 0;
+ const struct hip_tlv_common *current_param = NULL;
+ hip_tlv_type_t current_param_type = 0, prev_param_type = 0;
+ int err = 0;
/* Checksum of the message header is verified in input.c */
@@ -1755,8 +1846,8 @@
struct hip_common *msg_copy,
struct hip_host_id *host_id)
{
- struct hip_tlv_common *param = NULL;
- int err = 0;
+ const struct hip_tlv_common *param = NULL;
+ int err = 0;
HIP_HEXDUMP("host id", host_id,
hip_get_param_total_len(host_id));
@@ -2048,7 +2139,7 @@
* @param request true if parameter is ECHO_REQUEST, otherwise parameter is ECHO_RESPONSE
* @return zero for success, or non-zero on error
*/
-int hip_build_param_echo(struct hip_common *msg, void *opaque, int len,
+int hip_build_param_echo(struct hip_common *msg, const void *opaque, int len,
int sign, int request)
{
struct hip_echo_request ping;
@@ -2460,7 +2551,8 @@
*
* @return zero for success, or non-zero on error
*/
-int hip_build_param_solution(struct hip_common *msg, struct hip_puzzle *pz,
+int hip_build_param_solution(struct hip_common *msg,
+ const struct hip_puzzle *pz,
uint64_t val_J)
{
struct hip_solution cookie;
@@ -2938,7 +3030,7 @@
int hip_build_param_esp_prot_branch(struct hip_common *msg,
int anchor_offset,
int branch_length,
- unsigned char *branch_nodes)
+ const unsigned char *branch_nodes)
{
int err = 0;
struct esp_prot_branch branch;
@@ -2981,7 +3073,7 @@
*/
int hip_build_param_esp_prot_secret(struct hip_common *msg,
int secret_length,
- unsigned char *secret)
+ const unsigned char *secret)
{
int err = 0;
struct esp_prot_secret esp_secret;
@@ -3270,7 +3362,7 @@
* @param len the length of the hostname in bytes
* @return zero on success and negative on error
*/
-int hip_get_param_host_id_di_type_len(struct hip_host_id *host,
+int hip_get_param_host_id_di_type_len(const struct hip_host_id *host,
const char **id,
int *len)
{
@@ -3297,7 +3389,7 @@
* @param hostid the host id parameter
* @return a pointer to the hostname field
*/
-char *hip_get_param_host_id_hostname(struct hip_host_id *hostid)
+const char *hip_get_param_host_id_hostname(const struct hip_host_id *hostid)
{
return hostid->hostname;
}
=== modified file 'lib/core/builder.h'
--- lib/core/builder.h 2010-08-17 17:23:18 +0000
+++ lib/core/builder.h 2010-08-19 09:32:20 +0000
@@ -78,7 +78,7 @@
uint8_t,
void *,
hip_tlv_len_t);
-int hip_build_param_echo(struct hip_common *, void *, int, int, int);
+int hip_build_param_echo(struct hip_common *, const void *, int, int, int);
int hip_build_param_eid_endpoint(struct hip_common *,
const struct endpoint_hip *);
int hip_build_param_encrypted_3des_sha1(struct hip_common *,
@@ -147,7 +147,7 @@
hip_tlv_len_t,
uint8_t);
int hip_build_param_solution(struct hip_common *,
- struct hip_puzzle *,
+ const struct hip_puzzle *,
uint64_t);
int hip_build_param_challenge_response(struct hip_common *,
@@ -198,14 +198,19 @@
hip_hdr_err_t hip_get_msg_err(const struct hip_common *);
uint16_t hip_get_msg_total_len(const struct hip_common *);
hip_hdr_type_t hip_get_msg_type(const struct hip_common *);
-struct hip_tlv_common *hip_get_next_param(const struct hip_common *,
- const struct hip_tlv_common *);
-void *hip_get_param(const struct hip_common *, hip_tlv_type_t);
-void *hip_get_param_contents(const struct hip_common *, hip_tlv_type_t);
-void *hip_get_param_contents_direct(void *);
+const struct hip_tlv_common *hip_get_next_param(const struct hip_common *,
+ const struct hip_tlv_common *);
+struct hip_tlv_common *hip_get_next_param_readwrite(struct hip_common *,
+ struct hip_tlv_common *);
+const void *hip_get_param(const struct hip_common *, hip_tlv_type_t);
+void *hip_get_param_readwrite(struct hip_common *, hip_tlv_type_t);
+const void *hip_get_param_contents(const struct hip_common *, hip_tlv_type_t);
+const void *hip_get_param_contents_direct(const void *);
+void *hip_get_param_contents_direct_readwrite(void *);
hip_tlv_len_t hip_get_param_contents_len(const void *);
-int hip_get_param_host_id_di_type_len(struct hip_host_id *, const char **, int *);
-char *hip_get_param_host_id_hostname(struct hip_host_id *);
+int hip_get_param_host_id_di_type_len(const struct hip_host_id *,
+ const char **, int *);
+const char *hip_get_param_host_id_hostname(const struct hip_host_id *);
hip_tlv_len_t hip_get_param_total_len(const void *);
hip_transform_suite_t hip_get_param_transform_suite_id(const void *);
hip_tlv_type_t hip_get_param_type(const void *);
@@ -264,10 +269,10 @@
int hip_build_param_esp_prot_branch(struct hip_common *msg,
int anchor_offset,
int branch_length,
- unsigned char *branch_nodes);
+ const unsigned char *branch_nodes);
int hip_build_param_esp_prot_secret(struct hip_common *msg,
int secret_length,
- unsigned char *secret);
+ const unsigned char *secret);
int hip_build_param_esp_prot_root(struct hip_common *msg,
uint8_t root_length,
unsigned char *root);
=== modified file 'lib/core/certtools.c'
--- lib/core/certtools.c 2010-07-16 17:19:52 +0000
+++ lib/core/certtools.c 2010-08-19 09:32:20 +0000
@@ -468,8 +468,8 @@
char buf_after[80];
char present_issuer[41];
char present_subject[41];
- struct hip_common *msg = NULL;
- struct hip_cert_spki_info *returned = NULL;
+ struct hip_common *msg = NULL;
+ const struct hip_cert_spki_info *returned = NULL;
/* Malloc needed */
tmp_issuer = malloc(128);
@@ -654,7 +654,7 @@
{
int err = 0;
struct hip_common *msg;
- struct hip_cert_spki_info *returned;
+ const struct hip_cert_spki_info *returned;
HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1,
"Malloc for msg failed\n");
@@ -703,7 +703,7 @@
{
int err = 0;
struct hip_common *msg;
- struct hip_cert_x509_resp *p;
+ const struct hip_cert_x509_resp *p;
HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1,
"Malloc for msg failed\n");
@@ -746,7 +746,7 @@
{
int err = 0;
struct hip_common *msg;
- struct hip_cert_x509_resp *received;
+ const struct hip_cert_x509_resp *received;
HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1,
"Malloc for msg failed\n");
=== modified file 'lib/core/conf.c'
--- lib/core/conf.c 2010-08-18 17:47:04 +0000
+++ lib/core/conf.c 2010-08-19 09:32:20 +0000
@@ -250,12 +250,12 @@
static int hip_get_hits(hip_common_t *msg, const char *opt,
UNUSED int optc, int send_only)
{
- int err = 0;
- struct hip_tlv_common *current_param = NULL;
- struct hip_hit_info *data;
- struct in_addr *deflsi = NULL;
- struct in6_addr *defhit = NULL;
- hip_tlv_type_t param_type = 0;
+ int err = 0;
+ const struct hip_tlv_common *current_param = NULL;
+ const struct hip_hit_info *data;
+ const struct in_addr *deflsi = NULL;
+ const struct in6_addr *defhit = NULL;
+ hip_tlv_type_t param_type = 0;
char hit_s[INET6_ADDRSTRLEN], lsi_s[INET_ADDRSTRLEN];
if (strcmp(opt, "all") == 0) {
@@ -356,10 +356,10 @@
UNUSED int optc,
int send_only)
{
- int err = 0;
- struct hip_tlv_common *param = NULL;
- struct hip_hit_info *data;
- hip_common_t *msg_tmp = NULL;
+ int err = 0;
+ const struct hip_tlv_common *param = NULL;
+ const struct hip_hit_info *data;
+ hip_common_t *msg_tmp = NULL;
msg_tmp = hip_msg_alloc();
HIP_IFEL(!msg_tmp, -ENOMEM, "Malloc for msg_tmp failed\n");
@@ -453,7 +453,7 @@
* @param ha hip_hadb_user_info_state (partial information of hadb)
* @return zero for success and negative on error
*/
-static int hip_conf_print_info_ha(struct hip_hadb_user_info_state *ha)
+static int hip_conf_print_info_ha(const struct hip_hadb_user_info_state *ha)
{
HIP_INFO("HA is %s\n", hip_state_str(ha->state));
if (ha->shotgun_status == HIP_MSG_SHOTGUN_ON) {
@@ -1626,7 +1626,7 @@
const char *opt[], UNUSED int optc, int send_only)
{
int err = 0, status = 0;
- struct hip_locator *locator = NULL;
+ const struct hip_locator *locator = NULL;
if (!strcmp("on", opt[0])) {
status = HIP_MSG_SET_LOCATOR_ON;
@@ -1671,10 +1671,11 @@
int optc,
int send_only)
{
- int err = 0, ret = 0, msg_type = 0, all, *diff = NULL, newVal = 0;
+ int err = 0, ret = 0, msg_type = 0, all, newVal = 0;
+ const int *diff = NULL;
hip_hit_t hit, all_zero_hit;
- struct hip_tlv_common *current_param = NULL;
- hip_tlv_type_t param_type = 0;
+ const struct hip_tlv_common *current_param = NULL;
+ hip_tlv_type_t param_type = 0;
char hit_s[INET6_ADDRSTRLEN];
memset(&hit, 0, sizeof(hip_hit_t));
@@ -1886,8 +1887,8 @@
{
int err = 0;
hip_hit_t hit;
- hip_tlv_common_t *param;
- hip_lsi_t *lsi;
+ const hip_tlv_common_t *param;
+ const hip_lsi_t *lsi;
char lsi_str[INET_ADDRSTRLEN];
const char *hit_str = opt[0];
@@ -2043,8 +2044,9 @@
int optc,
int send_only)
{
- struct hip_tlv_common *current_param = NULL;
- int err = 0;
+ const struct hip_tlv_common *current_param = NULL;
+ const struct hip_hadb_user_info_state *ha;
+ int err = 0;
struct in6_addr hit1;
HIP_IFEL(optc > 1, -1, "Too many arguments\n");
@@ -2056,8 +2058,7 @@
"send recv daemon info\n");
while ((current_param = hip_get_next_param(msg, current_param))) {
- struct hip_hadb_user_info_state *ha =
- hip_get_param_contents_direct(current_param);
+ ha = hip_get_param_contents_direct(current_param);
if (!strcmp("all", opt[0])) {
hip_conf_print_info_ha(ha);
@@ -2364,9 +2365,9 @@
int err = 0;
struct in6_addr hit;
struct in_addr lsi;
- struct in6_addr *ip;
+ const struct in6_addr *ip;
struct in_addr ip4;
- struct hip_tlv_common *param = NULL;
+ const struct hip_tlv_common *param = NULL;
char addr_str[INET6_ADDRSTRLEN];
if (inet_pton(AF_INET6, opt[0], &hit) != 1) {
@@ -2498,8 +2499,8 @@
{
int err = 0;
hip_lsi_t lsi;
- struct in6_addr *hit;
- struct hip_tlv_common *param = NULL;
+ const struct in6_addr *hit;
+ const struct hip_tlv_common *param = NULL;
HIP_IFEL(inet_pton(AF_INET, opt[0], &lsi) != 1, -1, "inet_pton()\n");
HIP_IFEL(hip_build_user_hdr(msg, HIP_MSG_LSI_TO_HIT, 0), -1,
=== modified file 'lib/core/debug.c'
--- lib/core/debug.c 2010-07-29 13:27:02 +0000
+++ lib/core/debug.c 2010-08-19 09:32:20 +0000
@@ -680,34 +680,37 @@
*
* @param in_msg the message where the LOCATOR parameter is located
*/
-void hip_print_locator_addresses(struct hip_common *in_msg)
+void hip_print_locator_addresses(const struct hip_common *in_msg)
{
- struct hip_locator *locator;
- struct hip_locator_info_addr_item *item = NULL;
- struct hip_locator_info_addr_item2 *item2 = NULL;
- char *address_pointer;
+ const struct hip_locator *locator;
+ const struct hip_locator_info_addr_item *ptr = NULL;
+ const struct hip_locator_info_addr_item *item = NULL;
+ const struct hip_locator_info_addr_item2 *item2 = NULL;
+ const char *address_pointer;
- locator = hip_get_param((struct hip_common *) in_msg,
- HIP_PARAM_LOCATOR);
+ locator = hip_get_param(in_msg, HIP_PARAM_LOCATOR);
if (locator) {
- address_pointer = (char *) (locator + 1);
+ address_pointer = (const char *) (locator + 1);
- for (; address_pointer < ((char *) locator) + hip_get_param_contents_len(locator); ) {
- if (((struct hip_locator_info_addr_item *) address_pointer)->locator_type
- == HIP_LOCATOR_LOCATOR_TYPE_UDP) {
- item2 = (struct hip_locator_info_addr_item2 *) address_pointer;
- HIP_DEBUG_HIT("LOCATOR", (struct in6_addr *) &item2->address);
- HIP_DEBUG("Locator address offset is %d\n", address_pointer - (char *) (locator + 1));
+ for (; address_pointer < ((const char *) locator) +
+ hip_get_param_contents_len(locator); ) {
+ ptr = (const struct hip_locator_info_addr_item *) address_pointer;
+ if (ptr->locator_type == HIP_LOCATOR_LOCATOR_TYPE_UDP) {
+ item2 = (const struct hip_locator_info_addr_item2 *)
+ address_pointer;
+ HIP_DEBUG_HIT("LOCATOR", &item2->address);
+ HIP_DEBUG("Locator address offset is %d\n",
+ address_pointer - (const char *) (locator + 1));
address_pointer += sizeof(struct hip_locator_info_addr_item2);
- } else if (((struct hip_locator_info_addr_item *) address_pointer)->locator_type
- == HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI) {
- item = (struct hip_locator_info_addr_item *) address_pointer;
- HIP_DEBUG_HIT("LOCATOR", (struct in6_addr *) &item->address);
+ } else if (ptr->locator_type == HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI) {
+ item = (const struct hip_locator_info_addr_item *)
+ address_pointer;
+ HIP_DEBUG_HIT("LOCATOR", &item->address);
address_pointer += sizeof(struct hip_locator_info_addr_item);
- } else if (((struct hip_locator_info_addr_item *) address_pointer)->locator_type
- == HIP_LOCATOR_LOCATOR_TYPE_IPV6) {
- item = (struct hip_locator_info_addr_item *) address_pointer;
- HIP_DEBUG_HIT("LOCATOR", (struct in6_addr *) &item->address);
+ } else if (ptr->locator_type == HIP_LOCATOR_LOCATOR_TYPE_IPV6) {
+ item = (const struct hip_locator_info_addr_item *)
+ address_pointer;
+ HIP_DEBUG_HIT("LOCATOR", &item->address);
address_pointer += sizeof(struct hip_locator_info_addr_item);
} else {
address_pointer += sizeof(struct hip_locator_info_addr_item);
=== modified file 'lib/core/debug.h'
--- lib/core/debug.h 2010-07-29 13:27:02 +0000
+++ lib/core/debug.h 2010-08-19 09:32:20 +0000
@@ -410,7 +410,7 @@
*/
void uint32_to_binstring(uint32_t val, char *buffer);
-void hip_print_locator_addresses(struct hip_common *);
+void hip_print_locator_addresses(const struct hip_common *);
void hip_print_peer_addresses_to_be_added(hip_ha_t *);
void hip_print_peer_addresses(hip_ha_t *);
void hip_print_locator(int debug_level,
=== modified file 'lib/core/hostsfiles.c'
--- lib/core/hostsfiles.c 2010-07-29 09:58:39 +0000
+++ lib/core/hostsfiles.c 2010-08-19 09:32:20 +0000
@@ -385,7 +385,7 @@
* written. Minimum buffer length is sizeof(struct hip_hit_t)
* @return zero on successful match or non-zero otherwise
*/
-int hip_map_lsi_to_hit_from_hosts_files(hip_lsi_t *lsi, hip_hit_t *hit)
+int hip_map_lsi_to_hit_from_hosts_files(const hip_lsi_t *lsi, hip_hit_t *hit)
{
int err = 0;
uint8_t hostname[HOST_NAME_MAX];
@@ -479,7 +479,9 @@
* @param ip the resulting routable IP address if found
* @return zero on successful match or non-zero otherwise
*/
-int hip_map_id_to_ip_from_hosts_files(hip_hit_t *hit, hip_lsi_t *lsi, struct in6_addr *ip)
+int hip_map_id_to_ip_from_hosts_files(const hip_hit_t *hit,
+ const hip_lsi_t *lsi,
+ struct in6_addr *ip)
{
int err = 0;
uint8_t hostname[HOST_NAME_MAX];
=== modified file 'lib/core/hostsfiles.h'
--- lib/core/hostsfiles.h 2010-07-14 16:01:50 +0000
+++ lib/core/hostsfiles.h 2010-08-19 09:32:20 +0000
@@ -32,10 +32,10 @@
#include "protodefs.h"
-int hip_map_lsi_to_hit_from_hosts_files(hip_lsi_t *lsi, hip_hit_t *hit);
+int hip_map_lsi_to_hit_from_hosts_files(const hip_lsi_t *lsi, hip_hit_t *hit);
int hip_map_hit_to_lsi_from_hosts_files(const hip_hit_t *hit, hip_lsi_t *lsi);
-int hip_map_id_to_ip_from_hosts_files(hip_hit_t *hit,
- hip_lsi_t *lsi,
+int hip_map_id_to_ip_from_hosts_files(const hip_hit_t *hit,
+ const hip_lsi_t *lsi,
struct in6_addr *ip);
int hip_map_lsi_to_hostname_from_hosts(hip_lsi_t *lsi, char *hostname);
int hip_host_file_info_exists_lsi(hip_lsi_t *lsi);
=== modified file 'lib/core/prefix.c'
--- lib/core/prefix.c 2010-07-29 13:41:29 +0000
+++ lib/core/prefix.c 2010-08-19 09:32:20 +0000
@@ -88,7 +88,7 @@
* @param ip the IPv6 address to test
* @return one if the address is all zeroes and zero otherwise
*/
-int ipv6_addr_is_null(struct in6_addr *ip)
+int ipv6_addr_is_null(const struct in6_addr *ip)
{
return (ip->s6_addr32[0] | ip->s6_addr32[1] |
ip->s6_addr32[2] | ip->s6_addr32[3]) == 0;
@@ -410,7 +410,7 @@
}
void hip_copy_in6addr_null_check(struct in6_addr *to,
- struct in6_addr *from) {
+ const struct in6_addr *from) {
HIP_ASSERT(to);
if (from) {
ipv6_addr_copy(to, from);
@@ -420,7 +420,7 @@
}
void hip_copy_inaddr_null_check(struct in_addr *to,
- struct in_addr *from) {
+ const struct in_addr *from) {
HIP_ASSERT(to);
if (from) {
memcpy(to, from, sizeof(*to));
=== modified file 'lib/core/prefix.h'
--- lib/core/prefix.h 2010-07-29 13:41:29 +0000
+++ lib/core/prefix.h 2010-08-19 09:32:20 +0000
@@ -47,7 +47,7 @@
int ipv6_addr_is_hit(const struct in6_addr *hit);
int ipv6_addr_is_teredo(const struct in6_addr *teredo);
-int ipv6_addr_is_null(struct in6_addr *ip);
+int ipv6_addr_is_null(const struct in6_addr *ip);
int hit_is_real_hit(const struct in6_addr *hit);
int hit_is_opportunistic_hit(const struct in6_addr *hit);
void set_hit_prefix(struct in6_addr *hit);
@@ -74,9 +74,9 @@
const struct in6_addr *a2);
int ipv6_addr_any(const struct in6_addr *a);
void hip_copy_in6addr_null_check(struct in6_addr *to,
- struct in6_addr *from);
+ const struct in6_addr *from);
void hip_copy_inaddr_null_check(struct in_addr *to,
- struct in_addr *from);
+ const struct in_addr *from);
/* IN6_IS_ADDR_V4MAPPED(a) is defined in /usr/include/netinet/in.h */
=== modified file 'lib/core/solve.c'
--- lib/core/solve.c 2010-07-14 15:58:20 +0000
+++ lib/core/solve.c 2010-08-19 09:32:20 +0000
@@ -55,8 +55,8 @@
* in improving this now.
* @return The J that solves the puzzle is returned, or 0 to indicate an error.
*/
-uint64_t hip_solve_puzzle(void *puzzle_or_solution,
- struct hip_common *hdr,
+uint64_t hip_solve_puzzle(const void *puzzle_or_solution,
+ const struct hip_common *hdr,
int mode)
{
uint64_t mask = 0;
@@ -65,7 +65,7 @@
uint64_t digest = 0;
uint8_t cookie[48];
int err = 0;
- union {
+ const union {
struct hip_puzzle pz;
struct hip_solution sl;
} *u;
@@ -82,7 +82,7 @@
" (current max K=%d)\n", u->pz.K, HIP_PUZZLE_MAX_K);
mask = hton64((1ULL << u->pz.K) - 1);
- memcpy(cookie, (uint8_t *) &(u->pz.I), sizeof(uint64_t));
+ memcpy(cookie, &u->pz.I, sizeof(uint64_t));
HIP_DEBUG("(u->pz.I: 0x%llx\n", u->pz.I);
=== modified file 'lib/core/solve.h'
--- lib/core/solve.h 2010-07-14 16:01:50 +0000
+++ lib/core/solve.h 2010-08-19 09:32:20 +0000
@@ -34,7 +34,8 @@
#define HIP_PUZZLE_MAX_K 28
-uint64_t hip_solve_puzzle(void *puzzle, struct hip_common *hdr, int mode);
+uint64_t hip_solve_puzzle(const void *puzzle,
+ const struct hip_common *hdr, int mode);
int hip_solve_puzzle_m(struct hip_common *out, struct hip_common *in);
#endif /* HIP_LIB_CORE_SOLVE_H */
=== modified file 'lib/core/transform.c'
--- lib/core/transform.c 2010-07-04 17:54:18 +0000
+++ lib/core/transform.c 2010-08-19 09:32:20 +0000
@@ -40,15 +40,15 @@
* @return the first acceptable Transform-ID or negative if no
* acceptable transform was found. The return value is in host byte order.
*/
-hip_transform_suite_t hip_select_hip_transform(struct hip_hip_transform *ht)
+hip_transform_suite_t hip_select_hip_transform(const struct hip_hip_transform *ht)
{
hip_transform_suite_t tid = 0;
int i;
int length;
- hip_transform_suite_t *suggestion;
+ const hip_transform_suite_t *suggestion;
length = ntohs(ht->length);
- suggestion = (hip_transform_suite_t *) &ht->suite_id[0];
+ suggestion = (const hip_transform_suite_t *) &ht->suite_id[0];
if ((length >> 1) > 6) {
HIP_ERROR("Too many transforms (%d)\n", length >> 1);
@@ -92,14 +92,14 @@
* @return the first acceptable Suite-ID or negative if no
* acceptable Suite-ID was found.
*/
-hip_transform_suite_t hip_select_esp_transform(struct hip_esp_transform *ht)
+hip_transform_suite_t hip_select_esp_transform(const struct hip_esp_transform *ht)
{
hip_transform_suite_t tid = 0;
unsigned i, length;
- hip_transform_suite_t *suggestion;
+ const hip_transform_suite_t *suggestion;
length = hip_get_param_contents_len(ht);
- suggestion = (uint16_t *) &ht->suite_id[0];
+ suggestion = (const hip_transform_suite_t *) &ht->suite_id[0];
for (i = 0; i < length; i++) {
switch (ntohs(*suggestion)) {
=== modified file 'lib/core/transform.h'
--- lib/core/transform.h 2010-07-14 16:01:50 +0000
+++ lib/core/transform.h 2010-08-19 09:32:20 +0000
@@ -30,8 +30,8 @@
#include "protodefs.h"
-hip_transform_suite_t hip_select_esp_transform(struct hip_esp_transform *ht);
-hip_transform_suite_t hip_select_hip_transform(struct hip_hip_transform *ht);
+hip_transform_suite_t hip_select_esp_transform(const struct hip_esp_transform *);
+hip_transform_suite_t hip_select_hip_transform(const struct hip_hip_transform *);
int hip_transform_key_length(int tid);
#endif /* HIP_LIB_CORE_TRANSFORM_H */
=== modified file 'lib/tool/pk.c'
--- lib/tool/pk.c 2010-08-02 07:20:22 +0000
+++ lib/tool/pk.c 2010-08-19 09:32:20 +0000
@@ -140,12 +140,13 @@
origlen = hip_get_msg_total_len(msg);
if (hip_get_msg_type(msg) == HIP_R1) {
- HIP_IFEL(!(sig = hip_get_param(msg, HIP_PARAM_HIP_SIGNATURE2)),
+ HIP_IFEL(!(sig = hip_get_param_readwrite(msg,
+ HIP_PARAM_HIP_SIGNATURE2)),
-ENOENT, "Could not find signature2\n");
memset(&msg->hitr, 0, sizeof(struct in6_addr));
- HIP_IFEL(!(pz = hip_get_param(msg, HIP_PARAM_PUZZLE)),
+ HIP_IFEL(!(pz = hip_get_param_readwrite(msg, HIP_PARAM_PUZZLE)),
-ENOENT, "Illegal R1 packet (puzzle missing)\n");
memcpy(opaque, pz->opaque, sizeof(pz->opaque));
randi = pz->I;
@@ -153,7 +154,7 @@
memset(pz->opaque, 0, sizeof(pz->opaque));
pz->I = 0;
} else {
- HIP_IFEL(!(sig = hip_get_param(msg, HIP_PARAM_HIP_SIGNATURE)),
+ HIP_IFEL(!(sig = hip_get_param_readwrite(msg, HIP_PARAM_HIP_SIGNATURE)),
-ENOENT, "Could not find signature\n");
}
=== modified file 'modules/update/hipd/update.c'
--- modules/update/hipd/update.c 2010-08-17 17:23:18 +0000
+++ modules/update/hipd/update.c 2010-08-19 09:32:20 +0000
@@ -115,7 +115,7 @@
HIP_IFEL(hip_build_locators_old(locator_msg),
-1,
"Failed to build locators\n");
- loc = hip_get_param(locator_msg, HIP_PARAM_LOCATOR);
+ loc = hip_get_param_readwrite(locator_msg, HIP_PARAM_LOCATOR);
hip_print_locator_addresses(locator_msg);
*locators = hip_get_locator_first_addr_item(loc);
@@ -167,12 +167,12 @@
struct hip_locator_info_addr_item *locators,
int type)
{
- int err = 0;
- uint32_t esp_info_old_spi = 0, esp_info_new_spi = 0;
- uint16_t mask = 0;
- struct hip_seq *seq = NULL;
- struct hip_echo_request *echo_request = NULL;
- struct update_state *localstate = NULL;
+ int err = 0;
+ uint32_t esp_info_old_spi = 0, esp_info_new_spi = 0;
+ uint16_t mask = 0;
+ const struct hip_seq *seq = NULL;
+ const struct hip_echo_request *echo_request = NULL;
+ struct update_state *localstate = NULL;
HIP_DEBUG("Creating the UPDATE packet\n");
@@ -313,10 +313,10 @@
HIP_DEBUG("echo opaque data len=%d\n",
hip_get_param_contents_len(echo_request));
HIP_HEXDUMP("ECHO_REQUEST ",
- (uint8_t *) echo_request + sizeof(struct hip_tlv_common),
+ (const uint8_t *) echo_request + sizeof(struct hip_tlv_common),
hip_get_param_contents_len(echo_request));
HIP_IFEL(hip_build_param_echo(update_packet_to_send,
- (uint8_t *) echo_request + sizeof(struct hip_tlv_common),
+ (const uint8_t *) echo_request + sizeof(struct hip_tlv_common),
hip_get_param_contents_len(echo_request), 1, 0),
-1, "Building of ECHO_RESPONSE failed\n");
}
@@ -698,13 +698,15 @@
struct hip_locator *locator = NULL;
struct hip_esp_info *esp_info = NULL;
- locator = hip_get_param(received_update_packet, HIP_PARAM_LOCATOR);
+ locator = hip_get_param_readwrite(received_update_packet,
+ HIP_PARAM_LOCATOR);
err = hip_handle_locator_parameter(ha, src_addr, locator);
if (err) {
goto out_err;
}
- esp_info = hip_get_param(received_update_packet, HIP_PARAM_ESP_INFO);
+ esp_info = hip_get_param_readwrite(received_update_packet,
+ HIP_PARAM_ESP_INFO);
ha->spi_outbound_new = ntohl(esp_info->new_spi);
// Randomize the echo response opaque data before sending ECHO_REQUESTS.
@@ -743,7 +745,7 @@
struct in6_addr *src_addr,
struct in6_addr *dst_addr)
{
- struct hip_esp_info *esp_info = NULL;
+ const struct hip_esp_info *esp_info = NULL;
hip_send_update_to_one_peer(received_update_packet,
ha,
@@ -874,7 +876,7 @@
{
int err = 0;
unsigned int has_esp_info = 0;
- struct hip_esp_info *esp_info = NULL;
+ const struct hip_esp_info *esp_info = NULL;
#ifdef CONFIG_HIP_PERFORMANCE
HIP_DEBUG("Start PERF_UPDATE\n");
hip_perf_start_benchmark(perf_set, PERF_UPDATE);
@@ -942,14 +944,14 @@
struct hip_packet_context *ctx)
{
int err = 0, same_seq = 0;
- unsigned int ack_peer_update_id = 0;
- unsigned int seq_update_id = 0;
- struct hip_seq *seq = NULL;
- struct hip_ack *ack = NULL;
- struct hip_locator *locator = NULL;
- struct hip_echo_request *echo_request = NULL;
- struct hip_echo_response *echo_response = NULL;
- struct update_state *localstate = NULL;
+ unsigned int ack_peer_update_id = 0;
+ unsigned int seq_update_id = 0;
+ const struct hip_seq *seq = NULL;
+ const struct hip_ack *ack = NULL;
+ const struct hip_locator *locator = NULL;
+ const struct hip_echo_request *echo_request = NULL;
+ const struct hip_echo_response *echo_response = NULL;
+ struct update_state *localstate = NULL;
/* RFC 5201 Section 5.4.4: If there is no corresponding HIP association,
* the implementation MAY reply with an ICMP Parameter Problem. */
=== modified file 'tools/pisacert.c'
--- tools/pisacert.c 2010-08-18 16:34:37 +0000
+++ tools/pisacert.c 2010-08-19 09:32:20 +0000
@@ -52,10 +52,10 @@
*/
static int get_default_hit(struct in6_addr *result)
{
- int err = 0;
- hip_common_t *msg = NULL;
- struct hip_tlv_common *param = NULL;
- struct in6_addr *hit = NULL;
+ int err = 0;
+ hip_common_t *msg = NULL;
+ const struct hip_tlv_common *param = NULL;
+ const struct in6_addr *hit = NULL;
msg = hip_msg_alloc();
HIP_IFE(!msg, -1);
Follow ups