Socket
Socket
Sign inDemoInstall

udp-header

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    udp-header

UDP header serialization


Version published
Weekly downloads
49
increased by36.11%
Maintainers
1
Install size
25.5 kB
Created
Weekly downloads
 

Readme

Source

udp-header

UDP header serialization.

Build Status

Example

var UdpHeader = require('udp-header');

// parse UDP headers in
var udph = new UdpHeader(inputBuf, inputOffset);
udph.srcPort === 52;
udph.dstPort === 5432;
udph.dataLength === 500;
udph.totalLength === 508;
udph.length === 8;

// write UDP headers out
var out = udph.toBuffer();

// By default, the UDP checksum is not calculated.  It is passed through from
// if you parse an existing buffer or set to the opts.checksum constructor
// option.
//
// To calculate the checksum you must call setChecksum() with the ip header
// object and udp payload buffer.
// the src IP, dst IP, and data buffer.
var iph = new IpHeader({dst:'1.1.1.1', src:'2.2.2.2'});
udph.setChecksum(iph, buf, offset);

// To write a buffer in place, provide the buffer and option offset
// after the packet object.
udph.toBuffer(buf, offset);

Keywords

FAQs

Last updated on 01 Mar 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc