Deleted Added
full compact
if_spppsubr.c (194951) if_spppsubr.c (195070)
1/*
2 * Synchronous PPP/Cisco/Frame Relay link level subroutines.
3 * Keepalive protocol implemented in both Cisco and PPP modes.
4 */
5/*-
6 * Copyright (C) 1994-2000 Cronyx Engineering.
7 * Author: Serge Vakulenko, <vak@cronyx.ru>
8 *

--- 4 unchanged lines hidden (view full) ---

13 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 *
15 * Authors grant any other persons or organisations permission to use
16 * or modify this software as long as this message is kept with the software,
17 * all derivative works or modified versions.
18 *
19 * From: Version 2.4, Thu Apr 30 17:17:21 MSD 1997
20 *
1/*
2 * Synchronous PPP/Cisco/Frame Relay link level subroutines.
3 * Keepalive protocol implemented in both Cisco and PPP modes.
4 */
5/*-
6 * Copyright (C) 1994-2000 Cronyx Engineering.
7 * Author: Serge Vakulenko, <vak@cronyx.ru>
8 *

--- 4 unchanged lines hidden (view full) ---

13 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 *
15 * Authors grant any other persons or organisations permission to use
16 * or modify this software as long as this message is kept with the software,
17 * all derivative works or modified versions.
18 *
19 * From: Version 2.4, Thu Apr 30 17:17:21 MSD 1997
20 *
21 * $FreeBSD: head/sys/net/if_spppsubr.c 194951 2009-06-25 11:52:33Z rwatson $
21 * $FreeBSD: head/sys/net/if_spppsubr.c 195070 2009-06-26 18:50:49Z rwatson $
22 */
23
24#include <sys/param.h>
25
26#include "opt_inet.h"
27#include "opt_inet6.h"
28#include "opt_ipx.h"
29

--- 4870 unchanged lines hidden (view full) ---

4900
4901 sm = NULL;
4902 ssrc = ddst = 0L;
4903 /*
4904 * Pick the first AF_INET address from the list,
4905 * aliases don't make any sense on a p2p link anyway.
4906 */
4907 si = 0;
22 */
23
24#include <sys/param.h>
25
26#include "opt_inet.h"
27#include "opt_inet6.h"
28#include "opt_ipx.h"
29

--- 4870 unchanged lines hidden (view full) ---

4900
4901 sm = NULL;
4902 ssrc = ddst = 0L;
4903 /*
4904 * Pick the first AF_INET address from the list,
4905 * aliases don't make any sense on a p2p link anyway.
4906 */
4907 si = 0;
4908 IF_ADDR_LOCK(ifp);
4908 if_addr_rlock(ifp);
4909 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
4910 if (ifa->ifa_addr->sa_family == AF_INET) {
4911 si = (struct sockaddr_in *)ifa->ifa_addr;
4912 sm = (struct sockaddr_in *)ifa->ifa_netmask;
4913 if (si)
4914 break;
4915 }
4916 if (ifa) {
4917 if (si && si->sin_addr.s_addr) {
4918 ssrc = si->sin_addr.s_addr;
4919 if (srcmask)
4920 *srcmask = ntohl(sm->sin_addr.s_addr);
4921 }
4922
4923 si = (struct sockaddr_in *)ifa->ifa_dstaddr;
4924 if (si && si->sin_addr.s_addr)
4925 ddst = si->sin_addr.s_addr;
4926 }
4909 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
4910 if (ifa->ifa_addr->sa_family == AF_INET) {
4911 si = (struct sockaddr_in *)ifa->ifa_addr;
4912 sm = (struct sockaddr_in *)ifa->ifa_netmask;
4913 if (si)
4914 break;
4915 }
4916 if (ifa) {
4917 if (si && si->sin_addr.s_addr) {
4918 ssrc = si->sin_addr.s_addr;
4919 if (srcmask)
4920 *srcmask = ntohl(sm->sin_addr.s_addr);
4921 }
4922
4923 si = (struct sockaddr_in *)ifa->ifa_dstaddr;
4924 if (si && si->sin_addr.s_addr)
4925 ddst = si->sin_addr.s_addr;
4926 }
4927 IF_ADDR_UNLOCK(ifp);
4927 if_addr_runlock(ifp);
4928
4929 if (dst) *dst = ntohl(ddst);
4930 if (src) *src = ntohl(ssrc);
4931}
4932
4933#ifdef INET
4934/*
4935 * Set my IP address. Must be called at splimp.

--- 7 unchanged lines hidden (view full) ---

4943 struct sockaddr_in *si;
4944 struct in_ifaddr *ia;
4945
4946 /*
4947 * Pick the first AF_INET address from the list,
4948 * aliases don't make any sense on a p2p link anyway.
4949 */
4950 si = 0;
4928
4929 if (dst) *dst = ntohl(ddst);
4930 if (src) *src = ntohl(ssrc);
4931}
4932
4933#ifdef INET
4934/*
4935 * Set my IP address. Must be called at splimp.

--- 7 unchanged lines hidden (view full) ---

4943 struct sockaddr_in *si;
4944 struct in_ifaddr *ia;
4945
4946 /*
4947 * Pick the first AF_INET address from the list,
4948 * aliases don't make any sense on a p2p link anyway.
4949 */
4950 si = 0;
4951 IF_ADDR_LOCK(ifp);
4951 if_addr_rlock(ifp);
4952 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
4953 if (ifa->ifa_addr->sa_family == AF_INET) {
4954 si = (struct sockaddr_in *)ifa->ifa_addr;
4955 if (si != NULL) {
4956 ifa_ref(ifa);
4957 break;
4958 }
4959 }
4960 }
4952 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
4953 if (ifa->ifa_addr->sa_family == AF_INET) {
4954 si = (struct sockaddr_in *)ifa->ifa_addr;
4955 if (si != NULL) {
4956 ifa_ref(ifa);
4957 break;
4958 }
4959 }
4960 }
4961 IF_ADDR_UNLOCK(ifp);
4961 if_addr_runlock(ifp);
4962
4963 if (ifa != NULL) {
4964 int error;
4965
4966 /* delete old route */
4967 error = rtinit(ifa, (int)RTM_DELETE, RTF_HOST);
4968 if (debug && error) {
4969 log(LOG_DEBUG, SPP_FMT "sppp_set_ip_addr: rtinit DEL failed, error=%d\n",

--- 35 unchanged lines hidden (view full) ---

5005 sm = NULL;
5006 bzero(&ssrc, sizeof(ssrc));
5007 bzero(&ddst, sizeof(ddst));
5008 /*
5009 * Pick the first link-local AF_INET6 address from the list,
5010 * aliases don't make any sense on a p2p link anyway.
5011 */
5012 si = NULL;
4962
4963 if (ifa != NULL) {
4964 int error;
4965
4966 /* delete old route */
4967 error = rtinit(ifa, (int)RTM_DELETE, RTF_HOST);
4968 if (debug && error) {
4969 log(LOG_DEBUG, SPP_FMT "sppp_set_ip_addr: rtinit DEL failed, error=%d\n",

--- 35 unchanged lines hidden (view full) ---

5005 sm = NULL;
5006 bzero(&ssrc, sizeof(ssrc));
5007 bzero(&ddst, sizeof(ddst));
5008 /*
5009 * Pick the first link-local AF_INET6 address from the list,
5010 * aliases don't make any sense on a p2p link anyway.
5011 */
5012 si = NULL;
5013 IF_ADDR_LOCK(ifp);
5013 if_addr_rlock(ifp);
5014 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
5015 if (ifa->ifa_addr->sa_family == AF_INET6) {
5016 si = (struct sockaddr_in6 *)ifa->ifa_addr;
5017 sm = (struct sockaddr_in6 *)ifa->ifa_netmask;
5018 if (si && IN6_IS_ADDR_LINKLOCAL(&si->sin6_addr))
5019 break;
5020 }
5021 if (ifa) {

--- 9 unchanged lines hidden (view full) ---

5031 if (si && !IN6_IS_ADDR_UNSPECIFIED(&si->sin6_addr))
5032 bcopy(&si->sin6_addr, &ddst, sizeof(ddst));
5033 }
5034
5035 if (dst)
5036 bcopy(&ddst, dst, sizeof(*dst));
5037 if (src)
5038 bcopy(&ssrc, src, sizeof(*src));
5014 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
5015 if (ifa->ifa_addr->sa_family == AF_INET6) {
5016 si = (struct sockaddr_in6 *)ifa->ifa_addr;
5017 sm = (struct sockaddr_in6 *)ifa->ifa_netmask;
5018 if (si && IN6_IS_ADDR_LINKLOCAL(&si->sin6_addr))
5019 break;
5020 }
5021 if (ifa) {

--- 9 unchanged lines hidden (view full) ---

5031 if (si && !IN6_IS_ADDR_UNSPECIFIED(&si->sin6_addr))
5032 bcopy(&si->sin6_addr, &ddst, sizeof(ddst));
5033 }
5034
5035 if (dst)
5036 bcopy(&ddst, dst, sizeof(*dst));
5037 if (src)
5038 bcopy(&ssrc, src, sizeof(*src));
5039 IF_ADDR_UNLOCK(ifp);
5039 if_addr_runlock(ifp);
5040}
5041
5042#ifdef IPV6CP_MYIFID_DYN
5043/*
5044 * Generate random ifid.
5045 */
5046static void
5047sppp_gen_ip6_addr(struct sppp *sp, struct in6_addr *addr)

--- 12 unchanged lines hidden (view full) ---

5060 struct sockaddr_in6 *sin6;
5061
5062 /*
5063 * Pick the first link-local AF_INET6 address from the list,
5064 * aliases don't make any sense on a p2p link anyway.
5065 */
5066
5067 sin6 = NULL;
5040}
5041
5042#ifdef IPV6CP_MYIFID_DYN
5043/*
5044 * Generate random ifid.
5045 */
5046static void
5047sppp_gen_ip6_addr(struct sppp *sp, struct in6_addr *addr)

--- 12 unchanged lines hidden (view full) ---

5060 struct sockaddr_in6 *sin6;
5061
5062 /*
5063 * Pick the first link-local AF_INET6 address from the list,
5064 * aliases don't make any sense on a p2p link anyway.
5065 */
5066
5067 sin6 = NULL;
5068 IF_ADDR_LOCK(ifp);
5068 if_addr_rlock(ifp);
5069 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
5070 if (ifa->ifa_addr->sa_family == AF_INET6) {
5071 sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
5072 if (sin6 && IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
5073 ifa_ref(ifa);
5074 break;
5075 }
5076 }
5077 }
5069 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
5070 if (ifa->ifa_addr->sa_family == AF_INET6) {
5071 sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
5072 if (sin6 && IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
5073 ifa_ref(ifa);
5074 break;
5075 }
5076 }
5077 }
5078 IF_ADDR_UNLOCK(ifp);
5078 if_addr_runlock(ifp);
5079
5080 if (ifa != NULL) {
5081 int error;
5082 struct sockaddr_in6 new_sin6 = *sin6;
5083
5084 bcopy(src, &new_sin6.sin6_addr, sizeof(new_sin6.sin6_addr));
5085 error = in6_ifinit(ifp, ifatoia6(ifa), &new_sin6, 1);
5086 if (debug && error) {

--- 406 unchanged lines hidden ---
5079
5080 if (ifa != NULL) {
5081 int error;
5082 struct sockaddr_in6 new_sin6 = *sin6;
5083
5084 bcopy(src, &new_sin6.sin6_addr, sizeof(new_sin6.sin6_addr));
5085 error = in6_ifinit(ifp, ifatoia6(ifa), &new_sin6, 1);
5086 if (debug && error) {

--- 406 unchanged lines hidden ---