~juju-qa/ubuntu/yakkety/juju/2.0-rc3-again

« back to all changes in this revision

Viewing changes to src/code.google.com/p/go.net/ipv4/genericopt_posix.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-04-24 22:34:47 UTC
  • Revision ID: package-import@ubuntu.com-20130424223447-f0qdji7ubnyo0s71
Tags: upstream-1.10.0.1
ImportĀ upstreamĀ versionĀ 1.10.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2012 The Go Authors.  All rights reserved.
 
2
// Use of this source code is governed by a BSD-style
 
3
// license that can be found in the LICENSE file.
 
4
 
 
5
// +build darwin freebsd linux netbsd openbsd windows
 
6
 
 
7
package ipv4
 
8
 
 
9
import (
 
10
        "syscall"
 
11
)
 
12
 
 
13
// TOS returns the type-of-service field value for outgoing packets.
 
14
func (c *genericOpt) TOS() (int, error) {
 
15
        if !c.ok() {
 
16
                return 0, syscall.EINVAL
 
17
        }
 
18
        fd, err := c.sysfd()
 
19
        if err != nil {
 
20
                return 0, err
 
21
        }
 
22
        return ipv4TOS(fd)
 
23
}
 
24
 
 
25
// SetTOS sets the type-of-service field value for future outgoing
 
26
// packets.
 
27
func (c *genericOpt) SetTOS(tos int) error {
 
28
        if !c.ok() {
 
29
                return syscall.EINVAL
 
30
        }
 
31
        fd, err := c.sysfd()
 
32
        if err != nil {
 
33
                return err
 
34
        }
 
35
        return setIPv4TOS(fd, tos)
 
36
}
 
37
 
 
38
// TTL returns the time-to-live field value for outgoing packets.
 
39
func (c *genericOpt) TTL() (int, error) {
 
40
        if !c.ok() {
 
41
                return 0, syscall.EINVAL
 
42
        }
 
43
        fd, err := c.sysfd()
 
44
        if err != nil {
 
45
                return 0, err
 
46
        }
 
47
        return ipv4TTL(fd)
 
48
}
 
49
 
 
50
// SetTTL sets the time-to-live field value for future outgoing
 
51
// packets.
 
52
func (c *genericOpt) SetTTL(ttl int) error {
 
53
        if !c.ok() {
 
54
                return syscall.EINVAL
 
55
        }
 
56
        fd, err := c.sysfd()
 
57
        if err != nil {
 
58
                return err
 
59
        }
 
60
        return setIPv4TTL(fd, ttl)
 
61
}