void CActiveConsole::RunL() { // key has been pressed TChar ch = iConsole.KeyCode(); TUint8 error = KHCIOK; TUint16 opcode; TBTDevAddr remoteaddr(MAKE_TINT64(0x0002, 0x5bff0a1e)); // an example addr TBTDevAddr remoteaddr2(MAKE_TINT64(0x0002, 0x5bff0a1e)); // an example addr // Change the errors for interesting tests of stack behaviour switch (ch) { case 's': error = KHCICommandDisallowed; opcode = KCreateACLConnectionOpcode; iEmulator.CommandStatusEvent(opcode, error); break; case 'n': opcode = KNoOpcode; iEmulator.CommandStatusEvent(opcode, error); break; case 'a': opcode = KReadBdaddrOpcode; iEmulator.ReadBDAddrCompleteEvent(error); break; case 'A': opcode = KReadLocalNameOpcode; iEmulator.ReadLocalNameCompleteEvent(error); break; case 'b': opcode = KReadBufferSizeOpcode; iEmulator.ReadBufferSizeCompleteEvent(error); break; case 'B': opcode = KHostBufferSizeOpcode; iEmulator.DefaultCommandCompleteEvent(opcode, error); break; case 'p': opcode = KWritePageTimeoutOpcode; iEmulator.DefaultCommandCompleteEvent(opcode, error); break; case 'e': opcode = KWriteScanEnableOpcode; iEmulator.DefaultCommandCompleteEvent(opcode, error); break; case 'h': opcode = KSetHostControllerToHostFlowOpcode; iEmulator.DefaultCommandCompleteEvent(opcode, error); break; case 'c': opcode = KWriteConnectionAcceptTimeoutOpcode; iEmulator.DefaultCommandCompleteEvent(opcode, error); break; case 'r': opcode = KResetOpcode; iEmulator.DefaultCommandCompleteEvent(opcode, error); break; case 'l': opcode = KChangeLocalNameOpcode; iEmulator.DefaultCommandCompleteEvent(opcode, error); break; case 'i': opcode = KInquiryOpcode; iEmulator.DefaultCommandCompleteEvent(opcode, error); break; case 'I': iEmulator.InquiryCompleteEvent(error); break; case 'C': iEmulator.ConnectionCompleteEvent(error, EACLLink); break; case 'd': iEmulator.DisconnectionCompleteEvent(error, KEmulatedBaseConnectionHandle, KHCIEmulatedDisconnectionReason); break; case 'k': iEmulator.ConnectionRequestEvent(remoteaddr, KEmulatedInquiryClassOfDevice, EACLLink); break; case 'K': iEmulator.ConnectionRequestEvent(remoteaddr2, KEmulatedInquiryNullClassOfDevice, EACLLink); break; case 'x': case 'X': iEmulator.HardwareErrorEvent(); break; case 'V': case 'v': iEmulator.SpecificVendorDebugEvent(); break; case '1': //First used for reproducing DEF074193 //Sends a SCO connection request. A DisconnectComplete event will //be sent in response to the resulting //HCI_Accept_Connection_Request command. iEmulator.ConnectionRequestEvent(KDeviceAddresses[0], KEmulatedInquiryNullClassOfDevice, ESCOLink); break; case EKeyEscape: { iEmulator.Stop(); goto end; } default: iConsole.Printf(_L("Unknown command\r\n")); } // schedule another key press RequestKey(); end: return; }
void main(int argc, char **argv) { static char data[1024], dir[1024], ndir[1024]; int ctl, nctl, fd; verbose = 1; if(!verbose){ close(1); fd = open("/dev/null", O_WRONLY); if(fd != 1){ dup2(fd, 1); close(fd); } } argc--, argv++; printf("listen started\n"); ctl = announce9(argv[0], dir, 0); if(ctl < 0){ fprintf(stderr, "announce %s: %r", argv[0]); exit(1); } for(;;){ nctl = listen9(dir, ndir, 0); if(nctl < 0){ fprintf(stderr, "listen %s: %r", argv[0]); exit(1); } //switch(rfork(RFFDG|RFPROC|RFNOWAIT|RFENVG|RFNAMEG|RFNOTEG)){ switch(fork()){ case -1: reject9(nctl, ndir, "host overloaded"); close(nctl); continue; case 0: fd = accept9(nctl, ndir); if(fd < 0){ fprintf(stderr, "accept %s: can't open %s/data: %r\n", argv[0], ndir); exit(1); } printf("incoming call for %s from %s in %s\n", argv[0], remoteaddr(ndir), ndir); //fprintf(nctl, "keepalive"); close(ctl); close(nctl); //putenv("net", ndir); /* this is for children that open /dev/cons. Too bad. snprintf(data, sizeof data, "%s/data", ndir); bind(data, "/dev/cons", MREPL); */ dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); close(fd); execv(argv[1], argv+1); // if(argv[1][0] != '/') // exec(smprintf("%s", argv[1]), argv+1); fprintf(stderr, "exec: %r\n"); exit(1); default: /* reap any available children */ while (waitpid(-1, 0, WNOHANG) > 0) ; close(nctl); break; } } }
void main(int argc, char **argv) { int fd; char *arg, cmdbuf[1024]; Cmd *c; rfork(RFNAMEG); Binit(&in, 0, OREAD); Binit(&out, 1, OWRITE); ARGBEGIN{ case 'a': loggedin = 1; if(readmbox(EARGF(usage())) < 0) exits(nil); break; case 'd': debug++; if((fd = create(EARGF(usage()), OWRITE, 0666)) >= 0 && fd != 2){ dup(fd, 2); close(fd); } break; case 'p': passwordinclear = 1; break; case 'r': strecpy(tmpaddr, tmpaddr+sizeof tmpaddr, EARGF(usage())); if(arg = strchr(tmpaddr, '!')) *arg = '\0'; peeraddr = tmpaddr; break; case 't': tlscert = readcert(EARGF(usage()), &ntlscert); if(tlscert == nil){ senderr("cannot read TLS certificate: %r"); exits(nil); } break; }ARGEND /* do before TLS */ if(peeraddr == nil) peeraddr = remoteaddr(0,0); hello(); while(Bflush(&out), getcrnl(cmdbuf, sizeof cmdbuf) > 0){ arg = nextarg(cmdbuf); for(c=cmdtab; c->name; c++) if(cistrcmp(c->name, cmdbuf) == 0) break; if(c->name == 0){ senderr("unknown command %s", cmdbuf); continue; } if(c->needauth && !loggedin){ senderr("%s requires authentication", cmdbuf); continue; } (*c->f)(arg); } exits(nil); }