-+-+-+-+-+-+-+-+ START OF PART 3 -+-+-+-+-+-+-+-+ V\3B06\380B`20is`20supported`20(called`20"lisChannel"); X\5B03even`20though\6405actual`20network`20command(s)`20arrive`20\AD05\8E05 V\6907assigned`20to`20\1804\5604\3F0F`20mailbox`20(w/\2405NET:`20device;`20c V\9C07mbxC\9C08.`20`20The`20"chan"`20being\5804pass\6A08is`20\5B04all`20other V`20socket`20emulation`20routines`20dealing`20with`20\9C08issues`20(i.e.,\5D04 V\9904only`20non-client`20\E507)`20is`20\2004listen\4C04\FF08established`20in V\8507()\C103All X\5703references`20\B805e`20Net`20Comm\BF04Mailbox`20\4F08are`20internal\E809li Vbrary,\F105\5404\2604opaque\5408upper`20layer`20program. X`20*/ Xunsigned`20short Xaccept`20(chan,`20psock\0707_l) X`09u\2E0D\9605; X`09struct`20sockaddr`20*psock; X`09long\3E08; X`7B X`20`20`20`20\0404int`20status; X`09\0D04dvi_unit; X`09\6313nel\1912sC\7D0Dio_stat_blk`20iosb\1A0Adsc$descriptor_s`20ncbd;\1F09 X`09`7B X`09`09\5406buf_le\5604\1107code\0E04\A404*ret_c\110Bret_\2E07\0F04term; X`09`7D`20dviitm`20=`20`7B`204,`20DVI$_UNIT,`20`26d\E707,`200,`200`7D; X X#ifdef`20DNDEBUG X`20`20`20`20`09fprintf(stderr,`20"accept:`20start`20-`20passed`20chan`20%d`5Cn V",\0C05); X#endif`20/*\5208`20*/ X`09if`20(!ncb)`20\ED06\6107`20(\6211no`20ncb`20received!`5Cn"); X`09`09return`20-1\E104 X`09ncb`5Binfo_cnt`5D\E903'`5C0'; X\BD04\0404ncbd.dsc$w_length\2203\2E08\2613a_pointer\2703ncb\2213b_dtype`20= V`20DSC$K_DTYPE_T;\2A14class`20\2A08CLASS_S; X X\2704`09if`20(!mbx_created) X\1705`7B X\0705`09fprintf(stderr,`20"accept:`20error`20-`20mailbox`20not`20c\4306`20yet V`5Cn")\8D06`09`09exit()\0E07`7D X\A208status\9803SYS$ASSIGN`20(`26net_device,`20`26channel,`200,`20`26netcmd_mb Vx); X\B805VMSFAIL(\4A06))`20LIB$SIGNAL\1408; X`09\680DGETDVI`20(0,`20\5D0Ddviitm\0903iosb\13050,`200)\692C\DF05sChan\6C03 V\5D07>>4; X`09clearChanTable`20((sChan)); X`09\1609Info`5B(\1906`5D->unit`20=`20dvi_unit\2A1Bnodename\2E03DNETALLOC`20(NO VDNAMSIZ\6504bcopy`20((char`20*)`20ncb,`20\5020,`20info_cnt\DC08\AC19ser`20= V`20(strchr(\5922'=')`20+`201\5908*(\9B09\4428':\43052)\7903'`5C0'\4A31user,'/' V))\4209`09FD_SET(channel,`20allC\0C06s); X#ifdef`20DNDEBUG X`09fprintf(stderr,`20"accept:`20from`20Node:`20%s`20User\0905on`20c\4E06`20%d V`5Cn", X\B305`09C\EC20`20C\C41C\5508); X#endif X\5704\0404status\DF03SYS$QIOW`20(0,\2F08,`20IO$_ACCESS,`20`26iosb,`200,`200 V\0605`26ncbd,\100A0); X`09if(!VMSFAIL(status)`20`26`26`20!\1408iosb.s\1906) X`09`7B X`09`09ncb\8003NULL; X`09\9808return\8908; X`09`7D X`09if`20(\5C0F)`20LIB$SIGNAL`20(\1507\8705\2B0A\730D\300B\190D; X`09\7307-1; X`7D X X`0C X/* X`20*`20B`20routines:`20bcmp,`20bcopy,`20bzero\2204These`20\2608`20are`20declar Ved`20here`20in`20function`20form`20to`20provide\4004a`20global`20linker`20reso Vlu\2E08`20references`20in`20upper`20level`20code. X`20*/ Xint Xbcmp`20(s1,`20s2,`20l) X`09char`20*s1; X`09\0B072; X`09int`20l; X`7B X\F108(BCMP(\390A); X`7D X X`0C Xvoid`20* Xbcopy`20(s,`20d,\570C\5609d;\5513BCOPY(\3508\5207/*\F004bind(): X\0B07`20the`20NET`20channel`20to\1305correct`20object`20name\ED0B\3904(chan V\B603a,`20sa_len) X`09unsigned`20short\5405; X`09struct`20sockaddr`20*sa;\2C0B\BE04\4206\C305\0F05tatu\E404\3B07io_stat_blk V\0C03sb\1A0Adsc$descriptor_s`20nfbd;\1F1A*object_name; X X#ifdef`20DNDEBUG X`20`20`20`20`09fprintf(stderr,`20"bind:`20start`20-`20passed`20chan`20%d`5Cn", V`20chan); X#endif`20/*\5008`20*/ X\5304\0404nfbd.dsc$w_length`20=`20sizeof(nfb); X\2911a_pointer\2A03`26nfb\2313b_dtype`20=`20DSC$K_DTYPE_T;\2A14class\2A09CLASS V_S; X/* X`20*`20Bind`20to`20the`20declare\D605nel`20in\1705ChanTableInfo`20struct. X\E304`09object_name\6103nameFromPort`20(sa); X`09statu\7E04SYS$QIOW`20(0,\6205,`20IO$_ACPCONTROL,`20`26iosb,`200,`200\0D03nf Vbd,`20\620B\1A08\0604\5B04if`20(VMSFAIL(\6706)`20`7C`7C`20V\1307iosb.s\1806) V`20return`20-1; X#ifdef`20DNDEBUG X`20`20`20`20`09fprintf(stderr,`20"bind:`20on`20channel`20%d`20to`20%s`5Cn", V\C007\9C0B->dsc$a_pointer); X#endif X`09\79070; X`7D X X`0C Xint Xbzero`20(buf,`20size) X`09char`20*buf\D804nt\1705; X`7B X\3F08(BZERO\330B); X\5005\CD07NOTDEF X/* X`20*`20connect(): X\0E03supports\1708ing`20to`20a`20"socket"`20given`20the`20network\F509(from V`20\2806()) X`20*/ Xint X\4B07`20(chan,`20name\0606len) X`09unsigned`20short\4E05; X`09struct`20sockaddr`20*name; X`09\2E09\F904\4507\FC05int`09`09status\270Cshort`09objlen; X`09char`20*pncb\640Adsc$descriptor`20ncb_desc\2105atic`20s\2806io_stat_blk V\0C03sb\4218_s`20*objdsc; X`20`20`20`20\4708\7C06objstr`20=`20NULL;\2106\1A05hname`5B32`5D\1507\E104l`20= V`200; X X#ifdef`20DNDEBUG\2006fprintf(stderr,`20"connect:`20start`20-`20passed`20chan V`20%d`5Cn",\0C05); X#endif`20/*\5308`20*/ X\7606f`20(!\A406)`20\AC09DNETALLOC(NCBSIZE)\A506\0404\3205(pncb`20=`20initNCB( Vname,`20`26objlen,`20TASKOBJECT,\F805)))`20\7006`7B X\0705`09char`20*a\4303\7506\6006`09`09short`20*are\1C04`26name->sa_data`5B2 V`5D\270Fnode\27124`5D; X\AF08`09`09objdsc`20=`20nameFromPort`20(name\D607`09`09BCOPY(\B60Ca,`20strlen V\160B))\3008a`20+=\2013\4F0E\7906->dsc$a_pointer\5A0C\2115\650B\640A\2A16 V\2908*a\DE030x0;\1007sprintf`20(hname,`20"%d.%d::",`20*area,`20*node\4009pncb V\4203initNCB(\3506`26objlen,`20objstr,`20hname\3408`7D X\0705ncb_desc.dsc$w_length`20=`20\3C06\2C06\0404\280D\C109\2903pncb\2717b_dtyp Ve\2503DSC$K_DTYPE_T;\2E18class`20\2E08CLASS_S; X X\2F08status\2103SYS$QIOW`20(0,`20chan,`20IO$_ACCESS\F903iosb,`200,`200,`20 V\0303`26n\6807\140B0)\870Aif`20(!VMSFAIL(status))\6E0Aiosb.status\341F X`09`7B X#ifdef`20DNDEBUG X`09`09fprintf(stderr,`20"connect:`20Connection`20to`20%s`20on`20channel`20%d V`5Cn",`20pncb\E306); X#endif\8305`09`09DNETFREE`20(pncb\CE0B\0808return`200; X`09`7D\1D09else\2A11LIB$SIGNAL`20(\CB07; X`09\6111`09r\5206-1; X`7D X\8D06`20/*`20NOTDEF`20*/ X X`0C X/* X`20*`20c\DA06(): X\0E03supports\1708ing`20to`20a`20"socket"`20given`20the`20network\F305nel`20(f Vrom`20\2806()) X\6704int X\4B07`20(chan,`20name\0606len)\E209unsigned`20short\5505; X\1D08struct`20sockaddr`20*name\1F0A\3C09int\5A08; X`7B X\2008\1704\0C08\4F06atus\4013\7C06`20objlen; X\2008char`20*pncb\9311dsc$descriptor`20ncb_desc\280Catic\2F08io_stat_blk`20ios Vb\501F_s`20*objdsc\8D10objstr`20=`20DNETALLOC(NCBSIZE);\2B0Fhname;\1509int`20l V`20=`200;\280Fa;\8D0Ahort`20*p\0604=`20`26name->sa_data`5B0`5D\2911area\29122 V`5D\2911node\29124`5D; X X#ifdef`20DNDEBUG X\3908fprintf(stderr,`20"connect:`20start`20-`20passed\C504n`20%d`20p\6904 V\0803addr`20%d.%d`5Cn", X\5008\F40Bn,\E306,`20*area,`20*node); X#endif`20/*\8E08`20*/ X\3908BCOPY`20(TASKOBJECT,`20objstr,`20strlen(\1B0A)); X\3808hname\FC03NULL\160Aif`20((objdsc`20=`20nameFromPort`20(name))) X\2C08`7B X\C510\5408DNETALLOC(32\730B\0808a`20=`20\A406`20+\A513\3112BCOPY\9707->dsc$a_p Vointer,`20a,\4408\2115\F40C\8109+=\341E\3312*a\B5030x0;\1A11sprintf`20(hname, V`20"%d.%d::",`20*area,`20*node)\3A0A`7D X\0A08pncb\5803initNCB(\4106`26objlen,`20objstr,`20hname\400Bif\6D07)`20DNETFRE VE\1007\240Ancb_desc.dsc$w_length`20=`20\5C06\2817a_pointer\2903pncb\2717b_dtyp Ve\2503DSC$K_DTYPE_T;\2E18class`20\2E08CLASS_S; X X\2F08status\2103SYS$QIOW`20(0,`20chan,`20IO$_ACCESS,`20`26iosb,`200,`200,`20 V\0303`26n\6807\140B0)\870Aif`20(!VMSFAIL(status))\6E0Aiosb.status\341F\1E09 V`7B X#ifdef`20DNDEBUG\1909\0808fprintf(stderr,`20"connect:`20Connection`20to`20%s V`20on`20channel`20%d`5Cn",`20pncb\F806); X#endif\6111DNETFREE`20(pncb\ED0B\0808return`200\1A0A`7D X\0A08else\3111LIB$SIGNAL`20(\F107\3C0A\6F19\6707-1; X`7D X X`0C X/* X`20*`20ffs\0704Emulates`20the`20find`20first`20set`20function`20for`20UNIX. X`20*/ Xint Xffs`20(lw) X`09int`20lw; X`7B\0B06fp; X\0905sp`20=\DB04\0D06tatus\0D08z`20=`20sizeof(lw)*BITSPERBYTE; X X`09\2C06\2303lib$ffs(`26sp,`20`26sz,`20`26lw\0503fp); X`09if`20(VMSFAIL(status)) X`09\8603`09LIB$SIGNA\1909; X`09`09exit(\0A04`7D X`09return`20++fp; X`7D X X`0C X/* X`20*`20getdtablesize\1104Routine`20to`20r\3406the`20given`20size`20of`20\1204f Vile`20descriptor`20table`20(channel`20table). X`20*/ Xint X\680D() X`7B\9309FD_SETSIZE;`20`20/*`20***`20should`20be`20CHANNELCNT`20in`20SYSGEN V\5404\C30Ehostbyaddr\1104Socket`20library`20emulation`20r\DC15host`20nam\E608a V`20(DECnet)\4D04network`20address.\D205struct\3A05ent`20* X\840D`20(addr,`20length,`20family) X`09unsigned`20char`20*addr; X\160Aint`20length\1610\4206; X`7B X`09static`20\8210t`20=`20NULL; X X#ifdef`20DNDEBUG X`20`20`20`20`09fprintf(stderr,`20"g\B10C:`20start`5Cn"); X#endif`20/*`20\4207\F104\4505if`20(!t)\0D06`7B X\0705`09t\7903DNETALLOC`20(sizeof(st\9F0C)); X\2E07->h_name\360C(NODNAMSIZ); X\2407aliases`20\D608\3F0Baddrtype\1C03AF_DECnet;`20 X\1E07length\1C03\8A07long\570Bddr_lis\B616long)\2D13`5B0`5D`20\3023cput\9806 V\2B0Ctrlen(CPUTYPE)+1)\3009opsy\E204\2E12OPSYS)\2C07bcopy`20\4208,`20\6C0C, V`20\600F\320COPSYS\3007opsys\2E09\6006); X`20`20`20`20`09`7D X#ifdef`20DNDEBUG X\1605fprintf`20(stderr,`20"gethostbyaddr:`20DECnet`20address`20%d.%d`5Cn",`20 V\4006`09(short)`20*addr,`20\0F08(*(addr+sizeof(\1606))); X#endif\3E06sp\7E07t->h_name,`20"%d.%d",`20\5A17\5916\E507if`20(NCPfind`20(0, V`20t->h_addr_list`5B0`5D\1307name)`20<`200)\3806`7B X\CE06h_errno`20=`20HOST_NOT_FOUND\5F07`09return`200;\1006`7D X\1208t; X`7D X X`0C X/* X`20*`20gethostbyname\1104Routine`20to`20r\3107he`20network`20address`20of`20a V`20given`20node`20name. X`20*/ Xstruct`20hostent`20* X\620D`20(name) X`09char`20*name; X`7B X`09static`20\3D10t`20=`20NULL; X X#ifdef`20DNDEBUG X\D505fprintf(stderr,`20"g\6C0C:`20start`5Cn"); X#endif`20/*`20\4207\AC04\4505if`20(!t)\0D06`7B X\0705`09t\7903DNETALLOC`20(sizeof(st\9F0C)); X\2E07->h_\DF05\360B(NODNAMSIZ); X\2407aliases`20\D608\1708ddrtyp\3F04AF_DECnet;\1D08length\1B03\8507long\520Bdd Vr_lis\B116long)\2D13`5B0`5D`20\3023cput\9706\2B0Ctrlen(CPUTYPE)+1)\3009opsy V\DD04\2E12OPSYS)\2C07bcopy`20\4208,`20\6C0C,`20\600F\320COPSYS\3007opsys\2E09 V\6006); X`20`20`20`20`09`7D X`09\3207name\3107\0B06\3007name\8F06\3105if`20(NCPfind`20(0\3107addr_list`5B0 V`5D\440B)`20<`200)\3806`7B X\0705`09h_errno\FB03HOST_NOT_FOUND\5F07`09return`200;\A009\1207t; X`7D X X`0C X/* X`20*`20gethostname\0F04Routine`20to`20r\2F07he`20host`20node`20name. X`20*/ Xint X\3D0B`20(hn\EE05l)\7106char`20*hname\F208nt`20l; X\C106\0404short`20retlen`20=`200; X\1B09unsigned\2407iosb`5B4`5D;\3B0Atruct X\0F08\0404\580A\4114d_buflen\430A\2616itmcod\260E\B904*id_scsi\1B0F\410F*id_ V\D006\4212listen\400F`7D`20itmlst`20=`20`7Bl,`20SYI$_NODENAME,`20hname,`20`26r Vetlen,`200`7D; X X#ifdef`20DNDEBUG X\4604`09fprintf(stderr,`20"gethostname:`20start`5Cn"); X#endif`20/*`20\4007`20*/ X\8D08SYS$GETSYIW`20(0,`200,`200\7E03\A206,`20iosb\1506); X\3408hname`5Bretlen`5D`20=`20'`5C0'; X`09return`200; X`7D X X`0C X/* X`20*`20getpeername\0F04Routine`20to`20r\2F06the`20node`20address`20(DECnet) V`20associated`20with`20a`20given`20channel. X`20*/ Xint X\640B`20(chan,`20psock,\0706_l) X`09unsigned`20short`20chan; X`09struct`20sockaddr`20*psock; X`09long\0E07_l; X`7B X\F804\4510sChan`20=\4D05>>4; X X#ifdef`20DNDEBUG\3506fprintf(stderr,`20"g\AF0A:`20start`5Cn"); X#endif`20/*\4008\E004`09psock->sa_family`20=`20AF_DECnet;\6206if`20(!ChanTable VInfo`5BsChan`5D)`20return`20-1\2B07\D308\4603sizeof(long); X`09r\2A06NCPfind`20(sChan,`20psock,`20\5E14->nodename); X`7D X X`0C X/* X`20*`20gettimeofday X\1003Routine`20to\8F08the`20time`20in`20secs`20and`20millisecs X`20*/ Xint X\490C`20(timev) X`09struct\4005val`20*timev; X`7B X`09static\1A05b_t`20t; X X#ifdef`20DNDEBUG X`20`20`20`20`09fprintf(stderr,`20"g\680B:`20start`5Cn"); X#endif`20/*`20\4107\9A04`09f\BB05(`26t); X`09timev->tv_sec`20=`20t.time\190Dus\1A07millitm`20*`201000; X X`09return`200; X`7D X X`0C Xint Xhtonl`20(i) X`09int`20i\DA04\B704\0404\1104t1; X`09\09052; X X\1A08t2\6203i;`20 X\1108((char`20*)`26t1)`5B0`5D\1F03\130B2)`5B3`5D; X`09\260E1`5D\26112`5D; X\53162`5D\2D111`5D\53113`5D\26110`5D\FA0Bt1; X\FB05unsigned`20short Xhtons`20(i) X`09\1A0E`20i; X`7B\9309\1C0Ft1; X\3010t2; X X\3008t2\8F03i; X\D3160`5D\D3241`5D\D316\5408\DA10/* X`20*`20inet_addr X\0D03Routine`20to`20translate`20the`20network`20address`20into`20a`20longword V`20value. X`20*/ Xint Xin\5507`20(\3207) X`09c\9905\1007; X`7B X\1205`09*a;\0A08b`5B4`5D; X\AC04\2D06`09*tmpvm; X`09int`09i\0807j`20=`200;\0C06out; X X#ifdef`20DNDEBUG\4106fprintf(stderr,`20"i\9408:`20start`5Cn"); X#endif`20/*\3E08\C304\4105if(isalpha(*\C508)`20return`20-1; X`09b`5Bj++`5D\8E03\D409\3905tmpvm\1603DNETALLOC(strlen(a\4608\2907bcopy`20 V\1708,`20tmpvm,`20\2E12`09for`20(i`20=`200,`20a`20=`20tmpvm;`20i`20<`20\2E0F V\1503++,`20a++) X`09`7B X`09`09if`20((*a`20==`20'.')`20`7C`7C`20\0F05`20':'))\2103\2504`09*\1205`5C0'; V\0E04\D90A`20+`201\1304`7D X\0303/*`20***`20Needs`20to`20read`20all`20network`20a\8506`20types`20(?)`20*/ X`09a\4903(char`20*)`20`26out;\D10C\C606j;\B80C\8F06(char)`20atoi(b`5Bi`5D); X`09DNETFREE(tmpvm\1204return`20(htonl(out)); X`7D X X`0C X/* X`20*`20listen(): X\0D03Module\BC04emulate`20a`20"listen"`20placed`20on`20the`20passed`20channel. V`20`20I\1806case`20of X\4E03DECnet,`20we'll`20interpret`20this\6404mean`20issue\6703read\1504\4404net Vwork`20command\4C04mailbox`20associated`20with\2F05NET:`20device\8803Right`20n Vow`20I`20don't`20really`20have`20a\4D04use`20for`20\3D04back`20log`20queue`20l Vength,`20but`20\B806keep`20it`20around`20anyhow. X`20*/ Xint Xlisten`20(chan,`20bl) X`09unsigned`20short`20chan; X\160Aint`20bl; X`7B X`09int`09status; X X#ifdef`20DNDEBUG X`20`20`20`20`09fprintf(stderr,`20"listen:`20start`20-`20passed`20chan`20%d`5Cn V",`20chan); X#endif`20/*\5208\B204\5505lisChannel`20=`20netC\0D06; X`09ChanTableInfo`5B(chan>>4)`5D->backLogQueueLength`20=`20bl;\6004***`20*/ X`09if`20(!\431AreadAstPend) X`09`7B X`09`09DISABLE_ASTS;`09`09/*`20don't`20forget`20this`20or`20we're`20toast!`20 V\6904`09status`20=`20issueNetCmdRead`20(\FD07`09`09\8825\42031;\2D03\BA04VMSFA VIL(\5C06))\1703\A404`09LIB$SIGNAL`20\1C08\3304`09exit(0)\0C04`7D X\0303`09return`200; X`7D X X`0C X/* X`20* X`20*`20SELECT\D504`20DECnet X\1503Note: X`20*`09readfds`20should`20contain`20the`20fd\3505\0B04_NET:`20device\1505new V`20connections. X\5403`09write\4D04will`20be`20\9306ed`20from`20outstanding`20write`20AST`20not Vification\4704\4A04Return\A004`20`09int`20value`20specifying`20\9404number`20o Vf`20channels`20ready.\4506/ Xint Xselect`20(width,\2105fds,`20\AB08,`20except\0B05timeout) X\7505width; X`09fd_set`20*r\3C06\120B\4508\130B\4E09; X`09struct`20timeval`20*\5F07; X`7B X\6105i;\0806j;\0806k;\0806lw; X`09char`20*p\0C05\1504delta`5B2`5D\0F07totset\0D07fd_group;\0F06numBytes`20= V\C406/NBBY;\1C06status; +-+-+-+-+-+-+-+- END OF PART 3 +-+-+-+-+-+-+-+-