Committer: Miika Komu <miika@xxxxxx> Date: 17/03/2010 at 19:23:35 Revision: 3991 Revision-id: miika@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Branch nick: trunk Log: Added missing doxygen for init.c Modified: D hipd/init.c.doxyme M hipd/init.c === modified file 'hipd/init.c' --- hipd/init.c 2010-03-14 14:05:28 +0000 +++ hipd/init.c 2010-03-17 17:23:33 +0000 @@ -1,7 +1,9 @@ /** @file + * + * Distributed under <a href="http://www.gnu.org/licenses/gpl2.txt";>GNU/GPL</a>. + * * This file defines initialization functions for the HIP daemon. * - * @note Distributed under <a href="http://www.gnu.org/licenses/gpl2.txt";>GNU/GPL</a>. * @note HIPU: BSD platform needs to be autodetected in hip_set_lowcapability */ @@ -81,7 +83,11 @@ static struct hip_host_id_entry *hip_return_first_rsa(void); /******************************************************************************/ -/** Catch SIGCHLD. */ +/** + * Catch SIGCHLD. + * + * @param signum the signal number to catch + */ static void hip_sig_chld(int signum) { #ifdef ANDROID_CHANGES @@ -101,6 +107,13 @@ } } +/** + * set or unset close-on-exec flag for a given file descriptor + * + * @param desc the file descriptor + * @param value 1 if to set or zero for unset + * @return the previous flags + */ static int set_cloexec_flag(int desc, int value) { int oldflags = fcntl(desc, F_GETFD, 0); @@ -121,6 +134,9 @@ #ifndef CONFIG_HIP_OPENWRT #ifdef CONFIG_HIP_DEBUG +/** + * print information about underlying the system for bug reports + */ static void hip_print_sysinfo(void) { FILE *fp = NULL; @@ -228,8 +244,11 @@ #endif #endif -/* +/** * Create a file with the given contents unless it already exists + * + * @param path the file with its path + * @param contents a string to write to the file */ static void hip_create_file_unless_exists(const char *path, const char *contents) { @@ -245,6 +264,9 @@ fclose(fp); } +/** + * load hipd configuration files + */ static void hip_load_configuration(void) { const char *cfile = "default"; @@ -270,6 +292,9 @@ hip_conf_handle_load(NULL, ACTION_LOAD, &cfile, 1, 1); } +/** + * initialize OS-dependent variables + */ static void hip_set_os_dep_variables(void) { struct utsname un; @@ -307,8 +332,9 @@ #ifdef CONFIG_HIP_AGENT /** - * hip_init_daemon_hitdb - The function initializes the database at daemon - * which receives the information from agent to be stored + * initialize the graphical agent database + * + * @return zero on success or negative on failure */ static int hip_init_daemon_hitdb(void) { @@ -326,7 +352,11 @@ #endif /* CONFIG_HIP_AGENT */ /** - * Initialize raw ipv4 socket. + * initialize a raw ipv4 socket + * + * @param hip_raw_sock_v4 the raw socket to initialize + * @param proto the protocol for the raw socket + * @return zero on success or negative on failure */ static int hip_init_raw_sock_v4(int *hip_raw_sock_v4, int proto) { @@ -352,7 +382,10 @@ } /** - * Initialize icmpv6 socket. + * initialize icmpv6 socket for heartbeats + * + * @param icmpsockfd the socket to initialize + * @return zero on success or negative on failure */ static int hip_init_icmp_v6(int *icmpsockfd) { @@ -380,12 +413,11 @@ return err; } +#ifndef CONFIG_HIP_OPENWRT +#ifndef ANDROID_CHANGES /** - * Probe kernel modules. + * probe for kernel modules (linux specific) */ - -#ifndef CONFIG_HIP_OPENWRT -#ifndef ANDROID_CHANGES static void hip_probe_kernel_modules(void) { int count, err, status; @@ -431,6 +463,11 @@ /** * Main initialization function for HIP daemon. + * + * @param flush_ipsec one if ipsec should be flushed or zero otherwise + * @param killold one if an existing hipd process should be killed or + * zero otherwise + * @return zero on success or negative on failure */ int hipd_init(int flush_ipsec, int killold) { @@ -679,9 +716,9 @@ } /** - * Function initializes needed variables for the OpenDHT + * initialize the needed variables for DHT * - * Returns positive on success negative otherwise + * @return zero on success or negative on failure */ int hip_init_dht() { @@ -802,7 +839,9 @@ } /** - * Initialize host IDs. + * Initialize local host IDs. + * + * @return zero on success or negative on failure */ static int hip_init_host_ids() { @@ -895,7 +934,12 @@ } /** - * Init raw ipv6 socket. + * Init raw ipv6 socket + * + * @param hip_raw_sock_v6 the socket to initialize + * @param proto protocol for the socket + * + * @return zero on success or negative on failure */ static int hip_init_raw_sock_v6(int *hip_raw_sock_v6, int proto) { @@ -917,6 +961,16 @@ return err; } +/** + * create a socket to handle UDP encapsulation of HIP control + * packets + * + * @param hip_nat_sock_udp the socket to initialize + * @param addr the address to which the socket should be bound + * @param is_output one if the socket is to be used for output + * or zero for input + * @return zero on success or negative on failure + */ int hip_create_nat_sock_udp(int *hip_nat_sock_udp, struct sockaddr_in *addr, int is_output) @@ -988,7 +1042,9 @@ } /** - * Start closing HIP daemon. + * exit gracefully by sending CLOSE to all peers + * + * @param signal the signal hipd received from OS */ void hip_close(int signal) { @@ -1014,6 +1070,8 @@ /** * Cleanup and signal handler to free userspace and kernel space * resource allocations. + * + * @param signal the signal hipd received */ void hip_exit(int signal) { @@ -1150,6 +1208,8 @@ /** * Initialize random seed. + * + * @return zero on success or negative on failure */ static int init_random_seed() { @@ -1174,6 +1234,11 @@ return err; } +/** + * Initialize certificates for the local host + * + * @return zero on success or negative on failure + */ static int hip_init_certs(void) { int err = 0; @@ -1243,6 +1308,11 @@ return err; } +/** + * find the first RSA-based host id + * + * @return the host id or NULL if none found + */ static struct hip_host_id_entry *hip_return_first_rsa(void) { hip_list_t *curr, *iter;