-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.c
More file actions
41 lines (31 loc) · 1.01 KB
/
check.c
File metadata and controls
41 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//Wiktor Pilarczyk 308533
#include "header.h"
void error_handle(const char *str, char *err){
fprintf(stderr, str, err);
exit(EXIT_FAILURE);
}
int Select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout){
int rv = select(nfds, readfds, writefds, exceptfds, timeout);
if(rv < 0)
error_handle("Select error: %s\n", strerror(errno));
return rv;
}
int Socket(int domain, int type, int protocol){
int rv = socket(domain, type, protocol);
if (rv < 0)
error_handle("Socket error %s\n", strerror(errno));
return rv;
}
int Setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen){
int rv = setsockopt(sockfd, level, optname, optval, optlen);
if (rv < 0)
error_handle("Setsockopt error %s\n", strerror(errno));
return rv;
}
int belong_to_table(int n, uint32_t ip, struct connected *conn){
for(int g = 0; g < n; g++){
if(conn[g].my_ip == ip)
return g;
}
return -1;
}