ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_capab.c
Revision: 30
Committed: Sun Oct 2 20:03:27 2005 UTC (19 years, 10 months ago) by adx
Content type: text/x-csrc
Original Path: ircd-hybrid/modules/m_capab.c
File size: 3420 byte(s)
Log Message:
- imported sources
- can be moved later according to the directory/branching scheme,
  but we need the svn up

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     * $Id: m_capab.c,v 1.39 2005/07/30 20:44:14 adx Exp $
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     #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     const char *_version = "$Revision: 1.39 $";
56     #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     char *p;
71     char *s;
72     #ifdef HAVE_LIBCRYPTO
73     struct EncCapability *ecap;
74     unsigned int cipher = 0;
75     #endif
76    
77     /* ummm, this shouldn't happen. Could argue this should be logged etc. */
78     if (client_p->localClient == NULL)
79     return;
80    
81     if (client_p->localClient->caps && !(IsCapable(client_p, CAP_TS6)))
82     {
83     exit_client(client_p, client_p, "CAPAB received twice");
84     return;
85     }
86     else
87     SetCapable(client_p, CAP_CAP);
88    
89     for (i = 1; i < parc; i++)
90     {
91     for (s = strtoken(&p, parv[i], " "); s; s = strtoken(&p, NULL, " "))
92     {
93     #ifdef HAVE_LIBCRYPTO
94     if ((strncmp(s, "ENC:", 4) == 0))
95     {
96     /* Skip the "ENC:" portion */
97     s += 4;
98    
99     /* Check the remaining portion against the list of ciphers we
100     * have available (CipherTable).
101     */
102     for (ecap = CipherTable; ecap->name; ecap++)
103     {
104     if ((irccmp(ecap->name, s) == 0) && (ecap->cap & CAP_ENC_MASK))
105     {
106     cipher = ecap->cap;
107     break;
108     }
109     }
110     /* Since the name and capabilities matched, use it. */
111     if (cipher != 0)
112     {
113     SetCapable(client_p, CAP_ENC);
114     client_p->localClient->enc_caps |= cipher;
115     }
116     else
117     {
118     /* cipher is still zero; we didn't find a matching entry. */
119     exit_client(client_p, client_p,
120     "Cipher selected is not available here.");
121     return;
122     }
123     }
124     else /* normal capab */
125     #endif
126     if ((cap = find_capability(s)) != 0)
127     SetCapable(client_p, cap);
128     }
129     }
130     }

Properties

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