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
2019-11-13 11:10:05 +01:00

35 lines
725 B
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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 lexécution du script de configuration de linterface.\n");
return 1;
}
int ext = ext_in(argv[1], port);
copy(tun, ext);
return 0;
}