Lines Matching defs:mhp

1997 key_gather_mbuf(struct mbuf *m, const struct sadb_msghdr *mhp,
2005 if (m == NULL || mhp == NULL)
2013 if (idx == SADB_EXT_RESERVED && mhp->msg == NULL)
2016 (mhp->ext[idx] == NULL || mhp->extlen[idx] == 0))
2033 len = mhp->extlen[idx];
2040 m_copydata(m, mhp->extoff[idx], mhp->extlen[idx],
2043 n = m_copym(m, mhp->extoff[idx], mhp->extlen[idx],
2088 const struct sadb_msghdr *mhp)
2101 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
2104 if (mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
2105 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL ||
2106 mhp->ext[SADB_X_EXT_POLICY] == NULL) {
2110 if (mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
2111 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address) ||
2112 mhp->extlen[SADB_X_EXT_POLICY] < sizeof(struct sadb_x_policy)) {
2116 if (mhp->ext[SADB_EXT_LIFETIME_HARD] != NULL) {
2117 if (mhp->extlen[SADB_EXT_LIFETIME_HARD]
2123 (void *)mhp->ext[SADB_EXT_LIFETIME_HARD];
2126 src0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_SRC];
2127 dst0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_DST];
2128 xpl0 = (struct sadb_x_policy *)(void *)mhp->ext[SADB_X_EXT_POLICY];
2147 mhp->msg->sadb_msg_errno = EINVAL;
2160 if (mhp->msg->sadb_msg_type != SADB_X_SPDSETIDX
2162 && mhp->extlen[SADB_X_EXT_POLICY] <= sizeof(*xpl0)) {
2175 if (mhp->msg->sadb_msg_type == SADB_X_SPDUPDATE) {
2281 if (mhp->msg->sadb_msg_type == SADB_X_SPDUPDATE) {
2302 n = key_gather_mbuf(m, mhp, 2, sizeof(mbufItems)/sizeof(int), mbufItems);
2306 n = key_gather_mbuf(m, mhp, 2, sizeof(mbufItems)/sizeof(int), mbufItems);
2387 const struct sadb_msghdr *mhp)
2397 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
2400 if (mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
2401 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL ||
2402 mhp->ext[SADB_X_EXT_POLICY] == NULL) {
2406 if (mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
2407 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address) ||
2408 mhp->extlen[SADB_X_EXT_POLICY] < sizeof(struct sadb_x_policy)) {
2413 src0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_SRC];
2414 dst0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_DST];
2415 xpl0 = (struct sadb_x_policy *)(void *)mhp->ext[SADB_X_EXT_POLICY];
2460 n = key_gather_mbuf(m, mhp, 1, sizeof(mbufItems)/sizeof(int), mbufItems);
2489 const struct sadb_msghdr *mhp)
2497 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
2500 if (mhp->ext[SADB_X_EXT_POLICY] == NULL ||
2501 mhp->extlen[SADB_X_EXT_POLICY] < sizeof(struct sadb_x_policy)) {
2508 (void *)mhp->ext[SADB_X_EXT_POLICY])->sadb_x_policy_id;
2555 n->m_next = m_copym(m, mhp->extoff[SADB_X_EXT_POLICY],
2556 mhp->extlen[SADB_X_EXT_POLICY], M_WAITOK);
2591 const struct sadb_msghdr *mhp)
2600 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
2603 if (mhp->ext[SADB_X_EXT_POLICY] == NULL ||
2604 mhp->extlen[SADB_X_EXT_POLICY] < sizeof(struct sadb_x_policy)) {
2610 (void *)mhp->ext[SADB_X_EXT_POLICY])->sadb_x_policy_id;
2620 n = key_setdumpsp(sp, SADB_X_SPDGET, 0, mhp->msg->sadb_msg_pid);
2722 const struct sadb_msghdr *mhp)
2729 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
2775 const struct sadb_msghdr *mhp)
2784 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
2821 mhp->msg->sadb_msg_pid);
3047 * allocating a memory for new SA head, and copy from the values of mhp.
3164 * and copy the values of mhp into new buffer.
3177 const struct sadb_msghdr *mhp,
3187 if (m == NULL || mhp == NULL || mhp->msg == NULL || sah == NULL)
3203 switch (mhp->msg->sadb_msg_type) {
3209 if (mhp->msg->sadb_msg_seq == 0)
3214 newsav->seq = mhp->msg->sadb_msg_seq;
3219 if (mhp->ext[SADB_EXT_SA] == NULL) {
3225 xsa = (struct sadb_sa *)(void *)mhp->ext[SADB_EXT_SA];
3227 newsav->seq = mhp->msg->sadb_msg_seq;
3236 if (mhp->msg->sadb_msg_type != SADB_GETSPI) {
3237 *errp = key_setsaval(newsav, m, mhp);
3253 newsav->pid = mhp->msg->sadb_msg_pid;
3576 const struct sadb_msghdr *mhp)
3587 if (m == NULL || mhp == NULL || mhp->msg == NULL)
3605 if (mhp->ext[SADB_EXT_SA] != NULL) {
3608 sa0 = (struct sadb_sa *)(void *)mhp->ext[SADB_EXT_SA];
3609 if (mhp->extlen[SADB_EXT_SA] < sizeof(*sa0)) {
3624 if (mhp->extlen[SADB_EXT_SA] < sizeof(struct sadb_sa_2) ||
3655 if (mhp->ext[SADB_EXT_KEY_AUTH] != NULL) {
3659 key0 = (const struct sadb_key *)mhp->ext[SADB_EXT_KEY_AUTH];
3660 len = mhp->extlen[SADB_EXT_KEY_AUTH];
3668 switch (mhp->msg->sadb_msg_satype) {
3694 if (mhp->ext[SADB_EXT_KEY_ENCRYPT] != NULL) {
3698 key0 = (const struct sadb_key *)mhp->ext[SADB_EXT_KEY_ENCRYPT];
3699 len = mhp->extlen[SADB_EXT_KEY_ENCRYPT];
3707 switch (mhp->msg->sadb_msg_satype) {
3741 switch (mhp->msg->sadb_msg_satype) {
3808 (void *)mhp->ext[SADB_EXT_LIFETIME_HARD];
3810 if (mhp->extlen[SADB_EXT_LIFETIME_HARD] < sizeof(*lft0)) {
3826 (void *)mhp->ext[SADB_EXT_LIFETIME_SOFT];
3828 if (mhp->extlen[SADB_EXT_LIFETIME_SOFT] < sizeof(*lft0)) {
5707 * IN: mhp: pointer to the pointer to each header.
5715 const struct sadb_msghdr *mhp)
5730 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
5733 if (mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
5734 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL) {
5738 if (mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
5739 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address)) {
5743 if (mhp->ext[SADB_X_EXT_SA2] != NULL) {
5745 (void *)mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_mode;
5747 (void *)mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_reqid;
5753 src0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_SRC]);
5754 dst0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_DST]);
5757 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
5803 (void *)mhp->ext[SADB_EXT_SPIRANGE], &saidx);
5821 newsav = key_newsav(m, mhp, newsah, &error);
5833 if (mhp->msg->sadb_msg_seq != 0) {
5835 if ((acq = key_getacqbyseq(mhp->msg->sadb_msg_seq)) != NULL) {
5889 n->m_next = key_gather_mbuf(m, mhp, 0, sizeof(mbufItems)/sizeof(int), mbufItems);
6067 const struct sadb_msghdr *mhp)
6082 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
6086 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
6091 if (mhp->ext[SADB_EXT_SA] == NULL ||
6092 mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
6093 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL ||
6094 (mhp->msg->sadb_msg_satype == SADB_SATYPE_ESP &&
6095 mhp->ext[SADB_EXT_KEY_ENCRYPT] == NULL) ||
6096 (mhp->msg->sadb_msg_satype == SADB_SATYPE_AH &&
6097 mhp->ext[SADB_EXT_KEY_AUTH] == NULL) ||
6098 (mhp->ext[SADB_EXT_LIFETIME_HARD] != NULL &&
6099 mhp->ext[SADB_EXT_LIFETIME_SOFT] == NULL) ||
6100 (mhp->ext[SADB_EXT_LIFETIME_HARD] == NULL &&
6101 mhp->ext[SADB_EXT_LIFETIME_SOFT] != NULL)) {
6105 if (mhp->extlen[SADB_EXT_SA] < sizeof(struct sadb_sa) ||
6106 mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
6107 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address)) {
6111 if (mhp->ext[SADB_X_EXT_SA2] != NULL) {
6113 (void *)mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_mode;
6115 (void *)mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_reqid;
6122 sa0 = (struct sadb_sa *)(void *)mhp->ext[SADB_EXT_SA];
6123 src0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_SRC]);
6124 dst0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_DST]);
6140 error = key_setident(sah, m, mhp);
6148 if (mhp->msg->sadb_msg_seq != 0
6149 && (sav = key_getsavbyseq(sah, mhp->msg->sadb_msg_seq)) == NULL) {
6153 mhp->msg->sadb_msg_seq));
6184 if (sav->pid != mhp->msg->sadb_msg_pid) {
6188 sav->pid, mhp->msg->sadb_msg_pid));
6193 error = key_setsaval(sav, m, mhp);
6221 /* set msg buf from mhp */
6222 n = key_getmsgbuf_x1(m, mhp);
6291 const struct sadb_msghdr *mhp)
6306 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
6310 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
6315 if (mhp->ext[SADB_EXT_SA] == NULL ||
6316 mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
6317 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL ||
6318 (mhp->msg->sadb_msg_satype == SADB_SATYPE_ESP &&
6319 mhp->ext[SADB_EXT_KEY_ENCRYPT] == NULL) ||
6320 (mhp->msg->sadb_msg_satype == SADB_SATYPE_AH &&
6321 mhp->ext[SADB_EXT_KEY_AUTH] == NULL) ||
6322 (mhp->ext[SADB_EXT_LIFETIME_HARD] != NULL &&
6323 mhp->ext[SADB_EXT_LIFETIME_SOFT] == NULL) ||
6324 (mhp->ext[SADB_EXT_LIFETIME_HARD] == NULL &&
6325 mhp->ext[SADB_EXT_LIFETIME_SOFT] != NULL)) {
6329 if (mhp->extlen[SADB_EXT_SA] < sizeof(struct sadb_sa) ||
6330 mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
6331 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address)) {
6336 if (mhp->ext[SADB_X_EXT_SA2] != NULL) {
6338 (void *)mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_mode;
6340 (void *)mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_reqid;
6346 sa0 = (struct sadb_sa *)(void *)mhp->ext[SADB_EXT_SA];
6347 src0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_SRC];
6348 dst0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_DST];
6367 error = key_setident(newsah, m, mhp);
6380 newsav = key_newsav(m, mhp, newsah, &error);
6412 /* set msg buf from mhp */
6413 n = key_getmsgbuf_x1(m, mhp);
6429 const struct sadb_msghdr *mhp)
6437 if (sah == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
6441 if (mhp->ext[SADB_EXT_IDENTITY_SRC] == NULL &&
6442 mhp->ext[SADB_EXT_IDENTITY_DST] == NULL) {
6448 if (mhp->ext[SADB_EXT_IDENTITY_SRC] == NULL ||
6449 mhp->ext[SADB_EXT_IDENTITY_DST] == NULL) {
6455 (void *)mhp->ext[SADB_EXT_IDENTITY_SRC];
6457 (void *)mhp->ext[SADB_EXT_IDENTITY_DST];
6458 idsrclen = mhp->extlen[SADB_EXT_IDENTITY_SRC];
6459 iddstlen = mhp->extlen[SADB_EXT_IDENTITY_DST];
6514 const struct sadb_msghdr *mhp)
6524 if (m == NULL || mhp == NULL || mhp->msg == NULL)
6528 n = key_gather_mbuf(m, mhp, 1, sizeof(mbufItems)/sizeof(int), mbufItems);
6562 const struct sadb_msghdr *mhp)
6574 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
6578 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
6583 if (mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
6584 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL) {
6589 if (mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
6590 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address)) {
6597 if (mhp->ext[SADB_EXT_SA] == NULL) {
6605 return key_delete_all(so, m, mhp, proto);
6606 } else if (mhp->extlen[SADB_EXT_SA] < sizeof(struct sadb_sa)) {
6612 sa0 = (struct sadb_sa *)(void *)mhp->ext[SADB_EXT_SA];
6613 src0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_SRC]);
6614 dst0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_DST]);
6650 n = key_gather_mbuf(m, mhp, 1, sizeof(mbufItems)/sizeof(int), mbufItems);
6675 const struct sadb_msghdr *mhp,
6686 src0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_SRC]);
6687 dst0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_DST]);
6731 n = key_gather_mbuf(m, mhp, 1, sizeof(mbufItems)/sizeof(int), mbufItems);
6765 const struct sadb_msghdr *mhp)
6777 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
6781 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
6786 if (mhp->ext[SADB_EXT_SA] == NULL ||
6787 mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
6788 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL) {
6792 if (mhp->extlen[SADB_EXT_SA] < sizeof(struct sadb_sa) ||
6793 mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
6794 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address)) {
6799 sa0 = (struct sadb_sa *)(void *)mhp->ext[SADB_EXT_SA];
6800 src0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_SRC];
6801 dst0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_DST];
6839 n = key_setdumpsa(sav, SADB_GET, satype, mhp->msg->sadb_msg_seq,
6840 mhp->msg->sadb_msg_pid);
7512 const struct sadb_msghdr *mhp)
7522 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
7533 if (mhp->msg->sadb_msg_len == PFKEY_UNIT64(sizeof(struct sadb_msg))) {
7539 if (mhp->msg->sadb_msg_seq == 0) {
7546 if ((acq = key_getacqbyseq(mhp->msg->sadb_msg_seq)) == NULL) {
7571 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
7577 if (mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
7578 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL ||
7579 mhp->ext[SADB_EXT_PROPOSAL] == NULL) {
7585 if (mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
7586 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address) ||
7587 mhp->extlen[SADB_EXT_PROPOSAL] < sizeof(struct sadb_prop)) {
7594 src0 = (const struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_SRC];
7595 dst0 = (const struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_DST];
7617 "from key_acquire.\n", mhp->msg->sadb_msg_errno));
7641 const struct sadb_msghdr *mhp)
7646 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
7650 if (mhp->msg->sadb_msg_satype >= sizeof(regtree)/sizeof(regtree[0]))
7654 if (mhp->msg->sadb_msg_satype == SADB_SATYPE_UNSPEC)
7667 LIST_FOREACH(reg, &regtree[mhp->msg->sadb_msg_satype], chain) {
7682 LIST_INSERT_HEAD(&regtree[mhp->msg->sadb_msg_satype], newreg, chain);
7980 const struct sadb_msghdr *mhp)
7990 if (so == NULL || mhp == NULL || mhp->msg == NULL)
7994 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
8007 if (mhp->msg->sadb_msg_satype != SADB_SATYPE_UNSPEC
8069 const struct sadb_msghdr *mhp)
8085 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
8089 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
8110 if (mhp->msg->sadb_msg_satype != SADB_SATYPE_UNSPEC
8149 --cnt2, mhp->msg->sadb_msg_pid);
8188 const struct sadb_msghdr *mhp)
8193 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
8196 olen = PFKEY_UNUNIT64(mhp->msg->sadb_msg_len);
8212 mhp->msg->sadb_msg_errno = 0;
8213 switch (mhp->msg->sadb_msg_satype) {
8216 kp->kp_promisc = mhp->msg->sadb_msg_satype;
8225 mhp->msg->sadb_msg_errno = 0;
8557 struct sadb_msghdr *mhp)
8566 if (m == NULL || mhp == NULL)
8572 bzero(mhp, sizeof(*mhp));
8574 mhp->msg = mtod(m, struct sadb_msg *);
8575 mhp->ext[0] = (struct sadb_ext *)mhp->msg; /*XXX backward compat */
8577 end = PFKEY_UNUNIT64(mhp->msg->sadb_msg_len);
8614 if (mhp->ext[ext->sadb_ext_type] != NULL) {
8647 mhp->ext[ext->sadb_ext_type] = ext;
8648 mhp->extoff[ext->sadb_ext_type] = off;
8649 mhp->extlen[ext->sadb_ext_type] = extlen;
8967 const struct sadb_msghdr *mhp)
8977 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
8980 if (mhp->ext[SADB_EXT_SESSION_ID] == NULL) {
8984 if (mhp->extlen[SADB_EXT_SESSION_ID] < sizeof(struct sadb_session_id)) {
8988 if (mhp->ext[SADB_EXT_SASTAT] == NULL) {
8992 if (mhp->extlen[SADB_EXT_SASTAT] < sizeof(*sa_stats_arg)) {
9016 (void *)mhp->ext[SADB_EXT_SASTAT];
9041 (void *)mhp->ext[SADB_EXT_SESSION_ID];
9048 mhp->msg->sadb_msg_seq,
9049 mhp->msg->sadb_msg_pid);