merge 64-bit fixes from Fernando Lucas Rodriguez <fernando_lr@terra.es>
[debian/gcpegg] / network.h
1 /* PROGRAM:     eggsh
2  * FILE:        $Header: /home/egg/src/RCS/network.h,v 1.6 1999/02/28 20:14:26 ghn Exp $
3  * PURPOSE:     Definitions for network communication functions
4  * AUTHOR:      Greg Nelson
5  * DATE:        98-05-09
6  *
7  * REVISED:
8  * $Log: network.h,v $
9  * Revision 1.6  1999/02/28 20:14:26  ghn
10  * Version 5.1: Modified InitNetwork to take interface (addr) argument as
11  * well as port, and handle various cases of interface (NULL, IP,
12  * hostname) gracefully.  Modified NetUp to call this new version.
13  *
14  * Revision 1.5  1999/01/02 00:02:24  ghn
15  * Modified NetTalk() api to offer "gripe" argument to silence some perror()s.
16  *
17  * Revision 1.4  1998/12/31 22:11:05  ghn
18  *  Rev 5 code: includes multi-reg support, HTML, etc.
19  *
20  * Revision 1.3  1998/08/01 18:51:25  ghn
21  * Added John's byte-order-independence changes.
22  *
23  * Revision 1.2  1998/08/01 17:17:40  ghn
24  * Added DND support.
25  *
26  * Revision 1.1  1998/07/21 11:36:34  ghn
27  * Initial revision
28  *
29  * Copyright 1998 - Greg Nelson
30  * Redistributable under the terms of the GNU Public Licence (GPL)
31  */
32
33 #ifndef _NETWORK_H
34 #define _NETWORK_H
35
36 #include <netinet/in.h>
37
38 #ifdef TESTPORT
39 #define EGGPORT         2074
40 #define BASKETPORT      2075
41 #else
42 #define EGGPORT         1105
43 #define BASKETPORT      2510
44 #endif
45
46 /* Initialize network subsystem, returning socket descriptor */
47 extern int32 InitNetwork(char *addr, int32 port);
48
49 /* Bring net up with command */
50 extern int32 NetUp(char *cmd, char *addr, int32 port);
51
52 /* Bring net down with command */
53 extern int NetDown(char *cmd, int32 oldsd);
54
55 /* Get a sockaddr given a host and port */
56 extern int NetGetAddr(struct sockaddr_in *sin, char *host, uint16 port);
57
58 /* Listen for a data request.
59
60    Listen on specified socket sd.  When one is received, validate the
61    checksum, and, if successful, allocate memory and stuff it as a
62    character array.  Return the remote sockaddr_in, if the sin pointer
63    is not null, and block until something interesting happens if block
64    is true. */
65 extern int NetListen(int sd, char **pktbuf, 
66                      struct sockaddr_in *sin,
67                      int block);
68
69 /* Send a data packet.
70
71    Create a socket, checksum the packet, and send it to the specified
72    addr in sin.  Length of packet to be extracted from packet
73    header. */
74 extern int NetTalk(struct sockaddr_in *sin, char *pkt, int gripe);
75
76 #endif /* !_NETWORK_H */