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 #include "ircd_alloc.h"
30 #include "ircd_chattr.h"
32 #include "ircd_reply.h"
33 #include "ircd_string.h"
40 #include "supported.h"
43 /* #include <assert.h> -- Now using assert in ircd_log.h */
49 * m_functions execute protocol messages on this server:
51 * cptr is always NON-NULL, pointing to a *LOCAL* client
52 * structure (with an open socket connected!). This
53 * identifies the physical socket where the message
54 * originated (or which caused the m_function to be
55 * executed--some m_functions may call others...).
57 * sptr is the source of the message, defined by the
58 * prefix part of the message if present. If not
59 * or prefix not found, then sptr==cptr.
61 * (!IsServer(cptr)) => (cptr == sptr), because
62 * prefixes are taken *only* from servers...
65 * (sptr == cptr) => the message didn't
68 * (sptr != cptr && IsServer(sptr) means
69 * the prefix specified servername. (?)
71 * (sptr != cptr && !IsServer(sptr) means
72 * that message originated from a remote
77 * (!IsServer(sptr)) means that, sptr can safely
78 * taken as defining the target structure of the
79 * message in this server.
81 * *Always* true (if 'parse' and others are working correct):
83 * 1) sptr->from == cptr (note: cptr->from == cptr)
85 * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
86 * *cannot* be a local connection, unless it's
87 * actually cptr!). [MyConnect(x) should probably
88 * be defined as (x == x->from) --msa ]
90 * parc number of variable parameter strings (if zero,
91 * parv is allowed to be NULL)
93 * parv a NULL terminated list of parameter pointers,
95 * parv[0], sender (prefix string), if not present
96 * this points to an empty string.
97 * parv[1]...parv[parc-1]
98 * pointers to additional parameters
99 * parv[parc] == NULL, *always*
101 * note: it is guaranteed that parv[0]..parv[parc-1] are all
105 static const char* const PROTO_REQ = "REQ";
106 static const char* const PROTO_ACK = "ACK";
107 static const char* const PROTO_SUP = "SUP";
109 int proto_handle_ack(struct Client* cptr, const char* msg)
112 * handle ack here, if option and args supported
118 int proto_handle_req(struct Client* cptr, const char* msg)
121 * handle request here if not supported args send
122 * option info. otherwise send ack
127 int proto_send_supported(struct Client* cptr)
130 * send_reply(cptr, RPL_PROTOLIST, "stuff");
132 sendcmdto_one(&me,CMD_PROTO,cptr,"%s unet1 1 1",PROTO_SUP);
136 int m_proto(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
139 return proto_send_supported(cptr);
142 return need_more_params(sptr, "PROTO");
144 if (0 == ircd_strcmp(PROTO_REQ, parv[1]))
145 return proto_handle_req(cptr, parv[2]);
147 else if (0 == ircd_strcmp(PROTO_ACK, parv[1]))
148 return proto_handle_ack(cptr, parv[2]);
150 else if (0 == ircd_strcmp(PROTO_SUP, parv[1]))
151 return 0; /* ignore it */