Change mode for some operations */
| 2504 | |
| 2505 | /* Change mode for some operations */ |
| 2506 | unsigned int |
| 2507 | LibAliasSetMode( |
| 2508 | struct libalias *la, |
| 2509 | unsigned int flags, /* Which state to bring flags to */ |
| 2510 | unsigned int mask /* Mask of which flags to affect (use 0 to |
| 2511 | * do a probe for flag values) */ |
| 2512 | ) |
| 2513 | { |
| 2514 | int res = -1; |
| 2515 | |
| 2516 | LIBALIAS_LOCK(la); |
| 2517 | /* Enable logging? */ |
| 2518 | if (flags & mask & PKT_ALIAS_LOG) { |
| 2519 | /* Do the enable */ |
| 2520 | if (InitPacketAliasLog(la) == ENOMEM) |
| 2521 | goto getout; |
| 2522 | } else |
| 2523 | /* _Disable_ logging? */ |
| 2524 | if (~flags & mask & PKT_ALIAS_LOG) { |
| 2525 | UninitPacketAliasLog(la); |
| 2526 | } |
| 2527 | #ifndef NO_FW_PUNCH |
| 2528 | /* Start punching holes in the firewall? */ |
| 2529 | if (flags & mask & PKT_ALIAS_PUNCH_FW) { |
| 2530 | InitPunchFW(la); |
| 2531 | } else |
| 2532 | /* Stop punching holes in the firewall? */ |
| 2533 | if (~flags & mask & PKT_ALIAS_PUNCH_FW) { |
| 2534 | UninitPunchFW(la); |
| 2535 | } |
| 2536 | #endif |
| 2537 | |
| 2538 | /* Other flags can be set/cleared without special action */ |
| 2539 | la->packetAliasMode = (flags & mask) | (la->packetAliasMode & ~mask); |
| 2540 | res = la->packetAliasMode; |
| 2541 | getout: |
| 2542 | LIBALIAS_UNLOCK(la); |
| 2543 | return (res); |
| 2544 | } |
| 2545 | |
| 2546 | int |
| 2547 | LibAliasCheckNewLink(struct libalias *la) |
no test coverage detected