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-out.c

35 lines
710 B
C
Raw Permalink 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
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;
}
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.10/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_out(port);
copy(ext, tun);
2019-11-06 07:36:00 +01:00
2019-10-25 23:53:43 +02:00
return 0;
}