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

2013年(15)

2012年(17)

2011年(17)

2010年(135)

2009年(85)

2008年(18)

分类: 系统运维

2010-06-04 15:53:51

TCP/IP management APIs (3)


     **
     **  Description : Print TCP/IP network routes
     **
     **  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.
     **
     **    QtocLstNetRte     List network      Returns a detailed list of all
     **                      routes            network routes.
     **
     **
     **
     **  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 TCP/IP network routes
     **       is loaded to the user space.
     **
     **    3. For each TCP/IP network route 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
     **
     **    According to the API documentation there are 5 route types (0-4)
     **    and route type 2 maps to HOST. It turns out that ICMP added host
     **    routes are given route type 5 and therefore an extra HOST entry
     **    in the mapping table is necessary to ensure a correct result.
     **
     **    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 route information.
     **
     **
     **  Compile options:
     **
     **    CrtRpgMod Module( CBX1062 )  DbgView( *LIST )
     **
     **    CrtPgm    Pgm( CBX1062 )
     **              Module( CBX1062 )
     **
     **-- 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                   'LSTNETRTE QTEMP'
     **
     D Time            s              6s 0
     D NbrRcds         s             10u 0
     D TcpRteTyp       s              7a
     D TcpRteSrc       s              6a
     D TcpRteSts       s              7a
     **-- Route type table:  -------------------------------------------------**
     D RteTbl          Ds
     D  RteTyp                        7a   Dim( 6 )
     D                               42a   Overlay( RteTbl )
     D                                     Inz( 'DFTRTE DIRECT HOST   SUBNET +
     D                                           NET    HOST   ' )
     **-- Route source table:  -----------------------------------------------**
     D SrcTbl          Ds
     D  RteSrc                        6a   Dim( 5 )
     D                               30a   Overlay( SrcTbl )
     D                                     Inz( 'OTHER CFG   ICMP  SNMP  RIP' )
     **-- Route status table:  -----------------------------------------------**
     D StsTbl          Ds
     D  RteSts                        7a   Dim( 5 )
     D                               35a   Overlay( StsTbl )
     D                                     Inz( 'YES    NO     DOD    NO GATE' )
     **-- 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
     **-- Route list entry:  -------------------------------------------------**
     D NRTE0100        Ds                  Based( pLstEnt )
     D  R1RteDst                     15a
     D                                1a
     D  R1RteDstB                    10u 0
     D  R1SubMsk                     15a
     D                                1a
     D  R1SubMskB                    10u 0
     D  R1NxtHop                     15a
     D                                1a
     D  R1NxtHopB                    10u 0
     D  R1RteSts                     10u 0
     D  R1TypSrv                     10i 0
     D  R1RteMtu                     10i 0
     D  R1RteTyp                     10u 0
     D  R1RteSrc                     10i 0
     D  R1RtePcd                     10u 0
     D  R1LocBndIfcSt                10u 0
     D  R1LocBndTyp                  10u 0
     D  R1LocBndLinTp                10i 0
     D  R1LocBndIfc                  15a
     D                                1a
     D  R1LocBndIfcB                 10u 0
     D  R1LocSubMsk                  15a
     D                                1a
     D  R1LocSubMskB                 10u 0
     D  R1LocNetAdr                  15a
     D                                1a
     D  R1LocNetAdrB                 10u 0
     D  R1LocBndLinD                 10a
     D  R1ChgDat                      8a
     D  R1ChgTim                      6a
     **-- 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 routes:  ----------------------------------------------**
     D LstNetRte       Pr                  ExtProc( 'QtocLstNetRte' )
     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     LstNetRte( PxUsrSpc
     C                                      : 'NRTE0100'
     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      PrtRteDtl
     **
     C                   If        Lix         < UsNumLstEnt
     C                   Eval      pLstEnt     = pLstEnt + UsSizLstEnt
     C                   EndIf
     C                   EndFor
     **
     C                   EndSr
     **-- Print route detail line:  ------------------------------------------**
     C     PrtRteDtl     BegSr
     **
     C                   If        PlCurLin    > PlOvfLin - 3
     C                   Except    Header
     C                   EndIf
     **
     C                   Eval      TcpRteTyp  =  RteTyp(R1RteTyp + 1)
     C                   Eval      TcpRteSrc  =  RteSrc(R1RteSrc + 2)
     C                   Eval      TcpRteSts  =  RteSts(R1RteSts)
     **
     C                   Eval      NbrRcds    =  NbrRcds + 1
     C                   Except    RteDtl
     **
     C                   EndSr
     **-- Print file definition:  --------------------------------------------**
     OQSYSPRT   EF           Header         2  3
     O                       UDATE         Y      8
     O                       Time                18 '  :  :  '
     O                                           75 'Print TCP/IP network -
     O                                              routes'
     O                                          107 'Program:'
     O                       PsPgmNam           118
     O                                          126 'Page:'
     O                       PAGE             +   1
     OQSYSPRT   EF           Header         1
     O                                           17 'Route destination'
     O                                           30 'Subnet mask'
     O                                           46 'Next hop'
     O                                           65 'Route type'
     O                                           74 '-source'
     O                                           83 '-status'
     O                                           96 'MTU'
     O                                          111 'Change date'
     O                                          118 '-time'
     **
     OQSYSPRT   EF           RteDtl         1
     O                       R1RteDst            15
     O                       R1SubMsk            34
     O                       R1NxtHop            53
     O                       TcpRteTyp           62
     O                       TcpRteSrc           73
     O                       TcpRteSts           83
     O                       R1RteMtu      3     96
     O                       R1ChgDat           110
     O                       R1ChgTim           119
     **
     OQSYSPRT   EF           NoStack     1
     O                                           26 '(TCP/IP stack not active)'
     OQSYSPRT   EF           NoRcds      1
     O                                           26 '(No entries found)'

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