|
|
You can use the ioctl system call to obtain
NetBIOS session status and adapter status (both local
and remote) over SCO TCP/NetBIOS
and NetBEUI.
The header file /usr/include/sconetbios.h
defines the constants and data structures you need.
The following program provides an example of how to
obtain session and adapter status over an
existing transport endpoint. The transport endpoint can
be either connection-oriented or connectionless.
Example for obtaining session and adapter status
1 #include <stropts.h> 2 #include <xti.h> 3 #include <sconetbios.h>4 #define ASTAT_BUFSIZE 4096 5 #define SSTAT_BUFSIZE 4096
6 extern print_astatus(struct strioctl *); 7 extern print_sstatus(struct strioctl *);
8 demo_ioctl_user_function(int fd, char *name) 9 { 10 struct strioctl cmdbuf; 11 union { 12 struct astat adapter_status; 13 char name[NB_NAMELEN]; 14 } astat_buf; 15 struct sstat session_status;
16 cmdbuf.ic_cmd = NBIOCTL_ASTAT; 17 cmdbuf.ic_timout = 0; 18 cmdbuf.ic_dp = (char *)&astat_buf; 19 cmdbuf.ic_len = ASTAT_BUFSIZE;
20 memcpy(&astat_buf.name[0], name, NB_NAMELEN);
21 if (ioctl(fd, I_STR, &cmdbuf) < 0) { 22 perror("Error getting Adapter Status"); 23 exit(1); 24 } 25 print_astatus(&cmdbuf);
26 cmdbuf.ic_cmd = NBIOCTL_SSTAT; 27 cmdbuf.ic_timout = 0; 28 cmdbuf.ic_dp = (char *)&session_status; 29 cmdbuf.ic_len = SSTAT_BUFSIZE;
30 if (ioctl(fd, I_STR, &cmdbuf) < 0) { 31 perror("Error getting session status"); 32 exit(2); 33 } 34 print_sstatus(&cmdbuf); 35 }