Revision: 14739
Author: adrian.chadd
Date: Tue Jul 13 07:06:28 2010
Log: Add in a helper function which returns a pointer to the underlying
address
storage struct.
http://code.google.com/p/lusca-cache/source/detail?r=14739
Modified:
/playpen/LUSCA_HEAD_ipv6/libsqinet/sqinet.c
/playpen/LUSCA_HEAD_ipv6/libsqinet/sqinet.h
=======================================
--- /playpen/LUSCA_HEAD_ipv6/libsqinet/sqinet.c Sun Jul 11 02:47:00 2010
+++ /playpen/LUSCA_HEAD_ipv6/libsqinet/sqinet.c Tue Jul 13 07:06:28 2010
@@ -932,3 +932,22 @@
return -1;
}
+/*
+ * Return a pointer to the underlying storage for the address part.
+ * Maybe this should be an inline function?
+ */
+void *
+sqinet_get_ipentry(const sqaddr_t *addr)
+{
+ switch (addr->st.ss_family) {
+ case AF_INET:
+ return &(((struct sockaddr_in *) &addr->st)->sin_addr);
+ break;
+ case AF_INET6:
+ return &(((struct sockaddr_in6 *)
&addr->st)->sin6_addr);
+ break;
+ default:
+ return NULL;
+ }
+ return NULL;
+}
=======================================
--- /playpen/LUSCA_HEAD_ipv6/libsqinet/sqinet.h Sun Jul 11 02:47:00 2010
+++ /playpen/LUSCA_HEAD_ipv6/libsqinet/sqinet.h Tue Jul 13 07:06:28 2010
@@ -50,8 +50,11 @@
static inline struct sockaddr * sqinet_get_entry(sqaddr_t *s) { return
(struct sockaddr *) &(s->st); }
static inline const struct sockaddr * sqinet_get_entry_ro(const sqaddr_t
*s) { return (struct sockaddr *) &(s->st); }
+
static inline int sqinet_get_family(const sqaddr_t *s) { return
s->st.ss_family; }
+
static inline int sqinet_get_length(const sqaddr_t *s) { if
(s->st.ss_family == AF_INET) return sizeof(struct sockaddr_in); else return
sizeof(struct sockaddr_in6); }
+static inline int sqinet_get_bitlength(const sqaddr_t *s) { if
(s->st.ss_family == AF_INET) return 32; else if (s->st.ss_family ==
AF_INET6) return 128; else return 0; }
static inline int sqinet_get_maxlength(const sqaddr_t *s) { return
sizeof(s->st); }
static inline int sqinet_copy(sqaddr_t *dst, const sqaddr_t *src) { *dst =
*src; return 1; }
@@ -65,4 +68,6 @@
extern unsigned int sqinet_hash_host_key(const sqaddr_t *a, unsigned int
size);
+extern void * sqinet_get_ipentry(const sqaddr_t *s);
+
#endif
--
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en.