ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/releases/8.0.1/modules/m_capab.c
Revision: 1243
Committed: Fri Sep 30 10:47:53 2011 UTC (15 years ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_capab.c
File size: 3311 byte(s)
Log Message:
- move content of msg.h, ircd_handler.h and handlers.h into parse.h and
  remove headers accordingly
- killed common.h
- remove m_killhost.c and m_flags.c from contrib/
- sort out unused header includes here and there

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

Properties

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