%%% utilities */ Take a key message (sadb_key) from the socket and turn it into one * of the kernel's key structures (seckey). * * IN: pointer to the src * OUT: NULL no more memory */
| 4045 | * OUT: NULL no more memory |
| 4046 | */ |
| 4047 | struct seckey * |
| 4048 | key_dup_keymsg(const struct sadb_key *src, size_t len, |
| 4049 | struct malloc_type *type) |
| 4050 | { |
| 4051 | struct seckey *dst; |
| 4052 | |
| 4053 | dst = malloc(sizeof(*dst), type, M_NOWAIT); |
| 4054 | if (dst != NULL) { |
| 4055 | dst->bits = src->sadb_key_bits; |
| 4056 | dst->key_data = malloc(len, type, M_NOWAIT); |
| 4057 | if (dst->key_data != NULL) { |
| 4058 | bcopy((const char *)(src + 1), dst->key_data, len); |
| 4059 | } else { |
| 4060 | ipseclog((LOG_DEBUG, "%s: No more memory.\n", |
| 4061 | __func__)); |
| 4062 | free(dst, type); |
| 4063 | dst = NULL; |
| 4064 | } |
| 4065 | } else { |
| 4066 | ipseclog((LOG_DEBUG, "%s: No more memory.\n", |
| 4067 | __func__)); |
| 4068 | } |
| 4069 | return (dst); |
| 4070 | } |
| 4071 | |
| 4072 | /* Take a lifetime message (sadb_lifetime) passed in on a socket and |
| 4073 | * turn it into one of the kernel's lifetime structures (seclifetime). |
no test coverage detected