Topic: [Solved] Command restrict for IP
Hi
I need help with this code, cannot seem to find the errors.
static int _handle_host_command(t_connection * c, char const * text)
{
unsigned int i;
unsigned int slvl;
unsigned int check;
t_message * message;
t_connection * user;
char const * channel;
struct in_addr addr;
unsigned int ip;
ip = conn_get_addr(c);
ip = ntohl(addr.s_addr);
//check if users ip matches 192.168.x.x
if (ip & 0xFFFF0000 == 0xC0A80000)
{
message_send_text(c,message_type_error,c,"Command is reserved for local clients only.");
return 0;
}
}
Example:
If user types /host, and the users IP doesn't match 192.168.x.x an error code should be sent saying "Command is reserved for local clients only." But if the IP matches the 192.168.x.x - no error should be displayed and continue using the correct output of the command.