Deleted Added
full compact
ctld.c (273635) ctld.c (273813)
1/*-
2 * Copyright (c) 2012 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Edward Tomasz Napierala under sponsorship
6 * from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 15 unchanged lines hidden (view full) ---

24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2012 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Edward Tomasz Napierala under sponsorship
6 * from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 15 unchanged lines hidden (view full) ---

24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/usr.sbin/ctld/ctld.c 273635 2014-10-25 12:50:26Z mav $");
32__FBSDID("$FreeBSD: head/usr.sbin/ctld/ctld.c 273813 2014-10-29 09:26:55Z trasz $");
33
34#include <sys/types.h>
35#include <sys/time.h>
36#include <sys/socket.h>
37#include <sys/wait.h>
38#include <netinet/in.h>
39#include <arpa/inet.h>
40#include <assert.h>

--- 933 unchanged lines hidden (view full) ---

974 return;
975 gethostname(hostname, sizeof(hostname));
976
977 res = isns_do_deregister(isns, s, hostname);
978 close(s);
979 set_timeout(0, false);
980}
981
33
34#include <sys/types.h>
35#include <sys/time.h>
36#include <sys/socket.h>
37#include <sys/wait.h>
38#include <netinet/in.h>
39#include <arpa/inet.h>
40#include <assert.h>

--- 933 unchanged lines hidden (view full) ---

974 return;
975 gethostname(hostname, sizeof(hostname));
976
977 res = isns_do_deregister(isns, s, hostname);
978 close(s);
979 set_timeout(0, false);
980}
981
982static int
983portal_group_set_filter(struct portal_group *pg, int filter)
984{
985
986 if (pg->pg_discovery_filter == PG_FILTER_UNKNOWN) {
987 pg->pg_discovery_filter = filter;
988 return (0);
989 }
990
991 if (pg->pg_discovery_filter == filter)
992 return (0);
993
994 return (1);
995}
996
997int
998portal_group_set_filter_str(struct portal_group *pg, const char *str)
999{
1000 int error, filter;
1001
1002 if (strcmp(str, "none") == 0) {
1003 filter = PG_FILTER_NONE;
1004 } else if (strcmp(str, "portal") == 0) {
1005 filter = PG_FILTER_PORTAL;
1006 } else if (strcmp(str, "portal-name") == 0) {
1007 filter = PG_FILTER_PORTAL_NAME;
1008 } else if (strcmp(str, "portal-name-auth") == 0) {
1009 filter = PG_FILTER_PORTAL_NAME_AUTH;
1010 } else {
1011 log_warnx("invalid discovery-filter \"%s\" for portal-group "
1012 "\"%s\"; valid values are \"none\", \"portal\", "
1013 "\"portal-name\", and \"portal-name-auth\"",
1014 str, pg->pg_name);
1015 return (1);
1016 }
1017
1018 error = portal_group_set_filter(pg, filter);
1019 if (error != 0) {
1020 log_warnx("cannot set discovery-filter to \"%s\" for "
1021 "portal-group \"%s\"; already has a different "
1022 "value", str, pg->pg_name);
1023 return (1);
1024 }
1025
1026 return (error);
1027}
1028
982static bool
983valid_hex(const char ch)
984{
985 switch (ch) {
986 case '0':
987 case '1':
988 case '2':
989 case '3':

--- 483 unchanged lines hidden (view full) ---

1473 TAILQ_FOREACH(pg, &conf->conf_portal_groups, pg_next) {
1474 assert(pg->pg_name != NULL);
1475 if (pg->pg_discovery_auth_group == NULL) {
1476 pg->pg_discovery_auth_group =
1477 auth_group_find(conf, "default");
1478 assert(pg->pg_discovery_auth_group != NULL);
1479 }
1480
1029static bool
1030valid_hex(const char ch)
1031{
1032 switch (ch) {
1033 case '0':
1034 case '1':
1035 case '2':
1036 case '3':

--- 483 unchanged lines hidden (view full) ---

1520 TAILQ_FOREACH(pg, &conf->conf_portal_groups, pg_next) {
1521 assert(pg->pg_name != NULL);
1522 if (pg->pg_discovery_auth_group == NULL) {
1523 pg->pg_discovery_auth_group =
1524 auth_group_find(conf, "default");
1525 assert(pg->pg_discovery_auth_group != NULL);
1526 }
1527
1528 if (pg->pg_discovery_filter == PG_FILTER_UNKNOWN)
1529 pg->pg_discovery_filter = PG_FILTER_NONE;
1530
1481 TAILQ_FOREACH(targ, &conf->conf_targets, t_next) {
1482 if (targ->t_portal_group == pg)
1483 break;
1484 }
1485 if (targ == NULL) {
1486 if (strcmp(pg->pg_name, "default") != 0)
1487 log_warnx("portal-group \"%s\" not assigned "
1488 "to any target", pg->pg_name);

--- 832 unchanged lines hidden ---
1531 TAILQ_FOREACH(targ, &conf->conf_targets, t_next) {
1532 if (targ->t_portal_group == pg)
1533 break;
1534 }
1535 if (targ == NULL) {
1536 if (strcmp(pg->pg_name, "default") != 0)
1537 log_warnx("portal-group \"%s\" not assigned "
1538 "to any target", pg->pg_name);

--- 832 unchanged lines hidden ---