| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- package main
- import (
- //"github.com/joaojeronimo/go-crc16"
- "bytes"
- "encoding/binary"
- //"strconv"
- "fmt"
- "net"
- "encoding/hex"
- //"strconv"
- )
- func IntToBytes(data int64) []byte {
- bytebuf := bytes.NewBuffer([]byte{})
- binary.Write(bytebuf, binary.BigEndian, data)
- return bytebuf.Bytes()
- }
- func ipToHexString(ip string) string {
- ipa := net.ParseIP(ip)
- p1 := fmt.Sprintf("%X", ipa[12])
- if len(p1) == 1 {
- p1 = "0" + p1
- }
- p2 := fmt.Sprintf("%X", ipa[13])
- if len(p2) == 1 {
- p2 = "0" + p2
- }
- p3 := fmt.Sprintf("%X", ipa[14])
- if len(p3) == 1 {
- p3 = "0" + p3
- }
- p4 := fmt.Sprintf("%X", ipa[15])
- if len(p4) == 1 {
- p4 = "0" + p4
- }
- s := fmt.Sprintf("%s%s%s%s", p1, p2, p3, p4)
- return s
- }
- func HexStringToBytes(s string) []byte {
- b, _ := hex.DecodeString(s)
- return b
- }
- func main () {
-
- /*str := "C0A8E3D4"
-
- bs := []byte{}
- for i:=0 ; i<len(str) ; i=i+2 {
- fmt.Println(str[i:i+2])
- b, _ := strconv.ParseInt(str[i:i+2], 16, 16)
- fmt.Println(b)
- bs = append(bs, IntToBytes(b)[0])
- }
-
-
- fmt.Printf("%X", bs)
- */
-
-
- //fmt.Println( crc16.Kermit([]byte("Hello World")) )
-
- //c0a8ae5b
- //fmt.Printf( "\n%x\n", HexStringToBytes(ipToHexString("192.168.174.91")))
-
-
- fmt.Printf( "\n%x\n", HexStringToBytes(ipToHexString("127.0.0.1")))
-
- for i:=0 ; i<100 ; i++ {
- fmt.Printf(`snmpset -v 2c -c 2811 192.168.169.26 .1.3.6.1.4.1.9.9.16.1.1.1.16.123456%d i 6
- snmpset -v 2c -c 2811 192.168.169.26 .1.3.6.1.4.1.9.9.16.1.1.1.16.123456%d i 5
- snmpset -v 2c -c 2811 192.168.169.26 .1.3.6.1.4.1.9.9.16.1.1.1.15.123456%d s "matrix"
- snmpset -v 2c -c 2811 192.168.169.26 .1.3.6.1.4.1.9.9.16.1.1.1.2.123456%d i 1
- snmpset -v 2c -c 2811 192.168.169.26 .1.3.6.1.4.1.9.9.16.1.1.1.5.123456%d i 64
- snmpset -v 2c -c 2811 192.168.169.26 .1.3.6.1.4.1.9.9.16.1.1.1.4.123456%d i 5
- snmpset -v 2c -c 2811 192.168.169.26 .1.3.6.1.4.1.9.9.16.1.1.1.6.123456%d i 500
- snmpset -v 2c -c 2811 192.168.169.26 .1.3.6.1.4.1.9.9.16.1.1.1.17.123456%d s ""
- snmpset -v 2c -c 2811 192.168.169.26 .1.3.6.1.4.1.9.9.16.1.1.1.3.123456%d x 7f000001
- snmpset -v 2c -c 2811 192.168.169.26 .1.3.6.1.4.1.9.9.16.1.1.1.16.123456%d i 1
- `,i,i,i,i,i,i,i,i,i,i)
-
- }
- }
|