Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1271797
  • 博文数量: 287
  • 博客积分: 11000
  • 博客等级: 上将
  • 技术积分: 3833
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-16 08:43
文章分类
文章存档

2013年(15)

2012年(17)

2011年(17)

2010年(135)

2009年(85)

2008年(18)

分类: 系统运维

2010-06-04 15:49:34

TCP/IP management APIs (2)


     **
     **  Description : Print TCP/IP interface status
     **
     **  Program summary
     **  ---------------
     **
     **  Object - User space APIs:
     **    QUSCRTUS       Create user space    Creates a user space in either
     **                                        user domain or system domain.
     **                                        Only user domain user spaces are
     **                                        accessible by the user space APIs.
     **
     **    QUSDLTUS       Delete user space    Deletes the user space specified.
     **
     **    QUSPTRUS       Retrieve pointer to  The address of the first byte
     **                   user space           of the storage allocated by the
     **                                        user space requested is returned.
     **
     **
     **  Communication - TCP/IP management APIs:
     **    QtocRtvTCPA       Retrieve TCP/IP   Retrieves TCP/IPv4 and TCP/IPv6
     **                      attributes        (V5R2) stack attributes.
     **
     **    QtocLstNetIfc     List network      Returns a detailed list of all
     **                      interfaces        logical TCP/IP interfaces.
     **
     **
     **
     **  Sequence of events:
     **    1. The current operational status of the TCP/IP stack is retrieved
     **       to ensure that TCP/IP connection information is available.
     **
     **    2. A user space is created and a list of the logical TCP/IP network
     **       interfaces is loaded to the user space.
     **
     **    3. For each TCP/IP network interface retrieved from user space a
     **       report line is printed.
     **
     **    4. Finally the user space is deleted and the program is terminated.
     **
     **
     **  Programmer's notes:
     **    Earliest release program will run: V5R1
     **
     **    The examples here are all retrieving information about TCP/IPv4
     **    stacks and connections. As of V5R2 new API formats are available
     **    for retrieval of similar TCP/IPv6 stack and interface information.
     **
     **
     **  Compile options:
     **
     **    CrtRpgMod Module( CBX1061 )  DbgView( *LIST )
     **
     **    CrtPgm    Pgm( CBX1061 )
     **              Module( CBX1061 )
     **
     **-- Header specifications:  --------------------------------------------**
     H Option( *SrcStmt )
     **-- Printer file:  -----------------------------------------------------**
     FQSYSPRT   O    F  132        Printer  InfDs( PrtLinInf )  OflInd( *InOf )
     **-- Printer file information:  -----------------------------------------**
     D PrtLinInf       Ds
     D  PlOvfLin                      5i 0  Overlay( PrtLinInf: 188 )
     D  PlCurLin                      5i 0  Overlay( PrtLinInf: 367 )
     D  PlCurPag                      5i 0  Overlay( PrtLinInf: 369 )
     **-- System information:  -----------------------------------------------**
     D                SDs
     D  PsPgmNam         *Proc
     **-- Global declarations:  ----------------------------------------------**
     D Lix             s             10u 0
     D PxUsrSpc        c                   'LSTNETIFC QTEMP'
     **
     D Time            s              6s 0
     D NbrRcds         s             10u 0
     D TcpIfcSts       s              9a
     D IfcLinTyp       s              7a
     **-- Interface status table:  -------------------------------------------**
     D StsTbl          Ds
     D  IfcSts                        9a   Dim( 9 )
     D                               81a   Overlay( StsTbl )
     D                                     Inz( 'Inactive Active   Starting +
     D                                           Ending   RCYPND   RCYCNL   +
     D                                           Failed   Failed-T DOD      ' )
     **-- Interface line type table:  ----------------------------------------**
     D TypTbl          Ds
     D  LinTyp                        7a   Dim( 15 )
     D                              105a   Overlay( TypTbl )
     D                                     Inz( 'NOTFND ERROR  NONE   OTHER  +
     D                                           n/a    ELAN   TRLAN  FR     +
     D                                           ASYNC  PPP    WLS    X.25   +
     D                                           DDI    TDLC   L2TP   ' )
     **-- Api error data structure:  -----------------------------------------**
     D ApiError        Ds
     D  AeBytPro                     10i 0 Inz( %Size( ApiError ))
     D  AeBytAvl                     10i 0 Inz
     D  AeMsgId                       7a
     D                                1a
     D  AeMsgDta                    128a
     **-- API Header information:  -------------------------------------------**
     D HdrInf          Ds                  Based( pHdrInf )
     D  HiUsrSpcNamSp                10a
     D  HiUsrSpcLibSp                10a
     **-- User space generic header:  ---------- -----------------------------**
     D UsrSpc          Ds                  Based( pUsrSpc )
     D  UsOfsHdr                     10i 0 Overlay( UsrSpc: 117 )
     D  UsOfsLst                     10i 0 Overlay( UsrSpc: 125 )
     D  UsNumLstEnt                  10i 0 Overlay( UsrSpc: 133 )
     D  UsSizLstEnt                  10i 0 Overlay( UsrSpc: 137 )
     **-- User space pointers:  ----------------------------------------------**
     D pUsrSpc         s               *   Inz( *Null )
     D pHdrInf         s               *   Inz( *Null )
     D pLstEnt         s               *   Inz( *Null )
     **-- TCP/IP attributes:  ------------------------------------------------**
     D TCPA0100        Ds
     D  T1BytRtn                     10u 0
     D  T1BytAvl                     10u 0
     D  T1StkSts                     10u 0
     D  T1ActTim                     10u 0
     D  T1LstStrD                     8a
     D  T1LstStrT                     6a
     D  T1LstEndD                     8a
     D  T1LstEndT                     6a
     D  T1StrJob                     10a
     D  T1StrUsr                     10a
     D  T1StrNbr                      6a
     D  T1StrJobInt                  16a
     D  T1EndJob                     10a
     D  T1EndUsr                     10a
     D  T1EndNbr                      6a
     D  T1EndJobInt                  16a
     D  T1OfsAddInf                  10u 0
     D  T1LenAddInf                  10u 0
     **-- Interface list entry:  ---------------------------------------------**
     D NIFC0100        Ds                  Based( pLstEnt )
     D  I1IntAdr                     15a
     D                                1a
     D  I1IntAdrB                    10u 0
     D  I1NetAdr                     15a
     D                                1a
     D  I1NetAdrB                    10u 0
     D  I1NetName                    10a
     D  I1LinD                       10a
     D  I1IfcName                    10a
     D                                2a
     D  I1IfcSts                     10u 0
     D  I1IfcTypSrv                  10i 0
     D  I1IfcMtu                     10i 0
     D  I1IfcLinTyp                  10i 0
     D  I1HostAdr                    15a
     D                                1a
     D  I1HostAdrB                   10u 0
     D  I1IfcSubMsk                  15a
     D                                1a
     D  I1IfcSubMskB                 10u 0
     D  I1DirBdcAdr                  15a
     D                                1a
     D  I1DirBdcAdrB                 10u 0
     D  I1ChgDat                      8a
     D  I1ChgTim                      6a
     D  I1AstLocIfc                  15a
     D                                3a
     D  I1AstLocIfcB                 10u 0
     D  I1ChgSts                     10u 0
     D  I1PckRul                     10i 0
     D  I1AutStr                     10u 0
     D  I1TrlBitSeq                  10u 0
     D  I1IfcTyp                     10u 0
     D  I1PrxArpEnb                  10u 0
     D  I1PrxArpAlw                  10u 0
     D  I1CfgMtu                     10i 0
     **-- Following fields were added in V5R2 - do not reference in V5R1:
     D  I1NetNameF                   24a
     D  I1IfcNameF                   24a
     **-- Create user space: -------------------------------------------------**
     D CrtUsrSpc       Pr                  ExtPgm( 'QUSCRTUS' )
     D  CsSpcNamQ                    20a   Const
     D  C***tAtr                     10a   Const
     D  CsInzSiz                     10i 0 Const
     D  CsInzVal                      1a   Const
     D  CsPubAut                     10a   Const
     D  CsText                       50a   Const
     **-- Optional 1:
     D  CsReplace                    10a   Const Options( *NoPass )
     D  CsError                   32767a         Options( *NoPass: *VarSize )
     **-- Optional 2:
     D  CsDomain                     10a   Const Options( *NoPass )
     **-- Delete user space: -------------------------------------------------**
     D DltUsrSpc       Pr                  ExtPgm( 'QUSDLTUS' )
     D  DsSpcNamQ                    20a   Const
     D  DsError                   32767a         Options( *VarSize )
     **-- Retrieve pointer to user space: ------------------------------------**
     D RtvPtrSpc       Pr                  ExtPgm( 'QUSPTRUS' )
     D  RpSpcNamQ                    20a   Const
     D  RpPointer                      *
     D  RpError                   32767a         Options( *NoPass: *VarSize )
     **-- Retrieve TCP/IP attributes:  ---------------------------------------**
     D RtvTcpA         Pr                  ExtProc( 'QtocRtvTCPA' )
     D  RtRcvVar                  32767a          Options( *VarSize )
     D  RtRcvVarLen                  10i 0 Const
     D  RtFmtNam                      8a   Const
     D  RtError                   32767a          Options( *VarSize )
     **-- List network interfaces:  ------------------------------------------**
     D LstNetIfc       Pr                  ExtProc( 'QtocLstNetIfc' )
     D  LiSpcNamQ                    20a   Const
     D  LiFmtNam                      8a   Const
     D  LiError                   32767a         Options( *VarSize )
     **
     **-- Mainline:  ---------------------------------------------------------**
     **
     C                   Time                    Time
     C                   Except    Header
     **
     C                   CallP     RtvTcpA( TCPA0100
     C                                    : %Size( TCPA0100 )
     C                                    : 'TCPA0100'
     C                                    : ApiError
     C                                    )
     **
     C                   Select
     C                   When      AeBytAvl    > *Zero
     **-- Error occurred...
     C                   Except    NoStack
     **
     C                   When      T1StkSts    = 0             Or
     C                             T1StkSts    = 2
     **-- TCP/IP stack not operational...
     C                   Except    NoStack
     **
     C                   Other
     **
     C                   CallP     CrtUsrSpc( PxUsrSpc
     C                                      : *Blanks
     C                                      : 65535
     C                                      : x'00'
     C                                      : '*CHANGE'
     C                                      : *Blanks
     C                                      : '*YES'
     C                                      : ApiError
     C                                      )
     **
     C                   CallP     LstNetIfc( PxUsrSpc
     C                                      : 'NIFC0100'
     C                                      : ApiError
     C                                      )
     **
     C                   If        AeBytAvl    = *Zero
     C                   ExSr      PrcLstEnt
     C                   EndIf
     **
     C                   CallP     DltUsrSpc( PxUsrSpc
     C                                      : ApiError
     C                                      )
     **
     C                   If        NbrRcds    =  *Zero
     C                   Except    NoRcds
     C                   EndIf
     C                   EndSl
     **
     C                   Eval      *InLr       = *On
     C                   Return
     **
     **-- Process list entries:  ---------------------------------------------**
     C     PrcLstEnt     BegSr
     **
     C                   CallP     RtvPtrSpc( PxUsrSpc
     C                                      : pUsrSpc
     C                                      )
     **
     C                   Eval      pHdrInf     = pUsrSpc + UsOfsHdr
     C                   Eval      pLstEnt     = pUsrSpc + UsOfsLst
     **
     C                   For       Lix         = 1  to UsNumLstEnt
     **
     C                   ExSr      PrtIfcDtl
     **
     C                   If        Lix         < UsNumLstEnt
     C                   Eval      pLstEnt     = pLstEnt + UsSizLstEnt
     C                   EndIf
     C                   EndFor
     **
     C                   EndSr
     **-- Print interface detail line:  --------------------------------------**
     C     PrtIfcDtl     BegSr
     **
     C                   If        PlCurLin    > PlOvfLin - 3
     C                   Except    Header
     C                   EndIf
     **
     C                   Eval      TcpIfcSts  =  IfcSts(I1IfcSts    + 1)
     C                   Eval      IfcLinTyp  =  LinTyp(I1IfcLinTyp + 5)
     **
     C                   Eval      NbrRcds    =  NbrRcds + 1
     C                   Except    IfcDtl
     **
     C                   EndSr
     **-- Print file definition:  --------------------------------------------**
     OQSYSPRT   EF           Header         2  3
     O                       UDATE         Y      8
     O                       Time                18 '  :  :  '
     O                                           75 'Print TCP/IP interface -
     O                                              status'
     O                                          107 'Program:'
     O                       PsPgmNam           118
     O                                          126 'Page:'
     O                       PAGE             +   1
     OQSYSPRT   EF           Header         1
     O                                           16 'Internet address'
     O                                           29 'Subnet mask'
     O                                           50 'Network address'
     O                                           64 'Host address'
     O                                           72 'Line'
     O                                           84 '-type'
     O                                           96 'Interface'
     O                                          106 '-status'
     O                                          118 'MTU'
     **
     OQSYSPRT   EF           IfcDtl         1
     O                       I1IntAdr            15
     O                       I1IfcSubMsk         33
     O                       I1NetAdr            50
     O                       I1HostAdr           67
     O                       I1LinD              78
     O                       IfcLinTyp           86
     O                       I1IfcName           97
     O                       TcpIfcSts          108
     O                       I1IfcMtu      3    118
     **
     OQSYSPRT   EF           NoStack     1
     O                                           26 '(TCP/IP stack not active)'
     OQSYSPRT   EF           NoRcds      1
     O                                           26 '(No entries found)'

Thanks to Carsten Flensburg
阅读(793) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~