📄 iscsi-config.c
字号:
config->defaults.auth_options. username_in[sizeof (config->defaults. auth_options. username_in) - 1] = '\0'; debugmsg(5, "config global incoming " "username %s", config->defaults.auth_options. username_in); } } else if ((strncasecmp(line, "Password=", 9) == 0) || (strncasecmp(line, "PasswordOut=", 12) == 0) || (strncasecmp(line, "OutgoingPassword=", 17) == 0)) { /* Password string can be quoted */ char *p, *cp = &line[8]; /* find start of value */ while (*cp && *cp != '=') { cp++; } p = parse_quoted_string(++cp); if (current_entry) { struct iscsi_auth_config *auth_options = entry_auth_options(current_entry); if (auth_options) { strncpy(auth_options->password, p, sizeof (auth_options-> password)); auth_options-> password[sizeof (auth_options-> password) - 1] = '\0'; auth_options->password_length = strlen(auth_options-> password); debugmsg(5, "config entry %p " "outgoing password %s " "length %u", current_entry, auth_options->password, auth_options-> password_length); } else { logmsg(AS_ERROR, "Invalid entry on line " "%d of %s," " current entry cannot " "have an outgoing " "password, see " "man page of iscsi." "conf", line_number, pathname); } } else { /* default to use while processing the * rest of the config file */ strncpy(config->defaults.auth_options. password, p, sizeof (config->defaults. auth_options.password)); config->defaults.auth_options. password[sizeof (config->defaults. auth_options.password) - 1] = '\0'; config->defaults.auth_options. password_length = strlen(config->defaults. auth_options.password); debugmsg(5, "config global outgoing " "password %s length %u", config->defaults.auth_options. password, config->defaults.auth_options. password_length); } } else if ((strncasecmp(line, "PasswordIn=", 11) == 0) || (strncasecmp(line, "IncomingPassword=", 17) == 0)) { char *p, *cp = line + 10; /* find start of value */ while (*cp && *cp != '=') { cp++; } p = parse_quoted_string(++cp); if (current_entry) { struct iscsi_auth_config *auth_options = entry_auth_options(current_entry); if (auth_options) { strncpy(auth_options-> password_in, p, sizeof (auth_options-> password_in)); auth_options-> password_in[sizeof (auth_options-> password_in) - 1] = '\0'; auth_options-> password_length_in = strlen(auth_options-> password_in); debugmsg(5, "config entry %p " "incoming password %s," " length %u", current_entry, auth_options-> password_in, auth_options-> password_length_in); } else { logmsg(AS_ERROR, "Invalid entry on line " "%d of %s," " current entry cannot " "have an incoming " "password, see " "man page of iscsi." "conf", line_number, pathname); } } else { /* default to use while processing the * rest of the config file */ strncpy(config->defaults.auth_options. password_in, p, sizeof (config->defaults. auth_options. password_in)); config->defaults.auth_options. password_in[sizeof (config->defaults. auth_options. password_in) - 1] = '\0'; config->defaults.auth_options. password_length_in = strlen(config->defaults. auth_options.password_in); debugmsg(1, "config global incoming " "password %s, length %u", config->defaults.auth_options. password_in, config->defaults.auth_options. password_length_in); } } else if ((strncasecmp(line, "Subnet=", 7) == 0) || (strncasecmp(line, "Address=", 8) == 0)) { char *address = line + 6; char *mask; struct in_addr addr; struct iscsi_subnet_config *subnet_config; while (*address && (*address != '=')) address++; address++; entry = calloc(1, sizeof (*entry)); if (entry == NULL) { logmsg(AS_ERROR, "failed to allocate " "config entry"); return 0; } entry->line_number = line_number; subnet_config = calloc(1, sizeof (*subnet_config)); if (subnet_config == NULL) { free(entry); entry = NULL; logmsg(AS_ERROR, "failed to allocate " "Subnet config"); return 0; } entry->type = CONFIG_TYPE_SUBNET; entry->config.subnet = subnet_config; subnet_config->subnet_mask = 0xFFFFFFFFU; /* look for a subnet mask */ if ((mask = strrchr(address, '/'))) { int bits; *mask = '\0'; /* terminate the address */ mask++; /* and calculate the mask */ bits = atoi(mask); if ((bits >= 0) && (bits < 32)) subnet_config->subnet_mask = 0xFFFFFFFFU << (32 - bits); } else if ((mask = strrchr(address, '&'))) { *mask = '\0'; /* terminate the address */ mask++; /* and calculate the mask */ subnet_config->subnet_mask = (uint32_t) iscsi_strtoul(mask, NULL, 16); } subnet_config->address = strdup(address); /* FIXME: IPv6 */ if (iscsi_inet_aton(address, &addr)) { subnet_config->ip_length = 4; memcpy(subnet_config->ip_address, &addr.s_addr, 4); } else { /* discard this entry */ logmsg(AS_ERROR, "error on line %d of %s, " "bogus Subnet address %s\n", line_number, pathname, address); free_config_entry(entry); entry = NULL; continue; } /* capture the current global defaults */ memcpy(&subnet_config-> connection_timeout_options, &config->defaults. connection_timeout_options, sizeof (subnet_config-> connection_timeout_options)); memcpy(&subnet_config->error_timeout_options, &config->defaults.error_timeout_options, sizeof (subnet_config-> error_timeout_options)); memcpy(&subnet_config->tcp_options, &config->defaults.tcp_options, sizeof (subnet_config->tcp_options)); /* append it to the list of all config entries */ add_config_entry(config, entry); debugmsg(5, "config entry %p subnet %p = addr %s " "ip %u.%u.%u.%u mask 0x%x\n", entry, subnet_config, address, subnet_config->ip_address[0], subnet_config->ip_address[1], subnet_config->ip_address[2], subnet_config->ip_address[3], subnet_config->subnet_mask); /* indented settings in the config file may * modify this entry */ current_entry = entry; entry_indent = indent; } else if (strncasecmp(line, "TCPWindowSize=", 14) == 0) { char *num = &line[14]; int value = parse_number(num); if (value >= 0) { if (current_entry) { struct iscsi_tcp_config *tcp_options = entry_tcp_options (current_entry); if (tcp_options) { tcp_options-> window_size = value; debugmsg(5, "config entry " "%p " "TCPWindowSize" " %d", current_entry, value); } else { logmsg(AS_ERROR, "Invalid entry " "on line " "%d of %s, " "TCPWindowSize " "does not apply " "to the current " "entry, see " "man page of" "iscsi.conf", line_number, pathname, num); } } else { config->defaults.tcp_options. window_size = value; debugmsg(5, "config global " "TCPWindowSize %d", value); } } else logmsg(AS_ERROR, "error on line %d, " "invalid TCPWindowSize %s", line_number, num); } else if (strncasecmp(line, "InitialR2T=", 11) == 0) { char *str = &line[11]; int value = parse_boolean(str); if (value >= 0) { if (current_entry) { struct iscsi_operational_config *iscsi_options = entry_iscsi_options (current_entry); if (iscsi_options) { debugmsg(5, "config entry " "%p InitialR2T" " %d", current_entry, value); iscsi_options-> InitialR2T = value; } else { logmsg(AS_ERROR, "Invalid " "InitialR2T" " entry on " "line " "%d of %s, " "see man page " "of iscsi." "conf", line_number, pathname); } } else { debugmsg(5, "config global " "InitialR2T %d", value); config->defaults.iscsi_options. InitialR2T = value; } } else logmsg(AS_ERROR, "error on line %d of %s, " "invalid InitialR2T %s", line_number, pathname, str); } else if (strncasecmp(line, "ImmediateData=", 14) == 0) { char *str = &line[14]; int value = parse_boolean(str); if (value >= 0) { if (current_entry) { struct iscsi_operational_config *iscsi_options = entry_iscsi_options (current_entry); if (iscsi_options) { debugmsg(5, "config entry " "%p " "ImmediateData" " %d", current_entry, value); iscsi_options-> ImmediateData = value; } else { logmsg(AS_ERROR, "Invalid " "ImmediateData" " entry on " "line " "%d of %s, " "see man page" " of iscsi." "conf", line_number, pathname); } } else { debugmsg(5, "config global " "ImmediateData %d", value); config->defaults.iscsi_options. ImmediateData = value; } } else logmsg(AS_ERROR, "error on line %d of %s, " "invalid ImmediateData %s", line_number, pathname, str); } else if (strncasecmp (line, "MaxRecvDataSegmentLength=", 25) == 0) { char *num = &line[25]; int value = parse_number(num); if (value >= 0) { if (current_entry) { struct iscsi_operational_config *iscsi_options = entry_iscsi_options (current_entry); if (iscsi_options) { debugmsg(5, "config entry " "%p " "MaxRecvDataSegmentLength " "%d", current_entry, value); iscsi_options-> MaxRecvDataSegmentLength = value; } else { logmsg(AS_ERROR, "Invalid " "MaxRecvDataSegmentLength" " entry on line" " %d of %s, " "see man page" " of iscsi." "conf", line_number, pathname); } } else { debugmsg(5, "config global " "MaxRecvDataSegmentLength " "%d", value); config->defaults.iscsi_options. MaxRecvDataSegmentLength = value; } } else logmsg(AS_ERROR, "error on line %d of %s, invalid" " MaxRecvDataSegmentLength %s", line_number, pathname, num); } else if (strncasecmp(line, "FirstBurstLength=", 17) == 0) { char *num = &line[17]; int value = parse_number(num); if (value >= 0) { if (current_entry) { struct iscsi_operational_config *iscsi_options = entry_iscsi_options (current_entry); if (iscsi_options) { debugmsg(5, "config entry " "%p " "FirstBurstLength" " %d", current_entry, value); iscsi_options-> FirstBurstLength = value; } else { logmsg(AS_ERROR, "Invalid " "FirstBurstLength" " entry on line" " %d of %s, " "see man page " "of iscsi." "conf", line_number, pathname); } } else { debugmsg(5, "config global " "FirstBurstLength %d", value); config->defaults.iscsi_options. FirstBurstLength = value; } } else logmsg(AS_ERROR, "error on line %d of %s, " "invalid FirstBurstLength %s", line_number, pathname, num); } else if (strncasecmp(line, "MaxBurstLength=", 15) == 0) { char *num = &line[15]; int value = parse_number(num); if (value >= 0) { if (current_entry) { struct iscsi_operational_config *iscsi_options = entry_iscsi_options (current_entry); if (iscsi_options) { debugmsg(5, "config entry " "%p " "MaxBurstLength" " %d", current_entry, value); iscsi_options-> MaxBurstLength = value; } else { logmsg(AS_ERROR, "Invalid " "MaxBurstLength" " entry on line" " %d of %s, " "see man page "
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -