35 lines
710 B
C
35 lines
710 B
C
#include "extremite.h"
|
||
#include "iftun.h"
|
||
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <unistd.h>
|
||
#include <sys/types.h>
|
||
|
||
|
||
int main(int argc, char *argv[argc]) {
|
||
int port = 123;
|
||
if (argc == 2) {
|
||
port = atoi(argv[1]);
|
||
}
|
||
else if (argc != 1) {
|
||
fprintf(stderr, "Utilisation : %s [port]\n", argv[0]);
|
||
return 1;
|
||
}
|
||
|
||
if (getuid() != 0) {
|
||
fprintf(stderr, "%s doit être lancé en tant que superutilisateur.\n", argv[0]);
|
||
return 1;
|
||
}
|
||
int tun = tun_alloc("tun0");
|
||
if (system("./configure-tun.sh tun0 172.16.2.10/28") != 0) {
|
||
fprintf(stderr, "Erreur lors de l’exécution du script de configuration de l’interface.\n");
|
||
return 1;
|
||
}
|
||
|
||
int ext = ext_out(port);
|
||
copy(ext, tun);
|
||
|
||
return 0;
|
||
}
|