version 1.60, 2012/10/01 11:05:05
|
version 1.93, 2018/05/30 09:27:36
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.11 |
RPL/2 (R) version 4.1.29 |
Copyright (C) 1989-2012 Dr. BERTRAND Joël |
Copyright (C) 1989-2018 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 210 instruction_or(struct_processus *s_etat_
|
Line 210 instruction_or(struct_processus *s_etat_
|
struct_objet *s_objet_argument_2; |
struct_objet *s_objet_argument_2; |
struct_objet *s_objet_resultat; |
struct_objet *s_objet_resultat; |
|
|
unsigned long nombre_elements; |
integer8 nombre_elements; |
|
|
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).erreur_execution = d_ex; |
|
|
Line 869 instruction_or(struct_processus *s_etat_
|
Line 869 instruction_or(struct_processus *s_etat_
|
================================================================================ |
================================================================================ |
*/ |
*/ |
|
|
|
|
|
static inline logical1 |
|
options_socket(struct_processus *s_etat_processus, |
|
struct_objet *s_objet_resultat, unsigned char *options, |
|
unsigned char *peripherique, int *priorite, |
|
int *buffer_emission, int *buffer_reception, |
|
int *timeout_emission, int *timeout_reception) |
|
{ |
|
int drapeau; |
|
|
|
/* |
|
* Options des sockets |
|
*/ |
|
|
|
drapeau = -1; |
|
|
|
# define WARNING(message) { \ |
|
if ((*s_etat_processus).langue != 'F') \ |
|
printf("+++Warning : %s unavailable on host system\n", message); \ |
|
else \ |
|
printf("+++Attention : %s non disponible sur le système hôte\n", \ |
|
message); } while(0) |
|
|
|
if (options[d_BIND_TO_DEVICE] == 'Y') |
|
{ |
|
# ifdef SO_BINDTODEVICE |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)) |
|
.socket, SOL_SOCKET, SO_BINDTODEVICE, peripherique, |
|
(socklen_t) strlen(peripherique)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
|
|
(*((struct_socket *) (*s_objet_resultat).objet)).options |= |
|
((integer8) 1) << d_BIND_TO_DEVICE; |
|
# else |
|
WARNING("BIND TO DEVICE"); |
|
# endif |
|
} |
|
|
|
if (options[d_BROADCAST] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, |
|
SOL_SOCKET, SO_BROADCAST, &drapeau, sizeof(drapeau)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
|
|
(*((struct_socket *) (*s_objet_resultat).objet)).options |= |
|
((integer8) 1) << d_BROADCAST; |
|
} |
|
|
|
if (options[d_DONT_ROUTE] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, |
|
SOL_SOCKET, SO_DONTROUTE, &drapeau, sizeof(drapeau)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
|
|
(*((struct_socket *) (*s_objet_resultat).objet)).options |= |
|
((integer8) 1) << d_DONT_ROUTE; |
|
} |
|
|
|
if (options[d_KEEP_ALIVE] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, |
|
SOL_SOCKET, SO_KEEPALIVE, &drapeau, sizeof(drapeau)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
if (options[d_PRIORITY] == 'Y') |
|
{ |
|
# ifdef SO_PRIORITY |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)) |
|
.socket, SOL_SOCKET, SO_PRIORITY, priorite, |
|
sizeof((*priorite))) != 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
|
|
(*((struct_socket *) (*s_objet_resultat).objet)).options |= |
|
((integer8) 1) << d_PRIORITY; |
|
(*((struct_socket *) (*s_objet_resultat).objet)).priorite = |
|
(*priorite); |
|
# else |
|
WARNING("PRIORITY"); |
|
# endif |
|
} |
|
|
|
if (options[d_RECEIVE_BUFFER] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, |
|
SOL_SOCKET, SO_RCVBUF, buffer_reception, |
|
sizeof((*buffer_reception))) != 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
|
|
(*((struct_socket *) (*s_objet_resultat).objet)).options |= |
|
((integer8) 1) << d_RECEIVE_BUFFER; |
|
(*((struct_socket *) (*s_objet_resultat).objet)).buffer_reception = |
|
(*buffer_reception); |
|
} |
|
|
|
if (options[d_FORCE_RECEIVE_BUFFER] == 'Y') |
|
{ |
|
# ifdef SO_RCVBUFFORCE |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)) |
|
.socket, SOL_SOCKET, SO_RCVBUFFORCE, |
|
buffer_reception, sizeof((*buffer_reception))) != 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
|
|
(*((struct_socket *) (*s_objet_resultat).objet)).options |= |
|
((integer8) 1) << d_FORCE_RECEIVE_BUFFER; |
|
(*((struct_socket *) (*s_objet_resultat).objet)).buffer_reception = |
|
(*buffer_reception); |
|
# else |
|
WARNING("FORCE_RECEIVE_BUFFER"); |
|
# endif |
|
} |
|
|
|
if (options[d_SEND_BUFFER] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, |
|
SOL_SOCKET, SO_SNDBUF, buffer_emission, |
|
sizeof((*buffer_emission))) != 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
|
|
(*((struct_socket *) (*s_objet_resultat).objet)).options |= |
|
((integer8) 1) << d_SEND_BUFFER; |
|
(*((struct_socket *) (*s_objet_resultat).objet)).buffer_emission = |
|
(*buffer_emission); |
|
} |
|
|
|
if (options[d_FORCE_SEND_BUFFER] == 'Y') |
|
{ |
|
# ifdef SO_SNDBUFFORCE |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)) |
|
.socket, SOL_SOCKET, SO_SNDBUFFORCE, buffer_emission, |
|
sizeof((*buffer_emission))) != 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
|
|
(*((struct_socket *) (*s_objet_resultat).objet)).options |= |
|
((integer8) 1) << d_FORCE_SEND_BUFFER; |
|
(*((struct_socket *) (*s_objet_resultat).objet)).buffer_emission = |
|
(*buffer_emission); |
|
# else |
|
WARNING("FORCE_SEND_BUFFER"); |
|
# endif |
|
} |
|
|
|
if (options[d_RECEIVING_TIMEOUT] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, |
|
SOL_SOCKET, SO_RCVTIMEO, |
|
timeout_reception, sizeof((*timeout_reception))) != 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
|
|
(*((struct_socket *) (*s_objet_resultat).objet)).options |= |
|
((integer8) 1) << d_RECEIVING_TIMEOUT; |
|
(*((struct_socket *) (*s_objet_resultat).objet)).timeout_reception = |
|
(*timeout_reception); |
|
} |
|
|
|
if (options[d_SENDING_TIMEOUT] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, |
|
SOL_SOCKET, SO_SNDTIMEO, |
|
timeout_emission, sizeof((*timeout_emission))) != 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
|
|
(*((struct_socket *) (*s_objet_resultat).objet)).options |= |
|
((integer8) 1) << d_SENDING_TIMEOUT; |
|
(*((struct_socket *) (*s_objet_resultat).objet)).timeout_emission = |
|
(*timeout_emission); |
|
} |
|
|
|
if (options[d_REUSE_ADDRESS] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, |
|
SOL_SOCKET, SO_REUSEADDR, &drapeau, sizeof(drapeau)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
|
|
(*((struct_socket *) (*s_objet_resultat).objet)).options |= |
|
((integer8) 1) << d_REUSE_ADDRESS; |
|
} |
|
|
|
return(d_absence_erreur); |
|
# undef WARNING |
|
} |
|
|
|
|
void |
void |
instruction_open(struct_processus *s_etat_processus) |
instruction_open(struct_processus *s_etat_processus) |
{ |
{ |
Line 905 instruction_open(struct_processus *s_eta
|
Line 1136 instruction_open(struct_processus *s_eta
|
|
|
int buffer_emission; |
int buffer_emission; |
int buffer_reception; |
int buffer_reception; |
int drapeau; |
|
int priorite; |
int priorite; |
|
int prochain_descripteur; |
int protocole_numerique; |
int protocole_numerique; |
int timeout_emission; |
int timeout_emission; |
int timeout_reception; |
int timeout_reception; |
Line 973 instruction_open(struct_processus *s_eta
|
Line 1204 instruction_open(struct_processus *s_eta
|
|
|
unsigned long i; |
unsigned long i; |
unsigned long nombre_elements; |
unsigned long nombre_elements; |
unsigned long prochain_descripteur; |
|
unsigned long unite; |
unsigned long unite; |
|
|
# define d_BIND_TO_DEVICE 0 |
|
# define d_BROADCAST 1 |
|
# define d_DONT_ROUTE 2 |
|
# define d_KEEP_ALIVE 3 |
|
# define d_PRIORITY 4 |
|
# define d_RECEIVE_BUFFER 5 |
|
# define d_FORCE_RECEIVE_BUFFER 6 |
|
# define d_SEND_BUFFER 7 |
|
# define d_FORCE_SEND_BUFFER 8 |
|
# define d_RECEIVING_TIMEOUT 9 |
|
# define d_SENDING_TIMEOUT 10 |
|
# define d_REUSE_ADDRESS 11 |
|
|
|
/* |
/* |
* Argument : { "ouverture" "accès" "format" [ { "nom" } 'protection' ] } |
* Argument : { "ouverture" "accès" "format" [ { "nom" } 'protection' ] } |
*/ |
*/ |
Line 1028 instruction_open(struct_processus *s_eta
|
Line 1245 instruction_open(struct_processus *s_eta
|
"\"file name\" } \"protection\" } OPEN\n"); |
"\"file name\" } \"protection\" } OPEN\n"); |
printf(" { \"filetype\" \"access\" \"format\" { \"name\" " |
printf(" { \"filetype\" \"access\" \"format\" { \"name\" " |
"\"file name\" } \n" |
"\"file name\" } \n" |
" { \"stty\" { \"stty parameters\" ... } } } OPEN\n"); |
" { \"stty\" \"speed,bits,parity,stop\"\n" |
|
" { \"stty parameters\" ... } } } OPEN\n"); |
printf(" { \"sockettype\" { \"name\" \"local name\" } } OPEN\n"); |
printf(" { \"sockettype\" { \"name\" \"local name\" } } OPEN\n"); |
printf(" { \"sockettype\" \"socketdomain\" \"protection\" } OPEN\n"); |
printf(" { \"sockettype\" \"socketdomain\" \"protection\" } OPEN\n"); |
printf(" \"/semaphore\" OPEN\n\n"); |
printf(" \"/semaphore\" OPEN\n\n"); |
Line 1078 instruction_open(struct_processus *s_eta
|
Line 1296 instruction_open(struct_processus *s_eta
|
printf(" { \"STREAM\" \"READWRITE\" } OPEN\n"); |
printf(" { \"STREAM\" \"READWRITE\" } OPEN\n"); |
printf(" { \"FOREIGN\" \"DATAGRAM\" } OPEN\n"); |
printf(" { \"FOREIGN\" \"DATAGRAM\" } OPEN\n"); |
printf(" { \"LOCAL\" { \"NAME\" \"socket.sock\" } } OPEN\n"); |
printf(" { \"LOCAL\" { \"NAME\" \"socket.sock\" } } OPEN\n"); |
printf(" { { \"NAME\" \"/dev/ttyS1\" } { \"STTY\" { \"9600,8,N,1\" " |
printf(" { { \"NAME\" \"/dev/ttyS1\" } { \"STTY\" \"9600,8,N,1\" " |
"\n { \"NO ICANON\" \"IGNBRK\" } } } OPEN\n"); |
"\n { \"NO ICANON\" \"IGNBRK\" } } } OPEN\n"); |
|
|
return; |
return; |
Line 1139 instruction_open(struct_processus *s_eta
|
Line 1357 instruction_open(struct_processus *s_eta
|
buffer_reception = 0; |
buffer_reception = 0; |
timeout_emission = 0; |
timeout_emission = 0; |
timeout_reception = 0; |
timeout_reception = 0; |
drapeau = -1; |
|
s_parametres_tty = NULL; |
s_parametres_tty = NULL; |
|
|
for(i = 0; i < 12; options[i++] = 'N'); |
for(i = 0; i < 12; options[i++] = 'N'); |
Line 1148 instruction_open(struct_processus *s_eta
|
Line 1365 instruction_open(struct_processus *s_eta
|
{ |
{ |
if ((*(*l_element_courant).donnee).type == CHN) |
if ((*(*l_element_courant).donnee).type == CHN) |
{ |
{ |
if ((argument_majuscule = conversion_majuscule((unsigned char *) |
if ((argument_majuscule = conversion_majuscule(s_etat_processus, |
(*(*l_element_courant).donnee).objet)) == NULL) |
(unsigned char *) (*(*l_element_courant).donnee).objet)) |
|
== NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 1763 instruction_open(struct_processus *s_eta
|
Line 1981 instruction_open(struct_processus *s_eta
|
if ((*(*l_element_courant_sous_objet).donnee).type == CHN) |
if ((*(*l_element_courant_sous_objet).donnee).type == CHN) |
{ |
{ |
if ((argument_majuscule = conversion_majuscule( |
if ((argument_majuscule = conversion_majuscule( |
(unsigned char *) |
s_etat_processus, (unsigned char *) |
(*(*l_element_courant_sous_objet) |
(*(*l_element_courant_sous_objet) |
.donnee).objet)) == NULL) |
.donnee).objet)) == NULL) |
{ |
{ |
Line 1829 instruction_open(struct_processus *s_eta
|
Line 2047 instruction_open(struct_processus *s_eta
|
free(argument_majuscule); |
free(argument_majuscule); |
|
|
if ((argument_majuscule = conversion_majuscule( |
if ((argument_majuscule = conversion_majuscule( |
(unsigned char *) |
s_etat_processus, (unsigned char *) |
(*(*l_element_courant_sous_objet) |
(*(*l_element_courant_sous_objet) |
.donnee).objet)) == NULL) |
.donnee).objet)) == NULL) |
{ |
{ |
Line 1998 instruction_open(struct_processus *s_eta
|
Line 2216 instruction_open(struct_processus *s_eta
|
if ((protocole_socket[i] >= 'a') && |
if ((protocole_socket[i] >= 'a') && |
(protocole_socket[i] <= 'z')) |
(protocole_socket[i] <= 'z')) |
{ |
{ |
protocole_socket[i] -= 'a' - 'A'; |
protocole_socket[i] = (unsigned char) |
|
(protocole_socket[i] |
|
- ('a' - 'A')); |
} |
} |
} |
} |
} |
} |
Line 2318 instruction_open(struct_processus *s_eta
|
Line 2538 instruction_open(struct_processus *s_eta
|
if ((*(*l_element_courant_sous_objet).donnee).type == CHN) |
if ((*(*l_element_courant_sous_objet).donnee).type == CHN) |
{ |
{ |
if ((argument_majuscule = conversion_majuscule( |
if ((argument_majuscule = conversion_majuscule( |
(unsigned char *) |
s_etat_processus, (unsigned char *) |
(*(*l_element_courant_sous_objet) |
(*(*l_element_courant_sous_objet) |
.donnee).objet)) == NULL) |
.donnee).objet)) == NULL) |
{ |
{ |
Line 2359 instruction_open(struct_processus *s_eta
|
Line 2579 instruction_open(struct_processus *s_eta
|
} |
} |
|
|
if ((argument_majuscule = conversion_majuscule( |
if ((argument_majuscule = conversion_majuscule( |
(unsigned char *) |
s_etat_processus, (unsigned char *) |
(*(*l_element_courant_sous_objet) |
(*(*l_element_courant_sous_objet) |
.donnee).objet)) == NULL) |
.donnee).objet)) == NULL) |
{ |
{ |
Line 3620 instruction_open(struct_processus *s_eta
|
Line 3840 instruction_open(struct_processus *s_eta
|
} |
} |
|
|
if ((parametre_courant_majuscule = conversion_majuscule( |
if ((parametre_courant_majuscule = conversion_majuscule( |
(*(*parametre_courant).donnee).objet)) == NULL) |
s_etat_processus, (*(*parametre_courant).donnee).objet)) |
|
== NULL) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
Line 3657 instruction_open(struct_processus *s_eta
|
Line 3878 instruction_open(struct_processus *s_eta
|
// Vitesse |
// Vitesse |
|
|
unsigned char *vitesses[] = |
unsigned char *vitesses[] = |
{ "0", "50", "75", "110", "134", "150", |
{ "50", "75", "110", "134", "150", |
"200", "300", "600", "1200", "1800", "2400", |
"200", "300", "600", "1200", "1800", "2400", |
"4800", "9600", "19200", "38400", |
"4800", "9600", "19200", "38400", |
#ifdef B57600 |
#ifdef B57600 |
Line 3670 instruction_open(struct_processus *s_eta
|
Line 3891 instruction_open(struct_processus *s_eta
|
"230400", |
"230400", |
#endif |
#endif |
NULL }; |
NULL }; |
int vitesses_constantes[] = |
tcflag_t vitesses_constantes[] = |
{ B0, B50, B75, B110, B134, B150, B200, B300, B600, |
{ B50, B75, B110, B134, B150, B200, B300, B600, |
B1200, B1800, B2400, B4800, B9600, B19200, B38400, |
B1200, B1800, B2400, B4800, B9600, B19200, B38400, |
#ifdef B57600 |
#ifdef B57600 |
B57600, |
B57600, |
Line 3696 instruction_open(struct_processus *s_eta
|
Line 3917 instruction_open(struct_processus *s_eta
|
d_code_espace) |
d_code_espace) |
{ |
{ |
#ifdef CBAUD |
#ifdef CBAUD |
tc.c_cflag &= ~CBAUD; |
tc.c_cflag &= ~((tcflag_t) CBAUD); |
tc.c_cflag |= vitesses_constantes[vitesse_courante]; |
tc.c_cflag |= vitesses_constantes[vitesse_courante]; |
#else // POSIX |
#else // POSIX |
cfsetispeed(&tc, |
cfsetispeed(&tc, |
Line 3742 instruction_open(struct_processus *s_eta
|
Line 3963 instruction_open(struct_processus *s_eta
|
{ |
{ |
case '5': |
case '5': |
{ |
{ |
tc.c_cflag &= ~CSIZE; |
tc.c_cflag &= ~((tcflag_t) CSIZE); |
tc.c_cflag |= CS5; |
tc.c_cflag |= CS5; |
break; |
break; |
} |
} |
|
|
case '6': |
case '6': |
{ |
{ |
tc.c_cflag &= ~CSIZE; |
tc.c_cflag &= ~((tcflag_t) CSIZE); |
tc.c_cflag |= CS6; |
tc.c_cflag |= CS6; |
break; |
break; |
} |
} |
|
|
case '7': |
case '7': |
{ |
{ |
tc.c_cflag &= ~CSIZE; |
tc.c_cflag &= ~((tcflag_t) CSIZE); |
tc.c_cflag |= CS7; |
tc.c_cflag |= CS7; |
break; |
break; |
} |
} |
|
|
case '8': |
case '8': |
{ |
{ |
tc.c_cflag &= ~CSIZE; |
tc.c_cflag &= ~((tcflag_t) CSIZE); |
tc.c_cflag |= CS8; |
tc.c_cflag |= CS8; |
break; |
break; |
} |
} |
Line 3809 instruction_open(struct_processus *s_eta
|
Line 4030 instruction_open(struct_processus *s_eta
|
{ |
{ |
case 'N': |
case 'N': |
{ |
{ |
tc.c_cflag &= ~PARENB; |
tc.c_cflag &= ~((tcflag_t) PARENB); |
break; |
break; |
} |
} |
|
|
Line 3823 instruction_open(struct_processus *s_eta
|
Line 4044 instruction_open(struct_processus *s_eta
|
case 'E': |
case 'E': |
{ |
{ |
tc.c_cflag |= PARENB; |
tc.c_cflag |= PARENB; |
tc.c_cflag &= ~PARODD; |
tc.c_cflag &= ~((tcflag_t) PARODD); |
break; |
break; |
} |
} |
|
|
Line 3868 instruction_open(struct_processus *s_eta
|
Line 4089 instruction_open(struct_processus *s_eta
|
{ |
{ |
case '1': |
case '1': |
{ |
{ |
tc.c_cflag &= ~CSTOPB; |
tc.c_cflag &= ~((tcflag_t) CSTOPB); |
break; |
break; |
} |
} |
|
|
Line 3934 instruction_open(struct_processus *s_eta
|
Line 4155 instruction_open(struct_processus *s_eta
|
} |
} |
|
|
if ((parametre_courant_majuscule = conversion_majuscule( |
if ((parametre_courant_majuscule = conversion_majuscule( |
(*(*parametre_courant).donnee).objet)) == NULL) |
s_etat_processus, (*(*parametre_courant).donnee) |
|
.objet)) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 3962 instruction_open(struct_processus *s_eta
|
Line 4184 instruction_open(struct_processus *s_eta
|
#endif |
#endif |
"ISIG", "ICANON", "ECHO", "ECHOE", "ECHOK", |
"ISIG", "ICANON", "ECHO", "ECHOE", "ECHOK", |
"ECHONL", "NOFLSH", "TOSTOP", "IEXTEN", NULL }; |
"ECHONL", "NOFLSH", "TOSTOP", "IEXTEN", NULL }; |
int fonctions_constantes[] = |
tcflag_t fonctions_constantes[] = |
{ /* c_iflag */ |
{ /* c_iflag */ |
1, IGNBRK, 1, BRKINT, 1, IGNPAR, 1, PARMRK, |
1, IGNBRK, 1, BRKINT, 1, IGNPAR, 1, PARMRK, |
1, INPCK, 1, ISTRIP, 1, INLCR, 1, IGNCR, 1, ICRNL, |
1, INPCK, 1, ISTRIP, 1, INLCR, 1, IGNCR, 1, ICRNL, |
Line 4307 instruction_open(struct_processus *s_eta
|
Line 4529 instruction_open(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
prochain_descripteur = i; |
prochain_descripteur = (int) i; |
|
|
/* |
/* |
* Ajout d'un élément à la fin de la liste chaînée |
* Ajout d'un élément à la fin de la liste chaînée |
Line 4377 instruction_open(struct_processus *s_eta
|
Line 4599 instruction_open(struct_processus *s_eta
|
* Traitement des sockets |
* Traitement des sockets |
*/ |
*/ |
|
|
|
|
inline logical1 options_socket() |
|
{ |
|
/* |
|
* Options des sockets |
|
*/ |
|
|
|
# define WARNING(message) \ |
|
if ((*s_etat_processus).langue != 'F') \ |
|
printf("+++Warning : %s unavailable on host system\n", \ |
|
message); \ |
|
else \ |
|
printf("+++Attention : %s non disponible sur le système " \ |
|
"hôte\n", message) |
|
|
|
if (options[d_BIND_TO_DEVICE] == 'Y') |
|
{ |
|
# ifdef SO_BINDTODEVICE |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).socket, SOL_SOCKET, SO_BINDTODEVICE, |
|
peripherique, strlen(peripherique)) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
# else |
|
WARNING("BIND TO DEVICE"); |
|
# endif |
|
} |
|
|
|
if (options[d_BROADCAST] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).socket, SOL_SOCKET, SO_BROADCAST, |
|
&drapeau, sizeof(drapeau)) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
if (options[d_DONT_ROUTE] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).socket, SOL_SOCKET, SO_DONTROUTE, |
|
&drapeau, sizeof(drapeau)) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
if (options[d_KEEP_ALIVE] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).socket, SOL_SOCKET, SO_KEEPALIVE, |
|
&drapeau, sizeof(drapeau)) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
if (options[d_PRIORITY] == 'Y') |
|
{ |
|
# ifdef SO_PRIORITY |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).socket, SOL_SOCKET, SO_PRIORITY, |
|
&priorite, sizeof(priorite)) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
# else |
|
WARNING("PRIORITY"); |
|
# endif |
|
} |
|
|
|
if (options[d_RECEIVE_BUFFER] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).socket, SOL_SOCKET, SO_RCVBUF, |
|
&buffer_reception, sizeof(buffer_reception)) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
if (options[d_FORCE_RECEIVE_BUFFER] == 'Y') |
|
{ |
|
# ifdef SO_RCVBUFFORCE |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).socket, SOL_SOCKET, SO_RCVBUFFORCE, |
|
&buffer_reception, sizeof(buffer_reception)) |
|
!= 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
# else |
|
WARNING("FORCE_RECEIVE_BUFFER"); |
|
# endif |
|
} |
|
|
|
if (options[d_SEND_BUFFER] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).socket, SOL_SOCKET, SO_SNDBUF, |
|
&buffer_emission, sizeof(buffer_emission)) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
if (options[d_FORCE_SEND_BUFFER] == 'Y') |
|
{ |
|
# ifdef SO_SNDBUFFORCE |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).socket, SOL_SOCKET, SO_SNDBUFFORCE, |
|
&buffer_emission, sizeof(buffer_emission)) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
# else |
|
WARNING("FORCE_SEND_BUFFER"); |
|
# endif |
|
} |
|
|
|
if (options[d_RECEIVING_TIMEOUT] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).socket, SOL_SOCKET, SO_RCVTIMEO, |
|
&timeout_reception, sizeof(timeout_reception)) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
if (options[d_SENDING_TIMEOUT] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).socket, SOL_SOCKET, SO_SNDTIMEO, |
|
&timeout_emission, sizeof(timeout_emission)) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
if (options[d_REUSE_ADDRESS] == 'Y') |
|
{ |
|
if (setsockopt((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).socket, SOL_SOCKET, SO_REUSEADDR, |
|
&drapeau, sizeof(drapeau)) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return(d_erreur); |
|
} |
|
} |
|
|
|
return(d_absence_erreur); |
|
#undef WARNING |
|
} |
|
|
|
/* |
/* |
* Vérification de la cohérence des arguments et traitement |
* Vérification de la cohérence des arguments et traitement |
* des valeurs par défaut. |
* des valeurs par défaut. |
Line 4691 instruction_open(struct_processus *s_eta
|
Line 4697 instruction_open(struct_processus *s_eta
|
for(i = 0; i < 16; adresse[i++] = 0); |
for(i = 0; i < 16; adresse[i++] = 0); |
type_adresse = '6'; |
type_adresse = '6'; |
} |
} |
else |
else if (strcmp(protocole, "UNIX") != 0) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
|
|
Line 4870 instruction_open(struct_processus *s_eta
|
Line 4876 instruction_open(struct_processus *s_eta
|
= 'Y'; |
= 'Y'; |
(*((struct_socket *) (*s_objet_resultat).objet)).socket_connectee |
(*((struct_socket *) (*s_objet_resultat).objet)).socket_connectee |
= d_faux; |
= d_faux; |
|
(*((struct_socket *) (*s_objet_resultat).objet)).options = 0; |
|
|
if (type_domaine == 'L') |
if (type_domaine == 'L') |
{ // Socket serveur |
{ // Socket serveur |
Line 4909 instruction_open(struct_processus *s_eta
|
Line 4916 instruction_open(struct_processus *s_eta
|
strncpy(socket_unix.sun_path, pointeur, UNIX_PATH_MAX); |
strncpy(socket_unix.sun_path, pointeur, UNIX_PATH_MAX); |
socket_unix.sun_path[UNIX_PATH_MAX - 1] = d_code_fin_chaine; |
socket_unix.sun_path[UNIX_PATH_MAX - 1] = d_code_fin_chaine; |
|
|
if (options_socket() == d_erreur) |
if (options_socket(s_etat_processus, s_objet_resultat, |
|
options, peripherique, &priorite, |
|
&buffer_emission, &buffer_reception, |
|
&timeout_emission, &timeout_reception) == d_erreur) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
Line 5013 instruction_open(struct_processus *s_eta
|
Line 5023 instruction_open(struct_processus *s_eta
|
(*resolution_courante).ai_addr)) |
(*resolution_courante).ai_addr)) |
.sin_addr.s_addr; |
.sin_addr.s_addr; |
|
|
if (options_socket() == d_erreur) |
if (options_socket(s_etat_processus, |
|
s_objet_resultat, |
|
options, peripherique, &priorite, |
|
&buffer_emission, &buffer_reception, |
|
&timeout_emission, &timeout_reception) |
|
== d_erreur) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
Line 5120 instruction_open(struct_processus *s_eta
|
Line 5135 instruction_open(struct_processus *s_eta
|
(*resolution_courante).ai_addr)) |
(*resolution_courante).ai_addr)) |
.sin6_addr.s6_addr[i], i++); |
.sin6_addr.s6_addr[i], i++); |
|
|
if (options_socket() == d_erreur) |
if (options_socket(s_etat_processus, |
|
s_objet_resultat, |
|
options, peripherique, &priorite, |
|
&buffer_emission, &buffer_reception, |
|
&timeout_emission, &timeout_reception) |
|
== d_erreur) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
Line 5251 instruction_open(struct_processus *s_eta
|
Line 5271 instruction_open(struct_processus *s_eta
|
|
|
adresse_ipv4 = 0; |
adresse_ipv4 = 0; |
for(i = 0; i < 4; adresse_ipv4 = |
for(i = 0; i < 4; adresse_ipv4 = |
(256 * adresse_ipv4) + adresse[i++]); |
(256 * adresse_ipv4) + |
|
((unsigned char) adresse[i++])); |
|
|
socket_ipv4.sin_addr.s_addr = htonl(adresse_ipv4); |
socket_ipv4.sin_addr.s_addr = htonl(adresse_ipv4); |
|
|
if (options_socket() == d_erreur) |
if (options_socket(s_etat_processus, |
|
s_objet_resultat, |
|
options, peripherique, &priorite, |
|
&buffer_emission, &buffer_reception, |
|
&timeout_emission, &timeout_reception) |
|
== d_erreur) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
Line 5332 instruction_open(struct_processus *s_eta
|
Line 5358 instruction_open(struct_processus *s_eta
|
socket_ipv6.sin6_addr.s6_addr[i] = |
socket_ipv6.sin6_addr.s6_addr[i] = |
(unsigned char) (adresse[i]), i++); |
(unsigned char) (adresse[i]), i++); |
|
|
if (options_socket() == d_erreur) |
if (options_socket(s_etat_processus, |
|
s_objet_resultat, |
|
options, peripherique, &priorite, |
|
&buffer_emission, &buffer_reception, |
|
&timeout_emission, &timeout_reception) |
|
== d_erreur) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
Line 5840 instruction_open(struct_processus *s_eta
|
Line 5871 instruction_open(struct_processus *s_eta
|
|
|
adresse_ipv4 = 0; |
adresse_ipv4 = 0; |
for(i = 0; i < 4; adresse_ipv4 = |
for(i = 0; i < 4; adresse_ipv4 = |
(256 * adresse_ipv4) + adresse[i++]); |
(256 * adresse_ipv4) |
|
+ ((unsigned char) adresse[i++])); |
|
|
socket_ipv4.sin_addr.s_addr = htonl(adresse_ipv4); |
socket_ipv4.sin_addr.s_addr = htonl(adresse_ipv4); |
|
|