+
+ sendline(fd, "%d %d %d", CONTROL, REQ_SET_DEBUG, debuglevel);
+ if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %d %d", &code, &req, &origlevel) != 3 || code != CONTROL || req != REQ_SET_DEBUG) {
+ fprintf(stderr, "Could not purge tinc daemon\n");
+ return 1;
+ }
+
+ fprintf(stderr, "Old level %d, new level %d\n", origlevel, debuglevel);
+ return 0;
+ }
+
+ if(!strcasecmp(argv[optind], "connect")) {
+ if(argc != optind + 2) {
+ fprintf(stderr, "Invalid arguments.\n");
+ return 1;
+ }
+ char *name = argv[optind + 1];
+
+ sendline(fd, "%d %d %s", CONTROL, REQ_CONNECT, name);
+ if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_CONNECT || result) {
+ fprintf(stderr, "Could not connect to %s\n", name);
+ return 1;
+ }
+ return 0;
+ }
+
+ if(!strcasecmp(argv[optind], "disconnect")) {
+ if(argc != optind + 2) {
+ fprintf(stderr, "Invalid arguments.\n");
+ return 1;
+ }
+ char *name = argv[optind + 1];
+
+ sendline(fd, "%d %d %s", CONTROL, REQ_DISCONNECT, name);
+ if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_DISCONNECT || result) {
+ fprintf(stderr, "Could not disconnect %s\n", name);
+ return 1;
+ }
+ return 0;
+ }
+
+#ifdef HAVE_CURSES
+ if(!strcasecmp(argv[optind], "top")) {
+ top(fd);
+ return 0;
+ }
+#endif
+
+ if(!strcasecmp(argv[optind], "pcap")) {
+ pcap(fd, stdout);
+ return 0;