Lines Matching defs:mhp
1891 key_gather_mbuf(struct mbuf *m, const struct sadb_msghdr *mhp,
1899 if (m == NULL || mhp == NULL)
1907 if (idx == SADB_EXT_RESERVED && mhp->msg == NULL)
1910 (mhp->ext[idx] == NULL || mhp->extlen[idx] == 0))
1927 len = mhp->extlen[idx];
1934 m_copydata(m, mhp->extoff[idx], mhp->extlen[idx],
1937 n = m_copym(m, mhp->extoff[idx], mhp->extlen[idx],
1979 key_spdadd(so, m, mhp)
1982 const struct sadb_msghdr *mhp;
1995 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
1998 if (mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
1999 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL ||
2000 mhp->ext[SADB_X_EXT_POLICY] == NULL) {
2004 if (mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
2005 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address) ||
2006 mhp->extlen[SADB_X_EXT_POLICY] < sizeof(struct sadb_x_policy)) {
2010 if (mhp->ext[SADB_EXT_LIFETIME_HARD] != NULL) {
2011 if (mhp->extlen[SADB_EXT_LIFETIME_HARD]
2016 lft = (struct sadb_lifetime *)mhp->ext[SADB_EXT_LIFETIME_HARD];
2019 src0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_SRC];
2020 dst0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_DST];
2021 xpl0 = (struct sadb_x_policy *)mhp->ext[SADB_X_EXT_POLICY];
2040 mhp->msg->sadb_msg_errno = EINVAL;
2053 if (mhp->msg->sadb_msg_type != SADB_X_SPDSETIDX
2055 && mhp->extlen[SADB_X_EXT_POLICY] <= sizeof(*xpl0)) {
2068 if (mhp->msg->sadb_msg_type == SADB_X_SPDUPDATE) {
2174 if (mhp->msg->sadb_msg_type == SADB_X_SPDUPDATE) {
2195 n = key_gather_mbuf(m, mhp, 2, sizeof(mbufItems)/sizeof(int), mbufItems);
2199 n = key_gather_mbuf(m, mhp, 2, sizeof(mbufItems)/sizeof(int), mbufItems);
2277 key_spddelete(so, m, mhp)
2280 const struct sadb_msghdr *mhp;
2290 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
2293 if (mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
2294 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL ||
2295 mhp->ext[SADB_X_EXT_POLICY] == NULL) {
2299 if (mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
2300 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address) ||
2301 mhp->extlen[SADB_X_EXT_POLICY] < sizeof(struct sadb_x_policy)) {
2306 src0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_SRC];
2307 dst0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_DST];
2308 xpl0 = (struct sadb_x_policy *)mhp->ext[SADB_X_EXT_POLICY];
2353 n = key_gather_mbuf(m, mhp, 1, sizeof(mbufItems)/sizeof(int), mbufItems);
2379 key_spddelete2(so, m, mhp)
2382 const struct sadb_msghdr *mhp;
2390 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
2393 if (mhp->ext[SADB_X_EXT_POLICY] == NULL ||
2394 mhp->extlen[SADB_X_EXT_POLICY] < sizeof(struct sadb_x_policy)) {
2400 id = ((struct sadb_x_policy *)mhp->ext[SADB_X_EXT_POLICY])->sadb_x_policy_id;
2447 n->m_next = m_copym(m, mhp->extoff[SADB_X_EXT_POLICY],
2448 mhp->extlen[SADB_X_EXT_POLICY], M_DONTWAIT);
2480 key_spdget(so, m, mhp)
2483 const struct sadb_msghdr *mhp;
2492 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
2495 if (mhp->ext[SADB_X_EXT_POLICY] == NULL ||
2496 mhp->extlen[SADB_X_EXT_POLICY] < sizeof(struct sadb_x_policy)) {
2501 id = ((struct sadb_x_policy *)mhp->ext[SADB_X_EXT_POLICY])->sadb_x_policy_id;
2511 n = key_setdumpsp(sp, SADB_X_SPDGET, 0, mhp->msg->sadb_msg_pid);
2610 key_spdflush(so, m, mhp)
2613 const struct sadb_msghdr *mhp;
2620 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
2663 key_spddump(so, m, mhp)
2666 const struct sadb_msghdr *mhp;
2675 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
2712 mhp->msg->sadb_msg_pid);
2937 * allocating a memory for new SA head, and copy from the values of mhp.
3052 * and copy the values of mhp into new buffer.
3063 key_newsav(m, mhp, sah, errp)
3065 const struct sadb_msghdr *mhp;
3075 if (m == NULL || mhp == NULL || mhp->msg == NULL || sah == NULL)
3091 switch (mhp->msg->sadb_msg_type) {
3097 if (mhp->msg->sadb_msg_seq == 0)
3102 newsav->seq = mhp->msg->sadb_msg_seq;
3107 if (mhp->ext[SADB_EXT_SA] == NULL) {
3113 xsa = (const struct sadb_sa *)mhp->ext[SADB_EXT_SA];
3115 newsav->seq = mhp->msg->sadb_msg_seq;
3124 if (mhp->msg->sadb_msg_type != SADB_GETSPI) {
3125 *errp = key_setsaval(newsav, m, mhp);
3141 newsav->pid = mhp->msg->sadb_msg_pid;
3341 key_setsaval(sav, m, mhp)
3344 const struct sadb_msghdr *mhp;
3355 if (m == NULL || mhp == NULL || mhp->msg == NULL)
3373 if (mhp->ext[SADB_EXT_SA] != NULL) {
3376 sa0 = (const struct sadb_sa *)mhp->ext[SADB_EXT_SA];
3377 if (mhp->extlen[SADB_EXT_SA] < sizeof(*sa0)) {
3392 if (mhp->extlen[SADB_EXT_SA] < sizeof(struct sadb_sa_2) ||
3423 if (mhp->ext[SADB_EXT_KEY_AUTH] != NULL) {
3427 key0 = (const struct sadb_key *)mhp->ext[SADB_EXT_KEY_AUTH];
3428 len = mhp->extlen[SADB_EXT_KEY_AUTH];
3436 switch (mhp->msg->sadb_msg_satype) {
3462 if (mhp->ext[SADB_EXT_KEY_ENCRYPT] != NULL) {
3466 key0 = (const struct sadb_key *)mhp->ext[SADB_EXT_KEY_ENCRYPT];
3467 len = mhp->extlen[SADB_EXT_KEY_ENCRYPT];
3475 switch (mhp->msg->sadb_msg_satype) {
3509 switch (mhp->msg->sadb_msg_satype) {
3575 lft0 = (struct sadb_lifetime *)mhp->ext[SADB_EXT_LIFETIME_HARD];
3577 if (mhp->extlen[SADB_EXT_LIFETIME_HARD] < sizeof(*lft0)) {
3592 lft0 = (struct sadb_lifetime *)mhp->ext[SADB_EXT_LIFETIME_SOFT];
3594 if (mhp->extlen[SADB_EXT_LIFETIME_SOFT] < sizeof(*lft0)) {
5156 * IN: mhp: pointer to the pointer to each header.
5161 key_getspi(so, m, mhp)
5164 const struct sadb_msghdr *mhp;
5179 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
5182 if (mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
5183 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL) {
5187 if (mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
5188 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address)) {
5192 if (mhp->ext[SADB_X_EXT_SA2] != NULL) {
5193 mode = ((struct sadb_x_sa2 *)mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_mode;
5194 reqid = ((struct sadb_x_sa2 *)mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_reqid;
5200 src0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_SRC]);
5201 dst0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_DST]);
5204 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
5249 spi = key_do_getnewspi((struct sadb_spirange *)mhp->ext[SADB_EXT_SPIRANGE],
5268 newsav = key_newsav(m, mhp, newsah, &error);
5280 if (mhp->msg->sadb_msg_seq != 0) {
5282 if ((acq = key_getacqbyseq(mhp->msg->sadb_msg_seq)) != NULL) {
5336 n->m_next = key_gather_mbuf(m, mhp, 0, sizeof(mbufItems)/sizeof(int), mbufItems);
5455 key_update(so, m, mhp)
5458 const struct sadb_msghdr *mhp;
5473 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
5477 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
5482 if (mhp->ext[SADB_EXT_SA] == NULL ||
5483 mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
5484 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL ||
5485 (mhp->msg->sadb_msg_satype == SADB_SATYPE_ESP &&
5486 mhp->ext[SADB_EXT_KEY_ENCRYPT] == NULL) ||
5487 (mhp->msg->sadb_msg_satype == SADB_SATYPE_AH &&
5488 mhp->ext[SADB_EXT_KEY_AUTH] == NULL) ||
5489 (mhp->ext[SADB_EXT_LIFETIME_HARD] != NULL &&
5490 mhp->ext[SADB_EXT_LIFETIME_SOFT] == NULL) ||
5491 (mhp->ext[SADB_EXT_LIFETIME_HARD] == NULL &&
5492 mhp->ext[SADB_EXT_LIFETIME_SOFT] != NULL)) {
5496 if (mhp->extlen[SADB_EXT_SA] < sizeof(struct sadb_sa) ||
5497 mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
5498 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address)) {
5502 if (mhp->ext[SADB_X_EXT_SA2] != NULL) {
5503 mode = ((struct sadb_x_sa2 *)mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_mode;
5504 reqid = ((struct sadb_x_sa2 *)mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_reqid;
5511 sa0 = (struct sadb_sa *)mhp->ext[SADB_EXT_SA];
5512 src0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_SRC]);
5513 dst0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_DST]);
5529 error = key_setident(sah, m, mhp);
5537 if (mhp->msg->sadb_msg_seq != 0
5538 && (sav = key_getsavbyseq(sah, mhp->msg->sadb_msg_seq)) == NULL) {
5542 mhp->msg->sadb_msg_seq));
5573 if (sav->pid != mhp->msg->sadb_msg_pid) {
5577 sav->pid, mhp->msg->sadb_msg_pid));
5582 error = key_setsaval(sav, m, mhp);
5610 /* set msg buf from mhp */
5611 n = key_getmsgbuf_x1(m, mhp);
5677 key_add(so, m, mhp)
5680 const struct sadb_msghdr *mhp;
5695 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
5699 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
5704 if (mhp->ext[SADB_EXT_SA] == NULL ||
5705 mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
5706 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL ||
5707 (mhp->msg->sadb_msg_satype == SADB_SATYPE_ESP &&
5708 mhp->ext[SADB_EXT_KEY_ENCRYPT] == NULL) ||
5709 (mhp->msg->sadb_msg_satype == SADB_SATYPE_AH &&
5710 mhp->ext[SADB_EXT_KEY_AUTH] == NULL) ||
5711 (mhp->ext[SADB_EXT_LIFETIME_HARD] != NULL &&
5712 mhp->ext[SADB_EXT_LIFETIME_SOFT] == NULL) ||
5713 (mhp->ext[SADB_EXT_LIFETIME_HARD] == NULL &&
5714 mhp->ext[SADB_EXT_LIFETIME_SOFT] != NULL)) {
5718 if (mhp->extlen[SADB_EXT_SA] < sizeof(struct sadb_sa) ||
5719 mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
5720 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address)) {
5725 if (mhp->ext[SADB_X_EXT_SA2] != NULL) {
5726 mode = ((struct sadb_x_sa2 *)mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_mode;
5727 reqid = ((struct sadb_x_sa2 *)mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_reqid;
5733 sa0 = (struct sadb_sa *)mhp->ext[SADB_EXT_SA];
5734 src0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_SRC];
5735 dst0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_DST];
5754 error = key_setident(newsah, m, mhp);
5767 newsav = key_newsav(m, mhp, newsah, &error);
5799 /* set msg buf from mhp */
5800 n = key_getmsgbuf_x1(m, mhp);
5813 key_setident(sah, m, mhp)
5816 const struct sadb_msghdr *mhp;
5824 if (sah == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
5828 if (mhp->ext[SADB_EXT_IDENTITY_SRC] == NULL &&
5829 mhp->ext[SADB_EXT_IDENTITY_DST] == NULL) {
5835 if (mhp->ext[SADB_EXT_IDENTITY_SRC] == NULL ||
5836 mhp->ext[SADB_EXT_IDENTITY_DST] == NULL) {
5841 idsrc = (const struct sadb_ident *)mhp->ext[SADB_EXT_IDENTITY_SRC];
5842 iddst = (const struct sadb_ident *)mhp->ext[SADB_EXT_IDENTITY_DST];
5843 idsrclen = mhp->extlen[SADB_EXT_IDENTITY_SRC];
5844 iddstlen = mhp->extlen[SADB_EXT_IDENTITY_DST];
5897 key_getmsgbuf_x1(m, mhp)
5899 const struct sadb_msghdr *mhp;
5909 if (m == NULL || mhp == NULL || mhp->msg == NULL)
5913 n = key_gather_mbuf(m, mhp, 1, sizeof(mbufItems)/sizeof(int), mbufItems);
5944 key_delete(so, m, mhp)
5947 const struct sadb_msghdr *mhp;
5959 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
5963 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
5968 if (mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
5969 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL) {
5974 if (mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
5975 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address)) {
5982 if (mhp->ext[SADB_EXT_SA] == NULL) {
5990 return key_delete_all(so, m, mhp, proto);
5991 } else if (mhp->extlen[SADB_EXT_SA] < sizeof(struct sadb_sa)) {
5997 sa0 = (struct sadb_sa *)mhp->ext[SADB_EXT_SA];
5998 src0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_SRC]);
5999 dst0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_DST]);
6035 n = key_gather_mbuf(m, mhp, 1, sizeof(mbufItems)/sizeof(int), mbufItems);
6057 key_delete_all(so, m, mhp, proto)
6060 const struct sadb_msghdr *mhp;
6071 src0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_SRC]);
6072 dst0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_DST]);
6116 n = key_gather_mbuf(m, mhp, 1, sizeof(mbufItems)/sizeof(int), mbufItems);
6147 key_get(so, m, mhp)
6150 const struct sadb_msghdr *mhp;
6162 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
6166 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
6171 if (mhp->ext[SADB_EXT_SA] == NULL ||
6172 mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
6173 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL) {
6177 if (mhp->extlen[SADB_EXT_SA] < sizeof(struct sadb_sa) ||
6178 mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
6179 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address)) {
6184 sa0 = (struct sadb_sa *)mhp->ext[SADB_EXT_SA];
6185 src0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_SRC];
6186 dst0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_DST];
6224 n = key_setdumpsa(sav, SADB_GET, satype, mhp->msg->sadb_msg_seq,
6225 mhp->msg->sadb_msg_pid);
6817 key_acquire2(so, m, mhp)
6820 const struct sadb_msghdr *mhp;
6830 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
6841 if (mhp->msg->sadb_msg_len == PFKEY_UNIT64(sizeof(struct sadb_msg))) {
6847 if (mhp->msg->sadb_msg_seq == 0) {
6854 if ((acq = key_getacqbyseq(mhp->msg->sadb_msg_seq)) == NULL) {
6879 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
6885 if (mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
6886 mhp->ext[SADB_EXT_ADDRESS_DST] == NULL ||
6887 mhp->ext[SADB_EXT_PROPOSAL] == NULL) {
6893 if (mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
6894 mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address) ||
6895 mhp->extlen[SADB_EXT_PROPOSAL] < sizeof(struct sadb_prop)) {
6902 src0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_SRC];
6903 dst0 = (struct sadb_address *)mhp->ext[SADB_EXT_ADDRESS_DST];
6924 "from key_acquire.\n", mhp->msg->sadb_msg_errno));
6945 key_register(so, m, mhp)
6948 const struct sadb_msghdr *mhp;
6953 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
6957 if (mhp->msg->sadb_msg_satype >= sizeof(regtree)/sizeof(regtree[0]))
6961 if (mhp->msg->sadb_msg_satype == SADB_SATYPE_UNSPEC)
6974 LIST_FOREACH(reg, ®tree[mhp->msg->sadb_msg_satype], chain) {
6989 LIST_INSERT_HEAD(®tree[mhp->msg->sadb_msg_satype], newreg, chain);
7282 key_flush(so, m, mhp)
7285 const struct sadb_msghdr *mhp;
7295 if (so == NULL || mhp == NULL || mhp->msg == NULL)
7299 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
7312 if (mhp->msg->sadb_msg_satype != SADB_SATYPE_UNSPEC
7371 key_dump(so, m, mhp)
7374 const struct sadb_msghdr *mhp;
7390 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
7394 if ((proto = key_satype2proto(mhp->msg->sadb_msg_satype)) == 0) {
7415 if (mhp->msg->sadb_msg_satype != SADB_SATYPE_UNSPEC
7454 --cnt2, mhp->msg->sadb_msg_pid);
7490 key_promisc(so, m, mhp)
7493 const struct sadb_msghdr *mhp;
7498 if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
7501 olen = PFKEY_UNUNIT64(mhp->msg->sadb_msg_len);
7517 mhp->msg->sadb_msg_errno = 0;
7518 switch (mhp->msg->sadb_msg_satype) {
7521 kp->kp_promisc = mhp->msg->sadb_msg_satype;
7530 mhp->msg->sadb_msg_errno = 0;
7859 key_align(m, mhp)
7861 struct sadb_msghdr *mhp;
7870 if (m == NULL || mhp == NULL)
7876 bzero(mhp, sizeof(*mhp));
7878 mhp->msg = mtod(m, struct sadb_msg *);
7879 mhp->ext[0] = (struct sadb_ext *)mhp->msg; /*XXX backward compat */
7881 end = PFKEY_UNUNIT64(mhp->msg->sadb_msg_len);
7916 if (mhp->ext[ext->sadb_ext_type] != NULL) {
7949 mhp->ext[ext->sadb_ext_type] = ext;
7950 mhp->extoff[ext->sadb_ext_type] = off;
7951 mhp->extlen[ext->sadb_ext_type] = extlen;