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

Last change on this file since 683 was 683, checked in by alain, 2 years ago

All modifications required to support the <tcp_chat> application
including error recovery in case of packet loss.A

File size: 3.6 KB
Line 
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    SOCK_SENDTO      = 7,
72    SOCK_RECVFROM    = 8,
73}
74socket_operation_type_t;
75
76/*****************************************************************************************
77 * These structures define an user defined address in the communication space.
78 * - sockaddr is the generic structure required by bind(), connect() & accept(),
79 *   that supports various socket types.
80 * _ sockaddr_in is the specific structure, used to build an IPv4 network address
81 *   composed of an IP_address (32 bits) and a port_number (16 bits).
82 ****************************************************************************************/
83
84typedef struct sockaddr
85{
86    unsigned short     sa_domain;               // protocols family
87    char               sa_data[14];             // address (format depends on sa_domain)
88}
89sockaddr_t;
90
91typedef struct sockaddr_in
92{
93    unsigned short     sin_domain;              // AF_INET / AF_UNIX
94    unsigned short     sin_port;                // port number
95    unsigned long      sin_addr;                // IP address
96}
97sockaddr_in_t;
98
99
100#endif // _SHARED_SOCKET_H_
101
102
Note: See TracBrowser for help on using the repository browser.