GNU libmicrohttpd 0.9.77
|
counting of connections per IP More...
Go to the source code of this file.
Functions | |
static struct MHD_Daemon * | get_master (struct MHD_Daemon *daemon) |
static void | MHD_ip_count_lock (struct MHD_Daemon *daemon) |
static void | MHD_ip_count_unlock (struct MHD_Daemon *daemon) |
static int | MHD_ip_addr_compare (const void *a1, const void *a2) |
static int | MHD_ip_addr_to_key (const struct sockaddr *addr, socklen_t addrlen, struct MHD_IPCount *key) |
int | MHD_ip_limit_add (struct MHD_Daemon *daemon, const struct sockaddr *addr, socklen_t addrlen) |
void | MHD_ip_limit_del (struct MHD_Daemon *daemon, const struct sockaddr *addr, socklen_t addrlen) |
counting of connections per IP
Definition in file daemon_ip_limit.c.
|
static |
Trace up to and return master daemon. If the supplied daemon is a master, then return the daemon itself.
daemon | handle to a daemon |
Definition at line 76 of file daemon_ip_limit.c.
References MHD_Daemon::master, and NULL.
Referenced by MHD_ip_limit_add(), and MHD_ip_limit_del().
|
static |
Tree comparison function for IP addresses (supplied to tsearch() family). We compare everything in the struct up through the beginning of the 'count' field.
a1 | first address to compare |
a2 | second address to compare |
Definition at line 118 of file daemon_ip_limit.c.
Referenced by MHD_ip_limit_add(), and MHD_ip_limit_del().
|
static |
Parse address and initialize key using the address.
addr | address to parse |
addrlen | number of bytes in addr |
key | where to store the parsed address |
Definition at line 137 of file daemon_ip_limit.c.
References MHD_NO, and MHD_YES.
Referenced by MHD_ip_limit_add(), and MHD_ip_limit_del().
|
static |
Lock shared structure for IP connection counts and connection DLLs.
daemon | handle to daemon where lock is |
Definition at line 90 of file daemon_ip_limit.c.
References MHD_mutex_lock_chk_, and MHD_Daemon::per_ip_connection_mutex.
Referenced by MHD_ip_limit_add(), and MHD_ip_limit_del().
|
static |
Unlock shared structure for IP connection counts and connection DLLs.
daemon | handle to daemon where lock is |
Definition at line 102 of file daemon_ip_limit.c.
References MHD_mutex_unlock_chk_, and MHD_Daemon::per_ip_connection_mutex.
Referenced by MHD_ip_limit_add(), and MHD_ip_limit_del().
int MHD_ip_limit_add | ( | struct MHD_Daemon * | daemon, |
const struct sockaddr * | addr, | ||
socklen_t | addrlen | ||
) |
Check if IP address is over its limit in terms of the number of allowed concurrent connections. If the IP is still allowed, increments the connection counter.
daemon | handle to daemon where connection counts are tracked |
addr | address to add (or increment counter) |
addrlen | number of bytes in addr |
Definition at line 188 of file daemon_ip_limit.c.
References _, get_master(), MHD_Daemon::ip_connection_limit, MHD_ip_addr_compare(), MHD_ip_addr_to_key(), MHD_ip_count_lock(), MHD_ip_count_unlock(), MHD_NO, MHD_YES, NULL, MHD_Daemon::per_ip_connection_count, and tsearch().
Referenced by internal_add_connection().
void MHD_ip_limit_del | ( | struct MHD_Daemon * | daemon, |
const struct sockaddr * | addr, | ||
socklen_t | addrlen | ||
) |
Decrement connection count for IP address, removing from table count reaches 0.
daemon | handle to daemon where connection counts are tracked |
addr | address to remove (or decrement counter) |
addrlen | number of bytes in addr |
Definition at line 255 of file daemon_ip_limit.c.
References _, get_master(), MHD_Daemon::ip_connection_limit, MHD_ip_addr_compare(), MHD_ip_addr_to_key(), MHD_ip_count_lock(), MHD_ip_count_unlock(), MHD_NO, MHD_PANIC, NULL, MHD_Daemon::per_ip_connection_count, tdelete(), and tfind().
Referenced by internal_add_connection(), and MHD_connection_cleanup_().