Committer: Tim Just <tim.just@xxxxxxxxxxxxxx> Date: Thu Feb 18 11:56:34 2010 +0100 Revision: 3533 Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Branch nick: tiny Log: Added 'struct update_state' and an initialization function for it. The struct contains the update-specific parts of 'struct hip_hadb_state'. Next steps will be removing these entries from hip_hadb_state and change the member accesses. Modified: M modules/update/hipd/update.c M modules/update/hipd/update.h === modified file 'modules/update/hipd/update.c' --- modules/update/hipd/update.c 2010-02-18 09:35:10 +0000 +++ modules/update/hipd/update.c 2010-02-18 10:56:34 +0000 @@ -798,3 +798,28 @@ { return 0; } + +/** + * Initialize an update_state instance. + * + * Allocates the required memory and sets the members to the start values. + * + * @return Success = Pointer to the new data structure + * Error = NULL + */ +struct update_state *hip_update_init_state(void) +{ + struct update_state *state; + + if ((state = (struct update_state*) malloc(sizeof(struct update_state))) == NULL) { + HIP_ERROR("Error on allocating memory for a update_state instance.\n"); + return NULL; + } + state->update_state = 0; + state->hadb_update_func = NULL; + state->addresses_to_send_echo_request = malloc(sizeof(hip_list_t)); + state->update_id_out = 0; + state->update_id_in = 0; + + return state; +} === modified file 'modules/update/hipd/update.h' --- modules/update/hipd/update.h 2010-02-18 09:35:10 +0000 +++ modules/update/hipd/update.h 2010-02-18 10:56:34 +0000 @@ -12,6 +12,34 @@ #include "lib/core/builder.h" #include "hipd/hadb.h" +struct update_state { + /** A kludge to get the UPDATE retransmission to work. + @todo Remove this kludge. */ + int update_state; + + /** Update function set. + @note Do not modify this value directly. Use + hip_hadb_set_handle_function_set() instead. */ + hip_update_func_set_t *hadb_update_func; + + /** This "linked list" includes the locators we recieved in the initial + * UPDATE packet. Locators are stored as "struct in6_addr *"s. + * + * Hipd sends UPDATE packets including ECHO_REQUESTS to all these + * addresses. + * + * Notice that there's a hack that a hash table is used as a linked list + * here but this is common allover HIPL and it doesn't seem to cause + * performance problems. + */ + HIP_HASHTABLE *addresses_to_send_echo_request; + + /** Stored outgoing UPDATE ID counter. */ + uint32_t update_id_out; + /** Stored incoming UPDATE ID counter. */ + uint32_t update_id_in; +}; + /** * Sends all the locators from our active source address to the active * destination addresses of all peers. @@ -50,4 +78,6 @@ int hip_update_init(void); +struct update_state *hip_update_init_state(void); + #endif /* HIP_HIPD_UPDATE_H */