* set data into sadb_x_policy */
| 4012 | * set data into sadb_x_policy |
| 4013 | */ |
| 4014 | static struct mbuf * |
| 4015 | key_setsadbxpolicy(u_int16_t type, u_int8_t dir, u_int32_t id, u_int32_t priority) |
| 4016 | { |
| 4017 | struct mbuf *m; |
| 4018 | struct sadb_x_policy *p; |
| 4019 | size_t len; |
| 4020 | |
| 4021 | len = PFKEY_ALIGN8(sizeof(struct sadb_x_policy)); |
| 4022 | m = m_get2(len, M_NOWAIT, MT_DATA, 0); |
| 4023 | if (m == NULL) |
| 4024 | return (NULL); |
| 4025 | m_align(m, len); |
| 4026 | m->m_len = len; |
| 4027 | p = mtod(m, struct sadb_x_policy *); |
| 4028 | |
| 4029 | bzero(p, len); |
| 4030 | p->sadb_x_policy_len = PFKEY_UNIT64(len); |
| 4031 | p->sadb_x_policy_exttype = SADB_X_EXT_POLICY; |
| 4032 | p->sadb_x_policy_type = type; |
| 4033 | p->sadb_x_policy_dir = dir; |
| 4034 | p->sadb_x_policy_id = id; |
| 4035 | p->sadb_x_policy_priority = priority; |
| 4036 | |
| 4037 | return m; |
| 4038 | } |
| 4039 | |
| 4040 | /* %%% utilities */ |
| 4041 | /* Take a key message (sadb_key) from the socket and turn it into one |
no test coverage detected