MCPcopy Create free account
hub / github.com/F-Stack/f-stack / in_control

Function in_control

freebsd/netinet/in.c:226–339  ·  view source on GitHub ↗

* Generic internet control operations (ioctl's). */

Source from the content-addressed store, hash-verified

224 * Generic internet control operations (ioctl's).
225 */
226int
227in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp,
228 struct thread *td)
229{
230 struct ifreq *ifr = (struct ifreq *)data;
231 struct sockaddr_in *addr = (struct sockaddr_in *)&ifr->ifr_addr;
232 struct epoch_tracker et;
233 struct ifaddr *ifa;
234 struct in_ifaddr *ia;
235 int error;
236
237 if (ifp == NULL)
238 return (EADDRNOTAVAIL);
239
240 /*
241 * Filter out 4 ioctls we implement directly. Forward the rest
242 * to specific functions and ifp->if_ioctl().
243 */
244 switch (cmd) {
245 case SIOCGIFADDR:
246 case SIOCGIFBRDADDR:
247 case SIOCGIFDSTADDR:
248 case SIOCGIFNETMASK:
249 break;
250 case SIOCGIFALIAS:
251 sx_xlock(&in_control_sx);
252 error = in_gifaddr_ioctl(cmd, data, ifp, td);
253 sx_xunlock(&in_control_sx);
254 return (error);
255 case SIOCDIFADDR:
256 sx_xlock(&in_control_sx);
257 error = in_difaddr_ioctl(cmd, data, ifp, td);
258 sx_xunlock(&in_control_sx);
259 return (error);
260 case OSIOCAIFADDR: /* 9.x compat */
261 case SIOCAIFADDR:
262 sx_xlock(&in_control_sx);
263 error = in_aifaddr_ioctl(cmd, data, ifp, td);
264 sx_xunlock(&in_control_sx);
265 return (error);
266 case SIOCSIFADDR:
267 case SIOCSIFBRDADDR:
268 case SIOCSIFDSTADDR:
269 case SIOCSIFNETMASK:
270 /* We no longer support that old commands. */
271 return (EINVAL);
272 default:
273 if (ifp->if_ioctl == NULL)
274 return (EOPNOTSUPP);
275 return ((*ifp->if_ioctl)(ifp, cmd, data));
276 }
277
278 if (addr->sin_addr.s_addr != INADDR_ANY &&
279 prison_check_ip4(td->td_ucred, &addr->sin_addr) != 0)
280 return (EADDRNOTAVAIL);
281
282 /*
283 * Find address for this interface, if it exists. If an

Callers 2

in_ifscrub_allFunction · 0.85
if_purgeaddrsFunction · 0.85

Calls 4

in_gifaddr_ioctlFunction · 0.85
in_difaddr_ioctlFunction · 0.85
in_aifaddr_ioctlFunction · 0.85
prison_check_ip4Function · 0.70

Tested by

no test coverage detected