This repository has been archived on 2019-11-14. You can view files and clone it, but cannot push or open issues or pull requests.
rip-vm2/partage/test/ext-in.c

35 lines
725 B
C
Raw Normal View History

2019-10-25 23:53:43 +02:00
#include "extremite.h"
2019-11-06 07:36:00 +01:00
#include "iftun.h"
2019-10-25 23:53:43 +02:00
#include <stdio.h>
#include <stdlib.h>
2019-11-06 07:36:00 +01:00
#include <unistd.h>
#include <sys/types.h>
2019-10-25 23:53:43 +02:00
2019-11-06 07:36:00 +01:00
int main(int argc, char *argv[argc]) {
2019-10-25 23:53:43 +02:00
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;
}
2019-11-06 07:36:00 +01:00
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 lexécution du script de configuration de linterface.\n");
return 1;
}
2019-11-13 11:10:05 +01:00
int ext = ext_in(argv[1], port);
copy(tun, ext);
2019-11-06 07:36:00 +01:00
2019-10-25 23:53:43 +02:00
return 0;
}