ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_capab.c
Revision: 969
Committed: Sun Aug 2 22:48:53 2009 UTC (16 years ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.2/modules/m_capab.c
File size: 3256 byte(s)
Log Message:
- cleanup m_capab() while reviewing: remove useless non-NULL test on p->localClient

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     #ifndef STATIC_MODULES
43     void
44     _modinit(void)
45     {
46     mod_add_cmd(&capab_msgtab);
47     }
48    
49     void
50     _moddeinit(void)
51     {
52     mod_del_cmd(&capab_msgtab);
53     }
54    
55 knight 31 const char *_version = "$Revision$";
56 adx 30 #endif
57    
58     /*
59     * mr_capab - CAPAB message handler
60     * parv[0] = sender prefix
61     * parv[1] = space-separated list of capabilities
62     *
63     */
64     static void
65     mr_capab(struct Client *client_p, struct Client *source_p,
66     int parc, char *parv[])
67     {
68     int i;
69     int cap;
70 michael 875 char *p = NULL;
71     char *s = NULL;
72 adx 30 #ifdef HAVE_LIBCRYPTO
73 michael 969 const struct EncCapability *ecap;
74 adx 30 unsigned int cipher = 0;
75     #endif
76    
77     if (client_p->localClient->caps && !(IsCapable(client_p, CAP_TS6)))
78     {
79     exit_client(client_p, client_p, "CAPAB received twice");
80     return;
81     }
82    
83 michael 969 SetCapable(client_p, CAP_CAP);
84    
85     for (i = 1; i < parc; ++i)
86 adx 30 {
87 michael 969 for (s = strtoken(&p, parv[i], " "); s;
88     s = strtoken(&p, NULL, " "))
89 adx 30 {
90     #ifdef HAVE_LIBCRYPTO
91 michael 969 if (!strncmp(s, "ENC:", 4))
92 adx 30 {
93     /* Skip the "ENC:" portion */
94     s += 4;
95    
96     /* Check the remaining portion against the list of ciphers we
97     * have available (CipherTable).
98     */
99 michael 969 for (ecap = CipherTable; ecap->name; ++ecap)
100 adx 30 {
101 michael 969 if (!irccmp(ecap->name, s) && (ecap->cap & CAP_ENC_MASK))
102 adx 30 {
103     cipher = ecap->cap;
104     break;
105     }
106     }
107 michael 969
108 adx 30 /* Since the name and capabilities matched, use it. */
109     if (cipher != 0)
110     {
111     SetCapable(client_p, CAP_ENC);
112     client_p->localClient->enc_caps |= cipher;
113     }
114     else
115     {
116     /* cipher is still zero; we didn't find a matching entry. */
117     exit_client(client_p, client_p,
118     "Cipher selected is not available here.");
119     return;
120     }
121     }
122     else /* normal capab */
123     #endif
124     if ((cap = find_capability(s)) != 0)
125     SetCapable(client_p, cap);
126     }
127     }
128     }

Properties

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