<commit_before>/*
 * Copyright (c) 2014, The Tor Project, Inc.
 * See LICENSE for licensing information
 */

package natpmp

import (
	"fmt"
	"net"
	"syscall"
)

type routeEntry struct {
	syscall.RtMsg
	SrcNet net.IPNet
	DstNet net.IPNet
	GwAddr net.IP
}

func parseRTMNewRoute(m *syscall.NetlinkMessage) (*routeEntry, error) {
	// The runtime doesn't expose RtMsg, which is needed to get the length of
	// various fields, so ensure that there is enough data present, and decode
	// the header by hand.
	if len(m.Data) < syscall.SizeofRtMsg {
		// Trunncated message.
		return nil, syscall.EINVAL
	}
	e := &routeEntry{}
	e.Family = m.Data[0]
	e.Dst_len = m.Data[1]
	e.Src_len = m.Data[2]
	e.Tos = m.Data[3]
	e.Table = m.Data[4]
	e.Protocol = m.Data[5]
	e.Scope = m.Data[6]
	e.Type = m.Data[7]
	e.Flags = uint32(m.Data[8]<<24) | uint32(m.Data[9]<<16) | uint32(m.Data[10]<<8) | uint32(m.Data[11])
	if e.Family != syscall.AF_INET {
		return nil, syscall.EAFNOSUPPORT
	}
<commit_msg>(FIXUP) Improve the Linux implementation of getGateway().<commit_after>/*
 * Copyright (c) 2014, The Tor Project, Inc.
 * See LICENSE for licensing information
 */

package natpmp

import (
	"fmt"
	"net"
	"syscall"
)

type routeEntry struct {
	syscall.RtMsg
	SrcNet net.IPNet
	DstNet net.IPNet
	GwAddr net.IP
}

func parseRTMNewRoute(m *syscall.NetlinkMessage) (*routeEntry, error) {
	// The runtime doesn't expose RtMsg, which is needed to get the length of
	// various fields, so ensure that there is enough data present, and decode
	// the header by hand.
	if len(m.Data) < syscall.SizeofRtMsg {
		// Trunncated message.
		return nil, syscall.EINVAL
	}
	e := &routeEntry{}
	e.Family = m.Data[0]
	e.Dst_len = m.Data[1]
	e.Src_len = m.Data[2]
	e.Tos = m.Data[3]
	e.Table = m.Data[4]
	e.Protocol = m.Data[5]
	e.Scope = m.Data[6]
	e.Type = m.Data[7]
	e.Flags = uint32(m.Data[8])<<24 | uint32(m.Data[9])<<16 | uint32(m.Data[10])<<8 | uint32(m.Data[11])
	if e.Family != syscall.AF_INET {
		return nil, syscall.EAFNOSUPPORT
	}

{'fraction_non_alphanumeric': 0.14635364635364637, 'fraction_numerical': 0.030969030969030968, 'mean_word_length': 3.6152073732718892, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5269348', 'n_tokens_mistral': 875, 'n_tokens_neox': 810, 'n_words': 206}