summaryrefslogtreecommitdiff
path: root/pfinet/options.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2000-10-06 15:14:12 +0000
committerMarcus Brinkmann <marcus@gnu.org>2000-10-06 15:14:12 +0000
commitf4814f877d82f6242c95c10bb661fadecc5ab24b (patch)
tree37bdddbc686b7cd112620461312327eadb8f6c80 /pfinet/options.c
parent898424326fc1188384f67963ab6789f18dd57fd3 (diff)
2000-10-06 Marcus Brinkmann <marcus@gnu.org>
* Makefile (SRCS): Add tunnel.c * tunnel.c: New file. * linux-src/net/ipv4/devinet.c (configure_device): New argument PEER. Implement support for setting the destination address for point-to-point interfaces. (inquire_device): New argument PEER. Implement support to get the destination address. * main.c: Include fcntl.h. Update prototype of configure_device. Set trivfs_support_read and trivfs_support_write to 1, as we support those in some cases now. For the same reason, set trivfs_allow_open to O_READ | O_WRITE. (pfinet_demuxer): If the port is not in the socketport_class, don't try io_server (so requests for trivfs are not catched too early). (find_device): Use setup_tunnel_device for tun* interfaces. (main): Add peer argument to configure_device call for the lo interface. * options.c: Update prototypes for configure_device, inquire_device. (options): Add --peer option. (stuct parse_interface): Add peer member. (parse_hook_add_interface): Initialize peer. (parse_opt): Add a case for --peer. Add peer argument to configure_device call. (add_dev_opts): Add peer variable, add it to inquire_device call arguments. Check for peer argument and add it to command line if it is there. * pfinet.h: Add prototype for setup_tunnel_device.
Diffstat (limited to 'pfinet/options.c')
-rw-r--r--pfinet/options.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/pfinet/options.c b/pfinet/options.c
index 0a00ea9d..12a7a4c1 100644
--- a/pfinet/options.c
+++ b/pfinet/options.c
@@ -44,10 +44,10 @@ extern error_t find_device (char *name, struct device **device);
extern error_t enumerate_devices (error_t (*fun) (struct device *dev));
/* devinet.c */
-extern error_t configure_device (struct device *dev,
- uint32_t addr, uint32_t netmask);
-extern void inquire_device (struct device *dev,
- uint32_t *addr, uint32_t *netmask);
+extern error_t configure_device (struct device *dev, uint32_t addr,
+ uint32_t netmask, uint32_t peer);
+extern void inquire_device (struct device *dev, uint32_t *addr,
+ uint32_t *netmask, uint32_t *peer);
/* Pfinet options. Used for both startup and runtime. */
static const struct argp_option options[] =
@@ -56,6 +56,7 @@ static const struct argp_option options[] =
{0,0,0,0,"These apply to a given interface:", 2},
{"address", 'a', "ADDRESS", 0, "Set the network address"},
{"netmask", 'm', "MASK", 0, "Set the netmask"},
+ {"peer", 'p', "ADDRESS", 0, "Set the peer address"},
{"gateway", 'g', "ADDRESS", 0, "Set the default gateway"},
{"shutdown", 's', 0, 0, "Shut it down"},
{0}
@@ -72,7 +73,7 @@ struct parse_interface
struct device *device;
/* New values to apply to it. */
- uint32_t address, netmask, gateway;
+ uint32_t address, netmask, peer, gateway;
};
/* Used to hold data during argument parsing. */
@@ -103,6 +104,7 @@ parse_hook_add_interface (struct parse_hook *h)
h->curint->device = 0;
h->curint->address = INADDR_NONE;
h->curint->netmask = INADDR_NONE;
+ h->curint->peer = INADDR_NONE;
h->curint->gateway = INADDR_NONE;
return 0;
}
@@ -187,6 +189,8 @@ parse_opt (int opt, char *arg, struct argp_state *state)
break;
case 'm':
h->curint->netmask = ADDR (arg, "netmask"); break;
+ case 'p':
+ h->curint->peer = ADDR (arg, "peer"); break;
case 'g':
h->curint->gateway = ADDR (arg, "gateway"); break;
@@ -244,7 +248,7 @@ parse_opt (int opt, char *arg, struct argp_state *state)
for (in = h->interfaces; in < h->interfaces + h->num_interfaces; in++)
if (in->address != INADDR_NONE || in->netmask != INADDR_NONE)
{
- err = configure_device (in->device, in->address, in->netmask);
+ err = configure_device (in->device, in->address, in->netmask, in->peer);
if (err)
FAIL (err, 16, 0, "cannot configure interface");
}
@@ -328,9 +332,9 @@ trivfs_append_args (struct trivfs_control *fsys, char **argz, size_t *argz_len)
error_t add_dev_opts (struct device *dev)
{
error_t err = 0;
- uint32_t addr, mask;
+ uint32_t addr, mask, peer;
- inquire_device (dev, &addr, &mask);
+ inquire_device (dev, &addr, &mask, &peer);
#define ADD_OPT(fmt, args...) \
do { char buf[100]; \
@@ -347,7 +351,8 @@ trivfs_append_args (struct trivfs_control *fsys, char **argz, size_t *argz_len)
ADD_ADDR_OPT ("address", addr);
if (mask != INADDR_NONE)
ADD_ADDR_OPT ("netmask", mask);
-
+ if (peer != addr)
+ ADD_ADDR_OPT ("peer", peer);
/* XXX how do we figure out the default gateway? */
#undef ADD_ADDR_OPT