35 lines
725 B
C
35 lines
725 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 == 3) {
|
||
port = atoi(argv[2]);
|
||
}
|
||
else if (argc != 2) {
|
||
fprintf(stderr, "Utilisation : %s adresse [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.1/28") != 0) {
|
||
fprintf(stderr, "Erreur lors de l’exécution du script de configuration de l’interface.\n");
|
||
return 1;
|
||
}
|
||
|
||
int ext = ext_in(argv[1], port);
|
||
copy(tun, ext);
|
||
|
||
return 0;
|
||
}
|