Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2004-12-16 03:29:02 UTC
Modified files:
ircd/send.c ircd/s_user.c ircd/s_serv.c ircd/s_bsd.c
include/send.h include/numnicks.h include/client.h ChangeLog
Log message:
Add new server flag (+6) to indicate IPv6 address format support. If
a peer server does not advertise that flag, send 0.0.0.0 as the IP for
IPv6 users.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.514 ircu2.10/ChangeLog:1.515
--- ircu2.10/ChangeLog:1.514 Mon Dec 13 19:00:37 2004
+++ ircu2.10/ChangeLog Wed Dec 15 19:28:52 2004
@@ -1,3 +1,27 @@
+2004-12-14 Michael Poole <[EMAIL PROTECTED]>
+
+ * include/client.h (FLAG_IPV6): New value for enum Flag.
+ (IsIPv6, SetIPv6): Accessor macros for it.
+
+ * include/numnicks.h (iptobase64): Add flag indicating whether to
+ use full IPv6 addresses or fake them in an IPv4-compatible way.
+
+ * ircd/numnicks.c (iptobase64): Use the new flag.
+
+ * include/send.h (sendcmdto_flag_serv_butone): New function to
+ send different lines to servers based on flags (like FLAG_IPV6).
+
+ * ircd/send.c (sendcmdto_flag_serv_butone): Implement it.
+
+ * ircd/s_bsd.c (completed_connection): Advertise IPv6 support in
+ our server flags.
+
+ * ircd/s_serv.c (server_estab): Likewise. Also make sure we send
+ compatible IP addresses for the new server.
+
+ * ircd/s_user.c (register_user): Only send full IPv6 addresses to
+ links that have FLAG_IPV6 set.
+
2004-12-13 Michael Poole <[EMAIL PROTECTED]>
* doc/example.conf: Update General block comment to mention
Index: ircu2.10/include/client.h
diff -u ircu2.10/include/client.h:1.40 ircu2.10/include/client.h:1.41
--- ircu2.10/include/client.h:1.40 Sun Nov 7 12:57:49 2004
+++ ircu2.10/include/client.h Wed Dec 15 19:28:51 2004
@@ -19,7 +19,7 @@
*/
/** @file
* @brief Structures and functions for handling local clients.
- * @version $Id: client.h,v 1.40 2004/11/07 20:57:49 entrope Exp $
+ * @version $Id: client.h,v 1.41 2004/12/16 03:28:51 entrope Exp $
*/
#ifndef INCLUDED_client_h
#define INCLUDED_client_h
@@ -143,6 +143,7 @@
FLAG_CLOSING, /**< set when closing to suppress errors */
FLAG_UPING, /**< has active UDP ping request */
FLAG_HUB, /**< server is a hub */
+ FLAG_IPV6, /**< server understands P10 IPv6 addrs */
FLAG_SERVICE, /**< server is a service */
FLAG_GOTID, /**< successful ident lookup achieved */
FLAG_DOID, /**< I-lines say must use ident return */
@@ -574,6 +575,8 @@
#define SendWallops(x) HasFlag(x, FLAG_WALLOP)
/** Return non-zero if the client claims to be a hub. */
#define IsHub(x) HasFlag(x, FLAG_HUB)
+/** Return non-zero if the client understands IPv6 addresses in P10. */
+#define IsIPv6(x) HasFlag(x, FLAG_IPV6)
/** Return non-zero if the client claims to be a services server. */
#define IsService(x) HasFlag(x, FLAG_SERVICE)
/** Return non-zero if the client has an account stamp. */
@@ -620,6 +623,8 @@
#define SetServNotice(x) SetFlag(x, FLAG_SERVNOTICE)
/** Mark a client as being a hub server. */
#define SetHub(x) SetFlag(x, FLAG_HUB)
+/** Mark a client as being an IPv6-grokking server. */
+#define SetIPv6(x) SetFlag(x, FLAG_IPV6)
/** Mark a client as being a services server. */
#define SetService(x) SetFlag(x, FLAG_SERVICE)
/** Mark a client as having an account stamp. */
Index: ircu2.10/include/numnicks.h
diff -u ircu2.10/include/numnicks.h:1.10 ircu2.10/include/numnicks.h:1.11
--- ircu2.10/include/numnicks.h:1.10 Mon Oct 4 21:14:44 2004
+++ ircu2.10/include/numnicks.h Wed Dec 15 19:28:51 2004
@@ -18,7 +18,7 @@
*/
/** @file
* @brief Interface for numeric nickname functions.
- * @version $Id: numnicks.h,v 1.10 2004/10/05 04:14:44 entrope Exp $
+ * @version $Id: numnicks.h,v 1.11 2004/12/16 03:28:51 entrope Exp $
*/
#ifndef INCLUDED_numnicks_h
#define INCLUDED_numnicks_h
@@ -84,7 +84,7 @@
extern unsigned int base64toint(const char* str);
extern const char* inttobase64(char* buf, unsigned int v, unsigned int
count);
-extern const char* iptobase64(char* buf, const struct irc_in_addr* addr,
unsigned int count);
+extern const char* iptobase64(char* buf, const struct irc_in_addr* addr,
unsigned int count, int v6_ok);
extern void base64toip(const char* s, struct irc_in_addr* addr);
#endif /* INCLUDED_numnicks_h */
Index: ircu2.10/include/send.h
diff -u ircu2.10/include/send.h:1.21 ircu2.10/include/send.h:1.22
--- ircu2.10/include/send.h:1.21 Mon Oct 4 21:21:37 2004
+++ ircu2.10/include/send.h Wed Dec 15 19:28:51 2004
@@ -1,6 +1,6 @@
/** @file send.h
* @brief Send messages to certain targets.
- * @version $Id: send.h,v 1.21 2004/10/05 04:21:37 entrope Exp $
+ * @version $Id: send.h,v 1.22 2004/12/16 03:28:51 entrope Exp $
*/
#ifndef INCLUDED_send_h
#define INCLUDED_send_h
@@ -44,6 +44,12 @@
const char *tok, struct Client *to,
const char *pattern, ...);
+/* Send command to servers by flags except one */
+extern void sendcmdto_flag_serv_butone(struct Client *from, const char *cmd,
+ const char *tok, struct Client *one,
+ int require, int forbid,
+ const char *pattern, ...);
+
/* Send command to all servers except one */
extern void sendcmdto_serv_butone(struct Client *from, const char *cmd,
const char *tok, struct Client *one,
Index: ircu2.10/ircd/s_bsd.c
diff -u ircu2.10/ircd/s_bsd.c:1.69 ircu2.10/ircd/s_bsd.c:1.70
--- ircu2.10/ircd/s_bsd.c:1.69 Fri Dec 10 21:14:04 2004
+++ ircu2.10/ircd/s_bsd.c Wed Dec 15 19:28:50 2004
@@ -19,7 +19,7 @@
*/
/** @file
* @brief Functions that now (or in the past) relied on BSD APIs.
- * @version $Id: s_bsd.c,v 1.69 2004/12/11 05:14:04 klmitch Exp $
+ * @version $Id: s_bsd.c,v 1.70 2004/12/16 03:28:50 entrope Exp $
*/
#include "config.h"
@@ -384,7 +384,7 @@
cli_lasttime(cptr) = CurrentTime;
SetFlag(cptr, FLAG_PINGSENT);
- sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s :%s",
+ sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s6 :%s",
cli_name(&me), cli_serv(&me)->timestamp, newts,
MAJOR_PROTOCOL, NumServCap(&me),
feature_bool(FEAT_HUB) ? "h" : "", cli_info(&me));
Index: ircu2.10/ircd/s_serv.c
diff -u ircu2.10/ircd/s_serv.c:1.34 ircu2.10/ircd/s_serv.c:1.35
--- ircu2.10/ircd/s_serv.c:1.34 Fri Dec 10 21:14:05 2004
+++ ircu2.10/ircd/s_serv.c Wed Dec 15 19:28:50 2004
@@ -22,7 +22,7 @@
*/
/** @file
* @brief Miscellaneous server support functions.
- * @version $Id: s_serv.c,v 1.34 2004/12/11 05:14:05 klmitch Exp $
+ * @version $Id: s_serv.c,v 1.35 2004/12/16 03:28:50 entrope Exp $
*/
#include "config.h"
@@ -128,7 +128,7 @@
/*
* Pass my info to the new server
*/
- sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s :%s",
+ sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s6 :%s",
cli_name(&me), cli_serv(&me)->timestamp,
cli_serv(cptr)->timestamp, MAJOR_PROTOCOL, NumServCap(&me),
feature_bool(FEAT_HUB) ? "h" : "",
@@ -258,7 +258,7 @@
cli_name(acptr), cli_hopcount(acptr) + 1,
cli_lastnick(acptr),
cli_user(acptr)->username, cli_user(acptr)->realhost,
*s ? "+" : "", s, *s ? " " : "",
- iptobase64(xxx_buf, &cli_ip(acptr), sizeof(xxx_buf)),
+ iptobase64(xxx_buf, &cli_ip(acptr), sizeof(xxx_buf),
IsIPv6(cptr)),
NumNick(acptr), cli_info(acptr));
}
}
Index: ircu2.10/ircd/s_user.c
diff -u ircu2.10/ircd/s_user.c:1.82 ircu2.10/ircd/s_user.c:1.83
--- ircu2.10/ircd/s_user.c:1.82 Fri Dec 10 21:14:06 2004
+++ ircu2.10/ircd/s_user.c Wed Dec 15 19:28:50 2004
@@ -22,7 +22,7 @@
*/
/** @file
* @brief Miscellaneous user-related helper functions.
- * @version $Id: s_user.c,v 1.82 2004/12/11 05:14:06 klmitch Exp $
+ * @version $Id: s_user.c,v 1.83 2004/12/16 03:28:50 entrope Exp $
*/
#include "config.h"
@@ -657,13 +657,24 @@
}
}
tmpstr = umode_str(sptr);
- sendcmdto_serv_butone(user->server, CMD_NICK, cptr,
- "%s %d %Tu %s %s %s%s%s%s %s%s :%s",
- nick, cli_hopcount(sptr) + 1, cli_lastnick(sptr),
- user->username, user->realhost,
- *tmpstr ? "+" : "", tmpstr, *tmpstr ? " " : "",
- iptobase64(ip_base64, &cli_ip(sptr), sizeof(ip_base64)),
- NumNick(sptr), cli_info(sptr));
+ /* Send full IP address to IPv6-grokking servers. */
+ sendcmdto_flag_serv_butone(user->server, CMD_NICK, cptr,
+ FLAG_IPV6, FLAG_LAST_FLAG,
+ "%s %d %Tu %s %s %s%s%s%s %s%s :%s",
+ nick, cli_hopcount(sptr) + 1, cli_lastnick(sptr),
+ user->username, user->realhost,
+ *tmpstr ? "+" : "", tmpstr, *tmpstr ? " " : "",
+ iptobase64(ip_base64, &cli_ip(sptr),
sizeof(ip_base64), 1),
+ NumNick(sptr), cli_info(sptr));
+ /* Send fake IPv6 addresses to pre-IPv6 servers. */
+ sendcmdto_flag_serv_butone(user->server, CMD_NICK, cptr,
+ FLAG_LAST_FLAG, FLAG_IPV6,
+ "%s %d %Tu %s %s %s%s%s%s %s%s :%s",
+ nick, cli_hopcount(sptr) + 1, cli_lastnick(sptr),
+ user->username, user->realhost,
+ *tmpstr ? "+" : "", tmpstr, *tmpstr ? " " : "",
+ iptobase64(ip_base64, &cli_ip(sptr),
sizeof(ip_base64), 0),
+ NumNick(sptr), cli_info(sptr));
/* Send server notice mask to client */
if (MyUser(sptr) && (cli_snomask(sptr) != SNO_DEFAULT) && HasFlag(sptr,
FLAG_SERVNOTICE))
Index: ircu2.10/ircd/send.c
diff -u ircu2.10/ircd/send.c:1.54 ircu2.10/ircd/send.c:1.55
--- ircu2.10/ircd/send.c:1.54 Fri Dec 10 21:14:07 2004
+++ ircu2.10/ircd/send.c Wed Dec 15 19:28:50 2004
@@ -19,7 +19,7 @@
*/
/** @file
* @brief Send messages to certain targets.
- * @version $Id: send.c,v 1.54 2004/12/11 05:14:07 klmitch Exp $
+ * @version $Id: send.c,v 1.55 2004/12/16 03:28:50 entrope Exp $
*/
#include "config.h"
@@ -364,6 +364,47 @@
}
/**
+ * Send a (prefixed) command to all servers matching or not matching a
+ * flag but one.
+ * @param[in] from Client sending the command.
+ * @param[in] cmd Long name of command (ignored).
+ * @param[in] tok Short name of command.
+ * @param[in] one Client direction to skip (or NULL).
+ * @param[in] require Only send to servers with this Flag bit set.
+ * @param[in] forbid Do not send to servers with this Flag bit set.
+ * @param[in] pattern Format string for command arguments.
+ */
+void sendcmdto_flag_serv_butone(struct Client *from, const char *cmd,
+ const char *tok, struct Client *one,
+ int require, int forbid,
+ const char *pattern, ...)
+{
+ struct VarData vd;
+ struct MsgBuf *mb;
+ struct DLink *lp;
+
+ vd.vd_format = pattern; /* set up the struct VarData for %v */
+ va_start(vd.vd_args, pattern);
+
+ /* use token */
+ mb = msgq_make(&me, "%C %s %v", from, tok, &vd);
+ va_end(vd.vd_args);
+
+ /* send it to our downlinks */
+ for (lp = cli_serv(&me)->down; lp; lp = lp->next) {
+ if (one && lp->value.cptr == cli_from(one))
+ continue;
+ if ((require < FLAG_LAST_FLAG) && !HasFlag(lp->value.cptr, require))
+ continue;
+ if ((forbid < FLAG_LAST_FLAG) && HasFlag(lp->value.cptr, forbid))
+ continue;
+ send_buffer(lp->value.cptr, mb, 0);
+ }
+
+ msgq_clean(mb);
+}
+
+/**
* Send a (prefixed) command to all servers but one.
* @param[in] from Client sending the command.
* @param[in] cmd Long name of command (ignored).
----------------------- End of diff -----------------------