ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_capab.c
Revision: 1155
Committed: Tue Aug 9 20:27:45 2011 UTC (14 years ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/modules/m_capab.c
File size: 3226 byte(s)
Log Message:
- recreate "trunk"

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
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 michael 969 static void mr_capab(struct Client *, struct Client *, int, char *[]);
36 adx 30
37     struct Message capab_msgtab = {
38     "CAPAB", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
39 michael 969 { mr_capab, m_ignore, m_ignore, m_ignore, m_ignore, m_ignore }
40 adx 30 };
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 knight 31 const char *_version = "$Revision$";
55 adx 30
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 michael 875 char *p = NULL;
69     char *s = NULL;
70 adx 30 #ifdef HAVE_LIBCRYPTO
71 michael 969 const struct EncCapability *ecap;
72 adx 30 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 michael 969 SetCapable(client_p, CAP_CAP);
82    
83     for (i = 1; i < parc; ++i)
84 adx 30 {
85 michael 969 for (s = strtoken(&p, parv[i], " "); s;
86     s = strtoken(&p, NULL, " "))
87 adx 30 {
88     #ifdef HAVE_LIBCRYPTO
89 michael 969 if (!strncmp(s, "ENC:", 4))
90 adx 30 {
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 michael 969 for (ecap = CipherTable; ecap->name; ++ecap)
98 adx 30 {
99 michael 969 if (!irccmp(ecap->name, s) && (ecap->cap & CAP_ENC_MASK))
100 adx 30 {
101     cipher = ecap->cap;
102     break;
103     }
104     }
105 michael 969
106 adx 30 /* 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