* Set/clear promiscuous mode on interface ifp based on the truth value * of pswitch. The calls are reference counted so that only the first * "on" request actually has an effect, as does the final "off" request. * Results are undefined if the "off" and "on" requests are not matched. */
| 3174 | * Results are undefined if the "off" and "on" requests are not matched. |
| 3175 | */ |
| 3176 | int |
| 3177 | ifpromisc(struct ifnet *ifp, int pswitch) |
| 3178 | { |
| 3179 | int error; |
| 3180 | int oldflags = ifp->if_flags; |
| 3181 | |
| 3182 | error = if_setflag(ifp, IFF_PROMISC, IFF_PPROMISC, |
| 3183 | &ifp->if_pcount, pswitch); |
| 3184 | /* If promiscuous mode status has changed, log a message */ |
| 3185 | if (error == 0 && ((ifp->if_flags ^ oldflags) & IFF_PROMISC) && |
| 3186 | log_promisc_mode_change) |
| 3187 | if_printf(ifp, "promiscuous mode %s\n", |
| 3188 | (ifp->if_flags & IFF_PROMISC) ? "enabled" : "disabled"); |
| 3189 | return (error); |
| 3190 | } |
| 3191 | |
| 3192 | /* |
| 3193 | * Return interface configuration |
no test coverage detected