/*
- * Copyright (c) 2005 Zmanda Inc. All Rights Reserved.
+ * Copyright (c) 2007, 2008, 2010 Zmanda, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Contact information: Zmanda Inc, 505 N Mathlida Ave, Suite 120
- * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
+ * Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
+ * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
*
* Author: Dustin J. Mitchell <dustin@zmanda.com>
*/
* Utility routines for handling sockaddrs
*/
+#include "amanda.h"
#include "sockaddr-util.h"
void
return mystr_sockaddr;
}
+int
+str_to_sockaddr(
+ const char *src,
+ sockaddr_union *dst)
+{
+ int result;
+
+ g_debug("parsing %s", src);
+ /* try AF_INET first */
+ SU_INIT(dst, AF_INET);
+ if ((result = inet_pton(AF_INET, src, &dst->sin.sin_addr)) == 1)
+ return result;
+
+ /* otherwise try AF_INET6, if supported */
+#ifdef WORKING_IPV6
+ SU_INIT(dst, AF_INET6);
+ return inet_pton(AF_INET6, src, &dst->sin6.sin6_addr);
+#else
+ return result;
+#endif
+}
+
/* Unmap a V4MAPPED IPv6 address into its equivalent IPv4 address. The location
* TMP is used to store the rewritten address, if necessary. Returns a pointer
* to the unmapped address.