Commit 0007fb16cd2bb0fdb3a67ec5640b8802fd854478

Authored by pifou
2 parents bb11e508 c9ce1fd2

Merge branch 'master' of https://archives.plil.fr/amoreau/skam_projet

Showing 306 changed files with 369 additions and 148 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,44 @@ @@ -2,29 +2,44 @@
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 +<<<<<<< HEAD
  22 + ranlib $(LDIR)$@
  23 + rm -f *.o
  24 +=======
  25 + ranlib $(LDIR)$@
  26 +>>>>>>> 52d8a1eaf954b611aaf0861144b440a15f7c517d
  27 +
  28 +
  29 +tcpserver.o: tcpserver.c
  30 + $(CC) -o $@ -c $^ -I$(IDIR) $(CFLAGS)
  31 +
  32 +sniffer.o: sniffer.c
  33 + $(CC) -o $@ -c $^ $(CFLAGS)
  34 +
  35 +sender.o: sender.c
  36 + $(CC) -o $@ -c $^ $(CFLAGS)
18 37
19 -#clean:  
20 -# rm -f core *.o libnet.a  
21 38
22 # 39 #
23 -# Les cibles pour la bibliotheque 40 +# La cible de nettoyage
24 # 41 #
25 42
26 -#libnet.o: libnet.c libnet.h 43 +clean:
  44 + rm -f *.o $(LDIR)$(LIB) ../bin/test
27 45
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
@@ -6,23 +6,30 @@ @@ -6,23 +6,30 @@
6 #include <string.h> 6 #include <string.h>
7 #include <netdb.h> 7 #include <netdb.h>
8 #include <arpa/inet.h> 8 #include <arpa/inet.h>
  9 +#include <errno.h>
9 10
10 11
11 -  
12 -int initialized=0;  
13 -int sock_id; 12 +<<<<<<< HEAD
  13 +int initializeSocketUDP(char* service)
  14 +{
  15 + int sock_id;
  16 + struct addrinfo precisions, *resultat=NULL, *origine; // On stocke dans précisions nos besoins pour le socket, dans resultat l'adresse qui respectera les requêtes
  17 +=======
14 18
15 int initializeSocketUDP(char* service) 19 int initializeSocketUDP(char* service)
16 { 20 {
  21 + 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 22 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
  23 +>>>>>>> 52d8a1eaf954b611aaf0861144b440a15f7c517d
18 24
19 memset(&precisions, 0, sizeof precisions); 25 memset(&precisions, 0, sizeof precisions);
20 precisions.ai_family = AF_UNSPEC; 26 precisions.ai_family = AF_UNSPEC;
21 precisions.ai_socktype = SOCK_DGRAM; 27 precisions.ai_socktype = SOCK_DGRAM;
22 //precisions.ai_flags = AI_PASSIVE; 28 //precisions.ai_flags = AI_PASSIVE;
23 -  
24 - if(getaddrinfo(NULL, service, &precisions, &origine)<0) { fprintf(stderr, "Erreur getaddrinfo\n"); return(-1); }  
25 - 29 +
  30 +
  31 + if(getaddrinfo("192.168.0.14", service, &precisions, &origine)<0) { fprintf(stderr, "Erreur getaddrinfo\n"); return(-1); }
  32 +
26 int n=0; 33 int n=0;
27 34
28 for(struct addrinfo* i=origine; i!=NULL && resultat==NULL; i=i->ai_next) 35 for(struct addrinfo* i=origine; i!=NULL && resultat==NULL; i=i->ai_next)
@@ -38,6 +45,8 @@ int initializeSocketUDP(char* service) @@ -38,6 +45,8 @@ int initializeSocketUDP(char* service)
38 n++; 45 n++;
39 } 46 }
40 47
  48 + printf("Value : %d\n", n);
  49 +
41 struct sockaddr_in* test=(struct sockaddr_in*)(resultat->ai_addr); 50 struct sockaddr_in* test=(struct sockaddr_in*)(resultat->ai_addr);
42 printf("Addr : %x\n", test->sin_addr.s_addr); 51 printf("Addr : %x\n", test->sin_addr.s_addr);
43 if((sock_id=socket(resultat->ai_family, resultat->ai_socktype, resultat->ai_protocol))<0) { fprintf(stderr, "Erreur socket\n"); return(-1); } 52 if((sock_id=socket(resultat->ai_family, resultat->ai_socktype, resultat->ai_protocol))<0) { fprintf(stderr, "Erreur socket\n"); return(-1); }
@@ -50,12 +59,10 @@ int initializeSocketUDP(char* service) @@ -50,12 +59,10 @@ int initializeSocketUDP(char* service)
50 59
51 60
52 freeaddrinfo(origine); 61 freeaddrinfo(origine);
53 -  
54 - initialized=1; 62 + return sock_id;
55 } 63 }
56 64
57 65
58 -  
59 int sendUDPBroadcast(char* message, int port) 66 int sendUDPBroadcast(char* message, int port)
60 { 67 {
61 static struct sockaddr_in addrUDP; 68 static struct sockaddr_in addrUDP;
@@ -65,17 +72,27 @@ int sendUDPBroadcast(char* message, int port) @@ -65,17 +72,27 @@ int sendUDPBroadcast(char* message, int port)
65 struct in_addr tmpadd={0xffffffff}; 72 struct in_addr tmpadd={0xffffffff};
66 addrUDP.sin_addr=tmpadd; 73 addrUDP.sin_addr=tmpadd;
67 74
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 - } 75 + char tmp_str[15];
  76 + sprintf(tmp_str, "%d", port);
  77 + int sock_id=initializeSocketUDP( tmp_str );
  78 +
  79 + printf("Initialize via Broadcast %d\n", sock_id);
  80 +<<<<<<< HEAD
  81 +
  82 + int status;
  83 + if((status=sendto(sock_id, message, sizeof(message), 0, (struct sockaddr*) &addrUDP, sizeof(addrUDP))) < 0) { fprintf(stderr, "Erreur sendto %d\n", status); return(-1);}
  84 +
  85 +=======
75 86
76 - if(sendto(sock_id, message, sizeof(message), 0, (struct sockaddr*) &addrUDP, sizeof(addrUDP)) < 0) { fprintf(stderr, "Erreur sendto\n"); return(-1);} 87 + if(sendto(sock_id, message, sizeof(message), 0, (struct sockaddr*) &addrUDP, sizeof(addrUDP)) < 0) { fprintf(stderr, "Erreur sendto\n"); return(-1);}
  88 +
  89 +>>>>>>> 52d8a1eaf954b611aaf0861144b440a15f7c517d
  90 + close(sock_id);
  91 + return 0;
77 } 92 }
78 93
  94 +
  95 +
79 int sendUDPUnicast(char* address, char* message, int port) 96 int sendUDPUnicast(char* address, char* message, int port)
80 { 97 {
81 static struct sockaddr_in addrUDP; 98 static struct sockaddr_in addrUDP;
@@ -84,26 +101,38 @@ int sendUDPUnicast(char* address, char* message, int port) @@ -84,26 +101,38 @@ int sendUDPUnicast(char* address, char* message, int port)
84 101
85 inet_aton(address, &(addrUDP.sin_addr)); // Converti l'écriture string de format a.b.c.d en format Internet 102 inet_aton(address, &(addrUDP.sin_addr)); // Converti l'écriture string de format a.b.c.d en format Internet
86 103
87 - 104 + char tmp_str[15];
  105 + sprintf(tmp_str, "%d", port);
  106 + int sock_id=initializeSocketUDP( tmp_str );
  107 + printf("Initialize via Unicast %d\n", sock_id);
  108 +<<<<<<< HEAD
88 109
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 - } 110 + if(sendto(sock_id, message, sizeof(message), 0, (struct sockaddr*) &addrUDP, sizeof(addrUDP)) < 0 ) { fprintf(stderr, "Error sendto %d\n", errno); return(-1); }
  111 +
  112 +=======
96 113
97 if(sendto(sock_id, message, sizeof(message), 0, (struct sockaddr*) &addrUDP, sizeof(addrUDP)) < 0 ) { fprintf(stderr, "Error sendto\n"); return(-1); } 114 if(sendto(sock_id, message, sizeof(message), 0, (struct sockaddr*) &addrUDP, sizeof(addrUDP)) < 0 ) { fprintf(stderr, "Error sendto\n"); return(-1); }
  115 +
  116 + close(sock_id);
  117 + return 0;
98 } 118 }
  119 +>>>>>>> 52d8a1eaf954b611aaf0861144b440a15f7c517d
99 120
  121 + close(sock_id);
  122 + return 0;
  123 +}
100 124
  125 +<<<<<<< HEAD
101 126
  127 +=======
  128 +>>>>>>> 52d8a1eaf954b611aaf0861144b440a15f7c517d
  129 +/*
102 130
103 int main(void) 131 int main(void)
104 { 132 {
105 sendUDPBroadcast("Broadwesh", 2020); 133 sendUDPBroadcast("Broadwesh", 2020);
106 - sendUDPUnicast("255.255.255.255", "Uniwesh", 2020); 134 + sendUDPUnicast("192.168.43.174", "Uniwesh", 2020);
107 return(1); 135 return(1);
108 - close(sock_id);  
109 } 136 }
  137 +
  138 +*/
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
Sioux/sioux.c renamed to Network/tcpserver.c
@@ -3,15 +3,10 @@ @@ -3,15 +3,10 @@
3 #include <stdio.h> 3 #include <stdio.h>
4 #include <stdlib.h> 4 #include <stdlib.h>
5 #include <unistd.h> 5 #include <unistd.h>
6 -#include <getopt.h>  
7 #include <string.h> 6 #include <string.h>
8 #include <netdb.h> 7 #include <netdb.h>
9 #include <arpa/inet.h> 8 #include <arpa/inet.h>
10 -#include <pthread.h>  
11 -  
12 -#define BUFF_SIZE 100  
13 -  
14 - 9 +#include "libthrd.h"
15 10
16 11
17 12
@@ -62,42 +57,7 @@ int initialisationServeur(char* service) @@ -62,42 +57,7 @@ int initialisationServeur(char* service)
62 return sock_fd; 57 return sock_fd;
63 } 58 }
64 59
65 -void* reponseConnexion(void* sock)  
66 -{  
67 - printf("Connected\n");  
68 - char buffer[BUFF_SIZE];  
69 -  
70 - FILE* sockdial_stream = fdopen(*((int*)(sock)), "a+");  
71 -  
72 - printf("Sock : %d // Stream : %p \n", *((int*)(sock)), sockdial_stream);  
73 -  
74 - while(strcmp(buffer, "EXIT\n")!=0)  
75 - {  
76 - printf("WAIT\n");  
77 - fgets(buffer, BUFF_SIZE, sockdial_stream);  
78 -  
79 - printf("Le message reçu : %s", buffer);  
80 -  
81 - fprintf(sockdial_stream, "Ceci est une réponse du serveur TCP.\n");  
82 -  
83 - }  
84 -  
85 - printf("Fin de la connexion\n");  
86 - fclose(sockdial_stream);  
87 -  
88 -}  
89 -  
90 60
91 -int lanceThread(void(* fonction) (void *), void* arg, int size)  
92 -{  
93 - pthread_t thr_id;  
94 -  
95 - if(pthread_create(&thr_id, NULL, (void*)fonction, arg )!=0) { fprintf(stderr, "Le thread n'a pas pu être créé.\n"); return -1; }  
96 -  
97 - pthread_detach(thr_id);  
98 -  
99 - return 0;  
100 -}  
101 61
102 62
103 int boucleServeur(int socket, void(* fctConnex)(int)) 63 int boucleServeur(int socket, void(* fctConnex)(int))
@@ -116,38 +76,3 @@ int boucleServeur(int socket, void(* fctConnex)(int)) @@ -116,38 +76,3 @@ int boucleServeur(int socket, void(* fctConnex)(int))
116 } 76 }
117 } 77 }
118 78
119 -void argPortParsing(int argc, char* argv[], char* port)  
120 -{  
121 - struct option port_arg={"port", 1, NULL, 'p'};  
122 - char opt;  
123 - int longindex;  
124 -  
125 - while( (opt=getopt_long(argc, argv, "p:", &port_arg, &longindex)) !='p' && opt!=-1) {}  
126 -  
127 - if(opt=='p')  
128 - {  
129 - strcpy(port, optarg);  
130 - printf("%s\n", optarg);  
131 - }  
132 - else  
133 - {  
134 - printf("La syntaxe doit être ./sioux -p <port> ou ./sioux --port <port>");  
135 - }  
136 -}  
137 -  
138 -int main(int argc, char* argv[])  
139 -{  
140 - char port[10]="80";  
141 - argPortParsing(argc, argv, port);  
142 -  
143 -  
144 - int sock_fd=initialisationServeur(port);  
145 -  
146 - if( sock_fd==-1 ) { fprintf(stderr, "Initialisation du serveur impossible\n"); return -1; }  
147 -  
148 -  
149 - boucleServeur(sock_fd, (void*)&reponseConnexion);  
150 - return 0;  
151 -}  
152 -  
153 -  
Network/tcpserver.o 0 → 100644
No preview for this file type
README.md 100644 → 100755
Sioux/Page.html 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +<!doctype html>
  2 +<html>
  3 + <head>
  4 + <meta charset ="utf-8">
  5 + <title> Interface Tangible </title>
  6 + </meta>
  7 + </head>
  8 + <body>
  9 + </body>
  10 +</html>
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.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/Page.html 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +<!doctype html>
  2 +<html>
  3 + <head>
  4 + <meta charset ="utf-8">
  5 + <title> Interface Tangible </title>
  6 + </meta>
  7 + </head>
  8 + <body>
  9 + </body>
  10 +</html>
Threads/threadSocket.c 0 → 100644
@@ -0,0 +1,73 @@ @@ -0,0 +1,73 @@
  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 +<<<<<<< HEAD
  14 + char buff_rec[BUFF_SIZE];
  15 + char buffer[]="HTTP/1.1 200 OK\r\nServer: Serveur fait maison\r\nContent-Type: text/html; charset=UTF-8\r\nConnection: Keep-alive\r\n\r\nPOST /Page.html HTTP/1.1\r\n\r\n";
  16 +
  17 +
  18 + FILE* sockdial_stream = fdopen(*((int*)(sock)), "a+");
  19 +
  20 + printf("Sock : %d // Stream : %p \n", *((int*)(sock)), sockdial_stream);
  21 +
  22 + fgets(buff_rec, BUFF_SIZE, sockdial_stream);
  23 + fprintf(sockdial_stream, "%s", buffer);
  24 +
  25 + //while(strcmp(buffer, "EXIT\n")!=0)
  26 + //{
  27 + printf("WAIT\n");
  28 + // fgets(buff_rec, BUFF_SIZE, sockdial_stream);
  29 +
  30 + printf("Le message reçu : %s", buff_rec);
  31 +
  32 + fprintf(sockdial_stream, "Ceci est une réponse du serveur TCP.\n");
  33 +
  34 + //}
  35 +=======
  36 + char buffer[BUFF_SIZE];
  37 +
  38 + FILE* sockdial_stream = fdopen(*((int*)(sock)), "a+");
  39 +
  40 + printf("Sock : %d // Stream : %p \n", *((int*)(sock)), sockdial_stream);
  41 +
  42 + while(strcmp(buffer, "EXIT\n")!=0)
  43 + {
  44 + printf("WAIT\n");
  45 + fgets(buffer, BUFF_SIZE, sockdial_stream);
  46 +
  47 + printf("Le message reçu : %s", buffer);
  48 +
  49 + fprintf(sockdial_stream, "Ceci est une réponse du serveur TCP.\n");
  50 +
  51 + }
  52 +>>>>>>> 52d8a1eaf954b611aaf0861144b440a15f7c517d
  53 +
  54 + strcpy(buffer, "START");
  55 + printf("Fin de la connexion\n");
  56 + fclose(sockdial_stream);
  57 + pthread_exit(NULL);
  58 +}
  59 +
  60 +
  61 +int lanceThread(void(* fonction) (void *), void* arg, int size)
  62 +{
  63 + pthread_t thr_id;
  64 + printf("%d \n",size);
  65 + if(pthread_create(&thr_id, NULL, (void*)fonction, arg )!=0) { fprintf(stderr, "Le thread n'a pas pu être créé.\n"); return -1; }
  66 +
  67 + pthread_detach(thr_id);
  68 +
  69 + return 0;
  70 +}
  71 +
  72 +
  73 +
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,84 @@ @@ -0,0 +1,84 @@
  1 +#include <stdlib.h>
  2 +#include <stdio.h>
  3 +<<<<<<< HEAD
  4 +#include <unistd.h>
  5 +#include <getopt.h>
  6 +#include <string.h>
  7 +#include <signal.h>
  8 +#include "libnet.h"
  9 +
  10 +
  11 +int sock_fd;
  12 +
  13 +struct sigaction action;
  14 +
  15 +void handler(int sig)
  16 +{
  17 + if(sig==SIGINT)
  18 + {
  19 + printf("\nINTERRUPTION SOCKET : %d\n\n", sock_fd);
  20 + close(sock_fd);
  21 + exit(1);
  22 + }
  23 +}
  24 +
  25 +
  26 +=======
  27 +#include <getopt.h>
  28 +#include <string.h>
  29 +#include "libnet.h"
  30 +
  31 +
  32 +>>>>>>> 52d8a1eaf954b611aaf0861144b440a15f7c517d
  33 +void argPortParsing(int argc, char* argv[], char* port)
  34 +{
  35 + struct option port_arg={"port", 1, NULL, 'p'};
  36 + char opt;
  37 + int longindex;
  38 +
  39 + while( (opt=getopt_long(argc, argv, "p:", &port_arg, &longindex)) !='p' && opt!=-1) {}
  40 +
  41 + if(opt=='p')
  42 + {
  43 + strcpy(port, optarg);
  44 + printf("%s\n", optarg);
  45 + }
  46 + else
  47 + {
  48 + printf("La syntaxe doit être de la forme %s -p <port> ou %s --port <port>\n\n", argv[0], argv[0]);
  49 + }
  50 +}
  51 +
  52 +
  53 +int main(int argc, char* argv[])
  54 +{
  55 + char port[10]="80";
  56 + argPortParsing(argc, argv, port);
  57 +
  58 +<<<<<<< HEAD
  59 + action.sa_handler=&handler;
  60 + sigaction(SIGINT, &action, NULL);
  61 +
  62 + if( (sock_fd=initialisationServeur(port)) ==-1 ) { fprintf(stderr, "Initialisation du serveur impossible\n"); return -1; }
  63 +
  64 + boucleServeur(sock_fd, (void*)&reponseConnexion);
  65 +
  66 +
  67 + sendUDPBroadcast("BroadWesh", 2020);
  68 + sendUDPUnicast("192.168.0.37", "Coucou", 2020);
  69 +=======
  70 +
  71 + int sock_fd=initialisationServeur(port);
  72 +
  73 + if( sock_fd==-1 ) { fprintf(stderr, "Initialisation du serveur impossible\n"); return -1; }
  74 +
  75 +
  76 + boucleServeur(sock_fd, (void*)&reponseConnexion);
  77 +
  78 +
  79 + sendUDPBroadcast("BroadWesh", 2020);
  80 +
  81 +>>>>>>> 52d8a1eaf954b611aaf0861144b440a15f7c517d
  82 + return 0;
  83 +}
  84 +
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