Committer: Diego Biurrun <diego@xxxxxxxxxx> Date: 21/04/2010 at 19:09:16 Revision: 4389 Revision-id: diego@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Branch nick: trunk Log: Replace BSD integer types by standard POSIX types. Modified: M firewall/midauth.c M hipd/pfkeyapi.c M lib/core/solve.c M lib/tool/pfkeysadb.c M lib/tool/pfkeysadb.h M test/performance/cookiesolver.c === modified file 'firewall/midauth.c' --- firewall/midauth.c 2010-04-09 16:24:44 +0000 +++ firewall/midauth.c 2010-04-21 16:08:58 +0000 @@ -83,8 +83,8 @@ static void update_udp_header(struct iphdr *ip, int len) { unsigned long sum; - u_int16_t *w = (u_int16_t *) ((unsigned char *) ip + (ip->ihl * 4)); - u_int16_t protocol = ntohs(IPPROTO_UDP); + uint16_t *w = (uint16_t *) ((unsigned char *) ip + (ip->ihl * 4)); + uint16_t protocol = ntohs(IPPROTO_UDP); int i; struct udphdr *udp = (struct udphdr *) w; @@ -106,7 +106,7 @@ } /* add UDP pseudoheader */ - w = (u_int16_t *) &ip->saddr; + w = (uint16_t *) &ip->saddr; for (i = 0; i < 4; w++, i++) { sum += *w; } @@ -134,10 +134,10 @@ memset(&dst, 0, sizeof(dst)); src.sin_family = AF_INET; - memcpy(&src.sin_addr, &ip->saddr, sizeof(u_int32_t)); + memcpy(&src.sin_addr, &ip->saddr, sizeof(uint32_t)); dst.sin_family = AF_INET; - memcpy(&dst.sin_addr, &ip->daddr, sizeof(u_int32_t)); + memcpy(&dst.sin_addr, &ip->daddr, sizeof(uint32_t)); hip_zero_msg_checksum(msg); msg->checksum = hip_checksum_packet((char *) msg, === modified file 'hipd/pfkeyapi.c' --- hipd/pfkeyapi.c 2010-04-16 18:50:27 +0000 +++ hipd/pfkeyapi.c 2010-04-21 16:08:58 +0000 @@ -186,24 +186,24 @@ { int so, len, err = 0, e_keylen, a_keylen; int aalg = ealg; - u_int wsize = 4; /* XXX static size of window */ + unsigned int wsize = 4; /* XXX static size of window */ struct sockaddr_storage ss_addr, dd_addr; struct sockaddr *s_saddr; struct sockaddr *d_saddr; uint32_t reqid = 0; - u_int32_t seq = 0; - u_int flags = 0; // always zero - u_int64_t lifebyte = 0, lifetime = 0; - u_int8_t l_natt_type = HIP_UDP_ENCAP_ESPINUDP; + uint32_t seq = 0; + unsigned int flags = 0; // always zero + uint64_t lifebyte = 0, lifetime = 0; + uint8_t l_natt_type = HIP_UDP_ENCAP_ESPINUDP; // FIXME: this parameter maybe should be related to some esp parameters (according to racoon source code) - u_int16_t l_natt_frag = 0; + uint16_t l_natt_frag = 0; /* Mappings from HIP to PFKEY algo names */ - u_int e_types[] = {SADB_EALG_NULL, SADB_X_EALG_AESCBC, SADB_EALG_3DESCBC, SADB_EALG_3DESCBC, - SADB_X_EALG_BLOWFISHCBC, SADB_EALG_NULL, SADB_EALG_NULL}; - u_int a_algos[] = {SADB_AALG_NONE, SADB_AALG_SHA1HMAC, SADB_AALG_SHA1HMAC, SADB_AALG_MD5HMAC, - SADB_AALG_SHA1HMAC, SADB_AALG_SHA1HMAC, SADB_AALG_MD5HMAC}; - u_int e_type = e_types[ealg]; - u_int a_type = a_algos[aalg]; + unsigned int e_types[] = {SADB_EALG_NULL, SADB_X_EALG_AESCBC, SADB_EALG_3DESCBC, SADB_EALG_3DESCBC, + SADB_X_EALG_BLOWFISHCBC, SADB_EALG_NULL, SADB_EALG_NULL}; + unsigned int a_algos[] = {SADB_AALG_NONE, SADB_AALG_SHA1HMAC, SADB_AALG_SHA1HMAC, SADB_AALG_MD5HMAC, + SADB_AALG_SHA1HMAC, SADB_AALG_SHA1HMAC, SADB_AALG_MD5HMAC}; + unsigned int e_type = e_types[ealg]; + unsigned int a_type = a_algos[aalg]; in_port_t sport = entry->local_udp_port; in_port_t dport = entry->peer_udp_port; @@ -301,8 +301,9 @@ * @param direction input or output direction * @return zero on success and non-zero on error */ -static int hip_pfkey_policy_modify(int so, const hip_hit_t *src_hit, u_int prefs, - const hip_hit_t *dst_hit, u_int prefd, +static int hip_pfkey_policy_modify(int so, const hip_hit_t *src_hit, + unsigned int prefs, + const hip_hit_t *dst_hit, unsigned int prefd, const struct in6_addr *src_addr, const struct in6_addr *dst_addr, uint8_t proto, int cmd, int direction) @@ -314,7 +315,7 @@ caddr_t policy = NULL; int policylen = 0; int len = 0; - u_int mode; + unsigned int mode; HIP_DEBUG("\n"); // Sanity check HIP_IFEL((src_hit == NULL || dst_hit == NULL), -1, "Invalid hit's\n"); === modified file 'lib/core/solve.c' --- lib/core/solve.c 2010-04-16 01:36:19 +0000 +++ lib/core/solve.c 2010-04-21 16:08:58 +0000 @@ -66,7 +66,7 @@ ipv6_addr_copy((hip_hit_t *) (cookie + 8), &hdr->hitr); ipv6_addr_copy((hip_hit_t *) (cookie + 24), &hdr->hits); maxtries = 1ULL << (u->pz.K + 3); - get_random_bytes(&randval, sizeof(u_int64_t)); + get_random_bytes(&randval, sizeof(uint64_t)); } else { HIP_IFEL(1, 0, "Unknown mode: %d\n", mode); } === modified file 'lib/tool/pfkeysadb.c' --- lib/tool/pfkeysadb.c 2010-04-16 01:30:31 +0000 +++ lib/tool/pfkeysadb.c 2010-04-21 16:08:58 +0000 @@ -35,7 +35,8 @@ * @param cmd add or delete */ int getsadbpolicy(caddr_t *policy0, int *policylen0, int direction, - struct sockaddr *src, struct sockaddr *dst, u_int mode, int cmd) + struct sockaddr *src, struct sockaddr *dst, + unsigned int mode, int cmd) { struct sadb_x_policy *xpl; struct sadb_x_ipsecrequest *xisr; === modified file 'lib/tool/pfkeysadb.h' --- lib/tool/pfkeysadb.h 2010-04-21 14:47:24 +0000 +++ lib/tool/pfkeysadb.h 2010-04-21 16:08:58 +0000 @@ -7,6 +7,7 @@ #include <sys/types.h> int getsadbpolicy(caddr_t *policy0, int *policylen0, int direction, - struct sockaddr *src, struct sockaddr *dst, u_int mode, int cmd); + struct sockaddr *src, struct sockaddr *dst, + unsigned int mode, int cmd); #endif /* HIP_LIB_TOOL_PFKEYSADB_H */ === modified file 'test/performance/cookiesolver.c' --- test/performance/cookiesolver.c 2010-03-19 09:00:54 +0000 +++ test/performance/cookiesolver.c 2010-04-21 16:08:58 +0000 @@ -36,15 +36,15 @@ } __attribute__ ((packed)); -u_int64_t calculate_digest(unsigned char *data, const u_int64_t j) +uint64_t calculate_digest(unsigned char *data, const uint64_t j) { unsigned char buf[SHA_DIGEST_LENGTH]; // openssl - u_int64_t result = 0; + uint64_t result = 0; - memcpy(&(data[40]), &j, sizeof(u_int64_t)); + memcpy(&(data[40]), &j, sizeof(uint64_t)); SHA1((unsigned char *)data,48,buf); - memcpy(&result,buf+(SHA_DIGEST_LENGTH-sizeof(u_int64_t)),sizeof(u_int64_t)); + memcpy(&result,buf+(SHA_DIGEST_LENGTH-sizeof(uint64_t)),sizeof(uint64_t)); return (ntoh64(result)); } @@ -60,10 +60,10 @@ int solve_puzzle(struct hip_birthday_cookie *cookie, const struct in6_addr *initiator, const struct in6_addr *responder) { - u_int64_t challenge_resp = 0; - u_int64_t randval = 0; /* j */ - u_int64_t mask = 0; - u_int64_t maxtries = 0; + uint64_t challenge_resp = 0; + uint64_t randval = 0; /* j */ + uint64_t mask = 0; + uint64_t maxtries = 0; unsigned char cookiebuffer[48]; if (cookie->random_j_k > 64) { @@ -79,7 +79,7 @@ maxtries = (1ULL << (cookie->random_j_k + 2)); /* prepare the cookie digest note: random_i must be in MSB order (network). - * sizeof(u_int64_t) is not used instead of 8 since we are dependent on getting + * sizeof(uint64_t) is not used instead of 8 since we are dependent on getting * 8 bytes of data. no less and/or no more. */