View previous topic :: View next topic |
Author |
Message |
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Sep 07, 2009 2:41 am Post subject: SNMP dll?? |
|
|
Anyone know if there is a VDS dll capable communicating with SNMP protocol?
Thanks in advance, |
|
Back to top |
|
|
PGWARE Web Host
Joined: 29 Dec 2001 Posts: 1562
|
Posted: Mon Sep 07, 2009 5:48 pm Post subject: |
|
|
I believe SNMP uses UDP. You could try to use the vdsipp and use the UDP protocol in it to build your own server/client system to read/send snmp requests. |
|
Back to top |
|
|
Rebel49 Contributor
Joined: 23 Aug 2002 Posts: 78 Location: Nova Scotia, Canada
|
Posted: Mon Sep 07, 2009 10:56 pm Post subject: |
|
|
A couple of years back I used VDS and SIPP quite successfully to communicate with several SNMP devices. However it was very brute force because i had to assemble the packets byte by byte and it took quite a lot of trial and error to get my understanding of the packet structure right.
Once I got it running correctly it was easy to pick up other devices that I had MIBs and OIDs for. Windows has its own SNMP service and i was able to use SNMP with that as well.
So indeed VDS can talk SNMP.
REB _________________ OLD and eager! |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Tue Sep 08, 2009 8:03 pm Post subject: |
|
|
Rebel49 wrote: | A couple of years back I used VDS and SIPP quite successfully to communicate with several SNMP devices. However it was very brute force because i had to assemble the packets byte by byte and it took quite a lot of trial and error to get my understanding of the packet structure right.
Once I got it running correctly it was easy to pick up other devices that I had MIBs and OIDs for. Windows has its own SNMP service and i was able to use SNMP with that as well.
So indeed VDS can talk SNMP.
REB |
Ummm... care to share
PK, I looked up the RFCs on SNMP and you are right. It should be possible to use your UDP portion the VSDIPP dll to communicate with a SNMP enabled device. As Rebel alluded to, I looks like the messages will have to be reassebled at the byte level. I will also need to incorporate the ability discern the different versions of SNMP.
Anyone know of a good SNMP test generator?
Looks like I'm in for a daunting task |
|
Back to top |
|
|
PGWARE Web Host
Joined: 29 Dec 2001 Posts: 1562
|
Posted: Tue Sep 08, 2009 11:26 pm Post subject: |
|
|
If you have a little delphi experience you can implement the SNMP function into the vdsipp. VDSIPP uses the Indy delphi components; one of the components included in that library is the TidSNMP vcl component. It likely would make your job much easier. Take a look at the vdsipp code it isnt that complicated to add in new protocols, it just takes a bit of time. |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Sep 09, 2009 12:47 am Post subject: |
|
|
Unfortunately, I have little to none experience with Delphi. But thanks for the info thow
Maybe one of the dll writers that use Delphi will see this post and consider adding it.
Thanks again P
BTW - For others reading this post, all I need is to be able get the "Connection Table" from a switch. I don't need to control it. |
|
Back to top |
|
|
Rebel49 Contributor
Joined: 23 Aug 2002 Posts: 78 Location: Nova Scotia, Canada
|
Posted: Wed Sep 09, 2009 1:06 pm Post subject: |
|
|
Hello Asian,
I retired from work in 2006 so I haven't had occasion to chat SNMP for quite a while. So I am quite rusty on how it fits together.
But you may interested in this site. Sales oriented but SNMP info is there in the form of brief white papers
http://www.dpstele.com/white-papers/snmp-tutorial/snmp_tutorial_video.php?link=poplinkspod
And I may be able to come up with some code using the windows snmp agent as an example. I will scrounge around my archives as it was Win98 at that time.
REB
REB _________________ OLD and eager! |
|
Back to top |
|
|
Rebel49 Contributor
Joined: 23 Aug 2002 Posts: 78 Location: Nova Scotia, Canada
|
Posted: Thu Sep 10, 2009 12:15 am Post subject: |
|
|
I dusted off this code and added a couple of VDS6 lines and it still works. Computers used were WIN98 and XP with SNMP service enabled.
VDSIPP is required of course and match up the IPs too.
IT was a crude early effort just to make SNMP work.
Maybe the code can provide some ideas.
REB
Code: |
REM version 2.0x major change to using multiple threads
REM 2.07 ADDS TX RID number
%%VERSION = 2.08
option scale,96
option fieldsep,|
option decimalsep,.
external VDSIPP.DLL
#define command, internet
#define function, internet
rem external vdsipp.dll,DEMO
INTERNET REPLACENULL, ON
INTERNET UDP,DESTROY,1
title Udp (SNMP) Example
DIALOG CREATE,PC SNMP %%VERSION,62,117,702,508
REM *** Modified by Dialog Designer on 10/5/03 - 21:58 ***
DIALOG ADD,STYLE,STYLE1,,,B,BLUE,YELLOW
DIALOG ADD,GRADIENT,GRADIENT1,0,0,710,600,cyan,BLUE,,BOTTOMTOTOP
DIALOG ADD,LIST,LIST1,40,6,250,194
DIALOG ADD,LIST,LIST2,40,250,180,194
DIALOG ADD,LIST,LIST3,40,400,150,194
DIALOG ADD,LIST,LIST4,40,550,100,194
DIALOG ADD,TEXT,TEXT1,20,6,250,50,"#"@TAB()RID@TAB()IP AND HOST NAME,,STYLE1
DIALOG ADD,TEXT,TEXT2,20,250,200,50,SYSTEM,,STYLE1
DIALOG ADD,TEXT,TEXT3,20,400,200,50,UPTIME,,STYLE1
DIALOG ADD,TEXT,TEXT4,20,550,100,50,PINGS,,STYLE1
REM DIALOG ADD,GROUP,GROUP1,400,10,680,90,RAW MESSAGE RECEIVED,,STYLE1
DIALOG ADD,SHAPE,SHAPE1,400,10,680,80,$00F8C261,BLACK,,ROUNDRECT,invisible
DIALOG ADD,TEXT,DEGREES,410,50,600,50,,,transparent
DIALOG ADD,EDIT,EDIT1,260,30,120,20,192.168.0.100,,readonly
DIALOG ADD,EDIT,EDIT2,285,30,120,20,192.168.0.101,,readonly
DIALOG ADD,EDIT,EDIT3,310,30,120,20,192.168.0.102,,readonly
DIALOG ADD,EDIT,EDIT4,335,30,120,20,192.168.0.103,,readonly
DIALOG ADD,CHECK,CHECK1,265,10,10,10,,yellow,blue,
DIALOG ADD,CHECK,CHECK2,290,10,10,10,,yellow,blue,
DIALOG ADD,CHECK,CHECK3,315,10,10,10,,yellow,blue,
DIALOG ADD,CHECK,CHECK4,340,10,10,10,,yellow,blue,
DIALOG SHOW
%%reports = 0
%%noreports = 0
REM %%MESSAGE NOW CONTAINS THE DESIRED FRAME INFO
rem ** CREATE the UDP client and turn THREADS ON **
INTERNET UDP,NEW,1
INTERNET UDP,CREATE,1
INTERNET UDP,ACTIVATE,1
INTERNET UDP,THREADS,1,ON
INTERNET UDP,NEW,2
INTERNET UDP,CREATE,2
INTERNET UDP,ACTIVATE,2
INTERNET UDP,THREADS,2,ON
INTERNET UDP,NEW,3
INTERNET UDP,CREATE,3
INTERNET UDP,ACTIVATE,3
INTERNET UDP,THREADS,3,ON
INTERNET UDP,NEW,4
INTERNET UDP,CREATE,4
INTERNET UDP,ACTIVATE,4
INTERNET UDP,THREADS,4,ON
%%TN = 0
:start
%E = @event()
GOSUB CHECKBOX
IF @DLGTEXT(CHECK1)
%%HOST = PC1
%%IP = 192.168.0.100
%%THREAD = 1
gosub send
END
IF @DLGTEXT(CHECK2)
%%HOST = PC2
%%IP = 192.168.0.101
%%THREAD = 2
gosub send
END
IF @DLGTEXT(CHECK3)
%%HOST = PC3
%%IP = 192.168.0.102
%%THREAD = 3
gosub send
END
IF @DLGTEXT(CHECK4)
%%HOST = PC4
%%IP = 192.168.0.103
%%THREAD = 4
gosub send
END
GOSUB CHECKBOX
%e = @EVENT()
wait 2
IF @equal(@EVENT(),CLOSE)
GOTO CLOSE
END
goto start
:send
%A = ""
INTERNET UDP,SERVER,%%THREAD,%%IP,161
GOSUB MAKEMESSAGE
INTERNET UDP,SEND,%%THREAD,%%MESSAGE
rem this wait event adds a 1 sec window for which to
rem receive the incoming message.
wait event,1
%E = @event()
goto %E
:Timer
goto process
:UDP1ONMESSAGE
%%IP = 192.168.0.100
goto process
:UDP2ONMESSAGE
%%IP = 192.168.0.101
goto process
:UDP3ONMESSAGE
%%IP = 192.168.0.102
goto process
:UDP4ONMESSAGE
%%IP = 192.168.0.103
goto process
:Process
rem ** A message has been received from the UDP server **
%A = @internet(udp,message,%%THREAD)
%%Reports = @succ(%%reports)
rem list add,list1,"---------------------------------------------------------"
rem list add,list1," "
rem list seek,list1,@pred(@count(list1))
rem IF @greater(@count(1),10)
rem info 10 reached
rem END
GOSUB CHECKBOX
%%MSGFLAG = 0
IF %A
%%MSGFLAG = 1
REM #######################################################################
REM THESE LINES REMOVE "NULLS" AND MAKE A NEW STRING %B with CHR(0) instead
REM #######################################################################
%B = %A
:NULLREMOVE
%N = @POS(^NULL^,%A)
IF @EQUAL(%N,0)
REM IF EQUAL 0 MEANS NULL NOT FOUND - END
ELSE
REM 6 CHARS AT ^NULL^ LOCATION
%A = @STRDEL(%A,%N,@SUM(%N,5))
REM REPLACE WITH CHR(0)
%A = @STRINS(%A,%N,@CHR(0))
REM RETEST
GOTO NULLREMOVE
END
REM ######## NULL REMOVE HA BEEN COMPLETED %A HOLDS THE NEW STRING ###########################
%%CHECK = @CHR(2)@CHR(1)@CHR(0)@CHR(2)@CHR(1)@CHR(0)
%%CHECKPOS = @POS(%%CHECK,%A)
%%RRID = @ASC(@SUBSTR(%A,@PRED(%%CHECKPOS)))
REM info %%CHECKPOS - %%RRID
%%INFO = %%OIDA
GOSUB EXTRACT
%%INFO1 = %%MSG
%%INFO = %%OIDB
GOSUB EXTRACT
%%INFO2 = %%MSG
%%INFO = %%OIDC
GOSUB EXTRACT
%%INFO3 = %%MSG
%%INFO = %%OIDD
GOSUB EXTRACT
%%INFO4 = %%MSG
REM INFO POS1 is %%POS1 @CR()POS2 is %%POS2 @CR()POS3 is %%POS3@CR() Message length is %%MSGLEN @CR()%%MSG
ELSE
%%INFO1 = --- no reply ---
%%INFO2 = @tab()"----------"
%%INFO3 = ""
%%INFO4 = ""
%A = ""
%B = ""
%%RRID = " "
END
%%TN = @SUCC(%%TN)
%%LL = @sum(@count(list1),1)
%%LL2 =14
%%LL1 = @PRED(%%LL2)
if @greater(%%LL,%%LL2)
rem info list is 11
list seek,list1,%%LL1
list delete,list1
list seek,list1,0
list seek,list2,%%LL1
list delete,list2
list seek,list2,0
list seek,list3,%%LL1
list delete,list3
list seek,list3,0
list seek,list4,%%LL1
list delete,list4
list seek,list4,0
end
%%job = %%info3
IF @EQUAL(%%MSGFLAG,1)
%%POS = 1
%%LENTT = @len(%%INFO3)
GOSUB %%LENTT
%%TIMETICK = %%RESULT
GOSUB UPTIME
%%job = %%info4
%%POS = 1
%%LENTT = @len(%%INFO4)
GOSUB %%LENTT
%%PING = %%RESULT
ELSE
%%TIME = ----
%%TIMETICK = ----
%%PING = ----
END
REM ##########################################################################
REM ########################## OUTPUT LISTS ##################################
REM ##########################################################################
list insert,list1,%%TN@tab()%%RID %%RRID@TAB() - %%IP - %%INFO1
list seek,list1,0
list insert,list2, %%INFO2
list seek,list2,0
list insert,list3," "%%TIME
list seek,list3,0
list insert,list4," "%%ping
list seek,list4,0
dialog set,degrees,Transaction # %%TN --> %%HOST message is %B
exit
REM ##########################################################################
:CLOSE
rem ** Always destroy the client protocols before exiting
rem your script, to prevent from errors and crashes **
INTERNET UDP,DESTROY,1
INTERNET UDP,DESTROY,2
INTERNET UDP,DESTROY,3
INTERNET UDP,DESTROY,4
exit
REM #########################################################################
REM ############333 SUBROUTINE TO EXAMINE CHECKBOXES #######################
REM #########################################################################
:CHECKBOX
IF @Dlgtext(check1)
dialog enable,edit1
ELSE
dialog disable,edit1
end
IF @Dlgtext(check2)
dialog enable,edit2
ELSE
dialog disable,edit2
end
IF @Dlgtext(check3)
dialog enable,edit3
ELSE
dialog disable,edit3
end
IF @Dlgtext(check4)
dialog enable,edit4
ELSE
dialog disable,edit4
end
EXIT
REM #########################################################################
REM ########## SUBROUTINE TO EXTRACT INFO FROM SNMP RESPONSE ###############
REM #########################################################################
:EXTRACT
%%POS1 = @POS(%%INFO,%A)
%%POS2 = @SUM(@LEN(%%INFO),%%POS1)
%%POS3 = @SUM(%%POS2,1)
%%MSGLEN = @ASC(@SUBSTR(%A,%%POS3))
%%MSG = @SUBSTR(%A,@SUM(%%POS3,1),@SUM(%%POS3,%%MSGLEN))
exit
REM #########################################################################
REM ########### SUBROUTINE to CALCULATE TIMETICKS AND COUNTERS ##########
REM #########################################################################
:4
%V = @ASC(@SUBSTR(%%JOB,%%POS))
%%RESULT = @PROD(%V,256)
%%RESULT = @PROD(%%RESULT,256)
%%X4 = @PROD(%%RESULT,256)
%%POS = @SUCC(%%POS)
:3
%x = @ASC(@SUBSTR(%%JOB,%%POS))
%%RESULT = @PROD(%X,256)
%%X3 = @PROD(%%RESULT,256)
%%POS = @SUCC(%%POS)
:2
%y = @ASC(@SUBSTR(%%JOB,%%POS))
%%X2 = @PROD(%Y,256)
%%POS = @SUCC(%%POS)
:1
%Z = @ASC(@SUBSTR(%%JOB,%%POS))
%%X1 = %Z
%%RESULT = @SUM(%%X4,%%X3)
%%RESULT = @SUM(%%RESULT,%%X2)
%%RESULT = @SUM(%%RESULT,%%X1)
:0
%%X4 = 0
%%X3 = 0
%%X2 = 0
%%X1 = 0
exit
REM #########################################################################
REM ############## SUBROUTINE to CONVERT TIMETICKS TO TIME ##############
REM #########################################################################
:UPTIME
%%SECS = @DIV(%%TIMETICK,100)
REM SECS PER DAY 86400
%%DAYS = @DIV(%%SECS,86400)
%%REMAINDERD = @DIFF(%%SECS,@PROD(%%DAYS,86400))
%%HOURS = @DIV(%%REMAINDERD,3600)
%%REMAINDERH = @DIFF(%%REMAINDERD,@PROD(%%Hours,3600))
%%MINS = @DIV(%%REMAINDERH,60)
%%SECS = @DIFF(%%REMAINDERH,@PROD(%%MINS,60))
REM info %%DAYS DAYS %%REMAINDERD REMAINDER@CR()%%HOURS HOURS %%REMAINDERH@CR()%%MINS MINS @CR() %%SECS SECS
%%TIME = %%DAYS""d" "%%HOURS""h" "%%MINS""m" "%%SECS""s
%%s = %%SECS s
exit
REM #########################################################################
REM ############## SUBROUTINE to MAKE MESSAGE FOR TRANSMIT ##############
REM #########################################################################
:MAKEMESSAGE
REM INCREMENT REQUEST ID
%%RID = @RANDOM(100,199)
%A = @CHR(48)@CHR(80)@CHR(2)@CHR(1)^NULL^@CHR(4)@CHR(6)
%B = public
%C = @CHR(160)@CHR(67)@CHR(2)@CHR(1)@CHR(%%RID)@CHR(2)@CHR(1)^NULL^@CHR(2)@CHR(1)^NULL^
%D = @CHR(48)@CHR(56)@CHR(48)@CHR(12)@CHR(6)@CHR(8)
%%OID1 = @CHR(43)@CHR(6)@CHR(1)@CHR(2)@CHR(1)@CHR(1)@CHR(5)^NULL^
%%OIDA = @CHR(43)@CHR(6)@CHR(1)@CHR(2)@CHR(1)@CHR(1)@CHR(5)@CHR(0)
%%EE = @CHR(5)^NULL^@CHR(48)@CHR(12)@CHR(6)@CHR(8)
%%OID2 = @CHR(43)@CHR(6)@CHR(1)@CHR(2)@CHR(1)@CHR(1)@CHR(1)^NULL^
%%OIDB = @CHR(43)@CHR(6)@CHR(1)@CHR(2)@CHR(1)@CHR(1)@CHR(1)@CHR(0)
%F = @CHR(5)^NULL^@CHR(48)@CHR(12)@CHR(6)@CHR(8)
%%OID3 = @CHR(43)@CHR(6)@CHR(1)@CHR(2)@CHR(1)@CHR(1)@CHR(3)^NULL^
%%OIDC = @CHR(43)@CHR(6)@CHR(1)@CHR(2)@CHR(1)@CHR(1)@CHR(3)@CHR(0)
%G = @CHR(5)^NULL^@CHR(48)@CHR(12)@CHR(6)@CHR(8)
%%OID4 = @CHR(43)@CHR(6)@CHR(1)@CHR(2)@CHR(1)@CHR(5)@CHR(1)^NULL^
%%OIDD = @CHR(43)@CHR(6)@CHR(1)@CHR(2)@CHR(1)@CHR(5)@CHR(1)@CHR(0)
%H = @CHR(5)^NULL^
%%message = %A%B%C%D%%OID1%%EE%%OID2%F%%OID3%G%%OID4%H
EXIT
|
_________________ OLD and eager! |
|
Back to top |
|
|
Rebel49 Contributor
Joined: 23 Aug 2002 Posts: 78 Location: Nova Scotia, Canada
|
Posted: Thu Sep 10, 2009 12:19 am Post subject: |
|
|
cool smiley is replacing 8 followed by )
REB _________________ OLD and eager! |
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Thu Sep 10, 2009 5:40 am Post subject: |
|
|
Rebel49 wrote: | cool smiley is replacing 8 followed by )
REB |
Just use the 'Code' tag to enclose your VDS code...
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
Rebel49 Contributor
Joined: 23 Aug 2002 Posts: 78 Location: Nova Scotia, Canada
|
Posted: Thu Sep 10, 2009 12:41 pm Post subject: |
|
|
Like I said..... rusty, real rusty and some say crusty!
Thanks Dread
REB _________________ OLD and eager! |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Fri Sep 11, 2009 10:59 pm Post subject: |
|
|
Many thanks Rebel Sorry it took me so long to get back to the forum to see your code.
This code looks like it will save me a lot of time. I was curious how you broke down the OIDs and I think it's starting to make sense now thanks to your code.
I'm gonna go play now
bl
Aslan |
|
Back to top |
|
|
Rebel49 Contributor
Joined: 23 Aug 2002 Posts: 78 Location: Nova Scotia, Canada
|
Posted: Tue Sep 15, 2009 2:56 pm Post subject: |
|
|
Just to elaborate a bit, once I had the MIB of the equipment to communicate with, I used a MIB browser to send and receive SNMP messagesto that device. I forget what I used back then but this seems to be a good current free version.
www.ireasoning.com/mibbrowser.shtml
I then captured and filtered the SNMP packets with WIRE SHARK.
Then I tried to duplicated the packet with VDS and VDSIPP. Once that worked it was a matter of gleaning the info from the packet payload with VDS. I had the assistance of a SNMP book which described the packet structure in detail. I seem to recall the field lengths bytes were the most troublesome. But once I did a few it became pretty easy. Eventually I could embed several OIDS in a packet and the messaging became quite efficient.
Hope that might help
REB _________________ OLD and eager! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|