* Set a port in sadb_x_nat_t_port. * In contrast to default RFC 2367 behaviour, port is in network byte order. */
| 3940 | * In contrast to default RFC 2367 behaviour, port is in network byte order. |
| 3941 | */ |
| 3942 | static struct mbuf * |
| 3943 | key_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. |
no test coverage detected