Deleted Added
full compact
ipx.c (170689) ipx.c (183113)
1/*-
2 * Copyright (c) 1984, 1985, 1986, 1987, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE.
58 *
59 * @(#)ipx.c
60 */
61
62#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1984, 1985, 1986, 1987, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE.
58 *
59 * @(#)ipx.c
60 */
61
62#include <sys/cdefs.h>
63__FBSDID("$FreeBSD: head/sys/netipx/ipx.c 170689 2007-06-13 22:42:43Z rwatson $");
63__FBSDID("$FreeBSD: head/sys/netipx/ipx.c 183113 2008-09-17 15:49:44Z attilio $");
64
65#include <sys/param.h>
66#include <sys/kernel.h>
67#include <sys/systm.h>
68#include <sys/malloc.h>
69#include <sys/priv.h>
70#include <sys/sockio.h>
71#include <sys/socket.h>

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

94 struct thread *td)
95{
96 struct ifreq *ifr = (struct ifreq *)data;
97 struct ipx_aliasreq *ifra = (struct ipx_aliasreq *)data;
98 struct ipx_ifaddr *ia;
99 struct ifaddr *ifa;
100 struct ipx_ifaddr *oia;
101 int dstIsNew, hostIsNew;
64
65#include <sys/param.h>
66#include <sys/kernel.h>
67#include <sys/systm.h>
68#include <sys/malloc.h>
69#include <sys/priv.h>
70#include <sys/sockio.h>
71#include <sys/socket.h>

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

94 struct thread *td)
95{
96 struct ifreq *ifr = (struct ifreq *)data;
97 struct ipx_aliasreq *ifra = (struct ipx_aliasreq *)data;
98 struct ipx_ifaddr *ia;
99 struct ifaddr *ifa;
100 struct ipx_ifaddr *oia;
101 int dstIsNew, hostIsNew;
102 int error = 0;
102 int error = 0, priv;
103
104 /*
105 * Find address for this interface, if it exists.
106 */
107 if (ifp == NULL)
108 return (EADDRNOTAVAIL);
109 for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next)
110 if (ia->ia_ifp == ifp)

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

130 if (ia == NULL)
131 return (EADDRNOTAVAIL);
132 if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
133 return (EINVAL);
134 *(struct sockaddr_ipx *)&ifr->ifr_dstaddr = ia->ia_dstaddr;
135 return (0);
136 }
137
103
104 /*
105 * Find address for this interface, if it exists.
106 */
107 if (ifp == NULL)
108 return (EADDRNOTAVAIL);
109 for (ia = ipx_ifaddr; ia != NULL; ia = ia->ia_next)
110 if (ia->ia_ifp == ifp)

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

130 if (ia == NULL)
131 return (EADDRNOTAVAIL);
132 if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
133 return (EINVAL);
134 *(struct sockaddr_ipx *)&ifr->ifr_dstaddr = ia->ia_dstaddr;
135 return (0);
136 }
137
138 if (td && (error = suser(td)) != 0)
139 return (error);
140
141 switch (cmd) {
142 case SIOCAIFADDR:
143 case SIOCDIFADDR:
138 switch (cmd) {
139 case SIOCAIFADDR:
140 case SIOCDIFADDR:
141 priv = (cmd == SIOCAIFADDR) ? PRIV_NET_ADDIFADDR :
142 PRIV_NET_DELIFADDR;
143 if (td && (error = priv_check(td, priv)) != 0)
144 return (error);
144 if (ifra->ifra_addr.sipx_family == AF_IPX)
145 for (oia = ia; ia != NULL; ia = ia->ia_next) {
146 if (ia->ia_ifp == ifp &&
147 ipx_neteq(ia->ia_addr.sipx_addr,
148 ifra->ifra_addr.sipx_addr))
149 break;
150 }
151 if (cmd == SIOCDIFADDR && ia == NULL)
152 return (EADDRNOTAVAIL);
153 /* FALLTHROUGH */
154
155 case SIOCSIFADDR:
156 case SIOCSIFDSTADDR:
145 if (ifra->ifra_addr.sipx_family == AF_IPX)
146 for (oia = ia; ia != NULL; ia = ia->ia_next) {
147 if (ia->ia_ifp == ifp &&
148 ipx_neteq(ia->ia_addr.sipx_addr,
149 ifra->ifra_addr.sipx_addr))
150 break;
151 }
152 if (cmd == SIOCDIFADDR && ia == NULL)
153 return (EADDRNOTAVAIL);
154 /* FALLTHROUGH */
155
156 case SIOCSIFADDR:
157 case SIOCSIFDSTADDR:
158 if (td && (error = priv_check(td, PRIV_NET_SETLLADDR)) != 0)
159 return (error);
157 if (ia == NULL) {
158 oia = (struct ipx_ifaddr *)
159 malloc(sizeof(*ia), M_IFADDR,
160 M_WAITOK | M_ZERO);
161 if (oia == NULL)
162 return (ENOBUFS);
163 if ((ia = ipx_ifaddr) != NULL) {
164 for ( ; ia->ia_next != NULL; ia = ia->ia_next)

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

178
179 ifa->ifa_dstaddr = (struct sockaddr *)&ia->ia_dstaddr;
180 if (ifp->if_flags & IFF_BROADCAST) {
181 ia->ia_broadaddr.sipx_family = AF_IPX;
182 ia->ia_broadaddr.sipx_len = sizeof(ia->ia_addr);
183 ia->ia_broadaddr.sipx_addr.x_host = ipx_broadhost;
184 }
185 }
160 if (ia == NULL) {
161 oia = (struct ipx_ifaddr *)
162 malloc(sizeof(*ia), M_IFADDR,
163 M_WAITOK | M_ZERO);
164 if (oia == NULL)
165 return (ENOBUFS);
166 if ((ia = ipx_ifaddr) != NULL) {
167 for ( ; ia->ia_next != NULL; ia = ia->ia_next)

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

181
182 ifa->ifa_dstaddr = (struct sockaddr *)&ia->ia_dstaddr;
183 if (ifp->if_flags & IFF_BROADCAST) {
184 ia->ia_broadaddr.sipx_family = AF_IPX;
185 ia->ia_broadaddr.sipx_len = sizeof(ia->ia_addr);
186 ia->ia_broadaddr.sipx_addr.x_host = ipx_broadhost;
187 }
188 }
189 break;
190 default:
191 if (td && (error = priv_check(td, PRIV_NET_HWIOCTL)) != 0)
192 return (error);
186 }
187
188 switch (cmd) {
189
190 case SIOCSIFDSTADDR:
191 if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
192 return (EINVAL);
193 if (ia->ia_flags & IFA_ROUTE) {

--- 221 unchanged lines hidden ---
193 }
194
195 switch (cmd) {
196
197 case SIOCSIFDSTADDR:
198 if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
199 return (EINVAL);
200 if (ia->ia_flags & IFA_ROUTE) {

--- 221 unchanged lines hidden ---