/*
* dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2015 Roy Marples <roy@marples.name>
+ * Copyright (c) 2006-2016 Roy Marples <roy@marples.name>
* All rights reserved
* Redistribution and use in source and binary forms, with or without
}
int
-control_open(struct dhcpcd_ctx *ctx, const char *ifname)
+control_open(const char *ifname)
{
struct sockaddr_un sa;
+ int fd;
- if ((ctx->control_fd = make_sock(&sa, ifname, 0)) != -1) {
+ if ((fd = make_sock(&sa, ifname, 0)) != -1) {
socklen_t len;
- int r;
len = (socklen_t)SUN_LEN(&sa);
- r = connect(ctx->control_fd, (struct sockaddr *)&sa, len);
- if (r == -1) {
- close(ctx->control_fd);
- ctx->control_fd = -1;
+ if (connect(fd, (struct sockaddr *)&sa, len) == -1) {
+ close(fd);
+ fd = -1;
}
}
- return ctx->control_fd;
+ return fd;
}
ssize_t
/*
* dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2015 Roy Marples <roy@marples.name>
+ * Copyright (c) 2006-2016 Roy Marples <roy@marples.name>
* All rights reserved
* Redistribution and use in source and binary forms, with or without
int control_start(struct dhcpcd_ctx *, const char *);
int control_stop(struct dhcpcd_ctx *);
-int control_open(struct dhcpcd_ctx *, const char *);
+int control_open(const char *);
ssize_t control_send(struct dhcpcd_ctx *, int, char * const *);
int control_queue(struct fd_list *fd, char *data, size_t data_len, uint8_t fit);
void control_close(struct dhcpcd_ctx *ctx);
const char *siga = NULL;
#endif
- int seq;
- seq = INT_MAX;
- printf ("%d\n", seq);
- seq++;
- printf ("%u\n", (uint32_t)seq);
-
/* Test for --help and --version */
if (argc > 1) {
if (strcmp(argv[1], "--help") == 0) {
!(ctx.options & DHCPCD_TEST))
{
#endif
- if (ctx.options & DHCPCD_MASTER)
- i = -1;
- else
- i = control_open(&ctx, argv[optind]);
- if (i == -1)
- i = control_open(&ctx, NULL);
- if (i != -1) {
+ if (!(ctx.options & DHCPCD_MASTER))
+ ctx.control_fd = control_open(argv[optind]);
+ if (ctx.control_fd == -1)
+ ctx.control_fd = control_open(NULL);
+ if (ctx.control_fd != -1) {
logger(&ctx, LOG_INFO,
"sending commands to master dhcpcd process");
len = control_send(&ctx, argc, argv);