1/* $NetBSD: if_gre.c,v 1.49 2003/12/11 00:22:29 itojun Exp $ */ |
2/* $FreeBSD: head/sys/net/if_gre.c 171056 2007-06-26 23:01:01Z rwatson $ */ |
3 4/*- 5 * Copyright (c) 1998 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Heiko W.Rupp <hwr@pilhuhn.de> 10 * --- 438 unchanged lines hidden (view full) --- 449 switch (cmd) { 450 case SIOCSIFADDR: 451 ifp->if_flags |= IFF_UP; 452 break; 453 case SIOCSIFDSTADDR: 454 break; 455 case SIOCSIFFLAGS: 456 /* |
457 * XXXRW: Isn't this priv_check() redundant to the ifnet 458 * layer check? |
459 */ 460 if ((error = priv_check(curthread, PRIV_NET_SETIFFLAGS)) != 0) 461 break; 462 if ((ifr->ifr_flags & IFF_LINK0) != 0) 463 sc->g_proto = IPPROTO_GRE; 464 else 465 sc->g_proto = IPPROTO_MOBILE; 466 if ((ifr->ifr_flags & IFF_LINK2) != 0) 467 sc->wccp_ver = WCCP_V2; 468 else 469 sc->wccp_ver = WCCP_V1; 470 goto recompute; 471 case SIOCSIFMTU: 472 /* |
473 * XXXRW: Isn't this priv_check() redundant to the ifnet 474 * layer check? |
475 */ 476 if ((error = priv_check(curthread, PRIV_NET_SETIFMTU)) != 0) 477 break; 478 if (ifr->ifr_mtu < 576) { 479 error = EINVAL; 480 break; 481 } 482 ifp->if_mtu = ifr->ifr_mtu; 483 break; 484 case SIOCGIFMTU: 485 ifr->ifr_mtu = GRE2IFP(sc)->if_mtu; 486 break; 487 case SIOCADDMULTI: 488 /* |
489 * XXXRW: Isn't this priv_checkr() redundant to the ifnet 490 * layer check? |
491 */ 492 if ((error = priv_check(curthread, PRIV_NET_ADDMULTI)) != 0) 493 break; 494 if (ifr == 0) { 495 error = EAFNOSUPPORT; 496 break; 497 } 498 switch (ifr->ifr_addr.sa_family) { --- 7 unchanged lines hidden (view full) --- 506#endif 507 default: 508 error = EAFNOSUPPORT; 509 break; 510 } 511 break; 512 case SIOCDELMULTI: 513 /* |
514 * XXXRW: Isn't this priv_check() redundant to the ifnet 515 * layer check? |
516 */ 517 if ((error = priv_check(curthread, PRIV_NET_DELIFGROUP)) != 0) 518 break; 519 if (ifr == 0) { 520 error = EAFNOSUPPORT; 521 break; 522 } 523 switch (ifr->ifr_addr.sa_family) { --- 7 unchanged lines hidden (view full) --- 531#endif 532 default: 533 error = EAFNOSUPPORT; 534 break; 535 } 536 break; 537 case GRESPROTO: 538 /* |
539 * XXXRW: Isn't this priv_check() redundant to the ifnet 540 * layer check? |
541 */ 542 if ((error = priv_check(curthread, PRIV_NET_GRE)) != 0) 543 break; 544 sc->g_proto = ifr->ifr_flags; 545 switch (sc->g_proto) { 546 case IPPROTO_GRE: 547 ifp->if_flags |= IFF_LINK0; 548 break; --- 73 unchanged lines hidden (view full) --- 622 si.sin_family = AF_INET; 623 si.sin_len = sizeof(struct sockaddr_in); 624 si.sin_addr.s_addr = sc->g_dst.s_addr; 625 sa = sintosa(&si); 626 ifr->ifr_addr = *sa; 627 break; 628 case SIOCSIFPHYADDR: 629 /* |
630 * XXXRW: Isn't this priv_check() redundant to the ifnet 631 * layer check? |
632 */ 633 if ((error = priv_check(curthread, PRIV_NET_SETIFPHYS)) != 0) 634 break; 635 if (aifr->ifra_addr.sin_family != AF_INET || 636 aifr->ifra_dstaddr.sin_family != AF_INET) { 637 error = EAFNOSUPPORT; 638 break; 639 } 640 if (aifr->ifra_addr.sin_len != sizeof(si) || 641 aifr->ifra_dstaddr.sin_len != sizeof(si)) { 642 error = EINVAL; 643 break; 644 } 645 sc->g_src = aifr->ifra_addr.sin_addr; 646 sc->g_dst = aifr->ifra_dstaddr.sin_addr; 647 goto recompute; 648 case SIOCSLIFPHYADDR: 649 /* |
650 * XXXRW: Isn't this priv_check() redundant to the ifnet 651 * layer check? |
652 */ 653 if ((error = priv_check(curthread, PRIV_NET_SETIFPHYS)) != 0) 654 break; 655 if (lifr->addr.ss_family != AF_INET || 656 lifr->dstaddr.ss_family != AF_INET) { 657 error = EAFNOSUPPORT; 658 break; 659 } 660 if (lifr->addr.ss_len != sizeof(si) || 661 lifr->dstaddr.ss_len != sizeof(si)) { 662 error = EINVAL; 663 break; 664 } 665 sc->g_src = (satosin(&lifr->addr))->sin_addr; 666 sc->g_dst = 667 (satosin(&lifr->dstaddr))->sin_addr; 668 goto recompute; 669 case SIOCDIFPHYADDR: 670 /* |
671 * XXXRW: Isn't this priv_check() redundant to the ifnet 672 * layer check? |
673 */ 674 if ((error = priv_check(curthread, PRIV_NET_SETIFPHYS)) != 0) 675 break; 676 sc->g_src.s_addr = INADDR_ANY; 677 sc->g_dst.s_addr = INADDR_ANY; 678 goto recompute; 679 case SIOCGLIFPHYADDR: 680 if (sc->g_src.s_addr == INADDR_ANY || --- 181 unchanged lines hidden --- |