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"
31 #include "ircd_reply.h"
32 #include "ircd_string.h"
39 #include "supported.h"
48 * m_functions execute protocol messages on this server:
50 * cptr is always NON-NULL, pointing to a *LOCAL* client
51 * structure (with an open socket connected!). This
52 * identifies the physical socket where the message
53 * originated (or which caused the m_function to be
54 * executed--some m_functions may call others...).
56 * sptr is the source of the message, defined by the
57 * prefix part of the message if present. If not
58 * or prefix not found, then sptr==cptr.
60 * (!IsServer(cptr)) => (cptr == sptr), because
61 * prefixes are taken *only* from servers...
64 * (sptr == cptr) => the message didn't
67 * (sptr != cptr && IsServer(sptr) means
68 * the prefix specified servername. (?)
70 * (sptr != cptr && !IsServer(sptr) means
71 * that message originated from a remote
76 * (!IsServer(sptr)) means that, sptr can safely
77 * taken as defining the target structure of the
78 * message in this server.
80 * *Always* true (if 'parse' and others are working correct):
82 * 1) sptr->from == cptr (note: cptr->from == cptr)
84 * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
85 * *cannot* be a local connection, unless it's
86 * actually cptr!). [MyConnect(x) should probably
87 * be defined as (x == x->from) --msa ]
89 * parc number of variable parameter strings (if zero,
90 * parv is allowed to be NULL)
92 * parv a NULL terminated list of parameter pointers,
94 * parv[0], sender (prefix string), if not present
95 * this points to an empty string.
96 * parv[1]...parv[parc-1]
97 * pointers to additional parameters
98 * parv[parc] == NULL, *always*
100 * note: it is guaranteed that parv[0]..parv[parc-1] are all
104 static const char* const PROTO_REQ = "REQ";
105 static const char* const PROTO_ACK = "ACK";
106 static const char* const PROTO_SUP = "SUP";
108 int proto_handle_ack(struct Client* cptr, const char* msg)
111 * handle ack here, if option and args supported
117 int proto_handle_req(struct Client* cptr, const char* msg)
120 * handle request here if not supported args send
121 * option info. otherwise send ack
126 int proto_send_supported(struct Client* cptr)
129 * send_reply(cptr, RPL_PROTOLIST, "stuff");
131 sendcmdto_one(&me,CMD_PROTO,cptr,"%s unet1 1 1",PROTO_SUP);
135 int m_proto(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
138 return proto_send_supported(cptr);
141 return need_more_params(sptr, "PROTO");
143 if (0 == ircd_strcmp(PROTO_REQ, parv[1]))
144 return proto_handle_req(cptr, parv[2]);
146 else if (0 == ircd_strcmp(PROTO_ACK, parv[1]))
147 return proto_handle_ack(cptr, parv[2]);
149 else if (0 == ircd_strcmp(PROTO_SUP, parv[1]))
150 return 0; /* ignore it */