KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
netcfg.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 kos/netcfg.h
4 Copyright (C) 2003 Megan Potter
5
6*/
7
8#ifndef __KOS_NETCFG_H
9#define __KOS_NETCFG_H
10
11/** \file kos/netcfg.h
12 \brief Network configuration interface.
13 \ingroup netcfg
14
15 This file provides a common interface for reading and writing the network
16 configuration on KOS. The interface can read from the flashrom on the
17 Dreamcast or from a file (such as on a VMU or the like), and can write data
18 back to a file.
19
20 The data that is written out by this code is written in a relatively easy to
21 parse text-based format.
22
23 \author Megan Potter
24*/
25
26#include <sys/cdefs.h>
27__BEGIN_DECLS
28
29#include <arch/types.h>
30
31/** \defgroup netcfg Configuration
32 \brief KOS Network Configuration Management
33 \ingroup networking
34*/
35
36/** \defgroup netcfg_methods Methods
37 \brief Network connection methods
38 \ingroup netcfg
39
40 These constants give the list of network connection methods that are
41 supported by the netcfg_t type. One of these will be in the method field of
42 objects of that type.
43
44 @{
45*/
46#define NETCFG_METHOD_DHCP 0 /**< \brief Use DHCP to configure. */
47#define NETCFG_METHOD_STATIC 1 /**< \brief Static network configuration. */
48#define NETCFG_METHOD_PPPOE 4 /**< \brief Use PPPoE. */
49/** @} */
50
51/** \defgroup netcfg_srcs Sources
52 \brief Network configuration sources
53 \ingroup netcfg
54
55 These constants give the list of places that the network configuration might
56 be read from. One of these constants should be in the src field of objects
57 of type netcfg_t.
58
59 @{
60*/
61#define NETCFG_SRC_VMU 0 /**< \brief Read from a VMU. */
62#define NETCFG_SRC_FLASH 1 /**< \brief Read from the flashrom. */
63#define NETCFG_SRC_CWD 2 /**< \brief Read from the working directory. */
64#define NETCFG_SRC_CDROOT 3 /**< \brief Read from the root of the CD. */
65/** @} */
66
67/** \brief Network configuration information.
68 \ingroup netcfg
69
70 This structure contains information about the network configuration of the
71 system, as set up by the user.
72
73 \headerfile kos/netcfg.h
74*/
75typedef struct netcfg {
76 /** \brief Where was this configuration read from?
77 \see netcfg_srcs
78 */
79 int src;
80
81 /** \brief How should the network be configured?
82 \see netcfg_methods
83 */
84 int method;
85
86 uint32 ip; /**< \brief IPv4 address of the console */
87 uint32 gateway; /**< \brief IPv4 address of the gateway/router. */
88 uint32 netmask; /**< \brief Network mask for the local net. */
89 uint32 broadcast; /**< \brief Broadcast address for the local net. */
90 uint32 dns[2]; /**< \brief IPv4 address of the DNS servers. */
91 char hostname[64]; /**< \brief DNS/DHCP hostname. */
92 char email[64]; /**< \brief E-Mail address. */
93 char smtp[64]; /**< \brief SMTP server address. */
94 char pop3[64]; /**< \brief POP3 server address. */
95 char pop3_login[64]; /**< \brief POP3 server username. */
96 char pop3_passwd[64]; /**< \brief POP3 server password. */
97 char proxy_host[64]; /**< \brief Proxy server address. */
98 int proxy_port; /**< \brief Proxy server port. */
99 char ppp_login[64]; /**< \brief PPP Username. */
100 char ppp_passwd[64]; /**< \brief PPP Password. */
101 char driver[64]; /**< \brief Driver program filename (if any). */
102} netcfg_t;
103
104/** \brief Load network configuration from a file.
105 \ingroup netcfg
106
107 This function loads the network configuration that is stored in the given
108 file to the network configuration structure passed in. This function will
109 also handle files on the VMU with the VMU specific header attached without
110 any extra work required.
111
112 \param fn The file to read the configuration from.
113 \param out Buffer to store the parsed configuration.
114
115 \return 0 on success, <0 on failure.
116*/
117int netcfg_load_from(const char * fn, netcfg_t * out);
118
119/** \brief Load network configuration from the Dreamcast's flashrom.
120 \ingroup netcfg
121
122 This function loads the network configuration that is stored in flashrom of
123 the Dreamcast, parsing it into a netcfg_t.
124
125 \note This currently does not read the configuration stored by
126 the PlanetWeb browser at all.
127
128 \param out Buffer to store the parsed configuration.
129
130 \return 0 on success, <0 on failure.
131*/
133
134/** \brief Load network configuration.
135 \ingroup netcfg
136
137 This function loads the network configuration data, searching in multiple
138 locations to attempt to find a file with a stored configuration. This
139 function will attempt to read the configuration from each VMU first (from
140 a file named net.cfg), then it will try the flashrom, followed by the
141 current working directory, and lastly the root of the CD.
142
143 \param out Buffer to store the parsed configuration.
144
145 \return 0 on success, <0 on failure.
146*/
148
149/** \brief Save network configuration to a file.
150 \ingroup netcfg
151
152 This function saves the network configuration to the specified file. This
153 function will automatically prepend the appropriate header if it is saved
154 to a VMU.
155
156 \param fn The file to save to.
157 \param cfg The configuration to save.
158
159 \return 0 on success, <0 on failure.
160*/
161int netcfg_save_to(const char * fn, const netcfg_t * cfg);
162
163/** \brief Save network configuration to the first available VMU.
164 \ingroup netcfg
165
166 This function saves the network configuration to first VMU that it finds. It
167 will not retry if the first VMU doesn't have enough space to hold the file.
168
169 \param cfg The configuration to save.
170
171 \return 0 on success, <0 on failure.
172*/
173int netcfg_save(const netcfg_t * cfg);
174
175__END_DECLS
176
177#endif /* __KOS_NETCFG_H */
178
int netcfg_save(const netcfg_t *cfg)
Save network configuration to the first available VMU.
int netcfg_save_to(const char *fn, const netcfg_t *cfg)
Save network configuration to a file.
int netcfg_load_flash(netcfg_t *out)
Load network configuration from the Dreamcast's flashrom.
int netcfg_load_from(const char *fn, netcfg_t *out)
Load network configuration from a file.
int netcfg_load(netcfg_t *out)
Load network configuration.
unsigned long uint32
32-bit unsigned integer
Definition types.h:33
Network configuration information.
Definition netcfg.h:75
int src
Where was this configuration read from?
Definition netcfg.h:79
int method
How should the network be configured?
Definition netcfg.h:84
uint32 netmask
Network mask for the local net.
Definition netcfg.h:88
uint32 gateway
IPv4 address of the gateway/router.
Definition netcfg.h:87
uint32 broadcast
Broadcast address for the local net.
Definition netcfg.h:89
int proxy_port
Proxy server port.
Definition netcfg.h:98
uint32 ip
IPv4 address of the console.
Definition netcfg.h:86
Common integer types.