mirror of
https://github.com/SCST-project/scst.git
synced 2026-10-22 14:12:33 +00:00
iscsi-scstd: Qualify read-only inputs, callbacks and local views
Qualify daemon protocol/configuration views and read-only helper inputs. Update private declarations and implementations together. Change the account-operation table and all three callbacks as one unit so username and password inputs have matching const types. Separate read-only keys and session-type strings from writable text parser cursors. Keep attribute/list anchors mutable for deletion, while lookup and replacement use read-only views where they leave the anchor unchanged. Preserve ownership, writable outputs and protocol layout. Keep the CHAP entropy probe's af_alg_supported() stub consistent with the const-qualified header it includes through chap.c. Otherwise the probe defines the function with an incompatible pointer parameter. This consumer mismatch was found by source review. Cppcheck reports constParameterPointer and constVariablePointer, including: Parameter 'user' can be declared as pointer to const Parameter 'attrs_list' can be declared as pointer to const Variable 'key' can be declared as pointer to const
This commit is contained in:
@@ -86,7 +86,7 @@ ssize_t af_alg_final(int datafd, void *out, size_t len)
|
||||
return res;
|
||||
}
|
||||
|
||||
bool af_alg_supported(char *alg)
|
||||
bool af_alg_supported(const char *alg)
|
||||
{
|
||||
int sock = af_alg_init(alg);
|
||||
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
int af_alg_init(const char *algorithm);
|
||||
int af_alg_update(int datafd, const void *data_in, size_t len);
|
||||
ssize_t af_alg_final(int datafd, void *out, size_t len);
|
||||
bool af_alg_supported(char *alg);
|
||||
bool af_alg_supported(const char *alg);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -78,7 +78,7 @@ static inline int decode_hex_digit(char c)
|
||||
|
||||
static void decode_hex_string(char *hex_string, u8 *intnum, int intlen)
|
||||
{
|
||||
char *ptr;
|
||||
const char *ptr;
|
||||
int j;
|
||||
|
||||
j = strlen(hex_string);
|
||||
@@ -120,7 +120,7 @@ static u8 decode_base64_digit(char base64)
|
||||
}
|
||||
|
||||
/* Base64 decoding, taken from UNH-iSCSI "Base64StringToInteger()" */
|
||||
static void decode_base64_string(char *string, u8 *intnum, int int_len)
|
||||
static void decode_base64_string(const char *string, u8 *intnum, int int_len)
|
||||
{
|
||||
int len;
|
||||
int count;
|
||||
@@ -176,7 +176,7 @@ static void decode_base64_string(char *string, u8 *intnum, int int_len)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void encode_hex_string(u8 *intnum, long length, char *string)
|
||||
static inline void encode_hex_string(const u8 *intnum, long length, char *string)
|
||||
{
|
||||
int i;
|
||||
char *strptr;
|
||||
@@ -187,7 +187,7 @@ static inline void encode_hex_string(u8 *intnum, long length, char *string)
|
||||
}
|
||||
|
||||
/* Base64 encoding, taken from UNH iSCSI "IntegerToBase64String()" */
|
||||
static void encode_base64_string(u8 *intnum, long length, char *string)
|
||||
static void encode_base64_string(const u8 *intnum, long length, char *string)
|
||||
{
|
||||
int count, strptr, delta;
|
||||
static const char base64code[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
@@ -234,7 +234,7 @@ static void encode_base64_string(u8 *intnum, long length, char *string)
|
||||
string[strptr] = '\0';
|
||||
}
|
||||
|
||||
static inline int chap_check_encoding_format(char *encoded)
|
||||
static inline int chap_check_encoding_format(const char *encoded)
|
||||
{
|
||||
int encoding_fmt;
|
||||
|
||||
@@ -253,7 +253,7 @@ static inline int chap_check_encoding_format(char *encoded)
|
||||
return encoding_fmt;
|
||||
}
|
||||
|
||||
static int chap_alloc_decode_buffer(char *encoded, u8 **decode_buf, int encoding_fmt)
|
||||
static int chap_alloc_decode_buffer(const char *encoded, u8 **decode_buf, int encoding_fmt)
|
||||
{
|
||||
int i;
|
||||
int decode_len = 0;
|
||||
@@ -310,7 +310,7 @@ static int chap_decode_string(char *encoded, u8 *decode_buf, int buf_len, int en
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void chap_encode_string(u8 *intnum, int buf_len, char *encode_buf, int encoding_fmt)
|
||||
static inline void chap_encode_string(const u8 *intnum, int buf_len, char *encode_buf, int encoding_fmt)
|
||||
{
|
||||
encode_buf[0] = '0';
|
||||
if (encoding_fmt == HEX_FORMAT) {
|
||||
@@ -649,7 +649,7 @@ static int chap_target_auth_create_response(struct connection *conn)
|
||||
char chap_id, *value, *response = NULL;
|
||||
u8 *challenge = NULL, *digest = NULL;
|
||||
int encoding_format, response_len;
|
||||
struct iscsi_attr *user;
|
||||
const struct iscsi_attr *user;
|
||||
int challenge_len = 0, digest_len = 0, retval = 0;
|
||||
int res;
|
||||
|
||||
|
||||
+19
-17
@@ -50,7 +50,7 @@ static struct __qelem discovery_users_in = LIST_HEAD_INIT(discovery_users_in);
|
||||
static struct __qelem discovery_users_out = LIST_HEAD_INIT(discovery_users_out);
|
||||
|
||||
struct iscsi_attr *iscsi_attr_lookup_by_sysfs_name(
|
||||
struct __qelem *attrs_list, const char *sysfs_name)
|
||||
const struct __qelem *attrs_list, const char *sysfs_name)
|
||||
{
|
||||
struct iscsi_attr *attr;
|
||||
|
||||
@@ -63,7 +63,7 @@ struct iscsi_attr *iscsi_attr_lookup_by_sysfs_name(
|
||||
}
|
||||
|
||||
struct iscsi_attr *iscsi_attr_lookup_by_key(
|
||||
struct __qelem *attrs_list, const char *key)
|
||||
const struct __qelem *attrs_list, const char *key)
|
||||
{
|
||||
struct iscsi_attr *attr;
|
||||
|
||||
@@ -175,12 +175,13 @@ out_free:
|
||||
goto out;
|
||||
}
|
||||
|
||||
int iscsi_attr_replace(struct __qelem *attrs_list, const char *sysfs_name,
|
||||
int iscsi_attr_replace(const struct __qelem *attrs_list, const char *sysfs_name,
|
||||
char *raw_value)
|
||||
{
|
||||
int res = 0;
|
||||
struct iscsi_attr *attr, *a;
|
||||
char *key, *val, *new_key, *new_val;
|
||||
char *key, *val, *new_key;
|
||||
const char *new_val;
|
||||
|
||||
key = config_sep_string(&raw_value);
|
||||
val = config_sep_string(&raw_value);
|
||||
@@ -313,7 +314,7 @@ static char *config_gets(char *buf, int size, const char *data, int *offset)
|
||||
int accounts_empty(u32 tid, int dir)
|
||||
{
|
||||
struct target *target;
|
||||
struct __qelem *list;
|
||||
const struct __qelem *list;
|
||||
|
||||
if (tid) {
|
||||
target = target_find_by_id(tid);
|
||||
@@ -330,7 +331,7 @@ int accounts_empty(u32 tid, int dir)
|
||||
static struct iscsi_attr *__account_lookup_by_name(struct target *target,
|
||||
int dir, const char *name)
|
||||
{
|
||||
struct __qelem *list;
|
||||
const struct __qelem *list;
|
||||
|
||||
list = account_list_get(target, dir);
|
||||
|
||||
@@ -354,7 +355,7 @@ static struct iscsi_attr *account_lookup_by_name(u32 tid, int dir, const char *n
|
||||
struct iscsi_attr *account_get_first(u32 tid, int dir)
|
||||
{
|
||||
struct target *target;
|
||||
struct __qelem *list;
|
||||
const struct __qelem *list;
|
||||
struct iscsi_attr *user;
|
||||
|
||||
if (tid) {
|
||||
@@ -376,7 +377,7 @@ struct iscsi_attr *account_get_first(u32 tid, int dir)
|
||||
struct iscsi_attr *account_lookup_by_sysfs_name(struct target *target,
|
||||
int dir, const char *sysfs_name)
|
||||
{
|
||||
struct __qelem *list;
|
||||
const struct __qelem *list;
|
||||
|
||||
list = account_list_get(target, dir);
|
||||
|
||||
@@ -385,7 +386,7 @@ struct iscsi_attr *account_lookup_by_sysfs_name(struct target *target,
|
||||
|
||||
int config_account_query(u32 tid, int dir, const char *name, char *pass)
|
||||
{
|
||||
struct iscsi_attr *user;
|
||||
const struct iscsi_attr *user;
|
||||
|
||||
user = account_lookup_by_name(tid, dir, name);
|
||||
if (!user)
|
||||
@@ -400,7 +401,7 @@ int config_account_list(u32 tid, int dir, u32 *cnt, u32 *overflow,
|
||||
char *buf, size_t buf_sz)
|
||||
{
|
||||
struct target *target;
|
||||
struct __qelem *list;
|
||||
const struct __qelem *list;
|
||||
struct iscsi_attr *user;
|
||||
|
||||
*cnt = *overflow = 0;
|
||||
@@ -496,14 +497,14 @@ static int account_create(struct __qelem *list, const char *sysfs_name,
|
||||
int account_replace(struct target *target, int direction,
|
||||
const char *sysfs_name, char *value)
|
||||
{
|
||||
struct __qelem *list;
|
||||
const struct __qelem *list;
|
||||
|
||||
list = account_list_get(target, direction);
|
||||
|
||||
return iscsi_attr_replace(list, sysfs_name, value);
|
||||
}
|
||||
|
||||
int __config_account_add(struct target *target, int dir, char *name, char *pass,
|
||||
int __config_account_add(struct target *target, int dir, char *name, const char *pass,
|
||||
const char *sysfs_name, int send_to_kern, u32 cookie)
|
||||
{
|
||||
int err = 0;
|
||||
@@ -572,7 +573,7 @@ out_destroy:
|
||||
goto out;
|
||||
}
|
||||
|
||||
int config_account_add(u32 tid, int dir, char *name, char *pass,
|
||||
int config_account_add(u32 tid, int dir, char *name, const char *pass,
|
||||
const char *sysfs_name, u32 cookie)
|
||||
{
|
||||
int err = 0;
|
||||
@@ -648,7 +649,7 @@ static int netmask_match_v4(const struct sockaddr_in *sa1,
|
||||
}
|
||||
|
||||
static int netmask_match(const sockaddress *sa1, const sockaddress *sa2,
|
||||
char *buf)
|
||||
const char *buf)
|
||||
{
|
||||
unsigned long mbit;
|
||||
uint8_t family = sa1->sa.sa_family;
|
||||
@@ -795,7 +796,7 @@ int config_initiator_access_allowed(u32 tid, int fd)
|
||||
* Main configuration code
|
||||
*/
|
||||
|
||||
int config_target_create(u32 *tid, char *name)
|
||||
int config_target_create(u32 *tid, const char *name)
|
||||
{
|
||||
int err;
|
||||
struct target *target;
|
||||
@@ -1026,7 +1027,8 @@ int config_parse_main(const char *data, u32 cookie)
|
||||
target->session_params[idx] = val;
|
||||
} else if (!((idx = params_index_by_name_numwild(p, user_keys)) < 0) &&
|
||||
((target != NULL) || global_section)) {
|
||||
char *name, *pass;
|
||||
char *name;
|
||||
const char *pass;
|
||||
|
||||
name = config_sep_string(&q);
|
||||
pass = config_sep_string(&q);
|
||||
@@ -1099,7 +1101,7 @@ static int config_isns_load(const char *config)
|
||||
free(isns_server);
|
||||
isns_server = server;
|
||||
} else if (!strcasecmp(p, ISCSI_ISNS_ACCESS_CONTROL_ATTR_NAME)) {
|
||||
char *str = config_sep_string(&q);
|
||||
const char *str = config_sep_string(&q);
|
||||
|
||||
if (!strcasecmp(str, "No"))
|
||||
isns_access_control = 0;
|
||||
|
||||
@@ -202,7 +202,7 @@ int kernel_target_destroy(u32 tid, u32 cookie)
|
||||
}
|
||||
|
||||
|
||||
int kernel_attr_add(struct target *target, const char *name, u32 mode,
|
||||
int kernel_attr_add(const struct target *target, const char *name, u32 mode,
|
||||
u32 cookie)
|
||||
{
|
||||
struct iscsi_kern_attr_info info;
|
||||
@@ -223,7 +223,7 @@ int kernel_attr_add(struct target *target, const char *name, u32 mode,
|
||||
return res;
|
||||
}
|
||||
|
||||
int kernel_attr_del(struct target *target, const char *name, u32 cookie)
|
||||
int kernel_attr_del(const struct target *target, const char *name, u32 cookie)
|
||||
{
|
||||
struct iscsi_kern_attr_info info;
|
||||
int res;
|
||||
@@ -242,12 +242,12 @@ int kernel_attr_del(struct target *target, const char *name, u32 cookie)
|
||||
return res;
|
||||
}
|
||||
|
||||
int kernel_user_add(struct target *target, struct iscsi_attr *user, u32 cookie)
|
||||
int kernel_user_add(const struct target *target, const struct iscsi_attr *user, u32 cookie)
|
||||
{
|
||||
return kernel_attr_add(target, user->sysfs_name, 0600, cookie);
|
||||
}
|
||||
|
||||
int kernel_user_del(struct target *target, struct iscsi_attr *user, u32 cookie)
|
||||
int kernel_user_del(const struct target *target, const struct iscsi_attr *user, u32 cookie)
|
||||
{
|
||||
return kernel_attr_del(target, user->sysfs_name, cookie);
|
||||
}
|
||||
|
||||
+10
-9
@@ -232,7 +232,8 @@ static int handle_add_user(struct target *target, int dir,
|
||||
const char *sysfs_name, char *p, u32 cookie)
|
||||
{
|
||||
int res;
|
||||
char *name, *pass;
|
||||
char *name;
|
||||
const char *pass;
|
||||
|
||||
name = config_sep_string(&p);
|
||||
pass = config_sep_string(&p);
|
||||
@@ -242,7 +243,7 @@ static int handle_add_user(struct target *target, int dir,
|
||||
return res;
|
||||
}
|
||||
|
||||
static int __handle_add_attr(struct target *target, struct __qelem *attrs_list,
|
||||
static int __handle_add_attr(const struct target *target, struct __qelem *attrs_list,
|
||||
const char *sysfs_name_tmpl, char *p, int single_param_only, u32 cookie)
|
||||
{
|
||||
int res;
|
||||
@@ -319,7 +320,7 @@ out:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int handle_del_user(struct target *target, int dir, char *p, u32 cookie)
|
||||
static int handle_del_user(const struct target *target, int dir, char *p, u32 cookie)
|
||||
{
|
||||
int res;
|
||||
char *name;
|
||||
@@ -332,7 +333,7 @@ static int handle_del_user(struct target *target, int dir, char *p, u32 cookie)
|
||||
return res;
|
||||
}
|
||||
|
||||
static int __handle_del_attr(struct target *target, struct __qelem *attrs_list,
|
||||
static int __handle_del_attr(const struct target *target, struct __qelem *attrs_list,
|
||||
char *p, u32 cookie)
|
||||
{
|
||||
int res;
|
||||
@@ -550,7 +551,7 @@ static int handle_e_get_attr_value(int fd, const struct iscsi_kern_event *event)
|
||||
if (target->session_params[idx] != session_keys[idx].local_def)
|
||||
add_key_mark(res_str, sizeof(res_str), 1);
|
||||
} else if (!((idx = params_index_by_name_numwild(pp, user_keys)) < 0)) {
|
||||
struct iscsi_attr *user;
|
||||
const struct iscsi_attr *user;
|
||||
|
||||
user = account_lookup_by_sysfs_name(target, idx, pp);
|
||||
if (user == NULL) {
|
||||
@@ -563,7 +564,7 @@ static int handle_e_get_attr_value(int fd, const struct iscsi_kern_event *event)
|
||||
ISCSI_USER_PASS(user));
|
||||
add_key_mark(res_str, sizeof(res_str), 0);
|
||||
} else if (strncasecmp_numwild(ISCSI_ALLOWED_PORTAL_ATTR_NAME, pp) == 0) {
|
||||
struct iscsi_attr *portal;
|
||||
const struct iscsi_attr *portal;
|
||||
|
||||
if (target == NULL) {
|
||||
log_error("Target expected for attr %s", pp);
|
||||
@@ -686,7 +687,7 @@ out:
|
||||
return res;
|
||||
}
|
||||
|
||||
static bool is_addr(char *addr)
|
||||
static bool is_addr(const char *addr)
|
||||
{
|
||||
struct in_addr ia;
|
||||
struct in6_addr ia6;
|
||||
@@ -933,7 +934,7 @@ static int handle_e_set_attr_value(int fd, const struct iscsi_kern_event *event)
|
||||
|
||||
target->session_params[idx] = val;
|
||||
} else if (!((idx = params_index_by_name_numwild(pp, user_keys)) < 0)) {
|
||||
struct iscsi_attr *user;
|
||||
const struct iscsi_attr *user;
|
||||
|
||||
user = account_lookup_by_sysfs_name(target, idx, pp);
|
||||
if (user == NULL) {
|
||||
@@ -946,7 +947,7 @@ static int handle_e_set_attr_value(int fd, const struct iscsi_kern_event *event)
|
||||
if (res != 0)
|
||||
goto out_free;
|
||||
} else if (strncasecmp_numwild(ISCSI_ALLOWED_PORTAL_ATTR_NAME, pp) == 0) {
|
||||
struct iscsi_attr *portal;
|
||||
const struct iscsi_attr *portal;
|
||||
|
||||
if (target == NULL) {
|
||||
log_error("Target expected for attr %s", pp);
|
||||
|
||||
+10
-10
@@ -37,7 +37,7 @@
|
||||
#define SET_CONNECTION (1 << 2)
|
||||
#define SET_USER (1 << 4)
|
||||
|
||||
typedef int (user_handle_fn_t)(struct iscsi_adm_req *req, char *user, char *pass);
|
||||
typedef int (user_handle_fn_t)(struct iscsi_adm_req *req, const char *user, const char *pass);
|
||||
|
||||
enum iscsi_adm_op {
|
||||
OP_NEW,
|
||||
@@ -117,7 +117,7 @@ Report bugs to <scst-devel@lists.sourceforge.net>.\n");
|
||||
exit(status == 0 ? 0 : -1);
|
||||
}
|
||||
|
||||
static int str_to_op(char *str)
|
||||
static int str_to_op(const char *str)
|
||||
{
|
||||
int op;
|
||||
|
||||
@@ -135,7 +135,7 @@ static int str_to_op(char *str)
|
||||
return op;
|
||||
}
|
||||
|
||||
static int iscsid_request_send(int fd, struct iscsi_adm_req *req)
|
||||
static int iscsid_request_send(int fd, const struct iscsi_adm_req *req)
|
||||
{
|
||||
int err, ret;
|
||||
|
||||
@@ -247,11 +247,11 @@ out_close:
|
||||
return err;
|
||||
}
|
||||
|
||||
static void show_iscsi_params(int type, struct iscsi_param *param)
|
||||
static void show_iscsi_params(int type, const struct iscsi_param *param)
|
||||
{
|
||||
int i, nr;
|
||||
char buf[1024];
|
||||
struct iscsi_key *keys;
|
||||
const struct iscsi_key *keys;
|
||||
|
||||
if (type == key_session) {
|
||||
nr = session_key_last;
|
||||
@@ -457,7 +457,7 @@ static int parse_user_params(char *params, u32 *auth_dir, char **user,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void show_account(int auth_dir, char *user, char *pass)
|
||||
static void show_account(int auth_dir, const char *user, const char *pass)
|
||||
{
|
||||
char buf[(ISCSI_NAME_LEN + 1) * 2] = {0};
|
||||
|
||||
@@ -469,7 +469,7 @@ static void show_account(int auth_dir, char *user, char *pass)
|
||||
"Incoming" : "Outgoing", buf);
|
||||
}
|
||||
|
||||
static int user_handle_show_user(struct iscsi_adm_req *req, char *user)
|
||||
static int user_handle_show_user(struct iscsi_adm_req *req, const char *user)
|
||||
{
|
||||
int err;
|
||||
|
||||
@@ -537,7 +537,7 @@ static int user_handle_show_list(struct iscsi_adm_req *req)
|
||||
return err;
|
||||
}
|
||||
|
||||
static int user_handle_show(struct iscsi_adm_req *req, char *user, char *pass)
|
||||
static int user_handle_show(struct iscsi_adm_req *req, const char *user, const char *pass)
|
||||
{
|
||||
if (pass)
|
||||
fprintf(stderr, "Ignoring specified password\n");
|
||||
@@ -548,7 +548,7 @@ static int user_handle_show(struct iscsi_adm_req *req, char *user, char *pass)
|
||||
return user_handle_show_list(req);
|
||||
}
|
||||
|
||||
static int user_handle_new(struct iscsi_adm_req *req, char *user, char *pass)
|
||||
static int user_handle_new(struct iscsi_adm_req *req, const char *user, const char *pass)
|
||||
{
|
||||
if (!user || !pass) {
|
||||
fprintf(stderr, "Username and password must be specified\n");
|
||||
@@ -563,7 +563,7 @@ static int user_handle_new(struct iscsi_adm_req *req, char *user, char *pass)
|
||||
return iscsid_request(req, NULL, 0);
|
||||
}
|
||||
|
||||
static int user_handle_del(struct iscsi_adm_req *req, char *user, char *pass)
|
||||
static int user_handle_del(struct iscsi_adm_req *req, const char *user, const char *pass)
|
||||
{
|
||||
if (!user) {
|
||||
fprintf(stderr, "Username must be specified\n");
|
||||
|
||||
@@ -243,7 +243,8 @@ static int uncork_transmit_iser(int fd)
|
||||
|
||||
static void create_iser_listen_socket(struct pollfd *array)
|
||||
{
|
||||
struct addrinfo hints, *res, *res0;
|
||||
struct addrinfo hints, *res0;
|
||||
const struct addrinfo *res;
|
||||
char servname[64];
|
||||
int i, k;
|
||||
int iser_fd;
|
||||
@@ -868,7 +869,7 @@ static void resume_logins(int sig)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ch, longindex;
|
||||
char *config = NULL;
|
||||
const char *config = NULL;
|
||||
uid_t uid = 0;
|
||||
gid_t gid = 0;
|
||||
int err;
|
||||
|
||||
+15
-11
@@ -52,7 +52,8 @@ static struct iscsi_key login_keys[] = {
|
||||
|
||||
char *text_key_find(struct connection *conn, const char *searchKey)
|
||||
{
|
||||
char *data, *key, *value;
|
||||
char *data, *value;
|
||||
const char *key;
|
||||
int keylen, datasize;
|
||||
|
||||
keylen = strlen(searchKey);
|
||||
@@ -194,7 +195,7 @@ void text_key_add(struct connection *conn, const char *key, const char *value)
|
||||
}
|
||||
}
|
||||
|
||||
static void text_key_add_reject(struct connection *conn, char *key)
|
||||
static void text_key_add_reject(struct connection *conn, const char *key)
|
||||
{
|
||||
text_key_add(conn, key, "Reject");
|
||||
}
|
||||
@@ -223,7 +224,8 @@ static void login_rsp_tgt_err(struct connection *conn, int status_detail)
|
||||
|
||||
static void text_scan_security(struct connection *conn)
|
||||
{
|
||||
char *key, *value, *data, *nextValue;
|
||||
char *value, *data, *nextValue;
|
||||
const char *key;
|
||||
int datasize;
|
||||
|
||||
data = conn->req.data;
|
||||
@@ -301,7 +303,7 @@ static int login_check_reinstatement(struct connection *conn)
|
||||
res = -1;
|
||||
goto out;
|
||||
} else {
|
||||
struct connection *c = conn_find(session, conn->cid);
|
||||
const struct connection *c = conn_find(session, conn->cid);
|
||||
|
||||
if (c != NULL) {
|
||||
/* Kernel will do connection reinstatement */
|
||||
@@ -790,7 +792,8 @@ static bool name_chars_are_valid(const char *name)
|
||||
static void login_start(struct connection *conn)
|
||||
{
|
||||
struct iscsi_login_req_hdr *req = (struct iscsi_login_req_hdr *)&conn->req.bhs;
|
||||
char *name, *session_type, *target_name;
|
||||
char *name, *target_name;
|
||||
const char *session_type;
|
||||
|
||||
conn->cid = be16_to_cpu(req->cid);
|
||||
conn->sid.id64 = req->sid.id64;
|
||||
@@ -1021,7 +1024,7 @@ static int cmnd_exec_auth(struct connection *conn)
|
||||
return res;
|
||||
}
|
||||
|
||||
static bool on_internal_portal(struct connection *conn)
|
||||
static bool on_internal_portal(const struct connection *conn)
|
||||
{
|
||||
if (!internal_portal)
|
||||
return false;
|
||||
@@ -1031,7 +1034,7 @@ static bool on_internal_portal(struct connection *conn)
|
||||
|
||||
if (portals) {
|
||||
char *saveptr;
|
||||
char *portal = strtok_r(portals, " ", &saveptr);
|
||||
const char *portal = strtok_r(portals, " ", &saveptr);
|
||||
|
||||
while (portal != NULL) {
|
||||
if (!strcmp(portal, conn->target_portal)) {
|
||||
@@ -1050,7 +1053,7 @@ static bool on_internal_portal(struct connection *conn)
|
||||
|
||||
static void cmnd_exec_login(struct connection *conn)
|
||||
{
|
||||
struct iscsi_login_req_hdr *req = (struct iscsi_login_req_hdr *)&conn->req.bhs;
|
||||
const struct iscsi_login_req_hdr *req = (struct iscsi_login_req_hdr *)&conn->req.bhs;
|
||||
struct iscsi_login_rsp_hdr *rsp = (struct iscsi_login_rsp_hdr *)&conn->rsp.bhs;
|
||||
int stay = 0, nsg_disagree = 0;
|
||||
|
||||
@@ -1242,7 +1245,8 @@ tgt_no_mem:
|
||||
static int text_scan_text(struct connection *conn)
|
||||
{
|
||||
int res = 0;
|
||||
char *key, *value, *data;
|
||||
char *value, *data;
|
||||
const char *key;
|
||||
int datasize;
|
||||
|
||||
data = conn->req.data;
|
||||
@@ -1326,7 +1330,7 @@ out:
|
||||
|
||||
static void cmnd_exec_logout(struct connection *conn)
|
||||
{
|
||||
struct iscsi_logout_req_hdr *req = (struct iscsi_logout_req_hdr *)&conn->req.bhs;
|
||||
const struct iscsi_logout_req_hdr *req = (struct iscsi_logout_req_hdr *)&conn->req.bhs;
|
||||
struct iscsi_logout_rsp_hdr *rsp = (struct iscsi_logout_rsp_hdr *)&conn->rsp.bhs;
|
||||
|
||||
memset(rsp, 0, BHS_SIZE);
|
||||
@@ -1346,7 +1350,7 @@ int cmnd_execute(struct connection *conn)
|
||||
{
|
||||
int res = 1;
|
||||
struct buf_segment *seg;
|
||||
struct iscsi_login_rsp_hdr *login_rsp;
|
||||
const struct iscsi_login_rsp_hdr *login_rsp;
|
||||
|
||||
switch (conn->req.bhs.opcode & ISCSI_OPCODE_MASK) {
|
||||
case ISCSI_OP_LOGIN_CMD:
|
||||
|
||||
+15
-15
@@ -316,13 +316,13 @@ int target_del(u32 tid, u32 cookie);
|
||||
u32 target_find_id_by_name(const char *name);
|
||||
struct target *target_find_by_name(const char *name);
|
||||
struct target *target_find_by_id(u32 tid);
|
||||
void target_list_build(struct connection *conn, char *target_name);
|
||||
void target_list_build(struct connection *conn, const char *target_name);
|
||||
int target_portal_allowed(struct target *target,
|
||||
const char *target_portal, const char *initiator_name);
|
||||
const char *iscsi_make_full_initiator_name(int per_portal_acl,
|
||||
const char *initiator_name, const char *target_portal,
|
||||
char *buf, int size);
|
||||
bool target_redirected(struct target *target, struct connection *conn);
|
||||
bool target_redirected(const struct target *target, struct connection *conn);
|
||||
|
||||
/* message.c */
|
||||
int iscsi_adm_request_listen(void);
|
||||
@@ -335,13 +335,13 @@ int kernel_params_set(u32 tid, u64 sid, int type, u32 partial,
|
||||
const struct iscsi_param *params);
|
||||
int kernel_target_create(struct target *target, u32 *tid, u32 cookie);
|
||||
int kernel_target_destroy(u32 tid, u32 cookie);
|
||||
int kernel_user_add(struct target *target, struct iscsi_attr *user,
|
||||
int kernel_user_add(const struct target *target, const struct iscsi_attr *user,
|
||||
u32 cookie);
|
||||
int kernel_user_del(struct target *target, struct iscsi_attr *user,
|
||||
int kernel_user_del(const struct target *target, const struct iscsi_attr *user,
|
||||
u32 cookie);
|
||||
int kernel_attr_add(struct target *target, const char *name,
|
||||
int kernel_attr_add(const struct target *target, const char *name,
|
||||
u32 mode, u32 cookie);
|
||||
int kernel_attr_del(struct target *target, const char *name, u32 cookie);
|
||||
int kernel_attr_del(const struct target *target, const char *name, u32 cookie);
|
||||
int kernel_initiator_allowed(u32 tid, const char *full_initiator_name);
|
||||
int kernel_session_create(struct connection *conn);
|
||||
int kernel_session_destroy(u32 tid, u64 sid);
|
||||
@@ -358,12 +358,12 @@ char *config_sep_string(char **pp);
|
||||
char *config_strip_string(char *s);
|
||||
int config_parse_main(const char *data, u32 cookie);
|
||||
int config_load(const char *config_name);
|
||||
int config_target_create(u32 *tid, char *name);
|
||||
int config_target_create(u32 *tid, const char *name);
|
||||
int config_target_destroy(u32 tid);
|
||||
int config_account_add(u32 tid, int dir, char *name, char *pass,
|
||||
int config_account_add(u32 tid, int dir, char *name, const char *pass,
|
||||
const char *sysfs_name, u32 cookie);
|
||||
int __config_account_add(struct target *target, int dir, char *name,
|
||||
char *pass, const char *sysfs_name, int send_to_kern, u32 cookie);
|
||||
const char *pass, const char *sysfs_name, int send_to_kern, u32 cookie);
|
||||
int config_account_query(u32 tid, int dir, const char *name, char *pass);
|
||||
int config_account_list(u32 tid, int dir, u32 *cnt, u32 *overflow,
|
||||
char *buf, size_t buf_sz);
|
||||
@@ -380,15 +380,15 @@ int account_replace(struct target *target, int direction,
|
||||
const char *sysfs_name, char *value);
|
||||
void accounts_free(struct __qelem *accounts_list);
|
||||
struct iscsi_attr *iscsi_attr_lookup_by_sysfs_name(
|
||||
struct __qelem *attrs_list, const char *sysfs_name);
|
||||
const struct __qelem *attrs_list, const char *sysfs_name);
|
||||
struct iscsi_attr *iscsi_attr_lookup_by_key(
|
||||
struct __qelem *attrs_list, const char *key);
|
||||
const struct __qelem *attrs_list, const char *key);
|
||||
void iscsi_attrs_free(struct __qelem *attrs_list);
|
||||
int iscsi_attr_create(int attr_size, struct __qelem *attrs_list,
|
||||
const char *sysfs_name_tmpl, const char *key, const char *val,
|
||||
u32 mode, struct iscsi_attr **res_attr);
|
||||
void iscsi_attr_destroy(struct iscsi_attr *attr);
|
||||
int iscsi_attr_replace(struct __qelem *attrs_list, const char *sysfs_name,
|
||||
int iscsi_attr_replace(const struct __qelem *attrs_list, const char *sysfs_name,
|
||||
char *raw_value);
|
||||
|
||||
/* isns.c */
|
||||
@@ -399,9 +399,9 @@ extern int isns_timeout;
|
||||
int isns_init(void);
|
||||
int isns_handle(int is_timeout);
|
||||
int isns_scn_handle(int is_accept);
|
||||
int isns_scn_access_allowed(u32 tid, char *name);
|
||||
int isns_target_register(char *name);
|
||||
int isns_target_deregister(char *name);
|
||||
int isns_scn_access_allowed(u32 tid, const char *name);
|
||||
int isns_target_register(const char *name);
|
||||
int isns_target_deregister(const char *name);
|
||||
void isns_exit(void);
|
||||
|
||||
#endif /* ISCSID_H */
|
||||
|
||||
+15
-14
@@ -68,7 +68,7 @@ static char eid[ISCSI_NAME_LEN];
|
||||
static uint8_t ip[16]; /* SCST iSCSI supports only one portal */
|
||||
static struct sockaddr_storage ss;
|
||||
|
||||
int isns_scn_access_allowed(uint32_t tid, char *name)
|
||||
int isns_scn_access_allowed(uint32_t tid, const char *name)
|
||||
{
|
||||
struct isns_initiator *ini;
|
||||
struct target *target = target_find_by_id(tid);
|
||||
@@ -187,7 +187,7 @@ static void isns_hdr_init(struct isns_hdr *hdr, uint16_t function,
|
||||
}
|
||||
|
||||
static int isns_tlv_set(struct isns_tlv **tlv, int max_tlv_buflen,
|
||||
uint32_t tag, uint32_t length, void *value)
|
||||
uint32_t tag, uint32_t length, const void *value)
|
||||
{
|
||||
int l = length;
|
||||
int res;
|
||||
@@ -217,7 +217,7 @@ out:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int isns_scn_deregister(char *name)
|
||||
static int isns_scn_deregister(const char *name)
|
||||
{
|
||||
int err;
|
||||
uint16_t flags, length = 0;
|
||||
@@ -281,7 +281,7 @@ static int isns_scn_register(void)
|
||||
struct isns_hdr *hdr = (struct isns_hdr *)buf;
|
||||
int max_buf;
|
||||
struct isns_tlv *tlv;
|
||||
struct target *target;
|
||||
const struct target *target;
|
||||
|
||||
if (list_empty(&targets_list))
|
||||
return 0;
|
||||
@@ -336,14 +336,14 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int isns_attr_query(char *name)
|
||||
static int isns_attr_query(const char *name)
|
||||
{
|
||||
int err;
|
||||
uint16_t flags, length = 0;
|
||||
char buf[4096];
|
||||
struct isns_hdr *hdr = (struct isns_hdr *)buf;
|
||||
struct isns_tlv *tlv;
|
||||
struct target *target;
|
||||
const struct target *target;
|
||||
uint32_t node = htonl(ISNS_NODE_INITIATOR);
|
||||
struct isns_qry_mgmt *mgmt;
|
||||
int max_buf;
|
||||
@@ -426,7 +426,7 @@ static int isns_deregister(void)
|
||||
char buf[4096];
|
||||
struct isns_hdr *hdr = (struct isns_hdr *)buf;
|
||||
struct isns_tlv *tlv;
|
||||
struct target *target;
|
||||
const struct target *target;
|
||||
int max_buf;
|
||||
|
||||
if (list_empty(&targets_list))
|
||||
@@ -472,7 +472,7 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
int isns_target_register(char *name)
|
||||
int isns_target_register(const char *name)
|
||||
{
|
||||
char buf[4096];
|
||||
uint16_t flags = 0, length = 0;
|
||||
@@ -481,7 +481,8 @@ int isns_target_register(char *name)
|
||||
uint32_t port = htonl(server_port);
|
||||
uint32_t node = htonl(ISNS_NODE_TARGET);
|
||||
uint32_t type = htonl(2);
|
||||
struct target *target, *alias_target;
|
||||
const struct target *target;
|
||||
struct target *alias_target;
|
||||
int err, initial = list_length_is_one(&targets_list);
|
||||
int max_buf;
|
||||
|
||||
@@ -610,7 +611,7 @@ static void free_all_acl(struct target *target)
|
||||
}
|
||||
}
|
||||
|
||||
int isns_target_deregister(char *name)
|
||||
int isns_target_deregister(const char *name)
|
||||
{
|
||||
char buf[4096];
|
||||
uint16_t flags, length = 0;
|
||||
@@ -679,7 +680,7 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int recv_hdr(int fd, struct isns_io *rx, struct isns_hdr *hdr)
|
||||
static int recv_hdr(int fd, struct isns_io *rx, const struct isns_hdr *hdr)
|
||||
{
|
||||
if (rx->offset < sizeof(*hdr)) {
|
||||
int err;
|
||||
@@ -718,7 +719,7 @@ static inline void get_hdr_param(const struct isns_hdr *hdr, uint16_t *function,
|
||||
*sequence = ntohs(hdr->sequence);
|
||||
}
|
||||
|
||||
static int recv_pdu(int fd, struct isns_io *rx, struct isns_hdr *hdr)
|
||||
static int recv_pdu(int fd, struct isns_io *rx, const struct isns_hdr *hdr)
|
||||
{
|
||||
uint16_t function, length, flags, transaction, sequence;
|
||||
int err;
|
||||
@@ -1026,7 +1027,7 @@ out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int send_scn_rsp(char *name, uint16_t transaction)
|
||||
static int send_scn_rsp(const char *name, uint16_t transaction)
|
||||
{
|
||||
char buf[1024];
|
||||
struct isns_hdr *hdr = (struct isns_hdr *)buf;
|
||||
@@ -1063,7 +1064,7 @@ int isns_scn_handle(int is_accept)
|
||||
struct isns_io *rx = &scn_rx;
|
||||
struct isns_hdr *hdr = (struct isns_hdr *)rx->buf;
|
||||
uint16_t function, transaction;
|
||||
char *name = NULL;
|
||||
const char *name = NULL;
|
||||
|
||||
log_debug(3, "%s %d: %d", __func__, __LINE__, is_accept);
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ struct session *session_find_id(u32 tid, u64 sid)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool session_id_exists(u32 tid, u64 sid, struct session *exclude)
|
||||
static bool session_id_exists(u32 tid, u64 sid, const struct session *exclude)
|
||||
{
|
||||
struct session *session;
|
||||
struct target *target;
|
||||
|
||||
@@ -175,7 +175,7 @@ out:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int is_addr_loopback(char *addr)
|
||||
static int is_addr_loopback(const char *addr)
|
||||
{
|
||||
struct in_addr ia;
|
||||
struct in6_addr ia6;
|
||||
@@ -189,7 +189,7 @@ static int is_addr_loopback(char *addr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is_addr_unspecified(char *addr)
|
||||
static int is_addr_unspecified(const char *addr)
|
||||
{
|
||||
struct in_addr ia;
|
||||
struct in6_addr ia6;
|
||||
@@ -203,7 +203,7 @@ static int is_addr_unspecified(char *addr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void target_print_addr(struct connection *conn, char *addr, int family)
|
||||
static void target_print_addr(struct connection *conn, const char *addr, int family)
|
||||
{
|
||||
char taddr[NI_MAXHOST + NI_MAXSERV + 5];
|
||||
|
||||
@@ -219,7 +219,7 @@ static void target_print_addr(struct connection *conn, char *addr, int family)
|
||||
}
|
||||
|
||||
static void target_list_build_ifaddrs(struct connection *conn,
|
||||
struct target *target, char *exclude_addr, int family)
|
||||
struct target *target, const char *exclude_addr, int family)
|
||||
{
|
||||
struct ifaddrs *ifaddr, *ifa;
|
||||
char if_addr[NI_MAXHOST];
|
||||
@@ -251,7 +251,7 @@ static void target_list_build_ifaddrs(struct connection *conn,
|
||||
return;
|
||||
}
|
||||
|
||||
void target_list_build(struct connection *conn, char *target_name)
|
||||
void target_list_build(struct connection *conn, const char *target_name)
|
||||
{
|
||||
struct target *target;
|
||||
struct sockaddr_storage ss1, ss2;
|
||||
@@ -462,7 +462,7 @@ out:
|
||||
return err;
|
||||
}
|
||||
|
||||
bool target_redirected(struct target *target, struct connection *conn)
|
||||
bool target_redirected(const struct target *target, struct connection *conn)
|
||||
{
|
||||
bool res = false, rc;
|
||||
union {
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ void text_key_add(struct connection *conn, const char *key, const char *value)
|
||||
}
|
||||
}
|
||||
|
||||
bool af_alg_supported(char *algorithm)
|
||||
bool af_alg_supported(const char *algorithm)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user