]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/parse.c
implement /WALLOPS as described in RFC 2812, section 4.7.
[ngircd-alex.git] / src / ngircd / parse.c
index 623855da08d02fc016f0ed03d601e756afd57dae..b5e64a331ffd0a2c57b503e0d0ca2097d84747ec 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: parse.c,v 1.64 2005/07/22 21:31:05 alex Exp $";
+static char UNUSED id[] = "$Id: parse.c,v 1.68 2007/08/02 10:14:26 fw Exp $";
 
 /**
  * @file
@@ -93,6 +93,7 @@ COMMAND My_Commands[] =
        { "USER", IRC_USER, 0xFFFF, 0, 0, 0 },
        { "USERHOST", IRC_USERHOST, CLIENT_USER, 0, 0, 0 },
        { "VERSION", IRC_VERSION, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+       { "WALLOPS", IRC_WALLOPS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "WHO", IRC_WHO, CLIENT_USER, 0, 0, 0 },
        { "WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
        { "WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
@@ -103,13 +104,13 @@ COMMAND My_Commands[] =
 };
 
 
-LOCAL void Init_Request PARAMS(( REQUEST *Req ));
+static void Init_Request PARAMS(( REQUEST *Req ));
 
-LOCAL bool Validate_Prefix PARAMS(( CONN_ID Idx, REQUEST *Req, bool *Closed ));
-LOCAL bool Validate_Command PARAMS(( CONN_ID Idx, REQUEST *Req, bool *Closed ));
-LOCAL bool Validate_Args PARAMS(( CONN_ID Idx, REQUEST *Req, bool *Closed ));
+static bool Validate_Prefix PARAMS(( CONN_ID Idx, REQUEST *Req, bool *Closed ));
+static bool Validate_Command PARAMS(( CONN_ID Idx, REQUEST *Req, bool *Closed ));
+static bool Validate_Args PARAMS(( CONN_ID Idx, REQUEST *Req, bool *Closed ));
 
-LOCAL bool Handle_Request PARAMS(( CONN_ID Idx, REQUEST *Req ));
+static bool Handle_Request PARAMS(( CONN_ID Idx, REQUEST *Req ));
 
 
 /**
@@ -247,7 +248,7 @@ Parse_Request( CONN_ID Idx, char *Request )
  * Initialize request structure.
  * @param Req Request structure to be initialized.
  */
-LOCAL void
+static void
 Init_Request( REQUEST *Req )
 {
        /* Neue Request-Struktur initialisieren */
@@ -263,7 +264,7 @@ Init_Request( REQUEST *Req )
 } /* Init_Request */
 
 
-LOCAL bool
+static bool
 Validate_Prefix( CONN_ID Idx, REQUEST *Req, bool *Closed )
 {
        CLIENT *client, *c;
@@ -277,7 +278,7 @@ Validate_Prefix( CONN_ID Idx, REQUEST *Req, bool *Closed )
        if( ! Req->prefix ) return true;
 
        /* Client-Struktur der Connection ermitteln */
-       client = Client_GetFromConn( Idx );
+       client = Conn_GetClient( Idx );
        assert( client != NULL );
 
        /* nur validieren, wenn bereits registrierte Verbindung */
@@ -306,7 +307,7 @@ Validate_Prefix( CONN_ID Idx, REQUEST *Req, bool *Closed )
        {
                /* das angegebene Prefix ist aus dieser Richtung, also
                 * aus der gegebenen Connection, ungueltig! */
-               Log( LOG_ERR, "Spoofed prefix \"%s\" from \"%s\" (connection %d, command %s)!", Req->prefix, Client_Mask( Client_GetFromConn( Idx )), Idx, Req->command );
+               Log( LOG_ERR, "Spoofed prefix \"%s\" from \"%s\" (connection %d, command %s)!", Req->prefix, Client_Mask( Conn_GetClient( Idx )), Idx, Req->command );
                Conn_Close( Idx, NULL, "Spoofed prefix", true);
                *Closed = true;
                return false;
@@ -316,7 +317,7 @@ Validate_Prefix( CONN_ID Idx, REQUEST *Req, bool *Closed )
 } /* Validate_Prefix */
 
 
-LOCAL bool
+static bool
 Validate_Command( UNUSED CONN_ID Idx, UNUSED REQUEST *Req, bool *Closed )
 {
        assert( Idx >= 0 );
@@ -327,7 +328,7 @@ Validate_Command( UNUSED CONN_ID Idx, UNUSED REQUEST *Req, bool *Closed )
 } /* Validate_Comman */
 
 
-LOCAL bool
+static bool
 Validate_Args( UNUSED CONN_ID Idx, UNUSED REQUEST *Req, bool *Closed )
 {
        assert( Idx >= 0 );
@@ -338,7 +339,7 @@ Validate_Args( UNUSED CONN_ID Idx, UNUSED REQUEST *Req, bool *Closed )
 } /* Validate_Args */
 
 
-LOCAL bool
+static bool
 Handle_Request( CONN_ID Idx, REQUEST *Req )
 {
        /* Client-Request verarbeiten. Bei einem schwerwiegenden Fehler
@@ -354,7 +355,7 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
        assert( Req != NULL );
        assert( Req->command != NULL );
 
-       client = Client_GetFromConn( Idx );
+       client = Conn_GetClient( Idx );
        assert( client != NULL );
 
        /* Statuscode? */
@@ -445,9 +446,12 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
                        Req->argc == 1 ? "parameter" : "parameters",
                        Req->prefix ? "" : " no" );
 
-       if( Client_Type( client ) != CLIENT_SERVER )
-               return IRC_WriteStrClient( client, ERR_UNKNOWNCOMMAND_MSG,
-                               Client_ID( client ), Req->command );
+       if (Client_Type(client) != CLIENT_SERVER) {
+               result = IRC_WriteStrClient(client, ERR_UNKNOWNCOMMAND_MSG,
+                               Client_ID(client), Req->command);
+               Conn_SetPenalty(Idx, 1);
+               return result;
+       }
 
        return true;
 } /* Handle_Request */