if_gif.c (77658) | if_gif.c (78064) |
---|---|
1/* $FreeBSD: head/sys/net/if_gif.c 77658 2001-06-03 17:31:11Z yar $ */ 2/* $KAME: if_gif.c,v 1.28 2000/06/20 12:30:03 jinmei Exp $ */ | 1/* $FreeBSD: head/sys/net/if_gif.c 78064 2001-06-11 12:39:29Z ume $ */ 2/* $KAME: if_gif.c,v 1.47 2001/05/01 05:28:42 itojun 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 10 * are met: --- 36 unchanged lines hidden (view full) --- 47#include <machine/cpu.h> 48 49#include <net/if.h> 50#include <net/if_types.h> 51#include <net/netisr.h> 52#include <net/route.h> 53#include <net/bpf.h> 54 | 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 10 * are met: --- 36 unchanged lines hidden (view full) --- 47#include <machine/cpu.h> 48 49#include <net/if.h> 50#include <net/if_types.h> 51#include <net/netisr.h> 52#include <net/route.h> 53#include <net/bpf.h> 54 |
55#ifdef INET | |
56#include <netinet/in.h> 57#include <netinet/in_systm.h> | 55#include <netinet/in.h> 56#include <netinet/in_systm.h> |
58#include <netinet/in_var.h> | |
59#include <netinet/ip.h> | 57#include <netinet/ip.h> |
58#ifdef INET 59#include <netinet/in_var.h> |
|
60#include <netinet/in_gif.h> 61#endif /* INET */ 62 63#ifdef INET6 64#ifndef INET 65#include <netinet/in.h> 66#endif 67#include <netinet6/in6_var.h> --- 41 unchanged lines hidden (view full) --- 109#define MAX_GIF_NEST 1 110#endif 111static int max_gif_nesting = MAX_GIF_NEST; 112 113void 114gifattach(dummy) 115 void *dummy; 116{ | 60#include <netinet/in_gif.h> 61#endif /* INET */ 62 63#ifdef INET6 64#ifndef INET 65#include <netinet/in.h> 66#endif 67#include <netinet6/in6_var.h> --- 41 unchanged lines hidden (view full) --- 109#define MAX_GIF_NEST 1 110#endif 111static int max_gif_nesting = MAX_GIF_NEST; 112 113void 114gifattach(dummy) 115 void *dummy; 116{ |
117 register struct gif_softc *sc; 118 register int i; | 117 struct gif_softc *sc; 118 int i; |
119 120 ngif = NGIF; | 119 120 ngif = NGIF; |
121 gif = sc = malloc (ngif * sizeof(struct gif_softc), M_DEVBUF, M_WAITOK); | 121 gif = sc = malloc(ngif * sizeof(struct gif_softc), M_DEVBUF, M_WAITOK); |
122 bzero(sc, ngif * sizeof(struct gif_softc)); 123 for (i = 0; i < ngif; sc++, i++) { 124 sc->gif_if.if_name = "gif"; 125 sc->gif_if.if_unit = i; 126 127 sc->encap_cookie4 = sc->encap_cookie6 = NULL; 128#ifdef INET 129 sc->encap_cookie4 = encap_attach_func(AF_INET, -1, --- 13 unchanged lines hidden (view full) --- 143 } 144 printf("%s: attach failed\n", if_name(&sc->gif_if)); 145 continue; 146 } 147#endif 148 149 sc->gif_if.if_mtu = GIF_MTU; 150 sc->gif_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; | 122 bzero(sc, ngif * sizeof(struct gif_softc)); 123 for (i = 0; i < ngif; sc++, i++) { 124 sc->gif_if.if_name = "gif"; 125 sc->gif_if.if_unit = i; 126 127 sc->encap_cookie4 = sc->encap_cookie6 = NULL; 128#ifdef INET 129 sc->encap_cookie4 = encap_attach_func(AF_INET, -1, --- 13 unchanged lines hidden (view full) --- 143 } 144 printf("%s: attach failed\n", if_name(&sc->gif_if)); 145 continue; 146 } 147#endif 148 149 sc->gif_if.if_mtu = GIF_MTU; 150 sc->gif_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; |
151#if 0 152 /* turn off ingress filter */ 153 sc->gif_if.if_flags |= IFF_LINK2; 154#endif |
|
151 sc->gif_if.if_ioctl = gif_ioctl; 152 sc->gif_if.if_output = gif_output; 153 sc->gif_if.if_type = IFT_GIF; 154 sc->gif_if.if_snd.ifq_maxlen = IFQ_MAXLEN; 155 if_attach(&sc->gif_if); 156#if NBPFILTER > 0 157#ifdef HAVE_OLD_BPF 158 bpfattach(&sc->gif_if, DLT_NULL, sizeof(u_int)); --- 65 unchanged lines hidden (view full) --- 224 225int 226gif_output(ifp, m, dst, rt) 227 struct ifnet *ifp; 228 struct mbuf *m; 229 struct sockaddr *dst; 230 struct rtentry *rt; /* added in net2 */ 231{ | 155 sc->gif_if.if_ioctl = gif_ioctl; 156 sc->gif_if.if_output = gif_output; 157 sc->gif_if.if_type = IFT_GIF; 158 sc->gif_if.if_snd.ifq_maxlen = IFQ_MAXLEN; 159 if_attach(&sc->gif_if); 160#if NBPFILTER > 0 161#ifdef HAVE_OLD_BPF 162 bpfattach(&sc->gif_if, DLT_NULL, sizeof(u_int)); --- 65 unchanged lines hidden (view full) --- 228 229int 230gif_output(ifp, m, dst, rt) 231 struct ifnet *ifp; 232 struct mbuf *m; 233 struct sockaddr *dst; 234 struct rtentry *rt; /* added in net2 */ 235{ |
232 register struct gif_softc *sc = (struct gif_softc*)ifp; | 236 struct gif_softc *sc = (struct gif_softc*)ifp; |
233 int error = 0; 234 static int called = 0; /* XXX: MUTEX */ 235 236 /* 237 * gif may cause infinite recursion calls when misconfigured. 238 * We'll prevent this by introducing upper limit. 239 * XXX: this mechanism may introduce another problem about 240 * mutual exclusion of the variable CALLED, especially if we --- 22 unchanged lines hidden (view full) --- 263 /* 264 * We need to prepend the address family as 265 * a four byte field. Cons up a dummy header 266 * to pacify bpf. This is safe because bpf 267 * will only read from the mbuf (i.e., it won't 268 * try to free it or keep a pointer a to it). 269 */ 270 struct mbuf m0; | 237 int error = 0; 238 static int called = 0; /* XXX: MUTEX */ 239 240 /* 241 * gif may cause infinite recursion calls when misconfigured. 242 * We'll prevent this by introducing upper limit. 243 * XXX: this mechanism may introduce another problem about 244 * mutual exclusion of the variable CALLED, especially if we --- 22 unchanged lines hidden (view full) --- 267 /* 268 * We need to prepend the address family as 269 * a four byte field. Cons up a dummy header 270 * to pacify bpf. This is safe because bpf 271 * will only read from the mbuf (i.e., it won't 272 * try to free it or keep a pointer a to it). 273 */ 274 struct mbuf m0; |
271 u_int af = dst->sa_family; | 275 u_int32_t af = dst->sa_family; |
272 273 m0.m_next = m; 274 m0.m_len = 4; 275 m0.m_data = (char *)⁡ 276 277#ifdef HAVE_OLD_BPF 278 bpf_mtap(ifp, &m0); 279#else 280 bpf_mtap(ifp->if_bpf, &m0); 281#endif 282 } 283#endif 284 ifp->if_opackets++; 285 ifp->if_obytes += m->m_pkthdr.len; 286 | 276 277 m0.m_next = m; 278 m0.m_len = 4; 279 m0.m_data = (char *)⁡ 280 281#ifdef HAVE_OLD_BPF 282 bpf_mtap(ifp, &m0); 283#else 284 bpf_mtap(ifp->if_bpf, &m0); 285#endif 286 } 287#endif 288 ifp->if_opackets++; 289 ifp->if_obytes += m->m_pkthdr.len; 290 |
291 /* inner AF-specific encapsulation */ 292 |
|
287 /* XXX should we check if our outer source is legal? */ 288 | 293 /* XXX should we check if our outer source is legal? */ 294 |
295 /* dispatch to output logic based on outer AF */ |
|
289 switch (sc->gif_psrc->sa_family) { 290#ifdef INET 291 case AF_INET: 292 error = in_gif_output(ifp, dst->sa_family, m, rt); 293 break; 294#endif 295#ifdef INET6 296 case AF_INET6: 297 error = in6_gif_output(ifp, dst->sa_family, m, rt); 298 break; 299#endif 300 default: 301 m_freem(m); 302 error = ENETDOWN; | 296 switch (sc->gif_psrc->sa_family) { 297#ifdef INET 298 case AF_INET: 299 error = in_gif_output(ifp, dst->sa_family, m, rt); 300 break; 301#endif 302#ifdef INET6 303 case AF_INET6: 304 error = in6_gif_output(ifp, dst->sa_family, m, rt); 305 break; 306#endif 307 default: 308 m_freem(m); 309 error = ENETDOWN; |
310 goto end; |
|
303 } 304 305 end: 306 called = 0; /* reset recursion counter */ | 311 } 312 313 end: 314 called = 0; /* reset recursion counter */ |
307 if (error) ifp->if_oerrors++; | 315 if (error) 316 ifp->if_oerrors++; |
308 return error; 309} 310 311void 312gif_input(m, af, gifp) 313 struct mbuf *m; 314 int af; 315 struct ifnet *gifp; 316{ 317 int isr; | 317 return error; 318} 319 320void 321gif_input(m, af, gifp) 322 struct mbuf *m; 323 int af; 324 struct ifnet *gifp; 325{ 326 int isr; |
318 register struct ifqueue *ifq = 0; | 327 struct ifqueue *ifq = 0; |
319 320 if (gifp == NULL) { 321 /* just in case */ 322 m_freem(m); 323 return; 324 } 325 326 m->m_pkthdr.rcvif = gifp; 327 328#if NBPFILTER > 0 329 if (gifp->if_bpf) { 330 /* 331 * We need to prepend the address family as 332 * a four byte field. Cons up a dummy header 333 * to pacify bpf. This is safe because bpf 334 * will only read from the mbuf (i.e., it won't 335 * try to free it or keep a pointer a to it). 336 */ 337 struct mbuf m0; | 328 329 if (gifp == NULL) { 330 /* just in case */ 331 m_freem(m); 332 return; 333 } 334 335 m->m_pkthdr.rcvif = gifp; 336 337#if NBPFILTER > 0 338 if (gifp->if_bpf) { 339 /* 340 * We need to prepend the address family as 341 * a four byte field. Cons up a dummy header 342 * to pacify bpf. This is safe because bpf 343 * will only read from the mbuf (i.e., it won't 344 * try to free it or keep a pointer a to it). 345 */ 346 struct mbuf m0; |
338 u_int af = AF_INET6; | 347 u_int32_t af1 = af; |
339 340 m0.m_next = m; 341 m0.m_len = 4; | 348 349 m0.m_next = m; 350 m0.m_len = 4; |
342 m0.m_data = (char *)⁡ | 351 m0.m_data = (char *)&af1; |
343 344#ifdef HAVE_OLD_BPF 345 bpf_mtap(gifp, &m0); 346#else 347 bpf_mtap(gifp->if_bpf, &m0); 348#endif 349 } 350#endif /*NBPFILTER > 0*/ --- 79 unchanged lines hidden (view full) --- 430 } 431 break; 432#endif /* SIOCSIFMTU */ 433 434 case SIOCSIFPHYADDR: 435#ifdef INET6 436 case SIOCSIFPHYADDR_IN6: 437#endif /* INET6 */ | 352 353#ifdef HAVE_OLD_BPF 354 bpf_mtap(gifp, &m0); 355#else 356 bpf_mtap(gifp->if_bpf, &m0); 357#endif 358 } 359#endif /*NBPFILTER > 0*/ --- 79 unchanged lines hidden (view full) --- 439 } 440 break; 441#endif /* SIOCSIFMTU */ 442 443 case SIOCSIFPHYADDR: 444#ifdef INET6 445 case SIOCSIFPHYADDR_IN6: 446#endif /* INET6 */ |
447 case SIOCSLIFPHYADDR: |
|
438 switch (cmd) { | 448 switch (cmd) { |
449#ifdef INET |
|
439 case SIOCSIFPHYADDR: 440 src = (struct sockaddr *) 441 &(((struct in_aliasreq *)data)->ifra_addr); 442 dst = (struct sockaddr *) 443 &(((struct in_aliasreq *)data)->ifra_dstaddr); 444 break; | 450 case SIOCSIFPHYADDR: 451 src = (struct sockaddr *) 452 &(((struct in_aliasreq *)data)->ifra_addr); 453 dst = (struct sockaddr *) 454 &(((struct in_aliasreq *)data)->ifra_dstaddr); 455 break; |
456#endif |
|
445#ifdef INET6 446 case SIOCSIFPHYADDR_IN6: 447 src = (struct sockaddr *) 448 &(((struct in6_aliasreq *)data)->ifra_addr); 449 dst = (struct sockaddr *) 450 &(((struct in6_aliasreq *)data)->ifra_dstaddr); 451 break; 452#endif | 457#ifdef INET6 458 case SIOCSIFPHYADDR_IN6: 459 src = (struct sockaddr *) 460 &(((struct in6_aliasreq *)data)->ifra_addr); 461 dst = (struct sockaddr *) 462 &(((struct in6_aliasreq *)data)->ifra_dstaddr); 463 break; 464#endif |
465 case SIOCSLIFPHYADDR: 466 src = (struct sockaddr *) 467 &(((struct if_laddrreq *)data)->addr); 468 dst = (struct sockaddr *) 469 &(((struct if_laddrreq *)data)->dstaddr); |
|
453 } 454 | 470 } 471 |
472 /* sa_family must be equal */ 473 if (src->sa_family != dst->sa_family) 474 return EINVAL; 475 476 /* validate sa_len */ 477 switch (src->sa_family) { 478#ifdef INET 479 case AF_INET: 480 if (src->sa_len != sizeof(struct sockaddr_in)) 481 return EINVAL; 482 break; 483#endif 484#ifdef INET6 485 case AF_INET6: 486 if (src->sa_len != sizeof(struct sockaddr_in6)) 487 return EINVAL; 488 break; 489#endif 490 default: 491 return EAFNOSUPPORT; 492 } 493 switch (dst->sa_family) { 494#ifdef INET 495 case AF_INET: 496 if (dst->sa_len != sizeof(struct sockaddr_in)) 497 return EINVAL; 498 break; 499#endif 500#ifdef INET6 501 case AF_INET6: 502 if (dst->sa_len != sizeof(struct sockaddr_in6)) 503 return EINVAL; 504 break; 505#endif 506 default: 507 return EAFNOSUPPORT; 508 } 509 510 /* check sa_family looks sane for the cmd */ 511 switch (cmd) { 512 case SIOCSIFPHYADDR: 513 if (src->sa_family == AF_INET) 514 break; 515 return EAFNOSUPPORT; 516#ifdef INET6 517 case SIOCSIFPHYADDR_IN6: 518 if (src->sa_family == AF_INET6) 519 break; 520 return EAFNOSUPPORT; 521#endif /* INET6 */ 522 case SIOCSLIFPHYADDR: 523 /* checks done in the above */ 524 break; 525 } 526 |
|
455 for (i = 0; i < ngif; i++) { 456 sc2 = gif + i; 457 if (sc2 == sc) 458 continue; 459 if (!sc2->gif_pdst || !sc2->gif_psrc) 460 continue; 461 if (sc2->gif_pdst->sa_family != dst->sa_family || 462 sc2->gif_pdst->sa_len != dst->sa_len || --- 25 unchanged lines hidden (view full) --- 488 if (dst->sa_family == AF_INET6 && 489 multidest6(dst) && multidest6(sc2->gif_pdst)) { 490 error = EADDRNOTAVAIL; 491 goto bad; 492 } 493#endif 494 } 495 | 527 for (i = 0; i < ngif; i++) { 528 sc2 = gif + i; 529 if (sc2 == sc) 530 continue; 531 if (!sc2->gif_pdst || !sc2->gif_psrc) 532 continue; 533 if (sc2->gif_pdst->sa_family != dst->sa_family || 534 sc2->gif_pdst->sa_len != dst->sa_len || --- 25 unchanged lines hidden (view full) --- 560 if (dst->sa_family == AF_INET6 && 561 multidest6(dst) && multidest6(sc2->gif_pdst)) { 562 error = EADDRNOTAVAIL; 563 goto bad; 564 } 565#endif 566 } 567 |
496 if (src->sa_family != dst->sa_family || 497 src->sa_len != dst->sa_len) { 498 error = EINVAL; 499 break; 500 } 501 switch (src->sa_family) { 502#ifdef INET 503 case AF_INET: 504 size = sizeof(struct sockaddr_in); 505 break; 506#endif 507#ifdef INET6 508 case AF_INET6: 509 size = sizeof(struct sockaddr_in6); 510 break; 511#endif 512 default: 513 error = EAFNOSUPPORT; 514 goto bad; 515 } 516 if (src->sa_len != size) { 517 error = EINVAL; 518 break; 519 } 520 | |
521 if (sc->gif_psrc) 522 free((caddr_t)sc->gif_psrc, M_IFADDR); | 568 if (sc->gif_psrc) 569 free((caddr_t)sc->gif_psrc, M_IFADDR); |
523 sa = (struct sockaddr *)malloc(size, M_IFADDR, M_WAITOK); 524 bcopy((caddr_t)src, (caddr_t)sa, size); | 570 sa = (struct sockaddr *)malloc(src->sa_len, M_IFADDR, M_WAITOK); 571 bcopy((caddr_t)src, (caddr_t)sa, src->sa_len); |
525 sc->gif_psrc = sa; 526 527 if (sc->gif_pdst) 528 free((caddr_t)sc->gif_pdst, M_IFADDR); | 572 sc->gif_psrc = sa; 573 574 if (sc->gif_pdst) 575 free((caddr_t)sc->gif_pdst, M_IFADDR); |
529 sa = (struct sockaddr *)malloc(size, M_IFADDR, M_WAITOK); 530 bcopy((caddr_t)dst, (caddr_t)sa, size); | 576 sa = (struct sockaddr *)malloc(dst->sa_len, M_IFADDR, M_WAITOK); 577 bcopy((caddr_t)dst, (caddr_t)sa, dst->sa_len); |
531 sc->gif_pdst = sa; 532 533 ifp->if_flags |= IFF_RUNNING; 534 s = splimp(); 535 if_up(ifp); /* mark interface UP and send up RTM_IFINFO */ 536 splx(s); 537 538 error = 0; --- 4 unchanged lines hidden (view full) --- 543 if (sc->gif_psrc) { 544 free((caddr_t)sc->gif_psrc, M_IFADDR); 545 sc->gif_psrc = NULL; 546 } 547 if (sc->gif_pdst) { 548 free((caddr_t)sc->gif_pdst, M_IFADDR); 549 sc->gif_pdst = NULL; 550 } | 578 sc->gif_pdst = sa; 579 580 ifp->if_flags |= IFF_RUNNING; 581 s = splimp(); 582 if_up(ifp); /* mark interface UP and send up RTM_IFINFO */ 583 splx(s); 584 585 error = 0; --- 4 unchanged lines hidden (view full) --- 590 if (sc->gif_psrc) { 591 free((caddr_t)sc->gif_psrc, M_IFADDR); 592 sc->gif_psrc = NULL; 593 } 594 if (sc->gif_pdst) { 595 free((caddr_t)sc->gif_pdst, M_IFADDR); 596 sc->gif_pdst = NULL; 597 } |
551 /* change the IFF_UP flag as well? */ | 598 /* change the IFF_{UP, RUNNING} flag as well? */ |
552 break; 553#endif 554 555 case SIOCGIFPSRCADDR: 556#ifdef INET6 557 case SIOCGIFPSRCADDR_IN6: 558#endif /* INET6 */ 559 if (sc->gif_psrc == NULL) { 560 error = EADDRNOTAVAIL; 561 goto bad; 562 } 563 src = sc->gif_psrc; | 599 break; 600#endif 601 602 case SIOCGIFPSRCADDR: 603#ifdef INET6 604 case SIOCGIFPSRCADDR_IN6: 605#endif /* INET6 */ 606 if (sc->gif_psrc == NULL) { 607 error = EADDRNOTAVAIL; 608 goto bad; 609 } 610 src = sc->gif_psrc; |
564 switch (sc->gif_psrc->sa_family) { | 611 switch (cmd) { |
565#ifdef INET | 612#ifdef INET |
566 case AF_INET: | 613 case SIOCGIFPSRCADDR: |
567 dst = &ifr->ifr_addr; | 614 dst = &ifr->ifr_addr; |
568 size = sizeof(struct sockaddr_in); | 615 size = sizeof(ifr->ifr_addr); |
569 break; 570#endif /* INET */ 571#ifdef INET6 | 616 break; 617#endif /* INET */ 618#ifdef INET6 |
572 case AF_INET6: | 619 case SIOCGIFPSRCADDR_IN6: |
573 dst = (struct sockaddr *) 574 &(((struct in6_ifreq *)data)->ifr_addr); | 620 dst = (struct sockaddr *) 621 &(((struct in6_ifreq *)data)->ifr_addr); |
575 size = sizeof(struct sockaddr_in6); | 622 size = sizeof(((struct in6_ifreq *)data)->ifr_addr); |
576 break; 577#endif /* INET6 */ 578 default: 579 error = EADDRNOTAVAIL; 580 goto bad; 581 } | 623 break; 624#endif /* INET6 */ 625 default: 626 error = EADDRNOTAVAIL; 627 goto bad; 628 } |
582 bcopy((caddr_t)src, (caddr_t)dst, size); | 629 if (src->sa_len > size) 630 return EINVAL; 631 bcopy((caddr_t)src, (caddr_t)dst, src->sa_len); |
583 break; 584 585 case SIOCGIFPDSTADDR: 586#ifdef INET6 587 case SIOCGIFPDSTADDR_IN6: 588#endif /* INET6 */ 589 if (sc->gif_pdst == NULL) { 590 error = EADDRNOTAVAIL; 591 goto bad; 592 } 593 src = sc->gif_pdst; | 632 break; 633 634 case SIOCGIFPDSTADDR: 635#ifdef INET6 636 case SIOCGIFPDSTADDR_IN6: 637#endif /* INET6 */ 638 if (sc->gif_pdst == NULL) { 639 error = EADDRNOTAVAIL; 640 goto bad; 641 } 642 src = sc->gif_pdst; |
594 switch (sc->gif_pdst->sa_family) { | 643 switch (cmd) { |
595#ifdef INET | 644#ifdef INET |
596 case AF_INET: | 645 case SIOCGIFPDSTADDR: |
597 dst = &ifr->ifr_addr; | 646 dst = &ifr->ifr_addr; |
598 size = sizeof(struct sockaddr_in); | 647 size = sizeof(ifr->ifr_addr); |
599 break; 600#endif /* INET */ 601#ifdef INET6 | 648 break; 649#endif /* INET */ 650#ifdef INET6 |
602 case AF_INET6: | 651 case SIOCGIFPDSTADDR_IN6: |
603 dst = (struct sockaddr *) 604 &(((struct in6_ifreq *)data)->ifr_addr); | 652 dst = (struct sockaddr *) 653 &(((struct in6_ifreq *)data)->ifr_addr); |
605 size = sizeof(struct sockaddr_in6); | 654 size = sizeof(((struct in6_ifreq *)data)->ifr_addr); |
606 break; 607#endif /* INET6 */ 608 default: 609 error = EADDRNOTAVAIL; 610 goto bad; 611 } | 655 break; 656#endif /* INET6 */ 657 default: 658 error = EADDRNOTAVAIL; 659 goto bad; 660 } |
612 bcopy((caddr_t)src, (caddr_t)dst, size); | 661 if (src->sa_len > size) 662 return EINVAL; 663 bcopy((caddr_t)src, (caddr_t)dst, src->sa_len); |
613 break; 614 | 664 break; 665 |
666 case SIOCGLIFPHYADDR: 667 if (sc->gif_psrc == NULL || sc->gif_pdst == NULL) { 668 error = EADDRNOTAVAIL; 669 goto bad; 670 } 671 672 /* copy src */ 673 src = sc->gif_psrc; 674 dst = (struct sockaddr *) 675 &(((struct if_laddrreq *)data)->addr); 676 size = sizeof(((struct if_laddrreq *)data)->addr); 677 if (src->sa_len > size) 678 return EINVAL; 679 bcopy((caddr_t)src, (caddr_t)dst, src->sa_len); 680 681 /* copy dst */ 682 src = sc->gif_pdst; 683 dst = (struct sockaddr *) 684 &(((struct if_laddrreq *)data)->dstaddr); 685 size = sizeof(((struct if_laddrreq *)data)->dstaddr); 686 if (src->sa_len > size) 687 return EINVAL; 688 bcopy((caddr_t)src, (caddr_t)dst, src->sa_len); 689 break; 690 |
|
615 case SIOCSIFFLAGS: 616 /* if_ioctl() takes care of it */ 617 break; 618 619 default: 620 error = EINVAL; 621 break; 622 } 623 bad: 624 return error; 625} 626#endif /*NGIF > 0*/ | 691 case SIOCSIFFLAGS: 692 /* if_ioctl() takes care of it */ 693 break; 694 695 default: 696 error = EINVAL; 697 break; 698 } 699 bad: 700 return error; 701} 702#endif /*NGIF > 0*/ |