CVS commit: src/lib/libisns

2011-10-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct 25 00:02:30 UTC 2011

Modified Files:
src/lib/libisns: isns.h isns_pdu.c

Log Message:
make length unsigned.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/lib/libisns/isns.h \
src/lib/libisns/isns_pdu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libisns/isns.h
diff -u src/lib/libisns/isns.h:1.1.1.1 src/lib/libisns/isns.h:1.2
--- src/lib/libisns/isns.h:1.1.1.1	Sat Jan 15 20:22:50 2011
+++ src/lib/libisns/isns.h	Mon Oct 24 20:02:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: isns.h,v 1.1.1.1 2011/01/16 01:22:50 agc Exp $	*/
+/*	$NetBSD: isns.h,v 1.2 2011/10/25 00:02:30 christos Exp $	*/
 
 /*-
  * Copyright (c) 2004,2009 The NetBSD Foundation, Inc.
@@ -59,8 +59,8 @@ void isns_stop(ISNS_HANDLE);
 ISNS_TRANS isns_new_trans(ISNS_HANDLE, uint16_t, uint16_t);
 void isns_free_trans(ISNS_TRANS);
 int isns_send_trans(ISNS_TRANS, const struct timespec *, uint32_t *);
-int isns_add_tlv(ISNS_TRANS, uint32_t, int, const void *);
-int isns_get_tlv(ISNS_TRANS, int, uint32_t *, int *, void **);
+int isns_add_tlv(ISNS_TRANS, uint32_t, uint32_t, const void *);
+int isns_get_tlv(ISNS_TRANS, int, uint32_t *, uint32_t *, void **);
 
 int	isns_add_string(ISNS_TRANS, uint32_t, const char *);
 
Index: src/lib/libisns/isns_pdu.c
diff -u src/lib/libisns/isns_pdu.c:1.1.1.1 src/lib/libisns/isns_pdu.c:1.2
--- src/lib/libisns/isns_pdu.c:1.1.1.1	Sat Jan 15 20:22:50 2011
+++ src/lib/libisns/isns_pdu.c	Mon Oct 24 20:02:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: isns_pdu.c,v 1.1.1.1 2011/01/16 01:22:50 agc Exp $	*/
+/*	$NetBSD: isns_pdu.c,v 1.2 2011/10/25 00:02:30 christos Exp $	*/
 
 /*-
  * Copyright (c) 2004,2009 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 
 #include sys/cdefs.h
-__RCSID($NetBSD: isns_pdu.c,v 1.1.1.1 2011/01/16 01:22:50 agc Exp $);
+__RCSID($NetBSD: isns_pdu.c,v 1.2 2011/10/25 00:02:30 christos Exp $);
 
 
 #include sys/types.h
@@ -576,7 +576,7 @@ int
 isns_add_string(ISNS_TRANS trans, uint32_t tag, const char *s)
 {
 	/* Add string, including required NULL. */
-	return isns_add_tlv(trans, tag, (int)strlen(s)+1, s);
+	return isns_add_tlv(trans, tag, (uint32_t)strlen(s) + 1, s);
 }
 
 
@@ -584,7 +584,8 @@ isns_add_string(ISNS_TRANS trans, uint32
  * isns_add_tlv - adds a TLV to an existing transaction
  */
 int
-isns_add_tlv(ISNS_TRANS trans, uint32_t tag, int data_len, const void *data_p)
+isns_add_tlv(ISNS_TRANS trans, uint32_t tag, uint32_t data_len,
+const void *data_p)
 {
 	struct isns_trans_s *trans_p;
 	uint8_t tlv_buf[ISNS_TLV_HDR_SIZE];
@@ -629,8 +630,8 @@ isns_add_tlv(ISNS_TRANS trans, uint32_t 
  *   ENOMEM - could not allocate storage for spanning TLV data
  */
 int
-isns_get_tlv(ISNS_TRANS trans, int which_tlv, uint32_t *tag_p, int *data_len_p,
-void **data_pp)
+isns_get_tlv(ISNS_TRANS trans, int which_tlv, uint32_t *tag_p,
+uint32_t *data_len_p, void **data_pp)
 {
 	struct isns_trans_s *trans_p;
 	struct isns_get_tlv_info_s *info_p;



CVS commit: src/lib/libisns

2011-08-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 17 10:08:43 UTC 2011

Modified Files:
src/lib/libisns: Makefile isns_pdu.h isns_util.h

Log Message:
fix gcc aliasing issues.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libisns/Makefile
cvs rdiff -u -r1.1.1.1 -r1.2 src/lib/libisns/isns_pdu.h \
src/lib/libisns/isns_util.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libisns/Makefile
diff -u src/lib/libisns/Makefile:1.2 src/lib/libisns/Makefile:1.3
--- src/lib/libisns/Makefile:1.2	Mon Jun 20 22:32:55 2011
+++ src/lib/libisns/Makefile	Wed Aug 17 06:08:43 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2011/06/21 02:32:55 mrg Exp $
+#	$NetBSD: Makefile,v 1.3 2011/08/17 10:08:43 christos Exp $
 
 .include bsd.own.mk
 
@@ -14,7 +14,3 @@
 WARNS=	4
 
 .include bsd.lib.mk
-
-.if ${HAVE_GCC} = 45
-COPTS.isns_pdu.c+=	-fno-strict-aliasing
-.endif

Index: src/lib/libisns/isns_pdu.h
diff -u src/lib/libisns/isns_pdu.h:1.1.1.1 src/lib/libisns/isns_pdu.h:1.2
--- src/lib/libisns/isns_pdu.h:1.1.1.1	Sat Jan 15 20:22:50 2011
+++ src/lib/libisns/isns_pdu.h	Wed Aug 17 06:08:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: isns_pdu.h,v 1.1.1.1 2011/01/16 01:22:50 agc Exp $	*/
+/*	$NetBSD: isns_pdu.h,v 1.2 2011/08/17 10:08:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 2004,2009 The NetBSD Foundation, Inc.
@@ -37,8 +37,10 @@
 #define _ISNS_PDU_H_
 
 #include pthread.h
+#include string.h
 
 #include isns_defs.h
+#include isns_util.h
 
 #define ISNSP_VERSION		(0x0001)
 
@@ -101,32 +103,36 @@
 /*
  * TLV buffer access/manipulation-related macros.
  */
-#define ISNS_TLV_HDR_SIZE	8
+#define ISNS_TLV_HDR_SIZE	(sizeof(uint32_t) * 2)
 
 #define ISNS_PAD4_LEN(n)	(uint32_t)(((n)+3)  ~0x03)
 #define ISNS_PAD4_BYTES(n)	((4 - ((n)  0x03))  0x03)
 
-#define ISNS_TLV_TAG_REF(_buf)	\
- 	(*(uint32_t *)(void *)(_buf))
-#define ISNS_TLV_GET_TAG(_buf)	\
-	isns_ntohl(ISNS_TLV_TAG_REF(_buf))
-#define ISNS_TLV_SET_TAG(_buf, _tag)\
-	do {			\
-		ISNS_TLV_TAG_REF(_buf) = isns_htonl(_tag);	\
-	} while (/* CONSTCOND */0)
-
-#define ISNS_TLV_LEN_REF(_buf)	\
-	(*(uint32_t *)(void *)((uint8_t *)(_buf)+4))
-#define ISNS_TLV_GET_LEN(_buf)	\
-	isns_ntohl(ISNS_TLV_LEN_REF(_buf))
-#define ISNS_TLV_SET_LEN(_buf, _len)\
-	do {			\
-		ISNS_TLV_LEN_REF(_buf) = isns_htonl(_len);	\
-	} while (/* CONSTCOND */0)
-
-#define ISNS_TLV_DATA_PTR(_buf)	\
-	((void *)((uint8_t *)(_buf)+8))
-
+static inline uint32_t ISNS_TLV_GET_TAG(const void *buf) {
+	uint32_t tag;
+	memcpy(tag, buf, sizeof(tag));
+	return isns_ntohl(tag);
+}
+
+static inline void ISNS_TLV_SET_TAG(void *buf, uint32_t tag) {
+	tag = isns_htonl(tag);
+	memcpy(buf, tag, sizeof(tag));
+}
+
+static inline uint32_t ISNS_TLV_GET_LEN(const void *buf) {
+	uint32_t len;
+	memcpy(len, (const uint8_t *)buf + sizeof(len), sizeof(len));
+	return isns_ntohl(len);
+}
+
+static inline void ISNS_TLV_SET_LEN(void *buf, uint32_t len) {
+	len = isns_htonl(len);
+	memcpy((uint8_t *)buf + sizeof(len), len, sizeof(len));
+}
+
+static inline void *ISNS_TLV_DATA_PTR(void *buf) {
+	return (uint8_t *)buf + ISNS_TLV_HDR_SIZE;
+}
 
 /*
  * ISNS transaction and PDU structs.
Index: src/lib/libisns/isns_util.h
diff -u src/lib/libisns/isns_util.h:1.1.1.1 src/lib/libisns/isns_util.h:1.2
--- src/lib/libisns/isns_util.h:1.1.1.1	Sat Jan 15 20:22:50 2011
+++ src/lib/libisns/isns_util.h	Wed Aug 17 06:08:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: isns_util.h,v 1.1.1.1 2011/01/16 01:22:50 agc Exp $	*/
+/*	$NetBSD: isns_util.h,v 1.2 2011/08/17 10:08:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 2004,2009 The NetBSD Foundation, Inc.
@@ -48,6 +48,7 @@
 #define ARRAY_ELEMS(a)	(sizeof(a)/sizeof((a)[0]))
 
 
+struct isns_config_s;
 int isns_issue_cmd(struct isns_config_s *, uint8_t);
 int isns_issue_cmd_with_data(struct isns_config_s *, uint8_t,
 uint8_t *, int);



CVS commit: src/lib/libisns

2011-01-16 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Jan 16 08:00:01 UTC 2011

Modified Files:
src/lib/libisns: isns.3

Log Message:
Typo fixes, use more markup.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/lib/libisns/isns.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libisns/isns.3
diff -u src/lib/libisns/isns.3:1.1.1.1 src/lib/libisns/isns.3:1.2
--- src/lib/libisns/isns.3:1.1.1.1	Sun Jan 16 01:22:50 2011
+++ src/lib/libisns/isns.3	Sun Jan 16 08:00:01 2011
@@ -1,4 +1,4 @@
-.\ $NetBSD: isns.3,v 1.1.1.1 2011/01/16 01:22:50 agc Exp $
+.\ $NetBSD: isns.3,v 1.2 2011/01/16 08:00:01 wiz Exp $
 .\
 .\ Copyright (c) 2004,2009 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -76,7 +76,7 @@
 .Nm
 does not currently support receipt of iSNS Heartbeat messages, State Change
 Notification (SCN) messages, or Entity Status Inquiry (ESI) messages.
-.Sh INITILAIZATION
+.Sh INITIALIZATION
 An iSNS client that uses
 .Nm
 must call
@@ -86,12 +86,16 @@
 as such should only be called when thread creation is appropriate (such
 as after a daemonized program forks).
 .Pp
-The value passed as 'is_server' is used to set iSNSP message format Flags
+The value passed as
+.Ar is_server
+is used to set iSNSP message format Flags
 Sender is the iSNS client (bit position 16) and Sender is the iSNS server
 (bit position 17).
 For now the value 0 (zero) should be passed for
-'is_server'.
-The value returned in 'h' should be considered opaque by the caller.
+.Ar is_server .
+The value returned in
+.Ar h
+should be considered opaque by the caller.
 This value is passed unchanged to
 .Fn isns_add_servercon ,
 .Fn isns_init_reg_refresh ,
@@ -110,8 +114,11 @@
 server to which iSNSP queries and requests are to be sent.
 This routine should not be called by a program acting as an iSNS server.
 .Pp
-A connected TCP socket descriptor is passed as parameter 'fd'.
-Parameter 'ai' is the address of the remote TCP endpoint.
+A connected TCP socket descriptor is passed as parameter
+.Ar fd .
+Parameter
+.Ar ai
+is the address of the remote TCP endpoint.
 It is included so that reconnection may be attempted by
 .Nm
 in the event that the TCP connection is broken.
@@ -124,20 +131,30 @@
 .Nm
 to refresh registrations on behalf of the iSNS client.
 .Pp
-Parameter 'node' is the iSCSI Name attribute used for the periodic queries.
+Parameter
+.Ar node
+is the
+.Dq iSCSI Name
+attribute used for the periodic queries.
 It should be the name of an iSCSI node within the registered iSNS entity.
-The desired refresh interval, in seconds, is passed in parameter 'interval'.
+The desired refresh interval, in seconds, is passed in parameter
+.Ar interval .
 .Sh TRANSACTIONS
 .Fn isns_new_trans
 creates new iSNS transactions.
 .Pp
-Parameter 'func_id' is used as the iSNSP message id.
-Parameter 'pdu_flags' is used to set iSNSP message format Flags and is
+Parameter
+.Ar func_id
+is used as the iSNSP message id.
+Parameter
+.Ar pdu_flags
+is used to set iSNSP message format Flags and is
 exposed to allow callers to set flag Replace flag (bit position 19).
 This provides callers with a way
 to specify whether a Device Attribute Registration Request is intended to
-update or replace an existing registration.  This is currently the only use
-defined for parameter 'pdu_flags'.
+update or replace an existing registration.
+This is currently the only use defined for parameter
+.Ar pdu_flags .
 .Pp
 Once a new transaction has been created, callers can specify iSNS attributes
 used for registration and query requests.
@@ -146,9 +163,15 @@
 or
 .Fn isns_add_string .
 .Pp
-Parameter 'tag' is the iSNS Tag corresponding to the attribute being added.
-Parameter 'data_len' is the length of the attribute value.
-Parameter 'data_p' references the attribute value.
+Parameter
+.Ar tag
+is the iSNS Tag corresponding to the attribute being added.
+Parameter
+.Ar data_len
+is the length of the attribute value.
+Parameter
+.Ar data_p
+references the attribute value.
 The caller does not need to handle iSNS attribute 4-byte alignment requirements.
 This is handled by the iSNS environment on behalf of the caller.
 .Fn isns_add_string
@@ -163,22 +186,36 @@
 supports bounded waits.
 Successful waits, those that do not time out, return the iSNSP response
 status code received in the iSNSP response message.
-If a wait does time out, the value of 'status_p' is undefined.
+If a wait does time out, the value of
+.Ar status_p
+is undefined.
 Callers that do not need to wait for returned data can simply
-pass NULL for parameter 'timeout_p'.
-Callers should set parameter 'status_p' to NULL if not waiting.
+pass
+.Dv NULL
+for parameter
+.Ar timeout_p .
+Callers should set parameter
+.Ar status_p
+to
+.Dv NULL
+if not waiting.
 .Pp
 .Fn isns_get_tlv
 is used to retrieve TLV data returned in a transaction.
 The first call to
 .Fn isns_get_tlv
-should pass 

CVS commit: src/lib/libisns

2011-01-15 Thread Alistair G. Crooks
Module Name:src
Committed By:   agc
Date:   Sun Jan 16 01:22:51 UTC 2011

Update of /cvsroot/src/lib/libisns
In directory ivanova.netbsd.org:/tmp/cvs-serv9549

Log Message:
Initial import of libisns, contributed to the NetBSD Foundation by
Wasabi Systems, Inc.

libisns(3) is an implementation of the iSNS protocol as defined in
IETF RFC 4171, exporting an API that simplifies Internet Storage Name
Service (iSNS) client implementations.

Status:

Vendor Tag: WASABI
Release Tags:   libisns-base

N src/lib/libisns/isns_config.h
N src/lib/libisns/Makefile
N src/lib/libisns/isns.3
N src/lib/libisns/isns.c
N src/lib/libisns/isns.h
N src/lib/libisns/isns_fileio.c
N src/lib/libisns/isns_defs.h
N src/lib/libisns/isns_fileio.h
N src/lib/libisns/isns_pdu.c
N src/lib/libisns/isns_pdu.h
N src/lib/libisns/isns_socketio.c
N src/lib/libisns/isns_socketio.h
N src/lib/libisns/isns_task.c
N src/lib/libisns/isns_task.h
N src/lib/libisns/isns_thread.c
N src/lib/libisns/isns_thread.h
N src/lib/libisns/isns_util.c
N src/lib/libisns/isns_util.h
N src/lib/libisns/shlib_version

No conflicts created by this import