source: trunk/kernel/syscalls/shared_include/shared_socket.h @ 670

Last change on this file since 670 was 670, checked in by alain, 3 years ago

1) Introduce up to 4 command lines arguments in the KSH "load" command.
These arguments are transfered to the user process through the
argc/argv mechanism, using the user space "args" vseg.

2) Introduce the named and anonymous "pipes", for inter-process communication
through the pipe() and mkfifo() syscalls.

3) Introduce the "chat" application to validate the two above mechanisms.

4) Improve printk() and assert() fonctions in printk.c.

File size: 3.5 KB
RevLine 
[664]1/*
2 * shared_socket.h - Shared mnemonics used by the socket related syscalls.
3 *
4 * Author  Alain Greiner (2016,2017,2018,2019,2020)
5 *
6 * Copyright (c) UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef _SHARED_SOCKET_H_
25#define _SHARED_SOCKET_H_
26
27/*******************************************************************************************
28 * This defines the mnemonics for the domains (protocol families).
29 ******************************************************************************************/
30
31#define  AF_LOCAL       1   
32#define  AF_INET        2
33
34/*******************************************************************************************
35 * This defines the mnemonics for the socket types.
36 ******************************************************************************************/
37
38#define  SOCK_DGRAM     0
39#define  SOCK_STREAM    1
40
41/*******************************************************************************************
42 * This defines macros for endiannes handling.
43 ******************************************************************************************/
44
45/*
46#define  HTONS( x )  (((x >> 8) & 0x00FF) + ((x << 8) & 0XFF00))
47
48#define  HTONL( x )  (((x >> 24) & 0x000000FF) + \
49                     ((x >> 8 ) & 0x0000FF00) + \
50                     ((x << 8 ) & 0x00FF0000) + \
51                     ((x << 24) & 0xFF000000))
52*/
53
54#define  HTONS( x )  (x)
55
56#define  HTONL( x )  (x)
57
58/*******************************************************************************************
59 * This enum defines the user operation mnemonics for socket access.
60 ******************************************************************************************/
61
62typedef enum
63{
64    SOCK_CREATE      = 0,     
65    SOCK_BIND        = 1,
66    SOCK_LISTEN      = 2,
67    SOCK_CONNECT     = 3,
68    SOCK_ACCEPT      = 4,
69    SOCK_SEND        = 5,
70    SOCK_RECV        = 6,
71}
72socket_operation_type_t;
73
74/*****************************************************************************************
75 * These structures define an user defined address in the communication space.
76 * - sockaddr is the generic structure required by bind(), connect() & accept(),
77 *   that supports various socket types.
78 * _ sockaddr_in is the specific structure, used to build an IPv4 network address
79 *   composed of an IP_address (32 bits) and a port_number (16 bits).
80 ****************************************************************************************/
81
82typedef struct sockaddr
83{
84    unsigned short     sa_domain;               // protocols family
85    char               sa_data[14];             // address (format depends on sa_domain)
86}
87sockaddr_t;
88
89typedef struct sockaddr_in
90{
91    unsigned short     sin_domain;              // AF_INET / AF_UNIX
92    unsigned short     sin_port;                // port number
93    unsigned long      sin_addr;                // IP address
94}
95sockaddr_in_t;
96
97
98#endif // _SHARED_SOCKET_H_
99
100
Note: See TracBrowser for help on using the repository browser.