MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tcp_keyed_hash

Function tcp_keyed_hash

freebsd/netinet/tcp_subr.c:2714–2743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2712#endif /* INET6 */
2713
2714static uint32_t
2715tcp_keyed_hash(struct in_conninfo *inc, u_char *key, u_int len)
2716{
2717 SIPHASH_CTX ctx;
2718 uint32_t hash[2];
2719
2720 KASSERT(len >= SIPHASH_KEY_LENGTH,
2721 ("%s: keylen %u too short ", __func__, len));
2722 SipHash24_Init(&ctx);
2723 SipHash_SetKey(&ctx, (uint8_t *)key);
2724 SipHash_Update(&ctx, &inc->inc_fport, sizeof(uint16_t));
2725 SipHash_Update(&ctx, &inc->inc_lport, sizeof(uint16_t));
2726 switch (inc->inc_flags & INC_ISIPV6) {
2727#ifdef INET
2728 case 0:
2729 SipHash_Update(&ctx, &inc->inc_faddr, sizeof(struct in_addr));
2730 SipHash_Update(&ctx, &inc->inc_laddr, sizeof(struct in_addr));
2731 break;
2732#endif
2733#ifdef INET6
2734 case INC_ISIPV6:
2735 SipHash_Update(&ctx, &inc->inc6_faddr, sizeof(struct in6_addr));
2736 SipHash_Update(&ctx, &inc->inc6_laddr, sizeof(struct in6_addr));
2737 break;
2738#endif
2739 }
2740 SipHash_Final((uint8_t *)hash, &ctx);
2741
2742 return (hash[0] ^ hash[1]);
2743}
2744
2745uint32_t
2746tcp_new_ts_offset(struct in_conninfo *inc)

Callers 2

tcp_new_ts_offsetFunction · 0.85
tcp_new_isnFunction · 0.85

Calls 3

SipHash_SetKeyFunction · 0.85
SipHash_UpdateFunction · 0.85
SipHash_FinalFunction · 0.85

Tested by

no test coverage detected