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

Function key_setsadbxport

freebsd/netipsec/key.c:3942–3964  ·  view source on GitHub ↗

* Set a port in sadb_x_nat_t_port. * In contrast to default RFC 2367 behaviour, port is in network byte order. */

Source from the content-addressed store, hash-verified

3940 * In contrast to default RFC 2367 behaviour, port is in network byte order.
3941 */
3942static struct mbuf *
3943key_setsadbxport(u_int16_t port, u_int16_t type)
3944{
3945 struct mbuf *m;
3946 size_t len;
3947 struct sadb_x_nat_t_port *p;
3948
3949 len = PFKEY_ALIGN8(sizeof(struct sadb_x_nat_t_port));
3950
3951 m = m_get2(len, M_NOWAIT, MT_DATA, 0);
3952 if (m == NULL)
3953 return (NULL);
3954 m_align(m, len);
3955 m->m_len = len;
3956 p = mtod(m, struct sadb_x_nat_t_port *);
3957
3958 bzero(p, len);
3959 p->sadb_x_nat_t_port_len = PFKEY_UNIT64(len);
3960 p->sadb_x_nat_t_port_exttype = type;
3961 p->sadb_x_nat_t_port_port = port;
3962
3963 return (m);
3964}
3965
3966/*
3967 * Get port from sockaddr. Port is in network byte order.

Callers 1

key_setdumpsaFunction · 0.85

Calls 3

m_get2Function · 0.85
bzeroFunction · 0.85
m_alignFunction · 0.50

Tested by

no test coverage detected