-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some util function from ft_traceroute
- ansi: - add dimmed + rst modifier - add RAINBOW_C - network: - ipv4: - add ft_getip_str() (need to refactor) - packet: - udp: - add ori_data to t_icmphdr_time_exceeded
- Loading branch information
Showing
7 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: brda-sil <[email protected] +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/09 00:48:48 by brda-sil #+# #+# */ | ||
/* Updated: 2024/05/12 17:57:11 by brda-sil ### ########.fr */ | ||
/* Updated: 2024/05/24 00:27:52 by brda-sil ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -170,6 +170,7 @@ typedef struct __attribute__((__packed__)) s_icmphdr_time_exceed | |
t_uint32 unused; | ||
|
||
t_iphdr ori_iphdr; | ||
t_uint8 ori_data[8]; | ||
} t_icmphdr_time_exceed; | ||
|
||
/* ########################################################################## */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: brda-sil <[email protected] +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/07 03:36:06 by brda-sil #+# #+# */ | ||
/* Updated: 2023/07/31 18:25:09 by brda-sil ### ########.fr */ | ||
/* Updated: 2024/05/24 00:39:25 by brda-sil ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -25,3 +25,44 @@ t_size ft_putip_fd(t_int4 n, int fd) | |
printed = ft_putunbr_fd(ft_int4_dcomp(n, 0), fd); | ||
return (printed); | ||
} | ||
|
||
// static set_part() | ||
|
||
char *ft_getip_str(t_int4 n) | ||
{ | ||
char *ptr; | ||
char *tmp_n; | ||
t_size index; | ||
t_size len_tmp_n; | ||
|
||
ptr = (char *)ft_calloc(15, sizeof(char)); | ||
|
||
tmp_n = ft_itoa(ft_int4_dcomp(n, 3)); | ||
len_tmp_n = ft_strlen(tmp_n); | ||
ft_memcpy(ptr, tmp_n, len_tmp_n); | ||
free(tmp_n); | ||
index = len_tmp_n; | ||
ptr[index++] = '.'; | ||
|
||
tmp_n = ft_itoa(ft_int4_dcomp(n, 2)); | ||
len_tmp_n = ft_strlen(tmp_n); | ||
ft_memcpy(ptr + index, tmp_n, len_tmp_n); | ||
free(tmp_n); | ||
index += len_tmp_n; | ||
ptr[index++] = '.'; | ||
|
||
tmp_n = ft_itoa(ft_int4_dcomp(n, 1)); | ||
len_tmp_n = ft_strlen(tmp_n); | ||
ft_memcpy(ptr + index, tmp_n, len_tmp_n); | ||
free(tmp_n); | ||
index += len_tmp_n; | ||
ptr[index++] = '.'; | ||
|
||
tmp_n = ft_itoa(ft_int4_dcomp(n, 0)); | ||
len_tmp_n = ft_strlen(tmp_n); | ||
ft_memcpy(ptr + index, tmp_n, len_tmp_n); | ||
free(tmp_n); | ||
index += len_tmp_n; | ||
|
||
return ptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_rainbow_c.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: brda-sil <[email protected] +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/05/24 00:24:30 by brda-sil #+# #+# */ | ||
/* Updated: 2024/05/24 00:26:41 by brda-sil ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "libft_print.h" | ||
|
||
# define LEN_RAINBOW_C 7 | ||
|
||
char *RAINBOW_C(int i) | ||
{ | ||
switch (i % LEN_RAINBOW_C) | ||
{ | ||
case (0): | ||
return (PUR); | ||
case (1): | ||
return (BLU); | ||
case (2): | ||
return (CYA); | ||
case (3): | ||
return (GRE); | ||
case (4): | ||
return (YEL); | ||
case (5): | ||
return (ORA); | ||
case (6): | ||
return (RED); | ||
} | ||
return ""; | ||
} |