]>
git.zerfleddert.de Git - hmcfgusb/blob - hmland.c
6dc2cac430c44cba87596eb06eb0c5c015ffd7aa
1 /* HM-CFG-LAN emulation for HM-CFG-USB
3 * Copyright (c) 2013 Michael Gernoth <michael@gernoth.net>
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
33 #include <sys/types.h>
34 #include <sys/socket.h>
38 #include <netinet/in.h>
39 #include <arpa/inet.h>
40 #include <libusb-1.0/libusb.h>
46 #define PID_FILE "/var/run/hmland.pid"
48 #define DEFAULT_REBOOT_SECONDS 86400
52 static int impersonate_hmlanif
= 0;
54 static int verbose
= 0;
55 static int reboot_seconds
= 0;
56 static int reboot_at_hour
= -1;
57 static int reboot_at_minute
= -1;
58 static int reboot_set
= 0;
63 struct queued_rx
*next
;
66 static struct queued_rx
*qrx
= NULL
;
67 static int wait_for_h
= 0;
69 #define FLAG_LENGTH_BYTE (1<<0)
70 #define FLAG_FORMAT_HEX (1<<1)
71 #define FLAG_COMMA_BEFORE (1<<2)
72 #define FLAG_COMMA_AFTER (1<<3)
73 #define FLAG_NL (1<<4)
74 #define FLAG_IGNORE_COMMAS (1<<5)
76 #define CHECK_SPACE(x) if ((*outpos + x) > outend) { fprintf(stderr, "Not enough space!\n"); return 0; }
77 #define CHECK_AVAIL(x) if ((*inpos + x) > inend) { fprintf(stderr, "Not enough input available!\n"); return 0; }
79 static void print_timestamp(FILE *f
)
85 gettimeofday(&tv
, NULL
);
86 tmp
= localtime(&tv
.tv_sec
);
87 memset(ts
, 0, sizeof(ts
));
88 strftime(ts
, sizeof(ts
)-1, "%Y-%m-%d %H:%M:%S", tmp
);
89 fprintf(f
, "%s.%06ld: ", ts
, tv
.tv_usec
);
92 static int format_part_out(uint8_t **inpos
, int inlen
, uint8_t **outpos
, int outlen
, int len
, int flags
)
94 const uint8_t nibble
[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
95 'A', 'B', 'C', 'D', 'E', 'F'};
96 uint8_t *buf_out
= *outpos
;
97 uint8_t *outend
= *outpos
+ outlen
;
98 uint8_t *inend
= *inpos
+ inlen
;
101 if (flags
& FLAG_COMMA_BEFORE
) {
107 if (flags
& FLAG_LENGTH_BYTE
) {
113 if (flags
& FLAG_FORMAT_HEX
) {
116 for (i
= 0; i
< len
; i
++) {
117 **outpos
= nibble
[((**inpos
) & 0xf0) >> 4];
119 **outpos
= nibble
[((**inpos
) & 0xf)];
120 *inpos
+= 1; *outpos
+= 1;
125 memcpy(*outpos
, *inpos
, len
);
130 if (flags
& FLAG_COMMA_AFTER
) {
136 if (flags
& FLAG_NL
) {
144 return *outpos
- buf_out
;
147 static uint8_t ascii_to_nibble(uint8_t a
)
151 if ((a
>= '0') && (a
<= '9')) {
153 } else if ((a
>= 'A') && (a
<= 'F')) {
155 } else if ((a
>= 'a') && (a
<= 'f')) {
162 static int parse_part_in(uint8_t **inpos
, int inlen
, uint8_t **outpos
, int outlen
, int flags
)
164 uint8_t *buf_out
= *outpos
;
165 uint8_t *outend
= *outpos
+ outlen
;
166 uint8_t *inend
= *inpos
+ inlen
;
168 if (flags
& FLAG_LENGTH_BYTE
) {
176 if (!(flags
& FLAG_IGNORE_COMMAS
))
185 **outpos
= (len
/ 2);
189 while(*inpos
< inend
) {
190 if (**inpos
== ',') {
192 if (!(flags
& FLAG_IGNORE_COMMAS
))
201 **outpos
= ascii_to_nibble(**inpos
) << 4;
203 **outpos
|= ascii_to_nibble(**inpos
);
204 *inpos
+= 1; *outpos
+= 1;
207 return *outpos
- buf_out
;
210 static int hmlan_format_out(uint8_t *buf
, int buf_len
, void *data
)
216 int fd
= *((int*)data
);
222 memset(out
, 0, sizeof(out
));
226 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 1, 0);
229 if (impersonate_hmlanif
) {
234 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 0, FLAG_LENGTH_BYTE
);
235 version
= inpos
[0] << 8;
237 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 2, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
238 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 0, FLAG_COMMA_BEFORE
| FLAG_LENGTH_BYTE
);
239 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 3, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
240 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 3, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
241 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 4, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
242 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 2, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
| FLAG_NL
);
245 int new_reboot_seconds
;
247 if (version
< 0x03c7) {
248 new_reboot_seconds
= DEFAULT_REBOOT_SECONDS
;
250 new_reboot_seconds
= 0;
253 if (verbose
&& new_reboot_seconds
&& (reboot_seconds
!= new_reboot_seconds
))
254 printf("Rebooting in %u seconds due to old firmware (0.%d)\n",
255 new_reboot_seconds
, version
);
257 reboot_seconds
= new_reboot_seconds
;
262 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 3, FLAG_FORMAT_HEX
);
263 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 2, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
264 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 4, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
265 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 1, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
266 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 2, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
267 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 0, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
| FLAG_LENGTH_BYTE
| FLAG_NL
);
271 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 4, FLAG_FORMAT_HEX
);
272 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 2, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
273 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 4, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
274 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 1, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
275 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 2, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
276 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 0, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
| FLAG_LENGTH_BYTE
| FLAG_NL
);
280 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 1, FLAG_FORMAT_HEX
);
281 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 1, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
282 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 1, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
);
283 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 1, FLAG_FORMAT_HEX
| FLAG_COMMA_BEFORE
| FLAG_NL
);
287 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 1, FLAG_FORMAT_HEX
| FLAG_NL
);
291 format_part_out(&inpos
, (buf_len
-(inpos
-buf
)), &outpos
, (sizeof(out
)-(outpos
-out
)), buf_len
-1, FLAG_FORMAT_HEX
| FLAG_NL
);
292 hexdump(buf
, buf_len
, "Unknown> ");
296 /* Queue packet until first respone to 'K' is received */
297 if (wait_for_h
&& buf
[0] != 'H') {
298 struct queued_rx
**rxp
= &qrx
;
301 rxp
= &((*rxp
)->next
);
303 *rxp
= malloc(sizeof(struct queued_rx
));
309 memset(*rxp
, 0, sizeof(struct queued_rx
));
310 (*rxp
)->len
= outpos
-out
;
311 (*rxp
)->rx
= malloc((*rxp
)->len
);
316 memset((*rxp
)->rx
, 0, (*rxp
)->len
);
317 memcpy((*rxp
)->rx
, out
, (*rxp
)->len
);
325 print_timestamp(stdout
);
327 for (i
= 0; i
< outpos
-out
-2; i
++)
328 printf("%c", out
[i
]);
332 w
= write(fd
, out
, outpos
-out
);
338 /* Send all queued packets */
340 struct queued_rx
*curr_rx
= qrx
;
341 struct queued_rx
*last_rx
;
347 print_timestamp(stdout
);
349 for (i
= 0; i
< curr_rx
->len
-2; i
++)
350 printf("%c", curr_rx
->rx
[i
]);
354 w
= write(fd
, curr_rx
->rx
, curr_rx
->len
);
359 curr_rx
= curr_rx
->next
;
373 static int hmlan_parse_in(int fd
, void *data
)
375 struct hmcfgusb_dev
*dev
= data
;
377 uint8_t out
[0x40]; //FIXME!!!
384 memset(buf
, 0, sizeof(buf
));
386 r
= read(fd
, buf
, sizeof(buf
)-1);
388 uint8_t *inend
= buf
+ r
;
392 while (inpos
< inend
) {
393 uint8_t *instart
= inpos
;
395 if ((*inpos
== '\r') || (*inpos
== '\n')) {
402 last
= inend
- inpos
;
404 for (i
= 0; i
< last
; i
++) {
405 if ((inpos
[i
] == '\r') || (inpos
[i
] == '\n')) {
415 print_timestamp(stdout
);
417 for (i
= 0; i
< last
; i
++)
418 printf("%c", instart
[i
]);
422 memset(out
, 0, sizeof(out
));
423 *outpos
++ = *inpos
++;
427 parse_part_in(&inpos
, (last
-(inpos
-instart
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 0);
428 parse_part_in(&inpos
, (last
-(inpos
-instart
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 0);
429 parse_part_in(&inpos
, (last
-(inpos
-instart
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 0);
430 parse_part_in(&inpos
, (last
-(inpos
-instart
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 0);
431 parse_part_in(&inpos
, (last
-(inpos
-instart
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 0);
432 parse_part_in(&inpos
, (last
-(inpos
-instart
)), &outpos
, (sizeof(out
)-(outpos
-out
)), FLAG_LENGTH_BYTE
);
435 parse_part_in(&inpos
, (last
-(inpos
-instart
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 0);
436 parse_part_in(&inpos
, (last
-(inpos
-instart
)), &outpos
, (sizeof(out
)-(outpos
-out
)), 0);
437 parse_part_in(&inpos
, (last
-(inpos
-instart
)), &outpos
, (sizeof(out
)-(outpos
-out
)), FLAG_LENGTH_BYTE
);
440 parse_part_in(&inpos
, (last
-(inpos
-instart
)), &outpos
, (sizeof(out
)-(outpos
-out
)), FLAG_IGNORE_COMMAS
);
444 hmcfgusb_send(dev
, out
, sizeof(out
), 1);
447 if (errno
!= ECONNRESET
)
457 static int comm(int fd_in
, int fd_out
, int master_socket
, int flags
)
459 struct hmcfgusb_dev
*dev
;
460 uint8_t out
[0x40]; //FIXME!!!
463 hmcfgusb_set_debug(debug
);
465 dev
= hmcfgusb_init(hmlan_format_out
, &fd_out
);
467 fprintf(stderr
, "Can't initialize HM-CFG-USB!\n");
471 if (dev
->bootloader
) {
473 printf("HM-CFG-USB in bootloader mode, restarting in normal mode...\n");
475 hmcfgusb_leave_bootloader(dev
);
482 if ((reboot_at_hour
!= -1) && (reboot_at_minute
!= -1)) {
487 tm_s
= localtime(&tm
);
493 tm_s
->tm_hour
= reboot_at_hour
;
494 tm_s
->tm_min
= reboot_at_minute
;
498 reboot_seconds
= tm
- dev
->opened_at
;
500 while (reboot_seconds
<= 0)
501 reboot_seconds
+= 86400;
504 if (verbose
&& reboot_seconds
)
505 printf("Rebooting in %u seconds\n", reboot_seconds
);
508 if (!hmcfgusb_add_pfd(dev
, fd_in
, POLLIN
)) {
509 fprintf(stderr
, "Can't add client to pollfd!\n");
514 if (master_socket
>= 0) {
515 if (!hmcfgusb_add_pfd(dev
, master_socket
, POLLIN
)) {
516 fprintf(stderr
, "Can't add master_socket to pollfd!\n");
522 memset(out
, 0, sizeof(out
));
525 hmcfgusb_send_null_frame(dev
, 1);
526 hmcfgusb_send(dev
, out
, sizeof(out
), 1);
531 fd
= hmcfgusb_poll(dev
, 1000); /* Wakeup device/bus at least once a second */
533 if (fd
== master_socket
) {
536 client
= accept(master_socket
, NULL
, 0);
538 shutdown(client
, SHUT_RDWR
);
542 if (hmlan_parse_in(fd
, dev
) <= 0) {
546 } else if (fd
== -1) {
548 if (errno
!= ETIMEDOUT
) {
549 perror("hmcfgusb_poll");
552 /* periodically wakeup the device */
553 hmcfgusb_send_null_frame(dev
, 1);
555 memset(out
, 0, sizeof(out
));
557 hmcfgusb_send(dev
, out
, sizeof(out
), 1);
563 if (reboot_seconds
&& ((dev
->opened_at
+ reboot_seconds
) <= time(NULL
))) {
565 printf("HM-CFG-USB running since %lu seconds, rebooting now...\n",
566 time(NULL
) - dev
->opened_at
);
568 hmcfgusb_enter_bootloader(dev
);
576 void sigterm_handler(int sig
)
578 if (unlink(PID_FILE
) == -1)
579 perror("Can't remove PID file");
584 #define FLAG_DAEMON (1 << 0)
585 #define FLAG_PID_FILE (1 << 1)
587 static int socket_server(char *iface
, int port
, int flags
)
589 struct sigaction sact
;
590 struct sockaddr_in sin
;
595 if (flags
& FLAG_DAEMON
) {
596 FILE *pidfile
= NULL
;
598 if (flags
& FLAG_PID_FILE
) {
601 fd
= open(PID_FILE
, O_CREAT
| O_EXCL
| O_WRONLY
, 0644);
603 if (errno
== EEXIST
) {
605 pidfile
= fopen(PID_FILE
, "r");
607 perror("PID file " PID_FILE
" already exists, already running?");
611 if (fscanf(pidfile
, "%u", &old_pid
) != 1) {
613 fprintf(stderr
, "Can't read old PID from " PID_FILE
", already running?\n");
619 fprintf(stderr
, "Already running with PID %u according to " PID_FILE
"!\n", old_pid
);
622 perror("Can't create PID file " PID_FILE
);
626 pidfile
= fdopen(fd
, "w");
628 perror("Can't reopen PID file fd");
632 memset(&sact
, 0, sizeof(sact
));
633 sact
.sa_handler
= sigterm_handler
;
635 if (sigaction(SIGTERM
, &sact
, NULL
) == -1) {
636 perror("sigaction(SIGTERM)");
644 fprintf(pidfile
, "%u\n", pid
);
648 printf("Daemon with PID %u started!\n", pid
);
650 } else if (pid
< 0) {
659 memset(&sact
, 0, sizeof(sact
));
660 sact
.sa_handler
= SIG_IGN
;
662 if (sigaction(SIGPIPE
, &sact
, NULL
) == -1) {
663 perror("sigaction(SIGPIPE)");
667 impersonate_hmlanif
= 1;
669 sock
= socket(PF_INET
, SOCK_STREAM
, IPPROTO_TCP
);
671 perror("Can't open socket");
676 if (setsockopt(sock
, SOL_SOCKET
, SO_REUSEADDR
, &n
, sizeof(n
)) == -1) {
677 perror("Can't set socket options");
681 memset(&sin
, 0, sizeof(sin
));
682 sin
.sin_family
= AF_INET
;
683 sin
.sin_port
= htons(port
);
685 sin
.sin_addr
.s_addr
= htonl(INADDR_ANY
);
687 if (inet_pton(AF_INET
, iface
, &(sin
.sin_addr
.s_addr
)) != 1) {
688 fprintf(stderr
, "Can't convert IP %s, aborting!\n", iface
);
693 if (bind(sock
, (struct sockaddr
*)&sin
, sizeof(sin
)) == -1) {
694 perror("Can't bind socket");
698 if (listen(sock
, 1) == -1) {
699 perror("Can't listen on socket");
704 struct sockaddr_in csin
;
707 in_addr_t client_addr
;
709 memset(&csin
, 0, sizeof(csin
));
710 csinlen
= sizeof(csin
);
711 client
= accept(sock
, (struct sockaddr
*)&csin
, &csinlen
);
713 perror("Couldn't accept client");
717 /* FIXME: getnameinfo... */
718 client_addr
= ntohl(csin
.sin_addr
.s_addr
);
721 print_timestamp(stdout
);
722 printf("Client %d.%d.%d.%d connected!\n",
723 (client_addr
& 0xff000000) >> 24,
724 (client_addr
& 0x00ff0000) >> 16,
725 (client_addr
& 0x0000ff00) >> 8,
726 (client_addr
& 0x000000ff));
729 comm(client
, client
, sock
, flags
);
731 shutdown(client
, SHUT_RDWR
);
735 print_timestamp(stdout
);
736 printf("Connection to %d.%d.%d.%d closed!\n",
737 (client_addr
& 0xff000000) >> 24,
738 (client_addr
& 0x00ff0000) >> 16,
739 (client_addr
& 0x0000ff00) >> 8,
740 (client_addr
& 0x000000ff));
748 static int interactive_server(int flags
)
750 if (!comm(STDIN_FILENO
, STDOUT_FILENO
, -1, flags
))
756 void hmlan_syntax(char *prog
)
758 fprintf(stderr
, "Syntax: %s options\n\n", prog
);
759 fprintf(stderr
, "Possible options:\n");
760 fprintf(stderr
, "\t-D\t\tdebug mode\n");
761 fprintf(stderr
, "\t-d\t\tdaemon mode\n");
762 fprintf(stderr
, "\t-h\t\tthis help\n");
763 fprintf(stderr
, "\t-i\t\tinteractive mode (connect HM-CFG-USB to terminal)\n");
764 fprintf(stderr
, "\t-l ip\t\tlisten on given IP address only (for example 127.0.0.1)\n");
765 fprintf(stderr
, "\t-P\t\tcreate PID file " PID_FILE
" in daemon mode\n");
766 fprintf(stderr
, "\t-p n\t\tlisten on port n (default: 1000)\n");
767 fprintf(stderr
, "\t-r n\t\treboot HM-CFG-USB after n seconds (0: no reboot, default: %u if FW < 0.967, 0 otherwise)\n", DEFAULT_REBOOT_SECONDS
);
768 fprintf(stderr
, "\t hh:mm\treboot HM-CFG-USB daily at hh:mm\n");
769 fprintf(stderr
, "\t-v\t\tverbose mode\n");
770 fprintf(stderr
, "\t-V\t\tshow version (" VERSION
")\n");
774 int main(int argc
, char **argv
)
783 while((opt
= getopt(argc
, argv
, "DdhiPp:Rr:l:vV")) != -1) {
790 flags
|= FLAG_DAEMON
;
796 flags
|= FLAG_PID_FILE
;
799 port
= strtoul(optarg
, &ep
, 10);
801 fprintf(stderr
, "Can't parse port!\n");
806 fprintf(stderr
, "-R is no longer needed (1s wakeup is default)\n");
809 reboot_seconds
= strtoul(optarg
, &ep
, 10);
812 reboot_at_hour
= reboot_seconds
;
814 reboot_at_minute
= strtoul(ep
, &ep
, 10);
816 fprintf(stderr
, "Can't parse reboot-time!\n");
822 fprintf(stderr
, "Can't parse reboot-timeout!\n");
835 printf("hmland " VERSION
"\n");
836 printf("Copyright (c) 2013 Michael Gernoth\n\n");
842 hmlan_syntax(argv
[0]);
849 return interactive_server(flags
);
851 return socket_server(iface
, port
, flags
);