update ESR base to 115; update EV roots, certs, HSTS, pins, TLDs, TZs; update usrsctp; security pullup; more comprehensive nuisance script blocking; fixes for #488, #566
This commit is contained in:
parent
17b23692fe
commit
55284dd803
|
@ -10,7 +10,7 @@ print <<'EOF';
|
|||
/* nsSiteSecurityService.cpp, you shouldn't be #including it. */
|
||||
/*****************************************************************************/
|
||||
|
||||
/* imported from ESR91 by TenFourFox conversion script */
|
||||
/* imported from ESR115 by TenFourFox conversion script */
|
||||
|
||||
#include <stdint.h>
|
||||
EOF
|
|
@ -390,7 +390,14 @@ if (!defined($json_ref->{'license'}) ||
|
|||
|
||||
select(STDOUT); $|++;
|
||||
%dupedupe = ();
|
||||
foreach $a (@{ $json_ref->{'categories'}->{'Cryptomining'} }) {
|
||||
&emit('Cryptomining');
|
||||
&emit('FingerprintingInvasive');
|
||||
# considering
|
||||
#&emit('Analytics');
|
||||
|
||||
sub emit {
|
||||
my $cat = shift(@_);
|
||||
foreach $a (@{ $json_ref->{'categories'}->{$cat} }) {
|
||||
foreach $b (keys(%{ $a })) {
|
||||
die("illegal newline: $b\n") if ($b =~ /[\r\n]/s);
|
||||
print "// $b\n";
|
||||
|
@ -404,8 +411,15 @@ foreach $a (@{ $json_ref->{'categories'}->{'Cryptomining'} }) {
|
|||
die("illegal quote: $d\n") if ($d =~ /"/);
|
||||
next if ($dupedupe{$d}++);
|
||||
|
||||
# whitelist (with regrets)
|
||||
next if (0 ||
|
||||
$d eq 'ibm.com' ||
|
||||
$d eq 'godaddy.com' ||
|
||||
0);
|
||||
print " BLOK(\"$d\") ||\n";
|
||||
print " BLOKD(\".$d\") ||\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ endif
|
|||
# if we update NSS, we need to remove that patch (TenFourFox issue 512).
|
||||
|
||||
set verbose
|
||||
set release_url=https://hg.mozilla.org/releases/mozilla-esr102/raw-file/tip/
|
||||
set release_url=https://hg.mozilla.org/releases/mozilla-esr115/raw-file/tip/
|
||||
|
||||
# self test to ensure certificates and encryption methods are correct
|
||||
curl ${release_url}/config/milestone.txt || exit
|
||||
|
|
2
CLOBBER
2
CLOBBER
|
@ -22,4 +22,4 @@
|
|||
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
|
||||
# don't change CLOBBER for WebIDL changes any more.
|
||||
|
||||
Rebuild for 102ESR base
|
||||
Rebuild for 115ESR base
|
||||
|
|
|
@ -738,6 +738,7 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
|
|||
if (MOZ_LIKELY(NS_SUCCEEDED(targetBaseURI->GetHost(hostname)))) {
|
||||
ToLowerCase(hostname);
|
||||
#define BLOK(q) hostname.EqualsLiteral(q)
|
||||
#define BLOKD(q) (StringEndsWith(hostname, NS_LITERAL_CSTRING(q)))
|
||||
if (0 ||
|
||||
// This is used as a data source by a lot of UIs,
|
||||
// so we shouldn't block it (e.g., nytimes).
|
||||
|
@ -1273,6 +1274,7 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
|
|||
#include "shavar-blocklist.h"
|
||||
|
||||
0) {
|
||||
#undef BLOKD
|
||||
#undef BLOK
|
||||
// Yup.
|
||||
#ifndef DEBUG
|
||||
|
|
|
@ -1,105 +1,568 @@
|
|||
// a.js
|
||||
// http://zymerget.bid
|
||||
BLOK("alflying.date") ||
|
||||
BLOKD(".alflying.date") ||
|
||||
BLOK("alflying.win") ||
|
||||
BLOKD(".alflying.win") ||
|
||||
BLOK("anybest.site") ||
|
||||
BLOKD(".anybest.site") ||
|
||||
BLOK("flightsy.bid") ||
|
||||
BLOKD(".flightsy.bid") ||
|
||||
BLOK("flightsy.win") ||
|
||||
BLOKD(".flightsy.win") ||
|
||||
BLOK("flightzy.bid") ||
|
||||
BLOKD(".flightzy.bid") ||
|
||||
BLOK("flightzy.date") ||
|
||||
BLOKD(".flightzy.date") ||
|
||||
BLOK("flightzy.win") ||
|
||||
BLOKD(".flightzy.win") ||
|
||||
BLOK("zymerget.bid") ||
|
||||
BLOKD(".zymerget.bid") ||
|
||||
BLOK("zymerget.faith") ||
|
||||
BLOKD(".zymerget.faith") ||
|
||||
// CashBeet
|
||||
// http://cashbeet.com
|
||||
BLOK("cashbeet.com") ||
|
||||
BLOKD(".cashbeet.com") ||
|
||||
BLOK("serv1swork.com") ||
|
||||
BLOKD(".serv1swork.com") ||
|
||||
// CoinHive
|
||||
// https://coinhive.com
|
||||
BLOK("ad-miner.com") ||
|
||||
BLOKD(".ad-miner.com") ||
|
||||
BLOK("authedmine.com") ||
|
||||
BLOKD(".authedmine.com") ||
|
||||
BLOK("bmst.pw") ||
|
||||
BLOKD(".bmst.pw") ||
|
||||
BLOK("cnhv.co") ||
|
||||
BLOKD(".cnhv.co") ||
|
||||
BLOK("coin-hive.com") ||
|
||||
BLOKD(".coin-hive.com") ||
|
||||
BLOK("coinhive.com") ||
|
||||
BLOKD(".coinhive.com") ||
|
||||
BLOK("wsservices.org") ||
|
||||
BLOKD(".wsservices.org") ||
|
||||
// CoinPot
|
||||
// http://coinpot.co
|
||||
BLOK("coinpot.co") ||
|
||||
BLOKD(".coinpot.co") ||
|
||||
// CryptoLoot
|
||||
// https://crypto-loot.com
|
||||
BLOK("cryptaloot.pro") ||
|
||||
BLOKD(".cryptaloot.pro") ||
|
||||
BLOK("crypto-loot.com") ||
|
||||
BLOKD(".crypto-loot.com") ||
|
||||
BLOK("cryptolootminer.com") ||
|
||||
BLOKD(".cryptolootminer.com") ||
|
||||
BLOK("flashx.pw") ||
|
||||
BLOKD(".flashx.pw") ||
|
||||
BLOK("gitgrub.pro") ||
|
||||
BLOKD(".gitgrub.pro") ||
|
||||
BLOK("reauthenticator.com") ||
|
||||
BLOKD(".reauthenticator.com") ||
|
||||
BLOK("statdynamic.com") ||
|
||||
BLOKD(".statdynamic.com") ||
|
||||
BLOK("webmine.pro") ||
|
||||
BLOKD(".webmine.pro") ||
|
||||
// CryptoWebMiner
|
||||
// https://www.crypto-webminer.com
|
||||
BLOK("bitcoin-pay.eu") ||
|
||||
BLOKD(".bitcoin-pay.eu") ||
|
||||
BLOK("crypto-webminer.com") ||
|
||||
BLOKD(".crypto-webminer.com") ||
|
||||
BLOK("ethpocket.de") ||
|
||||
BLOKD(".ethpocket.de") ||
|
||||
BLOK("ethtrader.de") ||
|
||||
BLOKD(".ethtrader.de") ||
|
||||
// Gridcash
|
||||
// https://www.gridcash.net/
|
||||
BLOK("adless.io") ||
|
||||
BLOKD(".adless.io") ||
|
||||
BLOK("gridcash.net") ||
|
||||
BLOKD(".gridcash.net") ||
|
||||
// JSE
|
||||
// http://jsecoin.com
|
||||
BLOK("freecontent.bid") ||
|
||||
BLOKD(".freecontent.bid") ||
|
||||
BLOK("freecontent.date") ||
|
||||
BLOKD(".freecontent.date") ||
|
||||
BLOK("freecontent.stream") ||
|
||||
BLOKD(".freecontent.stream") ||
|
||||
BLOK("hashing.win") ||
|
||||
BLOKD(".hashing.win") ||
|
||||
BLOK("hostingcloud.racing") ||
|
||||
BLOKD(".hostingcloud.racing") ||
|
||||
BLOK("hostingcloud.science") ||
|
||||
BLOKD(".hostingcloud.science") ||
|
||||
BLOK("jsecoin.com") ||
|
||||
BLOKD(".jsecoin.com") ||
|
||||
// MinerAlt
|
||||
// http://mineralt.io
|
||||
BLOK("1q2w3.website") ||
|
||||
BLOKD(".1q2w3.website") ||
|
||||
BLOK("analytics.blue") ||
|
||||
BLOKD(".analytics.blue") ||
|
||||
BLOK("aster18cdn.nl") ||
|
||||
BLOKD(".aster18cdn.nl") ||
|
||||
BLOK("belicimo.pw") ||
|
||||
BLOKD(".belicimo.pw") ||
|
||||
BLOK("besstahete.info") ||
|
||||
BLOKD(".besstahete.info") ||
|
||||
BLOK("dinorslick.icu") ||
|
||||
BLOKD(".dinorslick.icu") ||
|
||||
BLOK("feesocrald.com") ||
|
||||
BLOKD(".feesocrald.com") ||
|
||||
BLOK("gramombird.com") ||
|
||||
BLOKD(".gramombird.com") ||
|
||||
BLOK("istlandoll.com") ||
|
||||
BLOKD(".istlandoll.com") ||
|
||||
BLOK("mepirtedic.com") ||
|
||||
BLOKD(".mepirtedic.com") ||
|
||||
BLOK("mineralt.io") ||
|
||||
BLOKD(".mineralt.io") ||
|
||||
BLOK("pampopholf.com") ||
|
||||
BLOKD(".pampopholf.com") ||
|
||||
BLOK("tercabilis.info") ||
|
||||
BLOKD(".tercabilis.info") ||
|
||||
BLOK("tulip18.com") ||
|
||||
BLOKD(".tulip18.com") ||
|
||||
BLOK("vidzi.tv") ||
|
||||
BLOKD(".vidzi.tv") ||
|
||||
BLOK("yololike.space") ||
|
||||
BLOKD(".yololike.space") ||
|
||||
// Minescripts
|
||||
// http://minescripts.info
|
||||
BLOK("minescripts.info") ||
|
||||
BLOKD(".minescripts.info") ||
|
||||
BLOK("sslverify.info") ||
|
||||
BLOKD(".sslverify.info") ||
|
||||
// MineXMR
|
||||
// http://minexmr.stream
|
||||
BLOK("minexmr.stream") ||
|
||||
BLOKD(".minexmr.stream") ||
|
||||
// NeroHut
|
||||
// https://nerohut.com
|
||||
BLOK("nerohut.com") ||
|
||||
BLOKD(".nerohut.com") ||
|
||||
BLOK("nhsrv.cf") ||
|
||||
BLOKD(".nhsrv.cf") ||
|
||||
// Service4refresh
|
||||
// https://service4refresh.info
|
||||
BLOK("service4refresh.info") ||
|
||||
BLOKD(".service4refresh.info") ||
|
||||
// SpareChange
|
||||
// http://sparechange.io
|
||||
BLOK("sparechange.io") ||
|
||||
BLOKD(".sparechange.io") ||
|
||||
// SwiftMining
|
||||
// https://swiftmining.win/
|
||||
BLOK("swiftmining.win") ||
|
||||
BLOKD(".swiftmining.win") ||
|
||||
// Webmine
|
||||
// https://webmine.cz/
|
||||
BLOK("authedwebmine.cz") ||
|
||||
BLOKD(".authedwebmine.cz") ||
|
||||
BLOK("webmine.cz") ||
|
||||
BLOKD(".webmine.cz") ||
|
||||
// WebminePool
|
||||
// http://webminepool.com
|
||||
BLOK("webminepool.com") ||
|
||||
BLOKD(".webminepool.com") ||
|
||||
// Webmining
|
||||
// https://webmining.co/
|
||||
BLOK("webmining.co") ||
|
||||
BLOKD(".webmining.co") ||
|
||||
// Adbot
|
||||
// https://adbot.tw/
|
||||
BLOK("adbot.tw") ||
|
||||
BLOKD(".adbot.tw") ||
|
||||
// AdCash
|
||||
// https://adcash.com
|
||||
BLOK("ufpcdn.com") ||
|
||||
BLOKD(".ufpcdn.com") ||
|
||||
// AdMaven
|
||||
// https://ad-maven.com/
|
||||
BLOK("ad-maven.com") ||
|
||||
BLOKD(".ad-maven.com") ||
|
||||
BLOK("wrethicap.info") ||
|
||||
BLOKD(".wrethicap.info") ||
|
||||
// Admicro
|
||||
// http://www.admicro.vn/
|
||||
BLOK("admicro.vn") ||
|
||||
BLOKD(".admicro.vn") ||
|
||||
BLOK("vcmedia.vn") ||
|
||||
BLOKD(".vcmedia.vn") ||
|
||||
// Adnium
|
||||
// https://adnium.com
|
||||
BLOK("adnium.com") ||
|
||||
BLOKD(".adnium.com") ||
|
||||
BLOK("montwam.top") ||
|
||||
BLOKD(".montwam.top") ||
|
||||
// AdScore
|
||||
// http://www.adscoremarketing.com/
|
||||
BLOK("adsco.re") ||
|
||||
BLOKD(".adsco.re") ||
|
||||
// AdxSpace
|
||||
// https://adx.space
|
||||
BLOK("00px.net") ||
|
||||
BLOKD(".00px.net") ||
|
||||
// AivaLabs
|
||||
// https://aivalabs.com
|
||||
BLOK("aivalabs.com") ||
|
||||
BLOKD(".aivalabs.com") ||
|
||||
// AuditedMedia
|
||||
// https://auditedmedia.com/
|
||||
BLOK("aamapi.com") ||
|
||||
BLOKD(".aamapi.com") ||
|
||||
BLOK("aamsitecertifier.com") ||
|
||||
BLOKD(".aamsitecertifier.com") ||
|
||||
BLOK("auditedmedia.com") ||
|
||||
BLOKD(".auditedmedia.com") ||
|
||||
// Azet
|
||||
// http://mediaimpact.sk/
|
||||
BLOK("rsz.sk") ||
|
||||
BLOKD(".rsz.sk") ||
|
||||
// BetssonPalantir
|
||||
// https://betssonpalantir.com/
|
||||
BLOK("betssonpalantir.com") ||
|
||||
BLOKD(".betssonpalantir.com") ||
|
||||
// BitMedia
|
||||
// https://bitmedia.io/
|
||||
BLOK("bitmedia.io") ||
|
||||
BLOKD(".bitmedia.io") ||
|
||||
// BlueCava
|
||||
// http://www.bluecava.com/
|
||||
BLOK("bluecava.com") ||
|
||||
BLOKD(".bluecava.com") ||
|
||||
// BoostBox
|
||||
// https://www.boostbox.com.br/
|
||||
BLOK("boostbox.com.br") ||
|
||||
BLOKD(".boostbox.com.br") ||
|
||||
// Bouncex
|
||||
// https://www.bouncex.com/
|
||||
BLOK("bounceexchange.com") ||
|
||||
BLOKD(".bounceexchange.com") ||
|
||||
BLOK("bouncex.com") ||
|
||||
BLOKD(".bouncex.com") ||
|
||||
BLOK("bouncex.net") ||
|
||||
BLOKD(".bouncex.net") ||
|
||||
// Brandcrumb
|
||||
// http://www.brandcrumb.com
|
||||
BLOK("brandcrumb.com") ||
|
||||
BLOKD(".brandcrumb.com") ||
|
||||
// BreakTime
|
||||
// https://www.breaktime.com.tw/
|
||||
BLOK("breaktime.com.tw") ||
|
||||
BLOKD(".breaktime.com.tw") ||
|
||||
// BrightEdge
|
||||
// http://www.brightedge.com/
|
||||
BLOK("b0e8.com") ||
|
||||
BLOKD(".b0e8.com") ||
|
||||
// C3 Metrics
|
||||
// http://c3metrics.com/
|
||||
BLOK("c3metrics.com") ||
|
||||
BLOKD(".c3metrics.com") ||
|
||||
BLOK("c3tag.com") ||
|
||||
BLOKD(".c3tag.com") ||
|
||||
// CallSource
|
||||
// https://www.callsource.com/
|
||||
BLOK("leadtrackingdata.com") ||
|
||||
BLOKD(".leadtrackingdata.com") ||
|
||||
// CartsGuru
|
||||
// https://carts.guru/
|
||||
BLOK("carts.guru") ||
|
||||
BLOKD(".carts.guru") ||
|
||||
// ClearLink
|
||||
// https://www.clearlink.com/
|
||||
BLOK("clearlink.com") ||
|
||||
BLOKD(".clearlink.com") ||
|
||||
// Clickayab
|
||||
// http://www.clickyab.com
|
||||
BLOK("clickyab.com") ||
|
||||
BLOKD(".clickyab.com") ||
|
||||
// ClickFrog
|
||||
// https://clickfrog.ru/
|
||||
BLOK("bashirian.biz") ||
|
||||
BLOKD(".bashirian.biz") ||
|
||||
BLOK("buckridge.link") ||
|
||||
BLOKD(".buckridge.link") ||
|
||||
BLOK("franecki.net") ||
|
||||
BLOKD(".franecki.net") ||
|
||||
BLOK("quitzon.net") ||
|
||||
BLOKD(".quitzon.net") ||
|
||||
BLOK("reichelcormier.bid") ||
|
||||
BLOKD(".reichelcormier.bid") ||
|
||||
BLOK("wisokykulas.bid") ||
|
||||
BLOKD(".wisokykulas.bid") ||
|
||||
// ClickGuard
|
||||
// https://www.clickguard.com/
|
||||
BLOK("clickguard.com") ||
|
||||
BLOKD(".clickguard.com") ||
|
||||
// Clixtell
|
||||
// https://www.clixtell.com/
|
||||
BLOK("clixtell.com") ||
|
||||
BLOKD(".clixtell.com") ||
|
||||
// Cloudflare
|
||||
// https://cloudflare.com
|
||||
BLOK("hcaptcha.com") ||
|
||||
BLOKD(".hcaptcha.com") ||
|
||||
// dmpxs
|
||||
// http://bob.dmpxs.com
|
||||
BLOK("dmpxs.com") ||
|
||||
BLOKD(".dmpxs.com") ||
|
||||
// EroAdvertising
|
||||
// http://www.ero-advertising.com/
|
||||
BLOK("ero-advertising.com") ||
|
||||
BLOKD(".ero-advertising.com") ||
|
||||
// Foresee
|
||||
// https://www.foresee.com
|
||||
BLOK("answerscloud.com") ||
|
||||
BLOKD(".answerscloud.com") ||
|
||||
BLOK("foresee.com") ||
|
||||
BLOKD(".foresee.com") ||
|
||||
// Friends2Follow
|
||||
// https://friends2follow.com/
|
||||
BLOK("antifraudjs.friends2follow.com") ||
|
||||
BLOKD(".antifraudjs.friends2follow.com") ||
|
||||
// Gleam
|
||||
// https://gleam.io/
|
||||
BLOK("fraudjs.io") ||
|
||||
BLOKD(".fraudjs.io") ||
|
||||
// GrapheneMedia
|
||||
// http://graphenemedia.in/
|
||||
BLOK("graphenedigitalanalytics.in") ||
|
||||
BLOKD(".graphenedigitalanalytics.in") ||
|
||||
// HilltopAds
|
||||
// https://hilltopads.com/
|
||||
BLOK("hilltopads.net") ||
|
||||
BLOKD(".hilltopads.net") ||
|
||||
// HotelChamp
|
||||
// https://www.hotelchamp.com
|
||||
BLOK("hotelchamp.com") ||
|
||||
BLOKD(".hotelchamp.com") ||
|
||||
// HumanSecurity
|
||||
// https://www.humansecurity.com/
|
||||
BLOK("perimeterx.net") ||
|
||||
BLOKD(".perimeterx.net") ||
|
||||
// iMedia
|
||||
// http://www.imedia.cz
|
||||
BLOK("imedia.cz") ||
|
||||
BLOKD(".imedia.cz") ||
|
||||
// Impact
|
||||
// https://impact.com/
|
||||
BLOK("fqtag.com") ||
|
||||
BLOKD(".fqtag.com") ||
|
||||
// Integral Ad Science
|
||||
// https://integralads.com/
|
||||
BLOK("adsafeprotected.com") ||
|
||||
BLOKD(".adsafeprotected.com") ||
|
||||
// iShumei
|
||||
// https://www.ishumei.com/
|
||||
BLOK("fengkongcloud.com") ||
|
||||
BLOKD(".fengkongcloud.com") ||
|
||||
// IslayTech
|
||||
// http://islay.tech
|
||||
BLOK("islay.tech") ||
|
||||
BLOKD(".islay.tech") ||
|
||||
// ismatlab.com
|
||||
// http://ismatlab.com
|
||||
BLOK("ismatlab.com") ||
|
||||
BLOKD(".ismatlab.com") ||
|
||||
// Itch
|
||||
// https://itch.io/
|
||||
BLOK("itch.io") ||
|
||||
BLOKD(".itch.io") ||
|
||||
// Kitewheel
|
||||
// https://kitewheel.com/
|
||||
BLOK("kitewheel.com") ||
|
||||
BLOKD(".kitewheel.com") ||
|
||||
// Konduto
|
||||
// http://konduto.com
|
||||
BLOK("k-analytix.com") ||
|
||||
BLOKD(".k-analytix.com") ||
|
||||
BLOK("konduto.com") ||
|
||||
BLOKD(".konduto.com") ||
|
||||
// LeadsHub
|
||||
// https://ztsrv.com/
|
||||
BLOK("ztsrv.com") ||
|
||||
BLOKD(".ztsrv.com") ||
|
||||
// lptracker
|
||||
// https://lptracker.io/
|
||||
BLOK("lptracker.io") ||
|
||||
BLOKD(".lptracker.io") ||
|
||||
// MaxMind
|
||||
// https://www.maxmind.com/en/home
|
||||
BLOK("maxmind.com") ||
|
||||
BLOKD(".maxmind.com") ||
|
||||
BLOK("mmapiws.com") ||
|
||||
BLOKD(".mmapiws.com") ||
|
||||
// Mercadopago
|
||||
// https://www.mercadopago.com/
|
||||
BLOK("mercadopago.com") ||
|
||||
BLOKD(".mercadopago.com") ||
|
||||
// Mobials
|
||||
// http://mobials.com
|
||||
BLOK("mobials.com") ||
|
||||
BLOKD(".mobials.com") ||
|
||||
// Negishim
|
||||
// http://www.negishim.org
|
||||
BLOK("negishim.org") ||
|
||||
BLOKD(".negishim.org") ||
|
||||
// OneAd
|
||||
// https://www.onead.com.tw/
|
||||
BLOK("guoshipartners.com") ||
|
||||
BLOKD(".guoshipartners.com") ||
|
||||
BLOK("onevision.com.tw") ||
|
||||
BLOKD(".onevision.com.tw") ||
|
||||
// OnlineMetrix
|
||||
// http://h.online-metrix.net
|
||||
BLOK("online-metrix.net") ||
|
||||
BLOKD(".online-metrix.net") ||
|
||||
// Outbrain
|
||||
// http://www.outbrain.com/
|
||||
BLOK("ligatus.com") ||
|
||||
BLOKD(".ligatus.com") ||
|
||||
// PartyPoker
|
||||
// https://www.partypoker.com/
|
||||
BLOK("iivt.com") ||
|
||||
BLOKD(".iivt.com") ||
|
||||
// Paypal
|
||||
// https://www.paypal.com
|
||||
BLOK("simility.com") ||
|
||||
BLOKD(".simility.com") ||
|
||||
// PixAnalytics
|
||||
// https://pixanalytics.com/
|
||||
BLOK("pixanalytics.com") ||
|
||||
BLOKD(".pixanalytics.com") ||
|
||||
// Pixlee
|
||||
// https://www.pixlee.com/
|
||||
BLOK("pixlee.com") ||
|
||||
BLOKD(".pixlee.com") ||
|
||||
// PPCProtect
|
||||
// https://ppcprotect.com
|
||||
BLOK("ppcprotect.com") ||
|
||||
BLOKD(".ppcprotect.com") ||
|
||||
// PrometheusIntelligenceTechnology
|
||||
// https://prometheusintelligencetechnology.com/
|
||||
BLOK("prometheusintelligencetechnology.com") ||
|
||||
BLOKD(".prometheusintelligencetechnology.com") ||
|
||||
// Protected Media
|
||||
// http://www.protected.media/
|
||||
BLOK("ad-score.com") ||
|
||||
BLOKD(".ad-score.com") ||
|
||||
// Radware
|
||||
// https://www.radware.com/
|
||||
BLOK("perfdrive.com") ||
|
||||
BLOKD(".perfdrive.com") ||
|
||||
// RazorPay
|
||||
// https://razorpay.com
|
||||
BLOK("thirdwatch.ai") ||
|
||||
BLOKD(".thirdwatch.ai") ||
|
||||
// Rollick
|
||||
// https://gorollick.com
|
||||
BLOK("rollick.io") ||
|
||||
BLOKD(".rollick.io") ||
|
||||
// Selectable Media
|
||||
// http://selectablemedia.com/
|
||||
BLOK("selectablemedia.com") ||
|
||||
BLOKD(".selectablemedia.com") ||
|
||||
// Semantiqo
|
||||
// http://semantiqo.com/
|
||||
BLOK("semantiqo.com") ||
|
||||
BLOKD(".semantiqo.com") ||
|
||||
// SendPulse
|
||||
// https://sendpulse.com/
|
||||
BLOK("sendpulse.com") ||
|
||||
BLOKD(".sendpulse.com") ||
|
||||
// ShaftTraffic
|
||||
// https://shafttraffic.com
|
||||
BLOK("libertystmedia.com") ||
|
||||
BLOKD(".libertystmedia.com") ||
|
||||
// Shixiseng
|
||||
// https://www.shixiseng.com/
|
||||
BLOK("xiaoyuanzhao.com") ||
|
||||
BLOKD(".xiaoyuanzhao.com") ||
|
||||
// Shortest
|
||||
// http://shorte.st/
|
||||
BLOK("shorte.st") ||
|
||||
BLOKD(".shorte.st") ||
|
||||
// SiftScience
|
||||
// https://sift.com/
|
||||
BLOK("siftscience.com") ||
|
||||
BLOKD(".siftscience.com") ||
|
||||
// Signifyd
|
||||
// https://www.signifyd.com/
|
||||
BLOK("signifyd.com") ||
|
||||
BLOKD(".signifyd.com") ||
|
||||
// SmarterClick
|
||||
// https://smarterclick.com/privacy-policy/
|
||||
BLOK("smct.io") ||
|
||||
BLOKD(".smct.io") ||
|
||||
// Smi
|
||||
// http://24smi.net
|
||||
BLOK("24smi.net") ||
|
||||
BLOKD(".24smi.net") ||
|
||||
// Storeland
|
||||
// https://storeland.ru/
|
||||
BLOK("storeland.ru") ||
|
||||
BLOKD(".storeland.ru") ||
|
||||
// Stripchat
|
||||
// https://stripchat.com/
|
||||
BLOK("stripst.com") ||
|
||||
BLOKD(".stripst.com") ||
|
||||
// Stripe
|
||||
// https://stripe.com
|
||||
BLOK("stripe.network") ||
|
||||
BLOKD(".stripe.network") ||
|
||||
// TechSolutions
|
||||
// https://www.techsolutions.com.tw/
|
||||
BLOK("techsolutions.com.tw") ||
|
||||
BLOKD(".techsolutions.com.tw") ||
|
||||
// tongdun.cn
|
||||
// https://www.tongdun.cn/?lan=EN
|
||||
BLOK("fraudmetrix.cn") ||
|
||||
BLOKD(".fraudmetrix.cn") ||
|
||||
BLOK("tongdun.net") ||
|
||||
BLOKD(".tongdun.net") ||
|
||||
// Trendemon
|
||||
// https://trendemon.com/
|
||||
BLOK("trendemon.com") ||
|
||||
BLOKD(".trendemon.com") ||
|
||||
// Upland
|
||||
// https://uplandsoftware.com/
|
||||
BLOK("leadlander.com") ||
|
||||
BLOKD(".leadlander.com") ||
|
||||
BLOK("sf14g.com") ||
|
||||
BLOKD(".sf14g.com") ||
|
||||
// VerticalHealth
|
||||
// https://www.verticalhealth.com/
|
||||
BLOK("verticalhealth.net") ||
|
||||
BLOKD(".verticalhealth.net") ||
|
||||
// Warumbistdusoarm
|
||||
// https://warumbistdusoarm.space
|
||||
BLOK("warumbistdusoarm.space") ||
|
||||
BLOKD(".warumbistdusoarm.space") ||
|
||||
// Webmecanik
|
||||
// https://www.webmecanik.com/
|
||||
BLOK("webmecanik.com") ||
|
||||
BLOKD(".webmecanik.com") ||
|
||||
// WideOrbit
|
||||
// https://www.wideorbit.com/
|
||||
BLOK("dep-x.com") ||
|
||||
BLOKD(".dep-x.com") ||
|
||||
// Yandex
|
||||
// http://www.yandex.com/
|
||||
BLOK("mc.yandex.ru") ||
|
||||
BLOKD(".mc.yandex.ru") ||
|
||||
// ZafulAffiliate
|
||||
// https://affiliate.zaful.com/
|
||||
BLOK("affasi.com") ||
|
||||
BLOKD(".affasi.com") ||
|
||||
BLOK("gw-ec.com") ||
|
||||
BLOKD(".gw-ec.com") ||
|
||||
BLOK("zaful.com") ||
|
||||
BLOKD(".zaful.com") ||
|
||||
// Zip
|
||||
// https://zip.co
|
||||
BLOK("zipmoney.com.au") ||
|
||||
BLOKD(".zipmoney.com.au") ||
|
||||
|
|
|
@ -673,32 +673,52 @@ nsCSPContext::logToConsole(const char16_t* aName,
|
|||
* Strip URI for reporting according to:
|
||||
* http://www.w3.org/TR/CSP/#violation-reports
|
||||
*
|
||||
* @param aSelfURI
|
||||
* The URI of the CSP policy. Used for cross-origin checks.
|
||||
* @param aURI
|
||||
* The uri to be stripped for reporting
|
||||
* @param aProtectedResourcePrincipal
|
||||
* The loadingPrincipal of the protected resource
|
||||
* which is needed to enforce the SOP.
|
||||
* @param aEffectiveDirective
|
||||
* The effective directive that triggered this report
|
||||
* @return ASCII serialization of the uri to be reported.
|
||||
*/
|
||||
void
|
||||
StripURIForReporting(nsIURI* aURI,
|
||||
StripURIForReporting(nsIURI* aSelfURI, nsIURI* aURI,
|
||||
nsIPrincipal* aProtectedResourcePrincipal,
|
||||
const nsAString& aEffectiveDirective,
|
||||
nsACString& outStrippedURI)
|
||||
{
|
||||
// 1) If the origin of uri is a globally unique identifier (for example,
|
||||
// aURI has a scheme of data, blob, or filesystem), then return the
|
||||
// ASCII serialization of uri’s scheme.
|
||||
bool isHttp =
|
||||
(NS_SUCCEEDED(aURI->SchemeIs("http", &isHttp)) && isHttp) ||
|
||||
(NS_SUCCEEDED(aURI->SchemeIs("https", &isHttp)) && isHttp);
|
||||
if (!isHttp) {
|
||||
bool isHttpFtpOrWs =
|
||||
(NS_SUCCEEDED(aURI->SchemeIs("https", &isHttpFtpOrWs)) && isHttpFtpOrWs) ||
|
||||
(NS_SUCCEEDED(aURI->SchemeIs("http", &isHttpFtpOrWs)) && isHttpFtpOrWs) ||
|
||||
(NS_SUCCEEDED(aURI->SchemeIs("wss", &isHttpFtpOrWs)) && isHttpFtpOrWs) ||
|
||||
(NS_SUCCEEDED(aURI->SchemeIs("ws", &isHttpFtpOrWs)) && isHttpFtpOrWs) ||
|
||||
(NS_SUCCEEDED(aURI->SchemeIs("ftp", &isHttpFtpOrWs)) && isHttpFtpOrWs);
|
||||
if (!isHttpFtpOrWs) {
|
||||
// not strictly spec compliant, but what we really care about is
|
||||
// http/https. If it's not http/https, then treat aURI as if
|
||||
// it's a globally unique identifier and just return the scheme.
|
||||
// http/https and also ftp. If it's not http/https or ftp, then treat aURI
|
||||
// as if it's a globally unique identifier and just return the scheme.
|
||||
aURI->GetScheme(outStrippedURI);
|
||||
return;
|
||||
}
|
||||
|
||||
// For cross-origin URIs in frame-src also strip the path.
|
||||
// This prevents detailed tracking of pages loaded into an iframe
|
||||
// by the embedding page using a report-only policy.
|
||||
if (aEffectiveDirective.EqualsLiteral("frame-src") ||
|
||||
aEffectiveDirective.EqualsLiteral("object-src")) {
|
||||
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
|
||||
if (NS_FAILED(ssm->CheckSameOriginURI(aSelfURI, aURI, false))) {
|
||||
aURI->GetPrePath(outStrippedURI);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 2) If the origin of uri is not the same as the origin of the protected
|
||||
// resource, then return the ASCII serialization of uri’s origin.
|
||||
bool sameOrigin =
|
||||
|
@ -765,7 +785,8 @@ nsCSPContext::SendReports(nsISupports* aBlockedContentSource,
|
|||
nsCOMPtr<nsIURI> uri = do_QueryInterface(aBlockedContentSource);
|
||||
// could be a string or URI
|
||||
if (uri) {
|
||||
StripURIForReporting(uri, mLoadingPrincipal, reportBlockedURI);
|
||||
StripURIForReporting(mSelfURI, uri, mLoadingPrincipal, aViolatedDirective,
|
||||
reportBlockedURI);
|
||||
} else {
|
||||
nsCOMPtr<nsISupportsCString> cstr = do_QueryInterface(aBlockedContentSource);
|
||||
if (cstr) {
|
||||
|
@ -782,7 +803,8 @@ nsCSPContext::SendReports(nsISupports* aBlockedContentSource,
|
|||
|
||||
// document-uri
|
||||
nsAutoCString reportDocumentURI;
|
||||
StripURIForReporting(mSelfURI, mLoadingPrincipal, reportDocumentURI);
|
||||
StripURIForReporting(mSelfURI, mSelfURI, mLoadingPrincipal,
|
||||
aViolatedDirective, reportDocumentURI);
|
||||
report.mCsp_report.mDocument_uri = NS_ConvertUTF8toUTF16(reportDocumentURI);
|
||||
|
||||
// original-policy
|
||||
|
|
|
@ -297,6 +297,8 @@ gfxPlatformMac::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags)
|
|||
|
||||
// Start with leftmost, using hostname as a screen (TenFourFox issue 492).
|
||||
|
||||
HTTP_OR_HTTPS_SUBDIR("www.tagesschau.de", "/resources/assets/fonts/TheSansC5s");
|
||||
|
||||
HTTP_OR_HTTPS_SUBDIR("assets.tagesspiegel.de", "/fonts/Abril_Text_");
|
||||
HTTP_OR_HTTPS_SUBDIR("assets.tagesspiegel.de", "/fonts/franklingothic-");
|
||||
|
||||
|
|
|
@ -41,34 +41,10 @@ class ImageURL;
|
|||
class imgCacheEntry
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(imgCacheEntry)
|
||||
|
||||
imgCacheEntry(imgLoader* loader, imgRequest* request,
|
||||
bool aForcePrincipalCheck);
|
||||
~imgCacheEntry();
|
||||
|
||||
nsrefcnt AddRef()
|
||||
{
|
||||
NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt");
|
||||
MOZ_ASSERT(_mOwningThread.GetThread() == PR_GetCurrentThread(),
|
||||
"imgCacheEntry addref isn't thread-safe!");
|
||||
++mRefCnt;
|
||||
NS_LOG_ADDREF(this, mRefCnt, "imgCacheEntry", sizeof(*this));
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
nsrefcnt Release()
|
||||
{
|
||||
NS_PRECONDITION(0 != mRefCnt, "dup release");
|
||||
MOZ_ASSERT(_mOwningThread.GetThread() == PR_GetCurrentThread(),
|
||||
"imgCacheEntry release isn't thread-safe!");
|
||||
--mRefCnt;
|
||||
NS_LOG_RELEASE(this, mRefCnt, "imgCacheEntry");
|
||||
if (mRefCnt == 0) {
|
||||
mRefCnt = 1; /* stabilize */
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
uint32_t GetDataSize() const
|
||||
{
|
||||
|
@ -162,11 +138,9 @@ private: // methods
|
|||
|
||||
// Private, unimplemented copy constructor.
|
||||
imgCacheEntry(const imgCacheEntry&);
|
||||
~imgCacheEntry();
|
||||
|
||||
private: // data
|
||||
nsAutoRefCnt mRefCnt;
|
||||
NS_DECL_OWNINGTHREAD
|
||||
|
||||
imgLoader* mLoader;
|
||||
RefPtr<imgRequest> mRequest;
|
||||
uint32_t mDataSize;
|
||||
|
|
|
@ -305,9 +305,7 @@ metaZones:table(nofallback){
|
|||
EG{"Africa/Cairo"}
|
||||
FI{"Europe/Helsinki"}
|
||||
GR{"Europe/Athens"}
|
||||
JO{"Asia/Amman"}
|
||||
LB{"Asia/Beirut"}
|
||||
SY{"Asia/Damascus"}
|
||||
}
|
||||
Europe_Further_Eastern{
|
||||
001{"Europe/Minsk"}
|
||||
|
@ -1655,6 +1653,33 @@ metaZones:table(nofallback){
|
|||
{
|
||||
"Mexico_Pacific",
|
||||
"1998-04-05 09:00",
|
||||
"2022-10-30 08:00",
|
||||
}
|
||||
{
|
||||
"America_Central",
|
||||
"2022-10-30 08:00",
|
||||
"9999-12-31 23:59",
|
||||
}
|
||||
}
|
||||
"America:Ciudad_Juarez"{
|
||||
{
|
||||
"America_Central",
|
||||
"1970-01-01 00:00",
|
||||
"1998-04-05 09:00",
|
||||
}
|
||||
{
|
||||
"Mexico_Pacific",
|
||||
"1998-04-05 09:00",
|
||||
"2022-10-30 08:00",
|
||||
}
|
||||
{
|
||||
"America_Central",
|
||||
"2022-10-30 08:00",
|
||||
"2022-11-30 06:00",
|
||||
}
|
||||
{
|
||||
"America_Mountain",
|
||||
"2022-11-30 06:00",
|
||||
"9999-12-31 23:59",
|
||||
}
|
||||
}
|
||||
|
@ -2366,6 +2391,11 @@ metaZones:table(nofallback){
|
|||
{
|
||||
"America_Mountain",
|
||||
"1998-04-05 09:00",
|
||||
"2022-10-30 08:00",
|
||||
}
|
||||
{
|
||||
"America_Central",
|
||||
"2022-10-30 08:00",
|
||||
"9999-12-31 23:59",
|
||||
}
|
||||
}
|
||||
|
@ -2375,14 +2405,9 @@ metaZones:table(nofallback){
|
|||
}
|
||||
}
|
||||
"America:Pangnirtung"{
|
||||
{
|
||||
"Atlantic",
|
||||
"1970-01-01 00:00",
|
||||
"1995-04-02 06:00",
|
||||
}
|
||||
{
|
||||
"America_Eastern",
|
||||
"1995-04-02 06:00",
|
||||
"1970-01-01 00:00",
|
||||
"1999-10-31 06:00",
|
||||
}
|
||||
{
|
||||
|
@ -2839,6 +2864,8 @@ metaZones:table(nofallback){
|
|||
"Asia:Amman"{
|
||||
{
|
||||
"Europe_Eastern",
|
||||
"1970-01-01 00:00",
|
||||
"2022-10-27 22:00",
|
||||
}
|
||||
}
|
||||
"Asia:Anadyr"{
|
||||
|
@ -3026,6 +3053,8 @@ metaZones:table(nofallback){
|
|||
"Asia:Damascus"{
|
||||
{
|
||||
"Europe_Eastern",
|
||||
"1970-01-01 00:00",
|
||||
"2022-10-27 21:00",
|
||||
}
|
||||
}
|
||||
"Asia:Dhaka"{
|
||||
|
@ -4133,16 +4162,11 @@ metaZones:table(nofallback){
|
|||
{
|
||||
"Moscow",
|
||||
"1970-01-01 00:00",
|
||||
"1990-06-30 23:00",
|
||||
}
|
||||
{
|
||||
"Europe_Central",
|
||||
"1990-06-30 23:00",
|
||||
"1991-03-31 02:00",
|
||||
"1990-06-30 22:00",
|
||||
}
|
||||
{
|
||||
"Europe_Eastern",
|
||||
"1991-03-31 02:00",
|
||||
"1990-06-30 22:00",
|
||||
"9999-12-31 23:59",
|
||||
}
|
||||
}
|
||||
|
@ -4202,11 +4226,11 @@ metaZones:table(nofallback){
|
|||
{
|
||||
"Moscow",
|
||||
"1970-01-01 00:00",
|
||||
"1991-03-30 23:00",
|
||||
"1990-06-30 22:00",
|
||||
}
|
||||
{
|
||||
"Europe_Eastern",
|
||||
"1991-03-30 23:00",
|
||||
"1990-06-30 22:00",
|
||||
"9999-12-31 23:59",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,13 +5,47 @@ timezoneTypes:table(nofallback){
|
|||
bcpTypeAlias{
|
||||
tz{
|
||||
aqams{"nzakl"}
|
||||
aukns{"auhba"}
|
||||
caffs{"cawnp"}
|
||||
camtr{"cator"}
|
||||
canpg{"cator"}
|
||||
capnt{"caiql"}
|
||||
cathu{"cator"}
|
||||
cayzf{"caedm"}
|
||||
cnckg{"cnsha"}
|
||||
cnhrb{"cnsha"}
|
||||
cnkhg{"cnurc"}
|
||||
gaza{"gazastrp"}
|
||||
mxstis{"mxtij"}
|
||||
uaozh{"uaiev"}
|
||||
uauzh{"uaiev"}
|
||||
umjon{"ushnl"}
|
||||
usnavajo{"usden"}
|
||||
}
|
||||
}
|
||||
ianaMap{
|
||||
timezone{
|
||||
"Africa:Asmera"{"Africa/Asmara"}
|
||||
"America:Buenos_Aires"{"America/Argentina/Buenos_Aires"}
|
||||
"America:Catamarca"{"America/Argentina/Catamarca"}
|
||||
"America:Coral_Harbour"{"America/Atikokan"}
|
||||
"America:Cordoba"{"America/Argentina/Cordoba"}
|
||||
"America:Godthab"{"America/Nuuk"}
|
||||
"America:Indianapolis"{"America/Indiana/Indianapolis"}
|
||||
"America:Jujuy"{"America/Argentina/Jujuy"}
|
||||
"America:Louisville"{"America/Kentucky/Louisville"}
|
||||
"America:Mendoza"{"America/Argentina/Mendoza"}
|
||||
"Asia:Calcutta"{"Asia/Kolkata"}
|
||||
"Asia:Katmandu"{"Asia/Kathmandu"}
|
||||
"Asia:Rangoon"{"Asia/Yangon"}
|
||||
"Asia:Saigon"{"Asia/Ho_Chi_Minh"}
|
||||
"Atlantic:Faeroe"{"Atlantic/Faroe"}
|
||||
"Europe:Kiev"{"Europe/Kyiv"}
|
||||
"Pacific:Enderbury"{"Pacific/Kanton"}
|
||||
"Pacific:Ponape"{"Pacific/Pohnpei"}
|
||||
"Pacific:Truk"{"Pacific/Chuuk"}
|
||||
}
|
||||
}
|
||||
typeAlias{
|
||||
timezone{
|
||||
"Africa:Asmara"{"Africa/Asmera"}
|
||||
|
@ -29,11 +63,18 @@ timezoneTypes:table(nofallback){
|
|||
"America:Indiana:Indianapolis"{"America/Indianapolis"}
|
||||
"America:Kentucky:Louisville"{"America/Louisville"}
|
||||
"America:Knox_IN"{"America/Indiana/Knox"}
|
||||
"America:Montreal"{"America/Toronto"}
|
||||
"America:Nipigon"{"America/Toronto"}
|
||||
"America:Nuuk"{"America/Godthab"}
|
||||
"America:Pangnirtung"{"America/Iqaluit"}
|
||||
"America:Porto_Acre"{"America/Rio_Branco"}
|
||||
"America:Rainy_River"{"America/Winnipeg"}
|
||||
"America:Rosario"{"America/Cordoba"}
|
||||
"America:Santa_Isabel"{"America/Tijuana"}
|
||||
"America:Shiprock"{"America/Denver"}
|
||||
"America:Thunder_Bay"{"America/Toronto"}
|
||||
"America:Virgin"{"America/St_Thomas"}
|
||||
"America:Yellowknife"{"America/Edmonton"}
|
||||
"Antarctica:South_Pole"{"Pacific/Auckland"}
|
||||
"Asia:Ashkhabad"{"Asia/Ashgabat"}
|
||||
"Asia:Chongqing"{"Asia/Shanghai"}
|
||||
|
@ -55,6 +96,7 @@ timezoneTypes:table(nofallback){
|
|||
"Atlantic:Jan_Mayen"{"Arctic/Longyearbyen"}
|
||||
"Australia:ACT"{"Australia/Sydney"}
|
||||
"Australia:Canberra"{"Australia/Sydney"}
|
||||
"Australia:Currie"{"Australia/Hobart"}
|
||||
"Australia:LHI"{"Australia/Lord_Howe"}
|
||||
"Australia:NSW"{"Australia/Sydney"}
|
||||
"Australia:North"{"Australia/Darwin"}
|
||||
|
@ -90,10 +132,13 @@ timezoneTypes:table(nofallback){
|
|||
"Europe:Kyiv"{"Europe/Kiev"}
|
||||
"Europe:Nicosia"{"Asia/Nicosia"}
|
||||
"Europe:Tiraspol"{"Europe/Chisinau"}
|
||||
"Europe:Uzhgorod"{"Europe/Kiev"}
|
||||
"Europe:Zaporozhye"{"Europe/Kiev"}
|
||||
"Mexico:BajaNorte"{"America/Tijuana"}
|
||||
"Mexico:BajaSur"{"America/Mazatlan"}
|
||||
"Mexico:General"{"America/Mexico_City"}
|
||||
"Pacific:Chuuk"{"Pacific/Truk"}
|
||||
"Pacific:Johnston"{"Pacific/Honolulu"}
|
||||
"Pacific:Kanton"{"Pacific/Enderbury"}
|
||||
"Pacific:Pohnpei"{"Pacific/Ponape"}
|
||||
"Pacific:Samoa"{"Pacific/Pago_Pago"}
|
||||
|
@ -236,6 +281,7 @@ timezoneTypes:table(nofallback){
|
|||
"America:Cayman"{"kygec"}
|
||||
"America:Chicago"{"uschi"}
|
||||
"America:Chihuahua"{"mxchi"}
|
||||
"America:Ciudad_Juarez"{"mxcjs"}
|
||||
"America:Coral_Harbour"{"cayzs"}
|
||||
"America:Cordoba"{"arcor"}
|
||||
"America:Costa_Rica"{"crsjo"}
|
||||
|
@ -301,11 +347,9 @@ timezoneTypes:table(nofallback){
|
|||
"America:Moncton"{"camon"}
|
||||
"America:Monterrey"{"mxmty"}
|
||||
"America:Montevideo"{"uymvd"}
|
||||
"America:Montreal"{"camtr"}
|
||||
"America:Montserrat"{"msmni"}
|
||||
"America:Nassau"{"bsnas"}
|
||||
"America:New_York"{"usnyc"}
|
||||
"America:Nipigon"{"canpg"}
|
||||
"America:Nome"{"usome"}
|
||||
"America:Noronha"{"brfen"}
|
||||
"America:North_Dakota:Beulah"{"usxul"}
|
||||
|
@ -313,7 +357,6 @@ timezoneTypes:table(nofallback){
|
|||
"America:North_Dakota:New_Salem"{"usndnsl"}
|
||||
"America:Ojinaga"{"mxoji"}
|
||||
"America:Panama"{"papty"}
|
||||
"America:Pangnirtung"{"capnt"}
|
||||
"America:Paramaribo"{"srpbm"}
|
||||
"America:Phoenix"{"usphx"}
|
||||
"America:Port-au-Prince"{"htpap"}
|
||||
|
@ -321,13 +364,11 @@ timezoneTypes:table(nofallback){
|
|||
"America:Porto_Velho"{"brpvh"}
|
||||
"America:Puerto_Rico"{"prsju"}
|
||||
"America:Punta_Arenas"{"clpuq"}
|
||||
"America:Rainy_River"{"caffs"}
|
||||
"America:Rankin_Inlet"{"cayek"}
|
||||
"America:Recife"{"brrec"}
|
||||
"America:Regina"{"careg"}
|
||||
"America:Resolute"{"careb"}
|
||||
"America:Rio_Branco"{"brrbr"}
|
||||
"America:Santa_Isabel"{"mxstis"}
|
||||
"America:Santarem"{"brstm"}
|
||||
"America:Santiago"{"clscl"}
|
||||
"America:Santo_Domingo"{"dosdq"}
|
||||
|
@ -343,7 +384,6 @@ timezoneTypes:table(nofallback){
|
|||
"America:Swift_Current"{"cayyn"}
|
||||
"America:Tegucigalpa"{"hntgu"}
|
||||
"America:Thule"{"glthu"}
|
||||
"America:Thunder_Bay"{"cathu"}
|
||||
"America:Tijuana"{"mxtij"}
|
||||
"America:Toronto"{"cator"}
|
||||
"America:Tortola"{"vgtov"}
|
||||
|
@ -351,7 +391,6 @@ timezoneTypes:table(nofallback){
|
|||
"America:Whitehorse"{"cayxy"}
|
||||
"America:Winnipeg"{"cawnp"}
|
||||
"America:Yakutat"{"usyak"}
|
||||
"America:Yellowknife"{"cayzf"}
|
||||
"Antarctica:Casey"{"aqcas"}
|
||||
"Antarctica:Davis"{"aqdav"}
|
||||
"Antarctica:DumontDUrville"{"aqddu"}
|
||||
|
@ -460,7 +499,6 @@ timezoneTypes:table(nofallback){
|
|||
"Australia:Adelaide"{"auadl"}
|
||||
"Australia:Brisbane"{"aubne"}
|
||||
"Australia:Broken_Hill"{"aubhq"}
|
||||
"Australia:Currie"{"aukns"}
|
||||
"Australia:Darwin"{"audrw"}
|
||||
"Australia:Eucla"{"aueuc"}
|
||||
"Australia:Hobart"{"auhba"}
|
||||
|
@ -548,7 +586,6 @@ timezoneTypes:table(nofallback){
|
|||
"Europe:Tallinn"{"eetll"}
|
||||
"Europe:Tirane"{"altia"}
|
||||
"Europe:Ulyanovsk"{"ruuly"}
|
||||
"Europe:Uzhgorod"{"uauzh"}
|
||||
"Europe:Vaduz"{"livdz"}
|
||||
"Europe:Vatican"{"vavat"}
|
||||
"Europe:Vienna"{"atvie"}
|
||||
|
@ -556,7 +593,6 @@ timezoneTypes:table(nofallback){
|
|||
"Europe:Volgograd"{"ruvog"}
|
||||
"Europe:Warsaw"{"plwaw"}
|
||||
"Europe:Zagreb"{"hrzag"}
|
||||
"Europe:Zaporozhye"{"uaozh"}
|
||||
"Europe:Zurich"{"chzrh"}
|
||||
"Indian:Antananarivo"{"mgtnr"}
|
||||
"Indian:Chagos"{"iodga"}
|
||||
|
@ -584,7 +620,6 @@ timezoneTypes:table(nofallback){
|
|||
"Pacific:Guadalcanal"{"sbhir"}
|
||||
"Pacific:Guam"{"gugum"}
|
||||
"Pacific:Honolulu"{"ushnl"}
|
||||
"Pacific:Johnston"{"umjon"}
|
||||
"Pacific:Kiritimati"{"kicxi"}
|
||||
"Pacific:Kosrae"{"fmksa"}
|
||||
"Pacific:Kwajalein"{"mhkwa"}
|
||||
|
|
|
@ -168,7 +168,7 @@ windowsZones:table(nofallback){
|
|||
001{"America/Mexico_City"}
|
||||
MX{
|
||||
"America/Mexico_City America/Bahia_Banderas America/Merida America/Mo"
|
||||
"nterrey"
|
||||
"nterrey America/Chihuahua "
|
||||
}
|
||||
}
|
||||
"Central Standard Time"{
|
||||
|
@ -177,7 +177,7 @@ windowsZones:table(nofallback){
|
|||
"America/Winnipeg America/Rainy_River America/Rankin_Inlet America/Re"
|
||||
"solute"
|
||||
}
|
||||
MX{"America/Matamoros"}
|
||||
MX{"America/Matamoros America/Ojinaga"}
|
||||
US{
|
||||
"America/Chicago America/Indiana/Knox America/Indiana/Tell_City Ameri"
|
||||
"ca/Menominee America/North_Dakota/Beulah America/North_Dakota/Center"
|
||||
|
@ -398,8 +398,8 @@ windowsZones:table(nofallback){
|
|||
MA{"Africa/Casablanca"}
|
||||
}
|
||||
"Mountain Standard Time (Mexico)"{
|
||||
001{"America/Chihuahua"}
|
||||
MX{"America/Chihuahua America/Mazatlan"}
|
||||
001{"America/Mazatlan"}
|
||||
MX{"America/Mazatlan"}
|
||||
}
|
||||
"Mountain Standard Time"{
|
||||
001{"America/Denver"}
|
||||
|
@ -407,7 +407,7 @@ windowsZones:table(nofallback){
|
|||
"America/Edmonton America/Cambridge_Bay America/Inuvik America/Yellow"
|
||||
"knife"
|
||||
}
|
||||
MX{"America/Ojinaga"}
|
||||
MX{"America/Ciudad_Juarez"}
|
||||
US{"America/Denver America/Boise"}
|
||||
ZZ{"MST7MDT"}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,13 @@
|
|||
var g = newGlobal({newCompartment: true});
|
||||
|
||||
try {
|
||||
undef()
|
||||
} catch (err) {
|
||||
const handler = { "getPrototypeOf": (x) => () => x };
|
||||
const proxy = new g.Proxy(err, handler);
|
||||
try {
|
||||
proxy.stack
|
||||
/* odds are we weren't exploitable because we don't support pure catch,
|
||||
but now it's not a problem */
|
||||
} catch(e) {}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
function bar(x) {
|
||||
with ({}) {}
|
||||
switch (x) {
|
||||
case 1:
|
||||
foo(2);
|
||||
break;
|
||||
case 2:
|
||||
gczeal(14, 1);
|
||||
break;
|
||||
}
|
||||
return "a sufficiently long string";
|
||||
}
|
||||
|
||||
function foo(x) {
|
||||
for (var s in bar(x)) { gczeal(0); }
|
||||
}
|
||||
|
||||
with ({}) {}
|
||||
for (var i = 0; i < 100; i++) {
|
||||
foo(0);
|
||||
}
|
||||
foo(1);
|
||||
|
|
@ -1370,6 +1370,7 @@ CodeGeneratorShared::callVM(const VMFunction& fun, LInstruction* ins, const Regi
|
|||
// when returning from the call. Failures are handled with exceptions based
|
||||
// on the return value of the C functions. To guard the outcome of the
|
||||
// returned value, use another LIR instruction.
|
||||
ensureOsiSpace();
|
||||
uint32_t callOffset = masm.callJit(wrapper);
|
||||
markSafepointAt(callOffset, ins);
|
||||
|
||||
|
|
|
@ -174,34 +174,31 @@ js::ErrorObject::checkAndUnwrapThis(JSContext* cx, CallArgs& args, const char* f
|
|||
// the slots we need. This allows us to support the poor-man's subclassing
|
||||
// of error: Object.create(Error.prototype).
|
||||
|
||||
RootedObject target(cx, CheckedUnwrap(&thisValue.toObject()));
|
||||
if (!target) {
|
||||
RootedObject obj(cx, &args.thisv().toObject());
|
||||
RootedObject curr(cx, obj);
|
||||
RootedObject target(cx);
|
||||
do {
|
||||
target = CheckedUnwrap(curr);
|
||||
if (!target) {
|
||||
JS_ReportError(cx, "Permission denied to access object");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (target->is<ErrorObject>()) {
|
||||
error.set(&target->as<ErrorObject>());
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedObject proto(cx);
|
||||
while (!target->is<ErrorObject>()) {
|
||||
if (!GetPrototype(cx, target, &proto))
|
||||
return false;
|
||||
if (!GetPrototype(cx, curr, &curr)) {
|
||||
return false;
|
||||
}
|
||||
} while (curr);
|
||||
|
||||
if (!proto) {
|
||||
// We walked the whole prototype chain and did not find an Error
|
||||
// object.
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
|
||||
js_Error_str, fnName, thisValue.toObject().getClass()->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
target = CheckedUnwrap(proto);
|
||||
if (!target) {
|
||||
JS_ReportError(cx, "Permission denied to access object");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
error.set(&target->as<ErrorObject>());
|
||||
return true;
|
||||
// We walked the whole prototype chain and did not find an Error
|
||||
// object.
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
|
||||
JSMSG_INCOMPATIBLE_PROTO, js_Error_str,
|
||||
"(get stack)", obj->getClass()->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
|
|
|
@ -3851,7 +3851,20 @@ END_CASE(JSOP_INITHOMEOBJECT)
|
|||
CASE(JSOP_SUPERBASE)
|
||||
{
|
||||
JSFunction& superEnvFunc = GetSuperEnvFunction(cx, REGS);
|
||||
#if(0)
|
||||
// TenFourFox issue 488. This sometimes happens when we throw, so make
|
||||
// it a warning.
|
||||
MOZ_ASSERT(superEnvFunc.allowSuperProperty());
|
||||
#else
|
||||
if(!superEnvFunc.allowSuperProperty()) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "JSOP_SUPERBASE should only get things that allow SuperProperties\n");
|
||||
#endif
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO,
|
||||
"null", "object");
|
||||
goto error;
|
||||
}
|
||||
#endif
|
||||
MOZ_ASSERT(superEnvFunc.nonLazyScript()->needsHomeObject());
|
||||
const Value& homeObjVal = superEnvFunc.getExtendedSlot(FunctionExtended::METHOD_HOMEOBJECT_SLOT);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -16,3 +16,6 @@ sctp updated to version 8443 from SVN on Sun Mar 31 09:05:07 EDT 2013
|
|||
sctp updated to version 8815 from SVN on Tue Mar 4 08:50:51 EST 2014
|
||||
sctp updated to version 9168 from SVN on Tue Mar 3 12:11:40 EST 2015
|
||||
sctp updated to version 9209 from SVN on Tue Mar 24 18:11:59 EDT 2015
|
||||
sctp updated to version 0e076261b832121cf120ddc04aaff87ac3a34d30 from git on Tue Nov 28 15:20:51 EST 2017
|
||||
sctp updated to version ea345b6d0c8a0f8701cf49445dba5ec8d34e2305 from git on Tue 30 Jun 14:01:18 CEST 2020
|
||||
sctp updated to version 8e12cd9e01fc94d2e84ea1afa351c845966e116e from git on Mon Oct 17 10:23:01 CDT 2022
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,22 +32,20 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 279859 2015-03-10 19:49:25Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_H_
|
||||
#define _NETINET_SCTP_H_
|
||||
|
||||
#if (defined(__APPLE__) || defined(__Userspace_os_Linux) || defined(__Userspace_os_Darwin))
|
||||
#if defined(__APPLE__) || defined(__linux__)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
#if !defined(__Userspace_os_Windows)
|
||||
#if !defined(_WIN32)
|
||||
#define SCTP_PACKED __attribute__((packed))
|
||||
#else
|
||||
#pragma pack (push, 1)
|
||||
|
@ -139,6 +139,7 @@ struct sctp_paramhdr {
|
|||
#define SCTP_NRSACK_SUPPORTED 0x00000030
|
||||
#define SCTP_PKTDROP_SUPPORTED 0x00000031
|
||||
#define SCTP_MAX_CWND 0x00000032
|
||||
#define SCTP_ACCEPT_ZERO_CHECKSUM 0x00000033
|
||||
|
||||
/*
|
||||
* read-only options
|
||||
|
@ -189,7 +190,6 @@ struct sctp_paramhdr {
|
|||
#define SCTP_STREAM_RESET_INCOMING 0x00000001
|
||||
#define SCTP_STREAM_RESET_OUTGOING 0x00000002
|
||||
|
||||
|
||||
/* here on down are more implementation specific */
|
||||
#define SCTP_SET_DEBUG_LEVEL 0x00001005
|
||||
#define SCTP_CLR_STAT_LOG 0x00001007
|
||||
|
@ -202,13 +202,15 @@ struct sctp_paramhdr {
|
|||
#define SCTP_PLUGGABLE_SS 0x00001203
|
||||
#define SCTP_SS_VALUE 0x00001204
|
||||
#define SCTP_CC_OPTION 0x00001205 /* Options for CC modules */
|
||||
/* For I-DATA */
|
||||
#define SCTP_INTERLEAVING_SUPPORTED 0x00001206
|
||||
|
||||
/* read only */
|
||||
#define SCTP_GET_SNDBUF_USE 0x00001101
|
||||
#define SCTP_GET_STAT_LOG 0x00001103
|
||||
#define SCTP_PCB_STATUS 0x00001104
|
||||
#define SCTP_GET_NONCE_VALUES 0x00001105
|
||||
|
||||
|
||||
/* Special hook for dynamically setting primary for all assoc's,
|
||||
* this is a write only option that requires root privilege.
|
||||
*/
|
||||
|
@ -281,11 +283,11 @@ struct sctp_paramhdr {
|
|||
#define SCTP_PEELOFF 0x0000800a
|
||||
/* the real worker for sctp_getaddrlen() */
|
||||
#define SCTP_GET_ADDR_LEN 0x0000800b
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
/* temporary workaround for Apple listen() issue, no args used */
|
||||
#define SCTP_LISTEN_FIX 0x0000800c
|
||||
#endif
|
||||
#if defined(__Windows__)
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
/* workaround for Cygwin on Windows: returns the SOCKET handle */
|
||||
#define SCTP_GET_HANDLE 0x0000800d
|
||||
#endif
|
||||
|
@ -331,7 +333,6 @@ struct sctp_paramhdr {
|
|||
/* First-come, first-serve */
|
||||
#define SCTP_SS_FIRST_COME 0x00000005
|
||||
|
||||
|
||||
/* fragment interleave constants
|
||||
* setting must be one of these or
|
||||
* EINVAL returned.
|
||||
|
@ -402,33 +403,32 @@ struct sctp_error_cause {
|
|||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_invalid_stream {
|
||||
struct sctp_error_cause cause; /* code=SCTP_ERROR_INVALID_STREAM */
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_INVALID_STREAM */
|
||||
uint16_t stream_id; /* stream id of the DATA in error */
|
||||
uint16_t reserved;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_missing_param {
|
||||
struct sctp_error_cause cause; /* code=SCTP_ERROR_MISSING_PARAM */
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_MISSING_PARAM */
|
||||
uint32_t num_missing_params; /* number of missing parameters */
|
||||
/* uint16_t param_type's follow */
|
||||
uint16_t type[];
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_stale_cookie {
|
||||
struct sctp_error_cause cause; /* code=SCTP_ERROR_STALE_COOKIE */
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_STALE_COOKIE */
|
||||
uint32_t stale_time; /* time in usec of staleness */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_out_of_resource {
|
||||
struct sctp_error_cause cause; /* code=SCTP_ERROR_OUT_OF_RESOURCES */
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_OUT_OF_RESOURCES */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_unresolv_addr {
|
||||
struct sctp_error_cause cause; /* code=SCTP_ERROR_UNRESOLVABLE_ADDR */
|
||||
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_UNRESOLVABLE_ADDR */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_unrecognized_chunk {
|
||||
struct sctp_error_cause cause; /* code=SCTP_ERROR_UNRECOG_CHUNK */
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_UNRECOG_CHUNK */
|
||||
struct sctp_chunkhdr ch;/* header from chunk in error */
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
@ -437,6 +437,11 @@ struct sctp_error_no_user_data {
|
|||
uint32_t tsn; /* TSN of the empty data chunk */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_auth_invalid_hmac {
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_UNSUPPORTED_HMACID */
|
||||
uint16_t hmac_id;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* Main SCTP chunk types we place these here so natd and f/w's in user land
|
||||
* can find them.
|
||||
|
@ -462,6 +467,7 @@ struct sctp_error_no_user_data {
|
|||
/* EY nr_sack chunk id*/
|
||||
#define SCTP_NR_SELECTIVE_ACK 0x10
|
||||
/************0x40 series ***********/
|
||||
#define SCTP_IDATA 0x40
|
||||
/************0x80 series ***********/
|
||||
/* RFC5061 */
|
||||
#define SCTP_ASCONF_ACK 0x80
|
||||
|
@ -477,7 +483,7 @@ struct sctp_error_no_user_data {
|
|||
#define SCTP_FORWARD_CUM_TSN 0xc0
|
||||
/* RFC5061 */
|
||||
#define SCTP_ASCONF 0xc1
|
||||
|
||||
#define SCTP_IFORWARD_CUM_TSN 0xc2
|
||||
|
||||
/* ABORT and SHUTDOWN COMPLETE FLAG */
|
||||
#define SCTP_HAD_NO_TCB 0x01
|
||||
|
@ -520,6 +526,7 @@ struct sctp_error_no_user_data {
|
|||
#define SCTP_PCB_FLAGS_BOUNDALL 0x00000004
|
||||
#define SCTP_PCB_FLAGS_ACCEPTING 0x00000008
|
||||
#define SCTP_PCB_FLAGS_UNBOUND 0x00000010
|
||||
#define SCTP_PCB_FLAGS_SND_ITERATOR_UP 0x00000020
|
||||
#define SCTP_PCB_FLAGS_CLOSE_IP 0x00040000
|
||||
#define SCTP_PCB_FLAGS_WAS_CONNECTED 0x00080000
|
||||
#define SCTP_PCB_FLAGS_WAS_ABORTED 0x00100000
|
||||
|
@ -561,7 +568,6 @@ struct sctp_error_no_user_data {
|
|||
#define SCTP_PCB_FLAGS_INTERLEAVE_STRMS 0x0000000000000010
|
||||
#define SCTP_PCB_FLAGS_DO_ASCONF 0x0000000000000020
|
||||
#define SCTP_PCB_FLAGS_AUTO_ASCONF 0x0000000000000040
|
||||
#define SCTP_PCB_FLAGS_ZERO_COPY_ACTIVE 0x0000000000000080
|
||||
/* socket options */
|
||||
#define SCTP_PCB_FLAGS_NODELAY 0x0000000000000100
|
||||
#define SCTP_PCB_FLAGS_AUTOCLOSE 0x0000000000000200
|
||||
|
@ -602,8 +608,8 @@ struct sctp_error_no_user_data {
|
|||
/* Largest PMTU allowed when disabling PMTU discovery */
|
||||
#define SCTP_LARGEST_PMTU 65536
|
||||
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#pragma pack()
|
||||
#if defined(_WIN32)
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
#undef SCTP_PACKED
|
||||
|
||||
|
@ -621,9 +627,9 @@ struct sctp_error_no_user_data {
|
|||
*/
|
||||
#define SCTP_MAX_SACK_DELAY 500 /* per RFC4960 */
|
||||
#define SCTP_MAX_HB_INTERVAL 14400000 /* 4 hours in ms */
|
||||
#define SCTP_MIN_COOKIE_LIFE 1000 /* 1 second in ms */
|
||||
#define SCTP_MAX_COOKIE_LIFE 3600000 /* 1 hour in ms */
|
||||
|
||||
|
||||
/* Types of logging/KTR tracing that can be enabled via the
|
||||
* sysctl net.inet.sctp.sctp_logging. You must also enable
|
||||
* SUBSYS tracing.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 237715 2012-06-28 16:01:08Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_ASCONF_H_
|
||||
|
@ -43,7 +45,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 237715 2012-06-28 16:01:08Z t
|
|||
/*
|
||||
* function prototypes
|
||||
*/
|
||||
extern void sctp_asconf_cleanup(struct sctp_tcb *, struct sctp_nets *);
|
||||
extern void sctp_asconf_cleanup(struct sctp_tcb *);
|
||||
|
||||
extern struct mbuf *sctp_compose_asconf(struct sctp_tcb *, int *, int);
|
||||
|
||||
|
@ -56,9 +58,8 @@ sctp_handle_asconf_ack(struct mbuf *, int, struct sctp_asconf_ack_chunk *,
|
|||
struct sctp_tcb *, struct sctp_nets *, int *);
|
||||
|
||||
extern uint32_t
|
||||
sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *,
|
||||
uint32_t, uint32_t, struct sctp_ifa *);
|
||||
|
||||
sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *, uint32_t,
|
||||
uint32_t);
|
||||
|
||||
extern int sctp_asconf_iterator_ep(struct sctp_inpcb *inp, void *ptr,
|
||||
uint32_t val);
|
||||
|
@ -67,14 +68,10 @@ extern void sctp_asconf_iterator_stcb(struct sctp_inpcb *inp,
|
|||
void *ptr, uint32_t type);
|
||||
extern void sctp_asconf_iterator_end(void *ptr, uint32_t val);
|
||||
|
||||
|
||||
extern int32_t
|
||||
sctp_set_primary_ip_address_sa(struct sctp_tcb *,
|
||||
struct sockaddr *);
|
||||
|
||||
extern void
|
||||
sctp_set_primary_ip_address(struct sctp_ifa *ifa);
|
||||
|
||||
extern void
|
||||
sctp_check_address_list(struct sctp_tcb *, struct mbuf *, int, int,
|
||||
struct sockaddr *, uint16_t, uint16_t, uint16_t, uint16_t);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 271673 2014-09-16 14:20:33Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#include <netinet/sctp_os.h>
|
||||
|
@ -51,11 +53,10 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 271673 2014-09-16 14:20:33Z tue
|
|||
#define SCTP_AUTH_DEBUG2 (SCTP_BASE_SYSCTL(sctp_debug_on) & SCTP_DEBUG_AUTH2)
|
||||
#endif /* SCTP_DEBUG */
|
||||
|
||||
|
||||
void
|
||||
sctp_clear_chunklist(sctp_auth_chklist_t *chklist)
|
||||
{
|
||||
bzero(chklist, sizeof(*chklist));
|
||||
memset(chklist, 0, sizeof(*chklist));
|
||||
/* chklist->num_chunks = 0; */
|
||||
}
|
||||
|
||||
|
@ -94,12 +95,11 @@ sctp_copy_chunklist(sctp_auth_chklist_t *list)
|
|||
if (new_list == NULL)
|
||||
return (NULL);
|
||||
/* copy it */
|
||||
bcopy(list, new_list, sizeof(*new_list));
|
||||
memcpy(new_list, list, sizeof(*new_list));
|
||||
|
||||
return (new_list);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* add a chunk to the required chunks list
|
||||
*/
|
||||
|
@ -239,7 +239,6 @@ sctp_unpack_auth_chunks(const uint8_t *ptr, uint8_t num_chunks,
|
|||
return (size);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* allocate structure space for a key of length keylen
|
||||
*/
|
||||
|
@ -340,7 +339,7 @@ sctp_set_key(uint8_t *key, uint32_t keylen)
|
|||
/* out of memory */
|
||||
return (NULL);
|
||||
}
|
||||
bcopy(key, new_key->key, keylen);
|
||||
memcpy(new_key->key, key, keylen);
|
||||
return (new_key);
|
||||
}
|
||||
|
||||
|
@ -429,34 +428,33 @@ sctp_compute_hashkey(sctp_key_t *key1, sctp_key_t *key2, sctp_key_t *shared)
|
|||
if (sctp_compare_key(key1, key2) <= 0) {
|
||||
/* key is shared + key1 + key2 */
|
||||
if (sctp_get_keylen(shared)) {
|
||||
bcopy(shared->key, key_ptr, shared->keylen);
|
||||
memcpy(key_ptr, shared->key, shared->keylen);
|
||||
key_ptr += shared->keylen;
|
||||
}
|
||||
if (sctp_get_keylen(key1)) {
|
||||
bcopy(key1->key, key_ptr, key1->keylen);
|
||||
memcpy(key_ptr, key1->key, key1->keylen);
|
||||
key_ptr += key1->keylen;
|
||||
}
|
||||
if (sctp_get_keylen(key2)) {
|
||||
bcopy(key2->key, key_ptr, key2->keylen);
|
||||
memcpy(key_ptr, key2->key, key2->keylen);
|
||||
}
|
||||
} else {
|
||||
/* key is shared + key2 + key1 */
|
||||
if (sctp_get_keylen(shared)) {
|
||||
bcopy(shared->key, key_ptr, shared->keylen);
|
||||
memcpy(key_ptr, shared->key, shared->keylen);
|
||||
key_ptr += shared->keylen;
|
||||
}
|
||||
if (sctp_get_keylen(key2)) {
|
||||
bcopy(key2->key, key_ptr, key2->keylen);
|
||||
memcpy(key_ptr, key2->key, key2->keylen);
|
||||
key_ptr += key2->keylen;
|
||||
}
|
||||
if (sctp_get_keylen(key1)) {
|
||||
bcopy(key1->key, key_ptr, key1->keylen);
|
||||
memcpy(key_ptr, key1->key, key1->keylen);
|
||||
}
|
||||
}
|
||||
return (new_key);
|
||||
}
|
||||
|
||||
|
||||
sctp_sharedkey_t *
|
||||
sctp_alloc_sharedkey(void)
|
||||
{
|
||||
|
@ -523,7 +521,7 @@ sctp_insert_sharedkey(struct sctp_keyhead *shared_keys,
|
|||
} else if (new_skey->keyid == skey->keyid) {
|
||||
/* replace the existing key */
|
||||
/* verify this key *can* be replaced */
|
||||
if ((skey->deactivated) && (skey->refcount > 1)) {
|
||||
if ((skey->deactivated) || (skey->refcount > 1)) {
|
||||
SCTPDBG(SCTP_DEBUG_AUTH1,
|
||||
"can't replace shared key id %u\n",
|
||||
new_skey->keyid);
|
||||
|
@ -544,7 +542,7 @@ sctp_insert_sharedkey(struct sctp_keyhead *shared_keys,
|
|||
}
|
||||
}
|
||||
/* shouldn't reach here */
|
||||
return (0);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -560,16 +558,12 @@ sctp_auth_key_acquire(struct sctp_tcb *stcb, uint16_t key_id)
|
|||
atomic_add_int(&skey->refcount, 1);
|
||||
SCTPDBG(SCTP_DEBUG_AUTH2,
|
||||
"%s: stcb %p key %u refcount acquire to %d\n",
|
||||
__FUNCTION__, (void *)stcb, key_id, skey->refcount);
|
||||
__func__, (void *)stcb, key_id, skey->refcount);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked
|
||||
#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
)
|
||||
sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked)
|
||||
{
|
||||
sctp_sharedkey_t *skey;
|
||||
|
||||
|
@ -578,20 +572,20 @@ sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked
|
|||
|
||||
/* decrement the ref count */
|
||||
if (skey) {
|
||||
sctp_free_sharedkey(skey);
|
||||
SCTPDBG(SCTP_DEBUG_AUTH2,
|
||||
"%s: stcb %p key %u refcount release to %d\n",
|
||||
__FUNCTION__, (void *)stcb, key_id, skey->refcount);
|
||||
__func__, (void *)stcb, key_id, skey->refcount);
|
||||
|
||||
/* see if a notification should be generated */
|
||||
if ((skey->refcount <= 1) && (skey->deactivated)) {
|
||||
if ((skey->refcount <= 2) && (skey->deactivated)) {
|
||||
/* notify ULP that key is no longer used */
|
||||
sctp_ulp_notify(SCTP_NOTIFY_AUTH_FREE_KEY, stcb,
|
||||
key_id, 0, so_locked);
|
||||
SCTPDBG(SCTP_DEBUG_AUTH2,
|
||||
"%s: stcb %p key %u no longer used, %d\n",
|
||||
__FUNCTION__, (void *)stcb, key_id, skey->refcount);
|
||||
__func__, (void *)stcb, key_id, skey->refcount);
|
||||
}
|
||||
sctp_free_sharedkey(skey);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -624,14 +618,16 @@ sctp_copy_skeylist(const struct sctp_keyhead *src, struct sctp_keyhead *dest)
|
|||
LIST_FOREACH(skey, src, next) {
|
||||
new_skey = sctp_copy_sharedkey(skey);
|
||||
if (new_skey != NULL) {
|
||||
(void)sctp_insert_sharedkey(dest, new_skey);
|
||||
count++;
|
||||
if (sctp_insert_sharedkey(dest, new_skey)) {
|
||||
sctp_free_sharedkey(new_skey);
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (count);
|
||||
}
|
||||
|
||||
|
||||
sctp_hmaclist_t *
|
||||
sctp_alloc_hmaclist(uint16_t num_hmacs)
|
||||
{
|
||||
|
@ -655,7 +651,6 @@ sctp_free_hmaclist(sctp_hmaclist_t *list)
|
|||
{
|
||||
if (list != NULL) {
|
||||
SCTP_FREE(list,SCTP_M_AUTH_HL);
|
||||
list = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -772,7 +767,7 @@ sctp_serialize_hmaclist(sctp_hmaclist_t *list, uint8_t *ptr)
|
|||
|
||||
for (i = 0; i < list->num_algo; i++) {
|
||||
hmac_id = htons(list->hmac[i]);
|
||||
bcopy(&hmac_id, ptr, sizeof(hmac_id));
|
||||
memcpy(ptr, &hmac_id, sizeof(hmac_id));
|
||||
ptr += sizeof(hmac_id);
|
||||
}
|
||||
return (list->num_algo * sizeof(hmac_id));
|
||||
|
@ -803,7 +798,7 @@ sctp_alloc_authinfo(void)
|
|||
/* out of memory */
|
||||
return (NULL);
|
||||
}
|
||||
bzero(new_authinfo, sizeof(*new_authinfo));
|
||||
memset(new_authinfo, 0, sizeof(*new_authinfo));
|
||||
return (new_authinfo);
|
||||
}
|
||||
|
||||
|
@ -826,7 +821,6 @@ sctp_free_authinfo(sctp_authinfo_t *authinfo)
|
|||
/* SCTP_FREE(authinfo, SCTP_M_AUTH_??); */
|
||||
}
|
||||
|
||||
|
||||
uint32_t
|
||||
sctp_get_auth_chunk_len(uint16_t hmac_algo)
|
||||
{
|
||||
|
@ -974,10 +968,10 @@ sctp_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
|
|||
key = temp;
|
||||
}
|
||||
/* initialize the inner/outer pads with the key and "append" zeroes */
|
||||
bzero(ipad, blocklen);
|
||||
bzero(opad, blocklen);
|
||||
bcopy(key, ipad, keylen);
|
||||
bcopy(key, opad, keylen);
|
||||
memset(ipad, 0, blocklen);
|
||||
memset(opad, 0, blocklen);
|
||||
memcpy(ipad, key, keylen);
|
||||
memcpy(opad, key, keylen);
|
||||
|
||||
/* XOR the key with ipad and opad values */
|
||||
for (i = 0; i < blocklen; i++) {
|
||||
|
@ -1034,10 +1028,10 @@ sctp_hmac_m(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
|
|||
key = temp;
|
||||
}
|
||||
/* initialize the inner/outer pads with the key and "append" zeroes */
|
||||
bzero(ipad, blocklen);
|
||||
bzero(opad, blocklen);
|
||||
bcopy(key, ipad, keylen);
|
||||
bcopy(key, opad, keylen);
|
||||
memset(ipad, 0, blocklen);
|
||||
memset(opad, 0, blocklen);
|
||||
memcpy(ipad, key, keylen);
|
||||
memcpy(opad, key, keylen);
|
||||
|
||||
/* XOR the key with ipad and opad values */
|
||||
for (i = 0; i < blocklen; i++) {
|
||||
|
@ -1079,40 +1073,6 @@ sctp_hmac_m(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
|
|||
return (digestlen);
|
||||
}
|
||||
|
||||
/*-
|
||||
* verify the HMAC digest using the desired hash key, text, and HMAC
|
||||
* algorithm.
|
||||
* Returns -1 on error, 0 on success.
|
||||
*/
|
||||
int
|
||||
sctp_verify_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
|
||||
uint8_t *text, uint32_t textlen,
|
||||
uint8_t *digest, uint32_t digestlen)
|
||||
{
|
||||
uint32_t len;
|
||||
uint8_t temp[SCTP_AUTH_DIGEST_LEN_MAX];
|
||||
|
||||
/* sanity check the material and length */
|
||||
if ((key == NULL) || (keylen == 0) ||
|
||||
(text == NULL) || (textlen == 0) || (digest == NULL)) {
|
||||
/* can't do HMAC with empty key or text or digest */
|
||||
return (-1);
|
||||
}
|
||||
len = sctp_get_hmac_digest_len(hmac_algo);
|
||||
if ((len == 0) || (digestlen != len))
|
||||
return (-1);
|
||||
|
||||
/* compute the expected hash */
|
||||
if (sctp_hmac(hmac_algo, key, keylen, text, textlen, temp) != len)
|
||||
return (-1);
|
||||
|
||||
if (memcmp(digest, temp, digestlen) != 0)
|
||||
return (-1);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* computes the requested HMAC using a key struct (which may be modified if
|
||||
* the keylen exceeds the HMAC block len).
|
||||
|
@ -1145,7 +1105,7 @@ sctp_compute_hmac(uint16_t hmac_algo, sctp_key_t *key, uint8_t *text,
|
|||
sctp_hmac_final(hmac_algo, &ctx, temp);
|
||||
/* save the hashed key as the new key */
|
||||
key->keylen = digestlen;
|
||||
bcopy(temp, key->key, key->keylen);
|
||||
memcpy(key->key, temp, key->keylen);
|
||||
}
|
||||
return (sctp_hmac(hmac_algo, key->key, key->keylen, text, textlen,
|
||||
digest));
|
||||
|
@ -1179,7 +1139,7 @@ sctp_compute_hmac_m(uint16_t hmac_algo, sctp_key_t *key, struct mbuf *m,
|
|||
sctp_hmac_final(hmac_algo, &ctx, temp);
|
||||
/* save the hashed key as the new key */
|
||||
key->keylen = digestlen;
|
||||
bcopy(temp, key->key, key->keylen);
|
||||
memcpy(key->key, temp, key->keylen);
|
||||
}
|
||||
return (sctp_hmac_m(hmac_algo, key->key, key->keylen, m, m_offset, digest, 0));
|
||||
}
|
||||
|
@ -1200,7 +1160,6 @@ sctp_auth_is_supported_hmac(sctp_hmaclist_t *list, uint16_t id)
|
|||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
* clear any cached key(s) if they match the given key id on an association.
|
||||
* the cached key(s) will be recomputed and re-cached at next use.
|
||||
|
@ -1458,7 +1417,7 @@ sctp_auth_get_cookie_params(struct sctp_tcb *stcb, struct mbuf *m,
|
|||
if (plen > sizeof(random_store))
|
||||
break;
|
||||
phdr = sctp_get_next_param(m, offset,
|
||||
(struct sctp_paramhdr *)random_store, min(plen, sizeof(random_store)));
|
||||
(struct sctp_paramhdr *)random_store, plen);
|
||||
if (phdr == NULL)
|
||||
return;
|
||||
/* save the random and length for the key */
|
||||
|
@ -1471,7 +1430,7 @@ sctp_auth_get_cookie_params(struct sctp_tcb *stcb, struct mbuf *m,
|
|||
if (plen > sizeof(hmacs_store))
|
||||
break;
|
||||
phdr = sctp_get_next_param(m, offset,
|
||||
(struct sctp_paramhdr *)hmacs_store, min(plen,sizeof(hmacs_store)));
|
||||
(struct sctp_paramhdr *)hmacs_store, plen);
|
||||
if (phdr == NULL)
|
||||
return;
|
||||
/* save the hmacs list and num for the key */
|
||||
|
@ -1493,7 +1452,7 @@ sctp_auth_get_cookie_params(struct sctp_tcb *stcb, struct mbuf *m,
|
|||
if (plen > sizeof(chunks_store))
|
||||
break;
|
||||
phdr = sctp_get_next_param(m, offset,
|
||||
(struct sctp_paramhdr *)chunks_store, min(plen,sizeof(chunks_store)));
|
||||
(struct sctp_paramhdr *)chunks_store, plen);
|
||||
if (phdr == NULL)
|
||||
return;
|
||||
chunks = (struct sctp_auth_chunk_list *)phdr;
|
||||
|
@ -1522,24 +1481,24 @@ sctp_auth_get_cookie_params(struct sctp_tcb *stcb, struct mbuf *m,
|
|||
}
|
||||
new_key = sctp_alloc_key(keylen);
|
||||
if (new_key != NULL) {
|
||||
/* copy in the RANDOM */
|
||||
if (p_random != NULL) {
|
||||
keylen = sizeof(*p_random) + random_len;
|
||||
bcopy(p_random, new_key->key, keylen);
|
||||
} else {
|
||||
keylen = 0;
|
||||
}
|
||||
/* append in the AUTH chunks */
|
||||
if (chunks != NULL) {
|
||||
bcopy(chunks, new_key->key + keylen,
|
||||
sizeof(*chunks) + num_chunks);
|
||||
keylen += sizeof(*chunks) + num_chunks;
|
||||
}
|
||||
/* append in the HMACs */
|
||||
if (hmacs != NULL) {
|
||||
bcopy(hmacs, new_key->key + keylen,
|
||||
sizeof(*hmacs) + hmacs_len);
|
||||
}
|
||||
/* copy in the RANDOM */
|
||||
if (p_random != NULL) {
|
||||
keylen = sizeof(*p_random) + random_len;
|
||||
memcpy(new_key->key, p_random, keylen);
|
||||
} else {
|
||||
keylen = 0;
|
||||
}
|
||||
/* append in the AUTH chunks */
|
||||
if (chunks != NULL) {
|
||||
memcpy(new_key->key + keylen, chunks,
|
||||
sizeof(*chunks) + num_chunks);
|
||||
keylen += sizeof(*chunks) + num_chunks;
|
||||
}
|
||||
/* append in the HMACs */
|
||||
if (hmacs != NULL) {
|
||||
memcpy(new_key->key + keylen, hmacs,
|
||||
sizeof(*hmacs) + hmacs_len);
|
||||
}
|
||||
}
|
||||
if (stcb->asoc.authinfo.random != NULL)
|
||||
sctp_free_key(stcb->asoc.authinfo.random);
|
||||
|
@ -1576,7 +1535,7 @@ sctp_fill_hmac_digest_m(struct mbuf *m, uint32_t auth_offset,
|
|||
|
||||
/* zero the digest + chunk padding */
|
||||
digestlen = sctp_get_hmac_digest_len(stcb->asoc.peer_hmac_id);
|
||||
bzero(auth->hmac, SCTP_SIZE32(digestlen));
|
||||
memset(auth->hmac, 0, SCTP_SIZE32(digestlen));
|
||||
|
||||
/* is the desired key cached? */
|
||||
if ((keyid != stcb->asoc.authinfo.assoc_keyid) ||
|
||||
|
@ -1613,9 +1572,8 @@ sctp_fill_hmac_digest_m(struct mbuf *m, uint32_t auth_offset,
|
|||
m, auth_offset, auth->hmac);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
sctp_bzero_m(struct mbuf *m, uint32_t m_offset, uint32_t size)
|
||||
sctp_zero_m(struct mbuf *m, uint32_t m_offset, uint32_t size)
|
||||
{
|
||||
struct mbuf *m_tmp;
|
||||
uint8_t *data;
|
||||
|
@ -1633,11 +1591,11 @@ sctp_bzero_m(struct mbuf *m, uint32_t m_offset, uint32_t size)
|
|||
/* now use the rest of the mbuf chain */
|
||||
while ((m_tmp != NULL) && (size > 0)) {
|
||||
data = mtod(m_tmp, uint8_t *) + m_offset;
|
||||
if (size > (uint32_t) SCTP_BUF_LEN(m_tmp)) {
|
||||
bzero(data, SCTP_BUF_LEN(m_tmp));
|
||||
size -= SCTP_BUF_LEN(m_tmp);
|
||||
if (size > (uint32_t)(SCTP_BUF_LEN(m_tmp) - m_offset)) {
|
||||
memset(data, 0, SCTP_BUF_LEN(m_tmp) - m_offset);
|
||||
size -= SCTP_BUF_LEN(m_tmp) - m_offset;
|
||||
} else {
|
||||
bzero(data, size);
|
||||
memset(data, 0, size);
|
||||
size = 0;
|
||||
}
|
||||
/* clear the offset since it's only for the first mbuf */
|
||||
|
@ -1679,10 +1637,13 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
|
|||
"SCTP AUTH Chunk: shared key %u, HMAC id %u\n",
|
||||
shared_key_id, hmac_id);
|
||||
|
||||
#if defined(__Userspace__) && defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
|
||||
return (0);
|
||||
#endif
|
||||
/* is the indicated HMAC supported? */
|
||||
if (!sctp_auth_is_supported_hmac(stcb->asoc.local_hmacs, hmac_id)) {
|
||||
struct mbuf *m_err;
|
||||
struct sctp_auth_invalid_hmac *err;
|
||||
struct mbuf *op_err;
|
||||
struct sctp_error_auth_invalid_hmac *cause;
|
||||
|
||||
SCTP_STAT_INCR(sctps_recvivalhmacid);
|
||||
SCTPDBG(SCTP_DEBUG_AUTH1,
|
||||
|
@ -1692,20 +1653,19 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
|
|||
* report this in an Error Chunk: Unsupported HMAC
|
||||
* Identifier
|
||||
*/
|
||||
m_err = sctp_get_mbuf_for_msg(sizeof(*err), 0, M_NOWAIT,
|
||||
1, MT_HEADER);
|
||||
if (m_err != NULL) {
|
||||
op_err = sctp_get_mbuf_for_msg(sizeof(struct sctp_error_auth_invalid_hmac),
|
||||
0, M_NOWAIT, 1, MT_HEADER);
|
||||
if (op_err != NULL) {
|
||||
/* pre-reserve some space */
|
||||
SCTP_BUF_RESV_UF(m_err, sizeof(struct sctp_chunkhdr));
|
||||
SCTP_BUF_RESV_UF(op_err, sizeof(struct sctp_chunkhdr));
|
||||
/* fill in the error */
|
||||
err = mtod(m_err, struct sctp_auth_invalid_hmac *);
|
||||
bzero(err, sizeof(*err));
|
||||
err->ph.param_type = htons(SCTP_CAUSE_UNSUPPORTED_HMACID);
|
||||
err->ph.param_length = htons(sizeof(*err));
|
||||
err->hmac_id = ntohs(hmac_id);
|
||||
SCTP_BUF_LEN(m_err) = sizeof(*err);
|
||||
cause = mtod(op_err, struct sctp_error_auth_invalid_hmac *);
|
||||
cause->cause.code = htons(SCTP_CAUSE_UNSUPPORTED_HMACID);
|
||||
cause->cause.length = htons(sizeof(struct sctp_error_auth_invalid_hmac));
|
||||
cause->hmac_id = ntohs(hmac_id);
|
||||
SCTP_BUF_LEN(op_err) = sizeof(struct sctp_error_auth_invalid_hmac);
|
||||
/* queue it */
|
||||
sctp_queue_op_err(stcb, m_err);
|
||||
sctp_queue_op_err(stcb, op_err);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
@ -1755,13 +1715,13 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
|
|||
return (-1);
|
||||
}
|
||||
/* save a copy of the digest, zero the pseudo header, and validate */
|
||||
bcopy(auth->hmac, digest, digestlen);
|
||||
sctp_bzero_m(m, offset + sizeof(*auth), SCTP_SIZE32(digestlen));
|
||||
memcpy(digest, auth->hmac, digestlen);
|
||||
sctp_zero_m(m, offset + sizeof(*auth), SCTP_SIZE32(digestlen));
|
||||
(void)sctp_compute_hmac_m(hmac_id, stcb->asoc.authinfo.recv_key,
|
||||
m, offset, computed_digest);
|
||||
|
||||
/* compare the computed digest with the one in the AUTH chunk */
|
||||
if (memcmp(digest, computed_digest, digestlen) != 0) {
|
||||
if (timingsafe_bcmp(digest, computed_digest, digestlen) != 0) {
|
||||
SCTP_STAT_INCR(sctps_recvauthfailed);
|
||||
SCTPDBG(SCTP_DEBUG_AUTH1,
|
||||
"SCTP Auth: HMAC digest check failed\n");
|
||||
|
@ -1775,11 +1735,7 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
|
|||
*/
|
||||
void
|
||||
sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication,
|
||||
uint16_t keyid, uint16_t alt_keyid, int so_locked
|
||||
#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
)
|
||||
uint16_t keyid, uint16_t alt_keyid, int so_locked)
|
||||
{
|
||||
struct mbuf *m_notify;
|
||||
struct sctp_authkey_event *auth;
|
||||
|
@ -1826,15 +1782,14 @@ sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication,
|
|||
sctp_m_freem(m_notify);
|
||||
return;
|
||||
}
|
||||
control->spec_flags = M_NOTIFICATION;
|
||||
control->length = SCTP_BUF_LEN(m_notify);
|
||||
control->spec_flags = M_NOTIFICATION;
|
||||
/* not that we need this */
|
||||
control->tail_mbuf = m_notify;
|
||||
sctp_add_to_readq(stcb->sctp_ep, stcb, control,
|
||||
&stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, so_locked);
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
* validates the AUTHentication related parameters in an INIT/INIT-ACK
|
||||
* Note: currently only used for INIT as INIT-ACK is handled inline
|
||||
|
@ -1843,7 +1798,7 @@ sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication,
|
|||
int
|
||||
sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
|
||||
{
|
||||
struct sctp_paramhdr *phdr, parm_buf;
|
||||
struct sctp_paramhdr *phdr, param_buf;
|
||||
uint16_t ptype, plen;
|
||||
int peer_supports_asconf = 0;
|
||||
int peer_supports_auth = 0;
|
||||
|
@ -1852,7 +1807,7 @@ sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
|
|||
uint8_t saw_asconf_ack = 0;
|
||||
|
||||
/* go through each of the params. */
|
||||
phdr = sctp_get_next_param(m, offset, &parm_buf, sizeof(parm_buf));
|
||||
phdr = sctp_get_next_param(m, offset, ¶m_buf, sizeof(param_buf));
|
||||
while (phdr) {
|
||||
ptype = ntohs(phdr->param_type);
|
||||
plen = ntohs(phdr->param_length);
|
||||
|
@ -1866,11 +1821,15 @@ sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
|
|||
if (ptype == SCTP_SUPPORTED_CHUNK_EXT) {
|
||||
/* A supported extension chunk */
|
||||
struct sctp_supported_chunk_types_param *pr_supported;
|
||||
uint8_t local_store[SCTP_PARAM_BUFFER_SIZE];
|
||||
uint8_t local_store[SCTP_SMALL_CHUNK_STORE];
|
||||
int num_ent, i;
|
||||
|
||||
if (plen > sizeof(local_store)) {
|
||||
break;
|
||||
}
|
||||
phdr = sctp_get_next_param(m, offset,
|
||||
(struct sctp_paramhdr *)&local_store, min(plen,sizeof(local_store)));
|
||||
(struct sctp_paramhdr *)&local_store,
|
||||
plen);
|
||||
if (phdr == NULL) {
|
||||
return (-1);
|
||||
}
|
||||
|
@ -1888,7 +1847,6 @@ sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
|
|||
}
|
||||
}
|
||||
} else if (ptype == SCTP_RANDOM) {
|
||||
got_random = 1;
|
||||
/* enforce the random length */
|
||||
if (plen != (sizeof(struct sctp_auth_random) +
|
||||
SCTP_AUTH_RANDOM_SIZE_REQUIRED)) {
|
||||
|
@ -1896,20 +1854,23 @@ sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
|
|||
"SCTP: invalid RANDOM len\n");
|
||||
return (-1);
|
||||
}
|
||||
got_random = 1;
|
||||
} else if (ptype == SCTP_HMAC_LIST) {
|
||||
uint8_t store[SCTP_PARAM_BUFFER_SIZE];
|
||||
struct sctp_auth_hmac_algo *hmacs;
|
||||
uint8_t store[SCTP_PARAM_BUFFER_SIZE];
|
||||
int num_hmacs;
|
||||
|
||||
if (plen > sizeof(store))
|
||||
if (plen > sizeof(store)) {
|
||||
break;
|
||||
}
|
||||
phdr = sctp_get_next_param(m, offset,
|
||||
(struct sctp_paramhdr *)store, min(plen,sizeof(store)));
|
||||
if (phdr == NULL)
|
||||
(struct sctp_paramhdr *)store,
|
||||
plen);
|
||||
if (phdr == NULL) {
|
||||
return (-1);
|
||||
}
|
||||
hmacs = (struct sctp_auth_hmac_algo *)phdr;
|
||||
num_hmacs = (plen - sizeof(*hmacs)) /
|
||||
sizeof(hmacs->hmac_ids[0]);
|
||||
num_hmacs = (plen - sizeof(*hmacs)) / sizeof(hmacs->hmac_ids[0]);
|
||||
/* validate the hmac list */
|
||||
if (sctp_verify_hmac_param(hmacs, num_hmacs)) {
|
||||
SCTPDBG(SCTP_DEBUG_AUTH1,
|
||||
|
@ -1918,16 +1879,19 @@ sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
|
|||
}
|
||||
got_hmacs = 1;
|
||||
} else if (ptype == SCTP_CHUNK_LIST) {
|
||||
int i, num_chunks;
|
||||
struct sctp_auth_chunk_list *chunks;
|
||||
uint8_t chunks_store[SCTP_SMALL_CHUNK_STORE];
|
||||
/* did the peer send a non-empty chunk list? */
|
||||
struct sctp_auth_chunk_list *chunks = NULL;
|
||||
int i, num_chunks;
|
||||
|
||||
if (plen > sizeof(chunks_store)) {
|
||||
break;
|
||||
}
|
||||
phdr = sctp_get_next_param(m, offset,
|
||||
(struct sctp_paramhdr *)chunks_store,
|
||||
min(plen,sizeof(chunks_store)));
|
||||
if (phdr == NULL)
|
||||
plen);
|
||||
if (phdr == NULL) {
|
||||
return (-1);
|
||||
|
||||
}
|
||||
/*-
|
||||
* Flip through the list and mark that the
|
||||
* peer supports asconf/asconf_ack.
|
||||
|
@ -1940,7 +1904,6 @@ sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
|
|||
saw_asconf = 1;
|
||||
if (chunks->chunk_types[i] == SCTP_ASCONF_ACK)
|
||||
saw_asconf_ack = 1;
|
||||
|
||||
}
|
||||
if (num_chunks)
|
||||
got_chklist = 1;
|
||||
|
@ -1950,8 +1913,8 @@ sctp_validate_init_auth_params(struct mbuf *m, int offset, int limit)
|
|||
if (offset >= limit) {
|
||||
break;
|
||||
}
|
||||
phdr = sctp_get_next_param(m, offset, &parm_buf,
|
||||
sizeof(parm_buf));
|
||||
phdr = sctp_get_next_param(m, offset, ¶m_buf,
|
||||
sizeof(param_buf));
|
||||
}
|
||||
/* validate authentication required parameters */
|
||||
if (got_random && got_hmacs) {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 271673 2014-09-16 14:20:33Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_AUTH_H_
|
||||
|
@ -97,8 +99,6 @@ typedef struct sctp_authinformation {
|
|||
uint16_t recv_keyid; /* last recv keyid (cached) */
|
||||
} sctp_authinfo_t;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Macros
|
||||
*/
|
||||
|
@ -147,7 +147,6 @@ extern void sctp_auth_key_acquire(struct sctp_tcb *stcb, uint16_t keyid);
|
|||
extern void sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t keyid,
|
||||
int so_locked);
|
||||
|
||||
|
||||
/* hmac list handling */
|
||||
extern sctp_hmaclist_t *sctp_alloc_hmaclist(uint16_t num_hmacs);
|
||||
extern void sctp_free_hmaclist(sctp_hmaclist_t *list);
|
||||
|
@ -168,8 +167,6 @@ extern uint32_t sctp_get_auth_chunk_len(uint16_t hmac_algo);
|
|||
extern uint32_t sctp_get_hmac_digest_len(uint16_t hmac_algo);
|
||||
extern uint32_t sctp_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
|
||||
uint8_t *text, uint32_t textlen, uint8_t *digest);
|
||||
extern int sctp_verify_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
|
||||
uint8_t *text, uint32_t textlen, uint8_t *digest, uint32_t digestlen);
|
||||
extern uint32_t sctp_compute_hmac(uint16_t hmac_algo, sctp_key_t *key,
|
||||
uint8_t *text, uint32_t textlen, uint8_t *digest);
|
||||
extern int sctp_auth_is_supported_hmac(sctp_hmaclist_t *list, uint16_t id);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 276914 2015-01-10 20:49:57Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#include <netinet/sctp_os.h>
|
||||
|
@ -48,17 +50,11 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 276914 2015-01-10 20:49:57Z
|
|||
#include <netinet/sctp_asconf.h>
|
||||
#include <netinet/sctp_sysctl.h>
|
||||
#include <netinet/sctp_indata.h>
|
||||
#if defined(ANDROID)
|
||||
#include <unistd.h>
|
||||
#include <ifaddrs-android-ext.h>
|
||||
#else
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/unistd.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Declare all of our malloc named types */
|
||||
#ifndef __Panda__
|
||||
MALLOC_DEFINE(SCTP_M_MAP, "sctp_map", "sctp asoc map descriptor");
|
||||
MALLOC_DEFINE(SCTP_M_STRMI, "sctp_stri", "sctp stream in array");
|
||||
MALLOC_DEFINE(SCTP_M_STRMO, "sctp_stro", "sctp stream out array");
|
||||
|
@ -79,12 +75,11 @@ MALLOC_DEFINE(SCTP_M_MVRF, "sctp_mvrf", "sctp mvrf pcb list");
|
|||
MALLOC_DEFINE(SCTP_M_ITER, "sctp_iter", "sctp iterator control");
|
||||
MALLOC_DEFINE(SCTP_M_SOCKOPT, "sctp_socko", "sctp socket option");
|
||||
MALLOC_DEFINE(SCTP_M_MCORE, "sctp_mcore", "sctp mcore queue");
|
||||
#endif
|
||||
|
||||
/* Global NON-VNET structure that controls the iterator */
|
||||
struct iterator_control sctp_it_ctl;
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
|
||||
#if !defined(__FreeBSD__)
|
||||
static void
|
||||
sctp_cleanup_itqueue(void)
|
||||
{
|
||||
|
@ -112,7 +107,7 @@ void
|
|||
sctp_wakeup_iterator(void)
|
||||
{
|
||||
#if defined(SCTP_PROCESS_LEVEL_LOCKS)
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
WakeAllConditionVariable(&sctp_it_ctl.iterator_wakeup);
|
||||
#else
|
||||
pthread_cond_broadcast(&sctp_it_ctl.iterator_wakeup);
|
||||
|
@ -129,9 +124,12 @@ static void
|
|||
#endif
|
||||
sctp_iterator_thread(void *v SCTP_UNUSED)
|
||||
{
|
||||
#if defined(__Userspace__)
|
||||
sctp_userspace_set_threadname("SCTP iterator");
|
||||
#endif
|
||||
SCTP_IPI_ITERATOR_WQ_LOCK();
|
||||
/* In FreeBSD this thread never terminates. */
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
for (;;) {
|
||||
#else
|
||||
while ((sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) == 0) {
|
||||
|
@ -140,25 +138,25 @@ sctp_iterator_thread(void *v SCTP_UNUSED)
|
|||
msleep(&sctp_it_ctl.iterator_running,
|
||||
#if defined(__FreeBSD__)
|
||||
&sctp_it_ctl.ipi_iterator_wq_mtx,
|
||||
#elif defined(__APPLE__) || defined(__Userspace_os_Darwin)
|
||||
#elif defined(__APPLE__)
|
||||
sctp_it_ctl.ipi_iterator_wq_mtx,
|
||||
#endif
|
||||
0, "waiting_for_work", 0);
|
||||
#else
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
SleepConditionVariableCS(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx, INFINITE);
|
||||
#else
|
||||
pthread_cond_wait(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx);
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(__FreeBSD__)
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
sctp_iterator_worker();
|
||||
}
|
||||
#if !defined(__FreeBSD__)
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
/* Now this thread needs to be terminated */
|
||||
sctp_cleanup_itqueue();
|
||||
sctp_it_ctl.iterator_flags |= SCTP_ITERATOR_EXITED;
|
||||
|
@ -187,27 +185,21 @@ sctp_startup_iterator(void)
|
|||
SCTP_ITERATOR_LOCK_INIT();
|
||||
SCTP_IPI_ITERATOR_WQ_INIT();
|
||||
TAILQ_INIT(&sctp_it_ctl.iteratorhead);
|
||||
#if defined(__FreeBSD__)
|
||||
#if __FreeBSD_version <= 701000
|
||||
kthread_create(sctp_iterator_thread,
|
||||
#else
|
||||
#if defined(__Userspace__)
|
||||
if (sctp_userspace_thread_create(&sctp_it_ctl.thread_proc, &sctp_iterator_thread)) {
|
||||
SCTP_PRINTF("ERROR: Creating sctp_iterator_thread failed.\n");
|
||||
} else {
|
||||
SCTP_BASE_VAR(iterator_thread_started) = 1;
|
||||
}
|
||||
#elif defined(__FreeBSD__)
|
||||
kproc_create(sctp_iterator_thread,
|
||||
#endif
|
||||
(void *)NULL,
|
||||
&sctp_it_ctl.thread_proc,
|
||||
RFPROC,
|
||||
0,
|
||||
SCTP_KTHREAD_PAGES,
|
||||
SCTP_KTRHEAD_NAME);
|
||||
#elif defined(__APPLE__)
|
||||
kernel_thread_start((thread_continue_t)sctp_iterator_thread, NULL, &sctp_it_ctl.thread_proc);
|
||||
#elif defined(__Userspace__)
|
||||
#if defined(__Userspace_os_Windows)
|
||||
if ((sctp_it_ctl.thread_proc = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&sctp_iterator_thread, NULL, 0, NULL)) == NULL) {
|
||||
#else
|
||||
if (pthread_create(&sctp_it_ctl.thread_proc, NULL, &sctp_iterator_thread, NULL)) {
|
||||
#endif
|
||||
SCTP_PRINTF("ERROR: Creating sctp_iterator_thread failed.\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -252,7 +244,6 @@ sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa)
|
|||
#endif /* __Userspace__ */
|
||||
#endif /* INET6 */
|
||||
|
||||
|
||||
#if !defined(__Userspace__)
|
||||
static uint32_t
|
||||
sctp_is_desired_interface_type(struct ifnet *ifn)
|
||||
|
@ -260,7 +251,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn)
|
|||
int result;
|
||||
|
||||
/* check the interface type to see if it's one we care about */
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
switch(ifnet_type(ifn)) {
|
||||
#else
|
||||
switch (ifn->if_type) {
|
||||
|
@ -286,7 +277,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn)
|
|||
case IFT_GIF:
|
||||
case IFT_L2VLAN:
|
||||
case IFT_STF:
|
||||
#if !defined(__APPLE__)
|
||||
#if !(defined(__APPLE__) && !defined(__Userspace__))
|
||||
case IFT_IP:
|
||||
case IFT_IPOVERCDLC:
|
||||
case IFT_IPOVERCLAW:
|
||||
|
@ -302,29 +293,22 @@ sctp_is_desired_interface_type(struct ifnet *ifn)
|
|||
return (result);
|
||||
}
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
|
||||
#if defined(__APPLE__)
|
||||
int
|
||||
sctp_is_vmware_interface(struct ifnet *ifn)
|
||||
{
|
||||
return (strncmp(ifnet_name(ifn), "vmnet", 5) == 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#ifdef MALLOC
|
||||
#undef MALLOC
|
||||
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
|
||||
#endif
|
||||
#ifdef FREE
|
||||
#undef FREE
|
||||
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
|
||||
#endif
|
||||
#if defined(_WIN32) && defined(__Userspace__)
|
||||
#define SCTP_BSD_FREE(x) HeapFree(GetProcessHeap(), 0, (x))
|
||||
static void
|
||||
sctp_init_ifns_for_vrf(int vrfid)
|
||||
{
|
||||
#if defined(INET) || defined(INET6)
|
||||
struct ifaddrs *ifa;
|
||||
struct sctp_ifa *sctp_ifa;
|
||||
DWORD Err, AdapterAddrsSize;
|
||||
PIP_ADAPTER_ADDRESSES pAdapterAddrs, pAdapt;
|
||||
|
@ -350,6 +334,7 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
/* Get actual adapter information */
|
||||
if ((Err = GetAdaptersAddresses(AF_INET, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
|
||||
SCTP_PRINTF("GetAdaptersV4Addresses() failed with error code %d\n", Err);
|
||||
SCTP_BSD_FREE(pAdapterAddrs);
|
||||
return;
|
||||
}
|
||||
/* Enumerate through each returned adapter and save its information */
|
||||
|
@ -359,20 +344,14 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
if (IN4_ISLINKLOCAL_ADDRESS(&(((struct sockaddr_in *)(pUnicast->Address.lpSockaddr))->sin_addr))) {
|
||||
continue;
|
||||
}
|
||||
ifa = (struct ifaddrs*)malloc(sizeof(struct ifaddrs));
|
||||
ifa->ifa_name = _strdup(pAdapt->AdapterName);
|
||||
ifa->ifa_flags = pAdapt->Flags;
|
||||
ifa->ifa_addr = (struct sockaddr *)malloc(sizeof(struct sockaddr_in));
|
||||
memcpy(ifa->ifa_addr, pUnicast->Address.lpSockaddr, sizeof(struct sockaddr_in));
|
||||
|
||||
sctp_ifa = sctp_add_addr_to_vrf(0,
|
||||
ifa,
|
||||
NULL,
|
||||
pAdapt->IfIndex,
|
||||
(pAdapt->IfType == IF_TYPE_IEEE80211)?MIB_IF_TYPE_ETHERNET:pAdapt->IfType,
|
||||
ifa->ifa_name,
|
||||
(void *)ifa,
|
||||
ifa->ifa_addr,
|
||||
ifa->ifa_flags,
|
||||
pAdapt->AdapterName,
|
||||
NULL,
|
||||
pUnicast->Address.lpSockaddr,
|
||||
pAdapt->Flags,
|
||||
0);
|
||||
if (sctp_ifa) {
|
||||
sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE;
|
||||
|
@ -380,8 +359,7 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (pAdapterAddrs)
|
||||
FREE(pAdapterAddrs);
|
||||
SCTP_BSD_FREE(pAdapterAddrs);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
AdapterAddrsSize = 0;
|
||||
|
@ -401,25 +379,21 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
/* Get actual adapter information */
|
||||
if ((Err = GetAdaptersAddresses(AF_INET6, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
|
||||
SCTP_PRINTF("GetAdaptersV6Addresses() failed with error code %d\n", Err);
|
||||
SCTP_BSD_FREE(pAdapterAddrs);
|
||||
return;
|
||||
}
|
||||
/* Enumerate through each returned adapter and save its information */
|
||||
for (pAdapt = pAdapterAddrs; pAdapt; pAdapt = pAdapt->Next) {
|
||||
if (pAdapt->IfType == IF_TYPE_IEEE80211 || pAdapt->IfType == IF_TYPE_ETHERNET_CSMACD) {
|
||||
for (pUnicast = pAdapt->FirstUnicastAddress; pUnicast; pUnicast = pUnicast->Next) {
|
||||
ifa = (struct ifaddrs*)malloc(sizeof(struct ifaddrs));
|
||||
ifa->ifa_name = _strdup(pAdapt->AdapterName);
|
||||
ifa->ifa_flags = pAdapt->Flags;
|
||||
ifa->ifa_addr = (struct sockaddr *)malloc(sizeof(struct sockaddr_in6));
|
||||
memcpy(ifa->ifa_addr, pUnicast->Address.lpSockaddr, sizeof(struct sockaddr_in6));
|
||||
sctp_ifa = sctp_add_addr_to_vrf(0,
|
||||
ifa,
|
||||
NULL,
|
||||
pAdapt->Ipv6IfIndex,
|
||||
(pAdapt->IfType == IF_TYPE_IEEE80211)?MIB_IF_TYPE_ETHERNET:pAdapt->IfType,
|
||||
ifa->ifa_name,
|
||||
(void *)ifa,
|
||||
ifa->ifa_addr,
|
||||
ifa->ifa_flags,
|
||||
pAdapt->AdapterName,
|
||||
NULL,
|
||||
pUnicast->Address.lpSockaddr,
|
||||
pAdapt->Flags,
|
||||
0);
|
||||
if (sctp_ifa) {
|
||||
sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE;
|
||||
|
@ -427,8 +401,7 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (pAdapterAddrs)
|
||||
FREE(pAdapterAddrs);
|
||||
SCTP_BSD_FREE(pAdapterAddrs);
|
||||
#endif
|
||||
}
|
||||
#elif defined(__Userspace__)
|
||||
|
@ -437,15 +410,15 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
{
|
||||
#if defined(INET) || defined(INET6)
|
||||
int rc;
|
||||
struct ifaddrs *ifa = NULL;
|
||||
struct ifaddrs *ifa, *ifas;
|
||||
struct sctp_ifa *sctp_ifa;
|
||||
uint32_t ifa_flags;
|
||||
|
||||
rc = getifaddrs(&g_interfaces);
|
||||
rc = getifaddrs(&ifas);
|
||||
if (rc != 0) {
|
||||
return;
|
||||
}
|
||||
for (ifa = g_interfaces; ifa; ifa = ifa->ifa_next) {
|
||||
for (ifa = ifas; ifa; ifa = ifa->ifa_next) {
|
||||
if (ifa->ifa_addr == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
@ -468,7 +441,7 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
#if defined(INET6)
|
||||
if ((ifa->ifa_addr->sa_family == AF_INET6) &&
|
||||
IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr)) {
|
||||
/* skip unspecifed addresses */
|
||||
/* skip unspecified addresses */
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
@ -480,11 +453,11 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
#endif
|
||||
ifa_flags = 0;
|
||||
sctp_ifa = sctp_add_addr_to_vrf(vrfid,
|
||||
ifa,
|
||||
NULL,
|
||||
if_nametoindex(ifa->ifa_name),
|
||||
0,
|
||||
ifa->ifa_name,
|
||||
(void *)ifa,
|
||||
NULL,
|
||||
ifa->ifa_addr,
|
||||
ifa_flags,
|
||||
0);
|
||||
|
@ -492,11 +465,11 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE;
|
||||
}
|
||||
}
|
||||
freeifaddrs(ifas);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
static void
|
||||
sctp_init_ifns_for_vrf(int vrfid)
|
||||
{
|
||||
|
@ -541,7 +514,7 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
}
|
||||
if (ifa->ifa_addr->sa_family == AF_INET6) {
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr)) {
|
||||
/* skip unspecifed addresses */
|
||||
/* skip unspecified addresses */
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
@ -555,13 +528,13 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
} else {
|
||||
ifa_flags = 0;
|
||||
}
|
||||
snprintf(name, SCTP_IFNAMSIZ, "%s%d", ifnet_name(ifn), ifnet_unit(ifn));
|
||||
SCTP_SNPRINTF(name, SCTP_IFNAMSIZ, "%s%d", ifnet_name(ifn), ifnet_unit(ifn));
|
||||
sctp_ifa = sctp_add_addr_to_vrf(vrfid,
|
||||
(void *)ifn,
|
||||
(void *)ifn, /* XXX */
|
||||
ifnet_index(ifn),
|
||||
ifnet_type(ifn),
|
||||
name,
|
||||
(void *)ifa,
|
||||
(void *)ifa, /* XXX */
|
||||
ifa->ifa_addr,
|
||||
ifa_flags,
|
||||
0);
|
||||
|
@ -574,8 +547,7 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
ifnet_list_free(ifnetlist);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
static void
|
||||
sctp_init_ifns_for_vrf(int vrfid)
|
||||
{
|
||||
|
@ -584,6 +556,7 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
* any IFA that exists as we float through the
|
||||
* list of IFA's
|
||||
*/
|
||||
struct epoch_tracker et;
|
||||
struct ifnet *ifn;
|
||||
struct ifaddr *ifa;
|
||||
struct sctp_ifa *sctp_ifa;
|
||||
|
@ -593,17 +566,13 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
#endif
|
||||
|
||||
IFNET_RLOCK();
|
||||
TAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_list) {
|
||||
NET_EPOCH_ENTER(et);
|
||||
CK_STAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_link) {
|
||||
if (sctp_is_desired_interface_type(ifn) == 0) {
|
||||
/* non desired type */
|
||||
continue;
|
||||
}
|
||||
#if (__FreeBSD_version >= 803000 && __FreeBSD_version < 900000) || __FreeBSD_version > 900000
|
||||
IF_ADDR_RLOCK(ifn);
|
||||
#else
|
||||
IF_ADDR_LOCK(ifn);
|
||||
#endif
|
||||
TAILQ_FOREACH(ifa, &ifn->if_addrlist, ifa_list) {
|
||||
CK_STAILQ_FOREACH(ifa, &ifn->if_addrhead, ifa_link) {
|
||||
if (ifa->ifa_addr == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
@ -618,7 +587,7 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr)) {
|
||||
/* skip unspecifed addresses */
|
||||
/* skip unspecified addresses */
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
@ -655,12 +624,8 @@ sctp_init_ifns_for_vrf(int vrfid)
|
|||
sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE;
|
||||
}
|
||||
}
|
||||
#if (__FreeBSD_version >= 803000 && __FreeBSD_version < 900000) || __FreeBSD_version > 900000
|
||||
IF_ADDR_RUNLOCK(ifn);
|
||||
#else
|
||||
IF_ADDR_UNLOCK(ifn);
|
||||
#endif
|
||||
}
|
||||
NET_EPOCH_EXIT(et);
|
||||
IFNET_RUNLOCK();
|
||||
}
|
||||
#endif
|
||||
|
@ -688,10 +653,14 @@ sctp_addr_change(struct ifaddr *ifa, int cmd)
|
|||
return;
|
||||
#else
|
||||
uint32_t ifa_flags = 0;
|
||||
|
||||
if (SCTP_BASE_VAR(sctp_pcb_initialized) == 0) {
|
||||
return;
|
||||
}
|
||||
/* BSD only has one VRF, if this changes
|
||||
* we will need to hook in the right
|
||||
* things here to get the id to pass to
|
||||
* the address managment routine.
|
||||
* the address management routine.
|
||||
*/
|
||||
if (SCTP_BASE_VAR(first_time) == 0) {
|
||||
/* Special test to see if my ::1 will showup with this */
|
||||
|
@ -723,7 +692,7 @@ sctp_addr_change(struct ifaddr *ifa, int cmd)
|
|||
case AF_INET6:
|
||||
ifa_flags = ((struct in6_ifaddr *)ifa)->ia6_flags;
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr)) {
|
||||
/* skip unspecifed addresses */
|
||||
/* skip unspecified addresses */
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -734,16 +703,15 @@ sctp_addr_change(struct ifaddr *ifa, int cmd)
|
|||
}
|
||||
if (cmd == RTM_ADD) {
|
||||
(void)sctp_add_addr_to_vrf(SCTP_DEFAULT_VRFID, (void *)ifa->ifa_ifp,
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
ifnet_index(ifa->ifa_ifp), ifnet_type(ifa->ifa_ifp), ifnet_name(ifa->ifa_ifp),
|
||||
#else
|
||||
ifa->ifa_ifp->if_index, ifa->ifa_ifp->if_type, ifa->ifa_ifp->if_xname,
|
||||
#endif
|
||||
(void *)ifa, ifa->ifa_addr, ifa_flags, 1);
|
||||
} else {
|
||||
|
||||
sctp_del_addr_from_vrf(SCTP_DEFAULT_VRFID, ifa->ifa_addr,
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
ifnet_index(ifa->ifa_ifp),
|
||||
ifnet_name(ifa->ifa_ifp));
|
||||
#else
|
||||
|
@ -758,26 +726,13 @@ sctp_addr_change(struct ifaddr *ifa, int cmd)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
void
|
||||
sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add)
|
||||
{
|
||||
struct ifnet *ifn;
|
||||
struct ifaddr *ifa;
|
||||
|
||||
IFNET_RLOCK();
|
||||
TAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_list) {
|
||||
if (!(*pred)(ifn)) {
|
||||
continue;
|
||||
}
|
||||
TAILQ_FOREACH(ifa, &ifn->if_addrlist, ifa_list) {
|
||||
sctp_addr_change(ifa, add ? RTM_ADD : RTM_DELETE);
|
||||
}
|
||||
}
|
||||
IFNET_RUNLOCK();
|
||||
sctp_addr_change_event_handler(void *arg __unused, struct ifaddr *ifa, int cmd) {
|
||||
sctp_addr_change(ifa, cmd);
|
||||
}
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
void
|
||||
sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add)
|
||||
{
|
||||
|
@ -809,149 +764,52 @@ struct mbuf *
|
|||
sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header,
|
||||
int how, int allonebuf, int type)
|
||||
{
|
||||
struct mbuf *m = NULL;
|
||||
struct mbuf *m = NULL;
|
||||
#if defined(__FreeBSD__) || defined(__Userspace__)
|
||||
#if defined(__Userspace__)
|
||||
|
||||
/*
|
||||
* __Userspace__
|
||||
* Using m_clget, which creates and mbuf and a cluster and
|
||||
* hooks those together.
|
||||
* TODO: This does not yet have functionality for jumbo packets.
|
||||
*
|
||||
*/
|
||||
|
||||
int mbuf_threshold;
|
||||
if (want_header) {
|
||||
MGETHDR(m, how, type);
|
||||
} else {
|
||||
MGET(m, how, type);
|
||||
}
|
||||
if (m == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
if (allonebuf == 0)
|
||||
mbuf_threshold = SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count);
|
||||
else
|
||||
mbuf_threshold = 1;
|
||||
|
||||
|
||||
if ((int)space_needed > (((mbuf_threshold - 1) * MLEN) + MHLEN)) {
|
||||
MCLGET(m, how);
|
||||
if (m == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (SCTP_BUF_IS_EXTENDED(m) == 0) {
|
||||
sctp_m_freem(m);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
SCTP_BUF_LEN(m) = 0;
|
||||
SCTP_BUF_NEXT(m) = SCTP_BUF_NEXT_PKT(m) = NULL;
|
||||
|
||||
/* __Userspace__
|
||||
* Check if anything need to be done to ensure logging works
|
||||
*/
|
||||
#ifdef SCTP_MBUF_LOGGING
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) {
|
||||
sctp_log_mb(m, SCTP_MBUF_IALLOC);
|
||||
}
|
||||
m = m_getm2(NULL, space_needed, how, type, want_header ? M_PKTHDR : 0, allonebuf);
|
||||
#else
|
||||
m = m_getm2(NULL, space_needed, how, type, want_header ? M_PKTHDR : 0);
|
||||
#endif
|
||||
#elif defined(__FreeBSD__) && __FreeBSD_version > 1100052
|
||||
m = m_getm2(NULL, space_needed, how, type, want_header ? M_PKTHDR : 0);
|
||||
if (m == NULL) {
|
||||
/* bad, no memory */
|
||||
return (m);
|
||||
}
|
||||
#if !defined(__Userspace__)
|
||||
if (allonebuf) {
|
||||
if (SCTP_BUF_SIZE(m) < space_needed) {
|
||||
m_freem(m);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
if (SCTP_BUF_NEXT(m)) {
|
||||
sctp_m_freem(SCTP_BUF_NEXT(m));
|
||||
SCTP_BUF_NEXT(m) = NULL;
|
||||
}
|
||||
#ifdef SCTP_MBUF_LOGGING
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) {
|
||||
sctp_log_mb(m, SCTP_MBUF_IALLOC);
|
||||
KASSERT(SCTP_BUF_NEXT(m) == NULL, ("%s: no chain allowed", __func__));
|
||||
}
|
||||
#endif
|
||||
#elif defined(__FreeBSD__) && __FreeBSD_version > 602000
|
||||
m = m_getm2(NULL, space_needed, how, type, want_header ? M_PKTHDR : 0);
|
||||
if (m == NULL) {
|
||||
/* bad, no memory */
|
||||
return (m);
|
||||
}
|
||||
if (allonebuf) {
|
||||
int siz;
|
||||
if (SCTP_BUF_IS_EXTENDED(m)) {
|
||||
siz = SCTP_BUF_EXTEND_SIZE(m);
|
||||
} else {
|
||||
if (want_header)
|
||||
siz = MHLEN;
|
||||
else
|
||||
siz = MLEN;
|
||||
}
|
||||
if (siz < space_needed) {
|
||||
m_freem(m);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
if (SCTP_BUF_NEXT(m)) {
|
||||
sctp_m_freem(SCTP_BUF_NEXT(m));
|
||||
SCTP_BUF_NEXT(m) = NULL;
|
||||
}
|
||||
#ifdef SCTP_MBUF_LOGGING
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) {
|
||||
sctp_log_mb(m, SCTP_MBUF_IALLOC);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 601000
|
||||
int aloc_size;
|
||||
int index = 0;
|
||||
#endif
|
||||
int mbuf_threshold;
|
||||
unsigned int size;
|
||||
|
||||
if (want_header) {
|
||||
MGETHDR(m, how, type);
|
||||
size = MHLEN;
|
||||
} else {
|
||||
MGET(m, how, type);
|
||||
size = MLEN;
|
||||
}
|
||||
if (m == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
if (allonebuf == 0)
|
||||
if (allonebuf == 0) {
|
||||
mbuf_threshold = SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count);
|
||||
else
|
||||
} else {
|
||||
mbuf_threshold = 1;
|
||||
}
|
||||
|
||||
|
||||
if (space_needed > (((mbuf_threshold - 1) * MLEN) + MHLEN)) {
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 601000
|
||||
try_again:
|
||||
index = 4;
|
||||
if (space_needed <= MCLBYTES) {
|
||||
aloc_size = MCLBYTES;
|
||||
} else {
|
||||
aloc_size = MJUMPAGESIZE;
|
||||
index = 5;
|
||||
}
|
||||
m_cljget(m, how, aloc_size);
|
||||
if (m == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
if (SCTP_BUF_IS_EXTENDED(m) == 0) {
|
||||
if ((aloc_size != MCLBYTES) &&
|
||||
(allonebuf == 0)) {
|
||||
aloc_size -= 10;
|
||||
goto try_again;
|
||||
}
|
||||
sctp_m_freem(m);
|
||||
return (NULL);
|
||||
}
|
||||
#else
|
||||
if (space_needed > (unsigned int)(((mbuf_threshold - 1) * MLEN) + MHLEN)) {
|
||||
MCLGET(m, how);
|
||||
if (m == NULL) {
|
||||
return (NULL);
|
||||
|
@ -960,7 +818,11 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header,
|
|||
sctp_m_freem(m);
|
||||
return (NULL);
|
||||
}
|
||||
#endif
|
||||
size = SCTP_BUF_EXTEND_SIZE(m);
|
||||
}
|
||||
if (allonebuf != 0 && size < space_needed) {
|
||||
m_freem(m);
|
||||
return (NULL);
|
||||
}
|
||||
SCTP_BUF_LEN(m) = 0;
|
||||
SCTP_BUF_NEXT(m) = SCTP_BUF_NEXT_PKT(m) = NULL;
|
||||
|
@ -973,7 +835,6 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header,
|
|||
return (m);
|
||||
}
|
||||
|
||||
|
||||
#ifdef SCTP_PACKET_LOGGING
|
||||
void
|
||||
sctp_packet_log(struct mbuf *m)
|
||||
|
@ -1049,7 +910,6 @@ sctp_packet_log(struct mbuf *m)
|
|||
SCTP_BASE_VAR(packet_log_end));
|
||||
SCTP_BASE_VAR(packet_log_end) = 0;
|
||||
goto no_log;
|
||||
|
||||
}
|
||||
lenat = (int *)&SCTP_BASE_VAR(packet_log_buffer)[thisbegin];
|
||||
*lenat = total_len;
|
||||
|
@ -1075,7 +935,6 @@ sctp_packet_log(struct mbuf *m)
|
|||
atomic_subtract_int(&SCTP_BASE_VAR(packet_log_writers), 1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sctp_copy_out_packet_log(uint8_t *target, int length)
|
||||
{
|
||||
|
@ -1083,11 +942,10 @@ sctp_copy_out_packet_log(uint8_t *target, int length)
|
|||
* start copying up to length bytes out.
|
||||
* We return the number of bytes copied.
|
||||
*/
|
||||
int tocopy, this_copy;
|
||||
int this_copy;
|
||||
int *lenat;
|
||||
int did_delay = 0;
|
||||
|
||||
tocopy = length;
|
||||
if (length < (int)(2 * sizeof(int))) {
|
||||
/* not enough room */
|
||||
return (0);
|
||||
|
@ -1115,7 +973,7 @@ sctp_copy_out_packet_log(uint8_t *target, int length)
|
|||
memcpy((void *)lenat, (void *)SCTP_BASE_VAR(packet_log_buffer), this_copy);
|
||||
if (SCTP_PKTLOG_WRITERS_NEED_LOCK) {
|
||||
atomic_subtract_int(&SCTP_BASE_VAR(packet_log_writers),
|
||||
SCTP_PKTLOG_WRITERS_NEED_LOCK);
|
||||
SCTP_PKTLOG_WRITERS_NEED_LOCK);
|
||||
}
|
||||
SCTP_IP_PKTLOG_UNLOCK();
|
||||
return (this_copy + sizeof(int));
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 237540 2012-06-24 21:25:54Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_BSD_ADDR_H_
|
||||
|
@ -47,7 +49,6 @@ void sctp_wakeup_iterator(void);
|
|||
|
||||
void sctp_startup_iterator(void);
|
||||
|
||||
|
||||
#ifdef INET6
|
||||
void sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa);
|
||||
#endif
|
||||
|
@ -59,8 +60,10 @@ int sctp_copy_out_packet_log(uint8_t *target, int length);
|
|||
|
||||
#endif
|
||||
|
||||
#if !defined(__Panda__)
|
||||
void sctp_addr_change(struct ifaddr *ifa, int cmd);
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
|
||||
void sctp_addr_change_event_handler(void *, struct ifaddr *, int);
|
||||
#endif
|
||||
|
||||
void sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -32,18 +34,19 @@
|
|||
|
||||
#if defined(__Userspace__)
|
||||
#include <sys/types.h>
|
||||
#if !defined (__Userspace_os_Windows)
|
||||
#if !defined(_WIN32)
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#if defined(__Userspace_os_NaCl)
|
||||
#if defined(__native_client__)
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <user_atomic.h>
|
||||
#include <netinet/sctp_sysctl.h>
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#else
|
||||
|
@ -51,16 +54,26 @@
|
|||
#include <netinet/sctp_callout.h>
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#endif
|
||||
#include <netinet/sctputil.h>
|
||||
|
||||
/*
|
||||
* Callout/Timer routines for OS that doesn't have them
|
||||
*/
|
||||
#if defined(__APPLE__) || defined(__Userspace__)
|
||||
int ticks = 0;
|
||||
static uint32_t ticks = 0;
|
||||
#else
|
||||
extern int ticks;
|
||||
#endif
|
||||
|
||||
uint32_t sctp_get_tick_count(void) {
|
||||
uint32_t ret;
|
||||
|
||||
SCTP_TIMERQ_LOCK();
|
||||
ret = ticks;
|
||||
SCTP_TIMERQ_UNLOCK();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* SCTP_TIMERQ_LOCK protects:
|
||||
* - SCTP_BASE_INFO(callqueue)
|
||||
|
@ -71,20 +84,23 @@ static sctp_os_timer_t *sctp_os_timer_next = NULL;
|
|||
void
|
||||
sctp_os_timer_init(sctp_os_timer_t *c)
|
||||
{
|
||||
bzero(c, sizeof(*c));
|
||||
memset(c, 0, sizeof(*c));
|
||||
}
|
||||
|
||||
void
|
||||
sctp_os_timer_start(sctp_os_timer_t *c, int to_ticks, void (*ftn) (void *),
|
||||
int
|
||||
sctp_os_timer_start(sctp_os_timer_t *c, uint32_t to_ticks, void (*ftn) (void *),
|
||||
void *arg)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* paranoia */
|
||||
if ((c == NULL) || (ftn == NULL))
|
||||
return;
|
||||
return (ret);
|
||||
|
||||
SCTP_TIMERQ_LOCK();
|
||||
/* check to see if we're rescheduling a timer */
|
||||
if (c->c_flags & SCTP_CALLOUT_PENDING) {
|
||||
ret = 1;
|
||||
if (c == sctp_os_timer_next) {
|
||||
sctp_os_timer_next = TAILQ_NEXT(c, tqe);
|
||||
}
|
||||
|
@ -101,7 +117,7 @@ sctp_os_timer_start(sctp_os_timer_t *c, int to_ticks, void (*ftn) (void *),
|
|||
* We could unlock/splx here and lock/spl at the TAILQ_INSERT_TAIL,
|
||||
* but there's no point since doing this setup doesn't take much time.
|
||||
*/
|
||||
if (to_ticks <= 0)
|
||||
if (to_ticks == 0)
|
||||
to_ticks = 1;
|
||||
|
||||
c->c_arg = arg;
|
||||
|
@ -110,6 +126,7 @@ sctp_os_timer_start(sctp_os_timer_t *c, int to_ticks, void (*ftn) (void *),
|
|||
c->c_time = ticks + to_ticks;
|
||||
TAILQ_INSERT_TAIL(&SCTP_BASE_INFO(callqueue), c, tqe);
|
||||
SCTP_TIMERQ_UNLOCK();
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -119,7 +136,7 @@ sctp_os_timer_stop(sctp_os_timer_t *c)
|
|||
/*
|
||||
* Don't attempt to delete a callout that's not on the queue.
|
||||
*/
|
||||
if (!(c->c_flags & SCTP_CALLOUT_PENDING)) {
|
||||
if ((c->c_flags & SCTP_CALLOUT_PENDING) == 0) {
|
||||
c->c_flags &= ~SCTP_CALLOUT_ACTIVE;
|
||||
SCTP_TIMERQ_UNLOCK();
|
||||
return (0);
|
||||
|
@ -133,8 +150,8 @@ sctp_os_timer_stop(sctp_os_timer_t *c)
|
|||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
sctp_handle_tick(int delta)
|
||||
void
|
||||
sctp_handle_tick(uint32_t elapsed_ticks)
|
||||
{
|
||||
sctp_os_timer_t *c;
|
||||
void (*c_func)(void *);
|
||||
|
@ -142,10 +159,10 @@ sctp_handle_tick(int delta)
|
|||
|
||||
SCTP_TIMERQ_LOCK();
|
||||
/* update our tick count */
|
||||
ticks += delta;
|
||||
ticks += elapsed_ticks;
|
||||
c = TAILQ_FIRST(&SCTP_BASE_INFO(callqueue));
|
||||
while (c) {
|
||||
if (c->c_time <= ticks) {
|
||||
if (SCTP_UINT32_GE(ticks, c->c_time)) {
|
||||
sctp_os_timer_next = TAILQ_NEXT(c, tqe);
|
||||
TAILQ_REMOVE(&SCTP_BASE_INFO(callqueue), c, tqe);
|
||||
c_func = c->c_func;
|
||||
|
@ -163,7 +180,7 @@ sctp_handle_tick(int delta)
|
|||
SCTP_TIMERQ_UNLOCK();
|
||||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
void
|
||||
sctp_timeout(void *arg SCTP_UNUSED)
|
||||
{
|
||||
|
@ -178,43 +195,55 @@ sctp_timeout(void *arg SCTP_UNUSED)
|
|||
void *
|
||||
user_sctp_timer_iterate(void *arg)
|
||||
{
|
||||
sctp_userspace_set_threadname("SCTP timer");
|
||||
for (;;) {
|
||||
#if defined (__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
Sleep(TIMEOUT_INTERVAL);
|
||||
#else
|
||||
struct timeval timeout;
|
||||
struct timespec amount, remaining;
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 1000 * TIMEOUT_INTERVAL;
|
||||
select(0, NULL, NULL, NULL, &timeout);
|
||||
remaining.tv_sec = 0;
|
||||
remaining.tv_nsec = TIMEOUT_INTERVAL * 1000 * 1000;
|
||||
do {
|
||||
amount = remaining;
|
||||
} while (nanosleep(&amount, &remaining) == -1);
|
||||
#endif
|
||||
if (SCTP_BASE_VAR(timer_thread_should_exit)) {
|
||||
if (atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 1, 1)) {
|
||||
break;
|
||||
}
|
||||
sctp_handle_tick(MSEC_TO_TICKS(TIMEOUT_INTERVAL));
|
||||
sctp_handle_tick(sctp_msecs_to_ticks(TIMEOUT_INTERVAL));
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_start_timer(void)
|
||||
sctp_start_timer_thread(void)
|
||||
{
|
||||
/*
|
||||
* No need to do SCTP_TIMERQ_LOCK_INIT();
|
||||
* here, it is being done in sctp_pcb_init()
|
||||
*/
|
||||
#if defined (__Userspace_os_Windows)
|
||||
if ((SCTP_BASE_VAR(timer_thread) = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)user_sctp_timer_iterate, NULL, 0, NULL)) == NULL) {
|
||||
SCTP_PRINTF("ERROR; Creating ithread failed\n");
|
||||
}
|
||||
#else
|
||||
int rc;
|
||||
|
||||
rc = pthread_create(&SCTP_BASE_VAR(timer_thread), NULL, user_sctp_timer_iterate, NULL);
|
||||
rc = sctp_userspace_thread_create(&SCTP_BASE_VAR(timer_thread), user_sctp_timer_iterate);
|
||||
if (rc) {
|
||||
SCTP_PRINTF("ERROR; return code from pthread_create() is %d\n", rc);
|
||||
SCTP_PRINTF("ERROR; return code from sctp_thread_create() is %d\n", rc);
|
||||
} else {
|
||||
SCTP_BASE_VAR(timer_thread_started) = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
sctp_stop_timer_thread(void)
|
||||
{
|
||||
atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 0, 1);
|
||||
if (SCTP_BASE_VAR(timer_thread_started)) {
|
||||
#if defined(_WIN32)
|
||||
WaitForSingleObject(SCTP_BASE_VAR(timer_thread), INFINITE);
|
||||
CloseHandle(SCTP_BASE_VAR(timer_thread));
|
||||
#else
|
||||
pthread_join(SCTP_BASE_VAR(timer_thread), NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -28,7 +30,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
@ -51,26 +53,31 @@ __FBSDID("$FreeBSD$");
|
|||
#define SCTP_TICKS_PER_FASTTIMO 20 /* called about every 20ms */
|
||||
|
||||
#if defined(__Userspace__)
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
#define SCTP_TIMERQ_LOCK() EnterCriticalSection(&SCTP_BASE_VAR(timer_mtx))
|
||||
#define SCTP_TIMERQ_UNLOCK() LeaveCriticalSection(&SCTP_BASE_VAR(timer_mtx))
|
||||
#define SCTP_TIMERQ_LOCK_INIT() InitializeCriticalSection(&SCTP_BASE_VAR(timer_mtx))
|
||||
#define SCTP_TIMERQ_LOCK_DESTROY() DeleteCriticalSection(&SCTP_BASE_VAR(timer_mtx))
|
||||
#else
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_TIMERQ_LOCK() KASSERT(pthread_mutex_lock(&SCTP_BASE_VAR(timer_mtx)) == 0, ("%s: timer_mtx already locked", __func__))
|
||||
#define SCTP_TIMERQ_UNLOCK() KASSERT(pthread_mutex_unlock(&SCTP_BASE_VAR(timer_mtx)) == 0, ("%s: timer_mtx not locked", __func__))
|
||||
#else
|
||||
#define SCTP_TIMERQ_LOCK() (void)pthread_mutex_lock(&SCTP_BASE_VAR(timer_mtx))
|
||||
#define SCTP_TIMERQ_UNLOCK() (void)pthread_mutex_unlock(&SCTP_BASE_VAR(timer_mtx))
|
||||
#define SCTP_TIMERQ_LOCK_INIT() (void)pthread_mutex_init(&SCTP_BASE_VAR(timer_mtx), NULL)
|
||||
#endif
|
||||
#define SCTP_TIMERQ_LOCK_INIT() (void)pthread_mutex_init(&SCTP_BASE_VAR(timer_mtx), &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_TIMERQ_LOCK_DESTROY() (void)pthread_mutex_destroy(&SCTP_BASE_VAR(timer_mtx))
|
||||
#endif
|
||||
|
||||
extern int ticks;
|
||||
#endif
|
||||
|
||||
uint32_t sctp_get_tick_count(void);
|
||||
|
||||
TAILQ_HEAD(calloutlist, sctp_callout);
|
||||
|
||||
struct sctp_callout {
|
||||
TAILQ_ENTRY(sctp_callout) tqe;
|
||||
int c_time; /* ticks to the event */
|
||||
uint32_t c_time; /* ticks to the event */
|
||||
void *c_arg; /* function argument */
|
||||
void (*c_func)(void *); /* function to call */
|
||||
int c_flags; /* state of this entry */
|
||||
|
@ -81,10 +88,18 @@ typedef struct sctp_callout sctp_os_timer_t;
|
|||
#define SCTP_CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */
|
||||
|
||||
void sctp_os_timer_init(sctp_os_timer_t *tmr);
|
||||
void sctp_os_timer_start(sctp_os_timer_t *, int, void (*)(void *), void *);
|
||||
/* Returns 1 if pending timer was rescheduled, 0 otherwise. */
|
||||
int sctp_os_timer_start(sctp_os_timer_t *, uint32_t, void (*)(void *), void *);
|
||||
/* Returns 1 if pending timer was stopped, 0 otherwise. */
|
||||
int sctp_os_timer_stop(sctp_os_timer_t *);
|
||||
void sctp_handle_tick(uint32_t);
|
||||
|
||||
#define SCTP_OS_TIMER_INIT sctp_os_timer_init
|
||||
/*
|
||||
* NOTE: The next two shouldn't be called directly outside of sctp_timer_start()
|
||||
* and sctp_timer_stop(), since they don't handle incrementing/decrementing
|
||||
* relevant reference counts.
|
||||
*/
|
||||
#define SCTP_OS_TIMER_START sctp_os_timer_start
|
||||
#define SCTP_OS_TIMER_STOP sctp_os_timer_stop
|
||||
/* MT FIXME: Is the following correct? */
|
||||
|
@ -94,9 +109,10 @@ int sctp_os_timer_stop(sctp_os_timer_t *);
|
|||
#define SCTP_OS_TIMER_DEACTIVATE(tmr) ((tmr)->c_flags &= ~SCTP_CALLOUT_ACTIVE)
|
||||
|
||||
#if defined(__Userspace__)
|
||||
void sctp_start_timer(void);
|
||||
void sctp_start_timer_thread(void);
|
||||
void sctp_stop_timer_thread(void);
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
void sctp_timeout(void *);
|
||||
#endif
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,18 +32,18 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 271204 2014-09-06 19:12:14Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_CONSTANTS_H_
|
||||
#define _NETINET_SCTP_CONSTANTS_H_
|
||||
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32) && defined(__Userspace__)
|
||||
extern void getwintimeofday(struct timeval *tv);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* IANA assigned port number for SCTP over UDP encapsulation */
|
||||
#define SCTP_OVER_UDP_TUNNELING_PORT 9899
|
||||
|
||||
|
@ -71,6 +73,10 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
*/
|
||||
#define SCTP_LARGEST_INIT_ACCEPTED (65535 - 2048)
|
||||
|
||||
/* Largest length of a chunk */
|
||||
#define SCTP_MAX_CHUNK_LENGTH 0xffff
|
||||
/* Largest length of an error cause */
|
||||
#define SCTP_MAX_CAUSE_LENGTH 0xffff
|
||||
/* Number of addresses where we just skip the counting */
|
||||
#define SCTP_COUNT_LIMIT 40
|
||||
|
||||
|
@ -86,22 +92,16 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
/* #define SCTP_AUDITING_ENABLED 1 used for debug/auditing */
|
||||
#define SCTP_AUDIT_SIZE 256
|
||||
|
||||
|
||||
#define SCTP_KTRHEAD_NAME "sctp_iterator"
|
||||
#define SCTP_KTHREAD_PAGES 0
|
||||
|
||||
#define SCTP_MCORE_NAME "sctp_core_worker"
|
||||
|
||||
|
||||
/* If you support Multi-VRF how big to
|
||||
* make the initial array of VRF's to.
|
||||
*/
|
||||
#define SCTP_DEFAULT_VRF_SIZE 4
|
||||
|
||||
/* constants for rto calc */
|
||||
#define sctp_align_safe_nocopy 0
|
||||
#define sctp_align_unsafe_makecopy 1
|
||||
|
||||
/* JRS - Values defined for the HTCP algorithm */
|
||||
#define ALPHA_BASE (1<<7) /* 1.0 with shift << 7 */
|
||||
#define BETA_MIN (1<<6) /* 0.5 with shift << 7 */
|
||||
|
@ -266,7 +266,6 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
|
||||
#define SCTP_LOCK_UNKNOWN 2
|
||||
|
||||
|
||||
/* number of associations by default for zone allocation */
|
||||
#define SCTP_MAX_NUM_OF_ASOC 40000
|
||||
/* how many addresses per assoc remote and local */
|
||||
|
@ -276,7 +275,7 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_DEFAULT_MULTIPLE_ASCONFS 0
|
||||
|
||||
/*
|
||||
* Theshold for rwnd updates, we have to read (sb_hiwat >>
|
||||
* Threshold for rwnd updates, we have to read (sb_hiwat >>
|
||||
* SCTP_RWND_HIWAT_SHIFT) before we will look to see if we need to send a
|
||||
* window update sack. When we look, we compare the last rwnd we sent vs the
|
||||
* current rwnd. It too must be greater than this value. Using 3 divdes the
|
||||
|
@ -346,6 +345,7 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_RTT_FROM_NON_DATA 0
|
||||
#define SCTP_RTT_FROM_DATA 1
|
||||
|
||||
#define PR_SCTP_UNORDERED_FLAG 0x0001
|
||||
|
||||
/* IP hdr (20/40) + 12+2+2 (enet) + sctp common 12 */
|
||||
#define SCTP_FIRST_MBUF_RESV 68
|
||||
|
@ -387,15 +387,14 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
/* align to 32-bit sizes */
|
||||
#define SCTP_SIZE32(x) ((((x) + 3) >> 2) << 2)
|
||||
|
||||
#define IS_SCTP_CONTROL(a) ((a)->chunk_type != SCTP_DATA)
|
||||
#define IS_SCTP_DATA(a) ((a)->chunk_type == SCTP_DATA)
|
||||
|
||||
#define IS_SCTP_CONTROL(a) (((a)->chunk_type != SCTP_DATA) && ((a)->chunk_type != SCTP_IDATA))
|
||||
#define IS_SCTP_DATA(a) (((a)->chunk_type == SCTP_DATA) || ((a)->chunk_type == SCTP_IDATA))
|
||||
|
||||
/* SCTP parameter types */
|
||||
/*************0x0000 series*************/
|
||||
#define SCTP_HEARTBEAT_INFO 0x0001
|
||||
#if defined(__Userspace__)
|
||||
#define SCTP_CONN_ADDRESS 0x0004
|
||||
#define SCTP_CONN_ADDRESS 0x0004
|
||||
#endif
|
||||
#define SCTP_IPV4_ADDRESS 0x0005
|
||||
#define SCTP_IPV6_ADDRESS 0x0006
|
||||
|
@ -405,43 +404,34 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_HOSTNAME_ADDRESS 0x000b
|
||||
#define SCTP_SUPPORTED_ADDRTYPE 0x000c
|
||||
|
||||
/* draft-ietf-stewart-tsvwg-strreset-xxx */
|
||||
/* RFC 6525 */
|
||||
#define SCTP_STR_RESET_OUT_REQUEST 0x000d
|
||||
#define SCTP_STR_RESET_IN_REQUEST 0x000e
|
||||
#define SCTP_STR_RESET_TSN_REQUEST 0x000f
|
||||
#define SCTP_STR_RESET_RESPONSE 0x0010
|
||||
#define SCTP_STR_RESET_ADD_OUT_STREAMS 0x0011
|
||||
#define SCTP_STR_RESET_ADD_IN_STREAMS 0x0012
|
||||
#define SCTP_STR_RESET_ADD_IN_STREAMS 0x0012
|
||||
|
||||
#define SCTP_MAX_RESET_PARAMS 2
|
||||
#define SCTP_STREAM_RESET_TSN_DELTA 0x1000
|
||||
#define SCTP_STREAM_RESET_TSN_DELTA 0x1000
|
||||
|
||||
/*************0x4000 series*************/
|
||||
|
||||
/*************0x8000 series*************/
|
||||
#define SCTP_ECN_CAPABLE 0x8000
|
||||
|
||||
/* draft-ietf-tsvwg-auth-xxx */
|
||||
#define SCTP_ZERO_CHECKSUM_ACCEPTABLE 0x8001
|
||||
/* RFC 4895 */
|
||||
#define SCTP_RANDOM 0x8002
|
||||
#define SCTP_CHUNK_LIST 0x8003
|
||||
#define SCTP_HMAC_LIST 0x8004
|
||||
/*
|
||||
* draft-ietf-tsvwg-addip-sctp-xx param=0x8008 len=0xNNNN Byte | Byte | Byte
|
||||
* | Byte Byte | Byte ...
|
||||
*
|
||||
* Where each byte is a chunk type extension supported. For example, to support
|
||||
* all chunks one would have (in hex):
|
||||
*
|
||||
* 80 01 00 09 C0 C1 80 81 82 00 00 00
|
||||
*
|
||||
* Has the parameter. C0 = PR-SCTP (RFC3758) C1, 80 = ASCONF (addip draft) 81
|
||||
* = Packet Drop 82 = Stream Reset 83 = Authentication
|
||||
*/
|
||||
#define SCTP_SUPPORTED_CHUNK_EXT 0x8008
|
||||
/* RFC 4820 */
|
||||
#define SCTP_PAD 0x8005
|
||||
/* RFC 5061 */
|
||||
#define SCTP_SUPPORTED_CHUNK_EXT 0x8008
|
||||
|
||||
/*************0xC000 series*************/
|
||||
#define SCTP_PRSCTP_SUPPORTED 0xc000
|
||||
/* draft-ietf-tsvwg-addip-sctp */
|
||||
/* RFC 5061 */
|
||||
#define SCTP_ADD_IP_ADDRESS 0xc001
|
||||
#define SCTP_DEL_IP_ADDRESS 0xc002
|
||||
#define SCTP_ERROR_CAUSE_IND 0xc003
|
||||
|
@ -449,8 +439,8 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_SUCCESS_REPORT 0xc005
|
||||
#define SCTP_ULP_ADAPTATION 0xc006
|
||||
/* behave-nat-draft */
|
||||
#define SCTP_HAS_NAT_SUPPORT 0xc007
|
||||
#define SCTP_NAT_VTAGS 0xc008
|
||||
#define SCTP_HAS_NAT_SUPPORT 0xc007
|
||||
#define SCTP_NAT_VTAGS 0xc008
|
||||
|
||||
/* bits for TOS field */
|
||||
#define SCTP_ECT0_BIT 0x02
|
||||
|
@ -464,9 +454,8 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
/* mask to get sticky */
|
||||
#define SCTP_STICKY_OPTIONS_MASK 0x0c
|
||||
|
||||
|
||||
/*
|
||||
* SCTP states for internal state machine XXX (should match "user" values)
|
||||
* SCTP states for internal state machine
|
||||
*/
|
||||
#define SCTP_STATE_EMPTY 0x0000
|
||||
#define SCTP_STATE_INUSE 0x0001
|
||||
|
@ -484,10 +473,14 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_STATE_IN_ACCEPT_QUEUE 0x1000
|
||||
#define SCTP_STATE_MASK 0x007f
|
||||
|
||||
#define SCTP_GET_STATE(asoc) ((asoc)->state & SCTP_STATE_MASK)
|
||||
#define SCTP_SET_STATE(asoc, newstate) ((asoc)->state = ((asoc)->state & ~SCTP_STATE_MASK) | newstate)
|
||||
#define SCTP_CLEAR_SUBSTATE(asoc, substate) ((asoc)->state &= ~substate)
|
||||
#define SCTP_ADD_SUBSTATE(asoc, substate) ((asoc)->state |= substate)
|
||||
#define SCTP_GET_STATE(_stcb) \
|
||||
((_stcb)->asoc.state & SCTP_STATE_MASK)
|
||||
#define SCTP_SET_STATE(_stcb, _state) \
|
||||
sctp_set_state(_stcb, _state)
|
||||
#define SCTP_CLEAR_SUBSTATE(_stcb, _substate) \
|
||||
(_stcb)->asoc.state &= ~(_substate)
|
||||
#define SCTP_ADD_SUBSTATE(_stcb, _substate) \
|
||||
sctp_add_substate(_stcb, _substate)
|
||||
|
||||
/* SCTP reachability state for each address */
|
||||
#define SCTP_ADDR_REACHABLE 0x001
|
||||
|
@ -517,7 +510,7 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
/* Maximum the mapping array will grow to (TSN mapping array) */
|
||||
#define SCTP_MAPPING_ARRAY 512
|
||||
|
||||
/* size of the inital malloc on the mapping array */
|
||||
/* size of the initial malloc on the mapping array */
|
||||
#define SCTP_INITIAL_MAPPING_ARRAY 16
|
||||
/* how much we grow the mapping array each call */
|
||||
#define SCTP_MAPPING_ARRAY_INCR 32
|
||||
|
@ -553,26 +546,22 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_TIMER_TYPE_ASCONF 10
|
||||
#define SCTP_TIMER_TYPE_SHUTDOWNGUARD 11
|
||||
#define SCTP_TIMER_TYPE_AUTOCLOSE 12
|
||||
#define SCTP_TIMER_TYPE_EVENTWAKE 13
|
||||
#define SCTP_TIMER_TYPE_STRRESET 14
|
||||
#define SCTP_TIMER_TYPE_INPKILL 15
|
||||
#define SCTP_TIMER_TYPE_ASOCKILL 16
|
||||
#define SCTP_TIMER_TYPE_ADDR_WQ 17
|
||||
#define SCTP_TIMER_TYPE_ZERO_COPY 18
|
||||
#define SCTP_TIMER_TYPE_ZCOPY_SENDQ 19
|
||||
#define SCTP_TIMER_TYPE_PRIM_DELETED 20
|
||||
#define SCTP_TIMER_TYPE_STRRESET 13
|
||||
#define SCTP_TIMER_TYPE_INPKILL 14
|
||||
#define SCTP_TIMER_TYPE_ASOCKILL 15
|
||||
#define SCTP_TIMER_TYPE_ADDR_WQ 16
|
||||
#define SCTP_TIMER_TYPE_PRIM_DELETED 17
|
||||
/* add new timers here - and increment LAST */
|
||||
#define SCTP_TIMER_TYPE_LAST 21
|
||||
#define SCTP_TIMER_TYPE_LAST 18
|
||||
|
||||
#define SCTP_IS_TIMER_TYPE_VALID(t) (((t) > SCTP_TIMER_TYPE_NONE) && \
|
||||
((t) < SCTP_TIMER_TYPE_LAST))
|
||||
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
/* Number of ticks to run the main timer at in msec */
|
||||
#define SCTP_MAIN_TIMER_DEFAULT 10
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* max number of TSN's dup'd that I will hold */
|
||||
#define SCTP_MAX_DUP_TSNS 20
|
||||
|
||||
|
@ -591,22 +580,7 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
* number of clusters as a base. This way high bandwidth environments will
|
||||
* not get impacted by the lower bandwidth sending a bunch of 1 byte chunks
|
||||
*/
|
||||
#ifdef __Panda__
|
||||
#define SCTP_ASOC_MAX_CHUNKS_ON_QUEUE 10240
|
||||
#else
|
||||
#define SCTP_ASOC_MAX_CHUNKS_ON_QUEUE 512
|
||||
#endif
|
||||
|
||||
|
||||
/* The conversion from time to ticks and vice versa is done by rounding
|
||||
* upwards. This way we can test in the code the time to be positive and
|
||||
* know that this corresponds to a positive number of ticks.
|
||||
*/
|
||||
#define MSEC_TO_TICKS(x) ((hz == 1000) ? x : ((((x) * hz) + 999) / 1000))
|
||||
#define TICKS_TO_MSEC(x) ((hz == 1000) ? x : ((((x) * 1000) + (hz - 1)) / hz))
|
||||
|
||||
#define SEC_TO_TICKS(x) ((x) * hz)
|
||||
#define TICKS_TO_SEC(x) (((x) + (hz - 1)) / hz)
|
||||
|
||||
/*
|
||||
* Basically the minimum amount of time before I do a early FR. Making this
|
||||
|
@ -628,10 +602,6 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
/* 30 seconds + RTO (in ms) */
|
||||
#define SCTP_HB_DEFAULT_MSEC 30000
|
||||
|
||||
/* Max time I will wait for Shutdown to complete */
|
||||
#define SCTP_DEF_MAX_SHUTDOWN_SEC 180
|
||||
|
||||
|
||||
/*
|
||||
* This is how long a secret lives, NOT how long a cookie lives how many
|
||||
* ticks the current secret will live.
|
||||
|
@ -640,8 +610,7 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
|
||||
#define SCTP_RTO_UPPER_BOUND (60000) /* 60 sec in ms */
|
||||
#define SCTP_RTO_LOWER_BOUND (1000) /* 1 sec is ms */
|
||||
#define SCTP_RTO_INITIAL (3000) /* 3 sec in ms */
|
||||
|
||||
#define SCTP_RTO_INITIAL (1000) /* 1 sec in ms */
|
||||
|
||||
#define SCTP_INP_KILL_TIMEOUT 20 /* number of ms to retry kill of inpcb */
|
||||
#define SCTP_ASOC_KILL_TIMEOUT 10 /* number of ms to retry kill of inpcb */
|
||||
|
@ -653,8 +622,7 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
|
||||
#define SCTP_DEF_PMTU_RAISE_SEC 600 /* 10 min between raise attempts */
|
||||
|
||||
|
||||
/* How many streams I request initally by default */
|
||||
/* How many streams I request initially by default */
|
||||
#define SCTP_OSTREAM_INITIAL 10
|
||||
#define SCTP_ISTREAM_INITIAL 2048
|
||||
|
||||
|
@ -723,8 +691,6 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
/* amount peer is obligated to have in rwnd or I will abort */
|
||||
#define SCTP_MIN_RWND 1500
|
||||
|
||||
#define SCTP_DEFAULT_MAXSEGMENT 65535
|
||||
|
||||
#define SCTP_CHUNK_BUFFER_SIZE 512
|
||||
#define SCTP_PARAM_BUFFER_SIZE 512
|
||||
|
||||
|
@ -736,7 +702,6 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_NUMBER_OF_SECRETS 8 /* or 8 * 4 = 32 octets */
|
||||
#define SCTP_SECRET_SIZE 32 /* number of octets in a 256 bits */
|
||||
|
||||
|
||||
/*
|
||||
* SCTP upper layer notifications
|
||||
*/
|
||||
|
@ -767,6 +732,7 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_NOTIFY_NO_PEER_AUTH 25
|
||||
#define SCTP_NOTIFY_SENDER_DRY 26
|
||||
#define SCTP_NOTIFY_REMOTE_ERROR 27
|
||||
#define SCTP_NOTIFY_ASSOC_TIMEDOUT 28
|
||||
|
||||
/* This is the value for messages that are NOT completely
|
||||
* copied down where we will start to split the message.
|
||||
|
@ -777,7 +743,11 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_DEFAULT_SPLIT_POINT_MIN 2904
|
||||
|
||||
/* Maximum length of diagnostic information in error causes */
|
||||
#define SCTP_DIAG_INFO_LEN 64
|
||||
#if defined(__Userspace__)
|
||||
#define SCTP_DIAG_INFO_LEN 256
|
||||
#else
|
||||
#define SCTP_DIAG_INFO_LEN 128
|
||||
#endif
|
||||
|
||||
/* ABORT CODES and other tell-tale location
|
||||
* codes are generated by adding the below
|
||||
|
@ -785,18 +755,18 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
*/
|
||||
|
||||
/* File defines */
|
||||
#define SCTP_FROM_SCTP_INPUT 0x10000000
|
||||
#define SCTP_FROM_SCTP_PCB 0x20000000
|
||||
#define SCTP_FROM_SCTP_INDATA 0x30000000
|
||||
#define SCTP_FROM_SCTP_TIMER 0x40000000
|
||||
#define SCTP_FROM_SCTP_USRREQ 0x50000000
|
||||
#define SCTP_FROM_SCTPUTIL 0x60000000
|
||||
#define SCTP_FROM_SCTP6_USRREQ 0x70000000
|
||||
#define SCTP_FROM_SCTP_ASCONF 0x80000000
|
||||
#define SCTP_FROM_SCTP_OUTPUT 0x90000000
|
||||
#define SCTP_FROM_SCTP_PEELOFF 0xa0000000
|
||||
#define SCTP_FROM_SCTP_PANDA 0xb0000000
|
||||
#define SCTP_FROM_SCTP_SYSCTL 0xc0000000
|
||||
#define SCTP_FROM_SCTP_INPUT 0x10000000
|
||||
#define SCTP_FROM_SCTP_PCB 0x20000000
|
||||
#define SCTP_FROM_SCTP_INDATA 0x30000000
|
||||
#define SCTP_FROM_SCTP_TIMER 0x40000000
|
||||
#define SCTP_FROM_SCTP_USRREQ 0x50000000
|
||||
#define SCTP_FROM_SCTPUTIL 0x60000000
|
||||
#define SCTP_FROM_SCTP6_USRREQ 0x70000000
|
||||
#define SCTP_FROM_SCTP_ASCONF 0x80000000
|
||||
#define SCTP_FROM_SCTP_OUTPUT 0x90000000
|
||||
#define SCTP_FROM_SCTP_PEELOFF 0xa0000000
|
||||
#define SCTP_FROM_SCTP_SYSCTL 0xb0000000
|
||||
#define SCTP_FROM_SCTP_CC_FUNCTIONS 0xc0000000
|
||||
|
||||
/* Location ID's */
|
||||
#define SCTP_LOC_1 0x00000001
|
||||
|
@ -832,7 +802,10 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_LOC_31 0x0000001f
|
||||
#define SCTP_LOC_32 0x00000020
|
||||
#define SCTP_LOC_33 0x00000021
|
||||
|
||||
#define SCTP_LOC_34 0x00000022
|
||||
#define SCTP_LOC_35 0x00000023
|
||||
#define SCTP_LOC_36 0x00000024
|
||||
#define SCTP_LOC_37 0x00000025
|
||||
|
||||
/* Free assoc codes */
|
||||
#define SCTP_NORMAL_PROC 0
|
||||
|
@ -852,7 +825,6 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_DONOT_SETSCOPE 0
|
||||
#define SCTP_DO_SETSCOPE 1
|
||||
|
||||
|
||||
/* This value determines the default for when
|
||||
* we try to add more on the send queue., if
|
||||
* there is room. This prevents us from cycling
|
||||
|
@ -879,7 +851,7 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_CHUNKQUEUE_SCALE 10
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
/* clock variance is 1 ms */
|
||||
#define SCTP_CLOCK_GRANULARITY 1
|
||||
#else
|
||||
|
@ -908,12 +880,20 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
|
||||
/* modular comparison */
|
||||
/* See RFC 1982 for details. */
|
||||
#define SCTP_SSN_GT(a, b) (((a < b) && ((uint16_t)(b - a) > (1U<<15))) || \
|
||||
((a > b) && ((uint16_t)(a - b) < (1U<<15))))
|
||||
#define SCTP_SSN_GE(a, b) (SCTP_SSN_GT(a, b) || (a == b))
|
||||
#define SCTP_TSN_GT(a, b) (((a < b) && ((uint32_t)(b - a) > (1U<<31))) || \
|
||||
((a > b) && ((uint32_t)(a - b) < (1U<<31))))
|
||||
#define SCTP_TSN_GE(a, b) (SCTP_TSN_GT(a, b) || (a == b))
|
||||
#define SCTP_UINT16_GT(a, b) (((a < b) && ((uint16_t)(b - a) > (1U<<15))) || \
|
||||
((a > b) && ((uint16_t)(a - b) < (1U<<15))))
|
||||
#define SCTP_UINT16_GE(a, b) (SCTP_UINT16_GT(a, b) || (a == b))
|
||||
#define SCTP_UINT32_GT(a, b) (((a < b) && ((uint32_t)(b - a) > (1U<<31))) || \
|
||||
((a > b) && ((uint32_t)(a - b) < (1U<<31))))
|
||||
#define SCTP_UINT32_GE(a, b) (SCTP_UINT32_GT(a, b) || (a == b))
|
||||
|
||||
#define SCTP_SSN_GT(a, b) SCTP_UINT16_GT(a, b)
|
||||
#define SCTP_SSN_GE(a, b) SCTP_UINT16_GE(a, b)
|
||||
#define SCTP_TSN_GT(a, b) SCTP_UINT32_GT(a, b)
|
||||
#define SCTP_TSN_GE(a, b) SCTP_UINT32_GE(a, b)
|
||||
#define SCTP_MID_GT(i, a, b) (((i) == 1) ? SCTP_UINT32_GT(a, b) : SCTP_UINT16_GT((uint16_t)a, (uint16_t)b))
|
||||
#define SCTP_MID_GE(i, a, b) (((i) == 1) ? SCTP_UINT32_GE(a, b) : SCTP_UINT16_GE((uint16_t)a, (uint16_t)b))
|
||||
#define SCTP_MID_EQ(i, a, b) (((i) == 1) ? a == b : (uint16_t)a == (uint16_t)b)
|
||||
|
||||
/* Mapping array manipulation routines */
|
||||
#define SCTP_IS_TSN_PRESENT(arry, gap) ((arry[(gap >> 3)] >> (gap & 0x07)) & 0x01)
|
||||
|
@ -927,7 +907,6 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define SCTP_RETRAN_DONE -1
|
||||
#define SCTP_RETRAN_EXIT -2
|
||||
|
||||
|
@ -936,7 +915,7 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
* element. Each entry will take 2 4 byte ints (and of course the overhead
|
||||
* of the next pointer as well). Using 15 as an example will yield * ((8 *
|
||||
* 15) + 8) or 128 bytes of overhead for each timewait block that gets
|
||||
* initialized. Increasing it to 31 would yeild 256 bytes per block.
|
||||
* initialized. Increasing it to 31 would yield 256 bytes per block.
|
||||
*/
|
||||
#define SCTP_NUMBER_IN_VTAG_BLOCK 15
|
||||
/*
|
||||
|
@ -978,15 +957,11 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
|
||||
/*-
|
||||
* defines for socket lock states.
|
||||
* Used by __APPLE__ and SCTP_SO_LOCK_TESTING
|
||||
* Used by __APPLE__
|
||||
*/
|
||||
#define SCTP_SO_LOCKED 1
|
||||
#define SCTP_SO_NOT_LOCKED 0
|
||||
|
||||
|
||||
#define SCTP_HOLDS_LOCK 1
|
||||
#define SCTP_NOT_LOCKED 0
|
||||
|
||||
/*-
|
||||
* For address locks, do we hold the lock?
|
||||
*/
|
||||
|
@ -1002,17 +977,17 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
(((uint8_t *)&(a)->s_addr)[1] == 168)))
|
||||
|
||||
#define IN4_ISLOOPBACK_ADDRESS(a) \
|
||||
((((uint8_t *)&(a)->s_addr)[0] == 127) && \
|
||||
(((uint8_t *)&(a)->s_addr)[1] == 0) && \
|
||||
(((uint8_t *)&(a)->s_addr)[2] == 0) && \
|
||||
(((uint8_t *)&(a)->s_addr)[3] == 1))
|
||||
(((uint8_t *)&(a)->s_addr)[0] == 127)
|
||||
|
||||
#define IN4_ISLINKLOCAL_ADDRESS(a) \
|
||||
((((uint8_t *)&(a)->s_addr)[0] == 169) && \
|
||||
(((uint8_t *)&(a)->s_addr)[1] == 254))
|
||||
|
||||
/* Maximum size of optval for IPPROTO_SCTP level socket options. */
|
||||
#define SCTP_SOCKET_OPTION_LIMIT (64 * 1024)
|
||||
|
||||
#if defined(__Userspace__)
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
#define SCTP_GETTIME_TIMEVAL(x) getwintimeofday(x)
|
||||
#define SCTP_GETPTIME_TIMEVAL(x) getwintimeofday(x) /* this doesn't seem to ever be used.. */
|
||||
#else
|
||||
|
@ -1020,7 +995,6 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define SCTP_GETPTIME_TIMEVAL(x) gettimeofday(x, NULL)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_KERNEL)
|
||||
#define SCTP_GETTIME_TIMEVAL(x) (getmicrouptime(x))
|
||||
#define SCTP_GETPTIME_TIMEVAL(x) (microuptime(x))
|
||||
|
@ -1030,18 +1004,18 @@ extern void getwintimeofday(struct timeval *tv);
|
|||
#define sctp_sowwakeup(inp, so) \
|
||||
do { \
|
||||
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
|
||||
inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \
|
||||
sctp_pcb_add_flags(inp, SCTP_PCB_FLAGS_WAKEOUTPUT); \
|
||||
} else { \
|
||||
sowwakeup(so); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__)
|
||||
#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
|
||||
#define sctp_sowwakeup_locked(inp, so) \
|
||||
do { \
|
||||
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
|
||||
SOCKBUF_UNLOCK(&((so)->so_snd)); \
|
||||
inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \
|
||||
sctp_pcb_add_flags(inp, SCTP_PCB_FLAGS_WAKEOUTPUT); \
|
||||
SOCKBUF_UNLOCK(&((so)->so_snd)); \
|
||||
} else { \
|
||||
sowwakeup_locked(so); \
|
||||
} \
|
||||
|
@ -1050,8 +1024,8 @@ do { \
|
|||
#define sctp_sowwakeup_locked(inp, so) \
|
||||
do { \
|
||||
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
|
||||
SOCKBUF_UNLOCK(&((so)->so_snd)); \
|
||||
inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \
|
||||
sctp_pcb_add_flags(inp, SCTP_PCB_FLAGS_WAKEOUTPUT); \
|
||||
SOCKBUF_UNLOCK(&((so)->so_snd)); \
|
||||
} else { \
|
||||
sowwakeup(so); \
|
||||
} \
|
||||
|
@ -1061,18 +1035,18 @@ do { \
|
|||
#define sctp_sorwakeup(inp, so) \
|
||||
do { \
|
||||
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
|
||||
inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \
|
||||
sctp_pcb_add_flags(inp, SCTP_PCB_FLAGS_WAKEINPUT); \
|
||||
} else { \
|
||||
sorwakeup(so); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__)
|
||||
#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
|
||||
#define sctp_sorwakeup_locked(inp, so) \
|
||||
do { \
|
||||
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
|
||||
inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \
|
||||
SOCKBUF_UNLOCK(&((so)->so_rcv)); \
|
||||
sctp_pcb_add_flags(inp, SCTP_PCB_FLAGS_WAKEINPUT); \
|
||||
SOCKBUF_UNLOCK(&((so)->so_rcv)); \
|
||||
} else { \
|
||||
sorwakeup_locked(so); \
|
||||
} \
|
||||
|
@ -1082,8 +1056,8 @@ do { \
|
|||
#define sctp_sorwakeup_locked(inp, so) \
|
||||
do { \
|
||||
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
|
||||
inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \
|
||||
SOCKBUF_UNLOCK(&((so)->so_rcv)); \
|
||||
sctp_pcb_add_flags(inp, SCTP_PCB_FLAGS_WAKEINPUT); \
|
||||
SOCKBUF_UNLOCK(&((so)->so_rcv)); \
|
||||
} else { \
|
||||
sorwakeup(so); \
|
||||
} \
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,20 +32,31 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 235828 2012-05-23 11:26:28Z tuexen $");
|
||||
#endif
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_sctp.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/gsb_crc32.h>
|
||||
#include <sys/mbuf.h>
|
||||
|
||||
#include <netinet/sctp.h>
|
||||
#include <netinet/sctp_crc32.h>
|
||||
#if defined(SCTP) || defined(SCTP_SUPPORT)
|
||||
#include <netinet/sctp_os.h>
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#endif
|
||||
#else
|
||||
#include <netinet/sctp_os.h>
|
||||
#include <netinet/sctp.h>
|
||||
#include <netinet/sctp_crc32.h>
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(SCTP_WITH_NO_CSUM)
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 800000
|
||||
#else
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
/**
|
||||
*
|
||||
* Routine Description:
|
||||
|
@ -94,7 +107,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 235828 2012-05-23 11:26:28Z tu
|
|||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static uint32_t sctp_crc_tableil8_o32[256] =
|
||||
static const uint32_t sctp_crc_tableil8_o32[256] =
|
||||
{
|
||||
0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, 0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB,
|
||||
0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B, 0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24,
|
||||
|
@ -150,7 +163,7 @@ static uint32_t sctp_crc_tableil8_o32[256] =
|
|||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static uint32_t sctp_crc_tableil8_o40[256] =
|
||||
static const uint32_t sctp_crc_tableil8_o40[256] =
|
||||
{
|
||||
0x00000000, 0x13A29877, 0x274530EE, 0x34E7A899, 0x4E8A61DC, 0x5D28F9AB, 0x69CF5132, 0x7A6DC945,
|
||||
0x9D14C3B8, 0x8EB65BCF, 0xBA51F356, 0xA9F36B21, 0xD39EA264, 0xC03C3A13, 0xF4DB928A, 0xE7790AFD,
|
||||
|
@ -206,7 +219,7 @@ static uint32_t sctp_crc_tableil8_o40[256] =
|
|||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static uint32_t sctp_crc_tableil8_o48[256] =
|
||||
static const uint32_t sctp_crc_tableil8_o48[256] =
|
||||
{
|
||||
0x00000000, 0xA541927E, 0x4F6F520D, 0xEA2EC073, 0x9EDEA41A, 0x3B9F3664, 0xD1B1F617, 0x74F06469,
|
||||
0x38513EC5, 0x9D10ACBB, 0x773E6CC8, 0xD27FFEB6, 0xA68F9ADF, 0x03CE08A1, 0xE9E0C8D2, 0x4CA15AAC,
|
||||
|
@ -262,7 +275,7 @@ static uint32_t sctp_crc_tableil8_o48[256] =
|
|||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static uint32_t sctp_crc_tableil8_o56[256] =
|
||||
static const uint32_t sctp_crc_tableil8_o56[256] =
|
||||
{
|
||||
0x00000000, 0xDD45AAB8, 0xBF672381, 0x62228939, 0x7B2231F3, 0xA6679B4B, 0xC4451272, 0x1900B8CA,
|
||||
0xF64463E6, 0x2B01C95E, 0x49234067, 0x9466EADF, 0x8D665215, 0x5023F8AD, 0x32017194, 0xEF44DB2C,
|
||||
|
@ -318,7 +331,7 @@ static uint32_t sctp_crc_tableil8_o56[256] =
|
|||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static uint32_t sctp_crc_tableil8_o64[256] =
|
||||
static const uint32_t sctp_crc_tableil8_o64[256] =
|
||||
{
|
||||
0x00000000, 0x38116FAC, 0x7022DF58, 0x4833B0F4, 0xE045BEB0, 0xD854D11C, 0x906761E8, 0xA8760E44,
|
||||
0xC5670B91, 0xFD76643D, 0xB545D4C9, 0x8D54BB65, 0x2522B521, 0x1D33DA8D, 0x55006A79, 0x6D1105D5,
|
||||
|
@ -374,7 +387,7 @@ static uint32_t sctp_crc_tableil8_o64[256] =
|
|||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
uint32_t sctp_crc_tableil8_o72[256] =
|
||||
static const uint32_t sctp_crc_tableil8_o72[256] =
|
||||
{
|
||||
0x00000000, 0xEF306B19, 0xDB8CA0C3, 0x34BCCBDA, 0xB2F53777, 0x5DC55C6E, 0x697997B4, 0x8649FCAD,
|
||||
0x6006181F, 0x8F367306, 0xBB8AB8DC, 0x54BAD3C5, 0xD2F32F68, 0x3DC34471, 0x097F8FAB, 0xE64FE4B2,
|
||||
|
@ -430,7 +443,7 @@ uint32_t sctp_crc_tableil8_o72[256] =
|
|||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static uint32_t sctp_crc_tableil8_o80[256] =
|
||||
static const uint32_t sctp_crc_tableil8_o80[256] =
|
||||
{
|
||||
0x00000000, 0x68032CC8, 0xD0065990, 0xB8057558, 0xA5E0C5D1, 0xCDE3E919, 0x75E69C41, 0x1DE5B089,
|
||||
0x4E2DFD53, 0x262ED19B, 0x9E2BA4C3, 0xF628880B, 0xEBCD3882, 0x83CE144A, 0x3BCB6112, 0x53C84DDA,
|
||||
|
@ -486,7 +499,7 @@ static uint32_t sctp_crc_tableil8_o80[256] =
|
|||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static uint32_t sctp_crc_tableil8_o88[256] =
|
||||
static const uint32_t sctp_crc_tableil8_o88[256] =
|
||||
{
|
||||
0x00000000, 0x493C7D27, 0x9278FA4E, 0xDB448769, 0x211D826D, 0x6821FF4A, 0xB3657823, 0xFA590504,
|
||||
0x423B04DA, 0x0B0779FD, 0xD043FE94, 0x997F83B3, 0x632686B7, 0x2A1AFB90, 0xF15E7CF9, 0xB86201DE,
|
||||
|
@ -613,7 +626,7 @@ multitable_crc32c(uint32_t crc32c,
|
|||
return (sctp_crc32c_sb8_64_bit(crc32c, buffer, length, to_even_word));
|
||||
}
|
||||
|
||||
static uint32_t sctp_crc_c[256] = {
|
||||
static const uint32_t sctp_crc_c[256] = {
|
||||
0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4,
|
||||
0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB,
|
||||
0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B,
|
||||
|
@ -696,8 +709,11 @@ singletable_crc32c(uint32_t crc32c,
|
|||
return (crc32c);
|
||||
}
|
||||
|
||||
|
||||
#if defined(__Userspace__)
|
||||
uint32_t
|
||||
#else
|
||||
static uint32_t
|
||||
#endif
|
||||
calculate_crc32c(uint32_t crc32c,
|
||||
const unsigned char *buffer,
|
||||
unsigned int length)
|
||||
|
@ -708,92 +724,79 @@ calculate_crc32c(uint32_t crc32c,
|
|||
return (multitable_crc32c(crc32c, buffer, length));
|
||||
}
|
||||
}
|
||||
#endif /* FreeBSD < 80000 || other OS */
|
||||
|
||||
#endif
|
||||
#if defined(__Userspace__)
|
||||
uint32_t
|
||||
#else
|
||||
static uint32_t
|
||||
#endif
|
||||
sctp_finalize_crc32c(uint32_t crc32c)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
uint8_t byte0, byte1, byte2, byte3;
|
||||
|
||||
uint32_t byte0, byte1, byte2, byte3;
|
||||
#endif
|
||||
/* Complement the result */
|
||||
result = ~crc32c;
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
/*
|
||||
* For BIG-ENDIAN.. aka Motorola byte order the result is in
|
||||
* little-endian form. So we must manually swap the bytes. Then we
|
||||
* can call htonl() which does nothing...
|
||||
* For BIG-ENDIAN platforms, the result is in LITTLE-ENDIAN byte order.
|
||||
* For LITTLE-ENDIAN platforms, the result is in in BIG-ENDIAN byte
|
||||
* order. So for BIG-ENDIAN platforms the bytes must be swapped to
|
||||
* return the result always in network byte order (aka BIG-ENDIAN).
|
||||
*/
|
||||
byte0 = result & 0x000000ff;
|
||||
byte1 = (result >> 8) & 0x000000ff;
|
||||
byte2 = (result >> 16) & 0x000000ff;
|
||||
byte3 = (result >> 24) & 0x000000ff;
|
||||
byte0 = crc32c & 0x000000ff;
|
||||
byte1 = (crc32c >> 8) & 0x000000ff;
|
||||
byte2 = (crc32c >> 16) & 0x000000ff;
|
||||
byte3 = (crc32c >> 24) & 0x000000ff;
|
||||
crc32c = ((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3);
|
||||
#else
|
||||
/*
|
||||
* For INTEL platforms the result comes out in network order. No
|
||||
* htonl is required or the swap above. So we optimize out both the
|
||||
* htonl and the manual swap above.
|
||||
*/
|
||||
crc32c = result;
|
||||
#endif
|
||||
return (crc32c);
|
||||
return (~crc32c);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
sctp_calculate_cksum(struct mbuf *m, uint32_t offset)
|
||||
static int
|
||||
sctp_calculate_cksum_cb(void *arg, void *data, u_int len)
|
||||
{
|
||||
/*
|
||||
* given a mbuf chain with a packetheader offset by 'offset'
|
||||
* pointing at a sctphdr (with csum set to 0) go through the chain
|
||||
* of SCTP_BUF_NEXT()'s and calculate the SCTP checksum. This also
|
||||
* has a side bonus as it will calculate the total length of the
|
||||
* mbuf chain. Note: if offset is greater than the total mbuf
|
||||
* length, checksum=1, pktlen=0 is returned (ie. no real error code)
|
||||
*/
|
||||
uint32_t base = 0xffffffff;
|
||||
struct mbuf *at;
|
||||
uint32_t *basep;
|
||||
|
||||
at = m;
|
||||
/* find the correct mbuf and offset into mbuf */
|
||||
while ((at != NULL) && (offset > (uint32_t) SCTP_BUF_LEN(at))) {
|
||||
offset -= SCTP_BUF_LEN(at); /* update remaining offset
|
||||
* left */
|
||||
at = SCTP_BUF_NEXT(at);
|
||||
}
|
||||
while (at != NULL) {
|
||||
if ((SCTP_BUF_LEN(at) - offset) > 0) {
|
||||
base = calculate_crc32c(base,
|
||||
(unsigned char *)(SCTP_BUF_AT(at, offset)),
|
||||
(unsigned int)(SCTP_BUF_LEN(at) - offset));
|
||||
}
|
||||
if (offset) {
|
||||
/* we only offset once into the first mbuf */
|
||||
if (offset < (uint32_t) SCTP_BUF_LEN(at))
|
||||
offset = 0;
|
||||
else
|
||||
offset -= SCTP_BUF_LEN(at);
|
||||
}
|
||||
at = SCTP_BUF_NEXT(at);
|
||||
}
|
||||
base = sctp_finalize_crc32c(base);
|
||||
return (base);
|
||||
basep = arg;
|
||||
*basep = calculate_crc32c(*basep, data, len);
|
||||
return (0);
|
||||
}
|
||||
#endif /* !defined(SCTP_WITH_NO_CSUM) */
|
||||
|
||||
/*
|
||||
* Compute the SCTP checksum in network byte order for a given mbuf chain m
|
||||
* which contains an SCTP packet starting at offset.
|
||||
* Since this function is also called by ipfw, don't assume that
|
||||
* it is compiled on a kernel with SCTP support.
|
||||
*/
|
||||
uint32_t
|
||||
sctp_calculate_cksum(struct mbuf *m, int32_t offset)
|
||||
{
|
||||
uint32_t base;
|
||||
int len;
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
M_ASSERTPKTHDR(m);
|
||||
KASSERT(offset < m->m_pkthdr.len,
|
||||
("%s: invalid offset %u into mbuf %p", __func__, offset, m));
|
||||
|
||||
base = 0xffffffff;
|
||||
len = m->m_pkthdr.len - offset;
|
||||
(void)m_apply(m, offset, len, sctp_calculate_cksum_cb, &base);
|
||||
return (sctp_finalize_crc32c(base));
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#if defined(SCTP) || defined(SCTP_SUPPORT)
|
||||
|
||||
VNET_DEFINE(struct sctp_base_info, system_base_info);
|
||||
|
||||
/*
|
||||
* Compute and insert the SCTP checksum in network byte order for a given
|
||||
* mbuf chain m which contains an SCTP packet starting at offset.
|
||||
*/
|
||||
void
|
||||
sctp_delayed_cksum(struct mbuf *m, uint32_t offset)
|
||||
{
|
||||
#if defined(SCTP_WITH_NO_CSUM)
|
||||
#ifdef INVARIANTS
|
||||
panic("sctp_delayed_cksum() called when using no SCTP CRC.");
|
||||
#endif
|
||||
#else
|
||||
uint32_t checksum;
|
||||
|
||||
checksum = sctp_calculate_cksum(m, offset);
|
||||
|
@ -801,18 +804,18 @@ sctp_delayed_cksum(struct mbuf *m, uint32_t offset)
|
|||
SCTP_STAT_INCR(sctps_sendswcrc);
|
||||
offset += offsetof(struct sctphdr, checksum);
|
||||
|
||||
if (offset + sizeof(uint32_t) > (uint32_t) (m->m_len)) {
|
||||
SCTP_PRINTF("sctp_delayed_cksum(): m->len: %d, off: %d.\n",
|
||||
(uint32_t) m->m_len, offset);
|
||||
/*
|
||||
* XXX this shouldn't happen, but if it does, the correct
|
||||
* behavior may be to insert the checksum in the appropriate
|
||||
* next mbuf in the chain.
|
||||
*/
|
||||
if (offset + sizeof(uint32_t) > (uint32_t)(m->m_pkthdr.len)) {
|
||||
#ifdef INVARIANTS
|
||||
panic("sctp_delayed_cksum(): m->m_pkthdr.len: %d, offset: %u.",
|
||||
m->m_pkthdr.len, offset);
|
||||
#else
|
||||
SCTP_PRINTF("sctp_delayed_cksum(): m->m_pkthdr.len: %d, offset: %u.\n",
|
||||
m->m_pkthdr.len, offset);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
*(uint32_t *) (m->m_data + offset) = checksum;
|
||||
#endif
|
||||
m_copyback(m, (int)offset, (int)sizeof(uint32_t), (caddr_t)&checksum);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,25 +32,25 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.h 235828 2012-05-23 11:26:28Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_CRC32_H_
|
||||
#define _NETINET_SCTP_CRC32_H_
|
||||
|
||||
#if defined(_KERNEL)
|
||||
#if !defined(SCTP_WITH_NO_CSUM)
|
||||
uint32_t sctp_calculate_cksum(struct mbuf *, uint32_t);
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
uint32_t sctp_calculate_cksum(struct mbuf *, int32_t);
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#if defined(SCTP) || defined(SCTP_SUPPORT)
|
||||
void sctp_delayed_cksum(struct mbuf *, uint32_t offset);
|
||||
#endif
|
||||
#endif
|
||||
#endif /* _KERNEL */
|
||||
#if defined(__Userspace__)
|
||||
#if !defined(SCTP_WITH_NO_CSUM)
|
||||
uint32_t sctp_calculate_cksum(struct mbuf *, uint32_t);
|
||||
#endif
|
||||
uint32_t calculate_crc32c(uint32_t, const unsigned char *, unsigned int);
|
||||
uint32_t sctp_finalize_crc32c(uint32_t);
|
||||
uint32_t sctp_calculate_cksum(struct mbuf *, int32_t);
|
||||
#endif
|
||||
#endif /* __crc32c_h__ */
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,24 +32,24 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 273168 2014-10-16 15:36:04Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_HEADER_H_
|
||||
#define _NETINET_SCTP_HEADER_H_
|
||||
|
||||
#if defined(__Windows__) && !defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
#include <packon.h>
|
||||
#endif
|
||||
#if !defined(__Userspace_os_Windows)
|
||||
#if !defined(_WIN32)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <netinet/sctp.h>
|
||||
#include <netinet/sctp_constants.h>
|
||||
|
||||
#if !defined(__Userspace_os_Windows)
|
||||
#if !defined(_WIN32)
|
||||
#define SCTP_PACKED __attribute__((packed))
|
||||
#else
|
||||
#pragma pack (push, 1)
|
||||
|
@ -64,7 +66,6 @@ struct sctp_ipv4addr_param {
|
|||
|
||||
#define SCTP_V6_ADDR_BYTES 16
|
||||
|
||||
|
||||
struct sctp_ipv6addr_param {
|
||||
struct sctp_paramhdr ph;/* type=SCTP_IPV6_PARAM_TYPE, len=20 */
|
||||
uint8_t addr[SCTP_V6_ADDR_BYTES]; /* IPV6 address */
|
||||
|
@ -108,14 +109,12 @@ struct sctp_heartbeat_info_param {
|
|||
char address[SCTP_ADDRMAX];
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
/* draft-ietf-tsvwg-prsctp */
|
||||
/* PR-SCTP supported parameter */
|
||||
struct sctp_prsctp_supported_param {
|
||||
struct sctp_paramhdr ph;
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
/* draft-ietf-tsvwg-addip-sctp */
|
||||
struct sctp_asconf_paramhdr { /* an ASCONF "parameter" */
|
||||
struct sctp_paramhdr ph;/* a SCTP parameter header */
|
||||
|
@ -127,14 +126,12 @@ struct sctp_asconf_addr_param { /* an ASCONF address parameter */
|
|||
struct sctp_ipv6addr_param addrp; /* max storage size */
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
struct sctp_asconf_tag_param { /* an ASCONF NAT-Vtag parameter */
|
||||
struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
|
||||
uint32_t local_vtag;
|
||||
uint32_t remote_vtag;
|
||||
uint32_t local_vtag;
|
||||
uint32_t remote_vtag;
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
struct sctp_asconf_addrv4_param { /* an ASCONF address (v4) parameter */
|
||||
struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
|
||||
struct sctp_ipv4addr_param addrp; /* max storage size */
|
||||
|
@ -147,15 +144,14 @@ struct sctp_supported_chunk_types_param {
|
|||
uint8_t chunk_types[];
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
/*
|
||||
* Structures for DATA chunks
|
||||
*/
|
||||
struct sctp_data {
|
||||
uint32_t tsn;
|
||||
uint16_t stream_id;
|
||||
uint16_t stream_sequence;
|
||||
uint32_t protocol_id;
|
||||
uint16_t sid;
|
||||
uint16_t ssn;
|
||||
uint32_t ppid;
|
||||
/* user data follows */
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
@ -164,6 +160,23 @@ struct sctp_data_chunk {
|
|||
struct sctp_data dp;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_idata {
|
||||
uint32_t tsn;
|
||||
uint16_t sid;
|
||||
uint16_t reserved; /* Where does the SSN go? */
|
||||
uint32_t mid;
|
||||
union {
|
||||
uint32_t ppid;
|
||||
uint32_t fsn; /* Fragment Sequence Number */
|
||||
} ppid_fsn;
|
||||
/* user data follows */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_idata_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
struct sctp_idata dp;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* Structures for the control chunks
|
||||
*/
|
||||
|
@ -180,9 +193,9 @@ struct sctp_init {
|
|||
#define SCTP_IDENTIFICATION_SIZE 16
|
||||
#define SCTP_ADDRESS_SIZE 4
|
||||
#if defined(__Userspace__)
|
||||
#define SCTP_RESERVE_SPACE 5
|
||||
#define SCTP_RESERVE_SPACE 4
|
||||
#else
|
||||
#define SCTP_RESERVE_SPACE 6
|
||||
#define SCTP_RESERVE_SPACE 5
|
||||
#endif
|
||||
/* state cookie header */
|
||||
struct sctp_state_cookie { /* this is our definition... */
|
||||
|
@ -213,6 +226,7 @@ struct sctp_state_cookie { /* this is our definition... */
|
|||
|
||||
uint8_t ipv4_scope; /* IPv4 private addr scope */
|
||||
uint8_t loopback_scope; /* loopback scope information */
|
||||
uint8_t zero_checksum; /* copy of the inp value */
|
||||
uint8_t reserved[SCTP_RESERVE_SPACE]; /* Align to 64 bits */
|
||||
/*
|
||||
* at the end is tacked on the INIT chunk and the INIT-ACK chunk
|
||||
|
@ -220,34 +234,6 @@ struct sctp_state_cookie { /* this is our definition... */
|
|||
*/
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
/* Used for NAT state error cause */
|
||||
struct sctp_missing_nat_state {
|
||||
uint16_t cause;
|
||||
uint16_t length;
|
||||
uint8_t data[];
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
struct sctp_inv_mandatory_param {
|
||||
uint16_t cause;
|
||||
uint16_t length;
|
||||
uint32_t num_param;
|
||||
uint16_t param;
|
||||
/*
|
||||
* We include this to 0 it since only a missing cookie will cause
|
||||
* this error.
|
||||
*/
|
||||
uint16_t resv;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_unresolv_addr {
|
||||
uint16_t cause;
|
||||
uint16_t length;
|
||||
uint16_t addr_type;
|
||||
uint16_t reserved; /* Only one invalid addr type */
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* state cookie parameter */
|
||||
struct sctp_state_cookie_param {
|
||||
struct sctp_paramhdr ph;
|
||||
|
@ -269,7 +255,6 @@ struct sctp_init_msg {
|
|||
#define sctp_init_ack_chunk sctp_init_chunk
|
||||
#define sctp_init_ack_msg sctp_init_msg
|
||||
|
||||
|
||||
/* Selective Ack (SACK) */
|
||||
struct sctp_gap_ack_block {
|
||||
uint16_t start; /* Gap Ack block start */
|
||||
|
@ -306,7 +291,6 @@ struct sctp_nr_sack_chunk {
|
|||
struct sctp_nr_sack nr_sack;
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
/* Heartbeat Request (HEARTBEAT) */
|
||||
struct sctp_heartbeat {
|
||||
struct sctp_heartbeat_info_param hb_info;
|
||||
|
@ -321,7 +305,6 @@ struct sctp_heartbeat_chunk {
|
|||
#define sctp_heartbeat_ack sctp_heartbeat
|
||||
#define sctp_heartbeat_ack_chunk sctp_heartbeat_chunk
|
||||
|
||||
|
||||
/* Abort Asssociation (ABORT) */
|
||||
struct sctp_abort_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
|
@ -333,27 +316,23 @@ struct sctp_abort_msg {
|
|||
struct sctp_abort_chunk msg;
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
/* Shutdown Association (SHUTDOWN) */
|
||||
struct sctp_shutdown_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
uint32_t cumulative_tsn_ack;
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
/* Shutdown Acknowledgment (SHUTDOWN ACK) */
|
||||
struct sctp_shutdown_ack_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
/* Operation Error (ERROR) */
|
||||
struct sctp_error_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
/* optional error causes follow */
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
/* Cookie Echo (COOKIE ECHO) */
|
||||
struct sctp_cookie_echo_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
|
@ -388,28 +367,11 @@ struct sctp_shutdown_complete_chunk {
|
|||
struct sctp_chunkhdr ch;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* Oper error holding a stale cookie */
|
||||
struct sctp_stale_cookie_msg {
|
||||
struct sctp_paramhdr ph;/* really an error cause */
|
||||
uint32_t time_usec;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_adaptation_layer_indication {
|
||||
struct sctp_paramhdr ph;
|
||||
uint32_t indication;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_cookie_while_shutting_down {
|
||||
struct sctphdr sh;
|
||||
struct sctp_chunkhdr ch;
|
||||
struct sctp_paramhdr ph;/* really an error cause */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_shutdown_complete_msg {
|
||||
struct sctphdr sh;
|
||||
struct sctp_shutdown_complete_chunk shut_cmp;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* draft-ietf-tsvwg-addip-sctp
|
||||
*/
|
||||
|
@ -437,10 +399,16 @@ struct sctp_forward_tsn_chunk {
|
|||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_strseq {
|
||||
uint16_t stream;
|
||||
uint16_t sequence;
|
||||
uint16_t sid;
|
||||
uint16_t ssn;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_strseq_mid {
|
||||
uint16_t sid;
|
||||
uint16_t flags;
|
||||
uint32_t mid;
|
||||
};
|
||||
|
||||
struct sctp_forward_tsn_msg {
|
||||
struct sctphdr sh;
|
||||
struct sctp_forward_tsn_chunk msg;
|
||||
|
@ -456,7 +424,6 @@ struct sctp_chunk_desc {
|
|||
uint32_t tsn_ifany;
|
||||
} SCTP_PACKED;
|
||||
|
||||
|
||||
struct sctp_pktdrop_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
uint32_t bottle_bw;
|
||||
|
@ -507,10 +474,10 @@ struct sctp_stream_reset_response_tsn {
|
|||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_stream_reset_add_strm {
|
||||
struct sctp_paramhdr ph;
|
||||
uint32_t request_seq;
|
||||
uint16_t number_of_streams;
|
||||
uint16_t reserved;
|
||||
struct sctp_paramhdr ph;
|
||||
uint32_t request_seq;
|
||||
uint16_t number_of_streams;
|
||||
uint16_t reserved;
|
||||
} SCTP_PACKED;
|
||||
|
||||
#define SCTP_STREAM_RESET_RESULT_NOTHING_TO_DO 0x00000000 /* XXX: unused */
|
||||
|
@ -572,12 +539,6 @@ struct sctp_auth_chunk {
|
|||
uint8_t hmac[];
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_auth_invalid_hmac {
|
||||
struct sctp_paramhdr ph;
|
||||
uint16_t hmac_id;
|
||||
uint16_t padding;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* we pre-reserve enough room for a ECNE or CWR AND a SACK with no missing
|
||||
* pieces. If ENCE is missing we could have a couple of blocks. This way we
|
||||
|
@ -589,49 +550,47 @@ struct sctp_auth_invalid_hmac {
|
|||
#ifndef SCTP_MAX_OVERHEAD
|
||||
#ifdef INET6
|
||||
#define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct sctp_ecne_chunk) + \
|
||||
sizeof(struct sctp_sack_chunk) + \
|
||||
sizeof(struct ip6_hdr))
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct sctp_ecne_chunk) + \
|
||||
sizeof(struct sctp_sack_chunk) + \
|
||||
sizeof(struct ip6_hdr))
|
||||
|
||||
#define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct ip6_hdr))
|
||||
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct ip6_hdr))
|
||||
|
||||
#define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \
|
||||
sizeof(struct sctphdr))
|
||||
sizeof(struct sctphdr))
|
||||
|
||||
#else
|
||||
#define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct sctp_ecne_chunk) + \
|
||||
sizeof(struct sctp_sack_chunk) + \
|
||||
sizeof(struct ip))
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct sctp_ecne_chunk) + \
|
||||
sizeof(struct sctp_sack_chunk) + \
|
||||
sizeof(struct ip))
|
||||
|
||||
#define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct ip))
|
||||
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct ip))
|
||||
|
||||
#define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \
|
||||
sizeof(struct sctphdr))
|
||||
sizeof(struct sctphdr))
|
||||
|
||||
#endif /* INET6 */
|
||||
#endif /* !SCTP_MAX_OVERHEAD */
|
||||
|
||||
#define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct ip))
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct ip))
|
||||
|
||||
#define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \
|
||||
sizeof(struct sctphdr))
|
||||
sizeof(struct sctphdr))
|
||||
|
||||
#if defined(__Windows__)
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
#include <packoff.h>
|
||||
#endif
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#pragma pack ()
|
||||
#if defined(_WIN32) && defined(__Userspace__)
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
#undef SCTP_PACKED
|
||||
#endif /* !__sctp_header_h__ */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 252585 2013-07-03 18:48:43Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_INDATA_H_
|
||||
|
@ -42,46 +44,40 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 252585 2013-07-03 18:48:43Z t
|
|||
|
||||
struct sctp_queued_to_read *
|
||||
sctp_build_readq_entry(struct sctp_tcb *stcb,
|
||||
struct sctp_nets *net,
|
||||
uint32_t tsn, uint32_t ppid,
|
||||
uint32_t context, uint16_t stream_no,
|
||||
uint16_t stream_seq, uint8_t flags,
|
||||
struct mbuf *dm);
|
||||
struct sctp_nets *net,
|
||||
uint32_t tsn, uint32_t ppid,
|
||||
uint32_t context, uint16_t sid,
|
||||
uint32_t mid, uint8_t flags,
|
||||
struct mbuf *dm);
|
||||
|
||||
|
||||
#define sctp_build_readq_entry_mac(_ctl, in_it, context, net, tsn, ppid, stream_no, stream_seq, flags, dm) do { \
|
||||
#define sctp_build_readq_entry_mac(_ctl, in_it, context, net, tsn, ppid, sid, flags, dm, tfsn, mid) do { \
|
||||
if (_ctl) { \
|
||||
atomic_add_int(&((net)->ref_count), 1); \
|
||||
(_ctl)->sinfo_stream = stream_no; \
|
||||
(_ctl)->sinfo_ssn = stream_seq; \
|
||||
memset(_ctl, 0, sizeof(struct sctp_queued_to_read)); \
|
||||
(_ctl)->sinfo_stream = sid; \
|
||||
TAILQ_INIT(&_ctl->reasm); \
|
||||
(_ctl)->top_fsn = tfsn; \
|
||||
(_ctl)->mid = mid; \
|
||||
(_ctl)->sinfo_flags = (flags << 8); \
|
||||
(_ctl)->sinfo_ppid = ppid; \
|
||||
(_ctl)->sinfo_context = context; \
|
||||
(_ctl)->sinfo_timetolive = 0; \
|
||||
(_ctl)->fsn_included = 0xffffffff; \
|
||||
(_ctl)->sinfo_tsn = tsn; \
|
||||
(_ctl)->sinfo_cumtsn = tsn; \
|
||||
(_ctl)->sinfo_assoc_id = sctp_get_associd((in_it)); \
|
||||
(_ctl)->length = 0; \
|
||||
(_ctl)->held_length = 0; \
|
||||
(_ctl)->whoFrom = net; \
|
||||
(_ctl)->data = dm; \
|
||||
(_ctl)->tail_mbuf = NULL; \
|
||||
(_ctl)->aux_data = NULL; \
|
||||
(_ctl)->stcb = (in_it); \
|
||||
(_ctl)->port_from = (in_it)->rport; \
|
||||
(_ctl)->spec_flags = 0; \
|
||||
(_ctl)->do_not_ref_stcb = 0; \
|
||||
(_ctl)->end_added = 0; \
|
||||
(_ctl)->pdapi_aborted = 0; \
|
||||
(_ctl)->some_taken = 0; \
|
||||
if ((in_it)->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { \
|
||||
(_ctl)->do_not_ref_stcb = 1; \
|
||||
}\
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
struct mbuf *
|
||||
sctp_build_ctl_nchunk(struct sctp_inpcb *inp,
|
||||
struct sctp_sndrcvinfo *sinfo);
|
||||
struct sctp_sndrcvinfo *sinfo);
|
||||
|
||||
void sctp_set_rwnd(struct sctp_tcb *, struct sctp_association *);
|
||||
|
||||
|
@ -90,7 +86,7 @@ sctp_calc_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc);
|
|||
|
||||
void
|
||||
sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
|
||||
uint32_t rwnd, int *abort_now, int ecne_seen);
|
||||
uint32_t rwnd, int *abort_now, int ecne_seen);
|
||||
|
||||
void
|
||||
sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup,
|
||||
|
@ -102,7 +98,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup,
|
|||
/* draft-ietf-tsvwg-usctp */
|
||||
void
|
||||
sctp_handle_forward_tsn(struct sctp_tcb *,
|
||||
struct sctp_forward_tsn_chunk *, int *, struct mbuf *, int);
|
||||
struct sctp_forward_tsn_chunk *, int *, struct mbuf *, int);
|
||||
|
||||
struct sctp_tmit_chunk *
|
||||
sctp_try_advance_peer_ack_point(struct sctp_tcb *, struct sctp_association *);
|
||||
|
@ -114,14 +110,8 @@ sctp_update_acked(struct sctp_tcb *, struct sctp_shutdown_chunk *, int *);
|
|||
|
||||
int
|
||||
sctp_process_data(struct mbuf **, int, int *, int,
|
||||
struct sockaddr *src, struct sockaddr *dst,
|
||||
struct sctphdr *,
|
||||
struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *, uint32_t *,
|
||||
#if defined(__FreeBSD__)
|
||||
uint8_t, uint32_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *, uint32_t *);
|
||||
|
||||
void sctp_slide_mapping_arrays(struct sctp_tcb *stcb);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 273168 2014-10-16 15:36:04Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_INPUT_H_
|
||||
|
@ -43,12 +45,10 @@ void
|
|||
sctp_common_input_processing(struct mbuf **, int, int, int,
|
||||
struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, struct sctp_chunkhdr *,
|
||||
#if !defined(SCTP_WITH_NO_CSUM)
|
||||
uint8_t,
|
||||
#endif
|
||||
uint8_t,
|
||||
#if defined(__FreeBSD__)
|
||||
uint8_t, uint32_t,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t, uint16_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
|
||||
|
@ -56,9 +56,9 @@ struct sctp_stream_reset_request *
|
|||
sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq,
|
||||
struct sctp_tmit_chunk **bchk);
|
||||
|
||||
void sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries,
|
||||
uint16_t *list);
|
||||
|
||||
void
|
||||
sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries,
|
||||
uint16_t *list);
|
||||
|
||||
int sctp_is_there_unsent_data(struct sctp_tcb *stcb, int so_locked);
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -31,7 +33,7 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
@ -61,12 +63,15 @@ __FBSDID("$FreeBSD$");
|
|||
#define SCTP_INP_INFO_TRYLOCK() 1
|
||||
#define SCTP_INP_INFO_RUNLOCK()
|
||||
#define SCTP_INP_INFO_WUNLOCK()
|
||||
#define SCTP_INP_INFO_LOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_RLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_WLOCK_ASSERT()
|
||||
|
||||
#define SCTP_WQ_ADDR_INIT()
|
||||
#define SCTP_WQ_ADDR_DESTROY()
|
||||
#define SCTP_WQ_ADDR_LOCK()
|
||||
#define SCTP_WQ_ADDR_UNLOCK()
|
||||
|
||||
#define SCTP_WQ_ADDR_LOCK_ASSERT()
|
||||
|
||||
#define SCTP_IPI_ADDR_INIT()
|
||||
#define SCTP_IPI_ADDR_DESTROY()
|
||||
|
@ -74,20 +79,19 @@ __FBSDID("$FreeBSD$");
|
|||
#define SCTP_IPI_ADDR_WLOCK()
|
||||
#define SCTP_IPI_ADDR_RUNLOCK()
|
||||
#define SCTP_IPI_ADDR_WUNLOCK()
|
||||
#define SCTP_IPI_ADDR_LOCK_ASSERT()
|
||||
#define SCTP_IPI_ADDR_WLOCK_ASSERT()
|
||||
|
||||
#define SCTP_IPI_ITERATOR_WQ_INIT()
|
||||
#define SCTP_IPI_ITERATOR_WQ_DESTROY()
|
||||
#define SCTP_IPI_ITERATOR_WQ_LOCK()
|
||||
#define SCTP_IPI_ITERATOR_WQ_UNLOCK()
|
||||
|
||||
|
||||
#define SCTP_IP_PKTLOG_INIT()
|
||||
#define SCTP_IP_PKTLOG_LOCK()
|
||||
#define SCTP_IP_PKTLOG_UNLOCK()
|
||||
#define SCTP_IP_PKTLOG_DESTROY()
|
||||
|
||||
|
||||
|
||||
#define SCTP_INP_READ_INIT(_inp)
|
||||
#define SCTP_INP_READ_DESTROY(_inp)
|
||||
#define SCTP_INP_READ_LOCK(_inp)
|
||||
|
@ -98,9 +102,10 @@ __FBSDID("$FreeBSD$");
|
|||
#define SCTP_INP_LOCK_DESTROY(_inp)
|
||||
#define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp)
|
||||
|
||||
|
||||
#define SCTP_INP_RLOCK(_inp)
|
||||
#define SCTP_INP_WLOCK(_inp)
|
||||
#define SCTP_INP_RLOCK_ASSERT(_inp)
|
||||
#define SCTP_INP_WLOCK_ASSERT(_inp)
|
||||
|
||||
#define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
|
||||
|
||||
|
@ -109,11 +114,6 @@ __FBSDID("$FreeBSD$");
|
|||
#define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
|
||||
|
||||
|
||||
#define SCTP_TCB_SEND_LOCK_INIT(_tcb)
|
||||
#define SCTP_TCB_SEND_LOCK_DESTROY(_tcb)
|
||||
#define SCTP_TCB_SEND_LOCK(_tcb)
|
||||
#define SCTP_TCB_SEND_UNLOCK(_tcb)
|
||||
|
||||
#define SCTP_INP_INCR_REF(_inp)
|
||||
#define SCTP_INP_DECR_REF(_inp)
|
||||
|
||||
|
@ -212,14 +212,6 @@ __FBSDID("$FreeBSD$");
|
|||
} while (0)
|
||||
|
||||
|
||||
/* not sure if __Userspace__ needs these (but copied nonetheless...) */
|
||||
#if defined(SCTP_SO_LOCK_TESTING)
|
||||
#define SCTP_INP_SO(sctpinp) (sctpinp)->ip_inp.inp.inp_socket
|
||||
#define SCTP_SOCKET_LOCK(so, refcnt)
|
||||
#define SCTP_SOCKET_UNLOCK(so, refcnt)
|
||||
#endif
|
||||
|
||||
|
||||
/* these were in sctp_lock_empty.h but aren't in sctp_lock_bsd.h ... */
|
||||
#if 0
|
||||
#define SCTP_IPI_ADDR_LOCK()
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2006-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 235828 2012-05-23 11:26:28Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_OS_H_
|
||||
|
@ -62,25 +64,18 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 235828 2012-05-23 11:26:28Z tuexe
|
|||
* SCTP_ZONE_DESTROY(zone)
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <netinet/sctp_os_bsd.h>
|
||||
#else
|
||||
#define MODULE_GLOBAL(_B) (_B)
|
||||
#endif
|
||||
|
||||
#if defined(__Userspace__)
|
||||
#include <netinet/sctp_os_userspace.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
#include <netinet/sctp_os_macosx.h>
|
||||
#endif
|
||||
|
||||
#if defined(__Panda__)
|
||||
#include <ip/sctp/sctp_os_iox.h>
|
||||
#endif
|
||||
|
||||
#if defined(__Windows__)
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
#include <netinet/sctp_os_windows.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2006-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2011, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved.
|
||||
|
@ -41,15 +43,16 @@
|
|||
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <Mswsock.h>
|
||||
#include <Windows.h>
|
||||
#include <mswsock.h>
|
||||
#include <windows.h>
|
||||
#include "user_environment.h"
|
||||
typedef CRITICAL_SECTION userland_mutex_t;
|
||||
#if WINVER < 0x0600
|
||||
typedef CRITICAL_SECTION userland_rwlock_t;
|
||||
enum {
|
||||
C_SIGNAL = 0,
|
||||
C_BROADCAST = 1,
|
||||
|
@ -70,6 +73,7 @@ void WakeAllXPConditionVariable(userland_cond_t *);
|
|||
#define SleepConditionVariableCS(cond, mtx, time) SleepXPConditionVariable(cond, mtx)
|
||||
#define WakeAllConditionVariable(cond) WakeAllXPConditionVariable(cond)
|
||||
#else
|
||||
typedef SRWLOCK userland_rwlock_t;
|
||||
#define DeleteConditionVariable(cond)
|
||||
typedef CONDITION_VARIABLE userland_cond_t;
|
||||
#endif
|
||||
|
@ -78,33 +82,30 @@ typedef HANDLE userland_thread_t;
|
|||
#define IPVERSION 4
|
||||
#define MAXTTL 255
|
||||
/* VS2010 comes with stdint.h */
|
||||
#if _MSC_VER >= 1600
|
||||
#if !defined(_MSC_VER) || (_MSC_VER >= 1600)
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#define uint64_t unsigned __int64
|
||||
#define uint32_t unsigned __int32
|
||||
#define int32_t __int32
|
||||
#define uint16_t unsigned __int16
|
||||
#define int16_t __int16
|
||||
#define uint8_t unsigned __int8
|
||||
#define int8_t __int8
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int8 int8_t;
|
||||
#endif
|
||||
#ifndef _SIZE_T_DEFINED
|
||||
#define size_t __int32
|
||||
#typedef __int32 size_t;
|
||||
#endif
|
||||
#define u_long unsigned __int64
|
||||
#define u_int unsigned __int32
|
||||
#define u_int32_t unsigned __int32
|
||||
#define u_int16_t unsigned __int16
|
||||
#define u_int8_t unsigned __int8
|
||||
#define u_char unsigned char
|
||||
#define n_short unsigned __int16
|
||||
#define u_short unsigned __int16
|
||||
#define n_time unsigned __int32
|
||||
#define sa_family_t unsigned __int8
|
||||
#define ssize_t __int64
|
||||
typedef unsigned __int32 u_int;
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned __int16 u_short;
|
||||
typedef unsigned __int8 sa_family_t;
|
||||
#ifndef _SSIZE_T_DEFINED
|
||||
typedef __int64 ssize_t;
|
||||
#endif
|
||||
#if !defined(__MINGW32__)
|
||||
#define __func__ __FUNCTION__
|
||||
|
||||
#endif
|
||||
#ifndef EWOULDBLOCK
|
||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#endif
|
||||
|
@ -218,9 +219,19 @@ typedef char* caddr_t;
|
|||
|
||||
#define bzero(buf, len) memset(buf, 0, len)
|
||||
#define bcopy(srcKey, dstKey, len) memcpy(dstKey, srcKey, len)
|
||||
#if _MSC_VER < 1900
|
||||
#define snprintf(data, size, format, ...) _snprintf_s(data, size, _TRUNCATE, format, __VA_ARGS__)
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(__MINGW32__)
|
||||
#define SCTP_SNPRINTF(data, size, format, ...) \
|
||||
if (_snprintf_s(data, size, _TRUNCATE, format, __VA_ARGS__) < 0) { \
|
||||
data[0] = '\0'; \
|
||||
}
|
||||
#else
|
||||
#define SCTP_SNPRINTF(data, ...) \
|
||||
if (snprintf(data, __VA_ARGS__) < 0 ) { \
|
||||
data[0] = '\0'; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define inline __inline
|
||||
#define __inline__ __inline
|
||||
#define MSG_EOR 0x8 /* data completes record */
|
||||
|
@ -273,18 +284,21 @@ typedef char* caddr_t;
|
|||
#endif
|
||||
|
||||
#else /* !defined(Userspace_os_Windows) */
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <pthread.h>
|
||||
#if defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_OpenBSD) || defined(__Userspace_os_NaCl)
|
||||
#include <pthread.h>
|
||||
|
||||
#if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__)
|
||||
#error "Unsupported build configuration."
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
typedef pthread_mutex_t userland_mutex_t;
|
||||
typedef pthread_rwlock_t userland_rwlock_t;
|
||||
typedef pthread_cond_t userland_cond_t;
|
||||
typedef pthread_t userland_thread_t;
|
||||
#endif
|
||||
|
||||
#if defined(__Userspace_os_Windows) || defined(__Userspace_os_NaCl)
|
||||
#if defined(_WIN32) || defined(__native_client__)
|
||||
|
||||
#define IFNAMSIZ 64
|
||||
|
||||
|
@ -326,7 +340,7 @@ struct ip {
|
|||
u_char ip_ttl;
|
||||
u_char ip_p;
|
||||
u_short ip_sum;
|
||||
struct in_addr ip_src, ip_dst;
|
||||
struct in_addr ip_src, ip_dst;
|
||||
};
|
||||
|
||||
struct ifaddrs {
|
||||
|
@ -347,7 +361,7 @@ struct udphdr {
|
|||
};
|
||||
|
||||
struct iovec {
|
||||
unsigned long len;
|
||||
size_t len;
|
||||
char *buf;
|
||||
};
|
||||
|
||||
|
@ -378,43 +392,9 @@ struct ifkpi {
|
|||
int ifk_value;
|
||||
} ifk_data;
|
||||
};
|
||||
|
||||
struct ifreq {
|
||||
char ifr_name[16];
|
||||
union {
|
||||
struct sockaddr ifru_addr;
|
||||
struct sockaddr ifru_dstaddr;
|
||||
struct sockaddr ifru_broadaddr;
|
||||
short ifru_flags;
|
||||
int ifru_metric;
|
||||
int ifru_mtu;
|
||||
int ifru_phys;
|
||||
int ifru_media;
|
||||
int ifru_intval;
|
||||
char* ifru_data;
|
||||
struct ifdevmtu ifru_devmtu;
|
||||
struct ifkpi ifru_kpi;
|
||||
uint32_t ifru_wake_flags;
|
||||
} ifr_ifru;
|
||||
#define ifr_addr ifr_ifru.ifru_addr
|
||||
#define ifr_dstaddr ifr_ifru.ifru_dstaddr
|
||||
#define ifr_broadaddr ifr_ifru.ifru_broadaddr
|
||||
#define ifr_flags ifr_ifru.ifru_flags[0]
|
||||
#define ifr_prevflags ifr_ifru.ifru_flags[1]
|
||||
#define ifr_metric ifr_ifru.ifru_metric
|
||||
#define ifr_mtu ifr_ifru.ifru_mtu
|
||||
#define ifr_phys ifr_ifru.ifru_phys
|
||||
#define ifr_media ifr_ifru.ifru_media
|
||||
#define ifr_data ifr_ifru.ifru_data
|
||||
#define ifr_devmtu ifr_ifru.ifru_devmtu
|
||||
#define ifr_intval ifr_ifru.ifru_intval
|
||||
#define ifr_kpi ifr_ifru.ifru_kpi
|
||||
#define ifr_wake_flags ifr_ifru.ifru_wake_flags
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
int Win_getifaddrs(struct ifaddrs**);
|
||||
#define getifaddrs(interfaces) (int)Win_getifaddrs(interfaces)
|
||||
int win_if_nametoindex(const char *);
|
||||
|
@ -425,9 +405,9 @@ int win_if_nametoindex(const char *);
|
|||
#define mtx_unlock(arg1)
|
||||
#define mtx_assert(arg1,arg2)
|
||||
#define MA_OWNED 7 /* sys/mutex.h typically on FreeBSD */
|
||||
#if !defined(__Userspace_os_FreeBSD)
|
||||
#if !defined(__FreeBSD__)
|
||||
struct mtx {int dummy;};
|
||||
#if !defined(__Userspace_os_NetBSD)
|
||||
#if !defined(__NetBSD__)
|
||||
struct selinfo {int dummy;};
|
||||
#endif
|
||||
struct sx {int dummy;};
|
||||
|
@ -435,10 +415,11 @@ struct sx {int dummy;};
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
/* #include <sys/param.h> in FreeBSD defines MSIZE */
|
||||
/* #include <sys/ktr.h> */
|
||||
/* #include <sys/systm.h> */
|
||||
#if 0 // 10.4 has an old one. // defined(HAVE_SYS_QUEUE_H)
|
||||
#if defined(HAVE_SYS_QUEUE_H)
|
||||
#include <sys/queue.h>
|
||||
#else
|
||||
#include <user_queue.h>
|
||||
|
@ -457,22 +438,22 @@ struct sx {int dummy;};
|
|||
#include <user_mbuf.h>
|
||||
/* #include <sys/uio.h> */
|
||||
/* #include <sys/lock.h> */
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version > 602000
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/rwlock.h>
|
||||
#endif
|
||||
/* #include <sys/kthread.h> */
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version > 602000
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/priv.h>
|
||||
#endif
|
||||
/* #include <sys/random.h> */
|
||||
/* #include <sys/limits.h> */
|
||||
#include <limits.h>
|
||||
/* #include <machine/cpu.h> */
|
||||
|
||||
#if defined(__Userspace_os_Darwin)
|
||||
#if defined(__APPLE__)
|
||||
/* was a 0 byte file. needed for structs if_data(64) and net_event_data */
|
||||
#include <net/if_var.h>
|
||||
#endif
|
||||
#if defined(__Userspace_os_FreeBSD)
|
||||
#if defined(__FreeBSD__)
|
||||
#include <net/if_types.h>
|
||||
/* #include <net/if_var.h> was a 0 byte file. causes struct mtx redefinition */
|
||||
#endif
|
||||
|
@ -480,7 +461,7 @@ struct sx {int dummy;};
|
|||
* userspace as well? */
|
||||
/* on FreeBSD, this results in a redefintion of struct route */
|
||||
/* #include <net/route.h> */
|
||||
#if !defined(__Userspace_os_Windows) && !defined(__Userspace_os_NaCl)
|
||||
#if !defined(_WIN32) && !defined(__native_client__)
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
@ -496,8 +477,8 @@ struct sx {int dummy;};
|
|||
|
||||
/* for getifaddrs */
|
||||
#include <sys/types.h>
|
||||
#if !defined(__Userspace_os_Windows)
|
||||
#if !defined(ANDROID) && (defined(INET) || defined(INET6))
|
||||
#if !defined(_WIN32)
|
||||
#if defined(INET) || defined(INET6)
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
|
@ -506,6 +487,8 @@ struct sx {int dummy;};
|
|||
|
||||
/* for close, etc. */
|
||||
#include <unistd.h>
|
||||
/* for gettimeofday */
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
/* lots of errno's used and needed in userspace */
|
||||
|
@ -513,7 +496,7 @@ struct sx {int dummy;};
|
|||
/* for offsetof */
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(SCTP_PROCESS_LEVEL_LOCKS) && !defined(__Userspace_os_Windows)
|
||||
#if defined(SCTP_PROCESS_LEVEL_LOCKS) && !defined(_WIN32)
|
||||
/* for pthread_mutex_lock, pthread_mutex_unlock, etc. */
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
@ -524,22 +507,21 @@ struct sx {int dummy;};
|
|||
#endif /* IPSEC */
|
||||
|
||||
#ifdef INET6
|
||||
#if defined(__Userspace_os_FreeBSD)
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/domain.h>
|
||||
#endif
|
||||
#ifdef IPSEC
|
||||
#include <netipsec/ipsec6.h>
|
||||
#endif
|
||||
#if !defined(__Userspace_os_Windows)
|
||||
#if !defined(_WIN32)
|
||||
#include <netinet/ip6.h>
|
||||
#include <netinet/icmp6.h>
|
||||
#endif
|
||||
#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_OpenBSD) || defined(__Userspace_os_Windows)
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(_WIN32) || defined(__EMSCRIPTEN__)
|
||||
#include "user_ip6_var.h"
|
||||
#else
|
||||
#include <netinet6/ip6_var.h>
|
||||
#endif
|
||||
#if defined(__Userspace_os_FreeBSD)
|
||||
#if defined(__FreeBSD__)
|
||||
#include <netinet6/in6_pcb.h>
|
||||
#include <netinet6/ip6protosw.h>
|
||||
/* #include <netinet6/nd6.h> was a 0 byte file */
|
||||
|
@ -554,7 +536,7 @@ struct sx {int dummy;};
|
|||
|
||||
#include "netinet/sctp_sha1.h"
|
||||
|
||||
#if __FreeBSD_version >= 700000
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <netinet/ip_options.h>
|
||||
#endif
|
||||
|
||||
|
@ -563,11 +545,6 @@ struct sx {int dummy;};
|
|||
SCTP_BASE_VAR(debug_printf)(__VA_ARGS__); \
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#ifndef in6pcb
|
||||
#define in6pcb inpcb
|
||||
#endif
|
||||
#endif
|
||||
/* Declare all the malloc names for all the various mallocs */
|
||||
MALLOC_DECLARE(SCTP_M_MAP);
|
||||
MALLOC_DECLARE(SCTP_M_STRMI);
|
||||
|
@ -612,12 +589,12 @@ MALLOC_DECLARE(SCTP_M_SOCKOPT);
|
|||
/*
|
||||
*
|
||||
*/
|
||||
#if !defined(__Userspace_os_Darwin)
|
||||
#if !defined(__APPLE__)
|
||||
#define USER_ADDR_NULL (NULL) /* FIX ME: temp */
|
||||
#endif
|
||||
|
||||
#if defined(SCTP_DEBUG)
|
||||
#include <netinet/sctp_constants.h>
|
||||
#if defined(SCTP_DEBUG)
|
||||
#define SCTPDBG(level, ...) \
|
||||
{ \
|
||||
do { \
|
||||
|
@ -671,7 +648,7 @@ MALLOC_DECLARE(SCTP_M_SOCKOPT);
|
|||
#define SCTP_VRF_IFN_HASH_SIZE 3
|
||||
#define SCTP_INIT_VRF_TABLEID(vrf)
|
||||
|
||||
#if !defined(__Userspace_os_Windows)
|
||||
#if !defined(_WIN32)
|
||||
#define SCTP_IFN_IS_IFT_LOOP(ifn) (strncmp((ifn)->ifn_name, "lo", 2) == 0)
|
||||
/* BSD definition */
|
||||
/* #define SCTP_ROUTE_IS_REAL_LOOP(ro) ((ro)->ro_rt && (ro)->ro_rt->rt_ifa && (ro)->ro_rt->rt_ifa->ifa_ifp && (ro)->ro_rt->rt_ifa->ifa_ifp->if_type == IFT_LOOP) */
|
||||
|
@ -765,14 +742,6 @@ MALLOC_DECLARE(SCTP_M_SOCKOPT);
|
|||
umem_cache_destroy(zone);
|
||||
#endif
|
||||
|
||||
/* global struct ifaddrs used in sctp_init_ifns_for_vrf getifaddrs call
|
||||
* but references to fields are needed to persist as the vrf is queried.
|
||||
* getifaddrs allocates memory that needs to be freed with a freeifaddrs
|
||||
* call; this global is used to call freeifaddrs upon in sctp_pcb_finish
|
||||
*/
|
||||
extern struct ifaddrs *g_interfaces;
|
||||
|
||||
|
||||
/*
|
||||
* __Userspace__ Defining sctp_hashinit_flags() and sctp_hashdestroy() for userland.
|
||||
*/
|
||||
|
@ -812,10 +781,8 @@ sctp_hashfreedestroy(void *vhashtbl, struct malloc_type *type, u_long hashmask);
|
|||
/*__Userspace__ defining KTR_SUBSYS 1 as done in sctp_os_macosx.h */
|
||||
#define KTR_SUBSYS 1
|
||||
|
||||
#define sctp_get_tick_count() (ticks)
|
||||
|
||||
/* The packed define for 64 bit platforms */
|
||||
#if !defined(__Userspace_os_Windows)
|
||||
#if !defined(_WIN32)
|
||||
#define SCTP_PACKED __attribute__((packed))
|
||||
#define SCTP_UNUSED __attribute__((unused))
|
||||
#else
|
||||
|
@ -844,6 +811,13 @@ sctp_hashfreedestroy(void *vhashtbl, struct malloc_type *type, u_long hashmask);
|
|||
M_ALIGN(m, len); \
|
||||
}
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#define SCTP_SNPRINTF(data, ...) \
|
||||
if (snprintf(data, __VA_ARGS__) < 0) { \
|
||||
data[0] = '\0'; \
|
||||
}
|
||||
#endif
|
||||
|
||||
/* We make it so if you have up to 4 threads
|
||||
* writting based on the default size of
|
||||
* the packet log 65 k, that would be
|
||||
|
@ -890,7 +864,7 @@ static inline void sctp_userspace_rtalloc(sctp_route_t *ro)
|
|||
* SCTP_GET_IF_INDEX_FROM_ROUTE macro.
|
||||
*/
|
||||
}
|
||||
#define SCTP_RTALLOC(ro, vrf_id) sctp_userspace_rtalloc((sctp_route_t *)ro)
|
||||
#define SCTP_RTALLOC(ro, vrf_id, fibnum) sctp_userspace_rtalloc((sctp_route_t *)ro)
|
||||
|
||||
/* dummy rtfree needed once user_route.h is included */
|
||||
static inline void sctp_userspace_rtfree(sctp_rtentry_t *rt)
|
||||
|
@ -902,7 +876,6 @@ static inline void sctp_userspace_rtfree(sctp_rtentry_t *rt)
|
|||
return;
|
||||
}
|
||||
free(rt);
|
||||
rt = NULL;
|
||||
}
|
||||
#define rtfree(arg1) sctp_userspace_rtfree(arg1)
|
||||
|
||||
|
@ -910,23 +883,17 @@ static inline void sctp_userspace_rtfree(sctp_rtentry_t *rt)
|
|||
/*************************/
|
||||
/* MTU */
|
||||
/*************************/
|
||||
int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af);
|
||||
int sctp_userspace_get_mtu_from_ifn(uint32_t if_index);
|
||||
|
||||
#define SCTP_GATHER_MTU_FROM_IFN_INFO(ifn, ifn_index, af) sctp_userspace_get_mtu_from_ifn(ifn_index, af)
|
||||
#define SCTP_GATHER_MTU_FROM_IFN_INFO(ifn, ifn_index) sctp_userspace_get_mtu_from_ifn(ifn_index)
|
||||
|
||||
#define SCTP_GATHER_MTU_FROM_ROUTE(sctp_ifa, sa, rt) ((rt != NULL) ? rt->rt_rmx.rmx_mtu : 0)
|
||||
|
||||
#define SCTP_GATHER_MTU_FROM_INTFC(sctp_ifn) sctp_userspace_get_mtu_from_ifn(if_nametoindex(((struct ifaddrs *) (sctp_ifn))->ifa_name), AF_INET)
|
||||
|
||||
#define SCTP_SET_MTU_OF_ROUTE(sa, rt, mtu) do { \
|
||||
if (rt != NULL) \
|
||||
rt->rt_rmx.rmx_mtu = mtu; \
|
||||
} while(0)
|
||||
|
||||
/* (de-)register interface event notifications */
|
||||
#define SCTP_REGISTER_INTERFACE(ifhandle, af)
|
||||
#define SCTP_DEREGISTER_INTERFACE(ifhandle, af)
|
||||
|
||||
|
||||
/*************************/
|
||||
/* These are for logging */
|
||||
|
@ -951,13 +918,6 @@ int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af);
|
|||
#define SCTP_GET_HEADER_FOR_OUTPUT(o_pak) 0
|
||||
#define SCTP_RELEASE_HEADER(m)
|
||||
#define SCTP_RELEASE_PKT(m) sctp_m_freem(m)
|
||||
/* UDP __Userspace__ - dummy definition */
|
||||
#define SCTP_ENABLE_UDP_CSUM(m) m=m
|
||||
/* BSD definition */
|
||||
/* #define SCTP_ENABLE_UDP_CSUM(m) do { \ */
|
||||
/* m->m_pkthdr.csum_flags = CSUM_UDP; \ */
|
||||
/* m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); \ */
|
||||
/* } while (0) */
|
||||
|
||||
#define SCTP_GET_PKT_VRFID(m, vrf_id) ((vrf_id = SCTP_DEFAULT_VRFID) != SCTP_DEFAULT_VRFID)
|
||||
|
||||
|
@ -983,11 +943,11 @@ int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af);
|
|||
*/
|
||||
|
||||
/* get the v6 hop limit */
|
||||
#define SCTP_GET_HLIM(inp, ro) 128 /* As done for __Windows__ */
|
||||
#define SCTP_GET_HLIM(inp, ro) 128
|
||||
#define IPv6_HOP_LIMIT 128
|
||||
|
||||
/* is the endpoint v6only? */
|
||||
#define SCTP_IPV6_V6ONLY(inp) (((struct inpcb *)inp)->inp_flags & IN6P_IPV6_V6ONLY)
|
||||
#define SCTP_IPV6_V6ONLY(sctp_inpcb) ((sctp_inpcb)->ip_inp.inp.inp_flags & IN6P_IPV6_V6ONLY)
|
||||
/* is the socket non-blocking? */
|
||||
#define SCTP_SO_IS_NBIO(so) ((so)->so_state & SS_NBIO)
|
||||
#define SCTP_SET_SO_NBIO(so) ((so)->so_state |= SS_NBIO)
|
||||
|
@ -1000,6 +960,8 @@ int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af);
|
|||
|
||||
/* wakeup a socket */
|
||||
#define SCTP_SOWAKEUP(so) wakeup(&(so)->so_timeo, so)
|
||||
/* number of bytes ready to read */
|
||||
#define SCTP_SBAVAIL(sb) (sb)->sb_cc
|
||||
/* clear the socket buffer state */
|
||||
#define SCTP_SB_CLEAR(sb) \
|
||||
(sb).sb_cc = 0; \
|
||||
|
@ -1009,11 +971,6 @@ int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af);
|
|||
#define SCTP_SB_LIMIT_RCV(so) so->so_rcv.sb_hiwat
|
||||
#define SCTP_SB_LIMIT_SND(so) so->so_snd.sb_hiwat
|
||||
|
||||
/* Future zero copy wakeup/send function */
|
||||
#define SCTP_ZERO_COPY_EVENT(inp, so)
|
||||
/* This is re-pulse ourselves for sendbuf */
|
||||
#define SCTP_ZERO_COPY_SENDQ_EVENT(inp, so)
|
||||
|
||||
#define SCTP_READ_RANDOM(buf, len) read_random(buf, len)
|
||||
|
||||
#define SCTP_SHA1_CTX struct sctp_sha1_context
|
||||
|
@ -1027,7 +984,7 @@ int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af);
|
|||
|
||||
/* sctp_pcb.h */
|
||||
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
#define SHUT_RD 1
|
||||
#define SHUT_WR 2
|
||||
#define SHUT_RDWR 3
|
||||
|
@ -1046,12 +1003,22 @@ int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af);
|
|||
struct sockaddr_conn {
|
||||
#ifdef HAVE_SCONN_LEN
|
||||
uint8_t sconn_len;
|
||||
#endif
|
||||
uint8_t sconn_family;
|
||||
#else
|
||||
uint16_t sconn_family;
|
||||
#endif
|
||||
uint16_t sconn_port;
|
||||
void *sconn_addr;
|
||||
};
|
||||
|
||||
typedef void *(*start_routine_t)(void *);
|
||||
|
||||
extern int
|
||||
sctp_userspace_thread_create(userland_thread_t *thread, start_routine_t start_routine);
|
||||
|
||||
void
|
||||
sctp_userspace_set_threadname(const char *name);
|
||||
|
||||
/*
|
||||
* SCTP protocol specific mbuf flags.
|
||||
*/
|
||||
|
@ -1074,13 +1041,13 @@ extern void sctp_userspace_ip_output(int *result, struct mbuf *o_pak,
|
|||
sctp_route_t *ro, void *stcb,
|
||||
uint32_t vrf_id);
|
||||
|
||||
#define SCTP_IP_OUTPUT(result, o_pak, ro, stcb, vrf_id) sctp_userspace_ip_output(&result, o_pak, ro, stcb, vrf_id);
|
||||
#define SCTP_IP_OUTPUT(result, o_pak, ro, inp, vrf_id) sctp_userspace_ip_output(&result, o_pak, ro, inp, vrf_id);
|
||||
|
||||
#if defined(INET6)
|
||||
extern void sctp_userspace_ip6_output(int *result, struct mbuf *o_pak,
|
||||
struct route_in6 *ro, void *stcb,
|
||||
uint32_t vrf_id);
|
||||
#define SCTP_IP6_OUTPUT(result, o_pak, ro, ifp, stcb, vrf_id) sctp_userspace_ip6_output(&result, o_pak, ro, stcb, vrf_id);
|
||||
#define SCTP_IP6_OUTPUT(result, o_pak, ro, ifp, inp, vrf_id) sctp_userspace_ip6_output(&result, o_pak, ro, inp, vrf_id);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1090,7 +1057,7 @@ extern void sctp_userspace_ip6_output(int *result, struct mbuf *o_pak,
|
|||
{ \
|
||||
if (stcb && stcb->sctp_ep) \
|
||||
result = ip6_output(o_pak, \
|
||||
((struct in6pcb *)(stcb->sctp_ep))->in6p_outputopts, \
|
||||
((struct inpcb *)(stcb->sctp_ep))->in6p_outputopts, \
|
||||
(ro), 0, 0, ifp, NULL); \
|
||||
else \
|
||||
result = ip6_output(o_pak, NULL, (ro), 0, 0, ifp, NULL); \
|
||||
|
@ -1104,12 +1071,12 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a
|
|||
/* with the current included files, this is defined in Linux but
|
||||
* in FreeBSD, it is behind a _KERNEL in sys/socket.h ...
|
||||
*/
|
||||
#if defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_OpenBSD) || defined(__Userspace_os_NaCl)
|
||||
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__native_client__)
|
||||
/* stolen from /usr/include/sys/socket.h */
|
||||
#define CMSG_ALIGN(n) _ALIGN(n)
|
||||
#elif defined(__Userspace_os_NetBSD)
|
||||
#elif defined(__NetBSD__)
|
||||
#define CMSG_ALIGN(n) (((n) + __ALIGNBYTES) & ~__ALIGNBYTES)
|
||||
#elif defined(__Userspace_os_Darwin)
|
||||
#elif defined(__APPLE__)
|
||||
#if !defined(__DARWIN_ALIGNBYTES)
|
||||
#define __DARWIN_ALIGNBYTES (sizeof(__darwin_size_t) - 1)
|
||||
#endif
|
||||
|
@ -1129,7 +1096,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a
|
|||
#endif
|
||||
#define I_AM_HERE \
|
||||
do { \
|
||||
SCTP_PRINTF("%s:%d at %s\n", __FILE__, __LINE__ , __FUNCTION__); \
|
||||
SCTP_PRINTF("%s:%d at %s\n", __FILE__, __LINE__ , __func__); \
|
||||
} while (0)
|
||||
|
||||
#ifndef timevalsub
|
||||
|
@ -1144,7 +1111,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a
|
|||
} while (0)
|
||||
#endif
|
||||
|
||||
#if defined(__Userspace_os_Linux)
|
||||
#if defined(__linux__)
|
||||
#if !defined(TAILQ_FOREACH_SAFE)
|
||||
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = ((head)->tqh_first); \
|
||||
|
@ -1158,16 +1125,23 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a
|
|||
(var) = (tvar))
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__Userspace_os_DragonFly)
|
||||
#if defined(__DragonFly__)
|
||||
#define TAILQ_FOREACH_SAFE TAILQ_FOREACH_MUTABLE
|
||||
#define LIST_FOREACH_SAFE LIST_FOREACH_MUTABLE
|
||||
#endif
|
||||
|
||||
#if defined(__Userspace_os_NaCl)
|
||||
#if defined(__native_client__)
|
||||
#define timercmp(tvp, uvp, cmp) \
|
||||
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
|
||||
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
|
||||
((tvp)->tv_sec cmp (uvp)->tv_sec))
|
||||
#endif
|
||||
|
||||
#define SCTP_IS_LISTENING(inp) ((inp->sctp_flags & SCTP_PCB_FLAGS_ACCEPTING) != 0)
|
||||
|
||||
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(_WIN32) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
|
||||
int
|
||||
timingsafe_bcmp(const void *, const void *, size_t);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 272751 2014-10-08 15:30:59Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_OUTPUT_H_
|
||||
|
@ -42,76 +44,68 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 272751 2014-10-08 15:30:59Z t
|
|||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
|
||||
|
||||
struct mbuf *
|
||||
sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb,
|
||||
struct sctp_scoping *scope,
|
||||
struct mbuf *m_at,
|
||||
int cnt_inits_to,
|
||||
uint16_t *padding_len, uint16_t *chunk_len);
|
||||
|
||||
struct sctp_scoping *scope,
|
||||
struct mbuf *m_at,
|
||||
int cnt_inits_to,
|
||||
uint16_t *padding_len, uint16_t *chunk_len);
|
||||
|
||||
int sctp_is_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
|
||||
|
||||
|
||||
int
|
||||
sctp_is_address_in_scope(struct sctp_ifa *ifa,
|
||||
struct sctp_scoping *scope,
|
||||
int do_update);
|
||||
int do_update);
|
||||
|
||||
int
|
||||
sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa);
|
||||
|
||||
struct sctp_ifa *
|
||||
sctp_source_address_selection(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb,
|
||||
sctp_route_t *ro, struct sctp_nets *net,
|
||||
int non_asoc_addr_ok, uint32_t vrf_id);
|
||||
struct sctp_tcb *stcb,
|
||||
sctp_route_t *ro, struct sctp_nets *net,
|
||||
int non_asoc_addr_ok, uint32_t vrf_id);
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__)
|
||||
int
|
||||
sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro);
|
||||
int
|
||||
sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro);
|
||||
int sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro);
|
||||
|
||||
int sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro);
|
||||
#endif
|
||||
|
||||
void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int
|
||||
#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
);
|
||||
void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int);
|
||||
|
||||
void
|
||||
sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *, struct mbuf *,
|
||||
sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *, struct mbuf *,
|
||||
int, int,
|
||||
struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, struct sctp_init_chunk *,
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t,
|
||||
#endif
|
||||
uint32_t, uint16_t, int);
|
||||
uint32_t, uint16_t);
|
||||
|
||||
struct mbuf *
|
||||
sctp_arethere_unrecognized_parameters(struct mbuf *, int, int *,
|
||||
struct sctp_chunkhdr *, int *);
|
||||
struct sctp_chunkhdr *, int *, int *);
|
||||
void sctp_queue_op_err(struct sctp_tcb *, struct mbuf *);
|
||||
|
||||
int
|
||||
sctp_send_cookie_echo(struct mbuf *, int, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
sctp_send_cookie_echo(struct mbuf *, int, int, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
void sctp_send_cookie_ack(struct sctp_tcb *);
|
||||
|
||||
void
|
||||
sctp_send_heartbeat_ack(struct sctp_tcb *, struct mbuf *, int, int,
|
||||
struct sctp_nets *);
|
||||
struct sctp_nets *);
|
||||
|
||||
void
|
||||
sctp_remove_from_wheel(struct sctp_tcb *stcb,
|
||||
struct sctp_association *asoc,
|
||||
struct sctp_stream_out *strq, int holds_lock);
|
||||
|
||||
struct sctp_association *asoc,
|
||||
struct sctp_stream_out *strq, int holds_lock);
|
||||
|
||||
void sctp_send_shutdown(struct sctp_tcb *, struct sctp_nets *);
|
||||
|
||||
|
@ -121,8 +115,8 @@ void sctp_send_shutdown_complete(struct sctp_tcb *, struct sctp_nets *, int);
|
|||
|
||||
void sctp_send_shutdown_complete2(struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *,
|
||||
#if defined(__FreeBSD__)
|
||||
uint8_t, uint32_t,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t, uint16_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
|
||||
|
@ -130,7 +124,7 @@ void sctp_send_asconf(struct sctp_tcb *, struct sctp_nets *, int addr_locked);
|
|||
|
||||
void sctp_send_asconf_ack(struct sctp_tcb *);
|
||||
|
||||
int sctp_get_frag_point(struct sctp_tcb *, struct sctp_association *);
|
||||
uint32_t sctp_get_frag_point(struct sctp_tcb *);
|
||||
|
||||
void sctp_toss_old_cookies(struct sctp_tcb *, struct sctp_association *);
|
||||
|
||||
|
@ -140,11 +134,15 @@ void sctp_fix_ecn_echo(struct sctp_association *);
|
|||
|
||||
void sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net);
|
||||
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
|
||||
#define SCTP_DATA_CHUNK_OVERHEAD(stcb) ((stcb)->asoc.idata_supported ? \
|
||||
sizeof(struct sctp_idata_chunk) : \
|
||||
sizeof(struct sctp_data_chunk))
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
int
|
||||
sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
|
||||
struct mbuf *, struct thread *, int);
|
||||
#elif defined(__Windows__)
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
|
||||
struct mbuf *, PKTHREAD, int);
|
||||
#else
|
||||
|
@ -153,30 +151,15 @@ sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
|
|||
#endif
|
||||
int
|
||||
sctp_output(struct sctp_inpcb *,
|
||||
#if defined(__Panda__)
|
||||
pakhandle_type,
|
||||
#else
|
||||
struct mbuf *,
|
||||
#endif
|
||||
struct sockaddr *,
|
||||
#if defined(__Panda__)
|
||||
pakhandle_type,
|
||||
#else
|
||||
struct mbuf *,
|
||||
#endif
|
||||
struct proc *, int);
|
||||
#endif
|
||||
|
||||
void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int
|
||||
#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
);
|
||||
void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int
|
||||
#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
);
|
||||
void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int);
|
||||
|
||||
void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int);
|
||||
|
||||
void send_forward_tsn(struct sctp_tcb *, struct sctp_association *);
|
||||
|
||||
|
@ -186,45 +169,45 @@ void sctp_send_hb(struct sctp_tcb *, struct sctp_nets *, int);
|
|||
|
||||
void sctp_send_ecn_echo(struct sctp_tcb *, struct sctp_nets *, uint32_t);
|
||||
|
||||
|
||||
void
|
||||
sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *,
|
||||
int, int, int);
|
||||
|
||||
|
||||
|
||||
void sctp_send_cwr(struct sctp_tcb *, struct sctp_nets *, uint32_t, uint8_t);
|
||||
|
||||
|
||||
void
|
||||
sctp_add_stream_reset_out(struct sctp_tmit_chunk *,
|
||||
int, uint16_t *, uint32_t, uint32_t, uint32_t);
|
||||
|
||||
void
|
||||
sctp_add_stream_reset_result(struct sctp_tmit_chunk *, uint32_t, uint32_t);
|
||||
|
||||
void
|
||||
sctp_send_deferred_reset_response(struct sctp_tcb *,
|
||||
struct sctp_stream_reset_list *,
|
||||
int);
|
||||
|
||||
void
|
||||
sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *,
|
||||
uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
int
|
||||
sctp_send_stream_reset_out_if_possible(struct sctp_tcb *, int);
|
||||
|
||||
int
|
||||
sctp_send_str_reset_req(struct sctp_tcb *, uint16_t , uint16_t *, uint8_t,
|
||||
sctp_send_str_reset_req(struct sctp_tcb *, uint16_t , uint16_t *,
|
||||
uint8_t, uint8_t, uint8_t, uint16_t, uint16_t, uint8_t);
|
||||
|
||||
void
|
||||
sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, uint32_t, struct mbuf *,
|
||||
#if defined(__FreeBSD__)
|
||||
uint8_t, uint32_t,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t, uint16_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
|
||||
void sctp_send_operr_to(struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, uint32_t, struct mbuf *,
|
||||
#if defined(__FreeBSD__)
|
||||
uint8_t, uint32_t,
|
||||
void
|
||||
sctp_send_operr_to(struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, uint32_t, struct mbuf *,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t, uint16_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
uint32_t, uint16_t);
|
||||
|
||||
#endif /* _KERNEL || __Userspace__ */
|
||||
|
||||
|
@ -233,20 +216,15 @@ int
|
|||
sctp_sosend(struct socket *so,
|
||||
struct sockaddr *addr,
|
||||
struct uio *uio,
|
||||
#ifdef __Panda__
|
||||
pakhandle_type top,
|
||||
pakhandle_type control,
|
||||
#else
|
||||
struct mbuf *top,
|
||||
struct mbuf *control,
|
||||
#endif
|
||||
#if defined(__APPLE__) || defined(__Panda__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
int flags
|
||||
#else
|
||||
int flags,
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct thread *p
|
||||
#elif defined(__Windows__)
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
PKTHREAD p
|
||||
#else
|
||||
#if defined(__Userspace__)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 279859 2015-03-10 19:49:25Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_PCB_H_
|
||||
|
@ -109,7 +111,7 @@ struct sctp_ifa {
|
|||
* appropriate locks. This is for V6.
|
||||
*/
|
||||
union sctp_sockstore address;
|
||||
uint32_t refcount; /* number of folks refering to this */
|
||||
uint32_t refcount; /* number of folks referring to this */
|
||||
uint32_t flags;
|
||||
uint32_t localifa_flags;
|
||||
uint32_t vrf_id; /* vrf_id of this addr (for deleting) */
|
||||
|
@ -145,9 +147,8 @@ struct sctp_tagblock {
|
|||
struct sctp_timewait vtag_block[SCTP_NUMBER_IN_VTAG_BLOCK];
|
||||
};
|
||||
|
||||
|
||||
struct sctp_epinfo {
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#ifdef INET
|
||||
struct socket *udp4_tun_socket;
|
||||
#endif
|
||||
|
@ -187,7 +188,7 @@ struct sctp_epinfo {
|
|||
struct sctppcbhead listhead;
|
||||
struct sctpladdr addr_wq;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
struct inpcbhead inplisthead;
|
||||
struct inpcbinfo sctbinfo;
|
||||
#endif
|
||||
|
@ -202,27 +203,19 @@ struct sctp_epinfo {
|
|||
sctp_zone_t ipi_zone_asconf;
|
||||
sctp_zone_t ipi_zone_asconf_ack;
|
||||
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 503000
|
||||
#if __FreeBSD_version <= 602000
|
||||
struct mtx ipi_ep_mtx;
|
||||
#else
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct rwlock ipi_ep_mtx;
|
||||
#endif
|
||||
struct mtx ipi_iterator_wq_mtx;
|
||||
#if __FreeBSD_version <= 602000
|
||||
struct mtx ipi_addr_mtx;
|
||||
#else
|
||||
struct rwlock ipi_addr_mtx;
|
||||
#endif
|
||||
struct mtx ipi_pktlog_mtx;
|
||||
struct mtx wq_addr_mtx;
|
||||
#elif defined(SCTP_PROCESS_LEVEL_LOCKS)
|
||||
userland_mutex_t ipi_ep_mtx;
|
||||
userland_mutex_t ipi_addr_mtx;
|
||||
userland_rwlock_t ipi_ep_mtx;
|
||||
userland_rwlock_t ipi_addr_mtx;
|
||||
userland_mutex_t ipi_count_mtx;
|
||||
userland_mutex_t ipi_pktlog_mtx;
|
||||
userland_mutex_t wq_addr_mtx;
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) && !defined(__Userspace__)
|
||||
#ifdef _KERN_LOCKS_H_
|
||||
lck_mtx_t *ipi_addr_mtx;
|
||||
lck_mtx_t *ipi_count_mtx;
|
||||
|
@ -233,13 +226,12 @@ struct sctp_epinfo {
|
|||
void *ipi_count_mtx;
|
||||
void *logging_mtx;
|
||||
#endif /* _KERN_LOCKS_H_ */
|
||||
#elif defined(__Windows__)
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
struct rwlock ipi_ep_lock;
|
||||
struct rwlock ipi_addr_lock;
|
||||
struct spinlock ipi_pktlog_mtx;
|
||||
struct rwlock wq_addr_mtx;
|
||||
#elif defined(__Userspace__)
|
||||
/* TODO decide on __Userspace__ locks */
|
||||
#endif
|
||||
uint32_t ipi_count_ep;
|
||||
|
||||
|
@ -284,14 +276,17 @@ struct sctp_epinfo {
|
|||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct sctp_base_info {
|
||||
/* All static structures that
|
||||
* anchor the system must be here.
|
||||
*/
|
||||
struct sctp_epinfo sctppcbinfo;
|
||||
#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
|
||||
struct sctpstat *sctpstat;
|
||||
#else
|
||||
struct sctpstat sctpstat;
|
||||
#endif
|
||||
#else
|
||||
struct sctpstat sctpstat;
|
||||
#endif
|
||||
|
@ -303,33 +298,51 @@ struct sctp_base_info {
|
|||
int packet_log_end;
|
||||
uint8_t packet_log_buffer[SCTP_PACKET_LOG_SIZE];
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
eventhandler_tag eh_tag;
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
int sctp_main_timer_ticks;
|
||||
#endif
|
||||
#if defined(__Userspace__)
|
||||
userland_mutex_t timer_mtx;
|
||||
userland_thread_t timer_thread;
|
||||
uint8_t timer_thread_should_exit;
|
||||
#if !defined(__Userspace_os_Windows)
|
||||
int timer_thread_should_exit;
|
||||
int iterator_thread_started;
|
||||
int timer_thread_started;
|
||||
#if !defined(_WIN32)
|
||||
pthread_mutexattr_t mtx_attr;
|
||||
pthread_rwlockattr_t rwlock_attr;
|
||||
#if defined(INET) || defined(INET6)
|
||||
int userspace_route;
|
||||
userland_thread_t recvthreadroute;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef INET
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
SOCKET userspace_rawsctp;
|
||||
SOCKET userspace_udpsctp;
|
||||
#else
|
||||
int userspace_rawsctp;
|
||||
int userspace_udpsctp;
|
||||
#endif
|
||||
userland_thread_t recvthreadraw;
|
||||
userland_thread_t recvthreadudp;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
SOCKET userspace_rawsctp6;
|
||||
SOCKET userspace_udpsctp6;
|
||||
#else
|
||||
int userspace_rawsctp6;
|
||||
int userspace_udpsctp6;
|
||||
#endif
|
||||
userland_thread_t recvthreadraw6;
|
||||
userland_thread_t recvthreadudp6;
|
||||
#endif
|
||||
int (*conn_output)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df);
|
||||
void (*debug_printf)(const char *format, ...);
|
||||
int crc32c_offloaded;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -344,11 +357,11 @@ struct sctp_pcb {
|
|||
uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS];
|
||||
unsigned int size_of_a_cookie;
|
||||
|
||||
unsigned int sctp_timeoutticks[SCTP_NUM_TMRS];
|
||||
unsigned int sctp_minrto;
|
||||
unsigned int sctp_maxrto;
|
||||
unsigned int initial_rto;
|
||||
int initial_init_rto_max;
|
||||
uint32_t sctp_timeoutticks[SCTP_NUM_TMRS];
|
||||
uint32_t sctp_minrto;
|
||||
uint32_t sctp_maxrto;
|
||||
uint32_t initial_rto;
|
||||
uint32_t initial_init_rto_max;
|
||||
|
||||
unsigned int sctp_sack_freq;
|
||||
uint32_t sctp_sws_sender;
|
||||
|
@ -361,6 +374,7 @@ struct sctp_pcb {
|
|||
sctp_auth_chklist_t *local_auth_chunks;
|
||||
sctp_hmaclist_t *local_hmacs;
|
||||
uint16_t default_keyid;
|
||||
uint32_t default_mtu;
|
||||
|
||||
/* various thresholds */
|
||||
/* Max times I will init at a guy */
|
||||
|
@ -388,13 +402,9 @@ struct sctp_pcb {
|
|||
*/
|
||||
struct sctp_timer signature_change;
|
||||
|
||||
/* Zero copy full buffer timer */
|
||||
struct sctp_timer zero_copy_timer;
|
||||
/* Zero copy app to transport (sendq) read repulse timer */
|
||||
struct sctp_timer zero_copy_sendq_timer;
|
||||
uint32_t def_cookie_life;
|
||||
/* defaults to 0 */
|
||||
int auto_close_time;
|
||||
uint32_t auto_close_time;
|
||||
uint32_t initial_sequence_debug;
|
||||
uint32_t adaptation_layer_indicator;
|
||||
uint8_t adaptation_layer_indicator_provided;
|
||||
|
@ -429,19 +439,17 @@ struct sctp_pcbtsn_rlog {
|
|||
};
|
||||
#define SCTP_READ_LOG_SIZE 135 /* we choose the number to make a pcb a page */
|
||||
|
||||
|
||||
struct sctp_inpcb {
|
||||
/*-
|
||||
* put an inpcb in front of it all, kind of a waste but we need to
|
||||
* for compatability with all the other stuff.
|
||||
* for compatibility with all the other stuff.
|
||||
*/
|
||||
union {
|
||||
struct inpcb inp;
|
||||
char align[(sizeof(struct in6pcb) + SCTP_ALIGNM1) &
|
||||
char align[(sizeof(struct inpcb) + SCTP_ALIGNM1) &
|
||||
~SCTP_ALIGNM1];
|
||||
} ip_inp;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
/* leave some space in case i386 inpcb is bigger than ppc */
|
||||
uint8_t padding[128];
|
||||
#endif
|
||||
|
@ -450,7 +458,7 @@ struct sctp_inpcb {
|
|||
struct sctp_readhead read_queue;
|
||||
|
||||
LIST_ENTRY(sctp_inpcb) sctp_list; /* lists all endpoints */
|
||||
/* hash of all endpoints for model */
|
||||
/* hash of all endpoints for model */
|
||||
LIST_ENTRY(sctp_inpcb) sctp_hash;
|
||||
/* count of local addresses bound, 0 if bound all */
|
||||
int laddr_count;
|
||||
|
@ -474,7 +482,6 @@ struct sctp_inpcb {
|
|||
#ifdef SCTP_TRACK_FREED_ASOCS
|
||||
struct sctpasochead sctp_asoc_free_list;
|
||||
#endif
|
||||
struct sctp_iterator *inp_starting_point_for_iterator;
|
||||
uint32_t sctp_frag_point;
|
||||
uint32_t partial_delivery_point;
|
||||
uint32_t sctp_context;
|
||||
|
@ -484,10 +491,12 @@ struct sctp_inpcb {
|
|||
uint8_t ecn_supported;
|
||||
uint8_t prsctp_supported;
|
||||
uint8_t auth_supported;
|
||||
uint8_t idata_supported;
|
||||
uint8_t asconf_supported;
|
||||
uint8_t reconfig_supported;
|
||||
uint8_t nrsack_supported;
|
||||
uint8_t pktdrop_supported;
|
||||
uint8_t zero_checksum;
|
||||
struct sctp_nonpad_sndrcvinfo def_send;
|
||||
/*-
|
||||
* These three are here for the sosend_dgram
|
||||
|
@ -497,26 +506,9 @@ struct sctp_inpcb {
|
|||
* they are candidates with sctp_sendm for
|
||||
* de-supporting.
|
||||
*/
|
||||
#ifdef __Panda__
|
||||
pakhandle_type pak_to_read;
|
||||
pakhandle_type pak_to_read_sendq;
|
||||
#endif
|
||||
struct mbuf *pkt, *pkt_last;
|
||||
struct mbuf *control;
|
||||
#if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__))
|
||||
#ifndef INP_IPV6
|
||||
#define INP_IPV6 0x1
|
||||
#endif
|
||||
#ifndef INP_IPV4
|
||||
#define INP_IPV4 0x2
|
||||
#endif
|
||||
uint8_t inp_vflag;
|
||||
/* TODO __Userspace__ where is our inp_vlag going to be? */
|
||||
uint8_t inp_ip_ttl;
|
||||
uint8_t inp_ip_tos; /* defined as macro in user_inpcb.h */
|
||||
uint8_t inp_ip_resv;
|
||||
#endif
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 503000
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct mtx inp_mtx;
|
||||
struct mtx inp_create_mtx;
|
||||
struct mtx inp_rdata_mtx;
|
||||
|
@ -526,7 +518,7 @@ struct sctp_inpcb {
|
|||
userland_mutex_t inp_create_mtx;
|
||||
userland_mutex_t inp_rdata_mtx;
|
||||
int32_t refcount;
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) && !defined(__Userspace__)
|
||||
#if defined(SCTP_APPLE_RWLOCK)
|
||||
lck_rw_t *inp_mtx;
|
||||
#else
|
||||
|
@ -534,16 +526,15 @@ struct sctp_inpcb {
|
|||
#endif
|
||||
lck_mtx_t *inp_create_mtx;
|
||||
lck_mtx_t *inp_rdata_mtx;
|
||||
#elif defined(__Windows__)
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
struct rwlock inp_lock;
|
||||
struct spinlock inp_create_lock;
|
||||
struct spinlock inp_rdata_lock;
|
||||
int32_t refcount;
|
||||
#elif defined(__Userspace__)
|
||||
/* TODO decide on __Userspace__ locks */
|
||||
int32_t refcount;
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
int32_t refcount;
|
||||
|
||||
uint32_t lock_caller1;
|
||||
|
@ -564,6 +555,7 @@ struct sctp_inpcb {
|
|||
uint32_t i_am_here_line;
|
||||
#endif
|
||||
uint32_t def_vrf_id;
|
||||
uint16_t fibnum;
|
||||
#ifdef SCTP_MVRF
|
||||
uint32_t *m_vrf_ids;
|
||||
uint32_t num_vrfs;
|
||||
|
@ -586,7 +578,7 @@ struct sctp_inpcb {
|
|||
int (*recv_callback)(struct socket *, union sctp_sockstore, void *, size_t,
|
||||
struct sctp_rcvinfo, int, void *);
|
||||
uint32_t send_sb_threshold;
|
||||
int (*send_callback)(struct socket *, uint32_t);
|
||||
int (*send_callback)(struct socket *, uint32_t, void *);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -594,8 +586,9 @@ struct sctp_inpcb {
|
|||
int register_recv_cb (struct socket *,
|
||||
int (*)(struct socket *, union sctp_sockstore, void *, size_t,
|
||||
struct sctp_rcvinfo, int, void *));
|
||||
int register_send_cb (struct socket *, uint32_t, int (*)(struct socket *, uint32_t));
|
||||
int register_send_cb (struct socket *, uint32_t, int (*)(struct socket *, uint32_t, void *));
|
||||
int register_ulp_info (struct socket *, void *);
|
||||
int retrieve_ulp_info (struct socket *, void **);
|
||||
|
||||
#endif
|
||||
struct sctp_tcb {
|
||||
|
@ -623,34 +616,26 @@ struct sctp_tcb {
|
|||
int freed_from_where;
|
||||
uint16_t rport; /* remote port in network format */
|
||||
uint16_t resv;
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 503000
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct mtx tcb_mtx;
|
||||
struct mtx tcb_send_mtx;
|
||||
#elif defined(SCTP_PROCESS_LEVEL_LOCKS)
|
||||
userland_mutex_t tcb_mtx;
|
||||
userland_mutex_t tcb_send_mtx;
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) && !defined(__Userspace__)
|
||||
lck_mtx_t* tcb_mtx;
|
||||
lck_mtx_t* tcb_send_mtx;
|
||||
#elif defined(__Windows__)
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
struct spinlock tcb_lock;
|
||||
struct spinlock tcb_send_lock;
|
||||
#elif defined(__Userspace__)
|
||||
/* TODO decide on __Userspace__ locks */
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
uint32_t caller1;
|
||||
uint32_t caller2;
|
||||
uint32_t caller3;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 503000
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <netinet/sctp_lock_bsd.h>
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) && !defined(__Userspace__)
|
||||
/*
|
||||
* Apple MacOS X 10.4 "Tiger"
|
||||
*/
|
||||
|
@ -661,7 +646,7 @@ struct sctp_tcb {
|
|||
|
||||
#include <netinet/sctp_process_lock.h>
|
||||
|
||||
#elif defined(__Windows__)
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
|
||||
#include <netinet/sctp_lock_windows.h>
|
||||
|
||||
|
@ -676,15 +661,14 @@ struct sctp_tcb {
|
|||
#include <netinet/sctp_lock_empty.h>
|
||||
#endif
|
||||
|
||||
/* TODO where to put non-_KERNEL things for __Userspace__? */
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
|
||||
/* Attention Julian, this is the extern that
|
||||
* goes with the base info. sctp_pcb.c has
|
||||
* the real definition.
|
||||
*/
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 801000
|
||||
VNET_DECLARE(struct sctp_base_info, system_base_info) ;
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
VNET_DECLARE(struct sctp_base_info, system_base_info);
|
||||
#else
|
||||
extern struct sctp_base_info system_base_info;
|
||||
#endif
|
||||
|
@ -726,26 +710,35 @@ void sctp_update_ifn_mtu(uint32_t ifn_index, uint32_t mtu);
|
|||
void sctp_free_ifn(struct sctp_ifn *sctp_ifnp);
|
||||
void sctp_free_ifa(struct sctp_ifa *sctp_ifap);
|
||||
|
||||
|
||||
void sctp_del_addr_from_vrf(uint32_t vrfid, struct sockaddr *addr,
|
||||
uint32_t ifn_index, const char *if_name);
|
||||
|
||||
|
||||
|
||||
struct sctp_nets *sctp_findnet(struct sctp_tcb *, struct sockaddr *);
|
||||
|
||||
struct sctp_inpcb *sctp_pcb_findep(struct sockaddr *, int, int, uint32_t);
|
||||
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
|
||||
int sctp_inpcb_bind(struct socket *, struct sockaddr *,
|
||||
struct sctp_ifa *,struct thread *);
|
||||
#elif defined(__Windows__)
|
||||
int sctp_inpcb_bind(struct socket *, struct sockaddr *,
|
||||
struct sctp_ifa *,PKTHREAD);
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
int
|
||||
sctp_inpcb_bind(struct socket *, struct sockaddr *,
|
||||
struct sctp_ifa *, struct thread *);
|
||||
int
|
||||
sctp_inpcb_bind_locked(struct sctp_inpcb *, struct sockaddr *,
|
||||
struct sctp_ifa *, struct thread *);
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
int
|
||||
sctp_inpcb_bind(struct socket *, struct sockaddr *,
|
||||
struct sctp_ifa *, PKTHREAD);
|
||||
int
|
||||
sctp_inpcb_bind_locked(struct sctp_inpcb *, struct sockaddr *,
|
||||
struct sctp_ifa *, PKTHREAD);
|
||||
#else
|
||||
/* struct proc is a dummy for __Userspace__ */
|
||||
int sctp_inpcb_bind(struct socket *, struct sockaddr *,
|
||||
struct sctp_ifa *, struct proc *);
|
||||
int
|
||||
sctp_inpcb_bind(struct socket *, struct sockaddr *,
|
||||
struct sctp_ifa *, struct proc *);
|
||||
int
|
||||
sctp_inpcb_bind_locked(struct sctp_inpcb *, struct sockaddr *,
|
||||
struct sctp_ifa *, struct proc *);
|
||||
#endif
|
||||
|
||||
struct sctp_tcb *
|
||||
|
@ -790,46 +783,52 @@ int sctp_is_address_on_local_host(struct sockaddr *addr, uint32_t vrf_id);
|
|||
|
||||
void sctp_inpcb_free(struct sctp_inpcb *, int, int);
|
||||
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
|
||||
#define SCTP_DONT_INITIALIZE_AUTH_PARAMS 0
|
||||
#define SCTP_INITIALIZE_AUTH_PARAMS 1
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct sctp_tcb *
|
||||
sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
|
||||
int *, uint32_t, uint32_t, struct thread *);
|
||||
#elif defined(__Windows__)
|
||||
int *, uint32_t, uint32_t, uint32_t, uint16_t, uint16_t,
|
||||
struct thread *, int);
|
||||
struct sctp_tcb *
|
||||
sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
|
||||
int *, uint32_t, uint32_t, PKTHREAD);
|
||||
sctp_aloc_assoc_connected(struct sctp_inpcb *, struct sockaddr *,
|
||||
int *, uint32_t, uint32_t, uint32_t, uint16_t, uint16_t,
|
||||
struct thread *, int);
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
struct sctp_tcb *
|
||||
sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *, int *, uint32_t,
|
||||
uint32_t, uint32_t, uint16_t, uint16_t, PKTHREAD, int);
|
||||
struct sctp_tcb *
|
||||
sctp_aloc_assoc_connected(struct sctp_inpcb *, struct sockaddr *, int *, uint32_t,
|
||||
uint32_t, uint32_t, uint16_t, uint16_t, PKTHREAD, int);
|
||||
#else
|
||||
/* proc will be NULL for __Userspace__ */
|
||||
struct sctp_tcb *
|
||||
sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
|
||||
int *, uint32_t, uint32_t, struct proc *);
|
||||
sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *, int *, uint32_t,
|
||||
uint32_t, uint32_t, uint16_t, uint16_t, struct proc *, int);
|
||||
struct sctp_tcb *
|
||||
sctp_aloc_assoc_connected(struct sctp_inpcb *, struct sockaddr *, int *, uint32_t,
|
||||
uint32_t, uint32_t, uint16_t, uint16_t, struct proc *, int);
|
||||
#endif
|
||||
|
||||
int sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *, int, int);
|
||||
|
||||
|
||||
void sctp_delete_from_timewait(uint32_t, uint16_t, uint16_t);
|
||||
|
||||
int sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport);
|
||||
|
||||
void
|
||||
sctp_add_vtag_to_timewait(uint32_t tag, uint32_t time, uint16_t lport, uint16_t rport);
|
||||
|
||||
void sctp_add_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *, uint32_t);
|
||||
|
||||
int sctp_insert_laddr(struct sctpladdr *, struct sctp_ifa *, uint32_t);
|
||||
|
||||
void sctp_remove_laddr(struct sctp_laddr *);
|
||||
|
||||
void sctp_del_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *);
|
||||
|
||||
int sctp_add_remote_addr(struct sctp_tcb *, struct sockaddr *, struct sctp_nets **, int, int);
|
||||
int sctp_add_remote_addr(struct sctp_tcb *, struct sockaddr *, struct sctp_nets **, uint16_t, int, int);
|
||||
|
||||
void sctp_remove_net(struct sctp_tcb *, struct sctp_nets *);
|
||||
|
||||
int sctp_del_remote_addr(struct sctp_tcb *, struct sockaddr *);
|
||||
|
||||
#if defined(__Userspace__)
|
||||
void sctp_pcb_init(int);
|
||||
#else
|
||||
void sctp_pcb_init(void);
|
||||
#endif
|
||||
|
||||
void sctp_pcb_finish(void);
|
||||
|
||||
|
@ -838,19 +837,24 @@ void sctp_del_local_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
|
|||
|
||||
int
|
||||
sctp_load_addresses_from_init(struct sctp_tcb *, struct mbuf *, int, int,
|
||||
struct sockaddr *, struct sockaddr *, struct sockaddr *);
|
||||
struct sockaddr *, struct sockaddr *, struct sockaddr *, uint16_t);
|
||||
|
||||
int
|
||||
sctp_set_primary_addr(struct sctp_tcb *, struct sockaddr *,
|
||||
struct sctp_nets *);
|
||||
|
||||
int sctp_is_vtag_good(uint32_t, uint16_t lport, uint16_t rport, struct timeval *);
|
||||
|
||||
bool
|
||||
sctp_is_vtag_good(uint32_t, uint16_t lport, uint16_t rport, struct timeval *);
|
||||
|
||||
int sctp_destination_is_reachable(struct sctp_tcb *, struct sockaddr *);
|
||||
|
||||
int sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp);
|
||||
|
||||
void sctp_clean_up_stream(struct sctp_tcb *stcb, struct sctp_readhead *rh);
|
||||
|
||||
void
|
||||
sctp_pcb_add_flags(struct sctp_inpcb *, uint32_t);
|
||||
|
||||
/*-
|
||||
* Null in last arg inpcb indicate run on ALL ep's. Specific inp in last arg
|
||||
* indicates run on ONLY assoc's of the specified endpoint.
|
||||
|
@ -865,15 +869,12 @@ sctp_initiate_iterator(inp_func inpf,
|
|||
end_func ef,
|
||||
struct sctp_inpcb *,
|
||||
uint8_t co_off);
|
||||
#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#if defined(SCTP_MCORE_INPUT) && defined(SMP)
|
||||
void
|
||||
sctp_queue_to_mcore(struct mbuf *m, int off, int cpu_to_use);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef INVARIANTS
|
||||
void
|
||||
sctp_validate_no_locks(struct sctp_inpcb *inp);
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 279859 2015-03-10 19:49:25Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#include <netinet/sctp_os.h>
|
||||
|
@ -47,10 +49,6 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 279859 2015-03-10 19:49:25Z
|
|||
#include <netinet/sctputil.h>
|
||||
#include <netinet/sctp_auth.h>
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define APPLE_FILE_NO 5
|
||||
#endif
|
||||
|
||||
int
|
||||
sctp_can_peel_off(struct socket *head, sctp_assoc_t assoc_id)
|
||||
{
|
||||
|
@ -77,7 +75,7 @@ sctp_can_peel_off(struct socket *head, sctp_assoc_t assoc_id)
|
|||
SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_PEELOFF, ENOENT);
|
||||
return (ENOENT);
|
||||
}
|
||||
state = SCTP_GET_STATE((&stcb->asoc));
|
||||
state = SCTP_GET_STATE(stcb);
|
||||
if ((state == SCTP_STATE_EMPTY) ||
|
||||
(state == SCTP_STATE_INUSE)) {
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
|
@ -107,7 +105,7 @@ sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id)
|
|||
return (ENOTCONN);
|
||||
}
|
||||
|
||||
state = SCTP_GET_STATE((&stcb->asoc));
|
||||
state = SCTP_GET_STATE(stcb);
|
||||
if ((state == SCTP_STATE_EMPTY) ||
|
||||
(state == SCTP_STATE_INUSE)) {
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
|
@ -136,7 +134,6 @@ sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id)
|
|||
n_inp->sctp_context = inp->sctp_context;
|
||||
n_inp->max_cwnd = inp->max_cwnd;
|
||||
n_inp->local_strreset_support = inp->local_strreset_support;
|
||||
n_inp->inp_starting_point_for_iterator = NULL;
|
||||
/* copy in the authentication parameters from the original endpoint */
|
||||
if (n_inp->sctp_ep.local_hmacs)
|
||||
sctp_free_hmaclist(n_inp->sctp_ep.local_hmacs);
|
||||
|
@ -162,7 +159,7 @@ sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id)
|
|||
atomic_add_int(&stcb->asoc.refcnt, 1);
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, SBL_WAIT);
|
||||
#else
|
||||
sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, M_WAITOK);
|
||||
|
@ -176,14 +173,6 @@ sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id)
|
|||
struct socket *
|
||||
sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
|
||||
{
|
||||
#if defined(__Userspace__)
|
||||
/* if __Userspace__ chooses to originally not support peeloff, put it here... */
|
||||
#endif
|
||||
#if defined(__Panda__)
|
||||
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, EINVAL);
|
||||
*error = EINVAL;
|
||||
return (NULL);
|
||||
#else
|
||||
struct socket *newso;
|
||||
struct sctp_inpcb *inp, *n_inp;
|
||||
struct sctp_tcb *stcb;
|
||||
|
@ -203,18 +192,15 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
|
|||
}
|
||||
atomic_add_int(&stcb->asoc.refcnt, 1);
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 801000
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
CURVNET_SET(head->so_vnet);
|
||||
#endif
|
||||
newso = sonewconn(head, SS_ISCONNECTED
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
, NULL
|
||||
#elif defined(__Panda__)
|
||||
/* place this socket in the assoc's vrf id */
|
||||
, NULL, stcb->asoc.vrf_id
|
||||
#endif
|
||||
);
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 801000
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
CURVNET_RESTORE();
|
||||
#endif
|
||||
if (newso == NULL) {
|
||||
|
@ -225,7 +211,7 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
|
|||
return (NULL);
|
||||
|
||||
}
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
else {
|
||||
SCTP_SOCKET_LOCK(newso, 1);
|
||||
}
|
||||
|
@ -277,14 +263,15 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
|
|||
sctp_feature_off(n_inp, SCTP_PCB_FLAGS_AUTOCLOSE);
|
||||
n_inp->sctp_ep.auto_close_time = 0;
|
||||
sctp_timer_stop(SCTP_TIMER_TYPE_AUTOCLOSE, n_inp, stcb, NULL,
|
||||
SCTP_FROM_SCTP_PEELOFF+SCTP_LOC_1);
|
||||
SCTP_FROM_SCTP_PEELOFF + SCTP_LOC_1);
|
||||
}
|
||||
/* Turn off any non-blocking semantic. */
|
||||
SOCK_LOCK(newso);
|
||||
SCTP_CLEAR_SO_NBIO(newso);
|
||||
newso->so_state |= SS_ISCONNECTED;
|
||||
newso->so_state |= SS_ISCONNECTED;
|
||||
SOCK_UNLOCK(newso);
|
||||
/* We remove it right away */
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) {
|
||||
sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK);
|
||||
|
@ -293,34 +280,23 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
|
|||
TAILQ_REMOVE(&head->so_comp, newso, so_list);
|
||||
head->so_qlen--;
|
||||
SOCK_UNLOCK(head);
|
||||
#else
|
||||
newso = TAILQ_FIRST(&head->so_q);
|
||||
if (soqremque(newso, 1) == 0) {
|
||||
SCTP_PRINTF("soremque failed, peeloff-fails (invarients would panic)\n");
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, ENOTCONN);
|
||||
*error = ENOTCONN;
|
||||
return (NULL);
|
||||
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Now we must move it from one hash table to another and get the
|
||||
* stcb in the right place.
|
||||
*/
|
||||
sctp_move_pcb_and_assoc(inp, n_inp, stcb);
|
||||
sctp_move_pcb_and_assoc(inp, n_inp, stcb);
|
||||
atomic_add_int(&stcb->asoc.refcnt, 1);
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
/*
|
||||
* And now the final hack. We move data in the pending side i.e.
|
||||
* head to the new socket buffer. Let the GRUBBING begin :-0
|
||||
*/
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, SBL_WAIT);
|
||||
#else
|
||||
sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, M_WAITOK);
|
||||
#endif
|
||||
atomic_subtract_int(&stcb->asoc.refcnt, 1);
|
||||
return (newso);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.h 243516 2012-11-25 14:25:08Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_PEELOFF_H_
|
||||
|
@ -40,13 +42,13 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.h 243516 2012-11-25 14:25:08Z
|
|||
#if defined(HAVE_SCTP_PEELOFF_SOCKOPT)
|
||||
/* socket option peeloff */
|
||||
struct sctp_peeloff_opt {
|
||||
#if !defined(__Windows__)
|
||||
#if !(defined(_WIN32) && !defined(__Userspace__))
|
||||
int s;
|
||||
#else
|
||||
HANDLE s;
|
||||
#endif
|
||||
sctp_assoc_t assoc_id;
|
||||
#if !defined(__Windows__)
|
||||
#if !(defined(_WIN32) && !defined(__Userspace__))
|
||||
int new_sd;
|
||||
#else
|
||||
HANDLE new_sd;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2011, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved.
|
||||
|
@ -51,13 +53,16 @@
|
|||
* per socket level locking
|
||||
*/
|
||||
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
/* Lock for INFO stuff */
|
||||
#define SCTP_INP_INFO_LOCK_INIT()
|
||||
#define SCTP_INP_INFO_RLOCK()
|
||||
#define SCTP_INP_INFO_RUNLOCK()
|
||||
#define SCTP_INP_INFO_WLOCK()
|
||||
#define SCTP_INP_INFO_WUNLOCK()
|
||||
#define SCTP_INP_INFO_LOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_RLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_WLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_LOCK_DESTROY()
|
||||
#define SCTP_IPI_COUNT_INIT()
|
||||
#define SCTP_IPI_COUNT_DESTROY()
|
||||
|
@ -67,16 +72,14 @@
|
|||
#define SCTP_INP_INFO_RUNLOCK()
|
||||
#define SCTP_INP_INFO_WLOCK()
|
||||
#define SCTP_INP_INFO_WUNLOCK()
|
||||
#define SCTP_INP_INFO_LOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_RLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_WLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_LOCK_DESTROY()
|
||||
#define SCTP_IPI_COUNT_INIT()
|
||||
#define SCTP_IPI_COUNT_DESTROY()
|
||||
#endif
|
||||
|
||||
#define SCTP_TCB_SEND_LOCK_INIT(_tcb)
|
||||
#define SCTP_TCB_SEND_LOCK_DESTROY(_tcb)
|
||||
#define SCTP_TCB_SEND_LOCK(_tcb)
|
||||
#define SCTP_TCB_SEND_UNLOCK(_tcb)
|
||||
|
||||
/* Lock for INP */
|
||||
#define SCTP_INP_LOCK_INIT(_inp)
|
||||
#define SCTP_INP_LOCK_DESTROY(_inp)
|
||||
|
@ -84,7 +87,9 @@
|
|||
#define SCTP_INP_RLOCK(_inp)
|
||||
#define SCTP_INP_RUNLOCK(_inp)
|
||||
#define SCTP_INP_WLOCK(_inp)
|
||||
#define SCTP_INP_WUNLOCK(_inep)
|
||||
#define SCTP_INP_WUNLOCK(_inp)
|
||||
#define SCTP_INP_RLOCK_ASSERT(_inp)
|
||||
#define SCTP_INP_WLOCK_ASSERT(_inp)
|
||||
#define SCTP_INP_INCR_REF(_inp)
|
||||
#define SCTP_INP_DECR_REF(_inp)
|
||||
|
||||
|
@ -113,17 +118,18 @@
|
|||
*/
|
||||
#define SCTP_IPI_COUNT_INIT()
|
||||
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
#define SCTP_WQ_ADDR_INIT() \
|
||||
InitializeCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
InitializeCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#define SCTP_WQ_ADDR_DESTROY() \
|
||||
DeleteCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#define SCTP_WQ_ADDR_LOCK() \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#define SCTP_WQ_ADDR_UNLOCK() \
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#define SCTP_WQ_ADDR_LOCK_ASSERT()
|
||||
|
||||
#if WINVER < 0x0600
|
||||
#define SCTP_INP_INFO_LOCK_INIT() \
|
||||
InitializeCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_LOCK_DESTROY() \
|
||||
|
@ -131,20 +137,41 @@
|
|||
#define SCTP_INP_INFO_RLOCK() \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_TRYLOCK() \
|
||||
TryEnterCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
TryEnterCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_WLOCK() \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_RUNLOCK() \
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_WUNLOCK() \
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_LOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_RLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_WLOCK_ASSERT()
|
||||
#else
|
||||
#define SCTP_INP_INFO_LOCK_INIT() \
|
||||
InitializeSRWLock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_LOCK_DESTROY()
|
||||
#define SCTP_INP_INFO_RLOCK() \
|
||||
AcquireSRWLockShared(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_TRYLOCK() \
|
||||
TryAcquireSRWLockShared(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_WLOCK() \
|
||||
AcquireSRWLockExclusive(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_RUNLOCK() \
|
||||
ReleaseSRWLockShared(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_WUNLOCK() \
|
||||
ReleaseSRWLockExclusive(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_LOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_RLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_WLOCK_ASSERT()
|
||||
#endif
|
||||
|
||||
#define SCTP_IP_PKTLOG_INIT() \
|
||||
InitializeCriticalSection(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
InitializeCriticalSection(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#define SCTP_IP_PKTLOG_DESTROY () \
|
||||
DeleteCriticalSection(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#define SCTP_IP_PKTLOG_LOCK() \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#define SCTP_IP_PKTLOG_UNLOCK() \
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
|
||||
|
@ -164,63 +191,44 @@
|
|||
|
||||
#define SCTP_INP_LOCK_INIT(_inp) \
|
||||
InitializeCriticalSection(&(_inp)->inp_mtx)
|
||||
#define SCTP_INP_LOCK_DESTROY(_inp) \
|
||||
DeleteCriticalSection(&(_inp)->inp_mtx)
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_INP_RLOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
|
||||
EnterCriticalSection(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
#define SCTP_INP_WLOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
|
||||
EnterCriticalSection(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_INP_RLOCK(_inp) \
|
||||
EnterCriticalSection(&(_inp)->inp_mtx)
|
||||
#define SCTP_INP_WLOCK(_inp) \
|
||||
EnterCriticalSection(&(_inp)->inp_mtx)
|
||||
#endif
|
||||
#define SCTP_INP_RLOCK_ASSERT(_tcb)
|
||||
#define SCTP_INP_WLOCK_ASSERT(_tcb)
|
||||
|
||||
#define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1)
|
||||
#define SCTP_INP_DECR_REF(_inp) atomic_subtract_int(&((_inp)->refcount), 1)
|
||||
|
||||
#define SCTP_ASOC_CREATE_LOCK_INIT(_inp) \
|
||||
InitializeCriticalSection(&(_inp)->inp_create_mtx)
|
||||
|
||||
#define SCTP_INP_LOCK_DESTROY(_inp) \
|
||||
DeleteCriticalSection(&(_inp)->inp_mtx)
|
||||
|
||||
#define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) \
|
||||
DeleteCriticalSection(&(_inp)->inp_create_mtx)
|
||||
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_INP_RLOCK(_inp) do { \
|
||||
if(SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_INP);\
|
||||
EnterCriticalSection(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_INP_WLOCK(_inp) do { \
|
||||
sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_INP);\
|
||||
EnterCriticalSection(&(_inp)->inp_mtx); \
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_CREATE); \
|
||||
EnterCriticalSection(&(_inp)->inp_create_mtx); \
|
||||
} while (0)
|
||||
#else
|
||||
|
||||
#define SCTP_INP_RLOCK(_inp) do { \
|
||||
EnterCriticalSection(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_INP_WLOCK(_inp) do { \
|
||||
EnterCriticalSection(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
#define SCTP_TCB_SEND_LOCK_INIT(_tcb) \
|
||||
InitializeCriticalSection(&(_tcb)->tcb_send_mtx)
|
||||
|
||||
#define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) \
|
||||
DeleteCriticalSection(&(_tcb)->tcb_send_mtx)
|
||||
|
||||
#define SCTP_TCB_SEND_LOCK(_tcb) do { \
|
||||
EnterCriticalSection(&(_tcb)->tcb_send_mtx); \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_TCB_SEND_UNLOCK(_tcb) \
|
||||
LeaveCriticalSection(&(_tcb)->tcb_send_mtx)
|
||||
|
||||
#define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1)
|
||||
#define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1)
|
||||
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) do { \
|
||||
if(SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_CREATE); \
|
||||
EnterCriticalSection(&(_inp)->inp_create_mtx); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) do { \
|
||||
EnterCriticalSection(&(_inp)->inp_create_mtx); \
|
||||
} while (0)
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) \
|
||||
EnterCriticalSection(&(_inp)->inp_create_mtx)
|
||||
#endif
|
||||
|
||||
#define SCTP_INP_RUNLOCK(_inp) \
|
||||
|
@ -240,65 +248,86 @@
|
|||
|
||||
#define SCTP_TCB_LOCK_INIT(_tcb) \
|
||||
InitializeCriticalSection(&(_tcb)->tcb_mtx)
|
||||
|
||||
#define SCTP_TCB_LOCK_DESTROY(_tcb) \
|
||||
DeleteCriticalSection(&(_tcb)->tcb_mtx)
|
||||
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_TCB_LOCK(_tcb) do { \
|
||||
if(SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \
|
||||
EnterCriticalSection(&(_tcb)->tcb_mtx); \
|
||||
#define SCTP_TCB_LOCK(_tcb) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \
|
||||
EnterCriticalSection(&(_tcb)->tcb_mtx); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
#define SCTP_TCB_LOCK(_tcb) do { \
|
||||
EnterCriticalSection(&(_tcb)->tcb_mtx); \
|
||||
} while (0)
|
||||
#define SCTP_TCB_LOCK(_tcb) \
|
||||
EnterCriticalSection(&(_tcb)->tcb_mtx)
|
||||
#endif
|
||||
|
||||
#define SCTP_TCB_TRYLOCK(_tcb) ((TryEnterCriticalSection(&(_tcb)->tcb_mtx)))
|
||||
|
||||
#define SCTP_TCB_UNLOCK(_tcb) do { \
|
||||
LeaveCriticalSection(&(_tcb)->tcb_mtx); \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_TCB_UNLOCK(_tcb) \
|
||||
LeaveCriticalSection(&(_tcb)->tcb_mtx)
|
||||
#define SCTP_TCB_LOCK_ASSERT(_tcb)
|
||||
|
||||
#else /* all Userspaces except Windows */
|
||||
#define SCTP_WQ_ADDR_INIT() \
|
||||
(void)pthread_mutex_init(&SCTP_BASE_INFO(wq_addr_mtx), NULL)
|
||||
(void)pthread_mutex_init(&SCTP_BASE_INFO(wq_addr_mtx), &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_WQ_ADDR_DESTROY() \
|
||||
(void)pthread_mutex_destroy(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_WQ_ADDR_LOCK() \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(wq_addr_mtx)) == 0, ("%s:%d: wq_addr_mtx already locked", __FILE__, __LINE__))
|
||||
#define SCTP_WQ_ADDR_UNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
|
||||
KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(wq_addr_mtx)) == 0, ("%s:%d: wq_addr_mtx not locked", __FILE__, __LINE__))
|
||||
#else
|
||||
#define SCTP_WQ_ADDR_LOCK() \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#define SCTP_WQ_ADDR_UNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#endif
|
||||
#define SCTP_WQ_ADDR_LOCK_ASSERT() \
|
||||
KASSERT(pthread_mutex_trylock(&SCTP_BASE_INFO(wq_addr_mtx)) == EBUSY, ("%s:%d: wq_addr_mtx not locked", __FILE__, __LINE__))
|
||||
|
||||
#define SCTP_INP_INFO_LOCK_INIT() \
|
||||
(void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_ep_mtx), NULL)
|
||||
(void)pthread_rwlock_init(&SCTP_BASE_INFO(ipi_ep_mtx), &SCTP_BASE_VAR(rwlock_attr))
|
||||
#define SCTP_INP_INFO_LOCK_DESTROY() \
|
||||
(void)pthread_mutex_destroy(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
(void)pthread_rwlock_destroy(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_INP_INFO_RLOCK() \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_TRYLOCK() \
|
||||
(!(pthread_mutex_trylock(&SCTP_BASE_INFO(ipi_ep_mtx))))
|
||||
KASSERT(pthread_rwlock_rdlock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s%d: ipi_ep_mtx already locked", __FILE__, __LINE__))
|
||||
#define SCTP_INP_INFO_WLOCK() \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_RUNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_WUNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
KASSERT(pthread_rwlock_wrlock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s:%d: ipi_ep_mtx already locked", __FILE__, __LINE__))
|
||||
#define SCTP_INP_INFO_RUNLOCK() \
|
||||
KASSERT(pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s:%d: ipi_ep_mtx not locked", __FILE__, __LINE__))
|
||||
#define SCTP_INP_INFO_WUNLOCK() \
|
||||
KASSERT(pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s:%d: ipi_ep_mtx not locked", __FILE__, __LINE__))
|
||||
#else
|
||||
#define SCTP_INP_INFO_RLOCK() \
|
||||
(void)pthread_rwlock_rdlock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_WLOCK() \
|
||||
(void)pthread_rwlock_wrlock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_RUNLOCK() \
|
||||
(void)pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_WUNLOCK() \
|
||||
(void)pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#endif
|
||||
#define SCTP_INP_INFO_LOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_RLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_WLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_TRYLOCK() \
|
||||
(!(pthread_rwlock_tryrdlock(&SCTP_BASE_INFO(ipi_ep_mtx))))
|
||||
|
||||
#define SCTP_IP_PKTLOG_INIT() \
|
||||
(void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_pktlog_mtx), NULL)
|
||||
(void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_pktlog_mtx), &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_IP_PKTLOG_DESTROY() \
|
||||
(void)pthread_mutex_destroy(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_IP_PKTLOG_LOCK() \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#define SCTP_IP_PKTLOG_UNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
|
||||
KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(ipi_pktlog_mtx)) == 0, ("%s:%d: ipi_pktlog_mtx already locked", __FILE__, __LINE__))
|
||||
#define SCTP_IP_PKTLOG_UNLOCK() \
|
||||
KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_pktlog_mtx)) == 0, ("%s:%d: ipi_pktlog_mtx not locked", __FILE__, __LINE__))
|
||||
#else
|
||||
#define SCTP_IP_PKTLOG_LOCK() \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#define SCTP_IP_PKTLOG_UNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
@ -307,88 +336,108 @@
|
|||
* or cookie secrets we lock the INP level.
|
||||
*/
|
||||
#define SCTP_INP_READ_INIT(_inp) \
|
||||
(void)pthread_mutex_init(&(_inp)->inp_rdata_mtx, NULL)
|
||||
|
||||
(void)pthread_mutex_init(&(_inp)->inp_rdata_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_INP_READ_DESTROY(_inp) \
|
||||
(void)pthread_mutex_destroy(&(_inp)->inp_rdata_mtx)
|
||||
|
||||
#define SCTP_INP_READ_LOCK(_inp) do { \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_rdata_mtx); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_INP_READ_LOCK(_inp) \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_rdata_mtx) == 0, ("%s:%d: inp_rdata_mtx already locked", __FILE__, __LINE__))
|
||||
#define SCTP_INP_READ_UNLOCK(_inp) \
|
||||
KASSERT(pthread_mutex_unlock(&(_inp)->inp_rdata_mtx) == 0, ("%s:%d: inp_rdata_mtx not locked", __FILE__, __LINE__))
|
||||
#else
|
||||
#define SCTP_INP_READ_LOCK(_inp) \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_rdata_mtx)
|
||||
#define SCTP_INP_READ_UNLOCK(_inp) \
|
||||
(void)pthread_mutex_unlock(&(_inp)->inp_rdata_mtx)
|
||||
#endif
|
||||
|
||||
#define SCTP_INP_LOCK_INIT(_inp) \
|
||||
(void)pthread_mutex_init(&(_inp)->inp_mtx, NULL)
|
||||
|
||||
#define SCTP_ASOC_CREATE_LOCK_INIT(_inp) \
|
||||
(void)pthread_mutex_init(&(_inp)->inp_create_mtx, NULL)
|
||||
|
||||
(void)pthread_mutex_init(&(_inp)->inp_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_INP_LOCK_DESTROY(_inp) \
|
||||
(void)pthread_mutex_destroy(&(_inp)->inp_mtx)
|
||||
|
||||
#define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) \
|
||||
(void)pthread_mutex_destroy(&(_inp)->inp_create_mtx)
|
||||
|
||||
#ifdef INVARIANTS
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_INP_RLOCK(_inp) do { \
|
||||
if(SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_INP);\
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_mtx); \
|
||||
#define SCTP_INP_RLOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s:%d: inp_mtx already locked", __FILE__, __LINE__)); \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_INP_WLOCK(_inp) do { \
|
||||
sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_INP);\
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define SCTP_INP_RLOCK(_inp) do { \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_INP_WLOCK(_inp) do { \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
#define SCTP_TCB_SEND_LOCK_INIT(_tcb) \
|
||||
(void)pthread_mutex_init(&(_tcb)->tcb_send_mtx, NULL)
|
||||
|
||||
#define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) \
|
||||
(void)pthread_mutex_destroy(&(_tcb)->tcb_send_mtx)
|
||||
|
||||
#define SCTP_TCB_SEND_LOCK(_tcb) do { \
|
||||
(void)pthread_mutex_lock(&(_tcb)->tcb_send_mtx); \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_TCB_SEND_UNLOCK(_tcb) \
|
||||
(void)pthread_mutex_unlock(&(_tcb)->tcb_send_mtx)
|
||||
|
||||
#define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1)
|
||||
#define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1)
|
||||
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) do { \
|
||||
if(SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_CREATE); \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_create_mtx); \
|
||||
#define SCTP_INP_WLOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s:%d: inp_mtx already locked", __FILE__, __LINE__)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) do { \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_create_mtx); \
|
||||
} while (0)
|
||||
#define SCTP_INP_RLOCK(_inp) \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s:%d: inp_mtx already locked", __FILE__, __LINE__))
|
||||
#define SCTP_INP_WLOCK(_inp) \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s:%d: inp_mtx already locked", __FILE__, __LINE__))
|
||||
#endif
|
||||
#define SCTP_INP_RUNLOCK(_inp) \
|
||||
KASSERT(pthread_mutex_unlock(&(_inp)->inp_mtx) == 0, ("%s:%d: inp_mtx not locked", __FILE__, __LINE__))
|
||||
#define SCTP_INP_WUNLOCK(_inp) \
|
||||
KASSERT(pthread_mutex_unlock(&(_inp)->inp_mtx) == 0, ("%s:%d: inp_mtx not locked", __FILE__, __LINE__))
|
||||
#else
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_INP_RLOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
#define SCTP_INP_WLOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_INP_RLOCK(_inp) \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_mtx)
|
||||
#define SCTP_INP_WLOCK(_inp) \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_mtx)
|
||||
#endif
|
||||
|
||||
#define SCTP_INP_RUNLOCK(_inp) \
|
||||
(void)pthread_mutex_unlock(&(_inp)->inp_mtx)
|
||||
#define SCTP_INP_WUNLOCK(_inp) \
|
||||
(void)pthread_mutex_unlock(&(_inp)->inp_mtx)
|
||||
#endif
|
||||
#define SCTP_INP_RLOCK_ASSERT(_inp) \
|
||||
KASSERT(pthread_mutex_trylock(&(_inp)->inp_mtx) == EBUSY, ("%s:%d: inp_mtx not locked", __FILE__, __LINE__))
|
||||
#define SCTP_INP_WLOCK_ASSERT(_inp) \
|
||||
KASSERT(pthread_mutex_trylock(&(_inp)->inp_mtx) == EBUSY, ("%s:%d: inp_mtx not locked", __FILE__, __LINE__))
|
||||
#define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1)
|
||||
#define SCTP_INP_DECR_REF(_inp) atomic_subtract_int(&((_inp)->refcount), 1)
|
||||
|
||||
#define SCTP_ASOC_CREATE_LOCK_INIT(_inp) \
|
||||
(void)pthread_mutex_init(&(_inp)->inp_create_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) \
|
||||
(void)pthread_mutex_destroy(&(_inp)->inp_create_mtx)
|
||||
#ifdef INVARIANTS
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_CREATE); \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_create_mtx) == 0, ("%s:%d: inp_create_mtx already locked", __FILE__, __LINE__)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_create_mtx) == 0, ("%s:%d: inp_create_mtx already locked", __FILE__, __LINE__))
|
||||
#endif
|
||||
#define SCTP_ASOC_CREATE_UNLOCK(_inp) \
|
||||
KASSERT(pthread_mutex_unlock(&(_inp)->inp_create_mtx) == 0, ("%s:%d: inp_create_mtx not locked", __FILE__, __LINE__))
|
||||
#else
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_CREATE); \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_create_mtx); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_create_mtx)
|
||||
#endif
|
||||
#define SCTP_ASOC_CREATE_UNLOCK(_inp) \
|
||||
(void)pthread_mutex_unlock(&(_inp)->inp_create_mtx)
|
||||
|
||||
#endif
|
||||
/*
|
||||
* For the majority of things (once we have found the association) we will
|
||||
* lock the actual association mutex. This will protect all the assoiciation
|
||||
|
@ -398,28 +447,38 @@
|
|||
*/
|
||||
|
||||
#define SCTP_TCB_LOCK_INIT(_tcb) \
|
||||
(void)pthread_mutex_init(&(_tcb)->tcb_mtx, NULL)
|
||||
|
||||
(void)pthread_mutex_init(&(_tcb)->tcb_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_TCB_LOCK_DESTROY(_tcb) \
|
||||
(void)pthread_mutex_destroy(&(_tcb)->tcb_mtx)
|
||||
|
||||
#ifdef INVARIANTS
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_TCB_LOCK(_tcb) do { \
|
||||
if(SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \
|
||||
(void)pthread_mutex_lock(&(_tcb)->tcb_mtx); \
|
||||
#define SCTP_TCB_LOCK(_tcb) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \
|
||||
KASSERT(pthread_mutex_lock(&(_tcb)->tcb_mtx) == 0, ("%s:%d: tcb_mtx already locked", __FILE__, __LINE__)) \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
#define SCTP_TCB_LOCK(_tcb) do { \
|
||||
(void)pthread_mutex_lock(&(_tcb)->tcb_mtx); \
|
||||
} while (0)
|
||||
#define SCTP_TCB_LOCK(_tcb) \
|
||||
KASSERT(pthread_mutex_lock(&(_tcb)->tcb_mtx) == 0, ("%s:%d: tcb_mtx already locked", __FILE__, __LINE__))
|
||||
#endif
|
||||
|
||||
#define SCTP_TCB_TRYLOCK(_tcb) (!(pthread_mutex_trylock(&(_tcb)->tcb_mtx)))
|
||||
|
||||
#define SCTP_TCB_UNLOCK(_tcb) (void)pthread_mutex_unlock(&(_tcb)->tcb_mtx)
|
||||
|
||||
#define SCTP_TCB_LOCK_ASSERT(_tcb)
|
||||
#define SCTP_TCB_UNLOCK(_tcb) \
|
||||
KASSERT(pthread_mutex_unlock(&(_tcb)->tcb_mtx) == 0, ("%s:%d: tcb_mtx not locked", __FILE__, __LINE__))
|
||||
#else
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_TCB_LOCK(_tcb) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \
|
||||
(void)pthread_mutex_lock(&(_tcb)->tcb_mtx); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_TCB_LOCK(_tcb) \
|
||||
(void)pthread_mutex_lock(&(_tcb)->tcb_mtx)
|
||||
#endif
|
||||
#define SCTP_TCB_UNLOCK(_tcb) (void)pthread_mutex_unlock(&(_tcb)->tcb_mtx)
|
||||
#endif
|
||||
#define SCTP_TCB_LOCK_ASSERT(_tcb) \
|
||||
KASSERT(pthread_mutex_trylock(&(_tcb)->tcb_mtx) == EBUSY, ("%s:%d: tcb_mtx not locked", __FILE__, __LINE__))
|
||||
#define SCTP_TCB_TRYLOCK(_tcb) (!(pthread_mutex_trylock(&(_tcb)->tcb_mtx)))
|
||||
#endif
|
||||
|
||||
#endif /* SCTP_PER_SOCKET_LOCKING */
|
||||
|
@ -434,29 +493,36 @@
|
|||
#define SCTP_INP_READ_CONTENDED(_inp) (0) /* Don't know if this is possible */
|
||||
#define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
|
||||
|
||||
|
||||
/* socket locks */
|
||||
|
||||
#if defined(__Userspace__)
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
#define SOCKBUF_LOCK_ASSERT(_so_buf)
|
||||
#define SOCKBUF_LOCK(_so_buf) EnterCriticalSection(&(_so_buf)->sb_mtx)
|
||||
#define SOCKBUF_UNLOCK(_so_buf) LeaveCriticalSection(&(_so_buf)->sb_mtx)
|
||||
#define SOCK_LOCK(_so) SOCKBUF_LOCK(&(_so)->so_rcv)
|
||||
#define SOCK_UNLOCK(_so) SOCKBUF_UNLOCK(&(_so)->so_rcv)
|
||||
#define SOCKBUF_LOCK(_so_buf) \
|
||||
EnterCriticalSection(&(_so_buf)->sb_mtx)
|
||||
#define SOCKBUF_UNLOCK(_so_buf) \
|
||||
LeaveCriticalSection(&(_so_buf)->sb_mtx)
|
||||
#define SOCK_LOCK(_so) \
|
||||
SOCKBUF_LOCK(&(_so)->so_rcv)
|
||||
#define SOCK_UNLOCK(_so) \
|
||||
SOCKBUF_UNLOCK(&(_so)->so_rcv)
|
||||
#else
|
||||
#define SOCKBUF_LOCK_ASSERT(_so_buf) KASSERT(pthread_mutex_trylock(SOCKBUF_MTX(_so_buf)) == EBUSY, ("%s: socket buffer not locked", __func__))
|
||||
#define SOCKBUF_LOCK(_so_buf) pthread_mutex_lock(SOCKBUF_MTX(_so_buf))
|
||||
#define SOCKBUF_UNLOCK(_so_buf) pthread_mutex_unlock(SOCKBUF_MTX(_so_buf))
|
||||
#define SOCK_LOCK(_so) SOCKBUF_LOCK(&(_so)->so_rcv)
|
||||
#define SOCK_UNLOCK(_so) SOCKBUF_UNLOCK(&(_so)->so_rcv)
|
||||
#define SOCKBUF_LOCK_ASSERT(_so_buf) \
|
||||
KASSERT(pthread_mutex_trylock(SOCKBUF_MTX(_so_buf)) == EBUSY, ("%s:%d: socket buffer not locked", __FILE__, __LINE__))
|
||||
#ifdef INVARIANTS
|
||||
#define SOCKBUF_LOCK(_so_buf) \
|
||||
KASSERT(pthread_mutex_lock(SOCKBUF_MTX(_so_buf)) == 0, ("%s:%d: sockbuf_mtx already locked", __FILE__, __LINE__))
|
||||
#define SOCKBUF_UNLOCK(_so_buf) \
|
||||
KASSERT(pthread_mutex_unlock(SOCKBUF_MTX(_so_buf)) == 0, ("%s:%d: sockbuf_mtx not locked", __FILE__, __LINE__))
|
||||
#else
|
||||
#define SOCKBUF_LOCK(_so_buf) \
|
||||
pthread_mutex_lock(SOCKBUF_MTX(_so_buf))
|
||||
#define SOCKBUF_UNLOCK(_so_buf) \
|
||||
pthread_mutex_unlock(SOCKBUF_MTX(_so_buf))
|
||||
#endif
|
||||
#else
|
||||
#define SOCK_LOCK(_so)
|
||||
#define SOCK_UNLOCK(_so)
|
||||
#define SOCKBUF_LOCK(_so_buf)
|
||||
#define SOCKBUF_UNLOCK(_so_buf)
|
||||
#define SOCKBUF_LOCK_ASSERT(_so_buf)
|
||||
#define SOCK_LOCK(_so) \
|
||||
SOCKBUF_LOCK(&(_so)->so_rcv)
|
||||
#define SOCK_UNLOCK(_so) \
|
||||
SOCKBUF_UNLOCK(&(_so)->so_rcv)
|
||||
#endif
|
||||
|
||||
#define SCTP_STATLOG_INIT_LOCK()
|
||||
|
@ -464,179 +530,160 @@
|
|||
#define SCTP_STATLOG_UNLOCK()
|
||||
#define SCTP_STATLOG_DESTROY()
|
||||
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
/* address list locks */
|
||||
#if WINVER < 0x0600
|
||||
#define SCTP_IPI_ADDR_INIT() \
|
||||
InitializeCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_DESTROY() \
|
||||
DeleteCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
|
||||
#define SCTP_IPI_ADDR_RLOCK() \
|
||||
do { \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx)); \
|
||||
} while (0)
|
||||
#define SCTP_IPI_ADDR_RLOCK() \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_RUNLOCK() \
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
|
||||
#define SCTP_IPI_ADDR_WLOCK() \
|
||||
do { \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx)); \
|
||||
} while (0)
|
||||
#define SCTP_IPI_ADDR_WLOCK() \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_WUNLOCK() \
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
|
||||
#define SCTP_IPI_ADDR_LOCK_ASSERT()
|
||||
#define SCTP_IPI_ADDR_WLOCK_ASSERT()
|
||||
#else
|
||||
#define SCTP_IPI_ADDR_INIT() \
|
||||
InitializeSRWLock(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_DESTROY()
|
||||
#define SCTP_IPI_ADDR_RLOCK() \
|
||||
AcquireSRWLockShared(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_RUNLOCK() \
|
||||
ReleaseSRWLockShared(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_WLOCK() \
|
||||
AcquireSRWLockExclusive(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_WUNLOCK() \
|
||||
ReleaseSRWLockExclusive(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_LOCK_ASSERT()
|
||||
#define SCTP_IPI_ADDR_WLOCK_ASSERT()
|
||||
#endif
|
||||
|
||||
/* iterator locks */
|
||||
#define SCTP_ITERATOR_LOCK_INIT() \
|
||||
InitializeCriticalSection(&sctp_it_ctl.it_mtx)
|
||||
|
||||
#define SCTP_ITERATOR_LOCK() \
|
||||
do { \
|
||||
EnterCriticalSection(&sctp_it_ctl.it_mtx); \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_ITERATOR_LOCK_DESTROY() \
|
||||
DeleteCriticalSection(&sctp_it_ctl.it_mtx)
|
||||
#define SCTP_ITERATOR_LOCK() \
|
||||
EnterCriticalSection(&sctp_it_ctl.it_mtx)
|
||||
#define SCTP_ITERATOR_UNLOCK() \
|
||||
LeaveCriticalSection(&sctp_it_ctl.it_mtx)
|
||||
|
||||
#define SCTP_ITERATOR_LOCK_DESTROY() \
|
||||
DeleteCriticalSection(&sctp_it_ctl.it_mtx)
|
||||
|
||||
|
||||
#define SCTP_IPI_ITERATOR_WQ_INIT() \
|
||||
InitializeCriticalSection(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
|
||||
#define SCTP_IPI_ITERATOR_WQ_DESTROY() \
|
||||
DeleteCriticalSection(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
|
||||
#define SCTP_IPI_ITERATOR_WQ_LOCK() \
|
||||
do { \
|
||||
EnterCriticalSection(&sctp_it_ctl.ipi_iterator_wq_mtx); \
|
||||
} while (0)
|
||||
|
||||
EnterCriticalSection(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
#define SCTP_IPI_ITERATOR_WQ_UNLOCK() \
|
||||
LeaveCriticalSection(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
|
||||
#else /* end of __Userspace_os_Windows */
|
||||
#else
|
||||
/* address list locks */
|
||||
#define SCTP_IPI_ADDR_INIT() \
|
||||
(void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_addr_mtx), NULL)
|
||||
(void)pthread_rwlock_init(&SCTP_BASE_INFO(ipi_addr_mtx), &SCTP_BASE_VAR(rwlock_attr))
|
||||
#define SCTP_IPI_ADDR_DESTROY() \
|
||||
(void)pthread_mutex_destroy(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
|
||||
#define SCTP_IPI_ADDR_RLOCK() \
|
||||
do { \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
|
||||
} while (0)
|
||||
(void)pthread_rwlock_destroy(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_IPI_ADDR_RLOCK() \
|
||||
KASSERT(pthread_rwlock_rdlock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s:%d: ipi_addr_mtx already locked", __FILE__, __LINE__))
|
||||
#define SCTP_IPI_ADDR_RUNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
|
||||
#define SCTP_IPI_ADDR_WLOCK() \
|
||||
do { \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
|
||||
} while (0)
|
||||
KASSERT(pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s:%d: ipi_addr_mtx not locked", __FILE__, __LINE__))
|
||||
#define SCTP_IPI_ADDR_WLOCK() \
|
||||
KASSERT(pthread_rwlock_wrlock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s:%d: ipi_addr_mtx already locked", __FILE__, __LINE__))
|
||||
#define SCTP_IPI_ADDR_WUNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
|
||||
KASSERT(pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s:%d: ipi_addr_mtx not locked", __FILE__, __LINE__))
|
||||
#else
|
||||
#define SCTP_IPI_ADDR_RLOCK() \
|
||||
(void)pthread_rwlock_rdlock(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_RUNLOCK() \
|
||||
(void)pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_WLOCK() \
|
||||
(void)pthread_rwlock_wrlock(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_WUNLOCK() \
|
||||
(void)pthread_rwlock_unlock(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#endif
|
||||
#define SCTP_IPI_ADDR_LOCK_ASSERT()
|
||||
#define SCTP_IPI_ADDR_WLOCK_ASSERT()
|
||||
|
||||
/* iterator locks */
|
||||
#define SCTP_ITERATOR_LOCK_INIT() \
|
||||
(void)pthread_mutex_init(&sctp_it_ctl.it_mtx, NULL)
|
||||
|
||||
#define SCTP_ITERATOR_LOCK() \
|
||||
do { \
|
||||
(void)pthread_mutex_lock(&sctp_it_ctl.it_mtx); \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_ITERATOR_UNLOCK() \
|
||||
(void)pthread_mutex_unlock(&sctp_it_ctl.it_mtx)
|
||||
|
||||
(void)pthread_mutex_init(&sctp_it_ctl.it_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_ITERATOR_LOCK_DESTROY() \
|
||||
(void)pthread_mutex_destroy(&sctp_it_ctl.it_mtx)
|
||||
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_ITERATOR_LOCK() \
|
||||
KASSERT(pthread_mutex_lock(&sctp_it_ctl.it_mtx) == 0, ("%s:%d: it_mtx already locked", __FILE__, __LINE__))
|
||||
#define SCTP_ITERATOR_UNLOCK() \
|
||||
KASSERT(pthread_mutex_unlock(&sctp_it_ctl.it_mtx) == 0, ("%s:%d: it_mtx not locked", __FILE__, __LINE__))
|
||||
#else
|
||||
#define SCTP_ITERATOR_LOCK() \
|
||||
(void)pthread_mutex_lock(&sctp_it_ctl.it_mtx)
|
||||
#define SCTP_ITERATOR_UNLOCK() \
|
||||
(void)pthread_mutex_unlock(&sctp_it_ctl.it_mtx)
|
||||
#endif
|
||||
|
||||
#define SCTP_IPI_ITERATOR_WQ_INIT() \
|
||||
(void)pthread_mutex_init(&sctp_it_ctl.ipi_iterator_wq_mtx, NULL)
|
||||
|
||||
(void)pthread_mutex_init(&sctp_it_ctl.ipi_iterator_wq_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_IPI_ITERATOR_WQ_DESTROY() \
|
||||
(void)pthread_mutex_destroy(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_IPI_ITERATOR_WQ_LOCK() \
|
||||
do { \
|
||||
(void)pthread_mutex_lock(&sctp_it_ctl.ipi_iterator_wq_mtx); \
|
||||
} while (0)
|
||||
|
||||
KASSERT(pthread_mutex_lock(&sctp_it_ctl.ipi_iterator_wq_mtx) == 0, ("%s:%d: ipi_iterator_wq_mtx already locked", __FILE__, __LINE__))
|
||||
#define SCTP_IPI_ITERATOR_WQ_UNLOCK() \
|
||||
KASSERT(pthread_mutex_unlock(&sctp_it_ctl.ipi_iterator_wq_mtx) == 0, ("%s:%d: ipi_iterator_wq_mtx not locked", __FILE__, __LINE__))
|
||||
#else
|
||||
#define SCTP_IPI_ITERATOR_WQ_LOCK() \
|
||||
(void)pthread_mutex_lock(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
#define SCTP_IPI_ITERATOR_WQ_UNLOCK() \
|
||||
(void)pthread_mutex_unlock(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SCTP_INCR_EP_COUNT() \
|
||||
do { \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_ep), 1); \
|
||||
} while (0)
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_ep), 1)
|
||||
|
||||
#define SCTP_DECR_EP_COUNT() \
|
||||
do { \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_ep), 1); \
|
||||
} while (0)
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_ep), 1)
|
||||
|
||||
#define SCTP_INCR_ASOC_COUNT() \
|
||||
do { \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_asoc), 1); \
|
||||
} while (0)
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_asoc), 1)
|
||||
|
||||
#define SCTP_DECR_ASOC_COUNT() \
|
||||
do { \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_asoc), 1); \
|
||||
} while (0)
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_asoc), 1)
|
||||
|
||||
#define SCTP_INCR_LADDR_COUNT() \
|
||||
do { \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_laddr), 1); \
|
||||
} while (0)
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_laddr), 1)
|
||||
|
||||
#define SCTP_DECR_LADDR_COUNT() \
|
||||
do { \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_laddr), 1); \
|
||||
} while (0)
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_laddr), 1)
|
||||
|
||||
#define SCTP_INCR_RADDR_COUNT() \
|
||||
do { \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_raddr), 1); \
|
||||
} while (0)
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_raddr), 1)
|
||||
|
||||
#define SCTP_DECR_RADDR_COUNT() \
|
||||
do { \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_raddr), 1); \
|
||||
} while (0)
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_raddr), 1)
|
||||
|
||||
#define SCTP_INCR_CHK_COUNT() \
|
||||
do { \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_chunk), 1); \
|
||||
} while (0)
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_chunk), 1)
|
||||
|
||||
#define SCTP_DECR_CHK_COUNT() \
|
||||
do { \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_chunk), 1); \
|
||||
} while (0)
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_chunk), 1)
|
||||
|
||||
#define SCTP_INCR_READQ_COUNT() \
|
||||
do { \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_readq), 1); \
|
||||
} while (0)
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_readq), 1)
|
||||
|
||||
#define SCTP_DECR_READQ_COUNT() \
|
||||
do { \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_readq), 1); \
|
||||
} while (0)
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_readq), 1)
|
||||
|
||||
#define SCTP_INCR_STRMOQ_COUNT() \
|
||||
do { \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_strmoq), 1); \
|
||||
} while (0)
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_strmoq), 1)
|
||||
|
||||
#define SCTP_DECR_STRMOQ_COUNT() \
|
||||
do { \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_strmoq), 1); \
|
||||
} while (0)
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_strmoq), 1)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2013, by Michael Tuexen. All rights reserved.
|
||||
|
@ -78,13 +80,31 @@ sctp_sha1_final(unsigned char *digest, struct sctp_sha1_context *ctx)
|
|||
{
|
||||
SHA1_Final(digest, &ctx->sha_ctx);
|
||||
}
|
||||
#elif defined(SCTP_USE_MBEDTLS_SHA1)
|
||||
void
|
||||
sctp_sha1_init(struct sctp_sha1_context *ctx)
|
||||
{
|
||||
mbedtls_sha1_init(&ctx->sha1_ctx);
|
||||
mbedtls_sha1_starts_ret(&ctx->sha1_ctx);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_sha1_update(struct sctp_sha1_context *ctx, const unsigned char *ptr, unsigned int siz)
|
||||
{
|
||||
mbedtls_sha1_update_ret(&ctx->sha1_ctx, ptr, siz);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_sha1_final(unsigned char *digest, struct sctp_sha1_context *ctx)
|
||||
{
|
||||
mbedtls_sha1_finish_ret(&ctx->sha1_ctx, digest);
|
||||
}
|
||||
#else
|
||||
|
||||
#include <string.h>
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32) && defined(__Userspace__)
|
||||
#include <winsock2.h>
|
||||
#elif !defined(__Windows__)
|
||||
#elif !(defined(_WIN32) && !defined(__Userspace__))
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,7 +32,7 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
@ -41,18 +43,11 @@ __FBSDID("$FreeBSD$");
|
|||
|
||||
#include <sys/types.h>
|
||||
#if defined(SCTP_USE_NSS_SHA1)
|
||||
#if defined(__Userspace_os_Darwin)
|
||||
/* The NSS sources require __APPLE__ to be defined.
|
||||
* XXX: Remove this ugly hack once the platform defines have been cleaned up.
|
||||
*/
|
||||
#define __APPLE__
|
||||
#endif
|
||||
#include <pk11pub.h>
|
||||
#if defined(__Userspace_os_Darwin)
|
||||
#undef __APPLE__
|
||||
#endif
|
||||
#elif defined(SCTP_USE_OPENSSL_SHA1)
|
||||
#include <openssl/sha.h>
|
||||
#elif defined(SCTP_USE_MBEDTLS_SHA1)
|
||||
#include <mbedtls/sha1.h>
|
||||
#endif
|
||||
|
||||
struct sctp_sha1_context {
|
||||
|
@ -60,6 +55,8 @@ struct sctp_sha1_context {
|
|||
struct PK11Context *pk11_ctx;
|
||||
#elif defined(SCTP_USE_OPENSSL_SHA1)
|
||||
SHA_CTX sha_ctx;
|
||||
#elif defined(SCTP_USE_MBEDTLS_SHA1)
|
||||
mbedtls_sha1_context sha1_ctx;
|
||||
#else
|
||||
unsigned int A;
|
||||
unsigned int B;
|
||||
|
@ -81,7 +78,7 @@ struct sctp_sha1_context {
|
|||
#endif
|
||||
};
|
||||
|
||||
#if (defined(__APPLE__) && defined(KERNEL))
|
||||
#if (defined(__APPLE__) && !defined(__Userspace__) && defined(KERNEL))
|
||||
#ifndef _KERNEL
|
||||
#define _KERNEL
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 279859 2015-03-10 19:49:25Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_STRUCTS_H_
|
||||
|
@ -53,7 +55,7 @@ struct sctp_timer {
|
|||
void *ep;
|
||||
void *tcb;
|
||||
void *net;
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 800000
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
void *vnet;
|
||||
#endif
|
||||
|
||||
|
@ -63,7 +65,6 @@ struct sctp_timer {
|
|||
uint32_t stopped_from;
|
||||
};
|
||||
|
||||
|
||||
struct sctp_foo_stuff {
|
||||
struct sctp_inpcb *inp;
|
||||
uint32_t lineno;
|
||||
|
@ -71,7 +72,6 @@ struct sctp_foo_stuff {
|
|||
int updown;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* This is the information we track on each interface that we know about from
|
||||
* the distant end.
|
||||
|
@ -80,6 +80,7 @@ TAILQ_HEAD(sctpnetlisthead, sctp_nets);
|
|||
|
||||
struct sctp_stream_reset_list {
|
||||
TAILQ_ENTRY(sctp_stream_reset_list) next_resp;
|
||||
uint32_t seq;
|
||||
uint32_t tsn;
|
||||
uint32_t number_entries;
|
||||
uint16_t list_of_streams[];
|
||||
|
@ -110,13 +111,12 @@ typedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr,
|
|||
typedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val);
|
||||
typedef void (*end_func) (void *ptr, uint32_t val);
|
||||
|
||||
#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#if defined(SCTP_MCORE_INPUT) && defined(SMP)
|
||||
/* whats on the mcore control struct */
|
||||
struct sctp_mcore_queue {
|
||||
TAILQ_ENTRY(sctp_mcore_queue) next;
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 801000
|
||||
struct vnet *vn;
|
||||
#endif
|
||||
struct mbuf *m;
|
||||
int off;
|
||||
int v6;
|
||||
|
@ -132,14 +132,32 @@ struct sctp_mcore_ctrl {
|
|||
int running;
|
||||
int cpuid;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This struct is here to cut out the compatiabilty
|
||||
* pad that bulks up both the inp and stcb. The non
|
||||
* pad portion MUST stay in complete sync with
|
||||
* sctp_sndrcvinfo... i.e. if sinfo_xxxx is added
|
||||
* this must be done here too.
|
||||
*/
|
||||
struct sctp_nonpad_sndrcvinfo {
|
||||
uint16_t sinfo_stream;
|
||||
uint16_t sinfo_ssn;
|
||||
uint16_t sinfo_flags;
|
||||
uint32_t sinfo_ppid;
|
||||
uint32_t sinfo_context;
|
||||
uint32_t sinfo_timetolive;
|
||||
uint32_t sinfo_tsn;
|
||||
uint32_t sinfo_cumtsn;
|
||||
sctp_assoc_t sinfo_assoc_id;
|
||||
uint16_t sinfo_keynumber;
|
||||
uint16_t sinfo_keynumber_valid;
|
||||
};
|
||||
|
||||
struct sctp_iterator {
|
||||
TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr;
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 801000
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct vnet *vn;
|
||||
#endif
|
||||
struct sctp_timer tmr;
|
||||
|
@ -163,14 +181,13 @@ struct sctp_iterator {
|
|||
#define SCTP_ITERATOR_DO_ALL_INP 0x00000001
|
||||
#define SCTP_ITERATOR_DO_SINGLE_INP 0x00000002
|
||||
|
||||
|
||||
TAILQ_HEAD(sctpiterators, sctp_iterator);
|
||||
|
||||
struct sctp_copy_all {
|
||||
struct sctp_inpcb *inp; /* ep */
|
||||
struct mbuf *m;
|
||||
struct sctp_sndrcvinfo sndrcv;
|
||||
int sndlen;
|
||||
struct sctp_nonpad_sndrcvinfo sndrcv;
|
||||
ssize_t sndlen;
|
||||
int cnt_sent;
|
||||
int cnt_failed;
|
||||
};
|
||||
|
@ -181,10 +198,10 @@ struct sctp_asconf_iterator {
|
|||
};
|
||||
|
||||
struct iterator_control {
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct mtx ipi_iterator_wq_mtx;
|
||||
struct mtx it_mtx;
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__APPLE__) && !defined(__Userspace__)
|
||||
lck_mtx_t *ipi_iterator_wq_mtx;
|
||||
lck_mtx_t *it_mtx;
|
||||
#elif defined(SCTP_PROCESS_LEVEL_LOCKS)
|
||||
|
@ -197,7 +214,7 @@ struct iterator_control {
|
|||
pthread_mutex_t it_mtx;
|
||||
pthread_cond_t iterator_wakeup;
|
||||
#endif
|
||||
#elif defined(__Windows__)
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
struct spinlock it_lock;
|
||||
struct spinlock ipi_iterator_wq_lock;
|
||||
KEVENT iterator_wakeup[2];
|
||||
|
@ -205,7 +222,7 @@ struct iterator_control {
|
|||
#else
|
||||
void *it_mtx;
|
||||
#endif
|
||||
#if !defined(__Windows__)
|
||||
#if !(defined(_WIN32) && !defined(__Userspace__))
|
||||
#if !defined(__Userspace__)
|
||||
SCTP_PROCESS_STRUCT thread_proc;
|
||||
#else
|
||||
|
@ -217,7 +234,7 @@ struct iterator_control {
|
|||
uint32_t iterator_running;
|
||||
uint32_t iterator_flags;
|
||||
};
|
||||
#if !defined(__FreeBSD__)
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
#define SCTP_ITERATOR_MUST_EXIT 0x00000001
|
||||
#define SCTP_ITERATOR_EXITED 0x00000002
|
||||
#endif
|
||||
|
@ -225,17 +242,21 @@ struct iterator_control {
|
|||
#define SCTP_ITERATOR_STOP_CUR_INP 0x00000008
|
||||
|
||||
struct sctp_net_route {
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct nhop_object *ro_nh;
|
||||
struct llentry *ro_lle;
|
||||
char *ro_prepend;
|
||||
uint16_t ro_plen;
|
||||
uint16_t ro_flags;
|
||||
uint16_t ro_mtu;
|
||||
uint16_t spare;
|
||||
#else
|
||||
sctp_rtentry_t *ro_rt;
|
||||
#if defined(__FreeBSD__)
|
||||
#if __FreeBSD_version >= 800000
|
||||
void *ro_lle;
|
||||
#endif
|
||||
#if __FreeBSD_version >= 900000
|
||||
void *ro_ia;
|
||||
int ro_flags;
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
#if !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN)
|
||||
struct llentry *ro_lle;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#if !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)
|
||||
struct ifaddr *ro_srcia;
|
||||
#endif
|
||||
|
@ -289,7 +310,6 @@ struct rtcc_cc {
|
|||
uint8_t last_inst_ind; /* Last saved inst indication */
|
||||
};
|
||||
|
||||
|
||||
struct sctp_nets {
|
||||
TAILQ_ENTRY(sctp_nets) sctp_next; /* next link */
|
||||
|
||||
|
@ -317,7 +337,7 @@ struct sctp_nets {
|
|||
int lastsa;
|
||||
int lastsv;
|
||||
uint64_t rtt; /* last measured rtt value in us */
|
||||
unsigned int RTO;
|
||||
uint32_t RTO;
|
||||
|
||||
/* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */
|
||||
struct sctp_timer rxt_timer;
|
||||
|
@ -426,18 +446,17 @@ struct sctp_nets {
|
|||
uint8_t last_hs_used; /* index into the last HS table entry we used */
|
||||
uint8_t lan_type;
|
||||
uint8_t rto_needed;
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint32_t flowid;
|
||||
uint8_t flowtype;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct sctp_data_chunkrec {
|
||||
uint32_t TSN_seq; /* the TSN of this transmit */
|
||||
uint16_t stream_seq; /* the stream sequence number of this transmit */
|
||||
uint16_t stream_number; /* the stream number of this guy */
|
||||
uint32_t payloadtype;
|
||||
uint32_t tsn; /* the TSN of this transmit */
|
||||
uint32_t mid; /* the message identifier of this transmit */
|
||||
uint16_t sid; /* the stream number of this guy */
|
||||
uint32_t ppid;
|
||||
uint32_t context; /* from send */
|
||||
uint32_t cwnd_at_send;
|
||||
/*
|
||||
|
@ -446,6 +465,7 @@ struct sctp_data_chunkrec {
|
|||
*/
|
||||
uint32_t fast_retran_tsn; /* sending_seq at the time of FR */
|
||||
struct timeval timetodrop; /* time we drop it from queue */
|
||||
uint32_t fsn; /* Fragment Sequence Number */
|
||||
uint8_t doing_fast_retransmit;
|
||||
uint8_t rcv_flags; /* flags pulled from data chunk on inbound for
|
||||
* outbound holds sending flags for PR-SCTP.
|
||||
|
@ -470,7 +490,6 @@ struct chk_id {
|
|||
uint8_t can_take_data;
|
||||
};
|
||||
|
||||
|
||||
struct sctp_tmit_chunk {
|
||||
union {
|
||||
struct sctp_data_chunkrec data;
|
||||
|
@ -498,14 +517,8 @@ struct sctp_tmit_chunk {
|
|||
uint8_t window_probe;
|
||||
};
|
||||
|
||||
/*
|
||||
* The first part of this structure MUST be the entire sinfo structure. Maybe
|
||||
* I should have made it a sub structure... we can circle back later and do
|
||||
* that if we want.
|
||||
*/
|
||||
struct sctp_queued_to_read { /* sinfo structure Pluse more */
|
||||
uint16_t sinfo_stream; /* off the wire */
|
||||
uint16_t sinfo_ssn; /* off the wire */
|
||||
uint16_t sinfo_flags; /* SCTP_UNORDERED from wire use SCTP_EOF for
|
||||
* EOR */
|
||||
uint32_t sinfo_ppid; /* off the wire */
|
||||
|
@ -515,8 +528,11 @@ struct sctp_queued_to_read { /* sinfo structure Pluse more */
|
|||
uint32_t sinfo_cumtsn; /* Use this in reassembly as last TSN */
|
||||
sctp_assoc_t sinfo_assoc_id; /* our assoc id */
|
||||
/* Non sinfo stuff */
|
||||
uint32_t mid; /* Fragment Index */
|
||||
uint32_t length; /* length of data */
|
||||
uint32_t held_length; /* length held in sb */
|
||||
uint32_t top_fsn; /* Highest FSN in queue */
|
||||
uint32_t fsn_included; /* Highest FSN in *data portion */
|
||||
struct sctp_nets *whoFrom; /* where it came from */
|
||||
struct mbuf *data; /* front of the mbuf chain of data with
|
||||
* PKT_HDR */
|
||||
|
@ -524,14 +540,24 @@ struct sctp_queued_to_read { /* sinfo structure Pluse more */
|
|||
struct mbuf *aux_data; /* used to hold/cache control if o/s does not take it from us */
|
||||
struct sctp_tcb *stcb; /* assoc, used for window update */
|
||||
TAILQ_ENTRY(sctp_queued_to_read) next;
|
||||
TAILQ_ENTRY(sctp_queued_to_read) next_instrm;
|
||||
struct sctpchunk_listhead reasm;
|
||||
uint16_t port_from;
|
||||
uint16_t spec_flags; /* Flags to hold the notification field */
|
||||
uint8_t do_not_ref_stcb;
|
||||
uint8_t end_added;
|
||||
uint8_t pdapi_aborted;
|
||||
uint8_t pdapi_started;
|
||||
uint8_t some_taken;
|
||||
uint8_t last_frag_seen;
|
||||
uint8_t first_frag_seen;
|
||||
uint8_t on_read_q;
|
||||
uint8_t on_strm_q;
|
||||
};
|
||||
|
||||
#define SCTP_ON_ORDERED 1
|
||||
#define SCTP_ON_UNORDERED 2
|
||||
|
||||
/* This data structure will be on the outbound
|
||||
* stream queues. Data will be pulled off from
|
||||
* the front of the mbuf data and chunk-ified
|
||||
|
@ -549,6 +575,7 @@ struct sctp_queued_to_read { /* sinfo structure Pluse more */
|
|||
* the user is in the explict MSG_EOR mode
|
||||
* and wrote some data, but has not completed
|
||||
* sending.
|
||||
* ss_next and scheduled are only used by the FCFS stream scheduler.
|
||||
*/
|
||||
struct sctp_stream_queue_pending {
|
||||
struct mbuf *data;
|
||||
|
@ -557,12 +584,13 @@ struct sctp_stream_queue_pending {
|
|||
struct sctp_nets *net;
|
||||
TAILQ_ENTRY (sctp_stream_queue_pending) next;
|
||||
TAILQ_ENTRY (sctp_stream_queue_pending) ss_next;
|
||||
uint32_t fsn;
|
||||
uint32_t length;
|
||||
uint32_t timetolive;
|
||||
uint32_t ppid;
|
||||
uint32_t context;
|
||||
uint16_t sinfo_flags;
|
||||
uint16_t stream;
|
||||
uint16_t sid;
|
||||
uint16_t act_flags;
|
||||
uint16_t auth_keyid;
|
||||
uint8_t holds_key_ref;
|
||||
|
@ -571,6 +599,8 @@ struct sctp_stream_queue_pending {
|
|||
uint8_t sender_all_done;
|
||||
uint8_t put_last_out;
|
||||
uint8_t discard_rest;
|
||||
uint8_t processing;
|
||||
bool scheduled;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -580,14 +610,30 @@ struct sctp_stream_queue_pending {
|
|||
TAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in);
|
||||
struct sctp_stream_in {
|
||||
struct sctp_readhead inqueue;
|
||||
uint16_t stream_no;
|
||||
uint16_t last_sequence_delivered; /* used for re-order */
|
||||
struct sctp_readhead uno_inqueue;
|
||||
uint32_t last_mid_delivered; /* used for re-order */
|
||||
uint16_t sid;
|
||||
uint8_t delivery_started;
|
||||
uint8_t pd_api_started;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(sctpwheel_listhead, sctp_stream_out);
|
||||
TAILQ_HEAD(sctplist_listhead, sctp_stream_queue_pending);
|
||||
|
||||
/*
|
||||
* This union holds all data necessary for
|
||||
* different stream schedulers.
|
||||
*/
|
||||
struct scheduling_data {
|
||||
struct sctp_stream_out *locked_on_sending;
|
||||
/* circular looking for output selection */
|
||||
struct sctp_stream_out *last_out_stream;
|
||||
union {
|
||||
struct sctpwheel_listhead wheel;
|
||||
struct sctplist_listhead list;
|
||||
} out;
|
||||
};
|
||||
|
||||
/* Round-robin schedulers */
|
||||
struct ss_rr {
|
||||
/* next link in wheel */
|
||||
|
@ -610,30 +656,31 @@ struct ss_fb {
|
|||
int32_t rounds;
|
||||
};
|
||||
|
||||
/*
|
||||
* This union holds all data necessary for
|
||||
* different stream schedulers.
|
||||
*/
|
||||
union scheduling_data {
|
||||
struct sctpwheel_listhead out_wheel;
|
||||
struct sctplist_listhead out_list;
|
||||
};
|
||||
|
||||
/*
|
||||
* This union holds all parameters per stream
|
||||
* necessary for different stream schedulers.
|
||||
*/
|
||||
union scheduling_parameters {
|
||||
struct ss_rr rr;
|
||||
struct ss_prio prio;
|
||||
struct ss_fb fb;
|
||||
struct scheduling_parameters {
|
||||
union {
|
||||
struct ss_rr rr;
|
||||
struct ss_prio prio;
|
||||
struct ss_fb fb;
|
||||
} ss;
|
||||
bool scheduled;
|
||||
};
|
||||
|
||||
/* States for outgoing streams */
|
||||
#define SCTP_STREAM_CLOSED 0x00
|
||||
#define SCTP_STREAM_OPENING 0x01
|
||||
#define SCTP_STREAM_OPEN 0x02
|
||||
#define SCTP_STREAM_RESET_PENDING 0x03
|
||||
#define SCTP_STREAM_RESET_IN_FLIGHT 0x04
|
||||
|
||||
/* This struct is used to track the traffic on outbound streams */
|
||||
struct sctp_stream_out {
|
||||
struct sctp_streamhead outqueue;
|
||||
union scheduling_parameters ss_params;
|
||||
uint32_t chunks_on_queues;
|
||||
struct scheduling_parameters ss_params;
|
||||
uint32_t chunks_on_queues; /* send queue and sent queue */
|
||||
#if defined(SCTP_DETAILED_STR_STATS)
|
||||
uint32_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1];
|
||||
uint32_t abandoned_sent[SCTP_PR_SCTP_MAX + 1];
|
||||
|
@ -642,11 +689,18 @@ struct sctp_stream_out {
|
|||
uint32_t abandoned_unsent[1];
|
||||
uint32_t abandoned_sent[1];
|
||||
#endif
|
||||
uint16_t stream_no;
|
||||
uint16_t next_sequence_send; /* next one I expect to send out */
|
||||
/* For associations using DATA chunks, the lower 16-bit of
|
||||
* next_mid_ordered are used as the next SSN.
|
||||
*/
|
||||
uint32_t next_mid_ordered;
|
||||
uint32_t next_mid_unordered;
|
||||
uint16_t sid;
|
||||
uint8_t last_msg_incomplete;
|
||||
uint8_t state;
|
||||
};
|
||||
|
||||
#define SCTP_MAX_STREAMS_AT_ONCE_RESET 200
|
||||
|
||||
/* used to keep track of the addresses yet to try to add/delete */
|
||||
TAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr);
|
||||
struct sctp_asconf_addr {
|
||||
|
@ -674,12 +728,13 @@ struct sctp_scoping {
|
|||
struct sctp_tsn_log {
|
||||
void *stcb;
|
||||
uint32_t tsn;
|
||||
uint32_t seq;
|
||||
uint16_t strm;
|
||||
uint16_t seq;
|
||||
uint16_t sz;
|
||||
uint16_t flgs;
|
||||
uint16_t in_pos;
|
||||
uint16_t in_out;
|
||||
uint16_t resv;
|
||||
};
|
||||
|
||||
#define SCTP_FS_SPEC_LOG_SIZE 200
|
||||
|
@ -692,26 +747,6 @@ struct sctp_fs_spec_log {
|
|||
uint8_t decr;
|
||||
};
|
||||
|
||||
/* This struct is here to cut out the compatiabilty
|
||||
* pad that bulks up both the inp and stcb. The non
|
||||
* pad portion MUST stay in complete sync with
|
||||
* sctp_sndrcvinfo... i.e. if sinfo_xxxx is added
|
||||
* this must be done here too.
|
||||
*/
|
||||
struct sctp_nonpad_sndrcvinfo {
|
||||
uint16_t sinfo_stream;
|
||||
uint16_t sinfo_ssn;
|
||||
uint16_t sinfo_flags;
|
||||
uint32_t sinfo_ppid;
|
||||
uint32_t sinfo_context;
|
||||
uint32_t sinfo_timetolive;
|
||||
uint32_t sinfo_tsn;
|
||||
uint32_t sinfo_cumtsn;
|
||||
sctp_assoc_t sinfo_assoc_id;
|
||||
uint16_t sinfo_keynumber;
|
||||
uint16_t sinfo_keynumber_valid;
|
||||
};
|
||||
|
||||
/*
|
||||
* JRS - Structure to hold function pointers to the functions responsible
|
||||
* for congestion control.
|
||||
|
@ -751,16 +786,15 @@ struct sctp_cc_functions {
|
|||
* for stream scheduling.
|
||||
*/
|
||||
struct sctp_ss_functions {
|
||||
void (*sctp_ss_init)(struct sctp_tcb *stcb, struct sctp_association *asoc,
|
||||
int holds_lock);
|
||||
void (*sctp_ss_init)(struct sctp_tcb *stcb, struct sctp_association *asoc);
|
||||
void (*sctp_ss_clear)(struct sctp_tcb *stcb, struct sctp_association *asoc,
|
||||
int clear_values, int holds_lock);
|
||||
void (*sctp_ss_init_stream)(struct sctp_stream_out *strq, struct sctp_stream_out *with_strq);
|
||||
bool clear_values);
|
||||
void (*sctp_ss_init_stream)(struct sctp_tcb *stcb, struct sctp_stream_out *strq, struct sctp_stream_out *with_strq);
|
||||
void (*sctp_ss_add_to_stream)(struct sctp_tcb *stcb, struct sctp_association *asoc,
|
||||
struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock);
|
||||
int (*sctp_ss_is_empty)(struct sctp_tcb *stcb, struct sctp_association *asoc);
|
||||
struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp);
|
||||
bool (*sctp_ss_is_empty)(struct sctp_tcb *stcb, struct sctp_association *asoc);
|
||||
void (*sctp_ss_remove_from_stream)(struct sctp_tcb *stcb, struct sctp_association *asoc,
|
||||
struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock);
|
||||
struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp);
|
||||
struct sctp_stream_out* (*sctp_ss_select_stream)(struct sctp_tcb *stcb,
|
||||
struct sctp_nets *net, struct sctp_association *asoc);
|
||||
void (*sctp_ss_scheduled)(struct sctp_tcb *stcb, struct sctp_nets *net,
|
||||
|
@ -771,6 +805,7 @@ struct sctp_ss_functions {
|
|||
struct sctp_stream_out *strq, uint16_t *value);
|
||||
int (*sctp_ss_set_value)(struct sctp_tcb *stcb, struct sctp_association *asoc,
|
||||
struct sctp_stream_out *strq, uint16_t value);
|
||||
bool (*sctp_ss_is_user_msgs_incomplete)(struct sctp_tcb *stcb, struct sctp_association *asoc);
|
||||
};
|
||||
|
||||
/* used to save ASCONF chunks for retransmission */
|
||||
|
@ -818,7 +853,6 @@ struct sctp_association {
|
|||
struct sctp_timer strreset_timer; /* stream reset */
|
||||
struct sctp_timer shut_guard_timer; /* shutdown guard */
|
||||
struct sctp_timer autoclose_timer; /* automatic close timer */
|
||||
struct sctp_timer delayed_event_timer; /* timer for delayed events */
|
||||
struct sctp_timer delete_prim_timer; /* deleting primary dst */
|
||||
|
||||
/* list of restricted local addresses */
|
||||
|
@ -850,20 +884,8 @@ struct sctp_association {
|
|||
struct sctpchunk_listhead sent_queue;
|
||||
struct sctpchunk_listhead send_queue;
|
||||
|
||||
/* re-assembly queue for fragmented chunks on the inbound path */
|
||||
struct sctpchunk_listhead reasmqueue;
|
||||
|
||||
/* Scheduling queues */
|
||||
union scheduling_data ss_data;
|
||||
|
||||
/* This pointer will be set to NULL
|
||||
* most of the time. But when we have
|
||||
* a fragmented message, where we could
|
||||
* not get out all of the message at
|
||||
* the last send then this will point
|
||||
* to the stream to go get data from.
|
||||
*/
|
||||
struct sctp_stream_out *locked_on_sending;
|
||||
struct scheduling_data ss_data;
|
||||
|
||||
/* If an iterator is looking at me, this is it */
|
||||
struct sctp_iterator *stcb_starting_point_for_iterator;
|
||||
|
@ -896,9 +918,6 @@ struct sctp_association {
|
|||
/* last place I got a control from */
|
||||
struct sctp_nets *last_control_chunk_from;
|
||||
|
||||
/* circular looking for output selection */
|
||||
struct sctp_stream_out *last_out_stream;
|
||||
|
||||
/*
|
||||
* wait to the point the cum-ack passes req->send_reset_at_tsn for
|
||||
* any req on the list.
|
||||
|
@ -918,7 +937,6 @@ struct sctp_association {
|
|||
uint32_t stream_scheduling_module;
|
||||
|
||||
uint32_t vrf_id;
|
||||
|
||||
uint32_t cookie_preserve_req;
|
||||
/* ASCONF next seq I am sending out, inits at init-tsn */
|
||||
uint32_t asconf_seq_out;
|
||||
|
@ -963,7 +981,6 @@ struct sctp_association {
|
|||
/* Original seq number I used ??questionable to keep?? */
|
||||
uint32_t init_seq_number;
|
||||
|
||||
|
||||
/* The Advanced Peer Ack Point, as required by the PR-SCTP */
|
||||
/* (A1 in Section 4.2) */
|
||||
uint32_t advanced_peer_ack_point;
|
||||
|
@ -992,7 +1009,7 @@ struct sctp_association {
|
|||
uint32_t sat_t3_recovery_tsn;
|
||||
uint32_t tsn_last_delivered;
|
||||
/*
|
||||
* For the pd-api we should re-write this a bit more efficent. We
|
||||
* For the pd-api we should re-write this a bit more efficient. We
|
||||
* could have multiple sctp_queued_to_read's that we are building at
|
||||
* once. Now we only do this when we get ready to deliver to the
|
||||
* socket buffer. Note that we depend on the fact that the struct is
|
||||
|
@ -1087,7 +1104,7 @@ struct sctp_association {
|
|||
uint32_t heart_beat_delay;
|
||||
|
||||
/* autoclose */
|
||||
unsigned int sctp_autoclose_ticks;
|
||||
uint32_t sctp_autoclose_ticks;
|
||||
|
||||
/* how many preopen streams we have */
|
||||
unsigned int pre_open_streams;
|
||||
|
@ -1096,7 +1113,7 @@ struct sctp_association {
|
|||
unsigned int max_inbound_streams;
|
||||
|
||||
/* the cookie life I award for any cookie, in seconds */
|
||||
unsigned int cookie_life;
|
||||
uint32_t cookie_life;
|
||||
/* time to delay acks for */
|
||||
unsigned int delayed_ack;
|
||||
unsigned int old_delayed_ack;
|
||||
|
@ -1105,10 +1122,10 @@ struct sctp_association {
|
|||
|
||||
unsigned int numduptsns;
|
||||
int dup_tsns[SCTP_MAX_DUP_TSNS];
|
||||
unsigned int initial_init_rto_max; /* initial RTO for INIT's */
|
||||
unsigned int initial_rto; /* initial send RTO */
|
||||
unsigned int minrto; /* per assoc RTO-MIN */
|
||||
unsigned int maxrto; /* per assoc RTO-MAX */
|
||||
uint32_t initial_init_rto_max; /* initial RTO for INIT's */
|
||||
uint32_t initial_rto; /* initial send RTO */
|
||||
uint32_t minrto; /* per assoc RTO-MIN */
|
||||
uint32_t maxrto; /* per assoc RTO-MAX */
|
||||
|
||||
/* authentication fields */
|
||||
sctp_auth_chklist_t *local_auth_chunks;
|
||||
|
@ -1125,6 +1142,7 @@ struct sctp_association {
|
|||
uint32_t chunks_on_out_queue; /* total chunks floating around,
|
||||
* locked by send socket buffer */
|
||||
uint32_t peers_adaptation;
|
||||
uint32_t default_mtu;
|
||||
uint16_t peer_hmac_id; /* peer HMAC id to send */
|
||||
|
||||
/*
|
||||
|
@ -1198,7 +1216,7 @@ struct sctp_association {
|
|||
uint8_t hb_random_idx;
|
||||
uint8_t default_dscp;
|
||||
uint8_t asconf_del_pending; /* asconf delete last addr pending */
|
||||
|
||||
uint8_t trigger_reset;
|
||||
/*
|
||||
* This value, plus all other ack'd but above cum-ack is added
|
||||
* together to cross check against the bit that we have yet to
|
||||
|
@ -1214,17 +1232,23 @@ struct sctp_association {
|
|||
uint8_t reconfig_supported;
|
||||
uint8_t nrsack_supported;
|
||||
uint8_t pktdrop_supported;
|
||||
uint8_t idata_supported;
|
||||
|
||||
/* Zero checksum supported information:
|
||||
* 0: disabled
|
||||
* 1: enabled for rcv
|
||||
* 2: enabled for snd/rcv
|
||||
*/
|
||||
uint8_t zero_checksum;
|
||||
|
||||
/* Did the peer make the stream config (add out) request */
|
||||
uint8_t peer_req_out;
|
||||
|
||||
uint8_t local_strreset_support;
|
||||
|
||||
uint8_t peer_supports_nat;
|
||||
|
||||
struct sctp_scoping scope;
|
||||
/* flags to handle send alternate net tracking */
|
||||
uint8_t used_alt_onsack;
|
||||
uint8_t used_alt_asconfack;
|
||||
uint8_t fast_retran_loss_recovery;
|
||||
uint8_t sat_t3_loss_recovery;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.h 271204 2014-09-06 19:12:14Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_SYSCTL_H_
|
||||
|
@ -54,11 +56,8 @@ struct sctp_sysctl {
|
|||
uint32_t sctp_nrsack_enable;
|
||||
uint32_t sctp_pktdrop_enable;
|
||||
uint32_t sctp_fr_max_burst_default;
|
||||
uint32_t sctp_strict_sacks;
|
||||
#if !(defined(__FreeBSD__) && __FreeBSD_version >= 800000)
|
||||
#if !defined(SCTP_WITH_NO_CSUM)
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
uint32_t sctp_no_csum_on_loopback;
|
||||
#endif
|
||||
#endif
|
||||
uint32_t sctp_peer_chunk_oh;
|
||||
uint32_t sctp_max_burst_default;
|
||||
|
@ -96,7 +95,6 @@ struct sctp_sysctl {
|
|||
uint32_t sctp_do_drain;
|
||||
uint32_t sctp_hb_maxburst;
|
||||
uint32_t sctp_abort_if_one_2_one_hits_limit;
|
||||
uint32_t sctp_strict_data_order;
|
||||
uint32_t sctp_min_residual;
|
||||
uint32_t sctp_max_retran_chunk;
|
||||
uint32_t sctp_logging_level;
|
||||
|
@ -113,9 +111,8 @@ struct sctp_sysctl {
|
|||
uint32_t sctp_rttvar_eqret;
|
||||
uint32_t sctp_steady_step;
|
||||
uint32_t sctp_use_dccc_ecn;
|
||||
uint32_t sctp_diag_info_code;
|
||||
#if defined(SCTP_LOCAL_TRACE_BUF)
|
||||
#if defined(__Windows__)
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
struct sctp_log *sctp_log;
|
||||
#else
|
||||
struct sctp_log sctp_log;
|
||||
|
@ -127,16 +124,19 @@ struct sctp_sysctl {
|
|||
uint32_t sctp_buffer_splitting;
|
||||
uint32_t sctp_initial_cwnd;
|
||||
uint32_t sctp_blackhole;
|
||||
uint32_t sctp_sendall_limit;
|
||||
uint32_t sctp_diag_info_code;
|
||||
uint32_t sctp_ootb_with_zero_cksum;
|
||||
#if defined(SCTP_DEBUG)
|
||||
uint32_t sctp_debug_on;
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
uint32_t sctp_ignore_vmware_interfaces;
|
||||
uint32_t sctp_main_timer;
|
||||
uint32_t sctp_addr_watchdog_limit;
|
||||
uint32_t sctp_vtag_watchdog_limit;
|
||||
#endif
|
||||
#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
uint32_t sctp_output_unlocked;
|
||||
#endif
|
||||
};
|
||||
|
@ -148,13 +148,21 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_MAXDGRAM_DESC "Maximum outgoing SCTP buffer size"
|
||||
#define SCTPCTL_MAXDGRAM_MIN 0
|
||||
#define SCTPCTL_MAXDGRAM_MAX 0xFFFFFFFF
|
||||
#if defined(__Userspace__)
|
||||
#define SCTPCTL_MAXDGRAM_DEFAULT SB_MAX
|
||||
#else
|
||||
#define SCTPCTL_MAXDGRAM_DEFAULT 262144 /* 256k */
|
||||
#endif
|
||||
|
||||
/* recvspace: Maximum incoming SCTP buffer size */
|
||||
#define SCTPCTL_RECVSPACE_DESC "Maximum incoming SCTP buffer size"
|
||||
#define SCTPCTL_RECVSPACE_MIN 0
|
||||
#define SCTPCTL_RECVSPACE_MAX 0xFFFFFFFF
|
||||
#if defined(__Userspace__)
|
||||
#define SCTPCTL_RECVSPACE_DEFAULT SB_RAW
|
||||
#else
|
||||
#define SCTPCTL_RECVSPACE_DEFAULT 262144 /* 256k */
|
||||
#endif
|
||||
|
||||
/* autoasconf: Enable SCTP Auto-ASCONF */
|
||||
#define SCTPCTL_AUTOASCONF_DESC "Enable SCTP Auto-ASCONF"
|
||||
|
@ -163,7 +171,7 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_AUTOASCONF_DEFAULT 1
|
||||
|
||||
/* autoasconf: Enable SCTP Auto-ASCONF */
|
||||
#define SCTPCTL_MULTIPLEASCONFS_DESC "Enable SCTP Muliple-ASCONFs"
|
||||
#define SCTPCTL_MULTIPLEASCONFS_DESC "Enable SCTP Multiple-ASCONFs"
|
||||
#define SCTPCTL_MULTIPLEASCONFS_MIN 0
|
||||
#define SCTPCTL_MULTIPLEASCONFS_MAX 1
|
||||
#define SCTPCTL_MULTIPLEASCONFS_DEFAULT SCTP_DEFAULT_MULTIPLE_ASCONFS
|
||||
|
@ -210,12 +218,6 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_PKTDROP_ENABLE_MAX 1
|
||||
#define SCTPCTL_PKTDROP_ENABLE_DEFAULT 0
|
||||
|
||||
/* strict_sacks: Enable SCTP Strict SACK checking */
|
||||
#define SCTPCTL_STRICT_SACKS_DESC "Enable SCTP Strict SACK checking"
|
||||
#define SCTPCTL_STRICT_SACKS_MIN 0
|
||||
#define SCTPCTL_STRICT_SACKS_MAX 1
|
||||
#define SCTPCTL_STRICT_SACKS_DEFAULT 1
|
||||
|
||||
/* loopback_nocsum: Enable NO Csum on packets sent on loopback */
|
||||
#define SCTPCTL_LOOPBACK_NOCSUM_DESC "Enable NO Csum on packets sent on loopback"
|
||||
#define SCTPCTL_LOOPBACK_NOCSUM_MIN 0
|
||||
|
@ -235,12 +237,11 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_MAXBURST_DEFAULT SCTP_DEF_MAX_BURST
|
||||
|
||||
/* fr_maxburst: Default max burst for sctp endpoints when fast retransmitting */
|
||||
#define SCTPCTL_FRMAXBURST_DESC "Default fr max burst for sctp endpoints"
|
||||
#define SCTPCTL_FRMAXBURST_DESC "Default max burst for SCTP endpoints when fast retransmitting"
|
||||
#define SCTPCTL_FRMAXBURST_MIN 0
|
||||
#define SCTPCTL_FRMAXBURST_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_FRMAXBURST_DEFAULT SCTP_DEF_FRMAX_BURST
|
||||
|
||||
|
||||
/* maxchunks: Default max chunks on queue per asoc */
|
||||
#define SCTPCTL_MAXCHUNKS_DESC "Default max chunks on queue per asoc"
|
||||
#define SCTPCTL_MAXCHUNKS_MIN 0
|
||||
|
@ -266,7 +267,7 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_MIN_SPLIT_POINT_DEFAULT SCTP_DEFAULT_SPLIT_POINT_MIN
|
||||
|
||||
/* chunkscale: Tunable for Scaling of number of chunks and messages */
|
||||
#define SCTPCTL_CHUNKSCALE_DESC "Tunable for Scaling of number of chunks and messages"
|
||||
#define SCTPCTL_CHUNKSCALE_DESC "Tunable for scaling of number of chunks and messages"
|
||||
#define SCTPCTL_CHUNKSCALE_MIN 1
|
||||
#define SCTPCTL_CHUNKSCALE_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_CHUNKSCALE_DEFAULT SCTP_CHUNKQUEUE_SCALE
|
||||
|
@ -308,10 +309,10 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_PMTU_RAISE_TIME_DEFAULT SCTP_DEF_PMTU_RAISE_SEC
|
||||
|
||||
/* shutdown_guard_time: Default shutdown guard timer in seconds */
|
||||
#define SCTPCTL_SHUTDOWN_GUARD_TIME_DESC "Default shutdown guard timer in seconds"
|
||||
#define SCTPCTL_SHUTDOWN_GUARD_TIME_DESC "Shutdown guard timer in seconds (0 means 5 times RTO.Max)"
|
||||
#define SCTPCTL_SHUTDOWN_GUARD_TIME_MIN 0
|
||||
#define SCTPCTL_SHUTDOWN_GUARD_TIME_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT SCTP_DEF_MAX_SHUTDOWN_SEC
|
||||
#define SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT 0
|
||||
|
||||
/* secret_lifetime: Default secret lifetime in seconds */
|
||||
#define SCTPCTL_SECRET_LIFETIME_DESC "Default secret lifetime in seconds"
|
||||
|
@ -343,14 +344,14 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_INIT_RTO_MAX_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_INIT_RTO_MAX_DEFAULT SCTP_RTO_UPPER_BOUND
|
||||
|
||||
/* valid_cookie_life: Default cookie lifetime in sec */
|
||||
#define SCTPCTL_VALID_COOKIE_LIFE_DESC "Default cookie lifetime in seconds"
|
||||
#define SCTPCTL_VALID_COOKIE_LIFE_MIN 0
|
||||
#define SCTPCTL_VALID_COOKIE_LIFE_MAX 0xFFFFFFFF
|
||||
/* valid_cookie_life: Default cookie lifetime in ms */
|
||||
#define SCTPCTL_VALID_COOKIE_LIFE_DESC "Default cookie lifetime in ms"
|
||||
#define SCTPCTL_VALID_COOKIE_LIFE_MIN SCTP_MIN_COOKIE_LIFE
|
||||
#define SCTPCTL_VALID_COOKIE_LIFE_MAX SCTP_MAX_COOKIE_LIFE
|
||||
#define SCTPCTL_VALID_COOKIE_LIFE_DEFAULT SCTP_DEFAULT_COOKIE_LIFE
|
||||
|
||||
/* init_rtx_max: Default maximum number of retransmission for INIT chunks */
|
||||
#define SCTPCTL_INIT_RTX_MAX_DESC "Default maximum number of retransmission for INIT chunks"
|
||||
#define SCTPCTL_INIT_RTX_MAX_DESC "Default maximum number of retransmissions for INIT chunks"
|
||||
#define SCTPCTL_INIT_RTX_MAX_MIN 0
|
||||
#define SCTPCTL_INIT_RTX_MAX_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_INIT_RTX_MAX_DEFAULT SCTP_DEF_MAX_INIT
|
||||
|
@ -403,8 +404,8 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_CMT_USE_DAC_MAX 1
|
||||
#define SCTPCTL_CMT_USE_DAC_DEFAULT 0
|
||||
|
||||
/* cwnd_maxburst: Use a CWND adjusting maxburst */
|
||||
#define SCTPCTL_CWND_MAXBURST_DESC "Use a CWND adjusting maxburst"
|
||||
/* cwnd_maxburst: Use a CWND adjusting to implement maxburst */
|
||||
#define SCTPCTL_CWND_MAXBURST_DESC "Adjust congestion control window to limit maximum burst when sending"
|
||||
#define SCTPCTL_CWND_MAXBURST_MIN 0
|
||||
#define SCTPCTL_CWND_MAXBURST_MAX 1
|
||||
#define SCTPCTL_CWND_MAXBURST_DEFAULT 1
|
||||
|
@ -440,17 +441,11 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_HB_MAX_BURST_DEFAULT SCTP_DEF_HBMAX_BURST
|
||||
|
||||
/* abort_at_limit: When one-2-one hits qlimit abort */
|
||||
#define SCTPCTL_ABORT_AT_LIMIT_DESC "When one-2-one hits qlimit abort"
|
||||
#define SCTPCTL_ABORT_AT_LIMIT_DESC "Abort when one-to-one hits qlimit"
|
||||
#define SCTPCTL_ABORT_AT_LIMIT_MIN 0
|
||||
#define SCTPCTL_ABORT_AT_LIMIT_MAX 1
|
||||
#define SCTPCTL_ABORT_AT_LIMIT_DEFAULT 0
|
||||
|
||||
/* strict_data_order: Enforce strict data ordering, abort if control inside data */
|
||||
#define SCTPCTL_STRICT_DATA_ORDER_DESC "Enforce strict data ordering, abort if control inside data"
|
||||
#define SCTPCTL_STRICT_DATA_ORDER_MIN 0
|
||||
#define SCTPCTL_STRICT_DATA_ORDER_MAX 1
|
||||
#define SCTPCTL_STRICT_DATA_ORDER_DEFAULT 0
|
||||
|
||||
/* min_residual: min residual in a data fragment leftover */
|
||||
#define SCTPCTL_MIN_RESIDUAL_DESC "Minimum residual data chunk in second part of split"
|
||||
#define SCTPCTL_MIN_RESIDUAL_MIN 20
|
||||
|
@ -458,7 +453,7 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_MIN_RESIDUAL_DEFAULT 1452
|
||||
|
||||
/* max_retran_chunk: max chunk retransmissions */
|
||||
#define SCTPCTL_MAX_RETRAN_CHUNK_DESC "Maximum times an unlucky chunk can be retran'd before assoc abort"
|
||||
#define SCTPCTL_MAX_RETRAN_CHUNK_DESC "Maximum times an unlucky chunk can be retransmitted before assoc abort"
|
||||
#define SCTPCTL_MAX_RETRAN_CHUNK_MIN 0
|
||||
#define SCTPCTL_MAX_RETRAN_CHUNK_MAX 65535
|
||||
#define SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT 30
|
||||
|
@ -503,79 +498,90 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_UDP_TUNNELING_PORT_DESC "Set the SCTP/UDP tunneling port"
|
||||
#define SCTPCTL_UDP_TUNNELING_PORT_MIN 0
|
||||
#define SCTPCTL_UDP_TUNNELING_PORT_MAX 65535
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#define SCTPCTL_UDP_TUNNELING_PORT_DEFAULT 0
|
||||
#else
|
||||
#define SCTPCTL_UDP_TUNNELING_PORT_DEFAULT SCTP_OVER_UDP_TUNNELING_PORT
|
||||
#endif
|
||||
|
||||
/* Enable sending of the SACK-IMMEDIATELY bit */
|
||||
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC "Enable sending of the SACK-IMMEDIATELY-bit."
|
||||
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC "Enable sending of the SACK-IMMEDIATELY-bit"
|
||||
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN 0
|
||||
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX 1
|
||||
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN
|
||||
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX
|
||||
|
||||
/* Enable sending of the NAT-FRIENDLY message */
|
||||
#define SCTPCTL_NAT_FRIENDLY_INITS_DESC "Enable sending of the nat-friendly SCTP option on INITs."
|
||||
#define SCTPCTL_NAT_FRIENDLY_INITS_DESC "Enable sending of the nat-friendly SCTP option on INITs"
|
||||
#define SCTPCTL_NAT_FRIENDLY_INITS_MIN 0
|
||||
#define SCTPCTL_NAT_FRIENDLY_INITS_MAX 1
|
||||
#define SCTPCTL_NAT_FRIENDLY_INITS_DEFAULT SCTPCTL_NAT_FRIENDLY_INITS_MIN
|
||||
|
||||
/* Vtag time wait in seconds */
|
||||
#define SCTPCTL_TIME_WAIT_DESC "Vtag time wait time in seconds, 0 disables it."
|
||||
#define SCTPCTL_TIME_WAIT_DESC "Vtag time wait time in seconds, 0 disables it"
|
||||
#define SCTPCTL_TIME_WAIT_MIN 0
|
||||
#define SCTPCTL_TIME_WAIT_MAX 0xffffffff
|
||||
#define SCTPCTL_TIME_WAIT_DEFAULT SCTP_TIME_WAIT
|
||||
|
||||
/* Enable Send/Receive buffer splitting */
|
||||
#define SCTPCTL_BUFFER_SPLITTING_DESC "Enable send/receive buffer splitting."
|
||||
#define SCTPCTL_BUFFER_SPLITTING_DESC "Enable send/receive buffer splitting"
|
||||
#define SCTPCTL_BUFFER_SPLITTING_MIN 0
|
||||
#define SCTPCTL_BUFFER_SPLITTING_MAX 0x3
|
||||
#define SCTPCTL_BUFFER_SPLITTING_DEFAULT SCTPCTL_BUFFER_SPLITTING_MIN
|
||||
|
||||
/* Initial congestion window in MTU */
|
||||
#define SCTPCTL_INITIAL_CWND_DESC "Initial congestion window in MTUs"
|
||||
/* Initial congestion window in MTUs */
|
||||
#define SCTPCTL_INITIAL_CWND_DESC "Defines the initial congestion window size in MTUs"
|
||||
#define SCTPCTL_INITIAL_CWND_MIN 0
|
||||
#define SCTPCTL_INITIAL_CWND_MAX 0xffffffff
|
||||
#define SCTPCTL_INITIAL_CWND_DEFAULT 3
|
||||
|
||||
/* rttvar smooth avg for bw calc */
|
||||
#define SCTPCTL_RTTVAR_BW_DESC "Shift amount for bw smoothing on rtt calc"
|
||||
#define SCTPCTL_RTTVAR_BW_DESC "Shift amount DCCC uses for bw smoothing on rtt calc"
|
||||
#define SCTPCTL_RTTVAR_BW_MIN 0
|
||||
#define SCTPCTL_RTTVAR_BW_MAX 32
|
||||
#define SCTPCTL_RTTVAR_BW_DEFAULT 4
|
||||
|
||||
/* rttvar smooth avg for bw calc */
|
||||
#define SCTPCTL_RTTVAR_RTT_DESC "Shift amount for rtt smoothing on rtt calc"
|
||||
#define SCTPCTL_RTTVAR_RTT_DESC "Shift amount DCCC uses for rtt smoothing on rtt calc"
|
||||
#define SCTPCTL_RTTVAR_RTT_MIN 0
|
||||
#define SCTPCTL_RTTVAR_RTT_MAX 32
|
||||
#define SCTPCTL_RTTVAR_RTT_DEFAULT 5
|
||||
|
||||
#define SCTPCTL_RTTVAR_EQRET_DESC "What to return when rtt and bw are unchanged"
|
||||
#define SCTPCTL_RTTVAR_EQRET_DESC "Whether DCCC increases cwnd when the rtt and bw are unchanged"
|
||||
#define SCTPCTL_RTTVAR_EQRET_MIN 0
|
||||
#define SCTPCTL_RTTVAR_EQRET_MAX 1
|
||||
#define SCTPCTL_RTTVAR_EQRET_DEFAULT 0
|
||||
|
||||
#define SCTPCTL_RTTVAR_STEADYS_DESC "How many the sames it takes to try step down of cwnd"
|
||||
#define SCTPCTL_RTTVAR_STEADYS_DESC "Number of identical bw measurements DCCC takes to try step down of cwnd"
|
||||
#define SCTPCTL_RTTVAR_STEADYS_MIN 0
|
||||
#define SCTPCTL_RTTVAR_STEADYS_MAX 0xFFFF
|
||||
#define SCTPCTL_RTTVAR_STEADYS_DEFAULT 20 /* 0 means disable feature */
|
||||
|
||||
#define SCTPCTL_RTTVAR_DCCCECN_DESC "Enable for RTCC CC datacenter ECN"
|
||||
#define SCTPCTL_RTTVAR_DCCCECN_DESC "Enable ECN for DCCC."
|
||||
#define SCTPCTL_RTTVAR_DCCCECN_MIN 0
|
||||
#define SCTPCTL_RTTVAR_DCCCECN_MAX 1
|
||||
#define SCTPCTL_RTTVAR_DCCCECN_DEFAULT 1 /* 0 means disable feature */
|
||||
|
||||
#define SCTPCTL_BLACKHOLE_DESC "Enable SCTP blackholing"
|
||||
#define SCTPCTL_BLACKHOLE_DESC "Enable SCTP blackholing, see blackhole(4) for more details"
|
||||
#define SCTPCTL_BLACKHOLE_MIN 0
|
||||
#define SCTPCTL_BLACKHOLE_MAX 2
|
||||
#define SCTPCTL_BLACKHOLE_DEFAULT SCTPCTL_BLACKHOLE_MIN
|
||||
|
||||
/* sendall_limit: Maximum message with SCTP_SENDALL */
|
||||
#define SCTPCTL_SENDALL_LIMIT_DESC "Maximum size of a message send with SCTP_SENDALL"
|
||||
#define SCTPCTL_SENDALL_LIMIT_MIN 0
|
||||
#define SCTPCTL_SENDALL_LIMIT_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_SENDALL_LIMIT_DEFAULT 1432
|
||||
|
||||
#define SCTPCTL_DIAG_INFO_CODE_DESC "Diagnostic information error cause code"
|
||||
#define SCTPCTL_DIAG_INFO_CODE_MIN 0
|
||||
#define SCTPCTL_DIAG_INFO_CODE_MAX 65535
|
||||
#define SCTPCTL_DIAG_INFO_CODE_DEFAULT 0
|
||||
|
||||
#define SCTPCTL_OOTB_WITH_ZERO_CKSUM_DESC "Accept OOTB packets with zero checksum"
|
||||
#define SCTPCTL_OOTB_WITH_ZERO_CKSUM_MIN 0
|
||||
#define SCTPCTL_OOTB_WITH_ZERO_CKSUM_MAX 1
|
||||
#define SCTPCTL_OOTB_WITH_ZERO_CKSUM_DEFAULT 0
|
||||
|
||||
#if defined(SCTP_DEBUG)
|
||||
/* debug: Configure debug output */
|
||||
#define SCTPCTL_DEBUG_DESC "Configure debug output"
|
||||
|
@ -584,7 +590,7 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_DEBUG_DEFAULT 0
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
#define SCTPCTL_MAIN_TIMER_DESC "Main timer interval in ms"
|
||||
#define SCTPCTL_MAIN_TIMER_MIN 1
|
||||
#define SCTPCTL_MAIN_TIMER_MAX 0xFFFFFFFF
|
||||
|
@ -594,16 +600,12 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_IGNORE_VMWARE_INTERFACES_MIN 0
|
||||
#define SCTPCTL_IGNORE_VMWARE_INTERFACES_MAX 1
|
||||
#define SCTPCTL_IGNORE_VMWARE_INTERFACES_DEFAULT SCTPCTL_IGNORE_VMWARE_INTERFACES_MAX
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
|
||||
#define SCTPCTL_OUTPUT_UNLOCKED_DESC "Unlock socket when sending packets down to IP."
|
||||
#define SCTPCTL_OUTPUT_UNLOCKED_DESC "Unlock socket when sending packets down to IP"
|
||||
#define SCTPCTL_OUTPUT_UNLOCKED_MIN 0
|
||||
#define SCTPCTL_OUTPUT_UNLOCKED_MAX 1
|
||||
#define SCTPCTL_OUTPUT_UNLOCKED_DEFAULT SCTPCTL_OUTPUT_UNLOCKED_MIN
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define SCTPCTL_ADDR_WATCHDOG_LIMIT_DESC "Address watchdog limit"
|
||||
#define SCTPCTL_ADDR_WATCHDOG_LIMIT_MIN 0
|
||||
#define SCTPCTL_ADDR_WATCHDOG_LIMIT_MAX 0xFFFFFFFF
|
||||
|
@ -613,8 +615,8 @@ struct sctp_sysctl {
|
|||
#define SCTPCTL_VTAG_WATCHDOG_LIMIT_MIN 0
|
||||
#define SCTPCTL_VTAG_WATCHDOG_LIMIT_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_VTAG_WATCHDOG_LIMIT_DEFAULT SCTPCTL_VTAG_WATCHDOG_LIMIT_MIN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__)
|
||||
#if defined(SYSCTL_DECL)
|
||||
|
@ -623,7 +625,7 @@ SYSCTL_DECL(_net_inet_sctp);
|
|||
#endif
|
||||
|
||||
void sctp_init_sysctls(void);
|
||||
#if defined(__Windows__)
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
void sctp_finish_sysctls(void);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,16 +32,16 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 279841 2015-03-10 09:16:31Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#define _IP_VHL
|
||||
#include <netinet/sctp_os.h>
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#ifdef INET6
|
||||
#if defined(__Userspace_os_FreeBSD)
|
||||
#if defined(__FreeBSD__) && defined(__Userspace__)
|
||||
#include <netinet6/sctp6_var.h>
|
||||
#endif
|
||||
#endif
|
||||
|
@ -55,15 +57,11 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 279841 2015-03-10 09:16:31Z tu
|
|||
#include <netinet/sctp.h>
|
||||
#include <netinet/sctp_uio.h>
|
||||
#if defined(INET) || defined(INET6)
|
||||
#if !defined(__Userspace_os_Windows)
|
||||
#if !(defined(_WIN32) && defined(__Userspace__))
|
||||
#include <netinet/udp.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define APPLE_FILE_NO 6
|
||||
#endif
|
||||
|
||||
void
|
||||
sctp_audit_retranmission_queue(struct sctp_association *asoc)
|
||||
{
|
||||
|
@ -95,7 +93,7 @@ sctp_audit_retranmission_queue(struct sctp_association *asoc)
|
|||
asoc->sent_queue_cnt);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
sctp_threshold_management(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
||||
struct sctp_nets *net, uint16_t threshold)
|
||||
{
|
||||
|
@ -116,12 +114,14 @@ sctp_threshold_management(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
}
|
||||
} else if ((net->pf_threshold < net->failure_threshold) &&
|
||||
(net->error_count > net->pf_threshold)) {
|
||||
if (!(net->dest_state & SCTP_ADDR_PF)) {
|
||||
if ((net->dest_state & SCTP_ADDR_PF) == 0) {
|
||||
net->dest_state |= SCTP_ADDR_PF;
|
||||
net->last_active = sctp_get_tick_count();
|
||||
sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED);
|
||||
sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net, SCTP_FROM_SCTP_TIMER + SCTP_LOC_3);
|
||||
sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net);
|
||||
sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT,
|
||||
inp, stcb, net,
|
||||
SCTP_FROM_SCTP_TIMER + SCTP_LOC_1);
|
||||
sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,20 +132,20 @@ sctp_threshold_management(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
if ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0) {
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) {
|
||||
sctp_misc_ints(SCTP_THRESHOLD_INCR,
|
||||
stcb->asoc.overall_error_count,
|
||||
(stcb->asoc.overall_error_count+1),
|
||||
SCTP_FROM_SCTP_TIMER,
|
||||
__LINE__);
|
||||
stcb->asoc.overall_error_count,
|
||||
(stcb->asoc.overall_error_count+1),
|
||||
SCTP_FROM_SCTP_TIMER,
|
||||
__LINE__);
|
||||
}
|
||||
stcb->asoc.overall_error_count++;
|
||||
}
|
||||
} else {
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) {
|
||||
sctp_misc_ints(SCTP_THRESHOLD_INCR,
|
||||
stcb->asoc.overall_error_count,
|
||||
(stcb->asoc.overall_error_count+1),
|
||||
SCTP_FROM_SCTP_TIMER,
|
||||
__LINE__);
|
||||
stcb->asoc.overall_error_count,
|
||||
(stcb->asoc.overall_error_count+1),
|
||||
SCTP_FROM_SCTP_TIMER,
|
||||
__LINE__);
|
||||
}
|
||||
stcb->asoc.overall_error_count++;
|
||||
}
|
||||
|
@ -161,18 +161,18 @@ sctp_threshold_management(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
/* Abort notification sends a ULP notify */
|
||||
struct mbuf *op_err;
|
||||
|
||||
op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION,
|
||||
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
|
||||
"Association error counter exceeded");
|
||||
inp->last_abort_code = SCTP_FROM_SCTP_TIMER+SCTP_LOC_1;
|
||||
sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED);
|
||||
inp->last_abort_code = SCTP_FROM_SCTP_TIMER + SCTP_LOC_2;
|
||||
sctp_abort_an_association(inp, stcb, op_err, true, SCTP_SO_NOT_LOCKED);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* sctp_find_alternate_net() returns a non-NULL pointer as long
|
||||
* the argument net is non-NULL.
|
||||
* sctp_find_alternate_net() returns a non-NULL pointer as long as there
|
||||
* exists nets, which are not being deleted.
|
||||
*/
|
||||
struct sctp_nets *
|
||||
sctp_find_alternate_net(struct sctp_tcb *stcb,
|
||||
|
@ -181,20 +181,20 @@ sctp_find_alternate_net(struct sctp_tcb *stcb,
|
|||
{
|
||||
/* Find and return an alternate network if possible */
|
||||
struct sctp_nets *alt, *mnet, *min_errors_net = NULL , *max_cwnd_net = NULL;
|
||||
int once;
|
||||
bool looped;
|
||||
/* JRS 5/14/07 - Initialize min_errors to an impossible value. */
|
||||
int min_errors = -1;
|
||||
uint32_t max_cwnd = 0;
|
||||
|
||||
if (stcb->asoc.numnets == 1) {
|
||||
/* No others but net */
|
||||
/* No selection can be made. */
|
||||
return (TAILQ_FIRST(&stcb->asoc.nets));
|
||||
}
|
||||
/*
|
||||
* JRS 5/14/07 - If mode is set to 2, use the CMT PF find alternate net algorithm.
|
||||
* This algorithm chooses the active destination (not in PF state) with the largest
|
||||
* cwnd value. If all destinations are in PF state, unreachable, or unconfirmed, choose
|
||||
* the desination that is in PF state with the lowest error count. In case of a tie,
|
||||
* the destination that is in PF state with the lowest error count. In case of a tie,
|
||||
* choose the destination that was most recently active.
|
||||
*/
|
||||
if (mode == 2) {
|
||||
|
@ -323,28 +323,29 @@ sctp_find_alternate_net(struct sctp_tcb *stcb,
|
|||
return (max_cwnd_net);
|
||||
}
|
||||
}
|
||||
mnet = net;
|
||||
once = 0;
|
||||
|
||||
if (mnet == NULL) {
|
||||
mnet = TAILQ_FIRST(&stcb->asoc.nets);
|
||||
if (mnet == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
/* Look for an alternate net, which is active. */
|
||||
if ((net != NULL) && ((net->dest_state & SCTP_ADDR_BEING_DELETED) == 0)) {
|
||||
alt = TAILQ_NEXT(net, sctp_next);
|
||||
} else {
|
||||
alt = TAILQ_FIRST(&stcb->asoc.nets);
|
||||
}
|
||||
looped = false;
|
||||
for (;;) {
|
||||
alt = TAILQ_NEXT(mnet, sctp_next);
|
||||
if (alt == NULL) {
|
||||
once++;
|
||||
if (once > 1) {
|
||||
if (!looped) {
|
||||
alt = TAILQ_FIRST(&stcb->asoc.nets);
|
||||
looped = true;
|
||||
}
|
||||
/* Definitely out of candidates. */
|
||||
if (alt == NULL) {
|
||||
break;
|
||||
}
|
||||
alt = TAILQ_FIRST(&stcb->asoc.nets);
|
||||
if (alt == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
if (alt->ro.ro_nh == NULL) {
|
||||
#else
|
||||
if (alt->ro.ro_rt == NULL) {
|
||||
#endif
|
||||
if (alt->ro._s_addr) {
|
||||
sctp_free_ifa(alt->ro._s_addr);
|
||||
alt->ro._s_addr = NULL;
|
||||
|
@ -352,44 +353,61 @@ sctp_find_alternate_net(struct sctp_tcb *stcb,
|
|||
alt->src_addr_selected = 0;
|
||||
}
|
||||
if (((alt->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE) &&
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
(alt->ro.ro_nh != NULL) &&
|
||||
#else
|
||||
(alt->ro.ro_rt != NULL) &&
|
||||
(!(alt->dest_state & SCTP_ADDR_UNCONFIRMED))) {
|
||||
/* Found a reachable address */
|
||||
#endif
|
||||
((alt->dest_state & SCTP_ADDR_UNCONFIRMED) == 0) &&
|
||||
(alt != net)) {
|
||||
/* Found an alternate net, which is reachable. */
|
||||
break;
|
||||
}
|
||||
mnet = alt;
|
||||
alt = TAILQ_NEXT(alt, sctp_next);
|
||||
}
|
||||
|
||||
if (alt == NULL) {
|
||||
/* Case where NO insv network exists (dormant state) */
|
||||
/* we rotate destinations */
|
||||
once = 0;
|
||||
mnet = net;
|
||||
/*
|
||||
* In case no active alternate net has been found, look for
|
||||
* an alternate net, which is confirmed.
|
||||
*/
|
||||
if ((net != NULL) && ((net->dest_state & SCTP_ADDR_BEING_DELETED) == 0)) {
|
||||
alt = TAILQ_NEXT(net, sctp_next);
|
||||
} else {
|
||||
alt = TAILQ_FIRST(&stcb->asoc.nets);
|
||||
}
|
||||
looped = false;
|
||||
for (;;) {
|
||||
if (mnet == NULL) {
|
||||
return (TAILQ_FIRST(&stcb->asoc.nets));
|
||||
}
|
||||
alt = TAILQ_NEXT(mnet, sctp_next);
|
||||
if (alt == NULL) {
|
||||
once++;
|
||||
if (once > 1) {
|
||||
break;
|
||||
if (!looped) {
|
||||
alt = TAILQ_FIRST(&stcb->asoc.nets);
|
||||
looped = true;
|
||||
}
|
||||
alt = TAILQ_FIRST(&stcb->asoc.nets);
|
||||
/* Definitely out of candidates. */
|
||||
if (alt == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((!(alt->dest_state & SCTP_ADDR_UNCONFIRMED)) &&
|
||||
if (((alt->dest_state & SCTP_ADDR_UNCONFIRMED) == 0) &&
|
||||
(alt != net)) {
|
||||
/* Found an alternate address */
|
||||
/* Found an alternate net, which is confirmed. */
|
||||
break;
|
||||
}
|
||||
mnet = alt;
|
||||
alt = TAILQ_NEXT(alt, sctp_next);
|
||||
}
|
||||
}
|
||||
if (alt == NULL) {
|
||||
return (net);
|
||||
/*
|
||||
* In case no confirmed alternate net has been found, just
|
||||
* return net, if it is not being deleted. In the other case
|
||||
* just return the first net.
|
||||
*/
|
||||
if ((net != NULL) && ((net->dest_state & SCTP_ADDR_BEING_DELETED) == 0)) {
|
||||
alt = net;
|
||||
}
|
||||
if (alt == NULL) {
|
||||
alt = TAILQ_FIRST(&stcb->asoc.nets);
|
||||
}
|
||||
}
|
||||
return (alt);
|
||||
}
|
||||
|
@ -401,7 +419,11 @@ sctp_backoff_on_timeout(struct sctp_tcb *stcb,
|
|||
int num_marked, int num_abandoned)
|
||||
{
|
||||
if (net->RTO == 0) {
|
||||
net->RTO = stcb->asoc.minrto;
|
||||
if (net->RTO_measured) {
|
||||
net->RTO = stcb->asoc.minrto;
|
||||
} else {
|
||||
net->RTO = stcb->asoc.initial_rto;
|
||||
}
|
||||
}
|
||||
net->RTO <<= 1;
|
||||
if (net->RTO > stcb->asoc.maxrto) {
|
||||
|
@ -423,14 +445,19 @@ sctp_recover_sent_list(struct sctp_tcb *stcb)
|
|||
|
||||
asoc = &stcb->asoc;
|
||||
TAILQ_FOREACH_SAFE(chk, &asoc->sent_queue, sctp_next, nchk) {
|
||||
if (SCTP_TSN_GE(asoc->last_acked_seq, chk->rec.data.TSN_seq)) {
|
||||
if (SCTP_TSN_GE(asoc->last_acked_seq, chk->rec.data.tsn)) {
|
||||
SCTP_PRINTF("Found chk:%p tsn:%x <= last_acked_seq:%x\n",
|
||||
(void *)chk, chk->rec.data.TSN_seq, asoc->last_acked_seq);
|
||||
(void *)chk, chk->rec.data.tsn, asoc->last_acked_seq);
|
||||
if (chk->sent != SCTP_DATAGRAM_NR_ACKED) {
|
||||
if (asoc->strmout[chk->rec.data.stream_number].chunks_on_queues > 0) {
|
||||
asoc->strmout[chk->rec.data.stream_number].chunks_on_queues--;
|
||||
if (asoc->strmout[chk->rec.data.sid].chunks_on_queues > 0) {
|
||||
asoc->strmout[chk->rec.data.sid].chunks_on_queues--;
|
||||
}
|
||||
}
|
||||
if ((asoc->strmout[chk->rec.data.sid].chunks_on_queues == 0) &&
|
||||
(asoc->strmout[chk->rec.data.sid].state == SCTP_STREAM_RESET_PENDING) &&
|
||||
TAILQ_EMPTY(&asoc->strmout[chk->rec.data.sid].outqueue)) {
|
||||
asoc->trigger_reset = 1;
|
||||
}
|
||||
TAILQ_REMOVE(&asoc->sent_queue, chk, sctp_next);
|
||||
if (PR_SCTP_ENABLED(chk->flags)) {
|
||||
if (asoc->pr_sctp_cnt != 0)
|
||||
|
@ -451,7 +478,7 @@ sctp_recover_sent_list(struct sctp_tcb *stcb)
|
|||
}
|
||||
SCTP_PRINTF("after recover order is as follows\n");
|
||||
TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) {
|
||||
SCTP_PRINTF("chk:%p TSN:%x\n", (void *)chk, chk->rec.data.TSN_seq);
|
||||
SCTP_PRINTF("chk:%p TSN:%x\n", (void *)chk, chk->rec.data.tsn);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -480,8 +507,9 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
unsigned int cnt_mk;
|
||||
uint32_t orig_flight, orig_tf;
|
||||
uint32_t tsnlast, tsnfirst;
|
||||
#ifndef INVARIANTS
|
||||
int recovery_cnt = 0;
|
||||
|
||||
#endif
|
||||
|
||||
/* none in flight now */
|
||||
audit_tf = 0;
|
||||
|
@ -504,7 +532,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
}
|
||||
tv.tv_sec = cur_rto / 1000000;
|
||||
tv.tv_usec = cur_rto % 1000000;
|
||||
#ifndef __FreeBSD__
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
timersub(&now, &tv, &min_wait);
|
||||
#else
|
||||
min_wait = now;
|
||||
|
@ -520,8 +548,8 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
min_wait.tv_sec = min_wait.tv_usec = 0;
|
||||
}
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
|
||||
sctp_log_fr(cur_rto, now.tv_sec, now.tv_usec, SCTP_FR_T3_MARK_TIME);
|
||||
sctp_log_fr(0, min_wait.tv_sec, min_wait.tv_usec, SCTP_FR_T3_MARK_TIME);
|
||||
sctp_log_fr(cur_rto, (uint32_t)now.tv_sec, now.tv_usec, SCTP_FR_T3_MARK_TIME);
|
||||
sctp_log_fr(0, (uint32_t)min_wait.tv_sec, min_wait.tv_usec, SCTP_FR_T3_MARK_TIME);
|
||||
}
|
||||
/*
|
||||
* Our rwnd will be incorrect here since we are not adding back the
|
||||
|
@ -539,14 +567,14 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
start_again:
|
||||
#endif
|
||||
TAILQ_FOREACH_SAFE(chk, &stcb->asoc.sent_queue, sctp_next, nchk) {
|
||||
if (SCTP_TSN_GE(stcb->asoc.last_acked_seq, chk->rec.data.TSN_seq)) {
|
||||
if (SCTP_TSN_GE(stcb->asoc.last_acked_seq, chk->rec.data.tsn)) {
|
||||
/* Strange case our list got out of order? */
|
||||
SCTP_PRINTF("Our list is out of order? last_acked:%x chk:%x\n",
|
||||
(unsigned int)stcb->asoc.last_acked_seq, (unsigned int)chk->rec.data.TSN_seq);
|
||||
recovery_cnt++;
|
||||
(unsigned int)stcb->asoc.last_acked_seq, (unsigned int)chk->rec.data.tsn);
|
||||
#ifdef INVARIANTS
|
||||
panic("last acked >= chk on sent-Q");
|
||||
#else
|
||||
recovery_cnt++;
|
||||
SCTP_PRINTF("Recover attempts a restart cnt:%d\n", recovery_cnt);
|
||||
sctp_recover_sent_list(stcb);
|
||||
if (recovery_cnt < 10) {
|
||||
|
@ -567,8 +595,8 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
|
||||
/* validate its been outstanding long enough */
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
|
||||
sctp_log_fr(chk->rec.data.TSN_seq,
|
||||
chk->sent_rcv_time.tv_sec,
|
||||
sctp_log_fr(chk->rec.data.tsn,
|
||||
(uint32_t)chk->sent_rcv_time.tv_sec,
|
||||
chk->sent_rcv_time.tv_usec,
|
||||
SCTP_FR_T3_MARK_TIME);
|
||||
}
|
||||
|
@ -580,7 +608,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
*/
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
|
||||
sctp_log_fr(0,
|
||||
chk->sent_rcv_time.tv_sec,
|
||||
(uint32_t)chk->sent_rcv_time.tv_sec,
|
||||
chk->sent_rcv_time.tv_usec,
|
||||
SCTP_FR_T3_STOPPED);
|
||||
}
|
||||
|
@ -601,7 +629,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
}
|
||||
if (stcb->asoc.prsctp_supported && PR_SCTP_TTL_ENABLED(chk->flags)) {
|
||||
/* Is it expired? */
|
||||
#ifndef __FreeBSD__
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
if (timercmp(&now, &chk->rec.data.timetodrop, >)) {
|
||||
#else
|
||||
if (timevalcmp(&now, &chk->rec.data.timetodrop, >)) {
|
||||
|
@ -635,11 +663,11 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
num_mk++;
|
||||
if (fir == 0) {
|
||||
fir = 1;
|
||||
tsnfirst = chk->rec.data.TSN_seq;
|
||||
tsnfirst = chk->rec.data.tsn;
|
||||
}
|
||||
tsnlast = chk->rec.data.TSN_seq;
|
||||
tsnlast = chk->rec.data.tsn;
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_FR_LOGGING_ENABLE) {
|
||||
sctp_log_fr(chk->rec.data.TSN_seq, chk->snd_count,
|
||||
sctp_log_fr(chk->rec.data.tsn, chk->snd_count,
|
||||
0, SCTP_FR_T3_MARKED);
|
||||
}
|
||||
|
||||
|
@ -654,8 +682,8 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_RSND_TO,
|
||||
chk->whoTo->flight_size,
|
||||
chk->book_size,
|
||||
(uintptr_t)chk->whoTo,
|
||||
chk->rec.data.TSN_seq);
|
||||
(uint32_t)(uintptr_t)chk->whoTo,
|
||||
chk->rec.data.tsn);
|
||||
}
|
||||
sctp_flight_size_decrease(chk);
|
||||
sctp_total_flight_decrease(stcb, chk);
|
||||
|
@ -663,6 +691,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
stcb->asoc.peers_rwnd += SCTP_BASE_SYSCTL(sctp_peer_chunk_oh);
|
||||
}
|
||||
chk->sent = SCTP_DATAGRAM_RESEND;
|
||||
chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
|
||||
SCTP_STAT_INCR(sctps_markedretrans);
|
||||
|
||||
/* reset the TSN for striking and other FR stuff */
|
||||
|
@ -685,7 +714,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
if (TAILQ_EMPTY(&stcb->asoc.send_queue)) {
|
||||
chk->rec.data.fast_retran_tsn = stcb->asoc.sending_seq;
|
||||
} else {
|
||||
chk->rec.data.fast_retran_tsn = (TAILQ_FIRST(&stcb->asoc.send_queue))->rec.data.TSN_seq;
|
||||
chk->rec.data.fast_retran_tsn = (TAILQ_FIRST(&stcb->asoc.send_queue))->rec.data.tsn;
|
||||
}
|
||||
}
|
||||
/* CMT: Do not allow FRs on retransmitted TSNs.
|
||||
|
@ -715,13 +744,9 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
if (num_mk) {
|
||||
SCTPDBG(SCTP_DEBUG_TIMER1, "LAST TSN marked was %x\n",
|
||||
tsnlast);
|
||||
SCTPDBG(SCTP_DEBUG_TIMER1, "Num marked for retransmission was %d peer-rwd:%ld\n",
|
||||
num_mk, (u_long)stcb->asoc.peers_rwnd);
|
||||
SCTPDBG(SCTP_DEBUG_TIMER1, "LAST TSN marked was %x\n",
|
||||
tsnlast);
|
||||
SCTPDBG(SCTP_DEBUG_TIMER1, "Num marked for retransmission was %d peer-rwd:%d\n",
|
||||
SCTPDBG(SCTP_DEBUG_TIMER1, "Num marked for retransmission was %d peer-rwd:%u\n",
|
||||
num_mk,
|
||||
(int)stcb->asoc.peers_rwnd);
|
||||
stcb->asoc.peers_rwnd);
|
||||
}
|
||||
#endif
|
||||
*num_marked = num_mk;
|
||||
|
@ -740,6 +765,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
chk->whoTo = alt;
|
||||
if (chk->sent != SCTP_DATAGRAM_RESEND) {
|
||||
chk->sent = SCTP_DATAGRAM_RESEND;
|
||||
chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
|
||||
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
||||
cnt_mk++;
|
||||
}
|
||||
|
@ -782,8 +808,8 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
sctp_misc_ints(SCTP_FLIGHT_LOG_UP,
|
||||
chk->whoTo->flight_size,
|
||||
chk->book_size,
|
||||
(uintptr_t)chk->whoTo,
|
||||
chk->rec.data.TSN_seq);
|
||||
(uint32_t)(uintptr_t)chk->whoTo,
|
||||
chk->rec.data.tsn);
|
||||
}
|
||||
|
||||
sctp_flight_size_increase(chk);
|
||||
|
@ -795,7 +821,6 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
|
|||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sctp_t3rxt_timer(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb,
|
||||
|
@ -837,11 +862,11 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp,
|
|||
if (net != stcb->asoc.primary_destination) {
|
||||
/* send a immediate HB if our RTO is stale */
|
||||
struct timeval now;
|
||||
unsigned int ms_goneby;
|
||||
uint32_t ms_goneby;
|
||||
|
||||
(void)SCTP_GETTIME_TIMEVAL(&now);
|
||||
if (net->last_sent_time.tv_sec) {
|
||||
ms_goneby = (now.tv_sec - net->last_sent_time.tv_sec) * 1000;
|
||||
ms_goneby = (uint32_t)(now.tv_sec - net->last_sent_time.tv_sec) * 1000;
|
||||
} else {
|
||||
ms_goneby = 0;
|
||||
}
|
||||
|
@ -896,7 +921,7 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp,
|
|||
num_mk = 0;
|
||||
num_abandoned = 0;
|
||||
(void)sctp_mark_all_for_resend(stcb, net, alt, win_probe,
|
||||
&num_mk, &num_abandoned);
|
||||
&num_mk, &num_abandoned);
|
||||
/* FR Loss recovery just ended with the T3. */
|
||||
stcb->asoc.fast_retran_loss_recovery = 0;
|
||||
|
||||
|
@ -915,26 +940,30 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp,
|
|||
|
||||
/* Backoff the timer and cwnd */
|
||||
sctp_backoff_on_timeout(stcb, net, win_probe, num_mk, num_abandoned);
|
||||
if ((!(net->dest_state & SCTP_ADDR_REACHABLE)) ||
|
||||
if (((net->dest_state & SCTP_ADDR_REACHABLE) == 0) ||
|
||||
(net->dest_state & SCTP_ADDR_PF)) {
|
||||
/* Move all pending over too */
|
||||
sctp_move_chunks_from_net(stcb, net);
|
||||
|
||||
/* Get the address that failed, to
|
||||
* force a new src address selecton and
|
||||
* force a new src address selection and
|
||||
* a route allocation.
|
||||
*/
|
||||
if (net->ro._s_addr) {
|
||||
if (net->ro._s_addr != NULL) {
|
||||
sctp_free_ifa(net->ro._s_addr);
|
||||
net->ro._s_addr = NULL;
|
||||
}
|
||||
net->src_addr_selected = 0;
|
||||
|
||||
/* Force a route allocation too */
|
||||
if (net->ro.ro_rt) {
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
RO_NHFREE(&net->ro);
|
||||
#else
|
||||
if (net->ro.ro_rt != NULL) {
|
||||
RTFREE(net->ro.ro_rt);
|
||||
net->ro.ro_rt = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Was it our primary? */
|
||||
if ((stcb->asoc.primary_destination == net) && (alt != net)) {
|
||||
|
@ -945,7 +974,7 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp,
|
|||
* change-primary then this flag must be cleared
|
||||
* from any net structures.
|
||||
*/
|
||||
if (stcb->asoc.alternate) {
|
||||
if (stcb->asoc.alternate != NULL) {
|
||||
sctp_free_remote_addr(stcb->asoc.alternate);
|
||||
}
|
||||
stcb->asoc.alternate = alt;
|
||||
|
@ -956,7 +985,7 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp,
|
|||
* Special case for cookie-echo'ed case, we don't do output but must
|
||||
* await the COOKIE-ACK before retransmission
|
||||
*/
|
||||
if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED) {
|
||||
if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED) {
|
||||
/*
|
||||
* Here we just reset the timer and start again since we
|
||||
* have not established the asoc
|
||||
|
@ -971,7 +1000,12 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp,
|
|||
/* C3. See if we need to send a Fwd-TSN */
|
||||
if (SCTP_TSN_GT(stcb->asoc.advanced_peer_ack_point, stcb->asoc.last_acked_seq)) {
|
||||
send_forward_tsn(stcb, &stcb->asoc);
|
||||
if (lchk) {
|
||||
for (; lchk != NULL; lchk = TAILQ_NEXT(lchk, sctp_next)) {
|
||||
if (lchk->whoTo != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lchk != NULL) {
|
||||
/* Assure a timer is up */
|
||||
sctp_timer_start(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, lchk->whoTo);
|
||||
}
|
||||
|
@ -998,7 +1032,7 @@ sctp_t1init_timer(struct sctp_inpcb *inp,
|
|||
sctp_send_initiate(inp, stcb, SCTP_SO_NOT_LOCKED);
|
||||
return (0);
|
||||
}
|
||||
if (SCTP_GET_STATE((&stcb->asoc)) != SCTP_STATE_COOKIE_WAIT) {
|
||||
if (SCTP_GET_STATE(stcb) != SCTP_STATE_COOKIE_WAIT) {
|
||||
return (0);
|
||||
}
|
||||
if (sctp_threshold_management(inp, stcb, net,
|
||||
|
@ -1046,19 +1080,19 @@ sctp_cookie_timer(struct sctp_inpcb *inp,
|
|||
}
|
||||
}
|
||||
if (cookie == NULL) {
|
||||
if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED) {
|
||||
if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED) {
|
||||
/* FOOBAR! */
|
||||
struct mbuf *op_err;
|
||||
|
||||
op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION,
|
||||
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
|
||||
"Cookie timer expired, but no cookie");
|
||||
inp->last_abort_code = SCTP_FROM_SCTP_TIMER+SCTP_LOC_4;
|
||||
sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED);
|
||||
inp->last_abort_code = SCTP_FROM_SCTP_TIMER + SCTP_LOC_3;
|
||||
sctp_abort_an_association(inp, stcb, op_err, false, SCTP_SO_NOT_LOCKED);
|
||||
} else {
|
||||
#ifdef INVARIANTS
|
||||
panic("Cookie timer expires in wrong state?");
|
||||
#else
|
||||
SCTP_PRINTF("Strange in state %d not cookie-echoed yet c-e timer expires?\n", SCTP_GET_STATE(&stcb->asoc));
|
||||
SCTP_PRINTF("Strange in state %d not cookie-echoed yet c-e timer expires?\n", SCTP_GET_STATE(stcb));
|
||||
return (0);
|
||||
#endif
|
||||
}
|
||||
|
@ -1071,8 +1105,8 @@ sctp_cookie_timer(struct sctp_inpcb *inp,
|
|||
return (1);
|
||||
}
|
||||
/*
|
||||
* cleared theshold management now lets backoff the address & select
|
||||
* an alternate
|
||||
* Cleared threshold management, now lets backoff the address
|
||||
* and select an alternate
|
||||
*/
|
||||
stcb->asoc.dropped_special_cnt = 0;
|
||||
sctp_backoff_on_timeout(stcb, cookie->whoTo, 1, 0, 0);
|
||||
|
@ -1087,6 +1121,7 @@ sctp_cookie_timer(struct sctp_inpcb *inp,
|
|||
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
||||
}
|
||||
cookie->sent = SCTP_DATAGRAM_RESEND;
|
||||
cookie->flags |= CHUNK_FLAGS_FRAGMENT_OK;
|
||||
/*
|
||||
* Now call the output routine to kick out the cookie again, Note we
|
||||
* don't mark any chunks for retran so that FR will need to kick in
|
||||
|
@ -1096,10 +1131,9 @@ sctp_cookie_timer(struct sctp_inpcb *inp,
|
|||
}
|
||||
|
||||
int
|
||||
sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
||||
struct sctp_nets *net)
|
||||
sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
|
||||
{
|
||||
struct sctp_nets *alt;
|
||||
struct sctp_nets *alt, *net;
|
||||
struct sctp_tmit_chunk *strrst = NULL, *chk = NULL;
|
||||
|
||||
if (stcb->asoc.stream_reset_outstanding == 0) {
|
||||
|
@ -1110,19 +1144,18 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
if (strrst == NULL) {
|
||||
return (0);
|
||||
}
|
||||
net = strrst->whoTo;
|
||||
/* do threshold management */
|
||||
if (sctp_threshold_management(inp, stcb, strrst->whoTo,
|
||||
stcb->asoc.max_send_times)) {
|
||||
if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) {
|
||||
/* Assoc is over */
|
||||
return (1);
|
||||
}
|
||||
/*
|
||||
* cleared theshold management now lets backoff the address & select
|
||||
* an alternate
|
||||
* Cleared threshold management, now lets backoff the address
|
||||
* and select an alternate
|
||||
*/
|
||||
sctp_backoff_on_timeout(stcb, strrst->whoTo, 1, 0, 0);
|
||||
alt = sctp_find_alternate_net(stcb, strrst->whoTo, 0);
|
||||
sctp_free_remote_addr(strrst->whoTo);
|
||||
sctp_backoff_on_timeout(stcb, net, 1, 0, 0);
|
||||
alt = sctp_find_alternate_net(stcb, net, 0);
|
||||
strrst->whoTo = alt;
|
||||
atomic_add_int(&alt->ref_count, 1);
|
||||
|
||||
|
@ -1133,26 +1166,30 @@ sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
sctp_free_remote_addr(chk->whoTo);
|
||||
if (chk->sent != SCTP_DATAGRAM_RESEND) {
|
||||
chk->sent = SCTP_DATAGRAM_RESEND;
|
||||
chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
|
||||
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
||||
}
|
||||
chk->whoTo = alt;
|
||||
atomic_add_int(&alt->ref_count, 1);
|
||||
}
|
||||
}
|
||||
if (!(net->dest_state & SCTP_ADDR_REACHABLE)) {
|
||||
if ((net->dest_state & SCTP_ADDR_REACHABLE) == 0) {
|
||||
/*
|
||||
* If the address went un-reachable, we need to move to
|
||||
* alternates for ALL chk's in queue
|
||||
*/
|
||||
sctp_move_chunks_from_net(stcb, net);
|
||||
}
|
||||
sctp_free_remote_addr(net);
|
||||
|
||||
/* mark the retran info */
|
||||
if (strrst->sent != SCTP_DATAGRAM_RESEND)
|
||||
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
||||
strrst->sent = SCTP_DATAGRAM_RESEND;
|
||||
strrst->flags |= CHUNK_FLAGS_FRAGMENT_OK;
|
||||
|
||||
/* restart the timer */
|
||||
sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, inp, stcb, strrst->whoTo);
|
||||
sctp_timer_start(SCTP_TIMER_TYPE_STRRESET, inp, stcb, alt);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1177,8 +1214,9 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
if (asconf == NULL) {
|
||||
return (0);
|
||||
}
|
||||
net = asconf->whoTo;
|
||||
/* do threshold management */
|
||||
if (sctp_threshold_management(inp, stcb, asconf->whoTo,
|
||||
if (sctp_threshold_management(inp, stcb, net,
|
||||
stcb->asoc.max_send_times)) {
|
||||
/* Assoc is over */
|
||||
return (1);
|
||||
|
@ -1191,17 +1229,16 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
* Mark this peer as ASCONF incapable and cleanup.
|
||||
*/
|
||||
SCTPDBG(SCTP_DEBUG_TIMER1, "asconf_timer: Peer has not responded to our repeated ASCONFs\n");
|
||||
sctp_asconf_cleanup(stcb, net);
|
||||
sctp_asconf_cleanup(stcb);
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* cleared threshold management, so now backoff the net and
|
||||
* select an alternate
|
||||
*/
|
||||
sctp_backoff_on_timeout(stcb, asconf->whoTo, 1, 0, 0);
|
||||
alt = sctp_find_alternate_net(stcb, asconf->whoTo, 0);
|
||||
sctp_backoff_on_timeout(stcb, net, 1, 0, 0);
|
||||
alt = sctp_find_alternate_net(stcb, net, 0);
|
||||
if (asconf->whoTo != alt) {
|
||||
sctp_free_remote_addr(asconf->whoTo);
|
||||
asconf->whoTo = alt;
|
||||
atomic_add_int(&alt->ref_count, 1);
|
||||
}
|
||||
|
@ -1214,6 +1251,7 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
chk->whoTo = alt;
|
||||
if (chk->sent != SCTP_DATAGRAM_RESEND) {
|
||||
chk->sent = SCTP_DATAGRAM_RESEND;
|
||||
chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
|
||||
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
||||
}
|
||||
atomic_add_int(&alt->ref_count, 1);
|
||||
|
@ -1228,18 +1266,22 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
if (asconf->sent != SCTP_DATAGRAM_RESEND && chk->sent != SCTP_DATAGRAM_UNSENT)
|
||||
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
||||
chk->sent = SCTP_DATAGRAM_RESEND;
|
||||
chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
|
||||
}
|
||||
if (!(net->dest_state & SCTP_ADDR_REACHABLE)) {
|
||||
if ((net->dest_state & SCTP_ADDR_REACHABLE) == 0) {
|
||||
/*
|
||||
* If the address went un-reachable, we need to move
|
||||
* to the alternate for ALL chunks in queue
|
||||
*/
|
||||
sctp_move_chunks_from_net(stcb, net);
|
||||
}
|
||||
sctp_free_remote_addr(net);
|
||||
|
||||
/* mark the retran info */
|
||||
if (asconf->sent != SCTP_DATAGRAM_RESEND)
|
||||
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
|
||||
asconf->sent = SCTP_DATAGRAM_RESEND;
|
||||
asconf->flags |= CHUNK_FLAGS_FRAGMENT_OK;
|
||||
|
||||
/* send another ASCONF if any and we can do */
|
||||
sctp_send_asconf(stcb, alt, SCTP_ADDR_NOT_LOCKED);
|
||||
|
@ -1249,8 +1291,7 @@ sctp_asconf_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
|
||||
/* Mobility adaptation */
|
||||
void
|
||||
sctp_delete_prim_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
||||
struct sctp_nets *net SCTP_UNUSED)
|
||||
sctp_delete_prim_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
|
||||
{
|
||||
if (stcb->asoc.deleted_primary == NULL) {
|
||||
SCTPDBG(SCTP_DEBUG_ASCONF1, "delete_prim_timer: deleted_primary is not stored...\n");
|
||||
|
@ -1277,7 +1318,7 @@ sctp_shutdown_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
{
|
||||
struct sctp_nets *alt;
|
||||
|
||||
/* first threshold managment */
|
||||
/* first threshold management */
|
||||
if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) {
|
||||
/* Assoc is over */
|
||||
return (1);
|
||||
|
@ -1300,7 +1341,7 @@ sctp_shutdownack_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
{
|
||||
struct sctp_nets *alt;
|
||||
|
||||
/* first threshold managment */
|
||||
/* first threshold management */
|
||||
if (sctp_threshold_management(inp, stcb, net, stcb->asoc.max_send_times)) {
|
||||
/* Assoc is over */
|
||||
return (1);
|
||||
|
@ -1318,17 +1359,17 @@ sctp_shutdownack_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
}
|
||||
|
||||
static void
|
||||
sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb)
|
||||
sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
|
||||
{
|
||||
struct sctp_stream_queue_pending *sp;
|
||||
unsigned int i, chks_in_queue = 0;
|
||||
int being_filled = 0;
|
||||
/*
|
||||
* This function is ONLY called when the send/sent queues are empty.
|
||||
*/
|
||||
if ((stcb == NULL) || (inp == NULL))
|
||||
return;
|
||||
|
||||
KASSERT(inp != NULL, ("inp is NULL"));
|
||||
KASSERT(stcb != NULL, ("stcb is NULL"));
|
||||
SCTP_TCB_LOCK_ASSERT(stcb);
|
||||
KASSERT(TAILQ_EMPTY(&stcb->asoc.send_queue), ("send_queue not empty"));
|
||||
KASSERT(TAILQ_EMPTY(&stcb->asoc.sent_queue), ("sent_queue not empty"));
|
||||
|
||||
if (stcb->asoc.sent_queue_retran_cnt) {
|
||||
SCTP_PRINTF("Hmm, sent_queue_retran_cnt is non-zero %d\n",
|
||||
|
@ -1337,7 +1378,7 @@ sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp,
|
|||
}
|
||||
if (stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, &stcb->asoc)) {
|
||||
/* No stream scheduler information, initialize scheduler */
|
||||
stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 0);
|
||||
stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc);
|
||||
if (!stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, &stcb->asoc)) {
|
||||
/* yep, we lost a stream or two */
|
||||
SCTP_PRINTF("Found additional streams NOT managed by scheduler, corrected\n");
|
||||
|
@ -1385,15 +1426,11 @@ int
|
|||
sctp_heartbeat_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
||||
struct sctp_nets *net)
|
||||
{
|
||||
uint8_t net_was_pf;
|
||||
bool net_was_pf;
|
||||
|
||||
if (net->dest_state & SCTP_ADDR_PF) {
|
||||
net_was_pf = 1;
|
||||
} else {
|
||||
net_was_pf = 0;
|
||||
}
|
||||
net_was_pf = (net->dest_state & SCTP_ADDR_PF) != 0;
|
||||
if (net->hb_responded == 0) {
|
||||
if (net->ro._s_addr) {
|
||||
if (net->ro._s_addr != NULL) {
|
||||
/* Invalidate the src address if we did not get
|
||||
* a response last time.
|
||||
*/
|
||||
|
@ -1408,7 +1445,7 @@ sctp_heartbeat_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
}
|
||||
}
|
||||
/* Zero PBA, if it needs it */
|
||||
if (net->partial_bytes_acked) {
|
||||
if (net->partial_bytes_acked > 0) {
|
||||
net->partial_bytes_acked = 0;
|
||||
}
|
||||
if ((stcb->asoc.total_output_queue_size > 0) &&
|
||||
|
@ -1416,15 +1453,16 @@ sctp_heartbeat_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
(TAILQ_EMPTY(&stcb->asoc.sent_queue))) {
|
||||
sctp_audit_stream_queues_for_size(inp, stcb);
|
||||
}
|
||||
if (!(net->dest_state & SCTP_ADDR_NOHB) &&
|
||||
!((net_was_pf == 0) && (net->dest_state & SCTP_ADDR_PF))) {
|
||||
/* when move to PF during threshold mangement, a HB has been
|
||||
queued in that routine */
|
||||
if ((((net->dest_state & SCTP_ADDR_NOHB) == 0) ||
|
||||
(net->dest_state & SCTP_ADDR_UNCONFIRMED)) &&
|
||||
(net_was_pf || ((net->dest_state & SCTP_ADDR_PF) == 0))) {
|
||||
/* When moving to PF during threshold management, a HB has been
|
||||
queued in that routine. */
|
||||
uint32_t ms_gone_by;
|
||||
|
||||
if ((net->last_sent_time.tv_sec > 0) ||
|
||||
(net->last_sent_time.tv_usec > 0)) {
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct timeval diff;
|
||||
|
||||
SCTP_GETTIME_TIMEVAL(&diff);
|
||||
|
@ -1441,6 +1479,7 @@ sctp_heartbeat_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
|||
ms_gone_by = 0xffffffff;
|
||||
}
|
||||
if ((ms_gone_by >= net->heart_beat_delay) ||
|
||||
(net->dest_state & SCTP_ADDR_UNCONFIRMED) ||
|
||||
(net->dest_state & SCTP_ADDR_PF)) {
|
||||
sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED);
|
||||
}
|
||||
|
@ -1470,7 +1509,7 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp,
|
|||
if (net->ro._l_addr.sa.sa_family == AF_INET6) {
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&net->ro._l_addr;
|
||||
/* KAME hack: embed scopeid */
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
#if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD)
|
||||
(void)in6_embedscope(&sin6->sin6_addr, sin6, NULL, NULL);
|
||||
#else
|
||||
|
@ -1503,7 +1542,11 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp,
|
|||
net->src_addr_selected = 1;
|
||||
}
|
||||
if (net->ro._s_addr) {
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._s_addr.sa, net->ro.ro_nh);
|
||||
#else
|
||||
mtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._s_addr.sa, net->ro.ro_rt);
|
||||
#endif
|
||||
#if defined(INET) || defined(INET6)
|
||||
if (net->port) {
|
||||
mtu -= sizeof(struct udphdr);
|
||||
|
@ -1511,6 +1554,8 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp,
|
|||
#endif
|
||||
if (mtu > next_mtu) {
|
||||
net->mtu = next_mtu;
|
||||
} else {
|
||||
net->mtu = mtu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1519,16 +1564,14 @@ sctp_pathmtu_timer(struct sctp_inpcb *inp,
|
|||
}
|
||||
|
||||
void
|
||||
sctp_autoclose_timer(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb,
|
||||
struct sctp_nets *net)
|
||||
sctp_autoclose_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
|
||||
{
|
||||
struct timeval tn, *tim_touse;
|
||||
struct sctp_association *asoc;
|
||||
int ticks_gone_by;
|
||||
uint32_t ticks_gone_by;
|
||||
|
||||
(void)SCTP_GETTIME_TIMEVAL(&tn);
|
||||
if (stcb->asoc.sctp_autoclose_ticks &&
|
||||
if (stcb->asoc.sctp_autoclose_ticks > 0 &&
|
||||
sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) {
|
||||
/* Auto close is on */
|
||||
asoc = &stcb->asoc;
|
||||
|
@ -1540,9 +1583,8 @@ sctp_autoclose_timer(struct sctp_inpcb *inp,
|
|||
tim_touse = &asoc->time_last_sent;
|
||||
}
|
||||
/* Now has long enough transpired to autoclose? */
|
||||
ticks_gone_by = SEC_TO_TICKS(tn.tv_sec - tim_touse->tv_sec);
|
||||
if ((ticks_gone_by > 0) &&
|
||||
(ticks_gone_by >= (int)asoc->sctp_autoclose_ticks)) {
|
||||
ticks_gone_by = sctp_secs_to_ticks((uint32_t)(tn.tv_sec - tim_touse->tv_sec));
|
||||
if (ticks_gone_by >= asoc->sctp_autoclose_ticks) {
|
||||
/*
|
||||
* autoclose time has hit, call the output routine,
|
||||
* which should do nothing just to be SURE we don't
|
||||
|
@ -1558,29 +1600,26 @@ sctp_autoclose_timer(struct sctp_inpcb *inp,
|
|||
* there is nothing queued to send, so I'm
|
||||
* done...
|
||||
*/
|
||||
if (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT) {
|
||||
if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) {
|
||||
/* only send SHUTDOWN 1st time thru */
|
||||
struct sctp_nets *netp;
|
||||
struct sctp_nets *net;
|
||||
|
||||
if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) ||
|
||||
(SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
|
||||
if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
|
||||
(SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
|
||||
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
|
||||
}
|
||||
SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT);
|
||||
SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
|
||||
SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_SENT);
|
||||
sctp_stop_timers_for_shutdown(stcb);
|
||||
if (stcb->asoc.alternate) {
|
||||
netp = stcb->asoc.alternate;
|
||||
net = stcb->asoc.alternate;
|
||||
} else {
|
||||
netp = stcb->asoc.primary_destination;
|
||||
net = stcb->asoc.primary_destination;
|
||||
}
|
||||
sctp_send_shutdown(stcb, netp);
|
||||
sctp_send_shutdown(stcb, net);
|
||||
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN,
|
||||
stcb->sctp_ep, stcb,
|
||||
netp);
|
||||
stcb->sctp_ep, stcb, net);
|
||||
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD,
|
||||
stcb->sctp_ep, stcb,
|
||||
netp);
|
||||
stcb->sctp_ep, stcb, NULL);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1588,13 +1627,12 @@ sctp_autoclose_timer(struct sctp_inpcb *inp,
|
|||
* No auto close at this time, reset t-o to check
|
||||
* later
|
||||
*/
|
||||
int tmp;
|
||||
uint32_t tmp;
|
||||
|
||||
/* fool the timer startup to use the time left */
|
||||
tmp = asoc->sctp_autoclose_ticks;
|
||||
asoc->sctp_autoclose_ticks -= ticks_gone_by;
|
||||
sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb,
|
||||
net);
|
||||
sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, NULL);
|
||||
/* restore the real tick value */
|
||||
asoc->sctp_autoclose_ticks = tmp;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.h 235828 2012-05-23 11:26:28Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_TIMER_H_
|
||||
|
@ -44,22 +46,20 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.h 235828 2012-05-23 11:26:28Z tu
|
|||
#define SCTP_RTT_VAR_SHIFT 2
|
||||
|
||||
struct sctp_nets *
|
||||
sctp_find_alternate_net(struct sctp_tcb *,
|
||||
struct sctp_nets *, int mode);
|
||||
|
||||
int
|
||||
sctp_threshold_management(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *, uint16_t);
|
||||
sctp_find_alternate_net(struct sctp_tcb *, struct sctp_nets *, int);
|
||||
|
||||
int
|
||||
sctp_t3rxt_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
int
|
||||
sctp_t1init_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
int
|
||||
sctp_shutdown_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
int
|
||||
sctp_heartbeat_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
@ -76,32 +76,28 @@ int
|
|||
sctp_shutdownack_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
int
|
||||
sctp_strreset_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
||||
struct sctp_nets *net);
|
||||
sctp_strreset_timer(struct sctp_inpcb *, struct sctp_tcb *);
|
||||
|
||||
int
|
||||
sctp_asconf_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
void
|
||||
sctp_delete_prim_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
sctp_delete_prim_timer(struct sctp_inpcb *, struct sctp_tcb *);
|
||||
|
||||
void
|
||||
sctp_autoclose_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *net);
|
||||
sctp_autoclose_timer(struct sctp_inpcb *, struct sctp_tcb *);
|
||||
|
||||
void sctp_audit_retranmission_queue(struct sctp_association *);
|
||||
|
||||
void sctp_iterator_timer(struct sctp_iterator *it);
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
#if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) || defined(APPLE_LION) || defined(APPLE_MOUNTAINLION)
|
||||
void sctp_slowtimo(void);
|
||||
#else
|
||||
void sctp_gc(struct inpcbinfo *);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,29 +32,28 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 269945 2014-08-13 15:50:16Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_UIO_H_
|
||||
#define _NETINET_SCTP_UIO_H_
|
||||
|
||||
#if (defined(__APPLE__) && defined(KERNEL))
|
||||
#if (defined(__APPLE__) && !defined(__Userspace__) && defined(KERNEL))
|
||||
#ifndef _KERNEL
|
||||
#define _KERNEL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !(defined(__Windows__)) && !defined(__Userspace_os_Windows)
|
||||
#if ! defined(_KERNEL)
|
||||
#if !defined(_WIN32)
|
||||
#if !defined(_KERNEL)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#if defined(__Windows__)
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4200)
|
||||
#if defined(_KERNEL)
|
||||
|
@ -108,14 +109,8 @@ struct sctp_event_subscribe {
|
|||
* ancillary data structures
|
||||
*/
|
||||
struct sctp_initmsg {
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version < 800000
|
||||
/* This is a bug. Not fixed for ABI compatibility */
|
||||
uint32_t sinit_num_ostreams;
|
||||
uint32_t sinit_max_instreams;
|
||||
#else
|
||||
uint16_t sinit_num_ostreams;
|
||||
uint16_t sinit_max_instreams;
|
||||
#endif
|
||||
uint16_t sinit_max_attempts;
|
||||
uint16_t sinit_max_init_timeo;
|
||||
};
|
||||
|
@ -133,7 +128,6 @@ struct sctp_initmsg {
|
|||
* all sendrcvinfo's need a verfid for SENDING only.
|
||||
*/
|
||||
|
||||
|
||||
#define SCTP_ALIGN_RESV_PAD 92
|
||||
#define SCTP_ALIGN_RESV_PAD_SHORT 76
|
||||
|
||||
|
@ -141,9 +135,6 @@ struct sctp_sndrcvinfo {
|
|||
uint16_t sinfo_stream;
|
||||
uint16_t sinfo_ssn;
|
||||
uint16_t sinfo_flags;
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version < 800000
|
||||
uint16_t sinfo_pr_policy;
|
||||
#endif
|
||||
uint32_t sinfo_ppid;
|
||||
uint32_t sinfo_context;
|
||||
uint32_t sinfo_timetolive;
|
||||
|
@ -159,24 +150,27 @@ struct sctp_extrcvinfo {
|
|||
uint16_t sinfo_stream;
|
||||
uint16_t sinfo_ssn;
|
||||
uint16_t sinfo_flags;
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version < 800000
|
||||
uint16_t sinfo_pr_policy;
|
||||
#endif
|
||||
uint32_t sinfo_ppid;
|
||||
uint32_t sinfo_context;
|
||||
uint32_t sinfo_timetolive;
|
||||
uint32_t sinfo_timetolive; /* should have been sinfo_pr_value */
|
||||
uint32_t sinfo_tsn;
|
||||
uint32_t sinfo_cumtsn;
|
||||
sctp_assoc_t sinfo_assoc_id;
|
||||
uint16_t sreinfo_next_flags;
|
||||
uint16_t sreinfo_next_stream;
|
||||
uint32_t sreinfo_next_aid;
|
||||
uint32_t sreinfo_next_length;
|
||||
uint32_t sreinfo_next_ppid;
|
||||
uint16_t serinfo_next_flags;
|
||||
uint16_t serinfo_next_stream;
|
||||
uint32_t serinfo_next_aid;
|
||||
uint32_t serinfo_next_length;
|
||||
uint32_t serinfo_next_ppid;
|
||||
uint16_t sinfo_keynumber;
|
||||
uint16_t sinfo_keynumber_valid;
|
||||
uint8_t __reserve_pad[SCTP_ALIGN_RESV_PAD_SHORT];
|
||||
};
|
||||
#define sinfo_pr_value sinfo_timetolive
|
||||
#define sreinfo_next_flags serinfo_next_flags
|
||||
#define sreinfo_next_stream serinfo_next_stream
|
||||
#define sreinfo_next_aid serinfo_next_aid
|
||||
#define sreinfo_next_length serinfo_next_length
|
||||
#define sreinfo_next_ppid serinfo_next_ppid
|
||||
|
||||
struct sctp_sndinfo {
|
||||
uint16_t snd_sid;
|
||||
|
@ -282,7 +276,8 @@ struct sctp_snd_all_completes {
|
|||
/* The lower four bits is an enumeration of PR-SCTP policies */
|
||||
#define SCTP_PR_SCTP_NONE 0x0000 /* Reliable transfer */
|
||||
#define SCTP_PR_SCTP_TTL 0x0001 /* Time based PR-SCTP */
|
||||
#define SCTP_PR_SCTP_BUF 0x0002 /* Buffer based PR-SCTP */
|
||||
#define SCTP_PR_SCTP_PRIO 0x0002 /* Buffer based PR-SCTP */
|
||||
#define SCTP_PR_SCTP_BUF SCTP_PR_SCTP_PRIO /* For backwards compatibility */
|
||||
#define SCTP_PR_SCTP_RTX 0x0003 /* Number of retransmissions based PR-SCTP */
|
||||
#define SCTP_PR_SCTP_MAX SCTP_PR_SCTP_RTX
|
||||
#define SCTP_PR_SCTP_ALL 0x000f /* Used for aggregated stats */
|
||||
|
@ -341,12 +336,13 @@ struct sctp_assoc_change {
|
|||
#define SCTP_CANT_STR_ASSOC 0x0005
|
||||
|
||||
/* sac_info values */
|
||||
#define SCTP_ASSOC_SUPPORTS_PR 0x01
|
||||
#define SCTP_ASSOC_SUPPORTS_AUTH 0x02
|
||||
#define SCTP_ASSOC_SUPPORTS_ASCONF 0x03
|
||||
#define SCTP_ASSOC_SUPPORTS_MULTIBUF 0x04
|
||||
#define SCTP_ASSOC_SUPPORTS_RE_CONFIG 0x05
|
||||
#define SCTP_ASSOC_SUPPORTS_MAX 0x05
|
||||
#define SCTP_ASSOC_SUPPORTS_PR 0x01
|
||||
#define SCTP_ASSOC_SUPPORTS_AUTH 0x02
|
||||
#define SCTP_ASSOC_SUPPORTS_ASCONF 0x03
|
||||
#define SCTP_ASSOC_SUPPORTS_MULTIBUF 0x04
|
||||
#define SCTP_ASSOC_SUPPORTS_RE_CONFIG 0x05
|
||||
#define SCTP_ASSOC_SUPPORTS_INTERLEAVING 0x06
|
||||
#define SCTP_ASSOC_SUPPORTS_MAX 0x06
|
||||
/*
|
||||
* Address event
|
||||
*/
|
||||
|
@ -443,7 +439,6 @@ struct sctp_setadaption {
|
|||
uint32_t ssb_adaption_ind;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Partial Delivery API event
|
||||
*/
|
||||
|
@ -460,7 +455,6 @@ struct sctp_pdapi_event {
|
|||
/* indication values */
|
||||
#define SCTP_PARTIAL_DELIVERY_ABORTED 0x0001
|
||||
|
||||
|
||||
/*
|
||||
* authentication key event
|
||||
*/
|
||||
|
@ -480,7 +474,6 @@ struct sctp_authkey_event {
|
|||
#define SCTP_AUTH_NO_AUTH 0x0002
|
||||
#define SCTP_AUTH_FREE_KEY 0x0003
|
||||
|
||||
|
||||
struct sctp_sender_dry_event {
|
||||
uint16_t sender_dry_type;
|
||||
uint16_t sender_dry_flags;
|
||||
|
@ -488,7 +481,6 @@ struct sctp_sender_dry_event {
|
|||
sctp_assoc_t sender_dry_assoc_id;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Stream reset event - subscribe to SCTP_STREAM_RESET_EVENT
|
||||
*/
|
||||
|
@ -536,7 +528,6 @@ struct sctp_stream_change_event {
|
|||
#define SCTP_STREAM_CHANGE_DENIED 0x0004
|
||||
#define SCTP_STREAM_CHANGE_FAILED 0x0008
|
||||
|
||||
|
||||
/* SCTP notification event */
|
||||
struct sctp_tlv {
|
||||
uint16_t sn_type;
|
||||
|
@ -611,6 +602,7 @@ struct sctp_paddrthlds {
|
|||
sctp_assoc_t spt_assoc_id;
|
||||
uint16_t spt_pathmaxrxt;
|
||||
uint16_t spt_pathpfthld;
|
||||
uint16_t spt_pathcpthld;
|
||||
};
|
||||
|
||||
struct sctp_paddrinfo {
|
||||
|
@ -651,10 +643,18 @@ struct sctp_setpeerprim {
|
|||
uint8_t sspp_padding[4];
|
||||
};
|
||||
|
||||
union sctp_sockstore {
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in6 sin6;
|
||||
#if defined(__Userspace__)
|
||||
struct sockaddr_conn sconn;
|
||||
#endif
|
||||
struct sockaddr sa;
|
||||
};
|
||||
|
||||
struct sctp_getaddresses {
|
||||
sctp_assoc_t sget_assoc_id;
|
||||
/* addr is filled in for N * sockaddr_storage */
|
||||
struct sockaddr addr[1];
|
||||
union sctp_sockstore addr[];
|
||||
};
|
||||
|
||||
struct sctp_status {
|
||||
|
@ -1001,7 +1001,7 @@ struct sctpstat {
|
|||
uint32_t sctps_recvauthfailed; /* total number of auth failed */
|
||||
uint32_t sctps_recvexpress; /* total fast path receives all one chunk */
|
||||
uint32_t sctps_recvexpressm; /* total fast path multi-part data */
|
||||
uint32_t sctps_recvnocrc;
|
||||
uint32_t sctps_recv_spare; /* formerly sctps_recvnocrc */
|
||||
uint32_t sctps_recvswcrc;
|
||||
uint32_t sctps_recvhwcrc;
|
||||
|
||||
|
@ -1012,13 +1012,13 @@ struct sctpstat {
|
|||
uint32_t sctps_sendretransdata; /* total output retransmitted DATA chunks */
|
||||
uint32_t sctps_sendfastretrans; /* total output fast retransmitted DATA chunks */
|
||||
uint32_t sctps_sendmultfastretrans; /* total FR's that happened more than once
|
||||
* to same chunk (u-del multi-fr algo).
|
||||
*/
|
||||
* to same chunk (u-del multi-fr algo).
|
||||
*/
|
||||
uint32_t sctps_sendheartbeat; /* total output HB chunks */
|
||||
uint32_t sctps_sendecne; /* total output ECNE chunks */
|
||||
uint32_t sctps_sendauth; /* total output AUTH chunks FIXME */
|
||||
uint32_t sctps_senderrors; /* ip_output error counter */
|
||||
uint32_t sctps_sendnocrc;
|
||||
uint32_t sctps_senderrors; /* ip_output error counter */
|
||||
uint32_t sctps_send_spare; /* formerly sctps_sendnocrc */
|
||||
uint32_t sctps_sendswcrc;
|
||||
uint32_t sctps_sendhwcrc;
|
||||
/* PCKDROPREP statistics: */
|
||||
|
@ -1104,19 +1104,26 @@ struct sctpstat {
|
|||
uint32_t sctps_send_burst_avoid; /* Unused */
|
||||
uint32_t sctps_send_cwnd_avoid; /* Send cwnd full avoidance, already max burst inflight to net */
|
||||
uint32_t sctps_fwdtsn_map_over; /* number of map array over-runs via fwd-tsn's */
|
||||
uint32_t sctps_queue_upd_ecne; /* Number of times we queued or updated an ECN chunk on send queue */
|
||||
uint32_t sctps_reserved[31]; /* Future ABI compat - remove int's from here when adding new */
|
||||
uint32_t sctps_queue_upd_ecne; /* Number of times we queued or updated an ECN chunk on send queue */
|
||||
uint32_t sctps_recvzerocrc; /* Number of accepted packets with zero CRC */
|
||||
uint32_t sctps_sendzerocrc; /* Number of packets sent with zero CRC */
|
||||
uint32_t sctps_reserved[29]; /* Future ABI compat - remove int's from here when adding new */
|
||||
};
|
||||
|
||||
#define SCTP_STAT_INCR(_x) SCTP_STAT_INCR_BY(_x,1)
|
||||
#define SCTP_STAT_DECR(_x) SCTP_STAT_DECR_BY(_x,1)
|
||||
#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
|
||||
#define SCTP_STAT_INCR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x += _d)
|
||||
#define SCTP_STAT_DECR_BY(_x,_d) (SCTP_BASE_STATS[PCPU_GET(cpuid)]._x -= _d)
|
||||
#else
|
||||
#define SCTP_STAT_INCR_BY(_x,_d) atomic_add_int(&SCTP_BASE_STAT(_x), _d)
|
||||
#define SCTP_STAT_DECR_BY(_x,_d) atomic_subtract_int(&SCTP_BASE_STAT(_x), _d)
|
||||
#endif
|
||||
#else
|
||||
#define SCTP_STAT_INCR_BY(_x,_d) atomic_add_int(&SCTP_BASE_STAT(_x), _d)
|
||||
#define SCTP_STAT_DECR_BY(_x,_d) atomic_subtract_int(&SCTP_BASE_STAT(_x), _d)
|
||||
#endif
|
||||
/* The following macros are for handling MIB values, */
|
||||
#define SCTP_STAT_INCR_COUNTER32(_x) SCTP_STAT_INCR(_x)
|
||||
#define SCTP_STAT_INCR_COUNTER64(_x) SCTP_STAT_INCR(_x)
|
||||
|
@ -1125,34 +1132,14 @@ struct sctpstat {
|
|||
#define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x)
|
||||
#define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x)
|
||||
|
||||
#if defined(__Userspace__)
|
||||
union sctp_sockstore {
|
||||
#if defined(INET)
|
||||
struct sockaddr_in sin;
|
||||
#endif
|
||||
#if defined(INET6)
|
||||
struct sockaddr_in6 sin6;
|
||||
#endif
|
||||
struct sockaddr_conn sconn;
|
||||
struct sockaddr sa;
|
||||
};
|
||||
#else
|
||||
union sctp_sockstore {
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in6 sin6;
|
||||
struct sockaddr sa;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************/
|
||||
/* And something for us old timers */
|
||||
/***********************************/
|
||||
|
||||
#ifndef __APPLE__
|
||||
#ifndef __Userspace__
|
||||
#if !(defined(__APPLE__) && !defined(__Userspace__))
|
||||
#if !defined(__Userspace__)
|
||||
#ifndef ntohll
|
||||
#if defined(__Userspace_os_Linux)
|
||||
#if defined(__linux__)
|
||||
#ifndef _BSD_SOURCE
|
||||
#define _BSD_SOURCE
|
||||
#endif
|
||||
|
@ -1164,7 +1151,7 @@ union sctp_sockstore {
|
|||
#endif
|
||||
|
||||
#ifndef htonll
|
||||
#if defined(__Userspace_os_Linux)
|
||||
#if defined(__linux__)
|
||||
#ifndef _BSD_SOURCE
|
||||
#define _BSD_SOURCE
|
||||
#endif
|
||||
|
@ -1178,30 +1165,33 @@ union sctp_sockstore {
|
|||
#endif
|
||||
/***********************************/
|
||||
|
||||
|
||||
struct xsctp_inpcb {
|
||||
uint32_t last;
|
||||
uint32_t flags;
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version < 1000048
|
||||
uint32_t features;
|
||||
#else
|
||||
uint64_t features;
|
||||
#endif
|
||||
uint32_t total_sends;
|
||||
uint32_t total_recvs;
|
||||
uint32_t total_nospaces;
|
||||
uint32_t fragmentation_point;
|
||||
uint16_t local_port;
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint16_t qlen_old;
|
||||
uint16_t maxqlen_old;
|
||||
#else
|
||||
uint16_t qlen;
|
||||
uint16_t maxqlen;
|
||||
#if defined(__Windows__)
|
||||
uint16_t padding;
|
||||
#endif
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version < 1000048
|
||||
uint32_t extra_padding[32]; /* future */
|
||||
uint16_t __spare16;
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
kvaddr_t socket;
|
||||
#else
|
||||
uint32_t extra_padding[31]; /* future */
|
||||
void *socket;
|
||||
#endif
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint32_t qlen;
|
||||
uint32_t maxqlen;
|
||||
#endif
|
||||
uint32_t extra_padding[26]; /* future */
|
||||
};
|
||||
|
||||
struct xsctp_tcb {
|
||||
|
@ -1230,18 +1220,9 @@ struct xsctp_tcb {
|
|||
uint16_t remote_port; /* sctpAssocEntry 4 */
|
||||
struct sctp_timeval start_time; /* sctpAssocEntry 16 */
|
||||
struct sctp_timeval discontinuity_time; /* sctpAssocEntry 17 */
|
||||
#if defined(__FreeBSD__)
|
||||
#if __FreeBSD_version >= 800000
|
||||
uint32_t peers_rwnd;
|
||||
sctp_assoc_t assoc_id; /* sctpAssocEntry 1 */
|
||||
uint32_t extra_padding[32]; /* future */
|
||||
#else
|
||||
#endif
|
||||
#else
|
||||
uint32_t peers_rwnd;
|
||||
sctp_assoc_t assoc_id; /* sctpAssocEntry 1 */
|
||||
uint32_t extra_padding[32]; /* future */
|
||||
#endif
|
||||
};
|
||||
|
||||
struct xsctp_laddr {
|
||||
|
@ -1266,17 +1247,12 @@ struct xsctp_raddr {
|
|||
uint8_t heartbeat_enabled; /* sctpAssocLocalRemEntry 4 */
|
||||
uint8_t potentially_failed;
|
||||
struct sctp_timeval start_time; /* sctpAssocLocalRemEntry 8 */
|
||||
#if defined(__FreeBSD__)
|
||||
#if __FreeBSD_version >= 800000
|
||||
uint32_t rtt;
|
||||
uint32_t heartbeat_interval;
|
||||
uint32_t extra_padding[31]; /* future */
|
||||
#endif
|
||||
#else
|
||||
uint32_t rtt;
|
||||
uint32_t heartbeat_interval;
|
||||
uint32_t extra_padding[31]; /* future */
|
||||
#endif
|
||||
uint32_t ssthresh;
|
||||
uint16_t encaps_port;
|
||||
uint16_t state;
|
||||
uint32_t extra_padding[29]; /* future */
|
||||
};
|
||||
|
||||
#define SCTP_MAX_LOGGING_SIZE 30000
|
||||
|
@ -1303,19 +1279,14 @@ int
|
|||
sctp_lower_sosend(struct socket *so,
|
||||
struct sockaddr *addr,
|
||||
struct uio *uio,
|
||||
#if defined(__Panda__)
|
||||
pakhandle_type i_pak,
|
||||
pakhandle_type i_control,
|
||||
#else
|
||||
struct mbuf *i_pak,
|
||||
struct mbuf *top,
|
||||
struct mbuf *control,
|
||||
#endif
|
||||
int flags,
|
||||
struct sctp_sndrcvinfo *srcv
|
||||
#if !(defined(__Panda__) || defined(__Userspace__))
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
|
||||
#if !defined(__Userspace__)
|
||||
#if defined(__FreeBSD__)
|
||||
,struct thread *p
|
||||
#elif defined(__Windows__)
|
||||
#elif defined(_WIN32)
|
||||
, PKTHREAD p
|
||||
#else
|
||||
,struct proc *p
|
||||
|
@ -1326,11 +1297,7 @@ sctp_lower_sosend(struct socket *so,
|
|||
int
|
||||
sctp_sorecvmsg(struct socket *so,
|
||||
struct uio *uio,
|
||||
#if defined(__Panda__)
|
||||
particletype **mp,
|
||||
#else
|
||||
struct mbuf **mp,
|
||||
#endif
|
||||
struct sockaddr *from,
|
||||
int fromlen,
|
||||
int *msg_flags,
|
||||
|
@ -1344,45 +1311,6 @@ sctp_sorecvmsg(struct socket *so,
|
|||
#if !(defined(_KERNEL)) && !(defined(__Userspace__))
|
||||
|
||||
__BEGIN_DECLS
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version < 902000
|
||||
int sctp_peeloff __P((int, sctp_assoc_t));
|
||||
int sctp_bindx __P((int, struct sockaddr *, int, int));
|
||||
int sctp_connectx __P((int, const struct sockaddr *, int, sctp_assoc_t *));
|
||||
int sctp_getaddrlen __P((sa_family_t));
|
||||
int sctp_getpaddrs __P((int, sctp_assoc_t, struct sockaddr **));
|
||||
void sctp_freepaddrs __P((struct sockaddr *));
|
||||
int sctp_getladdrs __P((int, sctp_assoc_t, struct sockaddr **));
|
||||
void sctp_freeladdrs __P((struct sockaddr *));
|
||||
int sctp_opt_info __P((int, sctp_assoc_t, int, void *, socklen_t *));
|
||||
|
||||
/* deprecated */
|
||||
ssize_t sctp_sendmsg __P((int, const void *, size_t, const struct sockaddr *,
|
||||
socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));
|
||||
|
||||
/* deprecated */
|
||||
ssize_t sctp_send __P((int, const void *, size_t,
|
||||
const struct sctp_sndrcvinfo *, int));
|
||||
|
||||
/* deprecated */
|
||||
ssize_t sctp_sendx __P((int, const void *, size_t, struct sockaddr *,
|
||||
int, struct sctp_sndrcvinfo *, int));
|
||||
|
||||
/* deprecated */
|
||||
ssize_t sctp_sendmsgx __P((int sd, const void *, size_t, struct sockaddr *,
|
||||
int, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t));
|
||||
|
||||
sctp_assoc_t sctp_getassocid __P((int, struct sockaddr *));
|
||||
|
||||
/* deprecated */
|
||||
ssize_t sctp_recvmsg __P((int, void *, size_t, struct sockaddr *, socklen_t *,
|
||||
struct sctp_sndrcvinfo *, int *));
|
||||
|
||||
ssize_t sctp_sendv __P((int, const struct iovec *, int, struct sockaddr *,
|
||||
int, void *, socklen_t, unsigned int, int));
|
||||
|
||||
ssize_t sctp_recvv __P((int, const struct iovec *, int, struct sockaddr *,
|
||||
socklen_t *, void *, socklen_t *, unsigned int *, int *));
|
||||
#else
|
||||
int sctp_peeloff(int, sctp_assoc_t);
|
||||
int sctp_bindx(int, struct sockaddr *, int, int);
|
||||
int sctp_connectx(int, const struct sockaddr *, int, sctp_assoc_t *);
|
||||
|
@ -1420,7 +1348,6 @@ ssize_t sctp_sendv(int, const struct iovec *, int, struct sockaddr *,
|
|||
|
||||
ssize_t sctp_recvv(int, const struct iovec *, int, struct sockaddr *,
|
||||
socklen_t *, void *, socklen_t *, unsigned int *, int *);
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_KERNEL */
|
||||
|
|
|
@ -31,164 +31,200 @@
|
|||
#include <netinet/sctp_pcb.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <iphlpapi.h>
|
||||
#pragma comment(lib, "IPHLPAPI.lib")
|
||||
#if !defined(__MINGW32__)
|
||||
#pragma comment(lib, "iphlpapi.lib")
|
||||
#endif
|
||||
#endif
|
||||
#include <netinet/sctp_os_userspace.h>
|
||||
#if defined(__FreeBSD__)
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* Adapter to translate Unix thread start routines to Windows thread start
|
||||
* routines.
|
||||
*/
|
||||
#if defined(__MINGW32__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
static DWORD WINAPI
|
||||
sctp_create_thread_adapter(void *arg) {
|
||||
start_routine_t start_routine = (start_routine_t)arg;
|
||||
return start_routine(NULL) == NULL;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && !defined(__Userspace_os_NaCl)
|
||||
int
|
||||
sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af)
|
||||
sctp_userspace_thread_create(userland_thread_t *thread, start_routine_t start_routine)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
int fd;
|
||||
*thread = CreateThread(NULL, 0, sctp_create_thread_adapter,
|
||||
(void *)start_routine, 0, NULL);
|
||||
if (*thread == NULL)
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if_indextoname(if_index, ifr.ifr_name);
|
||||
/* TODO can I use the raw socket here and not have to open a new one with each query? */
|
||||
if ((fd = socket(af, SOCK_DGRAM, 0)) < 0)
|
||||
return (0);
|
||||
if (ioctl(fd, SIOCGIFMTU, &ifr) < 0) {
|
||||
close(fd);
|
||||
return (0);
|
||||
}
|
||||
close(fd);
|
||||
return ifr.ifr_mtu;
|
||||
#if defined(__MINGW32__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#else
|
||||
int
|
||||
sctp_userspace_thread_create(userland_thread_t *thread, start_routine_t start_routine)
|
||||
{
|
||||
return pthread_create(thread, NULL, start_routine, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__Userspace_os_NaCl)
|
||||
void
|
||||
sctp_userspace_set_threadname(const char *name)
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
pthread_setname_np(name);
|
||||
#endif
|
||||
#if defined(__linux__)
|
||||
prctl(PR_SET_NAME, name);
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
pthread_set_name_np(pthread_self(), name);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && !defined(__native_client__)
|
||||
int
|
||||
sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af)
|
||||
sctp_userspace_get_mtu_from_ifn(uint32_t if_index)
|
||||
{
|
||||
#if defined(INET) || defined(INET6)
|
||||
struct ifreq ifr;
|
||||
int fd;
|
||||
#endif
|
||||
int mtu;
|
||||
|
||||
if (if_index == 0xffffffff) {
|
||||
mtu = 1280;
|
||||
} else {
|
||||
mtu = 0;
|
||||
#if defined(INET) || defined(INET6)
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
if (if_indextoname(if_index, ifr.ifr_name) != NULL) {
|
||||
/* TODO can I use the raw socket here and not have to open a new one with each query? */
|
||||
#if defined(INET)
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) {
|
||||
#else
|
||||
if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) >= 0) {
|
||||
#endif
|
||||
if (ioctl(fd, SIOCGIFMTU, &ifr) >= 0) {
|
||||
mtu = ifr.ifr_mtu;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return (mtu);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__native_client__)
|
||||
int
|
||||
sctp_userspace_get_mtu_from_ifn(uint32_t if_index)
|
||||
{
|
||||
return 1280;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(__QNX__) || defined(_WIN32) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
|
||||
int
|
||||
timingsafe_bcmp(const void *b1, const void *b2, size_t n)
|
||||
{
|
||||
const unsigned char *p1 = b1, *p2 = b2;
|
||||
int ret = 0;
|
||||
|
||||
for (; n > 0; n--)
|
||||
ret |= *p1++ ^ *p2++;
|
||||
return (ret != 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
int
|
||||
sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af)
|
||||
sctp_userspace_get_mtu_from_ifn(uint32_t if_index)
|
||||
{
|
||||
#if defined(INET) || defined(INET6)
|
||||
PIP_ADAPTER_ADDRESSES pAdapterAddrs, pAdapt;
|
||||
DWORD AdapterAddrsSize, Err;
|
||||
#endif
|
||||
int mtu;
|
||||
|
||||
AdapterAddrsSize = 0;
|
||||
if ((Err = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &AdapterAddrsSize)) != 0) {
|
||||
if ((Err != ERROR_BUFFER_OVERFLOW) && (Err != ERROR_INSUFFICIENT_BUFFER)) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersAddresses() sizing failed with error code %d, AdapterAddrsSize = %d\n", Err, AdapterAddrsSize);
|
||||
return (-1);
|
||||
if (if_index == 0xffffffff) {
|
||||
mtu = 1280;
|
||||
} else {
|
||||
mtu = 0;
|
||||
#if defined(INET) || defined(INET6)
|
||||
AdapterAddrsSize = 0;
|
||||
pAdapterAddrs = NULL;
|
||||
if ((Err = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &AdapterAddrsSize)) != 0) {
|
||||
if ((Err != ERROR_BUFFER_OVERFLOW) && (Err != ERROR_INSUFFICIENT_BUFFER)) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersAddresses() sizing failed with error code %d, AdapterAddrsSize = %d\n", Err, AdapterAddrsSize);
|
||||
mtu = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if ((pAdapterAddrs = (PIP_ADAPTER_ADDRESSES) GlobalAlloc(GPTR, AdapterAddrsSize)) == NULL) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "Memory allocation error!\n");
|
||||
mtu = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
if ((Err = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersAddresses() failed with error code %d\n", Err);
|
||||
mtu = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
for (pAdapt = pAdapterAddrs; pAdapt; pAdapt = pAdapt->Next) {
|
||||
if (pAdapt->IfIndex == if_index) {
|
||||
mtu = pAdapt->Mtu;
|
||||
break;
|
||||
}
|
||||
}
|
||||
cleanup:
|
||||
if (pAdapterAddrs != NULL) {
|
||||
GlobalFree(pAdapterAddrs);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if ((pAdapterAddrs = (PIP_ADAPTER_ADDRESSES) GlobalAlloc(GPTR, AdapterAddrsSize)) == NULL) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "Memory allocation error!\n");
|
||||
return (-1);
|
||||
}
|
||||
if ((Err = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersAddresses() failed with error code %d\n", Err);
|
||||
return (-1);
|
||||
}
|
||||
for (pAdapt = pAdapterAddrs; pAdapt; pAdapt = pAdapt->Next) {
|
||||
if (pAdapt->IfIndex == if_index)
|
||||
return (pAdapt->Mtu);
|
||||
}
|
||||
return (0);
|
||||
return (mtu);
|
||||
}
|
||||
|
||||
void
|
||||
getwintimeofday(struct timeval *tv)
|
||||
{
|
||||
struct timeb tb;
|
||||
FILETIME filetime;
|
||||
ULARGE_INTEGER ularge;
|
||||
|
||||
ftime(&tb);
|
||||
tv->tv_sec = (long)tb.time;
|
||||
tv->tv_usec = (long)(tb.millitm) * 1000L;
|
||||
}
|
||||
|
||||
int
|
||||
Win_getifaddrs(struct ifaddrs** interfaces)
|
||||
{
|
||||
#if defined(INET) || defined(INET6)
|
||||
DWORD Err, AdapterAddrsSize;
|
||||
int count;
|
||||
PIP_ADAPTER_ADDRESSES pAdapterAddrs, pAdapt;
|
||||
struct ifaddrs *ifa;
|
||||
GetSystemTimeAsFileTime(&filetime);
|
||||
ularge.LowPart = filetime.dwLowDateTime;
|
||||
ularge.HighPart = filetime.dwHighDateTime;
|
||||
/* Change base from Jan 1 1601 00:00:00 to Jan 1 1970 00:00:00 */
|
||||
#if defined(__MINGW32__)
|
||||
ularge.QuadPart -= 116444736000000000ULL;
|
||||
#else
|
||||
ularge.QuadPart -= 116444736000000000UI64;
|
||||
#endif
|
||||
#if defined(INET)
|
||||
struct sockaddr_in *addr;
|
||||
/*
|
||||
* ularge.QuadPart is now the number of 100-nanosecond intervals
|
||||
* since Jan 1 1970 00:00:00.
|
||||
*/
|
||||
#if defined(__MINGW32__)
|
||||
tv->tv_sec = (long)(ularge.QuadPart / 10000000ULL);
|
||||
tv->tv_usec = (long)((ularge.QuadPart % 10000000ULL) / 10ULL);
|
||||
#else
|
||||
tv->tv_sec = (long)(ularge.QuadPart / 10000000UI64);
|
||||
tv->tv_usec = (long)((ularge.QuadPart % 10000000UI64) / 10UI64);
|
||||
#endif
|
||||
#if defined(INET6)
|
||||
struct sockaddr_in6 *addr6;
|
||||
#endif
|
||||
#if defined(INET) || defined(INET6)
|
||||
count = 0;
|
||||
#endif
|
||||
#if defined(INET)
|
||||
AdapterAddrsSize = 0;
|
||||
if ((Err = GetAdaptersAddresses(AF_INET, 0, NULL, NULL, &AdapterAddrsSize)) != 0) {
|
||||
if ((Err != ERROR_BUFFER_OVERFLOW) && (Err != ERROR_INSUFFICIENT_BUFFER)) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersV4Addresses() sizing failed with error code %d and AdapterAddrsSize = %d\n", Err, AdapterAddrsSize);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
/* Allocate memory from sizing information */
|
||||
if ((pAdapterAddrs = (PIP_ADAPTER_ADDRESSES) GlobalAlloc(GPTR, AdapterAddrsSize)) == NULL) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "Memory allocation error!\n");
|
||||
return (-1);
|
||||
}
|
||||
/* Get actual adapter information */
|
||||
if ((Err = GetAdaptersAddresses(AF_INET, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersV4Addresses() failed with error code %d\n", Err);
|
||||
return (-1);
|
||||
}
|
||||
/* Enumerate through each returned adapter and save its information */
|
||||
for (pAdapt = pAdapterAddrs, count; pAdapt; pAdapt = pAdapt->Next, count++) {
|
||||
addr = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in));
|
||||
ifa = (struct ifaddrs *)malloc(sizeof(struct ifaddrs));
|
||||
if ((addr == NULL) || (ifa == NULL)) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "Can't allocate memory\n");
|
||||
return (-1);
|
||||
}
|
||||
ifa->ifa_name = _strdup(pAdapt->AdapterName);
|
||||
ifa->ifa_flags = pAdapt->Flags;
|
||||
ifa->ifa_addr = (struct sockaddr *)addr;
|
||||
memcpy(addr, &pAdapt->FirstUnicastAddress->Address.lpSockaddr, sizeof(struct sockaddr_in));
|
||||
interfaces[count] = ifa;
|
||||
}
|
||||
#endif
|
||||
#if defined(INET6)
|
||||
if (SCTP_BASE_VAR(userspace_rawsctp6) != -1) {
|
||||
AdapterAddrsSize = 0;
|
||||
if ((Err = GetAdaptersAddresses(AF_INET6, 0, NULL, NULL, &AdapterAddrsSize)) != 0) {
|
||||
if ((Err != ERROR_BUFFER_OVERFLOW) && (Err != ERROR_INSUFFICIENT_BUFFER)) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersV6Addresses() sizing failed with error code %d AdapterAddrsSize = %d\n", Err, AdapterAddrsSize);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
/* Allocate memory from sizing information */
|
||||
if ((pAdapterAddrs = (PIP_ADAPTER_ADDRESSES) GlobalAlloc(GPTR, AdapterAddrsSize)) == NULL) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "Memory allocation error!\n");
|
||||
return (-1);
|
||||
}
|
||||
/* Get actual adapter information */
|
||||
if ((Err = GetAdaptersAddresses(AF_INET6, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersV6Addresses() failed with error code %d\n", Err);
|
||||
return (-1);
|
||||
}
|
||||
/* Enumerate through each returned adapter and save its information */
|
||||
for (pAdapt = pAdapterAddrs, count; pAdapt; pAdapt = pAdapt->Next, count++) {
|
||||
addr6 = (struct sockaddr_in6 *)malloc(sizeof(struct sockaddr_in6));
|
||||
ifa = (struct ifaddrs *)malloc(sizeof(struct ifaddrs));
|
||||
if ((addr6 == NULL) || (ifa == NULL)) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "Can't allocate memory\n");
|
||||
return (-1);
|
||||
}
|
||||
ifa->ifa_name = _strdup(pAdapt->AdapterName);
|
||||
ifa->ifa_flags = pAdapt->Flags;
|
||||
ifa->ifa_addr = (struct sockaddr *)addr6;
|
||||
memcpy(addr6, &pAdapt->FirstUnicastAddress->Address.lpSockaddr, sizeof(struct sockaddr_in6));
|
||||
interfaces[count] = ifa;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 275427 2014-12-02 20:29:29Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_VAR_H_
|
||||
|
@ -42,10 +44,13 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 275427 2014-12-02 20:29:29Z tuex
|
|||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__)
|
||||
#if !defined(__Userspace__)
|
||||
#if defined(__FreeBSD__)
|
||||
extern struct protosw sctp_seqpacket_protosw, sctp_stream_protosw;
|
||||
#else
|
||||
extern struct pr_usrreqs sctp_usrreqs;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define sctp_feature_on(inp, feature) (inp->sctp_features |= feature)
|
||||
#define sctp_feature_off(inp, feature) (inp->sctp_features &= ~feature)
|
||||
|
@ -88,9 +93,9 @@ extern struct pr_usrreqs sctp_usrreqs;
|
|||
|
||||
#define sctp_sbspace(asoc, sb) ((long) ((sctp_maxspace(sb) > (asoc)->sb_cc) ? (sctp_maxspace(sb) - (asoc)->sb_cc) : 0))
|
||||
|
||||
#define sctp_sbspace_failedmsgs(sb) ((long) ((sctp_maxspace(sb) > (sb)->sb_cc) ? (sctp_maxspace(sb) - (sb)->sb_cc) : 0))
|
||||
#define sctp_sbspace_failedmsgs(sb) ((long) ((sctp_maxspace(sb) > SCTP_SBAVAIL(sb)) ? (sctp_maxspace(sb) - SCTP_SBAVAIL(sb)) : 0))
|
||||
|
||||
#define sctp_sbspace_sub(a,b) ((a > b) ? (a - b) : 0)
|
||||
#define sctp_sbspace_sub(a,b) (((a) > (b)) ? ((a) - (b)) : 0)
|
||||
|
||||
/*
|
||||
* I tried to cache the readq entries at one point. But the reality
|
||||
|
@ -101,11 +106,19 @@ extern struct pr_usrreqs sctp_usrreqs;
|
|||
* an mbuf cache as well so it is not really worth doing, at least
|
||||
* right now :-D
|
||||
*/
|
||||
|
||||
#ifdef INVARIANTS
|
||||
#define sctp_free_a_readq(_stcb, _readq) { \
|
||||
if ((_readq)->on_strm_q) \
|
||||
panic("On strm q stcb:%p readq:%p", (_stcb), (_readq)); \
|
||||
SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_readq), (_readq)); \
|
||||
SCTP_DECR_READQ_COUNT(); \
|
||||
}
|
||||
#else
|
||||
#define sctp_free_a_readq(_stcb, _readq) { \
|
||||
SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_readq), (_readq)); \
|
||||
SCTP_DECR_READQ_COUNT(); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define sctp_alloc_a_readq(_stcb, _readq) { \
|
||||
(_readq) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_readq), struct sctp_queued_to_read); \
|
||||
|
@ -176,17 +189,11 @@ extern struct pr_usrreqs sctp_usrreqs;
|
|||
} \
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version > 500000
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#define sctp_free_remote_addr(__net) { \
|
||||
if ((__net)) { \
|
||||
if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \
|
||||
(void)SCTP_OS_TIMER_STOP(&(__net)->rxt_timer.timer); \
|
||||
(void)SCTP_OS_TIMER_STOP(&(__net)->pmtu_timer.timer); \
|
||||
if ((__net)->ro.ro_rt) { \
|
||||
RTFREE((__net)->ro.ro_rt); \
|
||||
(__net)->ro.ro_rt = NULL; \
|
||||
} \
|
||||
RO_NHFREE(&(__net)->ro); \
|
||||
if ((__net)->src_addr_selected) { \
|
||||
sctp_free_ifa((__net)->ro._s_addr); \
|
||||
(__net)->ro._s_addr = NULL; \
|
||||
|
@ -215,22 +222,17 @@ extern struct pr_usrreqs sctp_usrreqs;
|
|||
atomic_add_int(&(sb)->sb_cc,SCTP_BUF_LEN((m))); \
|
||||
atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \
|
||||
if (stcb) { \
|
||||
atomic_add_int(&(stcb)->asoc.sb_cc,SCTP_BUF_LEN((m))); \
|
||||
atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
|
||||
atomic_add_int(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \
|
||||
} \
|
||||
if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \
|
||||
SCTP_BUF_TYPE(m) != MT_OOBDATA) \
|
||||
atomic_add_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \
|
||||
}
|
||||
|
||||
#else /* FreeBSD Version <= 500000 or non-FreeBSD */
|
||||
|
||||
#define sctp_free_remote_addr(__net) { \
|
||||
if ((__net)) { \
|
||||
if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \
|
||||
(void)SCTP_OS_TIMER_STOP(&(__net)->rxt_timer.timer); \
|
||||
(void)SCTP_OS_TIMER_STOP(&(__net)->pmtu_timer.timer); \
|
||||
(void)SCTP_OS_TIMER_STOP(&(__net)->hb_timer.timer); \
|
||||
if ((__net)->ro.ro_rt) { \
|
||||
RTFREE((__net)->ro.ro_rt); \
|
||||
(__net)->ro.ro_rt = NULL; \
|
||||
|
@ -247,31 +249,6 @@ extern struct pr_usrreqs sctp_usrreqs;
|
|||
} \
|
||||
}
|
||||
|
||||
#if defined(__Panda__)
|
||||
#define sctp_sbfree(ctl, stcb, sb, m) { \
|
||||
if ((sb)->sb_cc >= (uint32_t)SCTP_BUF_LEN((m))) { \
|
||||
atomic_subtract_int(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
|
||||
} else { \
|
||||
(sb)->sb_cc = 0; \
|
||||
} \
|
||||
if (((ctl)->do_not_ref_stcb == 0) && stcb) { \
|
||||
if ((stcb)->asoc.sb_cc >= (uint32_t)SCTP_BUF_LEN((m))) { \
|
||||
atomic_subtract_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
|
||||
} else { \
|
||||
(stcb)->asoc.sb_cc = 0; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define sctp_sballoc(stcb, sb, m) { \
|
||||
atomic_add_int(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
|
||||
if (stcb) { \
|
||||
atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
|
||||
} \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define sctp_sbfree(ctl, stcb, sb, m) { \
|
||||
SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
|
||||
SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \
|
||||
|
@ -290,7 +267,6 @@ extern struct pr_usrreqs sctp_usrreqs;
|
|||
} \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define sctp_ucount_incr(val) { \
|
||||
val++; \
|
||||
|
@ -331,7 +307,7 @@ extern struct pr_usrreqs sctp_usrreqs;
|
|||
if (stcb->asoc.fs_index > SCTP_FS_SPEC_LOG_SIZE) \
|
||||
stcb->asoc.fs_index = 0;\
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].total_flight = stcb->asoc.total_flight; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.TSN_seq; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.tsn; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].book = tp1->book_size; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].sent = tp1->sent; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].incr = 0; \
|
||||
|
@ -352,7 +328,7 @@ extern struct pr_usrreqs sctp_usrreqs;
|
|||
if (stcb->asoc.fs_index > SCTP_FS_SPEC_LOG_SIZE) \
|
||||
stcb->asoc.fs_index = 0;\
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].total_flight = stcb->asoc.total_flight; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.TSN_seq; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.tsn; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].book = tp1->book_size; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].sent = tp1->sent; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].incr = 1; \
|
||||
|
@ -391,115 +367,86 @@ struct sctp_inpcb;
|
|||
struct sctp_tcb;
|
||||
struct sctphdr;
|
||||
|
||||
|
||||
#if (defined(__FreeBSD__) && __FreeBSD_version > 690000) || defined(__Windows__) || defined(__Userspace__)
|
||||
#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
|
||||
void sctp_close(struct socket *so);
|
||||
#else
|
||||
int sctp_detach(struct socket *so);
|
||||
#endif
|
||||
int sctp_disconnect(struct socket *so);
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__)
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version < 902000
|
||||
void sctp_ctlinput __P((int, struct sockaddr *, void *));
|
||||
int sctp_ctloutput __P((struct socket *, struct sockopt *));
|
||||
#ifdef INET
|
||||
void sctp_input_with_port __P((struct mbuf *, int, uint16_t));
|
||||
void sctp_input __P((struct mbuf *, int));
|
||||
#endif
|
||||
void sctp_pathmtu_adjustment __P((struct sctp_tcb *, uint16_t));
|
||||
#if !defined(__Userspace__)
|
||||
#if defined(__APPLE__) && !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN)
|
||||
void sctp_ctlinput(int, struct sockaddr *, void *, struct ifnet * SCTP_UNUSED);
|
||||
#elif defined(__FreeBSD__)
|
||||
ipproto_ctlinput_t sctp_ctlinput;
|
||||
#else
|
||||
void sctp_ctlinput(int, struct sockaddr *, void *);
|
||||
#endif
|
||||
int sctp_ctloutput(struct socket *, struct sockopt *);
|
||||
#ifdef INET
|
||||
void sctp_input_with_port(struct mbuf *, int, uint16_t);
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 1100020
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
int sctp_input(struct mbuf **, int *, int);
|
||||
#else
|
||||
void sctp_input(struct mbuf *, int);
|
||||
#endif
|
||||
#endif
|
||||
void sctp_pathmtu_adjustment(struct sctp_tcb *, uint16_t);
|
||||
#endif
|
||||
void sctp_pathmtu_adjustment(struct sctp_tcb *, uint32_t, bool);
|
||||
#else
|
||||
#if defined(__Panda__)
|
||||
void sctp_input(pakhandle_type i_pak);
|
||||
#elif defined(__Userspace__)
|
||||
void sctp_pathmtu_adjustment(struct sctp_tcb *, uint16_t);
|
||||
#if defined(__Userspace__)
|
||||
void sctp_pathmtu_adjustment(struct sctp_tcb *, uint32_t, bool);
|
||||
#else
|
||||
void sctp_input(struct mbuf *,...);
|
||||
#endif
|
||||
void *sctp_ctlinput(int, struct sockaddr *, void *);
|
||||
int sctp_ctloutput(int, struct socket *, int, int, struct mbuf **);
|
||||
#endif
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version < 902000
|
||||
void sctp_drain __P((void));
|
||||
#else
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
void sctp_drain(void);
|
||||
#endif
|
||||
#if defined(__Userspace__)
|
||||
void sctp_init(uint16_t,
|
||||
int (*)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
|
||||
void (*)(const char *, ...));
|
||||
#elif defined(__FreeBSD__) && __FreeBSD_version < 902000
|
||||
void sctp_init __P((void));
|
||||
void (*)(const char *, ...), int start_threads);
|
||||
#elif defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) &&!defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION))
|
||||
void sctp_init(struct protosw *pp, struct domain *dp);
|
||||
#else
|
||||
#if !defined(__FreeBSD__)
|
||||
void sctp_init(void);
|
||||
#endif
|
||||
void sctp_notify(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *,
|
||||
uint8_t, uint8_t, uint16_t, uint32_t);
|
||||
#endif
|
||||
#if !defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
void sctp_finish(void);
|
||||
#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__)
|
||||
#endif
|
||||
#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
|
||||
int sctp_flush(struct socket *, int);
|
||||
#endif
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version < 902000
|
||||
int sctp_shutdown __P((struct socket *));
|
||||
void sctp_notify __P((struct sctp_inpcb *, struct ip *ip, struct sctphdr *,
|
||||
struct sockaddr *, struct sctp_tcb *,
|
||||
struct sctp_nets *));
|
||||
#else
|
||||
int sctp_shutdown(struct socket *);
|
||||
void sctp_notify(struct sctp_inpcb *, struct ip *ip, struct sctphdr *,
|
||||
struct sockaddr *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
#endif
|
||||
int sctp_bindx(struct socket *, int, struct sockaddr_storage *,
|
||||
int, int, struct proc *);
|
||||
/* can't use sctp_assoc_t here */
|
||||
int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *);
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__)
|
||||
#if !defined(__Userspace__)
|
||||
int sctp_ingetaddr(struct socket *, struct sockaddr **);
|
||||
#elif defined(__Panda__)
|
||||
int sctp_ingetaddr(struct socket *, struct sockaddr *);
|
||||
#else
|
||||
int sctp_ingetaddr(struct socket *, struct mbuf *);
|
||||
#endif
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__)
|
||||
#if !defined(__Userspace__)
|
||||
int sctp_peeraddr(struct socket *, struct sockaddr **);
|
||||
#elif defined(__Panda__)
|
||||
int sctp_peeraddr(struct socket *, struct sockaddr *);
|
||||
#else
|
||||
int sctp_peeraddr(struct socket *, struct mbuf *);
|
||||
#endif
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
|
||||
#if __FreeBSD_version >= 700000
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
int sctp_listen(struct socket *, int, struct thread *);
|
||||
#else
|
||||
int sctp_listen(struct socket *, struct thread *);
|
||||
#endif
|
||||
#elif defined(__Windows__)
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
int sctp_listen(struct socket *, int, PKTHREAD);
|
||||
#elif defined(__Userspace__)
|
||||
int sctp_listen(struct socket *, int, struct proc *);
|
||||
#else
|
||||
int sctp_listen(struct socket *, struct proc *);
|
||||
#endif
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)
|
||||
int sctp_accept(struct socket *, struct sockaddr **);
|
||||
#elif defined(__Panda__)
|
||||
int sctp_accept(struct socket *, struct sockaddr *, int *, void *, int *);
|
||||
#else
|
||||
int sctp_accept(struct socket *, struct mbuf *);
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctputil.h 276914 2015-01-10 20:49:57Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_UTIL_H_
|
||||
|
@ -55,17 +57,19 @@ void sctp_m_freem(struct mbuf *m);
|
|||
#define sctp_m_freem m_freem
|
||||
#endif
|
||||
|
||||
#if defined(SCTP_LOCAL_TRACE_BUF) || defined(__APPLE__)
|
||||
#if defined(SCTP_LOCAL_TRACE_BUF)
|
||||
void
|
||||
sctp_log_trace(uint32_t fr, const char *str SCTP_UNUSED, uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e, uint32_t f);
|
||||
#endif
|
||||
|
||||
#define sctp_get_associd(stcb) ((sctp_assoc_t)stcb->asoc.assoc_id)
|
||||
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
int32_t
|
||||
sctp_map_assoc_state(int);
|
||||
|
||||
uint32_t
|
||||
sctp_get_ifa_hash_val(struct sockaddr *addr);
|
||||
|
||||
|
@ -79,7 +83,7 @@ uint32_t sctp_select_initial_TSN(struct sctp_pcb *);
|
|||
|
||||
uint32_t sctp_select_a_tag(struct sctp_inpcb *, uint16_t lport, uint16_t rport, int);
|
||||
|
||||
int sctp_init_asoc(struct sctp_inpcb *, struct sctp_tcb *, uint32_t, uint32_t);
|
||||
int sctp_init_asoc(struct sctp_inpcb *, struct sctp_tcb *, uint32_t, uint32_t, uint32_t, uint16_t);
|
||||
|
||||
void sctp_fill_random_store(struct sctp_pcb *);
|
||||
|
||||
|
@ -89,6 +93,14 @@ sctp_notify_stream_reset_add(struct sctp_tcb *stcb, uint16_t numberin,
|
|||
void
|
||||
sctp_notify_stream_reset_tsn(struct sctp_tcb *stcb, uint32_t sending_tsn, uint32_t recv_tsn, int flag);
|
||||
|
||||
/*
|
||||
* NOTE: sctp_timer_start() will increment the reference count of any relevant
|
||||
* structure the timer is referencing, in order to prevent a race condition
|
||||
* between the timer executing and the structure being freed.
|
||||
*
|
||||
* When the timer fires or sctp_timer_stop() is called, these references are
|
||||
* removed.
|
||||
*/
|
||||
void
|
||||
sctp_timer_start(int, struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
@ -101,8 +113,20 @@ int
|
|||
sctp_dynamic_set_primary(struct sockaddr *sa, uint32_t vrf_id);
|
||||
|
||||
void
|
||||
sctp_mtu_size_reset(struct sctp_inpcb *, struct sctp_association *, uint32_t);
|
||||
sctp_wakeup_the_read_socket(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
||||
int so_locked
|
||||
#if !(defined(__APPLE__) && !defined(__Userspace__))
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
);
|
||||
|
||||
#if defined(__Userspace__)
|
||||
void sctp_invoke_recv_callback(struct sctp_inpcb *,
|
||||
struct sctp_tcb *,
|
||||
struct sctp_queued_to_read *,
|
||||
int);
|
||||
|
||||
#endif
|
||||
void
|
||||
sctp_add_to_readq(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb,
|
||||
|
@ -110,21 +134,7 @@ sctp_add_to_readq(struct sctp_inpcb *inp,
|
|||
struct sockbuf *sb,
|
||||
int end,
|
||||
int inpread_locked,
|
||||
int so_locked
|
||||
#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
);
|
||||
|
||||
int
|
||||
sctp_append_to_readq(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb,
|
||||
struct sctp_queued_to_read *control,
|
||||
struct mbuf *m,
|
||||
int end,
|
||||
int new_cumack,
|
||||
struct sockbuf *sb);
|
||||
|
||||
int so_locked);
|
||||
|
||||
void sctp_iterator_worker(void);
|
||||
|
||||
|
@ -134,9 +144,9 @@ uint32_t sctp_get_next_mtu(uint32_t);
|
|||
void
|
||||
sctp_timeout_handler(void *);
|
||||
|
||||
uint32_t
|
||||
int
|
||||
sctp_calculate_rto(struct sctp_tcb *, struct sctp_association *,
|
||||
struct sctp_nets *, struct timeval *, int, int);
|
||||
struct sctp_nets *, struct timeval *, int);
|
||||
|
||||
uint32_t sctp_calculate_len(struct mbuf *);
|
||||
|
||||
|
@ -152,70 +162,55 @@ sctp_add_pad_tombuf(struct mbuf *, int);
|
|||
struct mbuf *
|
||||
sctp_pad_lastmbuf(struct mbuf *, int, struct mbuf *);
|
||||
|
||||
void sctp_ulp_notify(uint32_t, struct sctp_tcb *, uint32_t, void *, int
|
||||
#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
);
|
||||
void sctp_ulp_notify(uint32_t, struct sctp_tcb *, uint32_t, void *, int);
|
||||
|
||||
void
|
||||
sctp_pull_off_control_to_new_inp(struct sctp_inpcb *old_inp,
|
||||
struct sctp_inpcb *new_inp,
|
||||
struct sctp_tcb *stcb, int waitflags);
|
||||
|
||||
|
||||
void sctp_stop_timers_for_shutdown(struct sctp_tcb *);
|
||||
|
||||
void sctp_report_all_outbound(struct sctp_tcb *, uint16_t, int, int
|
||||
#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
);
|
||||
/* Stop all timers for association and remote addresses. */
|
||||
void sctp_stop_association_timers(struct sctp_tcb *, bool);
|
||||
|
||||
void sctp_report_all_outbound(struct sctp_tcb *, uint16_t, int);
|
||||
|
||||
int sctp_expand_mapping_array(struct sctp_association *, uint32_t);
|
||||
|
||||
void sctp_abort_notification(struct sctp_tcb *, uint8_t, uint16_t,
|
||||
struct sctp_abort_chunk *, int
|
||||
#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
);
|
||||
void sctp_abort_notification(struct sctp_tcb *, bool, bool, uint16_t,
|
||||
struct sctp_abort_chunk *, int);
|
||||
|
||||
/* We abort responding to an IP packet for some reason */
|
||||
void
|
||||
sctp_abort_association(struct sctp_inpcb *, struct sctp_tcb *, struct mbuf *,
|
||||
int, struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, struct mbuf *,
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
|
||||
|
||||
/* We choose to abort via user input */
|
||||
void
|
||||
sctp_abort_an_association(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct mbuf *, int
|
||||
#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
);
|
||||
struct mbuf *, bool, int);
|
||||
|
||||
void sctp_handle_ootb(struct mbuf *, int, int,
|
||||
struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, struct sctp_inpcb *,
|
||||
struct mbuf *,
|
||||
#if defined(__FreeBSD__)
|
||||
uint8_t, uint32_t,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t, uint16_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
|
||||
int sctp_connectx_helper_add(struct sctp_tcb *stcb, struct sockaddr *addr,
|
||||
int totaddr, int *error);
|
||||
|
||||
struct sctp_tcb *
|
||||
sctp_connectx_helper_find(struct sctp_inpcb *inp, struct sockaddr *addr,
|
||||
int *totaddr, int *num_v4, int *num_v6, int *error, int limit, int *bad_addr);
|
||||
int
|
||||
sctp_connectx_helper_find(struct sctp_inpcb *, struct sockaddr *,
|
||||
unsigned int, unsigned int *, unsigned int *, unsigned int);
|
||||
|
||||
int sctp_is_there_an_abort_here(struct mbuf *, int, uint32_t *);
|
||||
#ifdef INET6
|
||||
|
@ -266,52 +261,23 @@ void sctp_print_address(struct sockaddr *);
|
|||
|
||||
int
|
||||
sctp_release_pr_sctp_chunk(struct sctp_tcb *, struct sctp_tmit_chunk *,
|
||||
uint8_t, int
|
||||
#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
);
|
||||
uint8_t, int);
|
||||
|
||||
struct mbuf *sctp_generate_cause(uint16_t, char *);
|
||||
struct mbuf *sctp_generate_no_user_data_cause(uint32_t);
|
||||
|
||||
void sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp,
|
||||
struct sockaddr *sa, sctp_assoc_t assoc_id,
|
||||
uint32_t vrf_id, int *error, void *p);
|
||||
void sctp_bindx_delete_address(struct sctp_inpcb *inp,
|
||||
struct sockaddr *sa, sctp_assoc_t assoc_id,
|
||||
uint32_t vrf_id, int *error);
|
||||
struct sockaddr *sa, uint32_t vrf_id, int *error,
|
||||
void *p);
|
||||
void sctp_bindx_delete_address(struct sctp_inpcb *inp, struct sockaddr *sa,
|
||||
uint32_t vrf_id, int *error);
|
||||
|
||||
int sctp_local_addr_count(struct sctp_tcb *stcb);
|
||||
|
||||
#ifdef SCTP_MBCNT_LOGGING
|
||||
void
|
||||
sctp_free_bufspace(struct sctp_tcb *, struct sctp_association *,
|
||||
struct sctp_tmit_chunk *, int);
|
||||
|
||||
#else
|
||||
#define sctp_free_bufspace(stcb, asoc, tp1, chk_cnt) \
|
||||
do { \
|
||||
if (tp1->data != NULL) { \
|
||||
atomic_subtract_int(&((asoc)->chunks_on_out_queue), chk_cnt); \
|
||||
if ((asoc)->total_output_queue_size >= tp1->book_size) { \
|
||||
atomic_subtract_int(&((asoc)->total_output_queue_size), tp1->book_size); \
|
||||
} else { \
|
||||
(asoc)->total_output_queue_size = 0; \
|
||||
} \
|
||||
if (stcb->sctp_socket && ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \
|
||||
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \
|
||||
if (stcb->sctp_socket->so_snd.sb_cc >= tp1->book_size) { \
|
||||
atomic_subtract_int(&((stcb)->sctp_socket->so_snd.sb_cc), tp1->book_size); \
|
||||
} else { \
|
||||
stcb->sctp_socket->so_snd.sb_cc = 0; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
#define sctp_free_spbufspace(stcb, asoc, sp) \
|
||||
do { \
|
||||
if (sp->data != NULL) { \
|
||||
|
@ -342,11 +308,11 @@ do { \
|
|||
} while (0)
|
||||
|
||||
/* functions to start/stop udp tunneling */
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
#if (defined(__APPLE__) || defined(__FreeBSD__)) && !defined(__Userspace__)
|
||||
void sctp_over_udp_stop(void);
|
||||
int sctp_over_udp_start(void);
|
||||
#endif
|
||||
#if defined(__Windows__)
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
void sctp_over_udp_restart(void);
|
||||
#endif
|
||||
|
||||
|
@ -368,7 +334,6 @@ void sctp_log_strm_del_alt(struct sctp_tcb *stcb, uint32_t, uint16_t, uint16_t,
|
|||
|
||||
void sctp_log_nagle_event(struct sctp_tcb *stcb, int action);
|
||||
|
||||
|
||||
#ifdef SCTP_MBUF_LOGGING
|
||||
void
|
||||
sctp_log_mb(struct mbuf *m, int from);
|
||||
|
@ -392,7 +357,7 @@ void sctp_log_closing(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int16_t loc
|
|||
|
||||
void sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from);
|
||||
void sctp_log_maxburst(struct sctp_tcb *stcb, struct sctp_nets *, int, int, uint8_t);
|
||||
void sctp_log_block(uint8_t, struct sctp_association *, int);
|
||||
void sctp_log_block(uint8_t, struct sctp_association *, ssize_t);
|
||||
void sctp_log_rwnd(uint8_t, uint32_t, uint32_t, uint32_t);
|
||||
void sctp_log_rwnd_set(uint8_t, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
int sctp_fill_stat_log(void *, size_t *);
|
||||
|
@ -402,7 +367,6 @@ void sctp_log_map(uint32_t, uint32_t, uint32_t, int);
|
|||
void sctp_print_mapping_array(struct sctp_association *asoc);
|
||||
void sctp_clr_stat_log(void);
|
||||
|
||||
|
||||
#ifdef SCTP_AUDITING_ENABLED
|
||||
void
|
||||
sctp_auditing(int, struct sctp_inpcb *, struct sctp_tcb *,
|
||||
|
@ -410,5 +374,17 @@ sctp_auditing(int, struct sctp_inpcb *, struct sctp_tcb *,
|
|||
void sctp_audit_log(uint8_t, uint8_t);
|
||||
|
||||
#endif
|
||||
uint32_t sctp_min_mtu(uint32_t, uint32_t, uint32_t);
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
void sctp_hc_set_mtu(union sctp_sockstore *, uint16_t, uint32_t);
|
||||
uint32_t sctp_hc_get_mtu(union sctp_sockstore *, uint16_t);
|
||||
#endif
|
||||
void sctp_set_state(struct sctp_tcb *, int);
|
||||
void sctp_add_substate(struct sctp_tcb *, int);
|
||||
uint32_t sctp_ticks_to_msecs(uint32_t);
|
||||
uint32_t sctp_msecs_to_ticks(uint32_t);
|
||||
uint32_t sctp_ticks_to_secs(uint32_t);
|
||||
uint32_t sctp_secs_to_ticks(uint32_t);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,6 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
||||
|
@ -30,9 +32,9 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet6/sctp6_var.h 243186 2012-11-17 20:04:04Z tuexen $");
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET6_SCTP6_VAR_H_
|
||||
|
@ -42,47 +44,44 @@ __FBSDID("$FreeBSD: head/sys/netinet6/sctp6_var.h 243186 2012-11-17 20:04:04Z tu
|
|||
#ifdef INET
|
||||
extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *);
|
||||
extern void in6_sin6_2_sin_in_sock(struct sockaddr *);
|
||||
extern void in6_sin_2_v4mapsin6(struct sockaddr_in *, struct sockaddr_in6 *);
|
||||
extern void in6_sin_2_v4mapsin6(const struct sockaddr_in *, struct sockaddr_in6 *);
|
||||
#endif
|
||||
#endif
|
||||
#if defined(_KERNEL)
|
||||
|
||||
#if defined(__FreeBSD__) || (__APPLE__) || defined(__Windows__)
|
||||
#if !defined(__Userspace__)
|
||||
SYSCTL_DECL(_net_inet6_sctp6);
|
||||
#if defined(__FreeBSD__)
|
||||
extern struct protosw sctp6_seqpacket_protosw, sctp6_stream_protosw;
|
||||
#else
|
||||
extern struct pr_usrreqs sctp6_usrreqs;
|
||||
#endif
|
||||
#else
|
||||
int sctp6_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *);
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
int sctp6_input(struct mbuf **, int *);
|
||||
int sctp6_input_with_port(struct mbuf **, int *, uint16_t);
|
||||
#elif defined(__Panda__)
|
||||
int sctp6_input (pakhandle_type *);
|
||||
#elif defined(__FreeBSD__) && __FreeBSD_version < 902000
|
||||
int sctp6_input __P((struct mbuf **, int *, int));
|
||||
int sctp6_input_with_port __P((struct mbuf **, int *, uint16_t));
|
||||
#else
|
||||
int sctp6_input(struct mbuf **, int *, int);
|
||||
int sctp6_input_with_port(struct mbuf **, int *, uint16_t);
|
||||
#endif
|
||||
#if defined(__FreeBSD__) && __FreeBSD_version < 902000
|
||||
int sctp6_output
|
||||
__P((struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
|
||||
struct mbuf *, struct proc *));
|
||||
void sctp6_ctlinput __P((int, struct sockaddr *, void *));
|
||||
#else
|
||||
int sctp6_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
|
||||
struct mbuf *, struct proc *);
|
||||
void sctp6_ctlinput(int, struct sockaddr *, void *);
|
||||
#if defined(__APPLE__) && !defined(__Userspace__) && !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN)
|
||||
void sctp6_ctlinput(int, struct sockaddr *, void *, struct ifnet * SCTP_UNUSED);
|
||||
#elif defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
ip6proto_ctlinput_t sctp6_ctlinput;
|
||||
#else
|
||||
void sctp6_ctlinput(int, struct sockaddr_in6 *, ip6ctlparam *);
|
||||
#endif
|
||||
#if !(defined(__FreeBSD__) || defined(__APPLE__))
|
||||
#if !((defined(__FreeBSD__) || defined(__APPLE__)) && !defined(__Userspace__))
|
||||
extern void in6_sin_2_v4mapsin6(struct sockaddr_in *, struct sockaddr_in6 *);
|
||||
extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *);
|
||||
extern void in6_sin6_2_sin_in_sock(struct sockaddr *);
|
||||
#endif
|
||||
extern void sctp6_notify(struct sctp_inpcb *, struct icmp6_hdr *,
|
||||
struct sctphdr *, struct sockaddr *,
|
||||
struct sctp_tcb *, struct sctp_nets *);
|
||||
void sctp6_notify(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *,
|
||||
uint8_t, uint8_t, uint32_t);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(__Userspace_os_Darwin) || defined (__Userspace_os_Windows)
|
||||
#if defined (__Userspace_os_Windows)
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
#if defined(_WIN32)
|
||||
#define atomic_add_int(addr, val) InterlockedExchangeAdd((LPLONG)addr, (LONG)val)
|
||||
#define atomic_fetchadd_int(addr, val) InterlockedExchangeAdd((LPLONG)addr, (LONG)val)
|
||||
#define atomic_subtract_int(addr, val) InterlockedExchangeAdd((LPLONG)addr,-((LONG)val))
|
||||
|
@ -54,7 +54,7 @@
|
|||
#define atomic_add_int(addr, val) OSAtomicAdd32Barrier(val, (int32_t *)addr)
|
||||
#define atomic_fetchadd_int(addr, val) OSAtomicAdd32Barrier(val, (int32_t *)addr)
|
||||
#define atomic_subtract_int(addr, val) OSAtomicAdd32Barrier(-val, (int32_t *)addr)
|
||||
#define atomic_cmpset_int(dst, exp, src) OSAtomicCompareAndSwap32Barrier(exp, src, (int *)dst)
|
||||
#define atomic_cmpset_int(dst, exp, src) OSAtomicCompareAndSwapIntBarrier(exp, src, (int *)dst)
|
||||
#define SCTP_DECREMENT_AND_CHECK_REFCOUNT(addr) (atomic_fetchadd_int(addr, -1) == 0)
|
||||
#endif
|
||||
|
||||
|
@ -76,11 +76,11 @@
|
|||
*addr = 0; \
|
||||
} \
|
||||
}
|
||||
#if defined(__Userspace_os_Windows)
|
||||
static void atomic_init() {} /* empty when we are not using atomic_mtx */
|
||||
#else
|
||||
static inline void atomic_init() {} /* empty when we are not using atomic_mtx */
|
||||
#endif
|
||||
#if defined(_WIN32)
|
||||
static void atomic_init(void) {} /* empty when we are not using atomic_mtx */
|
||||
#else
|
||||
static inline void atomic_init(void) {} /* empty when we are not using atomic_mtx */
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
@ -132,7 +132,7 @@ static inline void atomic_init() {} /* empty when we are not using atomic_mtx */
|
|||
} \
|
||||
}
|
||||
#endif
|
||||
static inline void atomic_init() {} /* empty when we are not using atomic_mtx */
|
||||
static inline void atomic_init(void) {} /* empty when we are not using atomic_mtx */
|
||||
#endif
|
||||
|
||||
#if 0 /* using libatomic_ops */
|
||||
|
@ -173,7 +173,7 @@ static inline void atomic_init() {} /* empty when we are not using atomic_mtx */
|
|||
|
||||
extern userland_mutex_t atomic_mtx;
|
||||
|
||||
#if defined (__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
static inline void atomic_init() {
|
||||
InitializeCriticalSection(&atomic_mtx);
|
||||
}
|
||||
|
@ -188,16 +188,31 @@ static inline void atomic_unlock() {
|
|||
}
|
||||
#else
|
||||
static inline void atomic_init() {
|
||||
(void)pthread_mutex_init(&atomic_mtx, NULL);
|
||||
pthread_mutexattr_t mutex_attr;
|
||||
|
||||
pthread_mutexattr_init(&mutex_attr);
|
||||
#ifdef INVARIANTS
|
||||
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_ERRORCHECK);
|
||||
#endif
|
||||
pthread_mutex_init(&accept_mtx, &mutex_attr);
|
||||
pthread_mutexattr_destroy(&mutex_attr);
|
||||
}
|
||||
static inline void atomic_destroy() {
|
||||
(void)pthread_mutex_destroy(&atomic_mtx);
|
||||
}
|
||||
static inline void atomic_lock() {
|
||||
#ifdef INVARIANTS
|
||||
KASSERT(pthread_mutex_lock(&atomic_mtx) == 0, ("atomic_lock: atomic_mtx already locked"))
|
||||
#else
|
||||
(void)pthread_mutex_lock(&atomic_mtx);
|
||||
#endif
|
||||
}
|
||||
static inline void atomic_unlock() {
|
||||
#ifdef INVARIANTS
|
||||
KASSERT(pthread_mutex_unlock(&atomic_mtx) == 0, ("atomic_unlock: atomic_mtx not locked"))
|
||||
#else
|
||||
(void)pthread_mutex_unlock(&atomic_mtx);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
|
|
|
@ -30,18 +30,23 @@
|
|||
|
||||
/* __Userspace__ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#if !defined (__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
#if !defined(_CRT_RAND_S) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
|
||||
#define _CRT_RAND_S
|
||||
#endif
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <netinet/sctp_os_userspace.h>
|
||||
#endif
|
||||
#ifdef INVARIANTS
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#endif
|
||||
#include <user_environment.h>
|
||||
#include <sys/types.h>
|
||||
/* #include <sys/param.h> defines MIN */
|
||||
#if !defined(MIN)
|
||||
#define MIN(arg1,arg2) ((arg1) < (arg2) ? (arg1) : (arg2))
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#define uHZ 1000
|
||||
|
||||
|
@ -60,37 +65,320 @@ u_short ip_id = 0; /*__Userspace__ TODO Should it be initialized to zero? */
|
|||
*/
|
||||
userland_mutex_t atomic_mtx;
|
||||
|
||||
/* Source: /usr/src/sys/dev/random/harvest.c */
|
||||
static int read_random_phony(void *, int);
|
||||
|
||||
static int (*read_func)(void *, int) = read_random_phony;
|
||||
|
||||
/* Userland-visible version of read_random */
|
||||
int
|
||||
read_random(void *buf, int count)
|
||||
{
|
||||
return ((*read_func)(buf, count));
|
||||
}
|
||||
|
||||
/* If the entropy device is not loaded, make a token effort to
|
||||
* provide _some_ kind of randomness. This should only be used
|
||||
* inside other RNG's, like arc4random(9).
|
||||
*/
|
||||
static int
|
||||
read_random_phony(void *buf, int count)
|
||||
#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
uint32_t randval;
|
||||
int size, i;
|
||||
|
||||
/* srandom() is called in kern/init_main.c:proc0_post() */
|
||||
|
||||
/* Fill buf[] with random(9) output */
|
||||
for (i = 0; i < count; i+= (int)sizeof(uint32_t)) {
|
||||
randval = random();
|
||||
size = MIN(count - i, (int)sizeof(uint32_t));
|
||||
memcpy(&((char *)buf)[i], &randval, (size_t)size);
|
||||
}
|
||||
|
||||
return (count);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
memset(buf, 'A', size);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* This define can be used to optionally use OpenSSL's random number utility,
|
||||
* which is capable of bypassing the chromium sandbox which normally would
|
||||
* prevent opening files, including /dev/urandom.
|
||||
*/
|
||||
#elif defined(SCTP_USE_OPENSSL_RAND)
|
||||
#include <openssl/rand.h>
|
||||
|
||||
/* Requiring BoringSSL because it guarantees that RAND_bytes will succeed. */
|
||||
#ifndef OPENSSL_IS_BORINGSSL
|
||||
#error Only BoringSSL is supported with SCTP_USE_OPENSSL_RAND.
|
||||
#endif
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
RAND_bytes((uint8_t *)buf, size);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined(__Bitrig__)
|
||||
#include <stdlib.h>
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
arc4random_buf(buf, size);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
#include <stdlib.h>
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
unsigned int randval;
|
||||
size_t position, remaining;
|
||||
|
||||
position = 0;
|
||||
while (position < size) {
|
||||
if (rand_s(&randval) == 0) {
|
||||
remaining = MIN(size - position, sizeof(unsigned int));
|
||||
memcpy((char *)buf + position, &randval, remaining);
|
||||
position += sizeof(unsigned int);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#elif (defined(__ANDROID__) && (__ANDROID_API__ < 28)) || defined(__QNX__) || defined(__EMSCRIPTEN__)
|
||||
#include <fcntl.h>
|
||||
|
||||
static int fd = -1;
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
fd = open("/dev/urandom", O_RDONLY);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
size_t position;
|
||||
ssize_t n;
|
||||
|
||||
position = 0;
|
||||
while (position < size) {
|
||||
n = read(fd, (char *)buf + position, size - position);
|
||||
if (n > 0) {
|
||||
position += n;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
#elif defined(__ANDROID__) && (__ANDROID_API__ >= 28)
|
||||
#include <sys/random.h>
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
size_t position;
|
||||
ssize_t n;
|
||||
|
||||
position = 0;
|
||||
while (position < size) {
|
||||
n = getrandom((char *)buf + position, size - position, 0);
|
||||
if (n > 0) {
|
||||
position += n;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
void __msan_unpoison(void *, size_t);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __NR_getrandom
|
||||
#if !defined(GRND_NONBLOCK)
|
||||
#define GRND_NONBLOCK 1
|
||||
#endif
|
||||
static int getrandom_available = 0;
|
||||
#endif
|
||||
static int fd = -1;
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
#ifdef __NR_getrandom
|
||||
char dummy;
|
||||
ssize_t n = syscall(__NR_getrandom, &dummy, sizeof(dummy), GRND_NONBLOCK);
|
||||
if (n > 0 || errno == EINTR || errno == EAGAIN) {
|
||||
/* Either getrandom succeeded, was interrupted or is waiting for entropy;
|
||||
* all of which mean the syscall is available.
|
||||
*/
|
||||
getrandom_available = 1;
|
||||
} else {
|
||||
#ifdef INVARIANTS
|
||||
if (errno != ENOSYS) {
|
||||
panic("getrandom syscall returned unexpected error: %d", errno);
|
||||
}
|
||||
#endif
|
||||
/* If the syscall isn't available, fall back to /dev/urandom. */
|
||||
#endif
|
||||
fd = open("/dev/urandom", O_RDONLY);
|
||||
#ifdef __NR_getrandom
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
size_t position;
|
||||
ssize_t n;
|
||||
|
||||
position = 0;
|
||||
while (position < size) {
|
||||
#ifdef __NR_getrandom
|
||||
if (getrandom_available) {
|
||||
/* Using syscall directly because getrandom isn't present in glibc < 2.25.
|
||||
*/
|
||||
n = syscall(__NR_getrandom, (char *)buf + position, size - position, 0);
|
||||
if (n > 0) {
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
/* Need to do this because MSan doesn't realize that syscall has
|
||||
* initialized the output buffer.
|
||||
*/
|
||||
__msan_unpoison(buf + position, n);
|
||||
#endif
|
||||
#endif
|
||||
position += n;
|
||||
} else if (errno != EINTR && errno != EAGAIN) {
|
||||
#ifdef INVARIANTS
|
||||
panic("getrandom syscall returned unexpected error: %d", errno);
|
||||
#endif
|
||||
}
|
||||
} else
|
||||
#endif /* __NR_getrandom */
|
||||
{
|
||||
n = read(fd, (char *)buf + position, size - position);
|
||||
if (n > 0) {
|
||||
position += n;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
if (fd != -1) {
|
||||
close(fd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#elif defined(__Fuchsia__)
|
||||
#include <zircon/syscalls.h>
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
zx_cprng_draw(buf, size);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#elif defined(__native_client__)
|
||||
#include <nacl/nacl_random.h>
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
size_t position;
|
||||
size_t n;
|
||||
|
||||
position = 0;
|
||||
while (position < size) {
|
||||
if (nacl_secure_random((char *)buf + position, size - position, &n) == 0)
|
||||
position += n;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#else
|
||||
#error "Unknown platform. Please provide platform specific RNG."
|
||||
#endif
|
||||
|
|
|
@ -30,15 +30,24 @@
|
|||
|
||||
#ifndef _USER_ENVIRONMENT_H_
|
||||
#define _USER_ENVIRONMENT_H_
|
||||
|
||||
#if defined(_WIN32)
|
||||
// Needed for unified build so that rand_s is available to all unified
|
||||
// sources.
|
||||
#if !defined(_CRT_RAND_S) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
|
||||
#define _CRT_RAND_S
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* __Userspace__ */
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __Userspace_os_FreeBSD
|
||||
#ifdef __FreeBSD__
|
||||
#ifndef _SYS_MUTEX_H_
|
||||
#include <sys/mutex.h>
|
||||
#endif
|
||||
#endif
|
||||
#if defined (__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
#include "netinet/sctp_os_userspace.h"
|
||||
#endif
|
||||
|
||||
|
@ -54,7 +63,7 @@ extern int maxsockets;
|
|||
extern int hz;
|
||||
|
||||
|
||||
/* The following two ints define a range of available ephermal ports. */
|
||||
/* The following two ints define a range of available ephemeral ports. */
|
||||
extern int ipport_firstauto, ipport_lastauto;
|
||||
|
||||
/* nmbclusters is used in sctp_usrreq.c (e.g., sctp_init). In the FreeBSD kernel,
|
||||
|
@ -62,12 +71,14 @@ extern int ipport_firstauto, ipport_lastauto;
|
|||
*/
|
||||
extern int nmbclusters;
|
||||
|
||||
#if !defined (__Userspace_os_Windows)
|
||||
#define min(a,b) ((a)>(b)?(b):(a))
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
#define min(a,b) (((a)>(b))?(b):(a))
|
||||
#define max(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
extern int read_random(void *buf, int count);
|
||||
void init_random(void);
|
||||
void read_random(void *, size_t);
|
||||
void finish_random(void);
|
||||
|
||||
/* errno's may differ per OS. errno.h now included in sctp_os_userspace.h */
|
||||
/* Source: /usr/src/sys/sys/errno.h */
|
||||
|
@ -82,23 +93,34 @@ extern int read_random(void *buf, int count);
|
|||
/* Source ip_output.c. extern'd in ip_var.h */
|
||||
extern u_short ip_id;
|
||||
|
||||
#if defined(__Userspace_os_Linux)
|
||||
#if defined(__linux__)
|
||||
#define IPV6_VERSION 0x60
|
||||
#endif
|
||||
#if defined(INVARIANTS)
|
||||
#define panic(args...) \
|
||||
do { \
|
||||
SCTP_PRINTF(args);\
|
||||
exit(1); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#if defined(INVARIANTS)
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
static inline void __declspec(noreturn)
|
||||
#else
|
||||
static inline void __attribute__((__noreturn__))
|
||||
#endif
|
||||
terminate_non_graceful(void) {
|
||||
abort();
|
||||
}
|
||||
|
||||
#define panic(...) \
|
||||
do { \
|
||||
SCTP_PRINTF("%s(): ", __func__); \
|
||||
SCTP_PRINTF(__VA_ARGS__); \
|
||||
SCTP_PRINTF("\n"); \
|
||||
terminate_non_graceful(); \
|
||||
} while (0)
|
||||
|
||||
#define KASSERT(cond, args) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
printf args ;\
|
||||
exit(1); \
|
||||
panic args ; \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
|
@ -35,8 +35,6 @@
|
|||
|
||||
#include <user_route.h> /* was <net/route.h> */
|
||||
|
||||
#define in6pcb inpcb /* for KAME src sync over BSD*'s */
|
||||
#define in6p_sp inp_sp /* for KAME src sync over BSD*'s */
|
||||
struct inpcbpolicy;
|
||||
|
||||
/*
|
||||
|
@ -56,7 +54,7 @@ LIST_HEAD(inpcbporthead, inpcbport);
|
|||
* the following structure.
|
||||
*/
|
||||
struct in_addr_4in6 {
|
||||
u_int32_t ia46_pad32[3];
|
||||
uint32_t ia46_pad32[3];
|
||||
struct in_addr ia46_addr4;
|
||||
};
|
||||
|
||||
|
@ -65,8 +63,8 @@ struct in_addr_4in6 {
|
|||
* some extra padding to accomplish this.
|
||||
*/
|
||||
struct in_endpoints {
|
||||
u_int16_t ie_fport; /* foreign port */
|
||||
u_int16_t ie_lport; /* local port */
|
||||
uint16_t ie_fport; /* foreign port */
|
||||
uint16_t ie_lport; /* local port */
|
||||
/* protocol dependent part, local and foreign addr */
|
||||
union {
|
||||
/* foreign host table entry */
|
||||
|
@ -89,13 +87,13 @@ struct in_endpoints {
|
|||
* references.
|
||||
*/
|
||||
struct in_conninfo {
|
||||
u_int8_t inc_flags;
|
||||
u_int8_t inc_len;
|
||||
u_int16_t inc_pad; /* XXX alignment for in_endpoints */
|
||||
uint8_t inc_flags;
|
||||
uint8_t inc_len;
|
||||
uint16_t inc_pad; /* XXX alignment for in_endpoints */
|
||||
/* protocol dependent part */
|
||||
struct in_endpoints inc_ie;
|
||||
};
|
||||
#define inc_isipv6 inc_flags /* temp compatability */
|
||||
#define inc_isipv6 inc_flags /* temp compatibility */
|
||||
#define inc_fport inc_ie.ie_fport
|
||||
#define inc_lport inc_ie.ie_lport
|
||||
#define inc_faddr inc_ie.ie_faddr
|
||||
|
@ -112,7 +110,7 @@ struct inpcb {
|
|||
struct inpcbinfo *inp_pcbinfo; /* PCB list info */
|
||||
struct socket *inp_socket; /* back pointer to socket */
|
||||
|
||||
u_int32_t inp_flow;
|
||||
uint32_t inp_flow;
|
||||
int inp_flags; /* generic IP/datagram flags */
|
||||
|
||||
u_char inp_vflag; /* IP version flag (v4/v6) */
|
||||
|
@ -326,13 +324,11 @@ struct inpcbinfo {
|
|||
|
||||
#define INPLOOKUP_WILDCARD 1
|
||||
#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
|
||||
#define sotoin6pcb(so) sotoinpcb(so) /* for KAME src sync over BSD*'s */
|
||||
|
||||
#define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family
|
||||
|
||||
#define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af)
|
||||
|
||||
/* #ifdef _KERNEL */
|
||||
extern int ipport_reservedhigh;
|
||||
extern int ipport_reservedlow;
|
||||
extern int ipport_lowfirstauto;
|
||||
|
@ -373,6 +369,5 @@ void ipport_tick(void *xtp);
|
|||
*/
|
||||
void db_print_inpcb(struct inpcb *inp, const char *name, int indent);
|
||||
|
||||
/* #endif _KERNEL */
|
||||
|
||||
#endif /* !_NETINET_IN_PCB_H_ */
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
|
@ -60,16 +60,16 @@
|
|||
#ifndef _USER_IP6_VAR_H_
|
||||
#define _USER_IP6_VAR_H_
|
||||
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
struct ip6_hdr {
|
||||
union {
|
||||
struct ip6_hdrctl {
|
||||
u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */
|
||||
u_int16_t ip6_un1_plen; /* payload length */
|
||||
u_int8_t ip6_un1_nxt; /* next header */
|
||||
u_int8_t ip6_un1_hlim; /* hop limit */
|
||||
uint32_t ip6_un1_flow; /* 20 bits of flow-ID */
|
||||
uint16_t ip6_un1_plen; /* payload length */
|
||||
uint8_t ip6_un1_nxt; /* next header */
|
||||
uint8_t ip6_un1_hlim; /* hop limit */
|
||||
} ip6_un1;
|
||||
u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
|
||||
uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
|
||||
} ip6_ctlun;
|
||||
struct in6_addr ip6_src; /* source address */
|
||||
struct in6_addr ip6_dst; /* destination address */
|
||||
|
@ -84,18 +84,16 @@ struct ip6_hdr {
|
|||
#define IPV6_VERSION 0x60
|
||||
#endif
|
||||
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
#define s6_addr16 u.Word
|
||||
#endif
|
||||
#if !defined(__Userspace_os_Windows)
|
||||
#if !defined(__Userspace_os_Linux)
|
||||
#if !defined(_WIN32) && !defined(__linux__) && !defined(__EMSCRIPTEN__)
|
||||
#define s6_addr8 __u6_addr.__u6_addr8
|
||||
#define s6_addr16 __u6_addr.__u6_addr16
|
||||
#define s6_addr32 __u6_addr.__u6_addr32
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(__Userspace_os_FreeBSD) && !defined(__Userspace_os_OpenBSD) && !defined(__Userspace_os_DragonFly)
|
||||
#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
|
||||
struct route_in6 {
|
||||
struct rtentry *ro_rt;
|
||||
struct llentry *ro_lle;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
|
@ -40,8 +40,8 @@
|
|||
* Internal of an ICMP Router Advertisement
|
||||
*/
|
||||
struct icmp_ra_addr {
|
||||
u_int32_t ira_addr;
|
||||
u_int32_t ira_preference;
|
||||
uint32_t ira_addr;
|
||||
uint32_t ira_preference;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -53,19 +53,19 @@ struct icmphdr {
|
|||
u_short icmp_cksum; /* ones complement cksum of struct */
|
||||
};
|
||||
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
#pragma pack (push, 1)
|
||||
struct icmp6_hdr {
|
||||
u_int8_t icmp6_type;
|
||||
u_int8_t icmp6_code;
|
||||
u_int16_t icmp6_cksum;
|
||||
uint8_t icmp6_type;
|
||||
uint8_t icmp6_code;
|
||||
uint16_t icmp6_cksum;
|
||||
union {
|
||||
u_int32_t icmp6_un_data32[1];
|
||||
u_int16_t icmp6_un_data16[2];
|
||||
u_int8_t icmp6_un_data8[4];
|
||||
uint32_t icmp6_un_data32[1];
|
||||
uint16_t icmp6_un_data16[2];
|
||||
uint8_t icmp6_un_data8[4];
|
||||
} icmp6_dataun;
|
||||
};
|
||||
#pragma pack()
|
||||
#pragma pack(pop)
|
||||
|
||||
#define icmp6_data32 icmp6_dataun.icmp6_un_data32
|
||||
#define icmp6_mtu icmp6_data32[0]
|
||||
|
@ -98,7 +98,7 @@ struct icmp {
|
|||
struct ih_rtradv {
|
||||
u_char irt_num_addrs;
|
||||
u_char irt_wpa;
|
||||
u_int16_t irt_lifetime;
|
||||
uint16_t irt_lifetime;
|
||||
} ih_rtradv;
|
||||
} icmp_hun;
|
||||
#define icmp_pptr icmp_hun.ih_pptr
|
||||
|
@ -126,7 +126,7 @@ struct icmp {
|
|||
/* options and then 64 bits of data */
|
||||
} id_ip;
|
||||
struct icmp_ra_addr id_radv;
|
||||
u_int32_t id_mask;
|
||||
uint32_t id_mask;
|
||||
char id_data[1];
|
||||
} icmp_dun;
|
||||
#define icmp_otime icmp_dun.id_ts.its_otime
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
|
@ -37,11 +37,11 @@
|
|||
/*__Userspace__*/
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#if !defined (__Userspace_os_Windows)
|
||||
#if !defined(_WIN32)
|
||||
#include <strings.h>
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1600
|
||||
#if (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ >= 1400)
|
||||
#include <stdint.h>
|
||||
#elif defined(SCTP_STDINT_INCLUDE)
|
||||
#include SCTP_STDINT_INCLUDE
|
||||
|
@ -195,72 +195,9 @@ Start copy: Copied code for __Userspace__ */
|
|||
#define MALLOC(space, cast, size, type, flags) \
|
||||
((space) = (cast)malloc((u_long)(size))); \
|
||||
do { \
|
||||
if(flags & M_ZERO) { \
|
||||
if (flags & M_ZERO) { \
|
||||
memset(space,0,size); \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
|
||||
/* End copy: Copied code for __Userspace__ */
|
||||
|
||||
#if 0
|
||||
#ifdef _KERNEL
|
||||
#define MALLOC_DEFINE(type, shortdesc, longdesc) \
|
||||
struct malloc_type type[1] = { \
|
||||
{ NULL, 0, 0, 0, 0, 0, M_MAGIC, shortdesc, NULL, NULL, \
|
||||
NULL, 0, NULL, NULL, 0, 0 } \
|
||||
}; \
|
||||
SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_SECOND, malloc_init, \
|
||||
type); \
|
||||
SYSUNINIT(type##_uninit, SI_SUB_KMEM, SI_ORDER_ANY, \
|
||||
malloc_uninit, type)
|
||||
|
||||
|
||||
#define MALLOC_DECLARE(type) \
|
||||
extern struct malloc_type type[1]
|
||||
|
||||
MALLOC_DECLARE(M_CACHE);
|
||||
MALLOC_DECLARE(M_DEVBUF);
|
||||
MALLOC_DECLARE(M_TEMP);
|
||||
|
||||
MALLOC_DECLARE(M_IP6OPT); /* for INET6 */
|
||||
MALLOC_DECLARE(M_IP6NDP); /* for INET6 */
|
||||
|
||||
/*
|
||||
* Deprecated macro versions of not-quite-malloc() and free().
|
||||
*/
|
||||
#define MALLOC(space, cast, size, type, flags) \
|
||||
((space) = (cast)malloc((u_long)(size), (type), (flags)))
|
||||
#define FREE(addr, type) free((addr), (type))
|
||||
|
||||
/*
|
||||
* XXX this should be declared in <sys/uio.h>, but that tends to fail
|
||||
* because <sys/uio.h> is included in a header before the source file
|
||||
* has a chance to include <sys/malloc.h> to get MALLOC_DECLARE() defined.
|
||||
*/
|
||||
MALLOC_DECLARE(M_IOV);
|
||||
|
||||
extern struct mtx malloc_mtx;
|
||||
|
||||
/* XXX struct malloc_type is unused for contig*(). */
|
||||
void contigfree(void *addr, unsigned long size, struct malloc_type *type);
|
||||
void *contigmalloc(unsigned long size, struct malloc_type *type, int flags,
|
||||
vm_paddr_t low, vm_paddr_t high, unsigned long alignment,
|
||||
unsigned long boundary);
|
||||
void free(void *addr, struct malloc_type *type);
|
||||
void *malloc(unsigned long size, struct malloc_type *type, int flags);
|
||||
void malloc_init(void *);
|
||||
int malloc_last_fail(void);
|
||||
void malloc_type_allocated(struct malloc_type *type, unsigned long size);
|
||||
void malloc_type_freed(struct malloc_type *type, unsigned long size);
|
||||
void malloc_uninit(void *);
|
||||
void *realloc(void *addr, unsigned long size, struct malloc_type *type,
|
||||
int flags);
|
||||
void *reallocf(void *addr, unsigned long size, struct malloc_type *type,
|
||||
int flags);
|
||||
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif
|
||||
|
||||
#endif /* !_SYS_MALLOC_H_ */
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "user_atomic.h"
|
||||
#include "netinet/sctp_pcb.h"
|
||||
|
||||
struct mbstat mbstat;
|
||||
#define KIPC_MAX_LINKHDR 4 /* int: max length of link header (see sys/sysclt.h) */
|
||||
#define KIPC_MAX_PROTOHDR 5 /* int: max length of network header (see sys/sysclt.h)*/
|
||||
int max_linkhdr = KIPC_MAX_LINKHDR;
|
||||
|
@ -81,8 +80,6 @@ static void mb_dtor_clust(void *, void *);
|
|||
static int mbuf_constructor_dup(struct mbuf *m, int pkthdr, short type)
|
||||
{
|
||||
int flags = pkthdr;
|
||||
if (type == MT_NOINIT)
|
||||
return (0);
|
||||
|
||||
m->m_next = NULL;
|
||||
m->m_nextpkt = NULL;
|
||||
|
@ -121,7 +118,7 @@ m_get(int how, short type)
|
|||
mbuf_mb_args.type = type;
|
||||
#endif
|
||||
/* Mbuf master zone, zone_mbuf, has already been
|
||||
* created in mbuf_init() */
|
||||
* created in mbuf_initialize() */
|
||||
mret = SCTP_ZONE_GET(zone_mbuf, struct mbuf);
|
||||
#if defined(SCTP_SIMPLE_ALLOCATOR)
|
||||
mb_ctor_mbuf(mret, &mbuf_mb_args, 0);
|
||||
|
@ -204,59 +201,59 @@ m_free(struct mbuf *m)
|
|||
}
|
||||
|
||||
|
||||
static int clust_constructor_dup(caddr_t m_clust, struct mbuf* m)
|
||||
static void
|
||||
clust_constructor_dup(caddr_t m_clust, struct mbuf* m)
|
||||
{
|
||||
u_int *refcnt;
|
||||
int type, size;
|
||||
|
||||
if (m == NULL) {
|
||||
return;
|
||||
}
|
||||
/* Assigning cluster of MCLBYTES. TODO: Add jumbo frame functionality */
|
||||
type = EXT_CLUSTER;
|
||||
size = MCLBYTES;
|
||||
|
||||
refcnt = SCTP_ZONE_GET(zone_ext_refcnt, u_int);
|
||||
/*refcnt = (u_int *)umem_cache_alloc(zone_ext_refcnt, UMEM_DEFAULT);*/
|
||||
if (refcnt == NULL) {
|
||||
#if !defined(SCTP_SIMPLE_ALLOCATOR)
|
||||
if (refcnt == NULL) {
|
||||
umem_reap();
|
||||
#endif
|
||||
refcnt = SCTP_ZONE_GET(zone_ext_refcnt, u_int);
|
||||
/*refcnt = (u_int *)umem_cache_alloc(zone_ext_refcnt, UMEM_DEFAULT);*/
|
||||
}
|
||||
#endif
|
||||
*refcnt = 1;
|
||||
if (m != NULL) {
|
||||
m->m_ext.ext_buf = (caddr_t)m_clust;
|
||||
m->m_data = m->m_ext.ext_buf;
|
||||
m->m_flags |= M_EXT;
|
||||
m->m_ext.ext_free = NULL;
|
||||
m->m_ext.ext_args = NULL;
|
||||
m->m_ext.ext_size = size;
|
||||
m->m_ext.ext_type = type;
|
||||
m->m_ext.ref_cnt = refcnt;
|
||||
}
|
||||
|
||||
return (0);
|
||||
m->m_ext.ext_buf = (caddr_t)m_clust;
|
||||
m->m_data = m->m_ext.ext_buf;
|
||||
m->m_flags |= M_EXT;
|
||||
m->m_ext.ext_free = NULL;
|
||||
m->m_ext.ext_args = NULL;
|
||||
m->m_ext.ext_size = size;
|
||||
m->m_ext.ext_type = type;
|
||||
m->m_ext.ref_cnt = refcnt;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* __Userspace__ */
|
||||
void
|
||||
m_clget(struct mbuf *m, int how)
|
||||
{
|
||||
caddr_t mclust_ret;
|
||||
#if defined(SCTP_SIMPLE_ALLOCATOR)
|
||||
struct clust_args clust_mb_args;
|
||||
struct clust_args clust_mb_args_l;
|
||||
#endif
|
||||
if (m->m_flags & M_EXT) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "%s: %p mbuf already has cluster\n", __func__, (void *)m);
|
||||
}
|
||||
m->m_ext.ext_buf = (char *)NULL;
|
||||
#if defined(SCTP_SIMPLE_ALLOCATOR)
|
||||
clust_mb_args.parent_mbuf = m;
|
||||
clust_mb_args_l.parent_mbuf = m;
|
||||
#endif
|
||||
mclust_ret = SCTP_ZONE_GET(zone_clust, char);
|
||||
#if defined(SCTP_SIMPLE_ALLOCATOR)
|
||||
mb_ctor_clust(mclust_ret, &clust_mb_args, 0);
|
||||
mb_ctor_clust(mclust_ret, &clust_mb_args_l, 0);
|
||||
#endif
|
||||
/*mclust_ret = umem_cache_alloc(zone_clust, UMEM_DEFAULT);*/
|
||||
/*
|
||||
|
@ -272,9 +269,9 @@ m_clget(struct mbuf *m, int how)
|
|||
mclust_ret = SCTP_ZONE_GET(zone_clust, char);
|
||||
#endif
|
||||
/*mclust_ret = umem_cache_alloc(zone_clust, UMEM_DEFAULT);*/
|
||||
if (NULL == mclust_ret) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "Memory allocation failure in %s\n", __func__);
|
||||
}
|
||||
/* if (NULL == mclust_ret) { */
|
||||
SCTPDBG(SCTP_DEBUG_USR, "Memory allocation failure in %s\n", __func__);
|
||||
/* } */
|
||||
}
|
||||
|
||||
#if USING_MBUF_CONSTRUCTOR
|
||||
|
@ -286,6 +283,166 @@ m_clget(struct mbuf *m, int how)
|
|||
#endif
|
||||
}
|
||||
|
||||
struct mbuf *
|
||||
m_getm2(struct mbuf *m, int len, int how, short type, int flags, int allonebuf)
|
||||
{
|
||||
struct mbuf *mb, *nm = NULL, *mtail = NULL;
|
||||
int size, mbuf_threshold, space_needed = len;
|
||||
|
||||
KASSERT(len >= 0, ("%s: len is < 0", __func__));
|
||||
|
||||
/* Validate flags. */
|
||||
flags &= (M_PKTHDR | M_EOR);
|
||||
|
||||
/* Packet header mbuf must be first in chain. */
|
||||
if ((flags & M_PKTHDR) && m != NULL) {
|
||||
flags &= ~M_PKTHDR;
|
||||
}
|
||||
|
||||
if (allonebuf == 0)
|
||||
mbuf_threshold = SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count);
|
||||
else
|
||||
mbuf_threshold = 1;
|
||||
|
||||
/* Loop and append maximum sized mbufs to the chain tail. */
|
||||
while (len > 0) {
|
||||
if ((!allonebuf && len >= MCLBYTES) || (len > (int)(((mbuf_threshold - 1) * MLEN) + MHLEN))) {
|
||||
mb = m_gethdr(how, type);
|
||||
MCLGET(mb, how);
|
||||
size = MCLBYTES;
|
||||
/* SCTP_BUF_LEN(mb) = MCLBYTES; */
|
||||
} else if (flags & M_PKTHDR) {
|
||||
mb = m_gethdr(how, type);
|
||||
if (len < MHLEN) {
|
||||
size = len;
|
||||
} else {
|
||||
size = MHLEN;
|
||||
}
|
||||
} else {
|
||||
mb = m_get(how, type);
|
||||
if (len < MLEN) {
|
||||
size = len;
|
||||
} else {
|
||||
size = MLEN;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fail the whole operation if one mbuf can't be allocated. */
|
||||
if (mb == NULL) {
|
||||
if (nm != NULL)
|
||||
m_freem(nm);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (allonebuf != 0 && size < space_needed) {
|
||||
m_freem(mb);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Book keeping. */
|
||||
len -= size;
|
||||
if (mtail != NULL)
|
||||
mtail->m_next = mb;
|
||||
else
|
||||
nm = mb;
|
||||
mtail = mb;
|
||||
flags &= ~M_PKTHDR; /* Only valid on the first mbuf. */
|
||||
}
|
||||
if (flags & M_EOR) {
|
||||
mtail->m_flags |= M_EOR; /* Only valid on the last mbuf. */
|
||||
}
|
||||
|
||||
/* If mbuf was supplied, append new chain to the end of it. */
|
||||
if (m != NULL) {
|
||||
for (mtail = m; mtail->m_next != NULL; mtail = mtail->m_next);
|
||||
mtail->m_next = nm;
|
||||
mtail->m_flags &= ~M_EOR;
|
||||
} else {
|
||||
m = nm;
|
||||
}
|
||||
|
||||
return (m);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy the contents of uio into a properly sized mbuf chain.
|
||||
*/
|
||||
struct mbuf *
|
||||
m_uiotombuf(struct uio *uio, int how, int len, int align, int flags)
|
||||
{
|
||||
struct mbuf *m, *mb;
|
||||
int error, length;
|
||||
ssize_t total;
|
||||
int progress = 0;
|
||||
|
||||
/*
|
||||
* len can be zero or an arbitrary large value bound by
|
||||
* the total data supplied by the uio.
|
||||
*/
|
||||
if (len > 0)
|
||||
total = min(uio->uio_resid, len);
|
||||
else
|
||||
total = uio->uio_resid;
|
||||
/*
|
||||
* The smallest unit returned by m_getm2() is a single mbuf
|
||||
* with pkthdr. We can't align past it.
|
||||
*/
|
||||
if (align >= MHLEN)
|
||||
return (NULL);
|
||||
/*
|
||||
* Give us the full allocation or nothing.
|
||||
* If len is zero return the smallest empty mbuf.
|
||||
*/
|
||||
m = m_getm2(NULL, (int)max(total + align, 1), how, MT_DATA, flags, 0);
|
||||
if (m == NULL)
|
||||
return (NULL);
|
||||
m->m_data += align;
|
||||
|
||||
/* Fill all mbufs with uio data and update header information. */
|
||||
for (mb = m; mb != NULL; mb = mb->m_next) {
|
||||
length = (int)min(M_TRAILINGSPACE(mb), total - progress);
|
||||
error = uiomove(mtod(mb, void *), length, uio);
|
||||
if (error) {
|
||||
m_freem(m);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
mb->m_len = length;
|
||||
progress += length;
|
||||
if (flags & M_PKTHDR)
|
||||
m->m_pkthdr.len += length;
|
||||
}
|
||||
KASSERT(progress == total, ("%s: progress != total", __func__));
|
||||
|
||||
return (m);
|
||||
}
|
||||
|
||||
u_int
|
||||
m_length(struct mbuf *m0, struct mbuf **last)
|
||||
{
|
||||
struct mbuf *m;
|
||||
u_int len;
|
||||
|
||||
len = 0;
|
||||
for (m = m0; m != NULL; m = m->m_next) {
|
||||
len += m->m_len;
|
||||
if (m->m_next == NULL)
|
||||
break;
|
||||
}
|
||||
if (last != NULL)
|
||||
*last = m;
|
||||
return (len);
|
||||
}
|
||||
|
||||
struct mbuf *
|
||||
m_last(struct mbuf *m)
|
||||
{
|
||||
while (m->m_next) {
|
||||
m = m->m_next;
|
||||
}
|
||||
return (m);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unlink a tag from the list of tags associated with an mbuf.
|
||||
*/
|
||||
|
@ -313,7 +470,7 @@ m_tag_free(struct m_tag *t)
|
|||
* XXX probably should be called m_tag_init, but that was already taken.
|
||||
*/
|
||||
static __inline void
|
||||
m_tag_setup(struct m_tag *t, u_int32_t cookie, int type, int len)
|
||||
m_tag_setup(struct m_tag *t, uint32_t cookie, int type, int len)
|
||||
{
|
||||
|
||||
t->m_tag_id = type;
|
||||
|
@ -327,12 +484,8 @@ m_tag_setup(struct m_tag *t, u_int32_t cookie, int type, int len)
|
|||
|
||||
/************ End functions to substitute umem_cache_alloc and umem_cache_free **************/
|
||||
|
||||
/* __Userspace__
|
||||
* TODO: mbuf_init must be called in the initialization routines
|
||||
* of userspace stack.
|
||||
*/
|
||||
void
|
||||
mbuf_init(void *dummy)
|
||||
mbuf_initialize(void *dummy)
|
||||
{
|
||||
|
||||
/*
|
||||
|
@ -351,7 +504,7 @@ mbuf_init(void *dummy)
|
|||
#else
|
||||
zone_mbuf = umem_cache_create(MBUF_MEM_NAME, MSIZE, 0,
|
||||
mb_ctor_mbuf, mb_dtor_mbuf, NULL,
|
||||
NUULL,
|
||||
NULL,
|
||||
NULL, 0);
|
||||
#endif
|
||||
/*zone_ext_refcnt = umem_cache_create(MBUF_EXTREFCNT_MEM_NAME, sizeof(u_int), 0,
|
||||
|
@ -380,26 +533,6 @@ mbuf_init(void *dummy)
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* [Re]set counters and local statistics knobs.
|
||||
*
|
||||
*/
|
||||
|
||||
mbstat.m_mbufs = 0;
|
||||
mbstat.m_mclusts = 0;
|
||||
mbstat.m_drain = 0;
|
||||
mbstat.m_msize = MSIZE;
|
||||
mbstat.m_mclbytes = MCLBYTES;
|
||||
mbstat.m_minclsize = MINCLSIZE;
|
||||
mbstat.m_mlen = MLEN;
|
||||
mbstat.m_mhlen = MHLEN;
|
||||
mbstat.m_numtypes = MT_NTYPES;
|
||||
|
||||
mbstat.m_mcfail = mbstat.m_mpfail = 0;
|
||||
mbstat.sf_iocnt = 0;
|
||||
mbstat.sf_allocwait = mbstat.sf_allocfail = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -442,13 +575,6 @@ mb_ctor_mbuf(void *mem, void *arg, int flgs)
|
|||
flags = args->flags;
|
||||
type = args->type;
|
||||
|
||||
/*
|
||||
* The mbuf is initialized later.
|
||||
*
|
||||
*/
|
||||
if (type == MT_NOINIT)
|
||||
return (0);
|
||||
|
||||
m->m_next = NULL;
|
||||
m->m_nextpkt = NULL;
|
||||
m->m_len = 0;
|
||||
|
@ -732,11 +858,10 @@ m_pullup(struct mbuf *n, int len)
|
|||
if (n->m_flags & M_PKTHDR)
|
||||
M_MOVE_PKTHDR(m, n);
|
||||
}
|
||||
space = &m->m_dat[MLEN] - (m->m_data + m->m_len);
|
||||
space = (int)(&m->m_dat[MLEN] - (m->m_data + m->m_len));
|
||||
do {
|
||||
count = min(min(max(len, max_protohdr), space), n->m_len);
|
||||
bcopy(mtod(n, caddr_t), mtod(m, caddr_t) + m->m_len,
|
||||
(u_int)count);
|
||||
memcpy(mtod(m, caddr_t) + m->m_len,mtod(n, caddr_t), (u_int)count);
|
||||
len -= count;
|
||||
m->m_len += count;
|
||||
n->m_len -= count;
|
||||
|
@ -754,7 +879,6 @@ m_pullup(struct mbuf *n, int len)
|
|||
return (m);
|
||||
bad:
|
||||
m_freem(n);
|
||||
mbstat.m_mpfail++; /* XXX: No consistency. */
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -890,19 +1014,17 @@ m_pulldown(struct mbuf *m, int off, int len, int *offp)
|
|||
* easy cases first.
|
||||
* we need to use m_copydata() to get data from <n->m_next, 0>.
|
||||
*/
|
||||
if ((off == 0 || offp) && M_TRAILINGSPACE(n) >= tlen
|
||||
&& writable) {
|
||||
if ((off == 0 || offp) && (M_TRAILINGSPACE(n) >= tlen) && writable) {
|
||||
m_copydata(n->m_next, 0, tlen, mtod(n, caddr_t) + n->m_len);
|
||||
n->m_len += tlen;
|
||||
m_adj(n->m_next, tlen);
|
||||
goto ok;
|
||||
}
|
||||
|
||||
if ((off == 0 || offp) && M_LEADINGSPACE(n->m_next) >= hlen
|
||||
&& writable) {
|
||||
if ((off == 0 || offp) && (M_LEADINGSPACE(n->m_next) >= hlen) && writable) {
|
||||
n->m_next->m_data -= hlen;
|
||||
n->m_next->m_len += hlen;
|
||||
bcopy(mtod(n, caddr_t) + off, mtod(n->m_next, caddr_t), hlen);
|
||||
memcpy( mtod(n->m_next, caddr_t), mtod(n, caddr_t) + off,hlen);
|
||||
n->m_len -= hlen;
|
||||
n = n->m_next;
|
||||
off = 0;
|
||||
|
@ -924,7 +1046,7 @@ m_pulldown(struct mbuf *m, int off, int len, int *offp)
|
|||
}
|
||||
/* get hlen from <n, off> into <o, 0> */
|
||||
o->m_len = hlen;
|
||||
bcopy(mtod(n, caddr_t) + off, mtod(o, caddr_t), hlen);
|
||||
memcpy(mtod(o, caddr_t), mtod(n, caddr_t) + off, hlen);
|
||||
n->m_len -= hlen;
|
||||
/* get tlen from <n->m_next, 0> into <o, hlen> */
|
||||
m_copydata(n->m_next, 0, tlen, mtod(o, caddr_t) + o->m_len);
|
||||
|
@ -992,7 +1114,13 @@ m_copym(struct mbuf *m, int off0, int len, int wait)
|
|||
|
||||
KASSERT(off >= 0, ("m_copym, negative off %d", off));
|
||||
KASSERT(len >= 0, ("m_copym, negative len %d", len));
|
||||
KASSERT(m != NULL, ("m_copym, m is NULL"));
|
||||
|
||||
#if !defined(INVARIANTS)
|
||||
if (m == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
#endif
|
||||
if (off == 0 && m->m_flags & M_PKTHDR)
|
||||
copyhdr = 1;
|
||||
while (off > 0) {
|
||||
|
@ -1030,21 +1158,17 @@ m_copym(struct mbuf *m, int off0, int len, int wait)
|
|||
n->m_data = m->m_data + off;
|
||||
mb_dupcl(n, m);
|
||||
} else
|
||||
bcopy(mtod(m, caddr_t)+off, mtod(n, caddr_t),
|
||||
(u_int)n->m_len);
|
||||
memcpy(mtod(n, caddr_t), mtod(m, caddr_t) + off, (u_int)n->m_len);
|
||||
if (len != M_COPYALL)
|
||||
len -= n->m_len;
|
||||
off = 0;
|
||||
m = m->m_next;
|
||||
np = &n->m_next;
|
||||
}
|
||||
if (top == NULL)
|
||||
mbstat.m_mcfail++; /* XXX: No consistency. */
|
||||
|
||||
return (top);
|
||||
nospace:
|
||||
m_freem(top);
|
||||
mbstat.m_mcfail++; /* XXX: No consistency. */
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
@ -1080,6 +1204,8 @@ int
|
|||
m_dup_pkthdr(struct mbuf *to, struct mbuf *from, int how)
|
||||
{
|
||||
|
||||
KASSERT(to, ("m_dup_pkthdr: to is NULL"));
|
||||
KASSERT(from, ("m_dup_pkthdr: from is NULL"));
|
||||
to->m_flags = (from->m_flags & M_COPYFLAGS) | (to->m_flags & M_EXT);
|
||||
if ((to->m_flags & M_EXT) == 0)
|
||||
to->m_data = to->m_pktdat;
|
||||
|
@ -1098,13 +1224,13 @@ m_tag_copy(struct m_tag *t, int how)
|
|||
p = m_tag_alloc(t->m_tag_cookie, t->m_tag_id, t->m_tag_len, how);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
bcopy(t + 1, p + 1, t->m_tag_len); /* Copy the data */
|
||||
memcpy(p + 1, t + 1, t->m_tag_len); /* Copy the data */
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Get a packet tag structure along with specified data following. */
|
||||
struct m_tag *
|
||||
m_tag_alloc(u_int32_t cookie, int type, int len, int wait)
|
||||
m_tag_alloc(uint32_t cookie, int type, int len, int wait)
|
||||
{
|
||||
struct m_tag *t;
|
||||
|
||||
|
@ -1146,7 +1272,7 @@ m_copyback(struct mbuf *m0, int off, int len, caddr_t cp)
|
|||
n = m_get(M_NOWAIT, m->m_type);
|
||||
if (n == NULL)
|
||||
goto out;
|
||||
bzero(mtod(n, caddr_t), MLEN);
|
||||
memset(mtod(n, caddr_t), 0, MLEN);
|
||||
n->m_len = min(MLEN, len + off);
|
||||
m->m_next = n;
|
||||
}
|
||||
|
@ -1154,7 +1280,7 @@ m_copyback(struct mbuf *m0, int off, int len, caddr_t cp)
|
|||
}
|
||||
while (len > 0) {
|
||||
mlen = min (m->m_len - off, len);
|
||||
bcopy(cp, off + mtod(m, caddr_t), (u_int)mlen);
|
||||
memcpy(off + mtod(m, caddr_t), cp, (u_int)mlen);
|
||||
cp += mlen;
|
||||
len -= mlen;
|
||||
mlen += off;
|
||||
|
@ -1175,6 +1301,38 @@ out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen))
|
|||
m->m_pkthdr.len = totlen;
|
||||
}
|
||||
|
||||
/*
|
||||
* Apply function f to the data in an mbuf chain starting "off" bytes from
|
||||
* the beginning, continuing for "len" bytes.
|
||||
*/
|
||||
int
|
||||
m_apply(struct mbuf *m, int off, int len,
|
||||
int (*f)(void *, void *, u_int), void *arg)
|
||||
{
|
||||
u_int count;
|
||||
int rval;
|
||||
|
||||
KASSERT(off >= 0, ("m_apply, negative off %d", off));
|
||||
KASSERT(len >= 0, ("m_apply, negative len %d", len));
|
||||
while (off > 0) {
|
||||
KASSERT(m != NULL, ("m_apply, offset > size of mbuf chain"));
|
||||
if (off < m->m_len)
|
||||
break;
|
||||
off -= m->m_len;
|
||||
m = m->m_next;
|
||||
}
|
||||
while (len > 0) {
|
||||
KASSERT(m != NULL, ("m_apply, offset > size of mbuf chain"));
|
||||
count = min(m->m_len - off, len);
|
||||
rval = (*f)(arg, mtod(m, caddr_t) + off, count);
|
||||
if (rval)
|
||||
return (rval);
|
||||
len -= count;
|
||||
off = 0;
|
||||
m = m->m_next;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lesser-used path for M_PREPEND:
|
||||
|
@ -1198,7 +1356,7 @@ m_prepend(struct mbuf *m, int len, int how)
|
|||
M_MOVE_PKTHDR(mn, m);
|
||||
mn->m_next = m;
|
||||
m = mn;
|
||||
if(m->m_flags & M_PKTHDR) {
|
||||
if (m->m_flags & M_PKTHDR) {
|
||||
if (len < MHLEN)
|
||||
MH_ALIGN(m, len);
|
||||
} else {
|
||||
|
@ -1230,7 +1388,7 @@ m_copydata(const struct mbuf *m, int off, int len, caddr_t cp)
|
|||
while (len > 0) {
|
||||
KASSERT(m != NULL, ("m_copydata, length > size of mbuf chain"));
|
||||
count = min(m->m_len - off, len);
|
||||
bcopy(mtod(m, caddr_t) + off, cp, count);
|
||||
memcpy(cp, mtod(m, caddr_t) + off, count);
|
||||
len -= count;
|
||||
cp += count;
|
||||
off = 0;
|
||||
|
@ -1257,7 +1415,7 @@ m_cat(struct mbuf *m, struct mbuf *n)
|
|||
return;
|
||||
}
|
||||
/* splat the data from one into the other */
|
||||
bcopy(mtod(n, caddr_t), mtod(m, caddr_t) + m->m_len, (u_int)n->m_len);
|
||||
memcpy(mtod(m, caddr_t) + m->m_len, mtod(n, caddr_t), (u_int)n->m_len);
|
||||
m->m_len += n->m_len;
|
||||
n = m_free(n);
|
||||
}
|
||||
|
@ -1400,7 +1558,7 @@ extpacket:
|
|||
n->m_data = m->m_data + len;
|
||||
mb_dupcl(n, m);
|
||||
} else {
|
||||
bcopy(mtod(m, caddr_t) + len, mtod(n, caddr_t), remain);
|
||||
memcpy(mtod(n, caddr_t), mtod(m, caddr_t) + len, remain);
|
||||
}
|
||||
n->m_len = remain;
|
||||
m->m_len = len;
|
||||
|
@ -1421,7 +1579,7 @@ pack_send_buffer(caddr_t buffer, struct mbuf* mb){
|
|||
|
||||
do {
|
||||
count_to_copy = mb->m_len;
|
||||
bcopy(mtod(mb, caddr_t), buffer+offset, count_to_copy);
|
||||
memcpy(buffer+offset, mtod(mb, caddr_t), count_to_copy);
|
||||
offset += count_to_copy;
|
||||
total_count_copied += count_to_copy;
|
||||
mb = mb->m_next;
|
||||
|
|
|
@ -55,10 +55,13 @@ struct mbuf * m_gethdr(int how, short type);
|
|||
struct mbuf * m_get(int how, short type);
|
||||
struct mbuf * m_free(struct mbuf *m);
|
||||
void m_clget(struct mbuf *m, int how);
|
||||
|
||||
struct mbuf * m_getm2(struct mbuf *m, int len, int how, short type, int flags, int allonebuf);
|
||||
struct mbuf *m_uiotombuf(struct uio *uio, int how, int len, int align, int flags);
|
||||
u_int m_length(struct mbuf *m0, struct mbuf **last);
|
||||
struct mbuf *m_last(struct mbuf *m);
|
||||
|
||||
/* mbuf initialization function */
|
||||
void mbuf_init(void *);
|
||||
void mbuf_initialize(void *);
|
||||
|
||||
#define M_MOVE_PKTHDR(to, from) m_move_pkthdr((to), (from))
|
||||
#define MGET(m, how, type) ((m) = m_get((how), (type)))
|
||||
|
@ -107,9 +110,10 @@ void m_cat(struct mbuf *m, struct mbuf *n);
|
|||
void m_adj(struct mbuf *, int);
|
||||
void mb_free_ext(struct mbuf *);
|
||||
void m_freem(struct mbuf *);
|
||||
struct m_tag *m_tag_alloc(u_int32_t, int, int, int);
|
||||
struct m_tag *m_tag_alloc(uint32_t, int, int, int);
|
||||
struct mbuf *m_copym(struct mbuf *, int, int, int);
|
||||
void m_copyback(struct mbuf *, int, int, caddr_t);
|
||||
int m_apply(struct mbuf *, int, int, int (*)(void *, void *, u_int), void *arg);
|
||||
struct mbuf *m_pullup(struct mbuf *, int);
|
||||
struct mbuf *m_pulldown(struct mbuf *, int off, int len, int *offp);
|
||||
int m_dup_pkthdr(struct mbuf *, struct mbuf *, int);
|
||||
|
@ -122,38 +126,6 @@ void m_copydata(const struct mbuf *, int, int, caddr_t);
|
|||
#define MBUF_CLUSTER_MEM_NAME "mbuf_cluster"
|
||||
#define MBUF_EXTREFCNT_MEM_NAME "mbuf_ext_refcnt"
|
||||
|
||||
#define MT_NOINIT 255 /* Not a type but a flag to allocate
|
||||
a non-initialized mbuf */
|
||||
|
||||
/*
|
||||
* General mbuf allocator statistics structure.
|
||||
* __Userspace__ mbstat may be useful for gathering statistics.
|
||||
* In the kernel many of these statistics are no longer used as
|
||||
* they track allocator statistics through kernel UMA's built in statistics mechanism.
|
||||
*/
|
||||
struct mbstat {
|
||||
u_long m_mbufs; /* XXX */
|
||||
u_long m_mclusts; /* XXX */
|
||||
|
||||
u_long m_drain; /* times drained protocols for space */
|
||||
u_long m_mcfail; /* XXX: times m_copym failed */
|
||||
u_long m_mpfail; /* XXX: times m_pullup failed */
|
||||
u_long m_msize; /* length of an mbuf */
|
||||
u_long m_mclbytes; /* length of an mbuf cluster */
|
||||
u_long m_minclsize; /* min length of data to allocate a cluster */
|
||||
u_long m_mlen; /* length of data in an mbuf */
|
||||
u_long m_mhlen; /* length of data in a header mbuf */
|
||||
|
||||
/* Number of mbtypes (gives # elems in mbtypes[] array: */
|
||||
short m_numtypes;
|
||||
|
||||
/* XXX: Sendfile stats should eventually move to their own struct */
|
||||
u_long sf_iocnt; /* times sendfile had to do disk I/O */
|
||||
u_long sf_allocfail; /* times sfbuf allocation failed */
|
||||
u_long sf_allocwait; /* times sfbuf allocation had to wait */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Mbufs are of a single size, MSIZE (sys/param.h), which includes overhead.
|
||||
* An mbuf may add a single "mbuf cluster" of size MCLBYTES (also in
|
||||
|
@ -187,9 +159,9 @@ struct m_hdr {
|
|||
*/
|
||||
struct m_tag {
|
||||
SLIST_ENTRY(m_tag) m_tag_link; /* List of packet tags */
|
||||
u_int16_t m_tag_id; /* Tag ID */
|
||||
u_int16_t m_tag_len; /* Length of data */
|
||||
u_int32_t m_tag_cookie; /* ABI/Module ID */
|
||||
uint16_t m_tag_id; /* Tag ID */
|
||||
uint16_t m_tag_len; /* Length of data */
|
||||
uint32_t m_tag_cookie; /* ABI/Module ID */
|
||||
void (*m_tag_free)(struct m_tag *);
|
||||
};
|
||||
|
||||
|
@ -204,8 +176,8 @@ struct pkthdr {
|
|||
/* variables for hardware checksum */
|
||||
int csum_flags; /* flags regarding checksum */
|
||||
int csum_data; /* data field used by csum routines */
|
||||
u_int16_t tso_segsz; /* TSO segment size */
|
||||
u_int16_t ether_vtag; /* Ethernet 802.1p+q vlan tag */
|
||||
uint16_t tso_segsz; /* TSO segment size */
|
||||
uint16_t ether_vtag; /* Ethernet 802.1p+q vlan tag */
|
||||
SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */
|
||||
};
|
||||
|
||||
|
@ -267,7 +239,6 @@ struct mbuf {
|
|||
#define M_PROTO3 0x0040 /* protocol-specific */
|
||||
#define M_PROTO4 0x0080 /* protocol-specific */
|
||||
#define M_PROTO5 0x0100 /* protocol-specific */
|
||||
#define M_SKIP_FIREWALL 0x4000 /* skip firewall processing */
|
||||
#define M_FREELIST 0x8000 /* mbuf is on the free list */
|
||||
|
||||
|
||||
|
@ -275,7 +246,7 @@ struct mbuf {
|
|||
* Flags copied when copying m_pkthdr.
|
||||
*/
|
||||
#define M_COPYFLAGS (M_PKTHDR|M_EOR|M_RDONLY|M_PROTO1|M_PROTO1|M_PROTO2|\
|
||||
M_PROTO3|M_PROTO4|M_PROTO5|M_SKIP_FIREWALL|\
|
||||
M_PROTO3|M_PROTO4|M_PROTO5|\
|
||||
M_BCAST|M_MCAST|M_FRAG|M_FIRSTFRAG|M_LASTFRAG|\
|
||||
M_VLANTAG|M_PROMISC)
|
||||
|
||||
|
@ -320,9 +291,6 @@ struct mbuf {
|
|||
#define MT_OOBDATA 15 /* expedited data */
|
||||
#define MT_NTYPES 16 /* number of mbuf types for mbtypes[] */
|
||||
|
||||
#define MT_NOINIT 255 /* Not a type but a flag to allocate
|
||||
a non-initialized mbuf */
|
||||
|
||||
/*
|
||||
* __Userspace__ flags like M_NOWAIT are defined in malloc.h
|
||||
* Flags like these are used in functions like uma_zalloc()
|
||||
|
@ -350,9 +318,6 @@ void m_tag_free_default(struct m_tag *);
|
|||
extern int max_linkhdr; /* Largest link-level header */
|
||||
extern int max_protohdr; /* Size of largest protocol layer header. See user_mbuf.c */
|
||||
|
||||
extern struct mbstat mbstat; /* General mbuf stats/infos */
|
||||
|
||||
|
||||
/*
|
||||
* Evaluate TRUE if it's safe to write to the mbuf m's data region (this can
|
||||
* be both the local data payload, or an external buffer area, depending on
|
||||
|
@ -362,6 +327,10 @@ extern struct mbstat mbstat; /* General mbuf stats/infos */
|
|||
(!(((m)->m_flags & M_EXT)) || \
|
||||
(*((m)->m_ext.ref_cnt) == 1)) ) \
|
||||
|
||||
/* Check if the supplied mbuf has a packet header, or else panic. */
|
||||
#define M_ASSERTPKTHDR(m) \
|
||||
KASSERT((m) != NULL && (m)->m_flags & M_PKTHDR, \
|
||||
("%s: no mbuf packet header!", __func__))
|
||||
|
||||
/*
|
||||
* Compute the amount of space available before the current start of data in
|
||||
|
@ -371,9 +340,9 @@ extern struct mbstat mbstat; /* General mbuf stats/infos */
|
|||
* of checking writability of the mbuf data area rests solely with the caller.
|
||||
*/
|
||||
#define M_LEADINGSPACE(m) \
|
||||
((m)->m_flags & M_EXT ? \
|
||||
(((m)->m_flags & M_EXT) ? \
|
||||
(M_WRITABLE(m) ? (m)->m_data - (m)->m_ext.ext_buf : 0): \
|
||||
(m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \
|
||||
((m)->m_flags & M_PKTHDR)? (m)->m_data - (m)->m_pktdat : \
|
||||
(m)->m_data - (m)->m_dat)
|
||||
|
||||
/*
|
||||
|
@ -383,7 +352,7 @@ extern struct mbstat mbstat; /* General mbuf stats/infos */
|
|||
* of checking writability of the mbuf data area rests solely with the caller.
|
||||
*/
|
||||
#define M_TRAILINGSPACE(m) \
|
||||
((m)->m_flags & M_EXT ? \
|
||||
(((m)->m_flags & M_EXT) ? \
|
||||
(M_WRITABLE(m) ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size \
|
||||
- ((m)->m_data + (m)->m_len) : 0) : \
|
||||
&(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len))
|
||||
|
@ -435,4 +404,9 @@ extern struct mbstat mbstat; /* General mbuf stats/infos */
|
|||
(m)->m_data += (MHLEN - (len)) & ~(sizeof(long) - 1); \
|
||||
} while (0)
|
||||
|
||||
#define M_SIZE(m) \
|
||||
(((m)->m_flags & M_EXT) ? (m)->m_ext.ext_size : \
|
||||
((m)->m_flags & M_PKTHDR) ? MHLEN : \
|
||||
MLEN)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
|
@ -144,8 +144,8 @@ struct name { \
|
|||
#define SLIST_HEAD_INITIALIZER(head) \
|
||||
{ NULL }
|
||||
|
||||
#if defined (__Userspace_os_Windows)
|
||||
#if defined (SLIST_ENTRY)
|
||||
#if defined(_WIN32)
|
||||
#if defined(SLIST_ENTRY)
|
||||
#undef SLIST_ENTRY
|
||||
#endif
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -10,7 +10,7 @@
|
|||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -10,7 +10,7 @@
|
|||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
|
@ -33,7 +33,7 @@
|
|||
#ifndef _USER_SOCKETVAR_H_
|
||||
#define _USER_SOCKETVAR_H_
|
||||
|
||||
#if defined(__Userspace_os_Darwin)
|
||||
#if defined(__APPLE__)
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
@ -42,7 +42,7 @@
|
|||
/* #include <sys/_lock.h> was 0 byte file */
|
||||
/* #include <sys/_mutex.h> was 0 byte file */
|
||||
/* #include <sys/_sx.h> */ /*__Userspace__ alternative?*/
|
||||
#if !defined(__Userspace_os_DragonFly) && !defined(__Userspace_os_FreeBSD) && !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_Windows) && !defined(__Userspace_os_NaCl)
|
||||
#if !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(_WIN32) && !defined(__native_client__)
|
||||
#include <sys/uio.h>
|
||||
#endif
|
||||
#define SOCK_MAXADDRLEN 255
|
||||
|
@ -54,16 +54,16 @@
|
|||
#define SS_CANTRCVMORE 0x020
|
||||
#define SS_CANTSENDMORE 0x010
|
||||
|
||||
#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_OpenBSD) || defined (__Userspace_os_Windows) || defined(__Userspace_os_NaCl)
|
||||
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(_WIN32) || defined(__native_client__)
|
||||
#define UIO_MAXIOV 1024
|
||||
#define ERESTART (-1)
|
||||
#endif
|
||||
|
||||
#if !defined(__Userspace_os_Darwin) && !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_OpenBSD)
|
||||
#if !defined(__APPLE__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
enum uio_rw { UIO_READ, UIO_WRITE };
|
||||
#endif
|
||||
|
||||
#if !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_OpenBSD)
|
||||
#if !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
/* Segment flag values. */
|
||||
enum uio_seg {
|
||||
UIO_USERSPACE, /* from user data space */
|
||||
|
@ -72,7 +72,7 @@ enum uio_seg {
|
|||
#endif
|
||||
|
||||
struct proc {
|
||||
int stub; /* struct proc is a dummy for __Userspace__ */
|
||||
int stub; /* struct proc is a dummy for __Userspace__ */
|
||||
};
|
||||
|
||||
MALLOC_DECLARE(M_ACCF);
|
||||
|
@ -83,12 +83,12 @@ MALLOC_DECLARE(M_SONAME);
|
|||
* Removing struct thread *uio_td; owner field
|
||||
*/
|
||||
struct uio {
|
||||
struct iovec *uio_iov; /* scatter/gather list */
|
||||
int uio_iovcnt; /* length of scatter/gather list */
|
||||
off_t uio_offset; /* offset in target object */
|
||||
int uio_resid; /* remaining bytes to process */
|
||||
enum uio_seg uio_segflg; /* address space */
|
||||
enum uio_rw uio_rw; /* operation */
|
||||
struct iovec *uio_iov; /* scatter/gather list */
|
||||
int uio_iovcnt; /* length of scatter/gather list */
|
||||
off_t uio_offset; /* offset in target object */
|
||||
ssize_t uio_resid; /* remaining bytes to process */
|
||||
enum uio_seg uio_segflg; /* address space */
|
||||
enum uio_rw uio_rw; /* operation */
|
||||
};
|
||||
|
||||
|
||||
|
@ -100,9 +100,11 @@ struct uio {
|
|||
* handle on protocol and pointer to protocol
|
||||
* private data and error information.
|
||||
*/
|
||||
#if defined (__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
#define AF_ROUTE 17
|
||||
#if !defined(__MINGW32__)
|
||||
typedef __int32 pid_t;
|
||||
#endif
|
||||
typedef unsigned __int32 uid_t;
|
||||
enum sigType {
|
||||
SIGNAL = 0,
|
||||
|
@ -235,7 +237,7 @@ struct socket {
|
|||
* avoid defining a lock order between listen and accept sockets
|
||||
* until such time as it proves to be a good idea.
|
||||
*/
|
||||
#if defined(__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
extern userland_mutex_t accept_mtx;
|
||||
extern userland_cond_t accept_cond;
|
||||
#define ACCEPT_LOCK_ASSERT()
|
||||
|
@ -248,14 +250,21 @@ extern userland_cond_t accept_cond;
|
|||
#define ACCEPT_UNLOCK_ASSERT()
|
||||
#else
|
||||
extern userland_mutex_t accept_mtx;
|
||||
|
||||
extern userland_cond_t accept_cond;
|
||||
#define ACCEPT_LOCK_ASSERT() KASSERT(pthread_mutex_trylock(&accept_mtx) == EBUSY, ("%s: accept_mtx not locked", __func__))
|
||||
#define ACCEPT_LOCK() (void)pthread_mutex_lock(&accept_mtx)
|
||||
#define ACCEPT_UNLOCK() (void)pthread_mutex_unlock(&accept_mtx)
|
||||
#define ACCEPT_UNLOCK_ASSERT() do{ \
|
||||
KASSERT(pthread_mutex_trylock(&accept_mtx) == 0, ("%s: accept_mtx locked", __func__)); \
|
||||
(void)pthread_mutex_unlock(&accept_mtx); \
|
||||
} while (0)
|
||||
#ifdef INVARIANTS
|
||||
#define ACCEPT_LOCK() KASSERT(pthread_mutex_lock(&accept_mtx) == 0, ("%s: accept_mtx already locked", __func__))
|
||||
#define ACCEPT_UNLOCK() KASSERT(pthread_mutex_unlock(&accept_mtx) == 0, ("%s: accept_mtx not locked", __func__))
|
||||
#else
|
||||
#define ACCEPT_LOCK() (void)pthread_mutex_lock(&accept_mtx)
|
||||
#define ACCEPT_UNLOCK() (void)pthread_mutex_unlock(&accept_mtx)
|
||||
#endif
|
||||
#define ACCEPT_LOCK_ASSERT() \
|
||||
KASSERT(pthread_mutex_trylock(&accept_mtx) == EBUSY, ("%s: accept_mtx not locked", __func__))
|
||||
#define ACCEPT_UNLOCK_ASSERT() do { \
|
||||
KASSERT(pthread_mutex_trylock(&accept_mtx) == 0, ("%s: accept_mtx locked", __func__)); \
|
||||
(void)pthread_mutex_unlock(&accept_mtx); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -263,7 +272,7 @@ extern userland_cond_t accept_cond;
|
|||
* buffer.
|
||||
*/
|
||||
#define SOCKBUF_MTX(_sb) (&(_sb)->sb_mtx)
|
||||
#if defined (__Userspace_os_Windows)
|
||||
#if defined(_WIN32)
|
||||
#define SOCKBUF_LOCK_INIT(_sb, _name) \
|
||||
InitializeCriticalSection(SOCKBUF_MTX(_sb))
|
||||
#define SOCKBUF_LOCK_DESTROY(_sb) DeleteCriticalSection(SOCKBUF_MTX(_sb))
|
||||
|
@ -273,8 +282,19 @@ extern userland_cond_t accept_cond;
|
|||
#define SOCK_COND_DESTROY(_so) DeleteConditionVariable((&(_so)->timeo_cond))
|
||||
#define SOCK_COND(_so) (&(_so)->timeo_cond)
|
||||
#else
|
||||
#ifdef INVARIANTS
|
||||
#define SOCKBUF_LOCK_INIT(_sb, _name) do { \
|
||||
pthread_mutexattr_t mutex_attr; \
|
||||
\
|
||||
pthread_mutexattr_init(&mutex_attr); \
|
||||
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_ERRORCHECK); \
|
||||
pthread_mutex_init(SOCKBUF_MTX(_sb), &mutex_attr); \
|
||||
pthread_mutexattr_destroy(&mutex_attr); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SOCKBUF_LOCK_INIT(_sb, _name) \
|
||||
pthread_mutex_init(SOCKBUF_MTX(_sb), NULL)
|
||||
#endif
|
||||
#define SOCKBUF_LOCK_DESTROY(_sb) pthread_mutex_destroy(SOCKBUF_MTX(_sb))
|
||||
#define SOCKBUF_COND_INIT(_sb) pthread_cond_init((&(_sb)->sb_cond), NULL)
|
||||
#define SOCKBUF_COND_DESTROY(_sb) pthread_cond_destroy((&(_sb)->sb_cond))
|
||||
|
@ -347,338 +367,11 @@ extern userland_cond_t accept_cond;
|
|||
#define SQ_COMP 0x1000 /* unaccepted, complete connection */
|
||||
|
||||
/*
|
||||
* Externalized form of struct socket used by the sysctl(3) interface.
|
||||
* Socket event flags
|
||||
*/
|
||||
struct xsocket {
|
||||
size_t xso_len; /* length of this structure */
|
||||
struct socket *xso_so; /* makes a convenient handle sometimes */
|
||||
short so_type;
|
||||
short so_options;
|
||||
short so_linger;
|
||||
short so_state;
|
||||
caddr_t so_pcb; /* another convenient handle */
|
||||
int xso_protocol;
|
||||
int xso_family;
|
||||
u_short so_qlen;
|
||||
u_short so_incqlen;
|
||||
u_short so_qlimit;
|
||||
short so_timeo;
|
||||
u_short so_error;
|
||||
pid_t so_pgid;
|
||||
u_long so_oobmark;
|
||||
struct xsockbuf {
|
||||
u_int sb_cc;
|
||||
u_int sb_hiwat;
|
||||
u_int sb_mbcnt;
|
||||
u_int sb_mbmax;
|
||||
int sb_lowat;
|
||||
int sb_timeo;
|
||||
short sb_flags;
|
||||
} so_rcv, so_snd;
|
||||
uid_t so_uid; /* XXX */
|
||||
};
|
||||
|
||||
#if defined(_KERNEL)
|
||||
|
||||
|
||||
/*
|
||||
* Macros for sockets and socket buffering.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Do we need to notify the other side when I/O is possible?
|
||||
*/
|
||||
#define sb_notify(sb) (((sb)->sb_flags & (SB_WAIT | SB_SEL | SB_ASYNC | \
|
||||
SB_UPCALL | SB_AIO | SB_KNOTE)) != 0)
|
||||
|
||||
/*
|
||||
* How much space is there in a socket buffer (so->so_snd or so->so_rcv)?
|
||||
* This is problematical if the fields are unsigned, as the space might
|
||||
* still be negative (cc > hiwat or mbcnt > mbmax). Should detect
|
||||
* overflow and return 0. Should use "lmin" but it doesn't exist now.
|
||||
*/
|
||||
#define sbspace(sb) \
|
||||
((long) imin((int)((sb)->sb_hiwat - (sb)->sb_cc), \
|
||||
(int)((sb)->sb_mbmax - (sb)->sb_mbcnt)))
|
||||
|
||||
/* do we have to send all at once on a socket? */
|
||||
#define sosendallatonce(so) \
|
||||
((so)->so_proto->pr_flags & PR_ATOMIC)
|
||||
|
||||
/* can we read something from so? */
|
||||
#define soreadable(so) \
|
||||
((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \
|
||||
((so)->so_rcv.sb_state & SBS_CANTRCVMORE) || \
|
||||
!TAILQ_EMPTY(&(so)->so_comp) || (so)->so_error)
|
||||
|
||||
/* can we write something to so? */
|
||||
#define sowriteable(so) \
|
||||
((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \
|
||||
(((so)->so_state&SS_ISCONNECTED) || \
|
||||
((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \
|
||||
((so)->so_snd.sb_state & SBS_CANTSENDMORE) || \
|
||||
(so)->so_error)
|
||||
|
||||
/* adjust counters in sb reflecting allocation of m */
|
||||
#define sballoc(sb, m) { \
|
||||
(sb)->sb_cc += (m)->m_len; \
|
||||
if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \
|
||||
(sb)->sb_ctl += (m)->m_len; \
|
||||
(sb)->sb_mbcnt += MSIZE; \
|
||||
if ((m)->m_flags & M_EXT) \
|
||||
(sb)->sb_mbcnt += (m)->m_ext.ext_size; \
|
||||
}
|
||||
|
||||
/* adjust counters in sb reflecting freeing of m */
|
||||
#define sbfree(sb, m) { \
|
||||
(sb)->sb_cc -= (m)->m_len; \
|
||||
if ((m)->m_type != MT_DATA && (m)->m_type != MT_OOBDATA) \
|
||||
(sb)->sb_ctl -= (m)->m_len; \
|
||||
(sb)->sb_mbcnt -= MSIZE; \
|
||||
if ((m)->m_flags & M_EXT) \
|
||||
(sb)->sb_mbcnt -= (m)->m_ext.ext_size; \
|
||||
if ((sb)->sb_sndptr == (m)) { \
|
||||
(sb)->sb_sndptr = NULL; \
|
||||
(sb)->sb_sndptroff = 0; \
|
||||
} \
|
||||
if ((sb)->sb_sndptroff != 0) \
|
||||
(sb)->sb_sndptroff -= (m)->m_len; \
|
||||
}
|
||||
|
||||
/*
|
||||
* soref()/sorele() ref-count the socket structure. Note that you must
|
||||
* still explicitly close the socket, but the last ref count will free
|
||||
* the structure.
|
||||
*/
|
||||
#define soref(so) do { \
|
||||
SOCK_LOCK_ASSERT(so); \
|
||||
++(so)->so_count; \
|
||||
} while (0)
|
||||
|
||||
#define sorele(so) do { \
|
||||
ACCEPT_LOCK_ASSERT(); \
|
||||
SOCK_LOCK_ASSERT(so); \
|
||||
KASSERT((so)->so_count > 0, ("sorele")); \
|
||||
if (--(so)->so_count == 0) \
|
||||
sofree(so); \
|
||||
else { \
|
||||
SOCK_UNLOCK(so); \
|
||||
ACCEPT_UNLOCK(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define sotryfree(so) do { \
|
||||
ACCEPT_LOCK_ASSERT(); \
|
||||
SOCK_LOCK_ASSERT(so); \
|
||||
if ((so)->so_count == 0) \
|
||||
sofree(so); \
|
||||
else { \
|
||||
SOCK_UNLOCK(so); \
|
||||
ACCEPT_UNLOCK(); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* In sorwakeup() and sowwakeup(), acquire the socket buffer lock to
|
||||
* avoid a non-atomic test-and-wakeup. However, sowakeup is
|
||||
* responsible for releasing the lock if it is called. We unlock only
|
||||
* if we don't call into sowakeup. If any code is introduced that
|
||||
* directly invokes the underlying sowakeup() primitives, it must
|
||||
* maintain the same semantics.
|
||||
*/
|
||||
#define sorwakeup_locked(so) do { \
|
||||
SOCKBUF_LOCK_ASSERT(&(so)->so_rcv); \
|
||||
if (sb_notify(&(so)->so_rcv)) \
|
||||
sowakeup((so), &(so)->so_rcv); \
|
||||
else \
|
||||
SOCKBUF_UNLOCK(&(so)->so_rcv); \
|
||||
} while (0)
|
||||
|
||||
#define sorwakeup(so) do { \
|
||||
SOCKBUF_LOCK(&(so)->so_rcv); \
|
||||
sorwakeup_locked(so); \
|
||||
} while (0)
|
||||
|
||||
#define sowwakeup_locked(so) do { \
|
||||
SOCKBUF_LOCK_ASSERT(&(so)->so_snd); \
|
||||
if (sb_notify(&(so)->so_snd)) \
|
||||
sowakeup((so), &(so)->so_snd); \
|
||||
else \
|
||||
SOCKBUF_UNLOCK(&(so)->so_snd); \
|
||||
} while (0)
|
||||
|
||||
#define sowwakeup(so) do { \
|
||||
SOCKBUF_LOCK(&(so)->so_snd); \
|
||||
sowwakeup_locked(so); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Argument structure for sosetopt et seq. This is in the KERNEL
|
||||
* section because it will never be visible to user code.
|
||||
*/
|
||||
enum sopt_dir { SOPT_GET, SOPT_SET };
|
||||
struct sockopt {
|
||||
enum sopt_dir sopt_dir; /* is this a get or a set? */
|
||||
int sopt_level; /* second arg of [gs]etsockopt */
|
||||
int sopt_name; /* third arg of [gs]etsockopt */
|
||||
void *sopt_val; /* fourth arg of [gs]etsockopt */
|
||||
size_t sopt_valsize; /* (almost) fifth arg of [gs]etsockopt */
|
||||
struct thread *sopt_td; /* calling thread or null if kernel */
|
||||
};
|
||||
|
||||
struct accept_filter {
|
||||
char accf_name[16];
|
||||
void (*accf_callback)
|
||||
(struct socket *so, void *arg, int waitflag);
|
||||
void * (*accf_create)
|
||||
(struct socket *so, char *arg);
|
||||
void (*accf_destroy)
|
||||
(struct socket *so);
|
||||
SLIST_ENTRY(accept_filter) accf_next;
|
||||
};
|
||||
|
||||
extern int maxsockets;
|
||||
extern u_long sb_max;
|
||||
extern struct uma_zone *socket_zone;
|
||||
extern so_gen_t so_gencnt;
|
||||
|
||||
struct mbuf;
|
||||
struct sockaddr;
|
||||
struct ucred;
|
||||
struct uio;
|
||||
|
||||
/*
|
||||
* From uipc_socket and friends
|
||||
*/
|
||||
int do_getopt_accept_filter(struct socket *so, struct sockopt *sopt);
|
||||
int do_setopt_accept_filter(struct socket *so, struct sockopt *sopt);
|
||||
int so_setsockopt(struct socket *so, int level, int optname,
|
||||
void *optval, size_t optlen);
|
||||
int sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type);
|
||||
int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len);
|
||||
void sbappend(struct sockbuf *sb, struct mbuf *m);
|
||||
void sbappend_locked(struct sockbuf *sb, struct mbuf *m);
|
||||
void sbappendstream(struct sockbuf *sb, struct mbuf *m);
|
||||
void sbappendstream_locked(struct sockbuf *sb, struct mbuf *m);
|
||||
int sbappendaddr(struct sockbuf *sb, const struct sockaddr *asa,
|
||||
struct mbuf *m0, struct mbuf *control);
|
||||
int sbappendaddr_locked(struct sockbuf *sb, const struct sockaddr *asa,
|
||||
struct mbuf *m0, struct mbuf *control);
|
||||
int sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
|
||||
struct mbuf *control);
|
||||
int sbappendcontrol_locked(struct sockbuf *sb, struct mbuf *m0,
|
||||
struct mbuf *control);
|
||||
void sbappendrecord(struct sockbuf *sb, struct mbuf *m0);
|
||||
void sbappendrecord_locked(struct sockbuf *sb, struct mbuf *m0);
|
||||
void sbcheck(struct sockbuf *sb);
|
||||
void sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n);
|
||||
struct mbuf *
|
||||
sbcreatecontrol(caddr_t p, int size, int type, int level);
|
||||
void sbdestroy(struct sockbuf *sb, struct socket *so);
|
||||
void sbdrop(struct sockbuf *sb, int len);
|
||||
void sbdrop_locked(struct sockbuf *sb, int len);
|
||||
void sbdroprecord(struct sockbuf *sb);
|
||||
void sbdroprecord_locked(struct sockbuf *sb);
|
||||
void sbflush(struct sockbuf *sb);
|
||||
void sbflush_locked(struct sockbuf *sb);
|
||||
void sbrelease(struct sockbuf *sb, struct socket *so);
|
||||
void sbrelease_locked(struct sockbuf *sb, struct socket *so);
|
||||
int sbreserve(struct sockbuf *sb, u_long cc, struct socket *so,
|
||||
struct thread *td);
|
||||
int sbreserve_locked(struct sockbuf *sb, u_long cc, struct socket *so,
|
||||
struct thread *td);
|
||||
struct mbuf *
|
||||
sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff);
|
||||
void sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
|
||||
int sbwait(struct sockbuf *sb);
|
||||
int sblock(struct sockbuf *sb, int flags);
|
||||
void sbunlock(struct sockbuf *sb);
|
||||
void soabort(struct socket *so);
|
||||
int soaccept(struct socket *so, struct sockaddr **nam);
|
||||
int socheckuid(struct socket *so, uid_t uid);
|
||||
int sobind(struct socket *so, struct sockaddr *nam, struct thread *td);
|
||||
void socantrcvmore(struct socket *so);
|
||||
void socantrcvmore_locked(struct socket *so);
|
||||
void socantsendmore(struct socket *so);
|
||||
void socantsendmore_locked(struct socket *so);
|
||||
int soclose(struct socket *so);
|
||||
int soconnect(struct socket *so, struct sockaddr *nam, struct thread *td);
|
||||
int soconnect2(struct socket *so1, struct socket *so2);
|
||||
int socow_setup(struct mbuf *m0, struct uio *uio);
|
||||
int socreate(int dom, struct socket **aso, int type, int proto,
|
||||
struct ucred *cred, struct thread *td);
|
||||
int sodisconnect(struct socket *so);
|
||||
struct sockaddr *sodupsockaddr(const struct sockaddr *sa, int mflags);
|
||||
void sofree(struct socket *so);
|
||||
int sogetopt(struct socket *so, struct sockopt *sopt);
|
||||
void sohasoutofband(struct socket *so);
|
||||
void soisconnected(struct socket *so);
|
||||
void soisconnecting(struct socket *so);
|
||||
void soisdisconnected(struct socket *so);
|
||||
void soisdisconnecting(struct socket *so);
|
||||
int solisten(struct socket *so, int backlog, struct thread *td);
|
||||
void solisten_proto(struct socket *so, int backlog);
|
||||
int solisten_proto_check(struct socket *so);
|
||||
struct socket *
|
||||
sonewconn(struct socket *head, int connstatus);
|
||||
int sooptcopyin(struct sockopt *sopt, void *buf, size_t len, size_t minlen);
|
||||
int sooptcopyout(struct sockopt *sopt, const void *buf, size_t len);
|
||||
|
||||
/* XXX; prepare mbuf for (__FreeBSD__ < 3) routines. */
|
||||
int soopt_getm(struct sockopt *sopt, struct mbuf **mp);
|
||||
int soopt_mcopyin(struct sockopt *sopt, struct mbuf *m);
|
||||
int soopt_mcopyout(struct sockopt *sopt, struct mbuf *m);
|
||||
|
||||
int sopoll(struct socket *so, int events, struct ucred *active_cred,
|
||||
struct thread *td);
|
||||
int sopoll_generic(struct socket *so, int events,
|
||||
struct ucred *active_cred, struct thread *td);
|
||||
int soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio,
|
||||
struct mbuf **mp0, struct mbuf **controlp, int *flagsp);
|
||||
int soreceive_generic(struct socket *so, struct sockaddr **paddr,
|
||||
struct uio *uio, struct mbuf **mp0, struct mbuf **controlp,
|
||||
int *flagsp);
|
||||
int soreserve(struct socket *so, u_long sndcc, u_long rcvcc);
|
||||
void sorflush(struct socket *so);
|
||||
int sosend(struct socket *so, struct sockaddr *addr, struct uio *uio,
|
||||
struct mbuf *top, struct mbuf *control, int flags,
|
||||
struct thread *td);
|
||||
int sosend_dgram(struct socket *so, struct sockaddr *addr,
|
||||
struct uio *uio, struct mbuf *top, struct mbuf *control,
|
||||
int flags, struct thread *td);
|
||||
int sosend_generic(struct socket *so, struct sockaddr *addr,
|
||||
struct uio *uio, struct mbuf *top, struct mbuf *control,
|
||||
int flags, struct thread *td);
|
||||
int sosetopt(struct socket *so, struct sockopt *sopt);
|
||||
int soshutdown(struct socket *so, int how);
|
||||
void sotoxsocket(struct socket *so, struct xsocket *xso);
|
||||
void sowakeup(struct socket *so, struct sockbuf *sb);
|
||||
|
||||
#ifdef SOCKBUF_DEBUG
|
||||
void sblastrecordchk(struct sockbuf *, const char *, int);
|
||||
#define SBLASTRECORDCHK(sb) sblastrecordchk((sb), __FILE__, __LINE__)
|
||||
|
||||
void sblastmbufchk(struct sockbuf *, const char *, int);
|
||||
#define SBLASTMBUFCHK(sb) sblastmbufchk((sb), __FILE__, __LINE__)
|
||||
#else
|
||||
#define SBLASTRECORDCHK(sb) /* nothing */
|
||||
#define SBLASTMBUFCHK(sb) /* nothing */
|
||||
#endif /* SOCKBUF_DEBUG */
|
||||
|
||||
/*
|
||||
* Accept filter functions (duh).
|
||||
*/
|
||||
int accept_filt_add(struct accept_filter *filt);
|
||||
int accept_filt_del(char *name);
|
||||
struct accept_filter *accept_filt_get(char *name);
|
||||
#ifdef ACCEPT_FILTER_MOD
|
||||
#ifdef SYSCTL_DECL
|
||||
SYSCTL_DECL(_net_inet_accf);
|
||||
#endif
|
||||
int accept_filt_generic_mod_event(module_t mod, int event, void *data);
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#define SCTP_EVENT_READ 0x0001 /* socket is readable */
|
||||
#define SCTP_EVENT_WRITE 0x0002 /* socket is writeable */
|
||||
#define SCTP_EVENT_ERROR 0x0004 /* socket has an error state */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
|
@ -690,7 +383,6 @@ int accept_filt_generic_mod_event(module_t mod, int event, void *data);
|
|||
* above into, avoiding having to port the entire thing at once...
|
||||
* For function prototypes, the full bodies are in user_socket.c .
|
||||
*/
|
||||
#if defined(__Userspace__)
|
||||
|
||||
/* ---------------------------------------------------------- */
|
||||
/* --- function prototypes (implemented in user_socket.c) --- */
|
||||
|
@ -701,6 +393,7 @@ void soisconnected(struct socket *so);
|
|||
struct socket * sonewconn(struct socket *head, int connstatus);
|
||||
void socantrcvmore(struct socket *so);
|
||||
void socantsendmore(struct socket *so);
|
||||
void sofree(struct socket *so);
|
||||
|
||||
|
||||
|
||||
|
@ -764,9 +457,7 @@ extern int sctp_listen(struct socket *so, int backlog, struct proc *p);
|
|||
extern void socantrcvmore_locked(struct socket *so);
|
||||
extern int sctp_bind(struct socket *so, struct sockaddr *addr);
|
||||
extern int sctp6_bind(struct socket *so, struct sockaddr *addr, void *proc);
|
||||
#if defined(__Userspace__)
|
||||
extern int sctpconn_bind(struct socket *so, struct sockaddr *addr);
|
||||
#endif
|
||||
extern int sctp_accept(struct socket *so, struct sockaddr **addr);
|
||||
extern int sctp_attach(struct socket *so, int proto, uint32_t vrf_id);
|
||||
extern int sctp6_attach(struct socket *so, int proto, uint32_t vrf_id);
|
||||
|
@ -785,9 +476,7 @@ extern int soconnect(struct socket *so, struct sockaddr *nam);
|
|||
extern int sctp_disconnect(struct socket *so);
|
||||
extern int sctp_connect(struct socket *so, struct sockaddr *addr);
|
||||
extern int sctp6_connect(struct socket *so, struct sockaddr *addr);
|
||||
#if defined(__Userspace__)
|
||||
extern int sctpconn_connect(struct socket *so, struct sockaddr *addr);
|
||||
#endif
|
||||
extern void sctp_finish(void);
|
||||
|
||||
/* ------------------------------------------------ */
|
||||
|
@ -835,8 +524,4 @@ extern void sctp_finish(void);
|
|||
sowwakeup_locked(so); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
#endif /* __Userspace__ */
|
||||
|
||||
#endif /* !_SYS_SOCKETVAR_H_ */
|
||||
|
|
|
@ -46,11 +46,11 @@ typedef struct uma_zone * uma_zone_t;
|
|||
typedef struct uma_keg * uma_keg_t;
|
||||
|
||||
struct uma_cache {
|
||||
int stub; /* TODO __Userspace__ */
|
||||
int stub; /* TODO __Userspace__ */
|
||||
};
|
||||
|
||||
struct uma_keg {
|
||||
int stub; /* TODO __Userspace__ */
|
||||
int stub; /* TODO __Userspace__ */
|
||||
};
|
||||
|
||||
struct uma_zone {
|
||||
|
@ -83,16 +83,14 @@ struct uma_zone {
|
|||
/* Prototype */
|
||||
uma_zone_t
|
||||
uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor,
|
||||
uma_init uminit, uma_fini fini, int align, u_int32_t flags);
|
||||
uma_init uminit, uma_fini fini, int align, uint32_t flags);
|
||||
|
||||
|
||||
#define uma_zone_set_max(zone, number) /* stub TODO __Userspace__ */
|
||||
|
||||
uma_zone_t
|
||||
uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor,
|
||||
uma_init uminit, uma_fini fini, int align, u_int32_t flags)
|
||||
{
|
||||
return NULL; /* stub TODO __Userspace__. Also place implementation in a separate .c file */
|
||||
|
||||
uma_init uminit, uma_fini fini, int align, uint32_t flags) {
|
||||
return NULL; /* stub TODO __Userspace__. Also place implementation in a separate .c file */
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -64,14 +64,24 @@ extern "C" {
|
|||
#elif defined(SCTP_STDINT_INCLUDE)
|
||||
#include SCTP_STDINT_INCLUDE
|
||||
#else
|
||||
#define uint8_t unsigned __int8
|
||||
#define uint16_t unsigned __int16
|
||||
#define uint32_t unsigned __int32
|
||||
#define int16_t __int16
|
||||
#define int32_t __int32
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
#endif
|
||||
|
||||
#ifndef ssize_t
|
||||
#ifdef _WIN64
|
||||
typedef __int64 ssize_t;
|
||||
#elif defined _WIN32
|
||||
typedef int ssize_t;
|
||||
#else
|
||||
#error "Unknown platform!"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define ssize_t __int64
|
||||
#define MSG_EOR 0x8
|
||||
#ifndef EWOULDBLOCK
|
||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||
|
@ -86,6 +96,25 @@ extern "C" {
|
|||
|
||||
typedef uint32_t sctp_assoc_t;
|
||||
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
#pragma pack (push, 1)
|
||||
#define SCTP_PACKED
|
||||
#else
|
||||
#define SCTP_PACKED __attribute__((packed))
|
||||
#endif
|
||||
|
||||
struct sctp_common_header {
|
||||
uint16_t source_port;
|
||||
uint16_t destination_port;
|
||||
uint32_t verification_tag;
|
||||
uint32_t crc32c;
|
||||
} SCTP_PACKED;
|
||||
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
#undef SCTP_PACKED
|
||||
|
||||
#define AF_CONN 123
|
||||
/* The definition of struct sockaddr_conn MUST be in
|
||||
* tune with other sockaddr_* structures.
|
||||
|
@ -107,12 +136,8 @@ struct sockaddr_conn {
|
|||
#endif
|
||||
|
||||
union sctp_sockstore {
|
||||
#if defined(INET)
|
||||
struct sockaddr_in sin;
|
||||
#endif
|
||||
#if defined(INET6)
|
||||
struct sockaddr_in6 sin6;
|
||||
#endif
|
||||
struct sockaddr_conn sconn;
|
||||
struct sockaddr sa;
|
||||
};
|
||||
|
@ -121,6 +146,10 @@ union sctp_sockstore {
|
|||
#define SCTP_CURRENT_ASSOC 1
|
||||
#define SCTP_ALL_ASSOC 2
|
||||
|
||||
#define SCTP_EVENT_READ 0x0001
|
||||
#define SCTP_EVENT_WRITE 0x0002
|
||||
#define SCTP_EVENT_ERROR 0x0004
|
||||
|
||||
/*** Structures and definitions to use the socket API ***/
|
||||
|
||||
#define SCTP_ALIGN_RESV_PAD 92
|
||||
|
@ -252,12 +281,13 @@ struct sctp_assoc_change {
|
|||
#define SCTP_CANT_STR_ASSOC 0x0005
|
||||
|
||||
/* sac_info values */
|
||||
#define SCTP_ASSOC_SUPPORTS_PR 0x01
|
||||
#define SCTP_ASSOC_SUPPORTS_AUTH 0x02
|
||||
#define SCTP_ASSOC_SUPPORTS_ASCONF 0x03
|
||||
#define SCTP_ASSOC_SUPPORTS_MULTIBUF 0x04
|
||||
#define SCTP_ASSOC_SUPPORTS_RE_CONFIG 0x05
|
||||
#define SCTP_ASSOC_SUPPORTS_MAX 0x05
|
||||
#define SCTP_ASSOC_SUPPORTS_PR 0x01
|
||||
#define SCTP_ASSOC_SUPPORTS_AUTH 0x02
|
||||
#define SCTP_ASSOC_SUPPORTS_ASCONF 0x03
|
||||
#define SCTP_ASSOC_SUPPORTS_MULTIBUF 0x04
|
||||
#define SCTP_ASSOC_SUPPORTS_RE_CONFIG 0x05
|
||||
#define SCTP_ASSOC_SUPPORTS_INTERLEAVING 0x06
|
||||
#define SCTP_ASSOC_SUPPORTS_MAX 0x06
|
||||
|
||||
/* Address event */
|
||||
struct sctp_paddr_change {
|
||||
|
@ -286,7 +316,7 @@ struct sctp_remote_error {
|
|||
uint32_t sre_length;
|
||||
uint16_t sre_error;
|
||||
sctp_assoc_t sre_assoc_id;
|
||||
uint8_t sre_data[4];
|
||||
uint8_t sre_data[];
|
||||
};
|
||||
|
||||
/* shutdown event */
|
||||
|
@ -451,6 +481,8 @@ struct sctp_event_subscribe {
|
|||
|
||||
|
||||
/* Flags that go into the sinfo->sinfo_flags field */
|
||||
#define SCTP_DATA_LAST_FRAG 0x0001 /* tail part of the message could not be sent */
|
||||
#define SCTP_DATA_NOT_FRAG 0x0003 /* complete message could not be sent */
|
||||
#define SCTP_NOTIFICATION 0x0010 /* next message is a notification */
|
||||
#define SCTP_COMPLETE 0x0020 /* next message is complete */
|
||||
#define SCTP_EOF 0x0100 /* Start shutdown procedures */
|
||||
|
@ -520,9 +552,21 @@ struct sctp_event_subscribe {
|
|||
#define SCTP_DEFAULT_SNDINFO 0x00000021
|
||||
#define SCTP_DEFAULT_PRINFO 0x00000022
|
||||
#define SCTP_REMOTE_UDP_ENCAPS_PORT 0x00000024
|
||||
#define SCTP_ECN_SUPPORTED 0x00000025
|
||||
#define SCTP_PR_SUPPORTED 0x00000026
|
||||
#define SCTP_AUTH_SUPPORTED 0x00000027
|
||||
#define SCTP_ASCONF_SUPPORTED 0x00000028
|
||||
#define SCTP_RECONFIG_SUPPORTED 0x00000029
|
||||
#define SCTP_NRSACK_SUPPORTED 0x00000030
|
||||
#define SCTP_PKTDROP_SUPPORTED 0x00000031
|
||||
#define SCTP_MAX_CWND 0x00000032
|
||||
|
||||
#define SCTP_ENABLE_STREAM_RESET 0x00000900 /* struct sctp_assoc_value */
|
||||
|
||||
/* Pluggable Stream Scheduling Socket option */
|
||||
#define SCTP_PLUGGABLE_SS 0x00001203
|
||||
#define SCTP_SS_VALUE 0x00001204
|
||||
|
||||
/*
|
||||
* read-only options
|
||||
*/
|
||||
|
@ -533,6 +577,9 @@ struct sctp_event_subscribe {
|
|||
#define SCTP_LOCAL_AUTH_CHUNKS 0x00000103
|
||||
#define SCTP_GET_ASSOC_NUMBER 0x00000104
|
||||
#define SCTP_GET_ASSOC_ID_LIST 0x00000105
|
||||
#define SCTP_TIMEOUTS 0x00000106
|
||||
#define SCTP_PR_STREAM_STATUS 0x00000107
|
||||
#define SCTP_PR_ASSOC_STATUS 0x00000108
|
||||
|
||||
/*
|
||||
* write-only options
|
||||
|
@ -778,6 +825,12 @@ struct sctp_cc_option {
|
|||
struct sctp_assoc_value aid_value;
|
||||
};
|
||||
|
||||
struct sctp_stream_value {
|
||||
sctp_assoc_t assoc_id;
|
||||
uint16_t stream_id;
|
||||
uint16_t stream_value;
|
||||
};
|
||||
|
||||
struct sctp_timeouts {
|
||||
sctp_assoc_t stimo_assoc_id;
|
||||
uint32_t stimo_init;
|
||||
|
@ -789,6 +842,13 @@ struct sctp_timeouts {
|
|||
uint32_t stimo_shutdownack;
|
||||
};
|
||||
|
||||
struct sctp_prstatus {
|
||||
sctp_assoc_t sprstat_assoc_id;
|
||||
uint16_t sprstat_sid;
|
||||
uint16_t sprstat_policy;
|
||||
uint64_t sprstat_abandoned_unsent;
|
||||
uint64_t sprstat_abandoned_sent;
|
||||
};
|
||||
|
||||
/* Standard TCP Congestion Control */
|
||||
#define SCTP_CC_RFC2581 0x00000000
|
||||
|
@ -835,11 +895,16 @@ usrsctp_init(uint16_t,
|
|||
int (*)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
|
||||
void (*)(const char *format, ...));
|
||||
|
||||
void
|
||||
usrsctp_init_nothreads(uint16_t,
|
||||
int (*)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
|
||||
void (*)(const char *format, ...));
|
||||
|
||||
struct socket *
|
||||
usrsctp_socket(int domain, int type, int protocol,
|
||||
int (*receive_cb)(struct socket *sock, union sctp_sockstore addr, void *data,
|
||||
size_t datalen, struct sctp_rcvinfo, int flags, void *ulp_info),
|
||||
int (*send_cb)(struct socket *sock, uint32_t sb_free),
|
||||
int (*send_cb)(struct socket *sock, uint32_t sb_free, void *ulp_info),
|
||||
uint32_t sb_threshold,
|
||||
void *ulp_info);
|
||||
|
||||
|
@ -857,6 +922,13 @@ usrsctp_getsockopt(struct socket *so,
|
|||
void *option_value,
|
||||
socklen_t *option_len);
|
||||
|
||||
int
|
||||
usrsctp_opt_info(struct socket *so,
|
||||
sctp_assoc_t id,
|
||||
int opt,
|
||||
void *arg,
|
||||
socklen_t *size);
|
||||
|
||||
int
|
||||
usrsctp_getpaddrs(struct socket *so,
|
||||
sctp_assoc_t id,
|
||||
|
@ -934,6 +1006,9 @@ usrsctp_connectx(struct socket *so,
|
|||
void
|
||||
usrsctp_close(struct socket *so);
|
||||
|
||||
sctp_assoc_t
|
||||
usrsctp_getassocid(struct socket *, struct sockaddr *);
|
||||
|
||||
int
|
||||
usrsctp_finish(void);
|
||||
|
||||
|
@ -958,17 +1033,49 @@ usrsctp_deregister_address(void *);
|
|||
int
|
||||
usrsctp_set_ulpinfo(struct socket *, void *);
|
||||
|
||||
int
|
||||
usrsctp_get_ulpinfo(struct socket *, void **);
|
||||
|
||||
int
|
||||
usrsctp_set_upcall(struct socket *so,
|
||||
void (*upcall)(struct socket *, void *, int),
|
||||
void *arg);
|
||||
|
||||
int
|
||||
usrsctp_get_events(struct socket *so);
|
||||
|
||||
|
||||
void
|
||||
usrsctp_handle_timers(uint32_t elapsed_milliseconds);
|
||||
|
||||
#define SCTP_DUMP_OUTBOUND 1
|
||||
#define SCTP_DUMP_INBOUND 0
|
||||
|
||||
char *
|
||||
usrsctp_dumppacket(void *, size_t, int);
|
||||
usrsctp_dumppacket(const void *, size_t, int);
|
||||
|
||||
void
|
||||
usrsctp_freedumpbuffer(char *);
|
||||
|
||||
#define USRSCTP_SYSCTL_DECL(__field) \
|
||||
void usrsctp_sysctl_set_ ## __field(uint32_t value);\
|
||||
void
|
||||
usrsctp_enable_crc32c_offload(void);
|
||||
|
||||
void
|
||||
usrsctp_disable_crc32c_offload(void);
|
||||
|
||||
uint32_t
|
||||
usrsctp_crc32c(void *, size_t);
|
||||
|
||||
#define USRSCTP_TUNABLE_DECL(__field) \
|
||||
int usrsctp_tunable_set_ ## __field(uint32_t value);\
|
||||
uint32_t usrsctp_sysctl_get_ ## __field(void);
|
||||
|
||||
USRSCTP_TUNABLE_DECL(sctp_hashtblsize)
|
||||
USRSCTP_TUNABLE_DECL(sctp_pcbtblsize)
|
||||
USRSCTP_TUNABLE_DECL(sctp_chunkscale)
|
||||
|
||||
#define USRSCTP_SYSCTL_DECL(__field) \
|
||||
int usrsctp_sysctl_set_ ## __field(uint32_t value);\
|
||||
uint32_t usrsctp_sysctl_get_ ## __field(void);
|
||||
|
||||
USRSCTP_SYSCTL_DECL(sctp_sendspace)
|
||||
|
@ -982,17 +1089,11 @@ USRSCTP_SYSCTL_DECL(sctp_asconf_enable)
|
|||
USRSCTP_SYSCTL_DECL(sctp_reconfig_enable)
|
||||
USRSCTP_SYSCTL_DECL(sctp_nrsack_enable)
|
||||
USRSCTP_SYSCTL_DECL(sctp_pktdrop_enable)
|
||||
USRSCTP_SYSCTL_DECL(sctp_strict_sacks)
|
||||
#if !defined(SCTP_WITH_NO_CSUM)
|
||||
USRSCTP_SYSCTL_DECL(sctp_no_csum_on_loopback)
|
||||
#endif
|
||||
USRSCTP_SYSCTL_DECL(sctp_peer_chunk_oh)
|
||||
USRSCTP_SYSCTL_DECL(sctp_max_burst_default)
|
||||
USRSCTP_SYSCTL_DECL(sctp_max_chunks_on_queue)
|
||||
USRSCTP_SYSCTL_DECL(sctp_hashtblsize)
|
||||
USRSCTP_SYSCTL_DECL(sctp_pcbtblsize)
|
||||
USRSCTP_SYSCTL_DECL(sctp_min_split_point)
|
||||
USRSCTP_SYSCTL_DECL(sctp_chunkscale)
|
||||
USRSCTP_SYSCTL_DECL(sctp_delayed_sack_time_default)
|
||||
USRSCTP_SYSCTL_DECL(sctp_sack_freq_default)
|
||||
USRSCTP_SYSCTL_DECL(sctp_system_free_resc_limit)
|
||||
|
@ -1021,7 +1122,6 @@ USRSCTP_SYSCTL_DECL(sctp_mbuf_threshold_count)
|
|||
USRSCTP_SYSCTL_DECL(sctp_do_drain)
|
||||
USRSCTP_SYSCTL_DECL(sctp_hb_maxburst)
|
||||
USRSCTP_SYSCTL_DECL(sctp_abort_if_one_2_one_hits_limit)
|
||||
USRSCTP_SYSCTL_DECL(sctp_strict_data_order)
|
||||
USRSCTP_SYSCTL_DECL(sctp_min_residual)
|
||||
USRSCTP_SYSCTL_DECL(sctp_max_retran_chunk)
|
||||
USRSCTP_SYSCTL_DECL(sctp_logging_level)
|
||||
|
@ -1034,6 +1134,7 @@ USRSCTP_SYSCTL_DECL(sctp_udp_tunneling_port)
|
|||
USRSCTP_SYSCTL_DECL(sctp_enable_sack_immediately)
|
||||
USRSCTP_SYSCTL_DECL(sctp_vtag_time_wait)
|
||||
USRSCTP_SYSCTL_DECL(sctp_blackhole)
|
||||
USRSCTP_SYSCTL_DECL(sctp_sendall_limit)
|
||||
USRSCTP_SYSCTL_DECL(sctp_diag_info_code)
|
||||
USRSCTP_SYSCTL_DECL(sctp_fr_max_burst_default)
|
||||
USRSCTP_SYSCTL_DECL(sctp_path_pf_threshold)
|
||||
|
@ -1045,6 +1146,7 @@ USRSCTP_SYSCTL_DECL(sctp_steady_step)
|
|||
USRSCTP_SYSCTL_DECL(sctp_use_dccc_ecn)
|
||||
USRSCTP_SYSCTL_DECL(sctp_buffer_splitting)
|
||||
USRSCTP_SYSCTL_DECL(sctp_initial_cwnd)
|
||||
USRSCTP_SYSCTL_DECL(sctp_ootb_with_zero_cksum)
|
||||
#ifdef SCTP_DEBUG
|
||||
USRSCTP_SYSCTL_DECL(sctp_debug_on)
|
||||
/* More specific values can be found in sctp_constants, but
|
||||
|
@ -1099,7 +1201,7 @@ struct sctpstat {
|
|||
uint32_t sctps_recvauthfailed; /* total number of auth failed */
|
||||
uint32_t sctps_recvexpress; /* total fast path receives all one chunk */
|
||||
uint32_t sctps_recvexpressm; /* total fast path multi-part data */
|
||||
uint32_t sctps_recvnocrc;
|
||||
uint32_t sctps_recv_spare; /* formerly sctps_recvnocrc */
|
||||
uint32_t sctps_recvswcrc;
|
||||
uint32_t sctps_recvhwcrc;
|
||||
|
||||
|
@ -1116,7 +1218,7 @@ struct sctpstat {
|
|||
uint32_t sctps_sendecne; /* total output ECNE chunks */
|
||||
uint32_t sctps_sendauth; /* total output AUTH chunks FIXME */
|
||||
uint32_t sctps_senderrors; /* ip_output error counter */
|
||||
uint32_t sctps_sendnocrc;
|
||||
uint32_t sctps_send_spare; /* formerly sctps_sendnocrc */
|
||||
uint32_t sctps_sendswcrc;
|
||||
uint32_t sctps_sendhwcrc;
|
||||
/* PCKDROPREP statistics: */
|
||||
|
@ -1203,7 +1305,9 @@ struct sctpstat {
|
|||
uint32_t sctps_send_cwnd_avoid; /* Send cwnd full avoidance, already max burst inflight to net */
|
||||
uint32_t sctps_fwdtsn_map_over; /* number of map array over-runs via fwd-tsn's */
|
||||
uint32_t sctps_queue_upd_ecne; /* Number of times we queued or updated an ECN chunk on send queue */
|
||||
uint32_t sctps_reserved[31]; /* Future ABI compat - remove int's from here when adding new */
|
||||
uint32_t sctps_recvzerocrc; /* Number of accepted packets with zero CRC */
|
||||
uint32_t sctps_sendzerocrc; /* Number of packets sent with zero CRC */
|
||||
uint32_t sctps_reserved[29]; /* Future ABI compat - remove int's from here when adding new */
|
||||
};
|
||||
|
||||
void
|
||||
|
|
|
@ -58,29 +58,3 @@ nsHtml5OwningUTF16Buffer::Swap(nsHtml5OwningUTF16Buffer* aOther)
|
|||
nsHtml5UTF16Buffer::Swap(aOther);
|
||||
}
|
||||
|
||||
|
||||
// Not using macros for AddRef and Release in order to be able to refcount on
|
||||
// and create on different threads.
|
||||
|
||||
nsrefcnt
|
||||
nsHtml5OwningUTF16Buffer::AddRef()
|
||||
{
|
||||
NS_PRECONDITION(int32_t(mRefCnt) >= 0, "Illegal refcount.");
|
||||
++mRefCnt;
|
||||
NS_LOG_ADDREF(this, mRefCnt, "nsHtml5OwningUTF16Buffer", sizeof(*this));
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
nsrefcnt
|
||||
nsHtml5OwningUTF16Buffer::Release()
|
||||
{
|
||||
NS_PRECONDITION(0 != mRefCnt, "Release without AddRef.");
|
||||
--mRefCnt;
|
||||
NS_LOG_RELEASE(this, mRefCnt, "nsHtml5OwningUTF16Buffer");
|
||||
if (mRefCnt == 0) {
|
||||
mRefCnt = 1; /* stabilize */
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
class nsHtml5OwningUTF16Buffer : public nsHtml5UTF16Buffer
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsHtml5OwningUTF16Buffer)
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
@ -48,11 +51,6 @@ public:
|
|||
* Swap start, end and buffer fields with another object.
|
||||
*/
|
||||
void Swap(nsHtml5OwningUTF16Buffer* aOther);
|
||||
|
||||
nsrefcnt AddRef();
|
||||
nsrefcnt Release();
|
||||
private:
|
||||
mozilla::ThreadSafeAutoRefCnt mRefCnt;
|
||||
};
|
||||
|
||||
#endif // nsHtml5OwningUTF16Buffer_h
|
||||
|
|
|
@ -293,18 +293,6 @@ static struct nsMyTrustedEVInfo myTrustedEVInfos[] = {
|
|||
"VQQDExJRdW9WYWRpcyBSb290IENBIDI=",
|
||||
"BQk=",
|
||||
},
|
||||
{
|
||||
// CN=Network Solutions Certificate Authority,O=Network Solutions L.L.C.,C=US
|
||||
"1.3.6.1.4.1.782.1.2.1.8.1",
|
||||
"Network Solutions EV OID",
|
||||
{ 0x15, 0xF0, 0xBA, 0x00, 0xA3, 0xAC, 0x7A, 0xF3, 0xAC, 0x88, 0x4C,
|
||||
0x07, 0x2B, 0x10, 0x11, 0xA0, 0x77, 0xBD, 0x77, 0xC0, 0x97, 0xF4,
|
||||
0x01, 0x64, 0xB2, 0xF8, 0x59, 0x8A, 0xBD, 0x83, 0x86, 0x0C },
|
||||
"MGIxCzAJBgNVBAYTAlVTMSEwHwYDVQQKExhOZXR3b3JrIFNvbHV0aW9ucyBMLkwu"
|
||||
"Qy4xMDAuBgNVBAMTJ05ldHdvcmsgU29sdXRpb25zIENlcnRpZmljYXRlIEF1dGhv"
|
||||
"cml0eQ==",
|
||||
"V8szb8JcFuZHFhfjkDFo4A==",
|
||||
},
|
||||
{
|
||||
// CN=Entrust Root Certification Authority,OU="(c) 2006 Entrust, Inc.",OU=www.entrust.net/CPS is incorporated by reference,O="Entrust, Inc.",C=US
|
||||
"2.16.840.1.114028.10.1.2",
|
||||
|
@ -513,17 +501,28 @@ static struct nsMyTrustedEVInfo myTrustedEVInfos[] = {
|
|||
"DL4=",
|
||||
},
|
||||
{
|
||||
// CN = E-Tugra Certification Authority, OU = E-Tugra Sertifikasyon Merkezi, O = E-Tuğra EBG Bilişim Teknolojileri ve Hizmetleri A.Ş., L = Ankara, C = TR
|
||||
"2.16.792.3.0.4.1.1.4",
|
||||
"ETugra EV OID",
|
||||
{ 0xB0, 0xBF, 0xD5, 0x2B, 0xB0, 0xD7, 0xD9, 0xBD, 0x92, 0xBF, 0x5D,
|
||||
0x4D, 0xC1, 0x3D, 0xA2, 0x55, 0xC0, 0x2C, 0x54, 0x2F, 0x37, 0x83,
|
||||
0x65, 0xEA, 0x89, 0x39, 0x11, 0xF5, 0x5E, 0x55, 0xF2, 0x3C },
|
||||
"MIGyMQswCQYDVQQGEwJUUjEPMA0GA1UEBwwGQW5rYXJhMUAwPgYDVQQKDDdFLVR1"
|
||||
"xJ9yYSBFQkcgQmlsacWfaW0gVGVrbm9sb2ppbGVyaSB2ZSBIaXptZXRsZXJpIEEu"
|
||||
"xZ4uMSYwJAYDVQQLDB1FLVR1Z3JhIFNlcnRpZmlrYXN5b24gTWVya2V6aTEoMCYG"
|
||||
"A1UEAwwfRS1UdWdyYSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eQ==",
|
||||
"amg+nFGby1M=",
|
||||
// CN=E-Tugra Global Root CA RSA v3,OU=E-Tugra Trust Center,O=E-Tugra EBG A.S.,L=Ankara,C=TR
|
||||
"2.23.140.1.1",
|
||||
"CA/Browser Forum EV OID",
|
||||
{ 0xEF, 0x66, 0xB0, 0xB1, 0x0A, 0x3C, 0xDB, 0x9F, 0x2E, 0x36, 0x48,
|
||||
0xC7, 0x6B, 0xD2, 0xAF, 0x18, 0xEA, 0xD2, 0xBF, 0xE6, 0xF1, 0x17,
|
||||
0x65, 0x5E, 0x28, 0xC4, 0x06, 0x0D, 0xA1, 0xA3, 0xF4, 0xC2 },
|
||||
"MIGAMQswCQYDVQQGEwJUUjEPMA0GA1UEBxMGQW5rYXJhMRkwFwYDVQQKExBFLVR1"
|
||||
"Z3JhIEVCRyBBLlMuMR0wGwYDVQQLExRFLVR1Z3JhIFRydXN0IENlbnRlcjEmMCQG"
|
||||
"A1UEAxMdRS1UdWdyYSBHbG9iYWwgUm9vdCBDQSBSU0EgdjM=",
|
||||
"DU3FzRYilZYIfrgLfxUGNPt5EDQ=",
|
||||
},
|
||||
{
|
||||
// CN=E-Tugra Global Root CA ECC v3,OU=E-Tugra Trust Center,O=E-Tugra EBG A.S.,L=Ankara,C=TR
|
||||
"2.23.140.1.1",
|
||||
"CA/Browser Forum EV OID",
|
||||
{ 0x87, 0x3F, 0x46, 0x85, 0xFA, 0x7F, 0x56, 0x36, 0x25, 0x25, 0x2E,
|
||||
0x6D, 0x36, 0xBC, 0xD7, 0xF1, 0x6F, 0xC2, 0x49, 0x51, 0xF2, 0x64,
|
||||
0xE4, 0x7E, 0x1B, 0x95, 0x4F, 0x49, 0x08, 0xCD, 0xCA, 0x13 },
|
||||
"MIGAMQswCQYDVQQGEwJUUjEPMA0GA1UEBxMGQW5rYXJhMRkwFwYDVQQKExBFLVR1"
|
||||
"Z3JhIEVCRyBBLlMuMR0wGwYDVQQLExRFLVR1Z3JhIFRydXN0IENlbnRlcjEmMCQG"
|
||||
"A1UEAxMdRS1UdWdyYSBHbG9iYWwgUm9vdCBDQSBFQ0MgdjM=",
|
||||
"JkYZdzHhT28oNt45UYbm1JeIIsE=",
|
||||
},
|
||||
{
|
||||
// CN=Actalis Authentication Root CA,O=Actalis S.p.A./03358520967,L=Milan,C=IT
|
||||
|
@ -597,6 +596,28 @@ static struct nsMyTrustedEVInfo myTrustedEVInfos[] = {
|
|||
"dCBHNA==",
|
||||
"BZsbV56OITLiOQe9p3d1XA==",
|
||||
},
|
||||
{
|
||||
// CN=DigiCert TLS RSA4096 Root G5,O="DigiCert, Inc.",C=US
|
||||
"2.23.140.1.1",
|
||||
"CA/Browser Forum EV OID",
|
||||
{ 0x37, 0x1A, 0x00, 0xDC, 0x05, 0x33, 0xB3, 0x72, 0x1A, 0x7E, 0xEB,
|
||||
0x40, 0xE8, 0x41, 0x9E, 0x70, 0x79, 0x9D, 0x2B, 0x0A, 0x0F, 0x2C,
|
||||
0x1D, 0x80, 0x69, 0x31, 0x65, 0xF7, 0xCE, 0xC4, 0xAD, 0x75 },
|
||||
"ME0xCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5EaWdpQ2VydCwgSW5jLjElMCMGA1UE"
|
||||
"AxMcRGlnaUNlcnQgVExTIFJTQTQwOTYgUm9vdCBHNQ==",
|
||||
"CPm0eKj6ftpqMzeJ3nzPig==",
|
||||
},
|
||||
{
|
||||
// CN=DigiCert TLS ECC P384 Root G5,O="DigiCert, Inc.",C=US
|
||||
"2.23.140.1.1",
|
||||
"CA/Browser Forum EV OID",
|
||||
{ 0x01, 0x8E, 0x13, 0xF0, 0x77, 0x25, 0x32, 0xCF, 0x80, 0x9B, 0xD1,
|
||||
0xB1, 0x72, 0x81, 0x86, 0x72, 0x83, 0xFC, 0x48, 0xC6, 0xE1, 0x3B,
|
||||
0xE9, 0xC6, 0x98, 0x12, 0x85, 0x4A, 0x49, 0x0C, 0x1B, 0x05 },
|
||||
"ME4xCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5EaWdpQ2VydCwgSW5jLjEmMCQGA1UE"
|
||||
"AxMdRGlnaUNlcnQgVExTIEVDQyBQMzg0IFJvb3QgRzU=",
|
||||
"CeCTZaz32ci5PhwLBCou8w==",
|
||||
},
|
||||
{
|
||||
// CN=QuoVadis Root CA 2 G3,O=QuoVadis Limited,C=BM
|
||||
"1.3.6.1.4.1.8024.0.2.100.1.2",
|
||||
|
@ -679,17 +700,6 @@ static struct nsMyTrustedEVInfo myTrustedEVInfos[] = {
|
|||
"cnVzdC5uZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgp",
|
||||
"OGPe+A==",
|
||||
},
|
||||
{
|
||||
// CN=Staat der Nederlanden EV Root CA,O=Staat der Nederlanden,C=NL
|
||||
"2.16.528.1.1003.1.2.7",
|
||||
"Staat der Nederlanden EV OID",
|
||||
{ 0x4D, 0x24, 0x91, 0x41, 0x4C, 0xFE, 0x95, 0x67, 0x46, 0xEC, 0x4C,
|
||||
0xEF, 0xA6, 0xCF, 0x6F, 0x72, 0xE2, 0x8A, 0x13, 0x29, 0x43, 0x2F,
|
||||
0x9D, 0x8A, 0x90, 0x7A, 0xC4, 0xCB, 0x5D, 0xAD, 0xC1, 0x5A },
|
||||
"MFgxCzAJBgNVBAYTAk5MMR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4x"
|
||||
"KTAnBgNVBAMMIFN0YWF0IGRlciBOZWRlcmxhbmRlbiBFViBSb290IENB",
|
||||
"AJiWjQ==",
|
||||
},
|
||||
{
|
||||
// CN=Entrust Root Certification Authority - G2,OU="(c) 2009 Entrust, Inc. - for authorized use only",OU=See www.entrust.net/legal-terms,O="Entrust, Inc.",C=US
|
||||
"2.16.840.1.114028.10.1.2",
|
||||
|
@ -1153,6 +1163,28 @@ static struct nsMyTrustedEVInfo myTrustedEVInfos[] = {
|
|||
"GUQtVFJVU1QgRVYgUm9vdCBDQSAxIDIwMjA=",
|
||||
"XwJB13qHfEwDo6yWjfv/0A==",
|
||||
},
|
||||
{
|
||||
// CN=BJCA Global Root CA1,O=BEIJING CERTIFICATE AUTHORITY,C=CN
|
||||
"2.23.140.1.1",
|
||||
"CA/Browser Forum EV OID",
|
||||
{ 0xF3, 0x89, 0x6F, 0x88, 0xFE, 0x7C, 0x0A, 0x88, 0x27, 0x66, 0xA7,
|
||||
0xFA, 0x6A, 0xD2, 0x74, 0x9F, 0xB5, 0x7A, 0x7F, 0x3E, 0x98, 0xFB,
|
||||
0x76, 0x9C, 0x1F, 0xA7, 0xB0, 0x9C, 0x2C, 0x44, 0xD5, 0xAE },
|
||||
"MFQxCzAJBgNVBAYTAkNOMSYwJAYDVQQKDB1CRUlKSU5HIENFUlRJRklDQVRFIEFV"
|
||||
"VEhPUklUWTEdMBsGA1UEAwwUQkpDQSBHbG9iYWwgUm9vdCBDQTE=",
|
||||
"VW9l47TZkGobCdFsPsBsIA==",
|
||||
},
|
||||
{
|
||||
// CN=BJCA Global Root CA2,O=BEIJING CERTIFICATE AUTHORITY,C=CN
|
||||
"2.23.140.1.1",
|
||||
"CA/Browser Forum EV OID",
|
||||
{ 0x57, 0x4D, 0xF6, 0x93, 0x1E, 0x27, 0x80, 0x39, 0x66, 0x7B, 0x72,
|
||||
0x0A, 0xFD, 0xC1, 0x60, 0x0F, 0xC2, 0x7E, 0xB6, 0x6D, 0xD3, 0x09,
|
||||
0x29, 0x79, 0xFB, 0x73, 0x85, 0x64, 0x87, 0x21, 0x28, 0x82 },
|
||||
"MFQxCzAJBgNVBAYTAkNOMSYwJAYDVQQKDB1CRUlKSU5HIENFUlRJRklDQVRFIEFV"
|
||||
"VEhPUklUWTEdMBsGA1UEAwwUQkpDQSBHbG9iYWwgUm9vdCBDQTI=",
|
||||
"LBcIfWQqwP6FGFkGz7RK6w==",
|
||||
},
|
||||
};
|
||||
|
||||
// TenFourFox issue 512, backport from ESR60: treat all EV roots as
|
||||
|
|
|
@ -71,6 +71,14 @@ static const char kDigiCert_Global_Root_G3Fingerprint[] =
|
|||
static const char kDigiCert_High_Assurance_EV_Root_CAFingerprint[] =
|
||||
"WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=";
|
||||
|
||||
/* DigiCert TLS ECC P384 Root G5 */
|
||||
static const char kDigiCert_TLS_ECC_P384_Root_G5Fingerprint[] =
|
||||
"oC+voZLIy4HLE0FVT5wFtxzKKokLDRKY1oNkfJYe+98=";
|
||||
|
||||
/* DigiCert TLS RSA4096 Root G5 */
|
||||
static const char kDigiCert_TLS_RSA4096_Root_G5Fingerprint[] =
|
||||
"ape1HIIZ6T5d7GS61YBs3rD4NVvkfnVwELcCRW4Bqv0=";
|
||||
|
||||
/* DigiCert Trusted Root G4 */
|
||||
static const char kDigiCert_Trusted_Root_G4Fingerprint[] =
|
||||
"Wd8xe/qfTwq3ylFNd3IpaqLHZbh2ZNCLluVzmeNkcpw=";
|
||||
|
@ -99,82 +107,18 @@ static const char kEntrust_net_Premium_2048_Secure_Server_CAFingerprint[] =
|
|||
static const char kFacebookBackupFingerprint[] =
|
||||
"q4PO2G2cbkZhZ82+JgmRUyGMoAeozA+BSXVXQWB8XWQ=";
|
||||
|
||||
/* GOOGLE_PIN_AddTrustClass1CARoot */
|
||||
static const char kGOOGLE_PIN_AddTrustClass1CARootFingerprint[] =
|
||||
"BStocQfshOhzA4JFLsKidFF0XXSFpX1vRk4Np6G2ryo=";
|
||||
|
||||
/* GOOGLE_PIN_AddTrustExternalCARoot */
|
||||
static const char kGOOGLE_PIN_AddTrustExternalCARootFingerprint[] =
|
||||
"lCppFqbkrlJ3EcVFAkeip0+44VaoJUymbnOaEUk7tEU=";
|
||||
|
||||
/* GOOGLE_PIN_AddTrustPublicCARoot */
|
||||
static const char kGOOGLE_PIN_AddTrustPublicCARootFingerprint[] =
|
||||
"OGHXtpYfzbISBFb/b8LrdwSxp0G0vZM6g3b14ZFcppg=";
|
||||
|
||||
/* GOOGLE_PIN_AddTrustQualifiedCARoot */
|
||||
static const char kGOOGLE_PIN_AddTrustQualifiedCARootFingerprint[] =
|
||||
"xzr8Lrp3DQy8HuQfJStS6Kk9ErctzOwDHY2DnL+Bink=";
|
||||
|
||||
/* GOOGLE_PIN_COMODORSADomainValidationSecureServerCA */
|
||||
static const char kGOOGLE_PIN_COMODORSADomainValidationSecureServerCAFingerprint[] =
|
||||
"klO23nT2ehFDXCfx3eHTDRESMz3asj1muO+4aIdjiuY=";
|
||||
|
||||
/* GOOGLE_PIN_DSTRootCAX3 */
|
||||
static const char kGOOGLE_PIN_DSTRootCAX3Fingerprint[] =
|
||||
"Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys=";
|
||||
|
||||
/* GOOGLE_PIN_DigiCertECCSecureServerCA */
|
||||
static const char kGOOGLE_PIN_DigiCertECCSecureServerCAFingerprint[] =
|
||||
"PZXN3lRAy+8tBKk2Ox6F7jIlnzr2Yzmwqc3JnyfXoCw=";
|
||||
|
||||
/* GOOGLE_PIN_Entrust_SSL */
|
||||
static const char kGOOGLE_PIN_Entrust_SSLFingerprint[] =
|
||||
"nsxRNo6G40YPZsKV5JQt1TCA8nseQQr/LRqp1Oa8fnw=";
|
||||
|
||||
/* GOOGLE_PIN_GTECyberTrustGlobalRoot */
|
||||
static const char kGOOGLE_PIN_GTECyberTrustGlobalRootFingerprint[] =
|
||||
"EGn6R6CqT4z3ERscrqNl7q7RC//zJmDe9uBhS/rnCHU=";
|
||||
|
||||
/* GOOGLE_PIN_GTSCA1O1 */
|
||||
static const char kGOOGLE_PIN_GTSCA1O1Fingerprint[] =
|
||||
"YZPgTZ+woNCCCIW3LH2CxQeLzB/1m42QcCTBSdgayjs=";
|
||||
|
||||
/* GOOGLE_PIN_GeoTrustGlobal */
|
||||
static const char kGOOGLE_PIN_GeoTrustGlobalFingerprint[] =
|
||||
"h6801m+z8v3zbgkRHpq6L29Esgfzhj89C1SyUCOQmqU=";
|
||||
|
||||
/* GOOGLE_PIN_GeoTrustGlobal2 */
|
||||
static const char kGOOGLE_PIN_GeoTrustGlobal2Fingerprint[] =
|
||||
"F3VaXClfPS1y5vAxofB/QAxYi55YKyLxfq4xoVkNEYU=";
|
||||
|
||||
/* GOOGLE_PIN_GeoTrustPrimary */
|
||||
static const char kGOOGLE_PIN_GeoTrustPrimaryFingerprint[] =
|
||||
"SQVGZiOrQXi+kqxcvWWE96HhfydlLVqFr4lQTqI5qqo=";
|
||||
|
||||
/* GOOGLE_PIN_GeoTrustPrimary_G2 */
|
||||
static const char kGOOGLE_PIN_GeoTrustPrimary_G2Fingerprint[] =
|
||||
"vPtEqrmtAhAVcGtBIep2HIHJ6IlnWQ9vlK50TciLePs=";
|
||||
|
||||
/* GOOGLE_PIN_GeoTrustPrimary_G3 */
|
||||
static const char kGOOGLE_PIN_GeoTrustPrimary_G3Fingerprint[] =
|
||||
"q5hJUnat8eyv8o81xTBIeB5cFxjaucjmelBPT2pRMo8=";
|
||||
|
||||
/* GOOGLE_PIN_GeoTrustUniversal */
|
||||
static const char kGOOGLE_PIN_GeoTrustUniversalFingerprint[] =
|
||||
"lpkiXF3lLlbN0y3y6W0c/qWqPKC7Us2JM8I7XCdEOCA=";
|
||||
|
||||
/* GOOGLE_PIN_GeoTrustUniversal2 */
|
||||
static const char kGOOGLE_PIN_GeoTrustUniversal2Fingerprint[] =
|
||||
"fKoDRlEkWQxgHlZ+UhSOlSwM/+iQAFMP4NlbbVDqrkE=";
|
||||
|
||||
/* GOOGLE_PIN_GlobalSignRootCA_R2 */
|
||||
static const char kGOOGLE_PIN_GlobalSignRootCA_R2Fingerprint[] =
|
||||
"iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0=";
|
||||
|
||||
/* GOOGLE_PIN_GoDaddySecure */
|
||||
static const char kGOOGLE_PIN_GoDaddySecureFingerprint[] =
|
||||
"MrZLZnJ6IGPkBm87lYywqu5Xal7O/ZUzmbuIdHMdlYc=";
|
||||
|
||||
/* GOOGLE_PIN_R3LetsEncrypt */
|
||||
static const char kGOOGLE_PIN_R3LetsEncryptFingerprint[] =
|
||||
"jQJTbIh0grw0/1TkHSumWb+Fs0Ggogr621gT3PvPKG0=";
|
||||
|
@ -187,66 +131,10 @@ static const char kGOOGLE_PIN_R4LetsEncryptFingerprint[] =
|
|||
static const char kGOOGLE_PIN_RapidSSLFingerprint[] =
|
||||
"lT09gPUeQfbYrlxRtpsHrjDblj9Rpz+u7ajfCrg4qDM=";
|
||||
|
||||
/* GOOGLE_PIN_SecureCertificateServices */
|
||||
static const char kGOOGLE_PIN_SecureCertificateServicesFingerprint[] =
|
||||
"RpHL/ehKa2BS3b4VK7DCFq4lqG5XR4E9vA8UfzOFcL4=";
|
||||
|
||||
/* GOOGLE_PIN_SymantecClass3EVG3 */
|
||||
static const char kGOOGLE_PIN_SymantecClass3EVG3Fingerprint[] =
|
||||
"gMxWOrX4PMQesK9qFNbYBxjBfjUvlkn/vN1n+L9lE5E=";
|
||||
|
||||
/* GOOGLE_PIN_TrustedCertificateServices */
|
||||
static const char kGOOGLE_PIN_TrustedCertificateServicesFingerprint[] =
|
||||
"4tiR77c4ZpEF1TDeXtcuKyrD9KZweLU0mz/ayklvXrg=";
|
||||
|
||||
/* GOOGLE_PIN_UTNDATACorpSGC */
|
||||
static const char kGOOGLE_PIN_UTNDATACorpSGCFingerprint[] =
|
||||
"QAL80xHQczFWfnG82XHkYEjI3OjRZZcRdTs9qiommvo=";
|
||||
|
||||
/* GOOGLE_PIN_UTNUSERFirstClientAuthenticationandEmail */
|
||||
static const char kGOOGLE_PIN_UTNUSERFirstClientAuthenticationandEmailFingerprint[] =
|
||||
"Laj56jRU0hFGRko/nQKNxMf7tXscUsc8KwVyovWZotM=";
|
||||
|
||||
/* GOOGLE_PIN_UTNUSERFirstHardware */
|
||||
static const char kGOOGLE_PIN_UTNUSERFirstHardwareFingerprint[] =
|
||||
"TUDnr0MEoJ3of7+YliBMBVFB4/gJsv5zO7IxD9+YoWI=";
|
||||
|
||||
/* GOOGLE_PIN_UTNUSERFirstObject */
|
||||
static const char kGOOGLE_PIN_UTNUSERFirstObjectFingerprint[] =
|
||||
"D+FMJksXu28NZT56cOs2Pb9UvhWAOe3a5cJXEd9IwQM=";
|
||||
|
||||
/* GOOGLE_PIN_VeriSignClass1 */
|
||||
static const char kGOOGLE_PIN_VeriSignClass1Fingerprint[] =
|
||||
"LclHC+Y+9KzxvYKGCUArt7h72ZY4pkOTTohoLRvowwg=";
|
||||
|
||||
/* GOOGLE_PIN_VeriSignClass2_G2 */
|
||||
static const char kGOOGLE_PIN_VeriSignClass2_G2Fingerprint[] =
|
||||
"2oALgLKofTmeZvoZ1y/fSZg7R9jPMix8eVA6DH4o/q8=";
|
||||
|
||||
/* GOOGLE_PIN_VeriSignClass3_G2 */
|
||||
static const char kGOOGLE_PIN_VeriSignClass3_G2Fingerprint[] =
|
||||
"AjyBzOjnxk+pQtPBUEhwfTXZu1uH9PVExb8bxWQ68vo=";
|
||||
|
||||
/* GOOGLE_PIN_VeriSignClass3_G3 */
|
||||
static const char kGOOGLE_PIN_VeriSignClass3_G3Fingerprint[] =
|
||||
"SVqWumuteCQHvVIaALrOZXuzVVVeS7f4FGxxu6V+es4=";
|
||||
|
||||
/* GOOGLE_PIN_VeriSignClass3_G4 */
|
||||
static const char kGOOGLE_PIN_VeriSignClass3_G4Fingerprint[] =
|
||||
"UZJDjsNp1+4M5x9cbbdflB779y5YRBcV6Z6rBMLIrO4=";
|
||||
|
||||
/* GOOGLE_PIN_VeriSignClass3_G5 */
|
||||
static const char kGOOGLE_PIN_VeriSignClass3_G5Fingerprint[] =
|
||||
"JbQbUG5JMJUoI6brnx0x3vZF6jilxsapbXGVfjhN8Fg=";
|
||||
|
||||
/* GOOGLE_PIN_VeriSignClass4_G3 */
|
||||
static const char kGOOGLE_PIN_VeriSignClass4_G3Fingerprint[] =
|
||||
"VnuCEf0g09KD7gzXzgZyy52ZvFtIeljJ1U7Gf3fUqPU=";
|
||||
|
||||
/* GOOGLE_PIN_VeriSignUniversal */
|
||||
static const char kGOOGLE_PIN_VeriSignUniversalFingerprint[] =
|
||||
"lnsM2T/O9/J84sJFdnrpsFp3awZJ+ZZbYpCWhGloaHI=";
|
||||
|
||||
/* GTS Root R1 */
|
||||
static const char kGTS_Root_R1Fingerprint[] =
|
||||
"hxqRlPTu1bMS/0DITB1SSu0vd4u/8l8TjPgfaAp63Gc=";
|
||||
|
@ -279,6 +167,10 @@ static const char kGlobalSign_Root_CA___R3Fingerprint[] =
|
|||
static const char kGlobalSign_Root_CA___R6Fingerprint[] =
|
||||
"aCdH+LpiG4fN07wpXtXKvOciocDANj0daLOJKNJ4fx4=";
|
||||
|
||||
/* GlobalSign Root R46 */
|
||||
static const char kGlobalSign_Root_R46Fingerprint[] =
|
||||
"rn+WLLnmp9v3uDP7GPqbcaiRdd+UnCMrap73yz3yu/w=";
|
||||
|
||||
/* Go Daddy Class 2 CA */
|
||||
static const char kGo_Daddy_Class_2_CAFingerprint[] =
|
||||
"VjLZe/p3W/PJnd6lL8JVNBCGQBZynFLdZSTIqcO0SJ8=";
|
||||
|
@ -295,6 +187,10 @@ static const char kGoogleBackup2048Fingerprint[] =
|
|||
static const char kISRG_Root_X1Fingerprint[] =
|
||||
"C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M=";
|
||||
|
||||
/* ISRG Root X2 */
|
||||
static const char kISRG_Root_X2Fingerprint[] =
|
||||
"diGVwiVYbubAI3RW4hB9xU8e/CH2GnkuvVFZE8zmgzI=";
|
||||
|
||||
/* Let's Encrypt Authority X3 */
|
||||
static const char kLet_s_Encrypt_Authority_X3Fingerprint[] =
|
||||
"YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=";
|
||||
|
@ -303,14 +199,6 @@ static const char kLet_s_Encrypt_Authority_X3Fingerprint[] =
|
|||
static const char kLet_s_Encrypt_Authority_X4Fingerprint[] =
|
||||
"sRHdihwgkaib1P1gxX8HFszlD+7/gTfNvuAybgLPNis=";
|
||||
|
||||
/* SpiderOak2 */
|
||||
static const char kSpiderOak2Fingerprint[] =
|
||||
"7Y3UnxbffL8aFPXsOJBpGasgpDmngpIhAxGKdQRklQQ=";
|
||||
|
||||
/* SpiderOak3 */
|
||||
static const char kSpiderOak3Fingerprint[] =
|
||||
"LkER54vOdlygpTsbYvlpMq1CE/lDAG1AP9xmdtwvV2A=";
|
||||
|
||||
/* Starfield Class 2 CA */
|
||||
static const char kStarfield_Class_2_CAFingerprint[] =
|
||||
"FfFKxFycfaIz00eRZOgTf+Ne4POK6FgYPwhBDqgqxLQ=";
|
||||
|
@ -319,14 +207,6 @@ static const char kStarfield_Class_2_CAFingerprint[] =
|
|||
static const char kStarfield_Root_Certificate_Authority___G2Fingerprint[] =
|
||||
"gI1os/q0iEpflxrOfRBVDXqVoWN3Tz7Dav/7IT++THQ=";
|
||||
|
||||
/* Swehack */
|
||||
static const char kSwehackFingerprint[] =
|
||||
"FdaffE799rVb3oyAuhJ2mBW/XJwD07Uajb2G6YwSAEw=";
|
||||
|
||||
/* SwehackBackup */
|
||||
static const char kSwehackBackupFingerprint[] =
|
||||
"z6cuswA6E1vgFkCjUsbEYo0Lf3aP8M8YOvwkoiGzDCo=";
|
||||
|
||||
/* TestSPKI */
|
||||
static const char kTestSPKIFingerprint[] =
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||
|
@ -343,10 +223,6 @@ static const char kTor2Fingerprint[] =
|
|||
static const char kTor3Fingerprint[] =
|
||||
"CleC1qwUR8JPgH1nXvSe2VHxDe5/KfNs96EusbfSOfo=";
|
||||
|
||||
/* Twitter1 */
|
||||
static const char kTwitter1Fingerprint[] =
|
||||
"vU9M48LzD/CF34wE5PPf4nBwRyosy06X21J0ap8yS5s=";
|
||||
|
||||
/* USERTrust ECC Certification Authority */
|
||||
static const char kUSERTrust_ECC_Certification_AuthorityFingerprint[] =
|
||||
"ICGRfpgmOUXIWcQ/HXPLQTkFPEFPoDyjvH7ohhQpjzs=";
|
||||
|
@ -355,14 +231,6 @@ static const char kUSERTrust_ECC_Certification_AuthorityFingerprint[] =
|
|||
static const char kUSERTrust_RSA_Certification_AuthorityFingerprint[] =
|
||||
"x4QzPSC810K5/cMjb05Qm4k3Bw5zBn4lTdO/nEW/Td4=";
|
||||
|
||||
/* Verisign Class 1 Public Primary Certification Authority - G3 */
|
||||
static const char kVerisign_Class_1_Public_Primary_Certification_Authority___G3Fingerprint[] =
|
||||
"IgduWu9Eu5pBaii30cRDItcFn2D+/6XK9sW+hEeJEwM=";
|
||||
|
||||
/* Verisign Class 2 Public Primary Certification Authority - G3 */
|
||||
static const char kVerisign_Class_2_Public_Primary_Certification_Authority___G3Fingerprint[] =
|
||||
"cAajgxHlj7GTSEIzIYIQxmEloOSoJq7VOaxWHfv72QM=";
|
||||
|
||||
/* Pinsets are each an ordered list by the actual value of the fingerprint */
|
||||
struct StaticFingerprints {
|
||||
// See bug 1338873 about making these fields const.
|
||||
|
@ -412,6 +280,9 @@ static const StaticFingerprints kPinset_google_root_pems = {
|
|||
static const char* const kPinset_mozilla_services_Data[] = {
|
||||
kISRG_Root_X1Fingerprint,
|
||||
kDigiCert_High_Assurance_EV_Root_CAFingerprint,
|
||||
kDigiCert_TLS_RSA4096_Root_G5Fingerprint,
|
||||
kDigiCert_Global_Root_G2Fingerprint,
|
||||
kDigiCert_TLS_ECC_P384_Root_G5Fingerprint,
|
||||
kDigiCert_Global_Root_CAFingerprint,
|
||||
};
|
||||
static const StaticFingerprints kPinset_mozilla_services = {
|
||||
|
@ -466,122 +337,33 @@ static const StaticFingerprints kPinset_tor = {
|
|||
kPinset_tor_Data
|
||||
};
|
||||
|
||||
static const char* const kPinset_twitterCom_Data[] = {
|
||||
kGOOGLE_PIN_VeriSignClass2_G2Fingerprint,
|
||||
kGOOGLE_PIN_VeriSignClass3_G2Fingerprint,
|
||||
kGOOGLE_PIN_GeoTrustGlobal2Fingerprint,
|
||||
kDigiCert_Assured_ID_Root_CAFingerprint,
|
||||
kVerisign_Class_1_Public_Primary_Certification_Authority___G3Fingerprint,
|
||||
kGOOGLE_PIN_VeriSignClass3_G5Fingerprint,
|
||||
kGOOGLE_PIN_VeriSignClass1Fingerprint,
|
||||
kGOOGLE_PIN_GeoTrustPrimaryFingerprint,
|
||||
kGOOGLE_PIN_VeriSignClass3_G3Fingerprint,
|
||||
kGOOGLE_PIN_VeriSignClass3_G4Fingerprint,
|
||||
kGOOGLE_PIN_VeriSignClass4_G3Fingerprint,
|
||||
kDigiCert_High_Assurance_EV_Root_CAFingerprint,
|
||||
kVerisign_Class_2_Public_Primary_Certification_Authority___G3Fingerprint,
|
||||
kGOOGLE_PIN_GeoTrustUniversal2Fingerprint,
|
||||
kGOOGLE_PIN_GeoTrustGlobalFingerprint,
|
||||
kGOOGLE_PIN_VeriSignUniversalFingerprint,
|
||||
kGOOGLE_PIN_GeoTrustUniversalFingerprint,
|
||||
kGOOGLE_PIN_GeoTrustPrimary_G3Fingerprint,
|
||||
kDigiCert_Global_Root_CAFingerprint,
|
||||
kGOOGLE_PIN_GeoTrustPrimary_G2Fingerprint,
|
||||
kTwitter1Fingerprint,
|
||||
};
|
||||
static const StaticFingerprints kPinset_twitterCom = {
|
||||
sizeof(kPinset_twitterCom_Data) / sizeof(const char*),
|
||||
kPinset_twitterCom_Data
|
||||
};
|
||||
|
||||
static const char* const kPinset_twitterCDN_Data[] = {
|
||||
kGOOGLE_PIN_VeriSignClass2_G2Fingerprint,
|
||||
kGOOGLE_PIN_TrustedCertificateServicesFingerprint,
|
||||
kCOMODO_Certification_AuthorityFingerprint,
|
||||
kGOOGLE_PIN_VeriSignClass3_G2Fingerprint,
|
||||
kGOOGLE_PIN_AddTrustClass1CARootFingerprint,
|
||||
kGOOGLE_PIN_UTNUSERFirstObjectFingerprint,
|
||||
kGOOGLE_PIN_GTECyberTrustGlobalRootFingerprint,
|
||||
kGOOGLE_PIN_GeoTrustGlobal2Fingerprint,
|
||||
kEntrust_net_Premium_2048_Secure_Server_CAFingerprint,
|
||||
kDigiCert_Assured_ID_Root_CAFingerprint,
|
||||
kVerisign_Class_1_Public_Primary_Certification_Authority___G3Fingerprint,
|
||||
kGOOGLE_PIN_VeriSignClass3_G5Fingerprint,
|
||||
kGlobalSign_Root_CAFingerprint,
|
||||
kGOOGLE_PIN_UTNUSERFirstClientAuthenticationandEmailFingerprint,
|
||||
kGOOGLE_PIN_VeriSignClass1Fingerprint,
|
||||
kGOOGLE_PIN_AddTrustPublicCARootFingerprint,
|
||||
kGOOGLE_PIN_UTNDATACorpSGCFingerprint,
|
||||
kGOOGLE_PIN_SecureCertificateServicesFingerprint,
|
||||
kGOOGLE_PIN_GeoTrustPrimaryFingerprint,
|
||||
kGOOGLE_PIN_VeriSignClass3_G3Fingerprint,
|
||||
kGOOGLE_PIN_UTNUSERFirstHardwareFingerprint,
|
||||
kGOOGLE_PIN_VeriSignClass3_G4Fingerprint,
|
||||
kGOOGLE_PIN_VeriSignClass4_G3Fingerprint,
|
||||
kDigiCert_High_Assurance_EV_Root_CAFingerprint,
|
||||
kBaltimore_CyberTrust_RootFingerprint,
|
||||
kEntrust_Root_Certification_AuthorityFingerprint,
|
||||
kVerisign_Class_2_Public_Primary_Certification_Authority___G3Fingerprint,
|
||||
kGlobalSign_Root_CA___R3Fingerprint,
|
||||
kEntrust_Root_Certification_Authority___G2Fingerprint,
|
||||
kGOOGLE_PIN_GeoTrustUniversal2Fingerprint,
|
||||
kGOOGLE_PIN_GeoTrustGlobalFingerprint,
|
||||
kGOOGLE_PIN_GlobalSignRootCA_R2Fingerprint,
|
||||
kGOOGLE_PIN_AddTrustExternalCARootFingerprint,
|
||||
kGOOGLE_PIN_VeriSignUniversalFingerprint,
|
||||
kGOOGLE_PIN_GeoTrustUniversalFingerprint,
|
||||
kGOOGLE_PIN_Entrust_SSLFingerprint,
|
||||
kGOOGLE_PIN_GeoTrustPrimary_G3Fingerprint,
|
||||
kDigiCert_Global_Root_CAFingerprint,
|
||||
kGOOGLE_PIN_GeoTrustPrimary_G2Fingerprint,
|
||||
kComodo_AAA_Services_rootFingerprint,
|
||||
kTwitter1Fingerprint,
|
||||
kGOOGLE_PIN_AddTrustQualifiedCARootFingerprint,
|
||||
};
|
||||
static const StaticFingerprints kPinset_twitterCDN = {
|
||||
sizeof(kPinset_twitterCDN_Data) / sizeof(const char*),
|
||||
kPinset_twitterCDN_Data
|
||||
};
|
||||
|
||||
static const char* const kPinset_dropbox_Data[] = {
|
||||
kEntrust_Root_Certification_Authority___EC1Fingerprint,
|
||||
kEntrust_net_Premium_2048_Secure_Server_CAFingerprint,
|
||||
kDigiCert_Assured_ID_Root_CAFingerprint,
|
||||
kGo_Daddy_Root_Certificate_Authority___G2Fingerprint,
|
||||
kGOOGLE_PIN_GoDaddySecureFingerprint,
|
||||
kGo_Daddy_Class_2_CAFingerprint,
|
||||
kDigiCert_High_Assurance_EV_Root_CAFingerprint,
|
||||
kEntrust_Root_Certification_AuthorityFingerprint,
|
||||
kEntrust_Root_Certification_Authority___G2Fingerprint,
|
||||
kDigiCert_Global_Root_CAFingerprint,
|
||||
};
|
||||
static const StaticFingerprints kPinset_dropbox = {
|
||||
sizeof(kPinset_dropbox_Data) / sizeof(const char*),
|
||||
kPinset_dropbox_Data
|
||||
};
|
||||
|
||||
static const char* const kPinset_facebook_Data[] = {
|
||||
kCOMODO_ECC_Certification_AuthorityFingerprint,
|
||||
kISRG_Root_X1Fingerprint,
|
||||
kUSERTrust_ECC_Certification_AuthorityFingerprint,
|
||||
kGlobalSign_Root_CAFingerprint,
|
||||
kGOOGLE_PIN_DigiCertECCSecureServerCAFingerprint,
|
||||
kDigiCert_Trusted_Root_G4Fingerprint,
|
||||
kDigiCert_High_Assurance_EV_Root_CAFingerprint,
|
||||
kGlobalSign_Root_CA___R6Fingerprint,
|
||||
kDigiCert_TLS_RSA4096_Root_G5Fingerprint,
|
||||
kGlobalSign_Root_CA___R3Fingerprint,
|
||||
kISRG_Root_X2Fingerprint,
|
||||
kGOOGLE_PIN_SymantecClass3EVG3Fingerprint,
|
||||
kCOMODO_RSA_Certification_AuthorityFingerprint,
|
||||
kDigiCert_Global_Root_G2Fingerprint,
|
||||
kDigiCert_TLS_ECC_P384_Root_G5Fingerprint,
|
||||
kFacebookBackupFingerprint,
|
||||
kDigiCert_Global_Root_CAFingerprint,
|
||||
kGlobalSign_Root_R46Fingerprint,
|
||||
kDigiCert_Global_Root_G3Fingerprint,
|
||||
kUSERTrust_RSA_Certification_AuthorityFingerprint,
|
||||
};
|
||||
static const StaticFingerprints kPinset_facebook = {
|
||||
sizeof(kPinset_facebook_Data) / sizeof(const char*),
|
||||
kPinset_facebook_Data
|
||||
};
|
||||
|
||||
static const char* const kPinset_spideroak_Data[] = {
|
||||
kSpiderOak2Fingerprint,
|
||||
kSpiderOak3Fingerprint,
|
||||
kDigiCert_High_Assurance_EV_Root_CAFingerprint,
|
||||
kGOOGLE_PIN_GeoTrustGlobalFingerprint,
|
||||
};
|
||||
static const StaticFingerprints kPinset_spideroak = {
|
||||
sizeof(kPinset_spideroak_Data) / sizeof(const char*),
|
||||
kPinset_spideroak_Data
|
||||
};
|
||||
|
||||
static const char* const kPinset_yahoo_Data[] = {
|
||||
kDigiCert_Assured_ID_Root_CAFingerprint,
|
||||
kGlobalSign_Root_CAFingerprint,
|
||||
|
@ -597,19 +379,6 @@ static const StaticFingerprints kPinset_yahoo = {
|
|||
kPinset_yahoo_Data
|
||||
};
|
||||
|
||||
static const char* const kPinset_swehackCom_Data[] = {
|
||||
kSwehackFingerprint,
|
||||
kGOOGLE_PIN_DSTRootCAX3Fingerprint,
|
||||
kLet_s_Encrypt_Authority_X3Fingerprint,
|
||||
kGOOGLE_PIN_COMODORSADomainValidationSecureServerCAFingerprint,
|
||||
kLet_s_Encrypt_Authority_X4Fingerprint,
|
||||
kSwehackBackupFingerprint,
|
||||
};
|
||||
static const StaticFingerprints kPinset_swehackCom = {
|
||||
sizeof(kPinset_swehackCom_Data) / sizeof(const char*),
|
||||
kPinset_swehackCom_Data
|
||||
};
|
||||
|
||||
/* Domainlist */
|
||||
struct TransportSecurityPreload {
|
||||
// See bug 1338873 about making these fields const.
|
||||
|
@ -631,7 +400,6 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "admin.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "android.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "api.accounts.firefox.com", true, false, true, 5, &kPinset_mozilla_services },
|
||||
{ "api.twitter.com", true, false, false, -1, &kPinset_twitterCDN },
|
||||
{ "apis.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "appengine.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "apps.facebook.com", true, false, false, -1, &kPinset_facebook },
|
||||
|
@ -650,7 +418,6 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "bugs.chromium.org", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "build.chromium.org", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "business.facebook.com", true, false, false, -1, &kPinset_facebook },
|
||||
{ "business.twitter.com", true, false, false, -1, &kPinset_twitterCom },
|
||||
{ "ca.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "calendar.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "cd.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
|
@ -690,7 +457,6 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "ct.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "datastudio.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "de.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "dev.twitter.com", true, false, false, -1, &kPinset_twitterCom },
|
||||
{ "developer.android.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "developers.facebook.com", true, false, false, -1, &kPinset_facebook },
|
||||
{ "dist.torproject.org", true, false, false, -1, &kPinset_tor },
|
||||
|
@ -703,9 +469,6 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "doubleclick.net", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "download.mozilla.org", false, false, true, 14, &kPinset_mozilla_services },
|
||||
{ "drive.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "dropbox.com", true, false, false, -1, &kPinset_dropbox },
|
||||
{ "dropboxstatic.com", false, true, false, -1, &kPinset_dropbox },
|
||||
{ "dropboxusercontent.com", false, true, false, -1, &kPinset_dropbox },
|
||||
{ "edit.yahoo.com", true, true, false, -1, &kPinset_yahoo },
|
||||
{ "en-maktoob.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "encrypted.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
|
@ -713,7 +476,7 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "espanol.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "example.test", true, true, false, -1, &kPinset_test },
|
||||
{ "exclude-subdomains.pinning.example.com", false, false, false, -1, &kPinset_mozilla_test },
|
||||
{ "facebook.com", false, false, false, -1, &kPinset_facebook },
|
||||
{ "facebook.com", true, false, false, -1, &kPinset_facebook },
|
||||
{ "fi.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "fi.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "firebaseio.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
|
@ -1001,8 +764,7 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "market.android.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "mbasic.facebook.com", true, false, false, -1, &kPinset_facebook },
|
||||
{ "meet.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "messenger.com", false, false, false, -1, &kPinset_facebook },
|
||||
{ "mobile.twitter.com", true, false, false, -1, &kPinset_twitterCom },
|
||||
{ "messenger.com", true, false, false, -1, &kPinset_facebook },
|
||||
{ "mt.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "mtouch.facebook.com", true, false, false, -1, &kPinset_facebook },
|
||||
{ "mu.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
|
@ -1015,7 +777,6 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "no.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "np.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "nz.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "oauth.twitter.com", true, false, false, -1, &kPinset_twitterCom },
|
||||
{ "oauthaccountmanager.googleapis.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "pa.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "passwords.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
|
@ -1029,7 +790,6 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "pixel.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "pk.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "pl.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "platform.twitter.com", true, false, false, -1, &kPinset_twitterCDN },
|
||||
{ "play.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "plus.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "plus.sandbox.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
|
@ -1050,12 +810,10 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "services.mozilla.com", true, false, true, 6, &kPinset_mozilla_services },
|
||||
{ "sg.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "sites.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "spideroak.com", true, false, false, -1, &kPinset_spideroak },
|
||||
{ "spreadsheets.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "static.googleadsserving.cn", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "stats.g.doubleclick.net", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "sv.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "swehack.org", true, true, false, -1, &kPinset_swehackCom },
|
||||
{ "sync.services.mozilla.com", true, false, true, 13, &kPinset_mozilla_services },
|
||||
{ "t.facebook.com", true, false, false, -1, &kPinset_facebook },
|
||||
{ "tablet.facebook.com", true, false, false, -1, &kPinset_facebook },
|
||||
|
@ -1073,8 +831,6 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "tunnel.googlezip.net", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "tv.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "tw.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "twimg.com", true, false, false, -1, &kPinset_twitterCDN },
|
||||
{ "twitter.com", true, false, false, -1, &kPinset_twitterCDN },
|
||||
{ "ua.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "ua5v.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "uk.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
|
@ -1101,7 +857,6 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "wf-trial-hrd.appspot.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "withgoogle.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "withyoutube.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "www.dropbox.com", true, false, false, -1, &kPinset_dropbox },
|
||||
{ "www.facebook.com", true, false, false, -1, &kPinset_facebook },
|
||||
{ "www.g.co", false, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "www.gmail.com", false, false, false, -1, &kPinset_google_root_pems },
|
||||
|
@ -1109,7 +864,6 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "www.googlemail.com", false, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "www.messenger.com", true, false, false, -1, &kPinset_facebook },
|
||||
{ "www.torproject.org", true, false, false, -1, &kPinset_tor },
|
||||
{ "www.twitter.com", true, false, false, -1, &kPinset_twitterCom },
|
||||
{ "xa.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
{ "xbrlsuccess.appspot.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
{ "xn--7xa.google.com", true, false, false, -1, &kPinset_google_root_pems },
|
||||
|
@ -1121,8 +875,8 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
|||
{ "zh.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
|
||||
};
|
||||
|
||||
// Pinning Preload List Length = 496;
|
||||
// Pinning Preload List Length = 481;
|
||||
|
||||
static const int32_t kUnknownId = -1;
|
||||
|
||||
static const PRTime kPreloadPKPinsExpirationTime = INT64_C(1669892929282000);
|
||||
static const PRTime kPreloadPKPinsExpirationTime = INT64_C(1701082122257000);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -337,31 +337,38 @@ sec_pkcs12_decoder_safe_bag_update(void *arg, const char *data,
|
|||
SEC_PKCS12DecoderContext *p12dcx;
|
||||
SECStatus rv;
|
||||
|
||||
/* make sure that we are not skipping the current safeBag,
|
||||
* and that there are no errors. If so, just return rather
|
||||
* than continuing to process.
|
||||
*/
|
||||
if (!safeContentsCtx || !safeContentsCtx->p12dcx ||
|
||||
safeContentsCtx->p12dcx->error || safeContentsCtx->skipCurrentSafeBag) {
|
||||
if (!safeContentsCtx || !safeContentsCtx->p12dcx || !safeContentsCtx->currentSafeBagA1Dcx) {
|
||||
return;
|
||||
}
|
||||
p12dcx = safeContentsCtx->p12dcx;
|
||||
|
||||
/* make sure that there are no errors and we are not skipping the current safeBag */
|
||||
if (p12dcx->error || safeContentsCtx->skipCurrentSafeBag) {
|
||||
goto loser;
|
||||
}
|
||||
|
||||
rv = SEC_ASN1DecoderUpdate(safeContentsCtx->currentSafeBagA1Dcx, data, len);
|
||||
if (rv != SECSuccess) {
|
||||
p12dcx->errorValue = PORT_GetError();
|
||||
p12dcx->error = PR_TRUE;
|
||||
goto loser;
|
||||
}
|
||||
|
||||
/* The update may have set safeContentsCtx->skipCurrentSafeBag, and we
|
||||
* may not get another opportunity to clean up the decoder context.
|
||||
*/
|
||||
if (safeContentsCtx->skipCurrentSafeBag) {
|
||||
goto loser;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
loser:
|
||||
/* set the error, and finish the decoder context. because there
|
||||
/* Finish the decoder context. Because there
|
||||
* is not a way of returning an error message, it may be worth
|
||||
* while to do a check higher up and finish any decoding contexts
|
||||
* that are still open.
|
||||
*/
|
||||
p12dcx->error = PR_TRUE;
|
||||
SEC_ASN1DecoderFinish(safeContentsCtx->currentSafeBagA1Dcx);
|
||||
safeContentsCtx->currentSafeBagA1Dcx = NULL;
|
||||
return;
|
||||
|
|
|
@ -73,6 +73,7 @@ struct sec_PKCS12SafeBagStr {
|
|||
sec_PKCS12CRLBag *crlBag;
|
||||
sec_PKCS12SecretBag *secretBag;
|
||||
sec_PKCS12SafeContents *safeContents;
|
||||
SECItem *unknownBag;
|
||||
} safeBagContent;
|
||||
|
||||
sec_PKCS12Attribute **attribs;
|
||||
|
|
|
@ -30,12 +30,12 @@ sec_pkcs12_choose_safe_bag_type(void *src_or_dest, PRBool encoding)
|
|||
|
||||
oiddata = SECOID_FindOID(&safeBag->safeBagType);
|
||||
if (oiddata == NULL) {
|
||||
return SEC_ASN1_GET(SEC_AnyTemplate);
|
||||
return SEC_ASN1_GET(SEC_PointerToAnyTemplate);
|
||||
}
|
||||
|
||||
switch (oiddata->offset) {
|
||||
default:
|
||||
theTemplate = SEC_ASN1_GET(SEC_AnyTemplate);
|
||||
theTemplate = SEC_ASN1_GET(SEC_PointerToAnyTemplate);
|
||||
break;
|
||||
case SEC_OID_PKCS12_V1_KEY_BAG_ID:
|
||||
theTemplate = SEC_ASN1_GET(SECKEY_PointerToPrivateKeyInfoTemplate);
|
||||
|
|
Loading…
Reference in New Issue