initial version of hashmap works
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#ifndef __HASHMAP_C__
|
||||
#define __HASHMAP_C__
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#define HASHMAP_MAX_ITEMS 10000
|
||||
#define HASHMAP_MAX_CLIENTS 10000
|
||||
|
||||
struct hashmap {
|
||||
int sockfd;
|
||||
@@ -11,6 +12,8 @@ struct hashmap {
|
||||
};
|
||||
|
||||
int hash(int sockfd);
|
||||
void hm_init(struct hashmap *map);
|
||||
void hm_insert(struct hashmap *map, int sockfd, struct sockaddr_storage *sas);
|
||||
struct hashmap *hm_lookup(struct hashmap *map, int sockfd);
|
||||
|
||||
#endif
|
||||
@@ -26,6 +26,5 @@ void epoll_ctl_add(int epfd, int sockfd, uint32_t events);
|
||||
void epoll_ctl_del(int epfd, int sockfd);
|
||||
void setnonblocking(int sockfd);
|
||||
int handle_new_client(int sockfd, struct sockaddr_storage *their_sa, socklen_t *theirsa_size);
|
||||
void print_client_ip(struct sockaddr_in *sin);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,5 +12,6 @@
|
||||
|
||||
// print every IPs of a hostname
|
||||
void print_ips(const char *hostname, const char *port);
|
||||
void get_client_ip(struct sockaddr_storage *sa, char *ip);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user