Git Product home page Git Product logo

Comments (6)

calmh avatar calmh commented on August 21, 2024

Yeah, the readme is outdated. This is better accomplished by doing the reading yourself and then using ParseBuffer. Probably ParseReader should not exist either, but now it does. :)

from ipfix.

isage avatar isage commented on August 21, 2024

Hm. But how do i know, how big a buffer i should use? So i don't run into short read - malformed packet?

from ipfix.

calmh avatar calmh commented on August 21, 2024

from ipfix.

isage avatar isage commented on August 21, 2024

Oh, right. But with such a big buffer i'm getting unexpected EOF.
Sorry for bothering you, but what am i doing wrong?

package main

import (
    "net"
    "log"
    "fmt"
    "github.com/calmh/ipfix"
)

func main() {

  pc, err := net.ListenPacket("udp", ":2055")
  if err != nil {
    log.Fatal(err)
  }
  defer pc.Close()

  s := ipfix.NewSession()
  i := ipfix.NewInterpreter(s)

  buffer := make([]byte, 65507)

  for {
    pc.ReadFrom(buffer)

    msg, err := s.ParseBuffer(buffer)
    if err != nil {
        panic(err)
    }

    var fieldList []ipfix.InterpretedField
    for _, record := range msg.DataRecords {
        fieldList = i.InterpretInto(record, fieldList)
        fmt.Println(fieldList)
    }
  }
}

from ipfix.

calmh avatar calmh commented on August 21, 2024

You need to only give it the part of the buffer that was actually read into. See the example I just wrote up in the readme in the commit linked above^ and see if that helps

from ipfix.

isage avatar isage commented on August 21, 2024

Yep, that definitely helps. Thank you!

from ipfix.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.