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

Function key_setsadbaddr

freebsd/netipsec/key.c:3813–3854  ·  view source on GitHub ↗

* set data into sadb_address. */

Source from the content-addressed store, hash-verified

3811 * set data into sadb_address.
3812 */
3813static struct mbuf *
3814key_setsadbaddr(u_int16_t exttype, const struct sockaddr *saddr,
3815 u_int8_t prefixlen, u_int16_t ul_proto)
3816{
3817 struct mbuf *m;
3818 struct sadb_address *p;
3819 size_t len;
3820
3821 len = PFKEY_ALIGN8(sizeof(struct sadb_address)) +
3822 PFKEY_ALIGN8(saddr->sa_len);
3823 m = m_get2(len, M_NOWAIT, MT_DATA, 0);
3824 if (m == NULL)
3825 return (NULL);
3826 m_align(m, len);
3827 m->m_len = len;
3828 p = mtod(m, struct sadb_address *);
3829
3830 bzero(p, len);
3831 p->sadb_address_len = PFKEY_UNIT64(len);
3832 p->sadb_address_exttype = exttype;
3833 p->sadb_address_proto = ul_proto;
3834 if (prefixlen == FULLMASK) {
3835 switch (saddr->sa_family) {
3836 case AF_INET:
3837 prefixlen = sizeof(struct in_addr) << 3;
3838 break;
3839 case AF_INET6:
3840 prefixlen = sizeof(struct in6_addr) << 3;
3841 break;
3842 default:
3843 ; /*XXX*/
3844 }
3845 }
3846 p->sadb_address_prefixlen = prefixlen;
3847 p->sadb_address_reserved = 0;
3848
3849 bcopy(saddr,
3850 mtod(m, caddr_t) + PFKEY_ALIGN8(sizeof(struct sadb_address)),
3851 saddr->sa_len);
3852
3853 return m;
3854}
3855
3856/*
3857 * set data into sadb_x_sa2.

Callers 5

key_setdumpspFunction · 0.85
key_spdexpireFunction · 0.85
key_setdumpsaFunction · 0.85
key_acquireFunction · 0.85
key_expireFunction · 0.85

Calls 3

m_get2Function · 0.85
bzeroFunction · 0.85
m_alignFunction · 0.50

Tested by

no test coverage detected