Commit 16d49651cb1277e13a73d973f3ca8b82bf99e2c4
1 parent
17f3ff42
add : interface creation
Showing
1 changed file
with
13 additions
and
1 deletions
Show diff stats
libnet.c
@@ -16,6 +16,8 @@ | @@ -16,6 +16,8 @@ | ||
16 | #include <linux/if.h> | 16 | #include <linux/if.h> |
17 | #include <linux/if_tun.h> | 17 | #include <linux/if_tun.h> |
18 | 18 | ||
19 | +#include <stdio.h> | ||
20 | + | ||
19 | #include "libnet.h" | 21 | #include "libnet.h" |
20 | 22 | ||
21 | /**** Constantes ****/ | 23 | /**** Constantes ****/ |
@@ -38,16 +40,26 @@ int fd,erreur; | @@ -38,16 +40,26 @@ int fd,erreur; | ||
38 | /* Ouverture du peripherique principal */ | 40 | /* Ouverture du peripherique principal */ |
39 | if((fd=open(TAP_PRINCIPAL,O_RDWR))<0) return fd; | 41 | if((fd=open(TAP_PRINCIPAL,O_RDWR))<0) return fd; |
40 | 42 | ||
43 | +printf("Je suis ici\n"); | ||
44 | + | ||
41 | /* Preparation de la structure */ | 45 | /* Preparation de la structure */ |
42 | memset(&interface,0,sizeof(interface)); | 46 | memset(&interface,0,sizeof(interface)); |
43 | interface.ifr_flags=IFF_TAP|IFF_NO_PI; | 47 | interface.ifr_flags=IFF_TAP|IFF_NO_PI; |
44 | if(nom!=NULL) strncpy(interface.ifr_name,nom,IFNAMSIZ); | 48 | if(nom!=NULL) strncpy(interface.ifr_name,nom,IFNAMSIZ); |
45 | 49 | ||
50 | +printf("Je suis la\n"); | ||
51 | + | ||
46 | /* Creation de l'interface */ | 52 | /* Creation de l'interface */ |
47 | if((erreur=ioctl(fd,TUNSETIFF,(void *)&interface))<0){ close(fd); return erreur; } | 53 | if((erreur=ioctl(fd,TUNSETIFF,(void *)&interface))<0){ close(fd); return erreur; } |
48 | 54 | ||
55 | +printf("Je suis ici bas %s\n", interface.ifr_name); | ||
56 | + | ||
49 | /* Recuperation du nom de l'interface */ | 57 | /* Recuperation du nom de l'interface */ |
50 | -if(nom!=NULL) strcpy(nom,interface.ifr_name); | 58 | +//if(nom!=NULL) strncpy(nom,interface.ifr_name, IFNAMSIZ); |
59 | +//MAIS PK ?? | ||
60 | + | ||
61 | + | ||
62 | +printf("La je suis\n"); | ||
51 | 63 | ||
52 | return fd; | 64 | return fd; |
53 | } | 65 | } |