1/* $FreeBSD: head/sys/netipsec/key.c 240392 2012-09-12 12:14:50Z vanhu $ */
2/* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */
3
4/*-
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
--- 6897 unchanged lines hidden (view full) ---
6907 * NOTE: We send only soft lifetime extension.
6908 *
6909 * OUT: 0 : succeed
6910 * others : error number
6911 */
6912static int
6913key_expire(struct secasvar *sav)
6914{
6915 int s;
6916 int satype;
6917 struct mbuf *result = NULL, *m;
6918 int len;
6919 int error = -1;
6920 struct sadb_lifetime *lt;
6921
6922 /* XXX: Why do we lock ? */
6923 s = splnet(); /*called from softclock()*/
6924
6925 IPSEC_ASSERT (sav != NULL, ("null sav"));
6926 IPSEC_ASSERT (sav->sah != NULL, ("null sa header"));
6927
6928 /* set msg header */
6929 satype = key_proto2satype(sav->sah->saidx.proto);
6930 IPSEC_ASSERT(satype != 0, ("invalid proto, satype %u", satype));
6931 m = key_setsadbmsg(SADB_EXPIRE, 0, satype, sav->seq, 0, sav->refcnt);
6932 if (!m) {
--- 85 unchanged lines hidden (view full) ---
7018
7019 result->m_pkthdr.len = 0;
7020 for (m = result; m; m = m->m_next)
7021 result->m_pkthdr.len += m->m_len;
7022
7023 mtod(result, struct sadb_msg *)->sadb_msg_len =
7024 PFKEY_UNIT64(result->m_pkthdr.len);
7025
7026 splx(s);
7027 return key_sendup_mbuf(NULL, result, KEY_SENDUP_REGISTERED);
7028
7029 fail:
7030 if (result)
7031 m_freem(result);
7032 splx(s);
7033 return error;
7034}
7035
7036/*
7037 * SADB_FLUSH processing
7038 * receive
7039 * <base>
7040 * from the ikmpd, and free all entries in secastree.
--- 1043 unchanged lines hidden ---
2/* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */
3
4/*-
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
--- 6897 unchanged lines hidden (view full) ---
6907 * NOTE: We send only soft lifetime extension.
6908 *
6909 * OUT: 0 : succeed
6910 * others : error number
6911 */
6912static int
6913key_expire(struct secasvar *sav)
6914{
6915 int s;
6916 int satype;
6917 struct mbuf *result = NULL, *m;
6918 int len;
6919 int error = -1;
6920 struct sadb_lifetime *lt;
6921
6922 /* XXX: Why do we lock ? */
6923 s = splnet(); /*called from softclock()*/
6924
6925 IPSEC_ASSERT (sav != NULL, ("null sav"));
6926 IPSEC_ASSERT (sav->sah != NULL, ("null sa header"));
6927
6928 /* set msg header */
6929 satype = key_proto2satype(sav->sah->saidx.proto);
6930 IPSEC_ASSERT(satype != 0, ("invalid proto, satype %u", satype));
6931 m = key_setsadbmsg(SADB_EXPIRE, 0, satype, sav->seq, 0, sav->refcnt);
6932 if (!m) {
--- 85 unchanged lines hidden (view full) ---
7018
7019 result->m_pkthdr.len = 0;
7020 for (m = result; m; m = m->m_next)
7021 result->m_pkthdr.len += m->m_len;
7022
7023 mtod(result, struct sadb_msg *)->sadb_msg_len =
7024 PFKEY_UNIT64(result->m_pkthdr.len);
7025
7026 splx(s);
7027 return key_sendup_mbuf(NULL, result, KEY_SENDUP_REGISTERED);
7028
7029 fail:
7030 if (result)
7031 m_freem(result);
7032 splx(s);
7033 return error;
7034}
7035
7036/*
7037 * SADB_FLUSH processing
7038 * receive
7039 * <base>
7040 * from the ikmpd, and free all entries in secastree.
--- 1043 unchanged lines hidden ---