Commit c35daaf678677555cf1884d1e5abe4419482975c

Authored by Souheib Khinache
1 parent 685f1984

Organisation, création des librairies et des Makefiles

Showing 305 changed files with 337 additions and 78 deletions   Show diff stats
Makefile 100644 → 100755
Network/.sender.c.swp deleted
No preview for this file type
Network/Makefile 100644 → 100755
@@ -2,29 +2,39 @@ @@ -2,29 +2,39 @@
2 # Makefile pour generer la bibliotheque de fonctions de communication 2 # Makefile pour generer la bibliotheque de fonctions de communication
3 # 3 #
4 4
5 -all : sniffer sender 5 +CC=gcc
  6 +CFLAGS=-W -Wall -Wextra
  7 +CLIBS=ar -rcs
  8 +LIB=libnet.a
  9 +LDIR=../libs/
  10 +LIBS=$(LDIR)libnet.a $(LDIR)libthrd.a
  11 +IDIR=../includes/
  12 +LDFLAGS=-lpthread -lpcap
6 13
7 -sniffer: sniffer.c  
8 - gcc -o sniffer sniffer.c -lpcap  
9 14
10 -sender: sender.c  
11 - gcc -o sender sender.c  
12 15
13 -#all: libnet.a 16 +all: $(LIB)
14 17
15 -#  
16 -# La cible de nettoyage  
17 -# 18 +$(LIB): sender.o sniffer.o tcpserver.o
  19 + rm -f $@
  20 + $(CLIBS) $(LDIR)$@ $^
  21 + ranlib $(LDIR)$@
  22 +
  23 +
  24 +tcpserver.o: tcpserver.c
  25 + $(CC) -o $@ -c $^ -I$(IDIR) $(CFLAGS)
  26 +
  27 +sniffer.o: sniffer.c
  28 + $(CC) -o $@ -c $^ $(CFLAGS)
  29 +
  30 +sender.o: sender.c
  31 + $(CC) -o $@ -c $^ $(CFLAGS)
18 32
19 -#clean:  
20 -# rm -f core *.o libnet.a  
21 33
22 # 34 #
23 -# Les cibles pour la bibliotheque 35 +# La cible de nettoyage
24 # 36 #
25 37
26 -#libnet.o: libnet.c libnet.h 38 +clean:
  39 + rm -f *.o $(LDIR)$(LIB) ../bin/test
27 40
28 -#libcom.a: libnet.o  
29 -# rm -f $@  
30 -# $(CLIB) $@ $+  
Network/libpcap-1.9.0/CHANGES 100644 → 100755
Network/libpcap-1.9.0/CMakeLists.txt 100644 → 100755
Network/libpcap-1.9.0/CONTRIBUTING.md 100644 → 100755
Network/libpcap-1.9.0/CREDITS 100644 → 100755
Network/libpcap-1.9.0/ChmodBPF/StartupParameters.plist 100644 → 100755
Network/libpcap-1.9.0/INSTALL.md 100644 → 100755
Network/libpcap-1.9.0/LICENSE 100644 → 100755
Network/libpcap-1.9.0/Makefile-devel-adds 100644 → 100755
Network/libpcap-1.9.0/Makefile.in 100644 → 100755
Network/libpcap-1.9.0/README.md 100644 → 100755
Network/libpcap-1.9.0/TODO 100644 → 100755
Network/libpcap-1.9.0/VERSION 100644 → 100755
Network/libpcap-1.9.0/Win32/Prj/wpcap.sln 100644 → 100755
Network/libpcap-1.9.0/Win32/Prj/wpcap.vcxproj 100644 → 100755
Network/libpcap-1.9.0/Win32/Prj/wpcap.vcxproj.filters 100644 → 100755
Network/libpcap-1.9.0/aclocal.m4 100644 → 100755
Network/libpcap-1.9.0/arcnet.h 100644 → 100755
Network/libpcap-1.9.0/atmuni31.h 100644 → 100755
Network/libpcap-1.9.0/bpf_dump.c 100644 → 100755
Network/libpcap-1.9.0/bpf_filter.c 100644 → 100755
Network/libpcap-1.9.0/bpf_image.c 100644 → 100755
Network/libpcap-1.9.0/cmake/Modules/FindDAG.cmake 100644 → 100755
Network/libpcap-1.9.0/cmake/Modules/FindFseeko.cmake 100644 → 100755
Network/libpcap-1.9.0/cmake/Modules/FindLFS.cmake 100644 → 100755
Network/libpcap-1.9.0/cmake/Modules/FindPacket.cmake 100644 → 100755
Network/libpcap-1.9.0/cmake/Modules/FindSNF.cmake 100644 → 100755
Network/libpcap-1.9.0/cmake/Modules/FindTC.cmake 100644 → 100755
Network/libpcap-1.9.0/cmake/have_siocglifconf.c 100644 → 100755
Network/libpcap-1.9.0/cmake_uninstall.cmake.in 100644 → 100755
Network/libpcap-1.9.0/cmakeconfig.h.in 100644 → 100755
Network/libpcap-1.9.0/config.h.in 100644 → 100755
Network/libpcap-1.9.0/configure.ac 100644 → 100755
Network/libpcap-1.9.0/diag-control.h 100644 → 100755
Network/libpcap-1.9.0/dlpisubs.c 100644 → 100755
Network/libpcap-1.9.0/dlpisubs.h 100644 → 100755
Network/libpcap-1.9.0/doc/DLT_ALLOCATE_HOWTO.md 100644 → 100755
Network/libpcap-1.9.0/doc/README.Win32 100644 → 100755
Network/libpcap-1.9.0/doc/README.aix 100644 → 100755
Network/libpcap-1.9.0/doc/README.dag 100644 → 100755
Network/libpcap-1.9.0/doc/README.hpux 100644 → 100755
Network/libpcap-1.9.0/doc/README.linux.md 100644 → 100755
Network/libpcap-1.9.0/doc/README.macos 100644 → 100755
Network/libpcap-1.9.0/doc/README.septel 100644 → 100755
Network/libpcap-1.9.0/doc/README.sita 100644 → 100755
Network/libpcap-1.9.0/doc/README.tru64 100644 → 100755
Network/libpcap-1.9.0/etherent.c 100644 → 100755
Network/libpcap-1.9.0/ethertype.h 100644 → 100755
Network/libpcap-1.9.0/extract.h 100644 → 100755
Network/libpcap-1.9.0/fad-getad.c 100644 → 100755
Network/libpcap-1.9.0/fad-gifc.c 100644 → 100755
Network/libpcap-1.9.0/fad-glifc.c 100644 → 100755
Network/libpcap-1.9.0/fmtutils.c 100644 → 100755
Network/libpcap-1.9.0/fmtutils.h 100644 → 100755
Network/libpcap-1.9.0/ftmacros.h 100644 → 100755
Network/libpcap-1.9.0/gencode.c 100644 → 100755
Network/libpcap-1.9.0/gencode.h 100644 → 100755
Network/libpcap-1.9.0/grammar.y 100644 → 100755
Network/libpcap-1.9.0/ieee80211.h 100644 → 100755
Network/libpcap-1.9.0/lbl/os-aix4.h 100644 → 100755
Network/libpcap-1.9.0/lbl/os-aix7.h 100644 → 100755
Network/libpcap-1.9.0/lbl/os-hpux11.h 100644 → 100755
Network/libpcap-1.9.0/lbl/os-osf4.h 100644 → 100755
Network/libpcap-1.9.0/lbl/os-osf5.h 100644 → 100755
Network/libpcap-1.9.0/lbl/os-solaris2.h 100644 → 100755
Network/libpcap-1.9.0/lbl/os-sunos4.h 100644 → 100755
Network/libpcap-1.9.0/lbl/os-ultrix4.h 100644 → 100755
Network/libpcap-1.9.0/libpcap.pc.in 100644 → 100755
Network/libpcap-1.9.0/llc.h 100644 → 100755
Network/libpcap-1.9.0/missing/getopt.c 100644 → 100755
Network/libpcap-1.9.0/missing/getopt.h 100644 → 100755
Network/libpcap-1.9.0/missing/snprintf.c 100644 → 100755
Network/libpcap-1.9.0/missing/strtok_r.c 100644 → 100755
Network/libpcap-1.9.0/missing/win_snprintf.c 100644 → 100755
Network/libpcap-1.9.0/msdos/bin2c.c 100644 → 100755
Network/libpcap-1.9.0/msdos/makefile 100644 → 100755
Network/libpcap-1.9.0/msdos/makefile.dj 100644 → 100755
Network/libpcap-1.9.0/msdos/makefile.wc 100644 → 100755
Network/libpcap-1.9.0/msdos/pkt_rx0.asm 100644 → 100755
Network/libpcap-1.9.0/msdos/pkt_rx1.s 100644 → 100755
Network/libpcap-1.9.0/msdos/pktdrvr.c 100644 → 100755
Network/libpcap-1.9.0/msdos/pktdrvr.h 100644 → 100755
Network/libpcap-1.9.0/msdos/readme.dos 100644 → 100755
Network/libpcap-1.9.0/nametoaddr.c 100644 → 100755
Network/libpcap-1.9.0/nametoaddr.h 100644 → 100755
Network/libpcap-1.9.0/nlpid.h 100644 → 100755
Network/libpcap-1.9.0/optimize.c 100644 → 100755
Network/libpcap-1.9.0/optimize.h 100644 → 100755
Network/libpcap-1.9.0/org.tcpdump.chmod_bpf.plist 100644 → 100755
Network/libpcap-1.9.0/pcap-bpf.c 100644 → 100755
Network/libpcap-1.9.0/pcap-bpf.h 100644 → 100755
Network/libpcap-1.9.0/pcap-bt-linux.c 100644 → 100755
Network/libpcap-1.9.0/pcap-bt-linux.h 100644 → 100755
Network/libpcap-1.9.0/pcap-bt-monitor-linux.c 100644 → 100755
Network/libpcap-1.9.0/pcap-bt-monitor-linux.h 100644 → 100755
Network/libpcap-1.9.0/pcap-common.c 100644 → 100755
Network/libpcap-1.9.0/pcap-common.h 100644 → 100755
Network/libpcap-1.9.0/pcap-config.1 100644 → 100755
Network/libpcap-1.9.0/pcap-config.in 100644 → 100755
Network/libpcap-1.9.0/pcap-dag.c 100644 → 100755
Network/libpcap-1.9.0/pcap-dag.h 100644 → 100755
Network/libpcap-1.9.0/pcap-dbus.c 100644 → 100755
Network/libpcap-1.9.0/pcap-dbus.h 100644 → 100755
Network/libpcap-1.9.0/pcap-dll.rc 100644 → 100755
Network/libpcap-1.9.0/pcap-dlpi.c 100644 → 100755
Network/libpcap-1.9.0/pcap-dos.c 100644 → 100755
Network/libpcap-1.9.0/pcap-dos.h 100644 → 100755
Network/libpcap-1.9.0/pcap-enet.c 100644 → 100755
Network/libpcap-1.9.0/pcap-filter.manmisc.in 100644 → 100755
Network/libpcap-1.9.0/pcap-int.h 100644 → 100755
Network/libpcap-1.9.0/pcap-libdlpi.c 100644 → 100755
Network/libpcap-1.9.0/pcap-linktype.manmisc.in 100644 → 100755
Network/libpcap-1.9.0/pcap-linux.c 100644 → 100755
Network/libpcap-1.9.0/pcap-namedb.h 100644 → 100755
Network/libpcap-1.9.0/pcap-netfilter-linux.c 100644 → 100755
Network/libpcap-1.9.0/pcap-netfilter-linux.h 100644 → 100755
Network/libpcap-1.9.0/pcap-netmap.c 100644 → 100755
Network/libpcap-1.9.0/pcap-netmap.h 100644 → 100755
Network/libpcap-1.9.0/pcap-new.c 100644 → 100755
Network/libpcap-1.9.0/pcap-nit.c 100644 → 100755
Network/libpcap-1.9.0/pcap-npf.c 100644 → 100755
Network/libpcap-1.9.0/pcap-null.c 100644 → 100755
Network/libpcap-1.9.0/pcap-pf.c 100644 → 100755
Network/libpcap-1.9.0/pcap-rdmasniff.c 100644 → 100755
Network/libpcap-1.9.0/pcap-rdmasniff.h 100644 → 100755
Network/libpcap-1.9.0/pcap-rpcap-int.h 100644 → 100755
Network/libpcap-1.9.0/pcap-rpcap.c 100644 → 100755
Network/libpcap-1.9.0/pcap-rpcap.h 100644 → 100755
Network/libpcap-1.9.0/pcap-savefile.manfile.in 100644 → 100755
Network/libpcap-1.9.0/pcap-septel.c 100644 → 100755
Network/libpcap-1.9.0/pcap-septel.h 100644 → 100755
Network/libpcap-1.9.0/pcap-sita.c 100644 → 100755
Network/libpcap-1.9.0/pcap-sita.h 100644 → 100755
Network/libpcap-1.9.0/pcap-sita.html 100644 → 100755
Network/libpcap-1.9.0/pcap-snf.c 100644 → 100755
Network/libpcap-1.9.0/pcap-snf.h 100644 → 100755
Network/libpcap-1.9.0/pcap-snit.c 100644 → 100755
Network/libpcap-1.9.0/pcap-snoop.c 100644 → 100755
Network/libpcap-1.9.0/pcap-tc.c 100644 → 100755
Network/libpcap-1.9.0/pcap-tc.h 100644 → 100755
Network/libpcap-1.9.0/pcap-tstamp.manmisc.in 100644 → 100755
Network/libpcap-1.9.0/pcap-types.h 100644 → 100755
Network/libpcap-1.9.0/pcap-usb-linux.c 100644 → 100755
Network/libpcap-1.9.0/pcap-usb-linux.h 100644 → 100755
Network/libpcap-1.9.0/pcap.3pcap.in 100644 → 100755
Network/libpcap-1.9.0/pcap.c 100644 → 100755
Network/libpcap-1.9.0/pcap.h 100644 → 100755
Network/libpcap-1.9.0/pcap/bluetooth.h 100644 → 100755
Network/libpcap-1.9.0/pcap/bpf.h 100644 → 100755
Network/libpcap-1.9.0/pcap/can_socketcan.h 100644 → 100755
Network/libpcap-1.9.0/pcap/compiler-tests.h 100644 → 100755
Network/libpcap-1.9.0/pcap/dlt.h 100644 → 100755
Network/libpcap-1.9.0/pcap/funcattrs.h 100644 → 100755
Network/libpcap-1.9.0/pcap/ipnet.h 100644 → 100755
Network/libpcap-1.9.0/pcap/namedb.h 100644 → 100755
Network/libpcap-1.9.0/pcap/nflog.h 100644 → 100755
Network/libpcap-1.9.0/pcap/pcap-inttypes.h 100644 → 100755
Network/libpcap-1.9.0/pcap/pcap.h 100644 → 100755
Network/libpcap-1.9.0/pcap/sll.h 100644 → 100755
Network/libpcap-1.9.0/pcap/usb.h 100644 → 100755
Network/libpcap-1.9.0/pcap/vlan.h 100644 → 100755
Network/libpcap-1.9.0/pcap_activate.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_breakloop.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_can_set_rfmon.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_close.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_compile.3pcap.in 100644 → 100755
Network/libpcap-1.9.0/pcap_create.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_datalink.3pcap.in 100644 → 100755
Network/libpcap-1.9.0/pcap_datalink_name_to_val.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_datalink_val_to_name.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_dump.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_dump_close.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_dump_file.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_dump_flush.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_dump_ftell.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_dump_open.3pcap.in 100644 → 100755
Network/libpcap-1.9.0/pcap_file.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_fileno.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_findalldevs.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_freecode.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_get_required_select_timeout.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_get_selectable_fd.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_get_tstamp_precision.3pcap.in 100644 → 100755
Network/libpcap-1.9.0/pcap_geterr.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_inject.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_is_swapped.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_lib_version.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_list_datalinks.3pcap.in 100644 → 100755
Network/libpcap-1.9.0/pcap_list_tstamp_types.3pcap.in 100644 → 100755
Network/libpcap-1.9.0/pcap_lookupdev.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_lookupnet.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_loop.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_major_version.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_next_ex.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_offline_filter.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_open_dead.3pcap.in 100644 → 100755
Network/libpcap-1.9.0/pcap_open_live.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_open_offline.3pcap.in 100644 → 100755
Network/libpcap-1.9.0/pcap_set_buffer_size.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_set_datalink.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_set_immediate_mode.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_set_promisc.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_set_protocol_linux.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_set_rfmon.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_set_snaplen.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_set_timeout.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_set_tstamp_precision.3pcap.in 100644 → 100755
Network/libpcap-1.9.0/pcap_set_tstamp_type.3pcap.in 100644 → 100755
Network/libpcap-1.9.0/pcap_setdirection.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_setfilter.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_setnonblock.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_snapshot.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_stats.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_statustostr.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_strerror.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_tstamp_type_name_to_val.3pcap 100644 → 100755
Network/libpcap-1.9.0/pcap_tstamp_type_val_to_name.3pcap 100644 → 100755
Network/libpcap-1.9.0/portability.h 100644 → 100755
Network/libpcap-1.9.0/ppp.h 100644 → 100755
Network/libpcap-1.9.0/rpcap-protocol.c 100644 → 100755
Network/libpcap-1.9.0/rpcap-protocol.h 100644 → 100755
Network/libpcap-1.9.0/rpcapd/CMakeLists.txt 100644 → 100755
Network/libpcap-1.9.0/rpcapd/Makefile.in 100644 → 100755
Network/libpcap-1.9.0/rpcapd/config_params.h 100644 → 100755
Network/libpcap-1.9.0/rpcapd/daemon.c 100644 → 100755
Network/libpcap-1.9.0/rpcapd/daemon.h 100644 → 100755
Network/libpcap-1.9.0/rpcapd/fileconf.c 100644 → 100755
Network/libpcap-1.9.0/rpcapd/fileconf.h 100644 → 100755
Network/libpcap-1.9.0/rpcapd/log-stderr.c 100644 → 100755
Network/libpcap-1.9.0/rpcapd/log.h 100644 → 100755
Network/libpcap-1.9.0/rpcapd/org.tcpdump.rpcapd.plist 100644 → 100755
Network/libpcap-1.9.0/rpcapd/rpcapd.c 100644 → 100755
Network/libpcap-1.9.0/rpcapd/rpcapd.h 100644 → 100755
Network/libpcap-1.9.0/rpcapd/rpcapd.inetd.conf 100644 → 100755
Network/libpcap-1.9.0/rpcapd/rpcapd.manadmin.in 100644 → 100755
Network/libpcap-1.9.0/rpcapd/rpcapd.rc 100644 → 100755
Network/libpcap-1.9.0/rpcapd/rpcapd.socket 100644 → 100755
Network/libpcap-1.9.0/rpcapd/rpcapd.xinetd.conf 100644 → 100755
Network/libpcap-1.9.0/rpcapd/rpcapd@.service 100644 → 100755
Network/libpcap-1.9.0/rpcapd/win32-svc.c 100644 → 100755
Network/libpcap-1.9.0/rpcapd/win32-svc.h 100644 → 100755
Network/libpcap-1.9.0/savefile.c 100644 → 100755
Network/libpcap-1.9.0/scanner.l 100644 → 100755
Network/libpcap-1.9.0/sf-pcap.c 100644 → 100755
Network/libpcap-1.9.0/sf-pcap.h 100644 → 100755
Network/libpcap-1.9.0/sf-pcapng.c 100644 → 100755
Network/libpcap-1.9.0/sf-pcapng.h 100644 → 100755
Network/libpcap-1.9.0/sockutils.c 100644 → 100755
Network/libpcap-1.9.0/sockutils.h 100644 → 100755
Network/libpcap-1.9.0/sunatmpos.h 100644 → 100755
Network/libpcap-1.9.0/testprogs/CMakeLists.txt 100644 → 100755
Network/libpcap-1.9.0/testprogs/Makefile.in 100644 → 100755
Network/libpcap-1.9.0/testprogs/can_set_rfmon_test.c 100644 → 100755
Network/libpcap-1.9.0/testprogs/capturetest.c 100644 → 100755
Network/libpcap-1.9.0/testprogs/filtertest.c 100644 → 100755
Network/libpcap-1.9.0/testprogs/findalldevstest.c 100644 → 100755
Network/libpcap-1.9.0/testprogs/opentest.c 100644 → 100755
Network/libpcap-1.9.0/testprogs/reactivatetest.c 100644 → 100755
Network/libpcap-1.9.0/testprogs/selpolltest.c 100644 → 100755
Network/libpcap-1.9.0/testprogs/threadsignaltest.c 100644 → 100755
Network/libpcap-1.9.0/testprogs/unix.h 100644 → 100755
Network/libpcap-1.9.0/testprogs/valgrindtest.c 100644 → 100755
Network/libpcap-1.9.0/tests/shb-option-too-long.pcapng 100644 → 100755
No preview for this file type
Network/libpcap-1.9.0/varattrs.h 100644 → 100755
Network/sender deleted
No preview for this file type
Network/sender.c 100644 → 100755
@@ -9,11 +9,9 @@ @@ -9,11 +9,9 @@
9 9
10 10
11 11
12 -int initialized=0;  
13 -int sock_id;  
14 -  
15 int initializeSocketUDP(char* service) 12 int initializeSocketUDP(char* service)
16 { 13 {
  14 + int sock_id;
17 struct addrinfo precisions, *resultat=NULL, *origine; // On stocke dans précisions nos besoins pour le socket, dans resultat l'adresse qui respectera les reqêtes 15 struct addrinfo precisions, *resultat=NULL, *origine; // On stocke dans précisions nos besoins pour le socket, dans resultat l'adresse qui respectera les reqêtes
18 16
19 memset(&precisions, 0, sizeof precisions); 17 memset(&precisions, 0, sizeof precisions);
@@ -50,12 +48,10 @@ int initializeSocketUDP(char* service) @@ -50,12 +48,10 @@ int initializeSocketUDP(char* service)
50 48
51 49
52 freeaddrinfo(origine); 50 freeaddrinfo(origine);
53 -  
54 - initialized=1; 51 + return sock_id;
55 } 52 }
56 53
57 54
58 -  
59 int sendUDPBroadcast(char* message, int port) 55 int sendUDPBroadcast(char* message, int port)
60 { 56 {
61 static struct sockaddr_in addrUDP; 57 static struct sockaddr_in addrUDP;
@@ -65,17 +61,20 @@ int sendUDPBroadcast(char* message, int port) @@ -65,17 +61,20 @@ int sendUDPBroadcast(char* message, int port)
65 struct in_addr tmpadd={0xffffffff}; 61 struct in_addr tmpadd={0xffffffff};
66 addrUDP.sin_addr=tmpadd; 62 addrUDP.sin_addr=tmpadd;
67 63
68 - if(initialized!=1)  
69 - {  
70 - printf("Initialize via Broadcast\n");  
71 - char tmp_str[15];  
72 - sprintf(tmp_str, "%d", port);  
73 - initializeSocketUDP( tmp_str );  
74 - } 64 + char tmp_str[15];
  65 + sprintf(tmp_str, "%d", port);
  66 + int sock_id=initializeSocketUDP( tmp_str );
75 67
76 - if(sendto(sock_id, message, sizeof(message), 0, (struct sockaddr*) &addrUDP, sizeof(addrUDP)) < 0) { fprintf(stderr, "Erreur sendto\n"); return(-1);} 68 + printf("Initialize via Broadcast %d\n", sock_id);
  69 +
  70 + if(sendto(sock_id, message, sizeof(message), 0, (struct sockaddr*) &addrUDP, sizeof(addrUDP)) < 0) { fprintf(stderr, "Erreur sendto\n"); return(-1);}
  71 +
  72 + close(sock_id);
  73 + return 0;
77 } 74 }
78 75
  76 +
  77 +
79 int sendUDPUnicast(char* address, char* message, int port) 78 int sendUDPUnicast(char* address, char* message, int port)
80 { 79 {
81 static struct sockaddr_in addrUDP; 80 static struct sockaddr_in addrUDP;
@@ -84,26 +83,25 @@ int sendUDPUnicast(char* address, char* message, int port) @@ -84,26 +83,25 @@ int sendUDPUnicast(char* address, char* message, int port)
84 83
85 inet_aton(address, &(addrUDP.sin_addr)); // Converti l'écriture string de format a.b.c.d en format Internet 84 inet_aton(address, &(addrUDP.sin_addr)); // Converti l'écriture string de format a.b.c.d en format Internet
86 85
87 -  
88 -  
89 - if(initialized!=1)  
90 - {  
91 - printf("Initialize via Unicast\n");  
92 - char tmp_str[15];  
93 - sprintf(tmp_str, "%d", port);  
94 - initializeSocketUDP( tmp_str );  
95 - } 86 + char tmp_str[15];
  87 + sprintf(tmp_str, "%d", port);
  88 + int sock_id=initializeSocketUDP( tmp_str );
  89 + printf("Initialize via Unicast %d\n", sock_id);
96 90
97 if(sendto(sock_id, message, sizeof(message), 0, (struct sockaddr*) &addrUDP, sizeof(addrUDP)) < 0 ) { fprintf(stderr, "Error sendto\n"); return(-1); } 91 if(sendto(sock_id, message, sizeof(message), 0, (struct sockaddr*) &addrUDP, sizeof(addrUDP)) < 0 ) { fprintf(stderr, "Error sendto\n"); return(-1); }
  92 +
  93 + close(sock_id);
  94 + return 0;
98 } 95 }
99 96
100 97
101 - 98 +/*
102 99
103 int main(void) 100 int main(void)
104 { 101 {
105 sendUDPBroadcast("Broadwesh", 2020); 102 sendUDPBroadcast("Broadwesh", 2020);
106 - sendUDPUnicast("255.255.255.255", "Uniwesh", 2020); 103 + sendUDPUnicast("192.168.43.174", "Uniwesh", 2020);
107 return(1); 104 return(1);
108 - close(sock_id);  
109 } 105 }
  106 +
  107 +*/
Network/sender.o 0 → 100644
No preview for this file type
Network/sniffer deleted
No preview for this file type
Network/sniffer.c 100644 → 100755
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 7
8 #define SZ_DEV 10 8 #define SZ_DEV 10
9 9
10 - 10 +/*
11 // Fonction lors de la detection d'un paquet 11 // Fonction lors de la detection d'un paquet
12 void arp_detect(u_char *args, const struct pcap_pkthdr *header, const u_char *packet) 12 void arp_detect(u_char *args, const struct pcap_pkthdr *header, const u_char *packet)
13 { 13 {
@@ -18,8 +18,8 @@ void arp_detect(u_char *args, const struct pcap_pkthdr *header, const u_char *pa @@ -18,8 +18,8 @@ void arp_detect(u_char *args, const struct pcap_pkthdr *header, const u_char *pa
18 if(num==10) { loop++; num=0; printf("10 paquets ARP ont été reçus !\n");} 18 if(num==10) { loop++; num=0; printf("10 paquets ARP ont été reçus !\n");}
19 } 19 }
20 20
21 -  
22 - 21 +*/
  22 +/*
23 23
24 int main(int argc, char *argv[]) 24 int main(int argc, char *argv[])
25 { 25 {
@@ -55,10 +55,10 @@ int main(int argc, char *argv[]) @@ -55,10 +55,10 @@ int main(int argc, char *argv[])
55 printf("Device: %s\n", dev); 55 printf("Device: %s\n", dev);
56 56
57 57
58 - // Permet d'obtenir l'adresse ip de l'interface demandée 58 + // Permet d'obtenir l'adresse ip de l'interface demandée*/
59 /* pcap permet de lister les interfaces et obtenir les adresses ip de ces dernières 59 /* pcap permet de lister les interfaces et obtenir les adresses ip de ces dernières
60 * On utilise la fonction pcap_findalldevs 60 * On utilise la fonction pcap_findalldevs
61 - */ 61 + *//*
62 62
63 pcap_if_t* interfaces; 63 pcap_if_t* interfaces;
64 if(pcap_findalldevs(&interfaces, buf_err)!=0) { printf("%s\n", buf_err); return(EXIT_FAILURE); } 64 if(pcap_findalldevs(&interfaces, buf_err)!=0) { printf("%s\n", buf_err); return(EXIT_FAILURE); }
@@ -142,3 +142,5 @@ int main(int argc, char *argv[]) @@ -142,3 +142,5 @@ int main(int argc, char *argv[])
142 142
143 return(0); 143 return(0);
144 } 144 }
  145 +
  146 +*/
Network/sniffer.o 0 → 100644
No preview for this file type
Network/tcpserver.c 0 → 100644
@@ -0,0 +1,78 @@ @@ -0,0 +1,78 @@
  1 +#include <sys/types.h>
  2 +#include <sys/socket.h>
  3 +#include <stdio.h>
  4 +#include <stdlib.h>
  5 +#include <unistd.h>
  6 +#include <string.h>
  7 +#include <netdb.h>
  8 +#include <arpa/inet.h>
  9 +#include "libthrd.h"
  10 +
  11 +
  12 +
  13 +int initialisationServeur(char* service)
  14 +{
  15 + int sock_fd;
  16 +
  17 + struct addrinfo precisions, *resultat=NULL, *origine; // On stocke dans précisions nos besoins pour le socket, dans resultat l'adresse qui respectera les reqêtes
  18 +
  19 + memset(&precisions, 0, sizeof precisions);
  20 + precisions.ai_family = AF_UNSPEC;
  21 + precisions.ai_socktype = SOCK_STREAM;
  22 + precisions.ai_flags = AI_PASSIVE;
  23 +
  24 + if(getaddrinfo(NULL, service, &precisions, &origine)<0) { fprintf(stderr, "Erreur getaddrinfo\n"); return(-1); }
  25 +
  26 + int n=0;
  27 +
  28 + for(struct addrinfo* i=origine; i!=NULL && resultat==NULL; i=i->ai_next)
  29 + {
  30 + printf("%d - ", n);
  31 + if(i->ai_family==AF_INET)
  32 + {
  33 + resultat=i;
  34 + printf("Test : %d", origine->ai_addrlen);
  35 + }
  36 +
  37 + printf("\n");
  38 + n++;
  39 + }
  40 +
  41 + struct sockaddr_in* test=(struct sockaddr_in*)(resultat->ai_addr);
  42 + printf("Addr : %x\n", test->sin_addr.s_addr);
  43 + if((sock_fd=socket(resultat->ai_family, resultat->ai_socktype, resultat->ai_protocol))<0) { fprintf(stderr, "Erreur socket\n"); return(-1); }
  44 +
  45 + int val=1;
  46 +
  47 + if(setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR|SO_BROADCAST, &val, sizeof(val))<0) { fprintf(stderr, "Erreur setsockopt\n"); return(-1); }
  48 +
  49 +
  50 +
  51 + if(bind(sock_fd, resultat->ai_addr, resultat->ai_addrlen)) { fprintf(stderr, "Erreur bind\n"); return(-1); }
  52 +
  53 + if(listen(sock_fd, 20) < 0) { fprintf(stderr, "Error listen server socket\n"); return (-1); }
  54 +
  55 + freeaddrinfo(origine);
  56 +
  57 + return sock_fd;
  58 +}
  59 +
  60 +
  61 +
  62 +
  63 +int boucleServeur(int socket, void(* fctConnex)(int))
  64 +{
  65 + int sock_dial;
  66 +
  67 + printf("------- Début boucle serveur TCP -------\n\n");
  68 +
  69 + while(1)
  70 + {
  71 + printf("-- boucle --\n");
  72 + if((sock_dial=accept(socket, NULL, NULL)) < 0){ fprintf(stderr, "Error accept dialogue\n"); return -1; }
  73 + printf("Dialogue ACCEPTED\n");
  74 +
  75 + lanceThread((void*)fctConnex, (void*)&sock_dial, sizeof(sock_dial));
  76 + }
  77 +}
  78 +
Network/tcpserver.o 0 → 100644
No preview for this file type
README.md 100644 → 100755
Sioux/client
No preview for this file type
Sioux/client.c 100644 → 100755
@@ -53,16 +53,25 @@ int connexionServeur(char* host, char* service) @@ -53,16 +53,25 @@ int connexionServeur(char* host, char* service)
53 53
54 int main(void) 54 int main(void)
55 { 55 {
  56 +
  57 + char buffer[100];
56 int sock_fd = connexionServeur("localhost", "2020"); 58 int sock_fd = connexionServeur("localhost", "2020");
57 if(sock_fd<0) { fprintf(stderr, "Erreur connexionServeur\n"); return(-1); } 59 if(sock_fd<0) { fprintf(stderr, "Erreur connexionServeur\n"); return(-1); }
58 60
59 FILE* sockfd_stream = fdopen(sock_fd, "a+"); 61 FILE* sockfd_stream = fdopen(sock_fd, "a+");
60 62
61 - while(1) 63 + printf("State sock : %p\n", sockfd_stream);
  64 +
  65 + for(int i=0; i<10; i++)
62 { 66 {
63 - fprintf(sockfd_stream, "YES !!! ");  
64 - } 67 + fprintf(sockfd_stream, "YES !!!\n");
  68 +
  69 + //fprintf(sockfd_stream, "EXIT\n");
65 70
  71 + fgets(buffer, 100, sockfd_stream);
  72 + }
  73 + fprintf(sockfd_stream, "EXIT\n");
  74 + fclose(sockfd_stream);
66 shutdown(sock_fd, SHUT_RDWR); 75 shutdown(sock_fd, SHUT_RDWR);
67 76
68 77
Sioux/sioux
No preview for this file type
Sioux/sioux.c 100644 → 100755
@@ -9,10 +9,7 @@ @@ -9,10 +9,7 @@
9 #include <arpa/inet.h> 9 #include <arpa/inet.h>
10 #include <pthread.h> 10 #include <pthread.h>
11 11
12 -#define BUFF_SIZE 100  
13 -  
14 -  
15 - 12 +#define BUFF_SIZE 1000
16 13
17 14
18 int initialisationServeur(char* service) 15 int initialisationServeur(char* service)
@@ -62,8 +59,10 @@ int initialisationServeur(char* service) @@ -62,8 +59,10 @@ int initialisationServeur(char* service)
62 return sock_fd; 59 return sock_fd;
63 } 60 }
64 61
  62 +
65 void* reponseConnexion(void* sock) 63 void* reponseConnexion(void* sock)
66 { 64 {
  65 +
67 printf("Connected\n"); 66 printf("Connected\n");
68 char buffer[BUFF_SIZE]; 67 char buffer[BUFF_SIZE];
69 68
@@ -81,10 +80,11 @@ void* reponseConnexion(void* sock) @@ -81,10 +80,11 @@ void* reponseConnexion(void* sock)
81 fprintf(sockdial_stream, "Ceci est une réponse du serveur TCP.\n"); 80 fprintf(sockdial_stream, "Ceci est une réponse du serveur TCP.\n");
82 81
83 } 82 }
84 - 83 +
  84 + strcpy(buffer, "START");
85 printf("Fin de la connexion\n"); 85 printf("Fin de la connexion\n");
86 fclose(sockdial_stream); 86 fclose(sockdial_stream);
87 - 87 + pthread_exit(NULL);
88 } 88 }
89 89
90 90
@@ -116,6 +116,7 @@ int boucleServeur(int socket, void(* fctConnex)(int)) @@ -116,6 +116,7 @@ int boucleServeur(int socket, void(* fctConnex)(int))
116 } 116 }
117 } 117 }
118 118
  119 +
119 void argPortParsing(int argc, char* argv[], char* port) 120 void argPortParsing(int argc, char* argv[], char* port)
120 { 121 {
121 struct option port_arg={"port", 1, NULL, 'p'}; 122 struct option port_arg={"port", 1, NULL, 'p'};
@@ -131,10 +132,11 @@ void argPortParsing(int argc, char* argv[], char* port) @@ -131,10 +132,11 @@ void argPortParsing(int argc, char* argv[], char* port)
131 } 132 }
132 else 133 else
133 { 134 {
134 - printf("La syntaxe doit être ./sioux -p <port> ou ./sioux --port <port>"); 135 + printf("La syntaxe doit être de la forme ./sioux -p <port> ou ./sioux --port <port>\n\n");
135 } 136 }
136 } 137 }
137 138
  139 +
138 int main(int argc, char* argv[]) 140 int main(int argc, char* argv[])
139 { 141 {
140 char port[10]="80"; 142 char port[10]="80";
@@ -147,6 +149,7 @@ int main(int argc, char* argv[]) @@ -147,6 +149,7 @@ int main(int argc, char* argv[])
147 149
148 150
149 boucleServeur(sock_fd, (void*)&reponseConnexion); 151 boucleServeur(sock_fd, (void*)&reponseConnexion);
  152 +
150 return 0; 153 return 0;
151 } 154 }
152 155
Sioux/sioux.o deleted
No preview for this file type
Sioux/threadsSocket.c 100644 → 100755
Tangible/Makefile 100644 → 100755
Tangible/ethernet.c 100644 → 100755
Tangible/ethernet.o 100644 → 100755
No preview for this file type
Tangible/iic.c 100644 → 100755
Tangible/iic.h 100644 → 100755
Tangible/iic.o 100644 → 100755
No preview for this file type
Tangible/serial.c 100644 → 100755
Tangible/serial.h 100644 → 100755
Tangible/serial.o 100644 → 100755
No preview for this file type
Tangible/socket.o 100644 → 100755
No preview for this file type
Tangible/tangibleInterface.c 100644 → 100755
Tangible/tangibleInterface.hex 100644 → 100755
Tangible/tangibleInterface.o 100644 → 100755
No preview for this file type
Tangible/w5100.o 100644 → 100755
No preview for this file type
Threads/Makefile 0 → 100755
@@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
  1 +#
  2 +# Makefile pour generer la bibliotheque de fonctions de communication
  3 +#
  4 +
  5 +CC=gcc
  6 +CFLAGS=-W -Wall -Wextra
  7 +CLIBS=ar -rcs
  8 +LIB=libthrd.a
  9 +LDIR=../libs/
  10 +IDIR=../includes/
  11 +LDFLAGS=-lpthread
  12 +
  13 +
  14 +
  15 +all: $(LIB)
  16 +
  17 +$(LIB): threadSocket.o
  18 + rm -f $@
  19 + $(CLIBS) $(LDIR)$@ $^
  20 + ranlib $(LDIR)$@
  21 + rm -f *.o
  22 +
  23 +threadSocket.o: threadSocket.c
  24 + $(CC) -o $@ -c $^ $(CFLAGS) $(LDFLAGS)
  25 +
  26 +
  27 +#
  28 +# La cible de nettoyage
  29 +#
  30 +
  31 +clean:
  32 + rm -f *.o $(LDIR)$(LIB)
  33 +
  34 +
Threads/threadSocket.c 0 → 100644
@@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
  1 +#include <stdio.h>
  2 +#include <stdlib.h>
  3 +#include <pthread.h>
  4 +#include <string.h>
  5 +#include <unistd.h>
  6 +
  7 +#define BUFF_SIZE 1000
  8 +
  9 +void* reponseConnexion(void* sock)
  10 +{
  11 +
  12 + printf("Connected\n");
  13 + char buffer[BUFF_SIZE];
  14 +
  15 + FILE* sockdial_stream = fdopen(*((int*)(sock)), "a+");
  16 +
  17 + printf("Sock : %d // Stream : %p \n", *((int*)(sock)), sockdial_stream);
  18 +
  19 + while(strcmp(buffer, "EXIT\n")!=0)
  20 + {
  21 + printf("WAIT\n");
  22 + fgets(buffer, BUFF_SIZE, sockdial_stream);
  23 +
  24 + printf("Le message reçu : %s", buffer);
  25 +
  26 + fprintf(sockdial_stream, "Ceci est une réponse du serveur TCP.\n");
  27 +
  28 + }
  29 +
  30 + strcpy(buffer, "START");
  31 + printf("Fin de la connexion\n");
  32 + fclose(sockdial_stream);
  33 + pthread_exit(NULL);
  34 +}
  35 +
  36 +
  37 +int lanceThread(void(* fonction) (void *), void* arg, int size)
  38 +{
  39 + pthread_t thr_id;
  40 + printf("%d \n",size);
  41 + if(pthread_create(&thr_id, NULL, (void*)fonction, arg )!=0) { fprintf(stderr, "Le thread n'a pas pu être créé.\n"); return -1; }
  42 +
  43 + pthread_detach(thr_id);
  44 +
  45 + return 0;
  46 +}
  47 +
  48 +
  49 +
Threads/threadsSocket.c deleted
@@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
1 -#include <stdio.h>  
2 -#include <stdlib.h>  
3 -#include <pthread.h>  
4 -  
5 -  
6 -int lanceThread(void(* fonction) (void *), void* arg, int size)  
7 -{  
8 - pthread_t thr_id;  
9 -  
10 - if(pthread_create(&thr_id, NULL, fonction, arg)!=0) { fprintf(stderr, "Le thread n'a pas pu être créé.\n"); return -1; }  
11 -  
12 - pthread_detach(thr_id);  
13 -  
14 -  
15 -  
16 -}  
17 -  
18 -int main(void)  
19 -{  
20 -  
21 -}  
bin/Makefile 0 → 100644
@@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
  1 +
  2 +CC=gcc
  3 +CFLAGS=-W -Wall -Wextra
  4 +CLIBS=ar -rcs
  5 +LIB=libnet.a
  6 +LDIR=../libs/
  7 +LIBS=$(LDIR)libnet.a $(LDIR)libthrd.a
  8 +IDIR=../includes/
  9 +LDFLAGS=-lpthread -lpcap
  10 +
  11 +
  12 +
  13 +all: test
  14 +
  15 +test: test.c
  16 + cd ../Threads/ && make
  17 + cd ../Network/ && make
  18 + $(CC) -o $@ $< -I$(IDIR) $(LDIR)libnet.a $(LDIR)libthrd.a $(CFLAGS) $(LDFLAGS)
  19 + rm -f *.o
  20 +
  21 +#
  22 +# La cible de nettoyage
  23 +#
  24 +
  25 +clean:
  26 + cd ../Threads/ && make clean
  27 + cd ../Network/ && make clean
  28 + rm -f *.o test
  29 +
bin/test 0 → 100755
No preview for this file type
bin/test.c 0 → 100644
@@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
  1 +#include <stdlib.h>
  2 +#include <stdio.h>
  3 +#include <getopt.h>
  4 +#include <string.h>
  5 +#include "libnet.h"
  6 +
  7 +
  8 +void argPortParsing(int argc, char* argv[], char* port)
  9 +{
  10 + struct option port_arg={"port", 1, NULL, 'p'};
  11 + char opt;
  12 + int longindex;
  13 +
  14 + while( (opt=getopt_long(argc, argv, "p:", &port_arg, &longindex)) !='p' && opt!=-1) {}
  15 +
  16 + if(opt=='p')
  17 + {
  18 + strcpy(port, optarg);
  19 + printf("%s\n", optarg);
  20 + }
  21 + else
  22 + {
  23 + printf("La syntaxe doit être de la forme %s -p <port> ou %s --port <port>\n\n", argv[0], argv[0]);
  24 + }
  25 +}
  26 +
  27 +
  28 +int main(int argc, char* argv[])
  29 +{
  30 + char port[10]="80";
  31 + argPortParsing(argc, argv, port);
  32 +
  33 +
  34 + int sock_fd=initialisationServeur(port);
  35 +
  36 + if( sock_fd==-1 ) { fprintf(stderr, "Initialisation du serveur impossible\n"); return -1; }
  37 +
  38 +
  39 + boucleServeur(sock_fd, (void*)&reponseConnexion);
  40 +
  41 +
  42 + sendUDPBroadcast("BroadWesh", 2020);
  43 +
  44 + return 0;
  45 +}
  46 +
includes/libnet.h 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +#ifndef __LIBNET_H__
  2 +#define __LIBNET_H__
  3 +
  4 +int boucleServeur(int socket, void(* fctConnex)(int));
  5 +int lanceThread(void(* fonction) (void *), void* arg, int size);
  6 +void* reponseConnexion(void* sock);
  7 +int initialisationServeur(char* service);
  8 +int initializeSocketUDP(char* service);
  9 +int sendUDPBroadcast(char* message, int port);
  10 +int sendUDPUnicast(char* address, char* message, int port);
  11 +
  12 +
  13 +#endif
includes/libthrd.h 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +#ifndef __LIBTHRD_H__
  2 +#define __LIBTHRD_H__
  3 +
  4 +void* reponseConnexion(void* sock);
  5 +
  6 +int lanceThread(void(* fonction) (void *), void* arg, int size);
  7 +
  8 +
  9 +#endif
libs/libnet.a 0 → 100644
No preview for this file type
libs/libthrd.a 0 → 100644
No preview for this file type