1
0
Fork 0
forked from ahurac/dotfiles

first-free-port : remaniement de la fonction is_valid_tcp_port

This commit is contained in:
Hippolyte Chauvin 2023-12-02 00:11:42 +01:00
parent 057ebd1b1a
commit bf4dd08139

View file

@ -5,7 +5,6 @@
#include <string.h>
#define MIN_TCP_PORT 1
#define MAX_TCP_PORT 65534
#define TCP_TABLE "/proc/net/tcp"
#define TCP_TABLE_LINE_LENGTH 151
#define LOCALHOST_HEX "0100007F"
@ -68,8 +67,8 @@ static unsigned char is_port_available(const unsigned short port, const unsigned
return listening_ports[i] == 0;
}
static unsigned char is_valid_tcp_port(unsigned short tcp_port) {
return tcp_port >= MIN_TCP_PORT && tcp_port <= MAX_TCP_PORT;
static inline unsigned char is_valid_tcp_port(const unsigned short tcp_port) {
return tcp_port >= MIN_TCP_PORT;
}
int main(int argc, char *argv[]) {