Home | History | Annotate | Download | only in iscsitgtd
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License (the "License").
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets "[]" replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 
     22 /*
     23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  */
     26 
     27 #ifndef _TARGET_UTILITY_H
     28 #define	_TARGET_UTILITY_H
     29 
     30 /*
     31  * Block comment which describes the contents of this file.
     32  */
     33 
     34 #ifdef __cplusplus
     35 extern "C" {
     36 #endif
     37 
     38 #include "iscsi_conn.h"
     39 #include <sys/iscsi_protocol.h>
     40 #include "errcode.h"
     41 
     42 #define	SNA32_CHECK 2147483648UL
     43 
     44 /*
     45  * Generates a lot more information on each transfer. Disabling this reduces
     46  * one possible performance impact in the data path. Event with logging turned
     47  * off the messages are still queued which requires malloc's and possible lock
     48  * contention on the management queue. This is a gut feeling, rather than
     49  * actual tests to confirm.
     50  */
     51 #undef	FULL_DEBUG
     52 
     53 typedef struct thick_provo {
     54 	struct thick_provo	*next,
     55 				*prev;
     56 	char			*targ_name;
     57 	int			lun;
     58 	target_queue_t		*q;
     59 } thick_provo_t;
     60 
     61 /*
     62  * in_mark presents the state in validate_xml()
     63  * in_lt means it enters a '<' and wants a '>' to return normal
     64  * in_amp means it meets a '&' and wants a ';' to return normal
     65  */
     66 typedef enum {
     67 	in_none,
     68 	in_lt,
     69 	in_amp
     70 } in_mark_t;
     71 
     72 void util_init();
     73 int read_retry(int fd, char *buf, int count);
     74 Boolean_t parse_text(iscsi_conn_t *c, int dlen, char **text,
     75     int *text_length, int *errcode);
     76 Boolean_t add_text(char **text, int *current_length, char *name, char *val);
     77 char *task_to_str(int func);
     78 void create_geom(diskaddr_t size, int *cylinders, int *heads, int *spt);
     79 void connection_parameters_default(iscsi_conn_t *c);
     80 int sna_lt(uint32_t n1, uint32_t n2);
     81 int sna_lte(uint32_t n1, uint32_t n2);
     82 void xml_rtn_msg(char **buf, err_code_t code);
     83 Boolean_t add_target_alias(iscsi_conn_t *c, char **text, int *test_length);
     84 Boolean_t validate_version(tgt_node_t *node, int *maj, int *min);
     85 char *create_tpgt_list(char *tname);
     86 Boolean_t check_access(tgt_node_t *targ, char *initiator_name,
     87     Boolean_t req_chap);
     88 tgt_node_t *find_target_node(char *targ_name);
     89 void util_title(target_queue_t *q, int type, int num, char *title);
     90 Boolean_t util_create_guid(char **guid, uchar_t id_type);
     91 Boolean_t strtoll_multiplier(char *str, uint64_t *sp);
     92 void thick_provo_stop(char *targ, int lun);
     93 void *thick_provo_start(void *v);
     94 Boolean_t thick_provo_chk_thr(char *targ, int lun);
     95 void remove_target_common(char *name, int lun, char **msg);
     96 char *get_local_name(char *iname);
     97 Boolean_t validate_xml(char *req);
     98 
     99 
    100 #ifdef __cplusplus
    101 }
    102 #endif
    103 
    104 #endif /* _TARGET_UTILITY_H */
    105