2 * IRC - Internet Relay Chat, ircd/m_proto.c
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
6 * See file AUTHORS in IRC package for additional names of
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 1, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 * No need to include handlers.h here the signatures must match
30 * and we don't need to force a rebuild of all the handlers everytime
31 * we add a new one to the list. --Bleep
37 #include "ircd_alloc.h"
38 #include "ircd_chattr.h"
39 #include "ircd_reply.h"
40 #include "ircd_string.h"
47 #include "supported.h"
56 * m_functions execute protocol messages on this server:
58 * cptr is always NON-NULL, pointing to a *LOCAL* client
59 * structure (with an open socket connected!). This
60 * identifies the physical socket where the message
61 * originated (or which caused the m_function to be
62 * executed--some m_functions may call others...).
64 * sptr is the source of the message, defined by the
65 * prefix part of the message if present. If not
66 * or prefix not found, then sptr==cptr.
68 * (!IsServer(cptr)) => (cptr == sptr), because
69 * prefixes are taken *only* from servers...
72 * (sptr == cptr) => the message didn't
75 * (sptr != cptr && IsServer(sptr) means
76 * the prefix specified servername. (?)
78 * (sptr != cptr && !IsServer(sptr) means
79 * that message originated from a remote
84 * (!IsServer(sptr)) means that, sptr can safely
85 * taken as defining the target structure of the
86 * message in this server.
88 * *Always* true (if 'parse' and others are working correct):
90 * 1) sptr->from == cptr (note: cptr->from == cptr)
92 * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
93 * *cannot* be a local connection, unless it's
94 * actually cptr!). [MyConnect(x) should probably
95 * be defined as (x == x->from) --msa ]
97 * parc number of variable parameter strings (if zero,
98 * parv is allowed to be NULL)
100 * parv a NULL terminated list of parameter pointers,
102 * parv[0], sender (prefix string), if not present
103 * this points to an empty string.
104 * parv[1]...parv[parc-1]
105 * pointers to additional parameters
106 * parv[parc] == NULL, *always*
108 * note: it is guaranteed that parv[0]..parv[parc-1] are all
112 static const char* const PROTO_REQ = "REQ";
113 static const char* const PROTO_ACK = "ACK";
114 static const char* const PROTO_SUP = "SUP";
116 int proto_handle_ack(struct Client* cptr, const char* msg)
119 * handle ack here, if option and args supported
125 int proto_handle_req(struct Client* cptr, const char* msg)
128 * handle request here if not supported args send
129 * option info. otherwise send ack
134 int proto_send_supported(struct Client* cptr)
137 * send_reply(cptr, RPL_PROTOLIST, "stuff");
139 sendcmdto_one(&me,CMD_PROTO,cptr,"%s unet1 1 1",PROTO_SUP);
143 int m_proto(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
146 return proto_send_supported(cptr);
149 return need_more_params(sptr, "PROTO");
151 if (0 == ircd_strcmp(PROTO_REQ, parv[1]))
152 return proto_handle_req(cptr, parv[2]);
154 else if (0 == ircd_strcmp(PROTO_ACK, parv[1]))
155 return proto_handle_ack(cptr, parv[2]);
157 else if (0 == ircd_strcmp(PROTO_SUP, parv[1]))
158 return 0; /* ignore it */