tip ernie or tip ernie -1200 getphonenumberbyname("ernie") # only if not number (note: will just # pass back numbers if given unchanged) if (-1) -> p_errno serial_connect(errorfd, pnstruct, optstruct, optlen) if (-1) -> c_errno ... close (fd) cancel_serial_connect(pnstruct) ... serial_connect socket connect /dev/connect sendmsg ... iov -> pnstruct,optstruct accrights-> errorfd if want to abort request, send out of band data msg cancel_serial_connect(pnstruct) recvmsg ... iov -> optstruct,errorstruct accrights-> serialfd rtn serialfd don't close socket, keep in table associated with fd other sub calls will ref fd to find socket, while connectd will ref socket to identify specific request. after finish call it is safe to close socket. connectd will assume fd is deallocated when socket is closed, and will reallocate resource. connectd does not maintain a fd on an open resource, it only keeps the socket to the process. the daemon will do a vhangup on a tty before issuing it to a drop request. connectd socket bind /dev/connect listen accept recvmsg for all dialout lines check lines(5) if a line can be used can work at desired baudrate can call this kind of phone number check if being used if one found that can work & is not busy, use if found but busy, return notyet if not found, return notavailable translate phonenumber to number per line open non-blocking, flock, ioctl to disable carrier (kern mod) set baud rate and line parameters fork rearrange filedescriptors setuid/geteuid? exec /etc/connector/hayes linestate=CONNECTINGOUTBOUND ... for all in/out lines block on select writeable (kern mod) if one becomes writable (CARRIER), fork a getty and mark linestate = CONNECTINGINBOUND else linestate = UNCONNECTED ... wait/sigchild if linestate == UNCONNECTED syslog error if linestate == CONNECTINGINBOUND forceclose, mark line SLEEPINGTWOSEC if linestate == CONNECTINGOUTBOUND if errorstat !=0 forceclose, mark line SLEEPINGTWOSEC else linestate = CONNECTEDOUTBOUND sendmsg (samemesgfdmt, with fd) ... sigurg recvmsg if existing request on socket, killoff pid if any, forceclose line close socket states UNUSED or MONITORED <--> OPENINBOUND ^ | CONNECTOROPEN | OPENOUTBOUND DOOPTION | CONNECTORDROP UNUSED: not open by anyone (we know), (ttys:out) MONITORED: open by us, looking for carrier via select writable or exception OPENINBOUND: we do inits and some of gettys functions (vhangup), and exec getty while closing fd's. we find out resource is reusable by child status return or sigcild. CONNECTOROPEN: we processed a request, found a connector and asked it to do our bidding. like getty, but on positve conculsion, we move to next state. we have a open socket per request and an open fd OPENOUTBOUND: we have passed back to user program a filedesc, and it is in possesion of fd which we don't have. but we have his socket, and we know what resource he has by virtue of the socket. DOOPTION: we have recieved another request from user, and we have passed the option off with the fd from user to connector program to implement the function. this is like connectoropen, but we don't clean off the descriptors before use. CONNECTORDROP: we recieved either a EPIPE/SIGPIPE, select returned a EBAF, or... or we processed a finish request, and we vhangup'd the line and spawned a connector with fd to do a drop. by this time we forsure don't have a open socket. ABORT: an abort request recieved at any time causes any outstanding connector to be killed (SIGTERM, followed by SIGKILL), and any outstanding request to be responded with negative result. if not connected, then we go into connector drop state. abort's are not acked! aborts on no connector active aare ignored. methods: tty/modem/pots - get a tty, and a modem, and a final number --> dial alloc a tty tty/alloc config the line for modem tty/setline modemdialingopts check for presence of modem tty/modem/hayes probe config generic hayes stuff tty/modem/hayes config modemopts config courier stuff tty/modem/hayes courier translate number tty/modem/pots/translate dial number tty/modem/hayes dial accept connection tty/modem/hayes connect change line for connection (speed?) tty/setline connectionopts done config the line for incoming tty/setline incomingmodemopts check for presence of modem tty/modem/hayes probe config generic hayes stuff tty/modem/hayes config modemopts config courier stuff tty/modem/hayes courier config incoming hayes stuff tty/modem/hayes config incoming line select **** accept connection tty/modem/hayes inconnect change line for connection (speed?) tty/setline inconnectionopts /etc/connect/ connectd tty/ lines alloc=? modem/ hayes hayes=type/ courier trailblaizer pots/ rewrite number fts/ datakit/ tty/ modem/ pots/