ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_capab.c
Revision: 1121
Committed: Sun Jan 9 11:03:03 2011 UTC (14 years, 7 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.3/modules/m_capab.c
File size: 3226 byte(s)
Log Message:
- removed all instances of STATIC_MODULES since we don't have
  static modules anymore
- removed m_mkpasswd module from contrib

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_capab.c: Negotiates capabilities with a remote server.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "handlers.h"
27 #include "client.h"
28 #include "irc_string.h"
29 #include "s_serv.h"
30 #include "s_conf.h"
31 #include "msg.h"
32 #include "parse.h"
33 #include "modules.h"
34
35 static void mr_capab(struct Client *, struct Client *, int, char *[]);
36
37 struct Message capab_msgtab = {
38 "CAPAB", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
39 { mr_capab, m_ignore, m_ignore, m_ignore, m_ignore, m_ignore }
40 };
41
42 void
43 _modinit(void)
44 {
45 mod_add_cmd(&capab_msgtab);
46 }
47
48 void
49 _moddeinit(void)
50 {
51 mod_del_cmd(&capab_msgtab);
52 }
53
54 const char *_version = "$Revision$";
55
56 /*
57 * mr_capab - CAPAB message handler
58 * parv[0] = sender prefix
59 * parv[1] = space-separated list of capabilities
60 *
61 */
62 static void
63 mr_capab(struct Client *client_p, struct Client *source_p,
64 int parc, char *parv[])
65 {
66 int i;
67 int cap;
68 char *p = NULL;
69 char *s = NULL;
70 #ifdef HAVE_LIBCRYPTO
71 const struct EncCapability *ecap;
72 unsigned int cipher = 0;
73 #endif
74
75 if (client_p->localClient->caps && !(IsCapable(client_p, CAP_TS6)))
76 {
77 exit_client(client_p, client_p, "CAPAB received twice");
78 return;
79 }
80
81 SetCapable(client_p, CAP_CAP);
82
83 for (i = 1; i < parc; ++i)
84 {
85 for (s = strtoken(&p, parv[i], " "); s;
86 s = strtoken(&p, NULL, " "))
87 {
88 #ifdef HAVE_LIBCRYPTO
89 if (!strncmp(s, "ENC:", 4))
90 {
91 /* Skip the "ENC:" portion */
92 s += 4;
93
94 /* Check the remaining portion against the list of ciphers we
95 * have available (CipherTable).
96 */
97 for (ecap = CipherTable; ecap->name; ++ecap)
98 {
99 if (!irccmp(ecap->name, s) && (ecap->cap & CAP_ENC_MASK))
100 {
101 cipher = ecap->cap;
102 break;
103 }
104 }
105
106 /* Since the name and capabilities matched, use it. */
107 if (cipher != 0)
108 {
109 SetCapable(client_p, CAP_ENC);
110 client_p->localClient->enc_caps |= cipher;
111 }
112 else
113 {
114 /* cipher is still zero; we didn't find a matching entry. */
115 exit_client(client_p, client_p,
116 "Cipher selected is not available here.");
117 return;
118 }
119 }
120 else /* normal capab */
121 #endif
122 if ((cap = find_capability(s)) != 0)
123 SetCapable(client_p, cap);
124 }
125 }
126 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision