#define INADDRSZ 4
#endif
-#ifdef IPV6
+#ifdef RB_IPV6
#ifndef IN6ADDRSZ
#define IN6ADDRSZ 16
#endif
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
-unsigned char *
-ircd_base64_encode(const unsigned char *str, int length)
-{
- const unsigned char *current = str;
- unsigned char *p;
- unsigned char *result;
-
- if ((length + 2) < 0 || ((length + 2) / 3) >= (1 << (sizeof(int) * 8 - 2))) {
- return NULL;
- }
-
- result = rb_malloc(((length + 2) / 3) * 5);
- p = result;
-
- while (length > 2)
- {
- *p++ = base64_table[current[0] >> 2];
- *p++ = base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
- *p++ = base64_table[((current[1] & 0x0f) << 2) + (current[2] >> 6)];
- *p++ = base64_table[current[2] & 0x3f];
-
- current += 3;
- length -= 3;
- }
-
- if (length != 0) {
- *p++ = base64_table[current[0] >> 2];
- if (length > 1) {
- *p++ = base64_table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
- *p++ = base64_table[(current[1] & 0x0f) << 2];
- *p++ = base64_pad;
- } else {
- *p++ = base64_table[(current[0] & 0x03) << 4];
- *p++ = base64_pad;
- *p++ = base64_pad;
- }
- }
- *p = '\0';
- return result;
-}
-
-unsigned char *
-ircd_base64_decode(const unsigned char *str, int length, int *ret)
-{
- const unsigned char *current = str;
- int ch, i = 0, j = 0, k;
- unsigned char *result;
-
- result = rb_malloc(length + 1);
-
- while ((ch = *current++) != '\0' && length-- > 0) {
- if (ch == base64_pad) break;
-
- ch = base64_reverse_table[ch];
- if (ch < 0) continue;
-
- switch(i % 4) {
- case 0:
- result[j] = ch << 2;
- break;
- case 1:
- result[j++] |= ch >> 4;
- result[j] = (ch & 0x0f) << 4;
- break;
- case 2:
- result[j++] |= ch >>2;
- result[j] = (ch & 0x03) << 6;
- break;
- case 3:
- result[j++] |= ch;
- break;
- }
- i++;
- }
-
- k = j;
-
- if (ch == base64_pad) {
- switch(i % 4) {
- case 1:
- free(result);
- return NULL;
- case 2:
- k++;
- case 3:
- result[k++] = 0;
- }
- }
- result[j] = '\0';
-
- if(ret)
- *ret = j;
-
- return result;
-}
-
/*
* From: Thomas Helvey <tomh@inxpress.net>
*/
*/
static const char *inet_ntop4(const u_char * src, char *dst, unsigned int size);
-#ifdef IPV6
+#ifdef RB_IPV6
static const char *inet_ntop6(const u_char * src, char *dst, unsigned int size);
#endif
* author:
* Paul Vixie, 1996.
*/
-#ifdef IPV6
+#ifdef RB_IPV6
static const char *
inet_ntop6(const unsigned char *src, char *dst, unsigned int size)
{
{
((struct sockaddr_in *) dst)->sin_port = 0;
((struct sockaddr_in *) dst)->sin_family = AF_INET;
- SET_SS_LEN((struct irc_sockaddr_storage *) dst, sizeof(struct sockaddr_in));
+ SET_SS_LEN((struct rb_sockaddr_storage *) dst, sizeof(struct sockaddr_in));
return 1;
}
-#ifdef IPV6
+#ifdef RB_IPV6
else if(inetpton(AF_INET6, src, &((struct sockaddr_in6 *) dst)->sin6_addr))
{
((struct sockaddr_in6 *) dst)->sin6_port = 0;
((struct sockaddr_in6 *) dst)->sin6_family = AF_INET6;
- SET_SS_LEN((struct irc_sockaddr_storage *) dst, sizeof(struct sockaddr_in6));
+ SET_SS_LEN((struct rb_sockaddr_storage *) dst, sizeof(struct sockaddr_in6));
return 1;
}
#endif
case AF_INET:
return (inetntop(AF_INET, &((struct sockaddr_in *) src)->sin_addr, dst, size));
break;
-#ifdef IPV6
+#ifdef RB_IPV6
case AF_INET6:
return (inetntop(AF_INET6, &((struct sockaddr_in6 *) src)->sin6_addr, dst, size));
break;
{
case AF_INET:
return (inet_ntop4(src, dst, size));
-#ifdef IPV6
+#ifdef RB_IPV6
case AF_INET6:
if(IN6_IS_ADDR_V4MAPPED((const struct in6_addr *) src) ||
IN6_IS_ADDR_V4COMPAT((const struct in6_addr *) src))
return (1);
}
-#ifdef IPV6
+#ifdef RB_IPV6
/* int
* inet_pton6(src, dst)
* convert presentation level address to network order binary form.
{
case AF_INET:
return (inet_pton4(src, dst));
-#ifdef IPV6
+#ifdef RB_IPV6
case AF_INET6:
/* Somebody might have passed as an IPv4 address this is sick but it works */
if(inet_pton4(src, dst))