Operating System - OpenVMS
1752752 Members
5041 Online
108789 Solutions
New Discussion юеВ

Programming dedicated LAT application ports on Itanium

 
twhjr
Advisor

Re: Programming dedicated LAT application ports on Itanium

Greetings,

Yea, there is some really nasty code here and fortunately I did not write it but equally unfortunately it was thrown over the wall and I have less than a week to make it work. I have spent most of the week trying to fix the obvious, when I took the VAXC out of the build.

I have stepped through this code line by line with the debugger putting break points a all of the Async entry points and I do not get into any loops. In fact the error happens attemting to post the first AST. Guess what, examining the buffers from the strncpy in the debugger indicates that what they appear to have intended with the statement actually worked? Go figure...

I guess you get what you pay for, as they say...

Have Fun,
twhjr
As one skilled in the art it should be obvious...
twhjr
Advisor

Re: Programming dedicated LAT application ports on Itanium

Greetings,

From the Docs:

Programming Application Services and Dedicated Ports

Rather than the normal timesharing service offered by the operating system, application programs can make use of LAT application services that allow terminal server users (or users on sytems with outgoing connections) to connect to a specialized application. To do this, the system manager must create LAT ports that are dedicated to a particular application service. (Alternatively, this LAT port creation can be done from a program using the QIOs discussed in previous sections, providing OPER privilege.) When the remote user makes the connection to the application service, the connection is directly to the application program that controls a LAT port (LTA device) associated with the service. In this case the prompt, Username:, is not received. HP recommends that you follow these steps to create an application service:

1. Define the dedicated ports in LAT$SYSTARTUP.COM and execute the command procedure in SYSTARTUP_VMS.COM. (Refer to the HP OpenVMS System Management Utilities Reference Manual and the HP OpenVMS System Manager's Manual for additional information.)

2. Run the application program. Within the application program, allocate dedicated ports with the same name as those defined in LAT$SYSTARTUP.COM. Use the Assign I/O Channel ($ASSIGN) system service to assign service channels to the ports.

3. Post a read request to the dedicated ports. When the terminal user connects to the service and presses the Return key, the application program can perform I/O to the dedicated port.

4. To break the connection, use the Deassign I/O Channel ($DASSGN) system service to deassign the channel and the Deallocate Device ($DALLOC) system service to deallocate the device. The application program must reallocate the port and reassign the channel in preparation for the next connection.
An example of the application service concept is a program that provides the time of day. For this example, the system manager includes the following lines in LAT$SYSTARTUP.COM (or enters them manually in the LATCP program):

CREATE SERVICE TIME/ID="At the tone, the time will be"/APPLICATION
CREATE PORT LTA99:/DEDICATED
SET PORT LTA99:/SERVICE=TIME

An application program then assigns a channel to device LTA99. When a terminal server user types CONNECT TIME, the user is connected to this application program, and the program prints out the time of day. The program then deassigns the channel, which disconnects the server user.

A system manager may associate more than one LAT port with the same service. In that case, the application program that offers the service should assign channels to all of the LTA devices created for that service.

Have Fun,
twhjr
As one skilled in the art it should be obvious...
Andy Bustamante
Honored Contributor

Re: Programming dedicated LAT application ports on Itanium

I used to support an VAX/Alpha application that used modems and terminal servers along the same lines. Along the way, we dropped LAT support and migrated to TCPIP.

As I recall, LAT needed to be configured to allow in bound connections. If you have more than one network interface, you also need to enable LAT for each NIC. Check the startup proceedures on the working Alphaserver.
If you don't have time to do it right, when will you have time to do it over? Reach me at first_name + "." + last_name at sysmanager net
Hoff
Honored Contributor

Re: Programming dedicated LAT application ports on Itanium

> guess you get what you pay for, as they say...

More specifically, your boss gets what your boss is willing to pay for, and your boss also gets what the customers are willing to pay for, etc.

Bad code can become immortal. The same bad decisions and bad designs and bad implementations that wrought the code creature can also lead to its continued zombie-like existence. Existing long past its intended lifetime, the creature will continue seeking brains from anyone in the vicinity, and can survive well past when an incremental rewrite or a port to IP or a port to Unix would have been warranted. But I digress.

Build a small reproducer of this and toss it at HP support.

And check MAXBUF parameter.
twhjr
Advisor

Re: Programming dedicated LAT application ports on Itanium

Greetings,

If I had any say in these matters I would write them a quick web page that does the RDB lookup and be done with it but government agencies are not always flexible when it comes to changing their interfaces which means changing their docs, etc, etc...

I am going to change the code to use a single port with a QIOW like the repair application and be done with it... I know that works because it is currently running and I can set host/lat to the port in enter repair info.

Have Fun,
twhjr
As one skilled in the art it should be obvious...
Bob Blunt
Respected Contributor

Re: Programming dedicated LAT application ports on Itanium

twhjr, I checked with a developer who has written and ported complex LAT code. His recommendation was to, first, refer to the IO Users Guide's sections on LAT and to code using the standards listed therein. I also found this example code that appears to have been submitted as an example to one of the support center's knowledge bases. The URL for this is:

http://vouters.dyndns.org/tima/OpenVMS-LAT-Creating-Application-Port-programming-example.html

bob
twhjr
Advisor

Re: Programming dedicated LAT application ports on Itanium

Greetings,

I have scrutinized every word in the IO Users Guide especiall these sections:

LAT Port Types

QIO functions can be used to create the following LAT port types:

Application Port: This type of port can be used to connect to a remote device (typically a printer) on a terminal server or to a dedicated port on another LAT service node. This is the default port type. See Programming Application Ports for a description of programming an application port.

Dedicated Port: This type of port specifies that the logical port on your node is dedicated to an application service. When users on a terminal server (or on another node that supports outgoing connections) request a connection to this service name, they are connected to a dedicated port. See Programming Application Services and Dedicated Ports for a description of programming a dedicated port and application service.

Forward Port: This type of port is used for outgoing LAT connections (to remote services) and is created by assigning a channel to the LAT template device _LTA0: with the $ASSIGN system service.

I am attempting to utilize a "Dedicated Port" buy utilizing the procedures layed out in the docs and I have included previously in this thread and again here:

Programming Application Services and Dedicated Ports

Rather than the normal timesharing service offered by the operating system, application programs can make use of LAT application services that allow terminal server users (or users on sytems with outgoing connections) to connect to a specialized application. To do this, the system manager must create LAT ports that are dedicated to a particular application service. (Alternatively, this LAT port creation can be done from a program using the QIOs discussed in previous sections, providing OPER privilege.) When the remote user makes the connection to the application service, the connection is directly to the application program that controls a LAT port (LTA device) associated with the service. In this case the prompt, Username:, is not received. HP recommends that you follow these steps to create an application service:

1. Define the dedicated ports in LAT$SYSTARTUP.COM and execute the command procedure in SYSTARTUP_VMS.COM. (Refer to the HP OpenVMS System Management Utilities Reference Manual and the HP OpenVMS System Manager's Manual for additional information.)

2. Run the application program. Within the application program, allocate dedicated ports with the same name as those defined in LAT$SYSTARTUP.COM. Use the Assign I/O Channel ($ASSIGN) system service to assign service channels to the ports.

3. Post a read request to the dedicated ports. When the terminal user connects to the service and presses the Return key, the application program can perform I/O to the dedicated port.

4. To break the connection, use the Deassign I/O Channel ($DASSGN) system service to deassign the channel and the Deallocate Device ($DALLOC) system service to deallocate the device. The application program must reallocate the port and reassign the channel in preparation for the next connection.

An example of the application service concept is a program that provides the time of day. For this example, the system manager includes the following lines in LAT$SYSTARTUP.COM (or enters them manually in the LATCP program):

CREATE SERVICE TIME/ID="At the tone, the time will be"/APPLICATION
CREATE PORT LTA99:/DEDICATED
SET PORT LTA99:/SERVICE=TIME

An application program then assigns a channel to device LTA99. When a terminal server user types CONNECT TIME, the user is connected to this application program, and the program prints out the time of day. The program then deassigns the channel, which disconnects the server user.

A system manager may associate more than one LAT port with the same service. In that case, the application program that offers the service should assign channels to all of the LTA devices created for that service.

The example in the docs, besides being full of errors, is for a "Forward Port" which is NOT what I am attempting to accomplish.

Have Fun,
twhjr
As one skilled in the art it should be obvious...
Dennis Handly
Acclaimed Contributor

Re: Programming dedicated LAT application ports on Itanium

>Craig: This is a really odd construct:
>strncpy(DEV_buf[index], "\0", DEF_IN_BUF_SIZE);
>If you're trying to null terminate ASCIZ strings, this may kinda sorta work

Yes, this will work.

>but definitely looks like it was written by someone unfamiliar with C.

No, it looks like someone too familiar with C but just not enough.

>If the intent is to zero-fill the buffers then the code as written isn't doing that.

Sure it does.

>Compare the docs for strncpy and memset and use the latter.

Right. The wording in memset(3) is much simpler to understand.

>Actually, it won't. strncpy copies the source string up to but *not including* the null terminator. So these calls do precisely nothing because the source strings have nothing in them but a null terminator.

Have you read it carefully? It shows the "broken" design of strncpy(3) where it doesn't work efficiently as a secure replacement for strcpy(3). I.e. if the string is short, it pads it out to the length, not just adding one null byte.

>Hoff: strncpy(LOG_buf[index], "\0", DEF_OUT_BUF_SIZE);
>Definitely broken. Was memset intended there?

I doubt it is broken but if it confuses the two of you, it isn't good code.
Hoff
Honored Contributor

Re: Programming dedicated LAT application ports on Itanium

Per the C specs, this does fill the buffer up to the specified length. Which I did not know. And there is still no way that I'd use this C call as a buffer fill tool. The str* calls aren't classically reliable around strings that contain nulls.

Around here, strlcpy() (where available) is preferred, and which reliably terminates the target buffer. Or the use of memset(), which explicitly zero-fills the whole buffer.

From some documentation (and why I prefer the strlcpy() call): "Because strncpy() does not guarantee to NUL terminate the string itself, this must be done explicitly." and "Be aware that the dest argument might not be terminated by a null character after a call to strncpy" In this case, there is a null and the target buffer length is (probably) non-zero, so there's no non-null terminated case here. It'll work.

Ugh. A quarter-century of C coding, and I still get bagged.



Craig A Berry
Honored Contributor

Re: Programming dedicated LAT application ports on Itanium

Dennis is right. I remembered the part about not necessarily getting a null terminator but I had forgotten that strncpy() pads up to the maximum length with nulls. This is one of several reasons strlcpy() is preferred where available; these days, with folks often using very large buffers for very large strings, zeroing more memory than you have to can be expensive.

I stand by the assertions that memset() would be better and old code that has been working is not necessarily correct code.

Hoff: Ugh. A quarter-century of C coding, and I still get bagged.

My first exposure to C was in 1987, so I have one more year to reach your level of confusion :-).