An acceptable segment: RFC 793 page 26.
191088
def segmentAcceptable(RCV_NXT, RCV_WND, SEG_SEQ, SEG_LEN):
    
    if SEG_LEN == 0 and RCV_WND == 0:
        return SEG_SEQ == RCV_NXT
    if SEG_LEN == 0 and RCV_WND > 0:
        return ((RCV_NXT <= SEG_SEQ) and (SEG_SEQ < RCV_NXT + RCV_WND))
    if SEG_LEN > 0 and RCV_WND == 0:
        return False
    if SEG_LEN > 0 and RCV_WND > 0:
        return ((  (RCV_NXT <= SEG_SEQ) and (SEG_SEQ < RCV_NXT + RCV_WND))
                or ((RCV_NXT <= SEG_SEQ+SEG_LEN-1) and
                    (SEG_SEQ+SEG_LEN-1 < RCV_NXT + RCV_WND)))
    assert 0, 'Should be impossible to get here.'
    return False
1091685
function Packet(e) {
    if(e instanceof Buffer) {
        this.data   = e;
        this.length = this.data.length;
    }else if((typeof Buffer) != 'undefined' && e.data instanceof Buffer) {
        this.data   = e.data;
        this.length = this.data.length;
    }else{
        this.data   = new DataView(e.data);
        this.length = this.data.byteLength;
    }

    this.offset = 0;
}
1130244
void signalProtocolEstablished(String inboundProtocol) {
        assert !channel.isClientMode() : "Signal protocol should only be made on channel in serverMode";
        this.inboundProtocol = inboundProtocol;
        channel.outboundPipeline().wakeup();
    }
534568
def _domain_event_block_threshold_cb(conn, domain, dev, path, threshold, excess, opaque):
    '''
    
    '''
    _salt_send_domain_event(opaque, conn, domain, opaque['event'], {
        'dev': dev,
        'path': path,
        'threshold': threshold,
        'excess': excess
    })
272563
private void processHyperlinkData(Resource resource, byte[] data)
   {
      if (data != null)
      {
         int offset = 12;
         String hyperlink;
         String address;
         String subaddress;

         offset += 12;
         hyperlink = MPPUtility.getUnicodeString(data, offset);
         offset += ((hyperlink.length() + 1) * 2);

         offset += 12;
         address = MPPUtility.getUnicodeString(data, offset);
         offset += ((address.length() + 1) * 2);

         offset += 12;
         subaddress = MPPUtility.getUnicodeString(data, offset);

         resource.setHyperlink(hyperlink);
         resource.setHyperlinkAddress(address);
         resource.setHyperlinkSubAddress(subaddress);
      }
   }
5167
def _supported_rule(protocol, ethertype):
        """"""
        if not protocol or protocol not in utils.SUPPORTED_SG_PROTOCOLS:
            return False

        if ethertype != n_const.IPv4:
            return False

        return True
148119
def secure_compare(a, b)
      fixed_length_secure_compare(::Digest::SHA256.digest(a), ::Digest::SHA256.digest(b)) && a == b
    end
220608
function rtcPipe(link, initiate)
  {
    // existing noop
    if(link.rtcPipe) return link.rtcPipe;

    // outgoing signal cache and sender
    var signals = [];
    function signal(sig){
      if(signals.indexOf(sig) == -1) signals.push(sig);
      if(!link.x) return;
      // send each signal as an individual lossy channel
      var json = {type:'webrtc',c:link.x.cid()};
      json.signal = sig;
      mesh.log.debug('sending signal to',link.hashname,json);
      link.x.send({json:json});
    }

    // new pipe
    var pipe = link.rtcPipe = new telehash.Pipe('webrtc');
    pipe.cloaked = true;
    pipe.id = link.hashname;
    pipe.path = {type:'webrtc'};
    
    // handle outgoing packets based on rtc state
    pipe.onSend = function(packet, link, cb){
      if(!packet) return cb('no packet');
      var safe = packet.toString('base64')
      if(link.rtc.connected)
      {
        mesh.log.debug('rtc send',safe.length);
        link.rtc.send(safe);
        return cb();
      }
      mesh.log.debug('rtc still signalling',signals.length);
      // cache most recent packet
      link.rtc.cached = safe;
      if(!link.up) return cb('not connected');
      // if there's signals yet, resend them as they could have been lost
      signals.forEach(signal);
    }

    // new webrtc connection
    link.rtc = new rtc.peer({initiate:initiate, _self:'self', _peer:link.hashname});
    link.rtc.DEBUG = true;
    link.rtc.onsignal = signal;
    link.rtc.onconnection = function() {
      mesh.log.debug('RTC CONNECTED');
      link.rtc.connected = true;
      signals = []; // empty any cached signals too
      if(link.rtc.cached) link.rtc.send(link.rtc.cached);
      link.rtc.cached = false;
    }
    link.rtc.onmessage = function(safe) {
      mesh.log.debug('rtc receive',safe.length);
      var packet = lob.decloak(new Buffer(safe,'base64'));
      if(!packet) return mesh.log.info('dropping invalid packet',safe);
      mesh.receive(packet,pipe);
    }
    
    return pipe;
  }
371614
def chomp_protocol(url):
        
        if '+' in url:
            url = url.split('+', 1)[1]
        scheme, netloc, path, query, frag = urlparse.urlsplit(url)
        rev = None
        if '@' in path:
            path, rev = path.rsplit('@', 1)
        url = urlparse.urlunsplit((scheme, netloc, path, query, ''))
        if url.startswith('ssh://git@github.com/'):
            url = url.replace('ssh://', 'git+ssh://')
        elif '://' not in url:
            assert 'file:' not in url
            url = url.replace('git+', 'git+ssh://')
            url = url.replace('ssh://', '')
        return url
801829
def _urlnorm(cls, uri):
        """"""
        (scheme, authority, path, query, fragment) = parse_uri(uri)
        if not scheme or not authority:
            raise Exception("Only absolute URIs are allowed. uri = %s" % uri)

        scheme = scheme.lower()
        authority = authority.lower()

        if not path:
            path = "/"

        # Could do syntax based normalization of the URI before
        # computing the digest. See Section 6.2.2 of Std 66.
        request_uri = query and "?".join([path, query]) or path
        defrag_uri = scheme + "://" + authority + request_uri

        return defrag_uri
217340
def srp(x, promisc=None, iface=None, iface_hint=None, filter=None,
        nofilter=0, type=ETH_P_ALL, *args, **kargs):
    """"""
    if iface is None and iface_hint is not None:
        iface = conf.route.route(iface_hint)[0]
    s = conf.L2socket(promisc=promisc, iface=iface,
                      filter=filter, nofilter=nofilter, type=type)
    result = sndrcv(s, x, *args, **kargs)
    s.close()
    return result
913457
def is_valid_for(self, entry_point, protocol):
        """"""
        return self.available_for_entry_point(entry_point) and self.available_for_protocol(protocol)
247170
private void verifyReservedBit1(WebSocketFrame frame) throws WebSocketException
    {
        // If a per-message compression extension has been agreed.
        if (mPMCE != null)
        {
            // Verify the RSV1 bit using the rule described in RFC 7692.
            boolean verified = verifyReservedBit1ForPMCE(frame);

            if (verified)
            {
                return;
            }
        }

        if (frame.getRsv1() == false)
        {
            // No problem.
            return;
        }

        // The RSV1 bit of a frame is set unexpectedly.
        throw new WebSocketException(
            WebSocketError.UNEXPECTED_RESERVED_BIT, "The RSV1 bit of a frame is set unexpectedly.");
    }
822566
function send(segment) {
    var client = this.socket;
    var formatted = segment.format();
    var data = PROTOCOL_HEADER + PROTOCOL_DELIMITER + formatted;
    var message = new Buffer(data);

    var short = '{"trace_id:"' + segment.trace_id + '","id":"' + segment.id + '"}';
    var type = segment.type === 'subsegment' ? 'Subsegment' : 'Segment';

    client.send(message, 0, message.length, this.daemonConfig.udp_port, this.daemonConfig.udp_ip, function(err) {
      if (err) {
        if (err.code === 'EMSGSIZE')
          logger.getLogger().error(type + ' too large to send: ' + short + ' (' + message.length + ' bytes).');
        else
          logger.getLogger().error('Error occured sending segment: ', err);
      } else {
        logger.getLogger().debug(type + ' sent: {"trace_id:"' + segment.trace_id + '","id":"' + segment.id + '"}');
        logger.getLogger().debug('UDP message sent: ' + segment);
      }
    });
  }
590486
def gprsSuspensionRequest():
    """"""
    a = TpPd(pd=0x6)
    b = MessageType()
    c = Tlli()
    d = RoutingAreaIdentification()
    e = SuspensionCause()
    packet = a / b / c / d / e
    return packet
1098225
def geturi(self):
        
        scheme, authority, path, query, fragment = self

        # RFC 3986 5.3. Component Recomposition
        result = []
        if scheme is not None:
            result.extend([scheme, self.COLON])
        if authority is not None:
            result.extend([self.SLASH, self.SLASH, authority])
        result.append(path)
        if query is not None:
            result.extend([self.QUEST, query])
        if fragment is not None:
            result.extend([self.HASH, fragment])
        return self.EMPTY.join(result)
315920
function protocol(value) {
  var val = value.slice(-6).toLowerCase()
  return val === mailto || val.slice(-5) === https || val.slice(-4) === http
}