From 0241729e67911dc28ec3195b226f545cf4ef0f02 Mon Sep 17 00:00:00 2001 From: ngwalang Date: Fri, 3 Mar 2023 21:52:30 +0100 Subject: [PATCH] Update --- SCR1.2/TP11/get_numb.c | 34 ++++++++++++++++++++++++++++++++++ SCR1.2/TP11/put_nub.c | 27 +++++++++++++++++++++++++++ SCR1.2/TP11/test.dat* | 0 SCR1.2/TP11/test.txt | Bin 13 -> 20 bytes SCR2.1/TP13/tp13-notes.txt | 20 ++++++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 SCR1.2/TP11/get_numb.c create mode 100644 SCR1.2/TP11/put_nub.c create mode 100644 SCR1.2/TP11/test.dat* create mode 100644 SCR2.1/TP13/tp13-notes.txt diff --git a/SCR1.2/TP11/get_numb.c b/SCR1.2/TP11/get_numb.c new file mode 100644 index 0000000..7c4450c --- /dev/null +++ b/SCR1.2/TP11/get_numb.c @@ -0,0 +1,34 @@ +#include +#include +#include +#include + +int main(int argc, char *argv[]){ + if (argc != 3){ + fprintf(stderr, "%c ", argv[0]); + exit(1); + } + off_t offset; + ssize_t nb_read; + int nb, n; + int fdin; + fdin = open(argv[1], O_RDONLY); + if (fdin == -1){ + perror("File can't be opened"); + exit(2); + } + offset = (off_t) strtol (argv[2], NULL, 0); + n = lseek(fdin, offset * sizeof(int), SEEK_SET); + if (!n){ + perror("Offset is out of range!"); + exit(3); + } + nb_read=read(fdin, &nb, sizeof(int)); + if (nb_read < 0){ + perror("File can't be read"); + exit(4); + } + printf("The number at offset %s is %x --> %d\n", argv[2], nb, nb); + return EXIT_SUCCESS; +} + diff --git a/SCR1.2/TP11/put_nub.c b/SCR1.2/TP11/put_nub.c new file mode 100644 index 0000000..7663b78 --- /dev/null +++ b/SCR1.2/TP11/put_nub.c @@ -0,0 +1,27 @@ +#include +#include +#include +#include + +int main(int argc, char *argv[]){ + if (argc != 4){ + fprintf(stderr, "%c <32-bit in Hex> ", argv[0]); + exit(1); + } + off_t offset; + ssize_t nb_write; + int nb, n; + int fdin; + fdin = open(argv[1],O_WRONLY); + if (fdin == -1){ + perror("File can't be opened"); + exit(2); + } + offset = (off_t) strtol (argv[3], NULL, 16); + nb = (int) strtol(argv[2], NULL, 16); + n = lseek(fdin, offset * sizeof(int), SEEK_SET); + nb_write=write(fdin, &nb, sizeof(int)); + printf("%x", nb); + return EXIT_SUCCESS; +} + diff --git a/SCR1.2/TP11/test.dat* b/SCR1.2/TP11/test.dat* new file mode 100644 index 0000000..e69de29 diff --git a/SCR1.2/TP11/test.txt b/SCR1.2/TP11/test.txt index 32ba21e7f79e7629f639506a2d5a57bc13ba69c6..1f21a8f79ccc0a3dbed8f670d07e7a99a4ddc949 100644 GIT binary patch literal 20 bcmXqTT+Lv{Wo~Z4WoX33z`)>QtRx5kCwK!S literal 13 UcmXppy2GBn}>01n3j0ssI2 diff --git a/SCR2.1/TP13/tp13-notes.txt b/SCR2.1/TP13/tp13-notes.txt new file mode 100644 index 0000000..6f63b46 --- /dev/null +++ b/SCR2.1/TP13/tp13-notes.txt @@ -0,0 +1,20 @@ +Question 1) +La commande ip addr permet d'afficher les interfaces réseau de notre machine + +Question 2) +La commande ip addr show lo permet d'afficher l'interface réseau associée au loopback + +Question 3) +La commande ip link show + +Question 4) +ip link show eno1 + +Question 5) +ip neigh + +Question 6) +ip neigh -r + +Question 7) +ip route