muhstik

- irc flooding solution
git clone git://git.acid.vegas/muhstik.git
Log | Files | Refs | Archive | README

net.h (1633B)

      1 /* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr>       */
      2 /*                        2009-2011, Leon Kaiser <literalka@gnaa.eu>    */
      3 /*                                                                      */
      4 /* This program is free software; you can redistribute it and/or        */
      5 /* modify it under the terms of the GNU Library General Public License  */
      6 /* as published by the Free Software Foundation; either version 2       */
      7 /* of the License, or (at your option) any later version.               */
      8 /*                                                                      */
      9 /* This program is distributed in the hope that it will be useful,      */
     10 /* but WITHOUT ANY WARRANTY; without even the implied warranty of       */
     11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        */
     12 /* GNU Library General Public License for more details.                 */
     13 
     14 #ifndef NETWORK_H
     15 #define NETWORK_H
     16 
     17 #include <sys/types.h>
     18 #include <sys/socket.h>
     19 #include <netinet/in.h>
     20 #include <arpa/inet.h>
     21 #include <netdb.h>
     22 #include <errno.h>
     23 
     24 #define max(n1, n2)\
     25 (n1 > n2 ? n1 : n2)
     26 
     27 typedef struct
     28 {
     29      struct addrinfo *ip6_hostent;
     30 } netstore;
     31 
     32 void host2ip (char *s, char *host, int size);
     33 int resolve (char *host, struct in_addr *addr);
     34 netstore *net_store_new ();
     35 void net_store_destroy (netstore *ns);
     36 void net_set_socket_options (int sock);
     37 void set_nonblocking (int sock);
     38 int net_bind (netstore *ns, int sock);
     39 int net_resolve (netstore *ns, char *hostname, unsigned short port);
     40 int net_connect (netstore *ns, int *sock, char *vhost);
     41 void send_sock (int sock, const char *fmt, ...);
     42 
     43 #endif