rx_kcommon.o \
rx_misc.o \
rx_null.o \
+ rx_opaque.o \
rx_getaddr.o \
rx_packet.o \
rx_multi.o \
rx_kcommon.o \
rx_misc.o \
rx_null.o \
+ rx_opaque.o \
rx_getaddr.o \
rx_packet.o \
rx_multi.o \
$(CRULE_NOOPT)
rx_null.o: $(TOP_SRC_RX)/rx_null.c
$(CRULE_NOOPT)
+rx_opaque.o: $(TOP_SRC_RX)/rx_opaque.c
+ $(CRULE_OPT)
rx_getaddr.o: $(TOP_SRC_RX)/rx_getaddr.c
$(CRULE_NOOPT)
rx_packet.o: $(TOP_SRC_RX)/rx_packet.c
rx_pthread.o \
rx.o \
rx_null.o \
+ rx_opaque.o \
rx_conncache.o \
rx_globals.o \
rx_getaddr.o \
rx_null.o: ${RX}/rx_null.c
${CCRULE} ${RX}/rx_null.c
+rx_opaque.o: ${RX}/rx_opaque.c
+ ${CCRULE} ${RX}/rx_opaque.c
+
rx_globals.o: ${RX}/rx_globals.c
${CCRULE} ${RX}/rx_globals.c
$(OUT)\xdr_rec.obj $(OUT)\xdr_refernce.obj $(OUT)\xdr_rx.obj $(OUT)\xdr_update.obj \
$(OUT)\xdr_afsuuid.obj $(OUT)\xdr_int64.obj $(OUT)\xdr_int32.obj $(OUT)\xdr_len.obj
-RXOBJS = $(OUT)\rx_event.obj $(OUT)\rx_user.obj $(OUT)\rx_pthread.obj $(OUT)\rx.obj $(OUT)\rx_clock_nt.obj \
- $(OUT)\rx_null.obj $(OUT)\rx_globals.obj $(OUT)\rx_getaddr.obj $(OUT)\rx_misc.obj $(OUT)\rx_packet.obj \
- $(OUT)\rx_rdwr.obj $(OUT)\rx_trace.obj $(OUT)\rx_xmit_nt.obj $(OUT)\rx_conncache.obj
+RXOBJS = $(OUT)\rx_event.obj $(OUT)\rx_user.obj $(OUT)\rx_pthread.obj \
+ $(OUT)\rx.obj $(OUT)\rx_clock_nt.obj $(OUT)\rx_null.obj \
+ $(OUT)\rx_globals.obj $(OUT)\rx_getaddr.obj $(OUT)\rx_misc.obj \
+ $(OUT)\rx_packet.obj $(OUT)\rx_rdwr.obj $(OUT)\rx_trace.obj \
+ $(OUT)\rx_xmit_nt.obj $(OUT)\rx_conncache.obj $(OUT)\rx_opaque.obj
RXSTATBJS = $(OUT)\rxstat.obj $(OUT)\rxstat.ss.obj $(OUT)\rxstat.xdr.obj $(OUT)\rxstat.cs.obj
$(DESTDIR)\lib\afsrpc.exp
clean::
- $(DEL) $(DESTDIR)\lib\afsrpc.dll $(DESTDIR)\lib\afsrpc.lib $(DESTDIR)\lib\afsrpc.exp
\ No newline at end of file
+ $(DEL) $(DESTDIR)\lib\afsrpc.dll $(DESTDIR)\lib\afsrpc.lib $(DESTDIR)\lib\afsrpc.exp
$(UOBJ)/rx_misc.o \
$(UOBJ)/rx_multi.o \
$(UOBJ)/rx_null.o \
+ $(UOBJ)/rx_opaque.o \
$(UOBJ)/rx_getaddr.o \
$(UOBJ)/rx_packet.o \
$(UOBJ)/rx_conncache.o \
$(WEBOBJ)/rx_misc.o \
$(WEBOBJ)/rx_multi.o \
$(WEBOBJ)/rx_null.o \
+ $(WEBOBJ)/rx_opaque.o \
$(WEBOBJ)/rx_getaddr.o \
$(WEBOBJ)/rx_packet.o \
$(WEBOBJ)/rx_conncache.o \
$(WEBOBJ)/rx_misc.o \
$(WEBOBJ)/rx_multi.o \
$(WEBOBJ)/rx_null.o \
+ $(WEBOBJ)/rx_opaque.o \
$(WEBOBJ)/rx_getaddr.o \
$(WEBOBJ)/rx_packet.o \
$(WEBOBJ)/rx_conncache.o \
$(JUAFS)/rx_misc.o \
$(JUAFS)/rx_multi.o \
$(JUAFS)/rx_null.o \
+ $(JUAFS)/rx_opaque.o \
$(JUAFS)/rx_getaddr.o \
$(JUAFS)/rx_packet.o \
$(JUAFS)/rx_conncache.o \
$(CRULE1)
$(UOBJ)/rx_null.o: $(TOP_SRC_RX)/rx_null.c
$(CRULE1)
+$(UOBJ)/rx_opaque.o: $(TOP_SRC_RX)/rx_opaque.c
+ $(CRULE1)
$(UOBJ)/rx_getaddr.o: $(TOP_SRC_RX)/rx_getaddr.c
$(CRULE1)
$(UOBJ)/rx_packet.o: $(TOP_SRC_RX)/rx_packet.c
$(CRULE2)
$(WEBOBJ)/rx_null.o: $(TOP_SRC_RX)/rx_null.c
$(CRULE2)
+$(WEBOBJ)/rx_opaque.o: $(TOP_SRC_RX)/rx_opaque.c
+ $(CRULE2)
$(WEBOBJ)/rx_getaddr.o: $(TOP_SRC_RX)/rx_getaddr.c
$(CRULE2)
$(WEBOBJ)/rx_packet.o: $(TOP_SRC_RX)/rx_packet.c
$(CRULE1)
$(JUAFS)/rx_null.o: $(TOP_SRC_RX)/rx_null.c
$(CRULE1)
+$(JUAFS)/rx_opaque.o: $(TOP_SRC_RX)/rx_opaque.c
+ $(CRULE1)
$(JUAFS)/rx_getaddr.o: $(TOP_SRC_RX)/rx_getaddr.c
$(CRULE1)
$(JUAFS)/rx_packet.o: $(TOP_SRC_RX)/rx_packet.c
RXOBJS_common = rx_clock.o rx_event.o rx_user.o rx_lwp.o rx.o rx_null.o \
rx_globals.o rx_getaddr.o rx_misc.o rx_packet.o rx_rdwr.o rx_trace.o \
- rx_conncache.o xdr_int32.o xdr_int64.o xdr_update.o xdr_refernce.o
+ rx_conncache.o rx_opaque.o \
+ xdr_int32.o xdr_int64.o xdr_update.o xdr_refernce.o
RXOBJS = ${RXOBJS_common}
${TOP_INCDIR}/rx/rx_lwp.h \
${TOP_INCDIR}/rx/rx_misc.h \
${TOP_INCDIR}/rx/rx_null.h \
+ ${TOP_INCDIR}/rx/rx_opaque.h \
${TOP_INCDIR}/rx/xdr.h \
${TOP_INCDIR}/rx/xdr_prototypes.h
${TOP_INCDIR}/rx/rx_null.h: rx_null.h
${INSTALL_DATA} $? $@
+${TOP_INCDIR}/rx/rx_opaque.h: rx_opaque.h
+ ${INSTALL_DATA} $? $@
+
${TOP_INCDIR}/rx/xdr.h: xdr.h
${INSTALL_DATA} $? $@
${INSTALL_DATA} ${srcdir}/rx_lwp.h ${DESTDIR}${includedir}/rx/rx_lwp.h
${INSTALL_DATA} ${srcdir}/rx_misc.h ${DESTDIR}${includedir}/rx/rx_misc.h
${INSTALL_DATA} ${srcdir}/rx_null.h ${DESTDIR}${includedir}/rx/rx_null.h
+ ${INSTALL_DATA} ${srcdir}/rx_opaque.h \
+ ${DESTDIR}${includedir}/rx/rx_opaque.h
${INSTALL_DATA} ${srcdir}/xdr.h ${DESTDIR}${includedir}/rx/xdr.h
${INSTALL_DATA} ${srcdir}/xdr_prototypes.h ${DESTDIR}${includedir}/rx/xdr_prototypes.h
${INSTALL_DATA} ${srcdir}/rx_lwp.h ${DEST}/include/rx/rx_lwp.h
${INSTALL_DATA} ${srcdir}/rx_misc.h ${DEST}/include/rx/rx_misc.h
${INSTALL_DATA} ${srcdir}/rx_null.h ${DEST}/include/rx/rx_null.h
+ ${INSTALL_DATA} ${srcdir}/rx_opaque.h ${DEST}/include/rx/rx_opaque.h
${INSTALL_DATA} ${srcdir}/xdr.h ${DEST}/include/rx/xdr.h
${INSTALL_DATA} ${srcdir}/xdr_prototypes.h ${DEST}/include/rx/xdr_prototypes.h
$(OUT)\xdr_rec.obj $(OUT)\xdr_refernce.obj $(OUT)\xdr_rx.obj $(OUT)\xdr_update.obj \
$(OUT)\xdr_afsuuid.obj $(OUT)\xdr_int64.obj $(OUT)\xdr_int32.obj $(OUT)\xdr_len.obj
-RXOBJS = $(OUT)\rx_event.obj $(OUT)\rx_clock_nt.obj $(OUT)\rx_user.obj $(OUT)\rx_lwp.obj $(OUT)\rx.obj \
- $(OUT)\rx_null.obj $(OUT)\rx_globals.obj $(OUT)\rx_getaddr.obj $(OUT)\rx_misc.obj $(OUT)\rx_packet.obj \
- $(OUT)\rx_rdwr.obj $(OUT)\rx_trace.obj $(OUT)\rx_xmit_nt.obj $(OUT)\rx_conncache.obj
+RXOBJS = $(OUT)\rx_event.obj $(OUT)\rx_clock_nt.obj $(OUT)\rx_user.obj \
+ $(OUT)\rx_lwp.obj $(OUT)\rx.obj $(OUT)\rx_null.obj \
+ $(OUT)\rx_globals.obj $(OUT)\rx_getaddr.obj $(OUT)\rx_misc.obj \
+ $(OUT)\rx_packet.obj $(OUT)\rx_rdwr.obj $(OUT)\rx_trace.obj \
+ $(OUT)\rx_xmit_nt.obj $(OUT)\rx_conncache.obj \
+ $(OUT)\rx_opaque.obj
MULTIOBJS = $(OUT)\rx_multi.obj
$(INCFILEDIR)\rx_multi.h \
$(INCFILEDIR)\rx_null.h \
$(INCFILEDIR)\rx_lwp.h \
+ $(INCFILEDIR)\rx_opaque.h \
$(INCFILEDIR)\rx_pthread.h \
$(INCFILEDIR)\rx_xmit_nt.h \
$(INCFILEDIR)\xdr_prototypes.h \
--- /dev/null
+/*
+ * Copyright (c) 2010 Your File System Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+
+#ifndef KERNEL
+# include <sys/types.h>
+# include <string.h>
+# include <errno.h>
+#else
+# include "afs/sysincludes.h"
+# include "afsincludes.h"
+#endif
+
+#include <rx/rx.h>
+#include <rx/rx_opaque.h>
+
+
+/*!
+ * Generate a new opaque object
+ *
+ * Allocate a new opaque object, and copy datalen bytes from data into it.
+ * The caller should dispose of the resulting object using rx_opaque_free or
+ * rx_opaque_zeroFree.
+ *
+ * @param data
+ * A pointer to the data to copy into the object
+ * @param datalen
+ * The number of bytes of data to copy
+ * @returns
+ * A pointer to the allocated opaque object.
+ */
+
+struct rx_opaque *
+rx_opaque_new(void *data, size_t datalen)
+{
+ struct rx_opaque *opaque = rxi_Alloc(sizeof(struct rx_opaque));
+ if (opaque != NULL)
+ rx_opaque_populate(opaque, data, datalen);
+ return opaque;
+}
+
+/*!
+ * Allocate space within an existing opaque object
+ *
+ * Allocate length bytes of data within an existing opaque object. This will
+ * overwrite (without freeing) any data that is already held within the
+ * object.
+ *
+ * @param buf
+ * The opaque object
+ * @param length
+ * The number of bytes to allocate
+ * @returns
+ * 0 on success, ENOMEM if the memory cannot be allocated.
+ */
+
+int
+rx_opaque_alloc(struct rx_opaque *buf, size_t length)
+{
+ void *mem = rxi_Alloc(length);
+ if (mem == NULL)
+ return ENOMEM;
+ buf->val = mem;
+ buf->len = length;
+ memset(buf->val, 0, buf->len);
+
+ return 0;
+}
+
+/*!
+ * Populate an existing opaque object
+ *
+ * Copy datalen bytes from data into an existing opaque object. This allocates
+ * new data space within the object, and will replace (without freeing) any
+ * data that is already held within the object.
+ *
+ * @param to
+ * The opaque object to populate
+ * @param length
+ * The number of bytes to allocate
+ * @returns
+ * 0 on sucess, ENOMEM if memory cannot be allocated
+ */
+
+int
+rx_opaque_populate(struct rx_opaque *to, void *data, size_t datalen)
+{
+ int code;
+ to->len = 0;
+ to->val = NULL;
+
+ code = rx_opaque_alloc(to, datalen);
+ if (code)
+ return code;
+ memcpy(to->val, data, datalen);
+ return 0;
+}
+
+/*!
+ * Copy data from one opaque object to another
+ *
+ * Make a copy of the data held within one existing opaque object into
+ * another. This allocates new data space within the destination object,
+ * and will replace (without freeing) any data that is already held within
+ * this object.
+ *
+ * @param to
+ * To object to copy to
+ * @param from
+ * The object to copy data from
+ * @returns
+ * 0 on success, ENOMEM if memory cannot be allocated
+ */
+
+int
+rx_opaque_copy(struct rx_opaque *to, const struct rx_opaque *from)
+{
+ return rx_opaque_populate(to, from->val, from->len);
+}
+
+/*!
+ * Free the contents of an opaque object
+ *
+ */
+void
+rx_opaque_freeContents(struct rx_opaque *buf) {
+ if (buf->val) {
+ rxi_Free(buf->val, buf->len);
+ }
+ buf->len = 0;
+ buf->val = NULL;
+}
+
+/*!
+ * Zero, then free, the contents of an opaque object
+ */
+void
+rx_opaque_zeroFreeContents(struct rx_opaque *buf) {
+ if (buf->val)
+ memset(buf->val, 0, buf->len);
+ rx_opaque_freeContents(buf);
+}
+
+/*!
+ * Free an opaque object
+ *
+ * This frees the contents of the object, then frees the object itself
+ */
+
+void
+rx_opaque_free(struct rx_opaque **buf) {
+ rx_opaque_freeContents(*buf);
+ rxi_Free(*buf, sizeof(struct rx_opaque));
+ *buf = NULL;
+}
+
+/*!
+ * Zero, then free an opaque object
+ *
+ * This zeros the contents of an opaque object, frees those contents,
+ * then frees the object itself.
+ */
+
+void
+rx_opaque_zeroFree(struct rx_opaque **buf) {
+ rx_opaque_zeroFreeContents(*buf);
+ rxi_Free(*buf, sizeof(struct rx_opaque));
+ *buf = NULL;
+}
--- /dev/null
+/*
+ * Copyright (c) 2010 Your File System Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef OPENAFS_RX_OPAQUE_H
+#define OPENAFS_RX_OPAQUE_H
+
+struct rx_opaque {
+ size_t len;
+ void *val;
+};
+
+#define RX_EMPTY_OPAQUE {0, NULL}
+
+struct rx_opaque *rx_opaque_new(void *data, size_t datalen);
+int rx_opaque_alloc(struct rx_opaque *buf, size_t length);
+int rx_opaque_populate(struct rx_opaque *to, void *data, size_t datalen);
+int rx_opaque_copy(struct rx_opaque *to, const struct rx_opaque *from);
+void rx_opaque_freeContents(struct rx_opaque *buf);
+void rx_opaque_zeroFreeContents(struct rx_opaque *buf);
+void rx_opaque_free(struct rx_opaque **buf);
+void rx_opaque_zeroFree(struct rx_opaque **buf);
+
+#endif
rx_pthread.o \
rx.o \
rx_null.o \
+ rx_opaque.o \
rx_conncache.o \
rx_globals.o \
rx_getaddr.o \
rx_null.o: ${RX}/rx_null.c
${CCRULE}
+rx_opaque.o: ${RX}/rx_opaque.c
+ ${CCRULE}
+
rx_globals.o: ${RX}/rx_globals.c
${CCRULE}
rxi_AllocDataBuf;
rx_MyMaxSendSize;
rxi_Free;
+ rx_opaque_new;
+ rx_opaque_alloc;
+ rx_opaque_populate;
+ rx_opaque_copy;
+ rx_opaque_freeContents;
+ rx_opaque_zeroFreeContents;
+ rx_opaque_free;
+ rx_opaque_zeroFree;
local:
*;
};