In article , andrew.roughan@writeme.com (Roughana) wrote: > Jalapeno wrote in message > news:... > > In article , > > andrew.roughan@writeme.com (Roughana) wrote: > > > May I please have your permission to add your IIgs MacIP Gateway > > > pseudo code post to the Feature Requests section of the MOSP site? > > > > Sure, if you want to. It's only an idea that popped into my head. > Thank you. I have added it. > https://sourceforge.net/tracker/index.php?func=detail&aid=522040&group_id=1617 > 6&atid=366176 > > >Maybe if I think about it for a couple of days I could give you a > better > > algorithm and whip up some sample code. (or not :) > > Feel free to contribute whatever you are inspired to. > > Cheers, > Andrew Hi Andrew, Thanks for posting that for me. I have started work on the IIgs MacIP Gateway and I almost have the Appletalk section done, but I have just downloaded the Marinetti Programmers manual. I will start on the LanceGS/Marinetti section after my vacation, but don't hold your breath, I may have to upload what I have already to the MOSP for someone else to finish because I have more important projects to work on and time is so tight. On another note, I don't know why my lk utility/hack crashed on your system, I couldn't get it to crash on any of my 3 IIGS's. It probably lost something or had something blasted on it's Internet journey. In any case, here is the source code. I changed the output slightly in case others want to use it and I added lots of comments in case you aren't a C hacker. Note: Make sure Appletalk is active before running the utility. I made the call to NBP synchronous for simplicity but it WILL hang your system if Appletalk isn't active (or if the SCC.manager and other appletalk drivers aren't present or are inactive). If someone wants to turn this ANSI C code into an NDA that would be cool, too. ;) The first part below is my compilation, after that is the source code. Good luck. I apologize in advance for the "majik numbers" but for a program this small I ain't changin' 'em. +------+-------+-------+ ORCA/C 2.1.0 Including :programming:LIBRARIES:ORCACDefs:stdio.h Compiling main Compiling print_the_results Compiling call_appletalk 0 errors found. Link Editor 2.0.3 Pass 1: ................................................... Pass 2: ................................................... There is 1 segment, for a length of $00001B94 bytes. Making the NBP call to appletalk (it's synchronous so please wait...) returned from appletalk call The number of entities found: 13 Appletalk network-visible entities are formed as follows: object : type : zone (note: a '*' in the zone field means the local zone) entity 0 is: SE/30 1:ProDOS16 Image@* entity 1 is: SE/30 1:Apple //gs@* entity 2 is: SE/30 1:Apple //e Boot@* entity 3 is: SE/30 1:AFPServer@* entity 4 is: SE/30 1:Macintosh SE/30@* entity 5 is: SE/30 1:Workstation@* entity 6 is: PM7100 1:AFPServer@* entity 7 is: PM7100 1:ARA - Personal Server@* entity 8 is: PM7100 1:MLS 2.0@* entity 9 is: PM7100 1: Power Macintosh@* entity 10 is: PM7100 1:Workstation@* entity 11 is: chipotle:Apple IIgs@* entity 12 is: jalapeno:Apple IIgs@* +------+-------+-------+ begin source code +------+-------+-------+ /* The code presented here (all or in part) is copyright */ /* 2002 Jalapeno Software. It is provided here without */ /* warranty of any kind, explicit or implicit, and is */ /* intended for illustration and discussion. You may use */ /* this code (all or in part) without charge, including as */ /* part of your own programs, but it is at your own risk. */ /* */ /* If you use any of this code, all or in part, including */ /* any of the ideas behind the code, I just would like to */ /* ask you to send an email to: */ /* */ /* jalapeno1 @ mac . com */ /* */ /* to let me know it is useful to someone. I am also */ /* interested in peer review of my code so if you find */ /* a bug, know of a better technique or algorithm, or just */ /* want to discuss it then don't be shy. I DO NOT collect */ /* email addresses nor would I violate your privacy in any */ /* manner. */ #pragma keep "lk" /* I try to keep as ANSI C89 as I can */ #include unsigned int call_appletalk(void *); void print_the_results(struct lookup_name *); /* This structure is our NBP Lookup Name */ /* parameter block thingy. (Yes, I know that */ /* ORCA/C has plain char defined as unsigned */ /* but I deal with at least one system that */ /* has plain char defined as signed so for */ /* maximum portablility of my code I am in the */ /* habit of being explicit. Besides, the way we */ /* will use chars in this program declaring */ /* them explicitly as unsigned is a good cue. */ struct lookup_name { unsigned char async_flag ; unsigned char command ; unsigned int result ; void (*completion_routine)(void) ; unsigned char *entity_name ; unsigned char retry_interval ; unsigned char retry_count ; unsigned int reserved ; unsigned int buffer_length ; unsigned char *buffer ; unsigned char max_matches ; unsigned char actual_matches ; } ; int main(void) { int rc; /* '=' is the NBP wildcard for the object and */ /* type fields of an entity name. To get a list */ /* of all entities registered on a network you */ /* use an entitiy name of '=:=@*'. The '*' is */ /* for the local zone. There is no 'wildcard' for */ /* the zone field. To get all entities of type */ /* 'laserwriter' you'd code the entity name as */ /* '=:laserwriter@*'. The Apple IIgs appletalk */ /* NBP implementation does most of the work for */ /* you. The entitiy name field of the LookupName */ /* parameter structure takes variable length */ /* (32 characters max) pStrings for the object */ /* type and zone fields. The firmware adds the */ /* separators for us. */ char who_is_out_there[6] = {'\x01','=','\x01','=','\x01','*'}; /* This is our buffer where the IIgs NBP protocol */ /* will store the results of who responded to the */ /* our inquiry. It should be large enough to hold */ /* max_matches entity names. For example, if every */ /* entity on your network had the largest possible */ /* name and you had 10 network-visible entities */ /* respond then you'd need 990 bytes. I like round */ /* figures so I am using 2048. */ unsigned char we_are_here[2048]; /* This is our NBP LookupName parameter block. */ struct lookup_name available_nves = {0}; /* First we must supply the required parms. */ available_nves.command = 0x10; /* appletalk command # */ available_nves.entity_name = who_is_out_there; available_nves.retry_interval = 0x02; /* adjust these nums. */ available_nves.retry_count = 0x02; /* if needed. */ available_nves.buffer_length = sizeof we_are_here; available_nves.buffer = we_are_here; available_nves.max_matches = 0xFF; /* AND away we go........ */ puts("Making the NBP call to appletalk"); puts(" (it's synchronous so please wait...)"); /* the call could be made async as well but for simplicity */ /* I chose to make this call synchronous. */ if ((rc = call_appletalk((void *)&available_nves)) != 0) { printf("Appletalk error: %X\n", rc); printf("The error code : %X ", available_nves.result); switch (available_nves.result) { case 0x0401: puts("Too many names"); break; case 0x0404: puts("User's buffer is full"); break; case 0x0406: puts("Invalid name format"); break; case 0x0408: puts("Too many NBP processes, try later"); break; default : puts("Not an NBP error, look it up"); } exit (rc); } puts("returned from appletalk call\n\n"); printf("The number of entities found: %d\n", available_nves.actual_matches); /* watch out for internet line-wrap on the printf above*/ print_the_results(&available_nves); } void print_the_results(struct lookup_name *captured_nves) { unsigned char *you_are_here; int i, j,length; puts("Appletalk network-visible entities are formed as follows:"); puts("object : type : zone"); puts(" (note: a '*' in the zone field means the local zone)\n"); /* We need to get the data out of the buffer */ /* that was filled by the NBP lookup call. */ /* We declared the buffer to be of type */ /* unsigned char so we can traverse it with */ /* an 8-bit pointer. So, let's point our */ /* pointer to the buffer. */ you_are_here = captured_nves->buffer; /* At this point we aren't interested in the */ /* hum-drum numbers of the network. We want */ /* the fun nve names! So let's slide our */ /* pointer past the buffer header and get to */ /* to the meaty part of the carcass. */ you_are_here += 5; /* Okey dokey. Our first stop on the "who's- */ /* on-our-network" express is the object field */ /* of the first network-visible entity. A */ /* pString so I'm told, so first let's rip out */ /* the length octet, save it for our loop, */ /* and nudge our pointer to the first char- */ /* acter in the object field. */ length = *you_are_here++; /* Now that we know how many potatoes are in */ /* the pot we can release Ms. Pacman to do */ /* her stuff! */ /* She is into nesting these days so she loops */ /* from one nve to the next while munching the */ /* tasty morsels along the way, looping */ /* through the object, then the type and */ /* finally the piece-de-resistance, the zone! */ for(i = 0; i < captured_nves->actual_matches; i++) { printf("entity %d is: ", i); for(j = 0; j < length; j++) { /* mmm-mmm, take a byte and move on to the next */ /* one! */ putchar(*you_are_here++); } /* Now that we consumed the object field, */ /* let's start on the type field. Since it */ /* too is a pString, let's grab the length */ /* and slip over to the grub. */ length = *you_are_here++; /* let's not forget to put back the ':' that */ /* the IIgs firmware stole from us. */ putchar(':'); for(j = 0; j < length; j++) { /* Munch, slide, munch, slide, munch slide... */ putchar(*you_are_here++); } length = *you_are_here++; putchar('@'); for(j = 0; j < length; j++) { putchar(*you_are_here++); } putchar('\n'); /* And now we are done with the first nve. We */ /* now need to have our pointer mosey on over */ /* to the next nve. But, we dont' want the */ /* network numbers in this broadway production */ /* so let's roll like a telli-tubby right on */ /* by. Oh, yeah. And get the length byte too. */ you_are_here += 5; length = *you_are_here++; } } /* +----+ +----+ */ /* +----+ The next function contains non-standard C +----+ */ /* +----+ +----+ */ asm unsigned int call_appletalk(void *at_parms) /* assembly glue to call the */ /* call the appletalk firmware */ { TSC /* set the stack as the direct page to */ PHD /* facilitate reading the parm that was */ TCD /* passed */ LDX 0x04 /* load the address of the appletalk parms */ LDY 0x06 /* into the index registers and then call */ JSL >0xE11014 /* RamDispatch (the appletalk entry point) */ TAX /* temporarily move the appletalk rc */ LDA 0x02 /* clean up the stack */ STA 0x04 LDA 0x00 STA 0x02 PLD PLA TXA /* restore the appletalk return code for rtl*/ RTL }