mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-30 12:25:10 +01:00
Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6085d40c1 | ||
|
|
34571a294c | ||
|
|
eb1340b403 | ||
|
|
18bbce21c4 | ||
|
|
447948bfdf | ||
|
|
a76434685e | ||
|
|
be3a5962cc | ||
|
|
1902f96b24 | ||
|
|
b3bf56b63c | ||
|
|
1c55c421a9 | ||
|
|
fc871bad45 | ||
|
|
e05a703754 | ||
|
|
a842388c8f |
No files matched your search
+1
-1
@@ -531,7 +531,7 @@ update:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; cvs -q update -rRELENG_4 -P -d
|
||||
cd ${.CURDIR}; cvs -q update -rRELENG_4_9 -P -d
|
||||
.endif
|
||||
|
||||
#
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
divert(-1)
|
||||
#
|
||||
# Copyright (c) 2001-2003 Sendmail, Inc. and its suppliers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# By using this file, you agree to the terms and conditions set
|
||||
# forth in the LICENSE file which can be found at the top level of
|
||||
# the sendmail distribution.
|
||||
#
|
||||
#
|
||||
|
||||
#
|
||||
# This is the FreeBSD configuration for a set-group-ID sm-msp sendmail
|
||||
# that acts as a initial mail submission program.
|
||||
#
|
||||
#
|
||||
|
||||
divert(0)dnl
|
||||
VERSIONID(`$FreeBSD$')
|
||||
define(`confCF_VERSION', `Submit')dnl
|
||||
define(`__OSTYPE__',`')dnl dirty hack to keep proto.m4 from complaining
|
||||
define(`_USE_DECNET_SYNTAX_', `1')dnl support DECnet
|
||||
define(`confTIME_ZONE', `USE_TZ')dnl
|
||||
define(`confDONT_INIT_GROUPS', `True')dnl
|
||||
define(`confBIND_OPTS', `WorkAroundBrokenAAAA')dnl
|
||||
dnl
|
||||
dnl If you use IPv6 only, change [127.0.0.1] to [IPv6:::1]
|
||||
FEATURE(`msp', `[127.0.0.1]')dnl
|
||||
@@ -1,823 +0,0 @@
|
||||
%% $FreeBSD$
|
||||
%% From The War Against The Chtorr,
|
||||
%% Copyright David Gerrold, 1984-2000, all rights reserved,
|
||||
%% used with permission of the author.
|
||||
%%
|
||||
%%© This is the copyright line.
|
||||
%%Eighty-nine is the year we assign.
|
||||
%% These verses are caroled
|
||||
%% by one David Gerrold.
|
||||
%%All rights are reserved. This is mine. *
|
||||
%%
|
||||
A limerick of classic proportion
|
||||
should have meter and rhyme and a portion
|
||||
of humor quite lewd,
|
||||
and a frightfully crude,
|
||||
impossible sexual contortion.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A limerick is best when it's lewd,
|
||||
gross, titillating and crude --
|
||||
but this one is clean,
|
||||
unless you are seen
|
||||
reading it aloud in the nude.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
I wanted to print here a medley
|
||||
of limericks so gross they were deadly,
|
||||
but when the typesetter tried
|
||||
to set them, he died;
|
||||
(not to mention my editor, Smedly.)
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
I have written some limericks quite fateful,
|
||||
malicious and vicious and hateful;
|
||||
but I've torn up the jokes
|
||||
that will sicken most folks,
|
||||
and humanity ought to be grateful.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young lady named Susie,
|
||||
Who everyone thought was a floozy.
|
||||
She liked boy scout troops
|
||||
and Shriners, in groups;
|
||||
"What the hell?" She replied. "I'm not choosy."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A fellow who lived in West Perkin
|
||||
was always a-jerkin' his gherkin.
|
||||
Said he, "It's not fickle
|
||||
to play with my pickle.
|
||||
At least my gherkin's a workin'."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A proctologist name of McGee
|
||||
once bent over double to see
|
||||
an eyeball of glass
|
||||
he had shoved up his ass,
|
||||
"-- so I can see one that looks back at me."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Bart has a singular penis
|
||||
for his wife who is built like a Venus.
|
||||
He awoke with a fright
|
||||
last Saturday night:
|
||||
"Hey! Something is coming between us!"
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A lady who lives in New Delhi
|
||||
has habits disgusting and smelhi.
|
||||
She likes to eat feces
|
||||
of various species.
|
||||
(The recipe is tattooed or her belhi.)
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A daisy chain isn't a riddle.
|
||||
just some folks who are happy to fiddle,
|
||||
by twos and by threes,
|
||||
on their backs or their knees,
|
||||
and it's fun getting caught in the middle!
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A lad with a marvelous bend
|
||||
has no need of a lover or friend.
|
||||
What he does to himself
|
||||
would fill up a shelf,
|
||||
but alas, he has come to his end.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was an old witch, name of Jessie
|
||||
whose crotch was all smelly and messie.
|
||||
She enjoyed a good squirm
|
||||
with an alien worm
|
||||
-- and got stains all over her dressie!
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A lady who favors coition,
|
||||
has invented the spaceship position.
|
||||
She lies down with ease
|
||||
and pulls up her knees,
|
||||
and hollers, "Lift off!" and "Ignitions!"
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Isaac the famous seducer,
|
||||
will meet a young lass and conducer
|
||||
to let him get fresh
|
||||
with her quivering flesh,
|
||||
but if there isn't the time, he'll just gucer.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
And old man of Texas named Tanners
|
||||
was notorious for his bad manners.
|
||||
When he noticed the start
|
||||
of an imminent fart,
|
||||
he'd announce it with bullhorns and banners.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A woman who wanted to see,
|
||||
if she stood up, how far she could pee,
|
||||
had pardon to beg,
|
||||
when it ran down her leg,
|
||||
and formed icicles off her left knee.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A promiscuous sort was dear Laurie
|
||||
(Yes, this is that kind of story.)
|
||||
She did it with Joe
|
||||
and Larry and Moe
|
||||
and Curly and Howard and Morrie.
|
||||
|
||||
And Johnny and Richard and Pritchard and Kerry
|
||||
And Lonnie and Horace and Boris and Barry
|
||||
and Donald and Harold
|
||||
and Ronald and Gerald
|
||||
and Tommy and Dicky and Harry.
|
||||
|
||||
And . . . Peter and Paul and Teddy and Todd
|
||||
and Matthew and Mark and Simon and Rod
|
||||
and Brucie and Mark
|
||||
and Bobby and Clarck
|
||||
and she still isn't finished! My God!
|
||||
|
||||
And David and Dennis and Huey and Ken
|
||||
and Dewey and Louie, then David again,
|
||||
and Willy and Ben
|
||||
and David again
|
||||
and again and again and again.
|
||||
|
||||
And Danny and Manny and Gary and Fred
|
||||
and Mackie and Jackie and Dougie and Ned
|
||||
and Harvey and Len
|
||||
(then David again)
|
||||
and -- hold on just a second, she's dead!
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young man from St. Loo,
|
||||
who gave his dear sister a screw.
|
||||
Said he, with aplomb,
|
||||
"You're better than Mom."
|
||||
Said she, "That's what Dad told me too!"
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A lady who didn't like flies
|
||||
managed to hide her surprise,
|
||||
when she opened up one
|
||||
and found it was fun.
|
||||
Now she willingly widens her thighs.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young lady named Nancy,
|
||||
who liked having sex, plain of fancy.
|
||||
With lightning and thunder,
|
||||
and a profound sense of wonder,
|
||||
But not with a partner -- much too chancy.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young lady quite tearful.
|
||||
Of sucking a cock, she was fearful.
|
||||
In a moment of dreard,
|
||||
she just turned her head.
|
||||
And, boy! Did she get an earful!
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A mathematician named Boris
|
||||
had a wife with a wondrous clitoris.
|
||||
He charged a small fee
|
||||
for his colleagues to see
|
||||
that it was made in the shape of a torus.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
The ladies all had to agree
|
||||
that Mort's penis was too small to see.
|
||||
A whore named Louise
|
||||
sniffed, "Who will _that_ please?"
|
||||
Mort proudly submitted, "Just me!"
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young fellow named Fisk
|
||||
whose comings and goings were brisk,
|
||||
He hid things that were stolen
|
||||
inside his colon,
|
||||
and said, "Hey! It's my own *."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A stunning young lady named Joan
|
||||
thought a penis was made with a bone.
|
||||
She just didn't know
|
||||
'twas her sexual glow
|
||||
that turned parts of men into stone.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A midwife named Flo from Arabia
|
||||
often enjoys giving baby a
|
||||
forty-volt shock
|
||||
to the base of the cock.
|
||||
(On a girl, she goes for the labia.)
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
I know of a lass who's for sale.
|
||||
She's really a nice piece of tail.
|
||||
From June to September,
|
||||
she'll devour your member,
|
||||
but the rest of the year, she's in jail.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Miss Wilkerson thought it her duty
|
||||
to maintain her conjugal beauty.
|
||||
She mixed up a paste
|
||||
of industrial waste,
|
||||
and applied it to her sweet patootie.*
|
||||
|
||||
* The facts about beauty are known,
|
||||
and well-learned by those who are grown:
|
||||
beauty is thin,
|
||||
it lies on the skin;
|
||||
but ugly goes down to the bone.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
The punctual Cynthia Rolen
|
||||
missed a period, (or it was stolen)
|
||||
She looked up her ass
|
||||
with a tube made of glass,
|
||||
but found only her own semi-colon;
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A short-organ fellow named Kevin
|
||||
used a vacuum to stretch it to seven,
|
||||
then to eight and to nine,
|
||||
and though ten was divine,
|
||||
there will be film at eleven.*
|
||||
|
||||
* If you think that our boy's now a stud,
|
||||
you've been fooled by the size of his pud.
|
||||
Although twelve inches soft,
|
||||
when it rises aloft,
|
||||
he just faints from the sheer lack of blood.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There once was a lady named Lizard,
|
||||
who got lost in a pink candy blizzard,
|
||||
with a fellow named Jim
|
||||
who wanted to swim
|
||||
up her legs to visit her gizzard.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young fellow named Ted,
|
||||
who had a radio put in his head.
|
||||
Long wave or short
|
||||
he did it for sport
|
||||
-- and to improve his reception in bed.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young lady from Venus,
|
||||
whose body was shaped like a penis.
|
||||
A fellow named Hunt
|
||||
was shaped like a cunt,
|
||||
so it all worked out fine, just between us.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was an old bastard named Gene,
|
||||
impotent, selfish, and mean.
|
||||
His dick was so shamed
|
||||
by what the man claimed,
|
||||
it pretended that is was a spleen.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There once was a fellow named Jason,
|
||||
whose horrible death I would hasten.
|
||||
I'd feed him to worms,
|
||||
just to see how he squirms
|
||||
-- but they'd vomit his crap in a basin.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
With a French lass, it's unwise to trifle.
|
||||
They have urges they simply can't stifle.
|
||||
A woman of France
|
||||
will pull down her pants
|
||||
at the sight of a towering eye-full.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
"My God!" screamed devout Mrs. Pike,
|
||||
as she fondled her stableman's spike.
|
||||
"This is quite out of place,
|
||||
and a great loss of face
|
||||
-- but I think I have fallen in like!"
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A well-endower fellow from Ortening
|
||||
prepared for an evening of sportening,
|
||||
with a boy from a disco,
|
||||
till he lubed up his Crisco,
|
||||
and discovered, alas, it was _shortening_!
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A lady who read Sigmund Freud,
|
||||
thought her genitals underemployed;
|
||||
so she put in a stand
|
||||
for a seven-piece band,
|
||||
and held dances that we all enjoyed.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A lady named Shirley was mellow
|
||||
and she said to her eager young fellow,
|
||||
"I prefer bagels and lox
|
||||
to sucking off cocks,
|
||||
Or even a nice dish of Jell-O!"
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young man from St. Helens
|
||||
afflicted with shrinkin's and swellin's.
|
||||
His dick was so small
|
||||
it was not there at all,
|
||||
but his balls looked like honeydew melons.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A woman who once faked a lettera
|
||||
reference by which she could gettera
|
||||
job much improved,
|
||||
regretted her move
|
||||
when they asked her to show her et cetera.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A lady of South Madagascar
|
||||
wears a bag on her head; it's to mask her.
|
||||
A bottle of scotch
|
||||
might loosen her crotch.
|
||||
Wait here, I'll go and I'll ask her.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Chuck is weird, let the whole world know it.
|
||||
He brought in his bucket to show it.
|
||||
We all had a fit
|
||||
when we saw it was shit.
|
||||
We didn't know he was planning to throw it.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
"Which partners are best? Sixty-niners.
|
||||
And better than that? Try the Shriners."
|
||||
These are the results
|
||||
of consenting adults,
|
||||
(and occasional like-minded minors.)
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A lady's iambic pentameter
|
||||
is thirty-two inches diameter.
|
||||
The breadth of her scansion
|
||||
is due to expansion
|
||||
in the pants of a critical amateur.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young fellow from Norwich
|
||||
Who liked having sex with his porridge.
|
||||
With sugar and cream
|
||||
and a buttery scream --
|
||||
(The leftovers went into storage.)
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young fellow named Jim
|
||||
who liked to get naked and swim
|
||||
with plastic sex toys
|
||||
shaped like pubescent boys,
|
||||
'cause he'd rather be gay than be grim.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A lady who jogged in the breeze
|
||||
had bosoms that flapped to her knees.
|
||||
Said she, "They're quite warm,
|
||||
they keep me dry in a storm,
|
||||
and when it snows, I use them for skis."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was an old voyeur named Zeke,
|
||||
who liked to hide in the closet and peek,
|
||||
then jump out with loud cries
|
||||
of "Aha!" and "Surprise!"
|
||||
and point out your flaws in technique.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Rick promised to gently deflower
|
||||
a maiden who lived on South Gower,
|
||||
(The truth is, he spread
|
||||
her legs wide on the bed,
|
||||
and finsihed her off in an hour.)
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
These poems have come out of my forehead.
|
||||
The subject are all fairly torrid
|
||||
-- except for the few
|
||||
that will make you say, "Pugh!"
|
||||
And those are the ones that are horrid.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Juanita, the subject of scandals,
|
||||
used to use unscented candles,
|
||||
but now thinks it nice
|
||||
to use a device
|
||||
with batteries, buzzers, and handles.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was an old prune name of Ginty
|
||||
who only ate muffins and thin tea.
|
||||
Thinking of sex
|
||||
gave her the blecchs,
|
||||
and left her all dried up and squinty.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
I have written some limericks quite fateful,
|
||||
malicious and vicious and hateful;
|
||||
but I've torn up the jokes
|
||||
that would sicken most folks,
|
||||
and humanity ought ot be grateful;
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Here's the tale of Benjamin Sneed:
|
||||
Where others were two'd he was three'd
|
||||
and when they unmasked it,
|
||||
(three balls in his basket),
|
||||
he was voted "Most Likely to Breed."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A maiden who had a third breast
|
||||
always kept her hand close to her chest,
|
||||
and I promised her well
|
||||
that I never woudl tell.
|
||||
(Write me privately. Name on request.)
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Skydiver Daniel McDopp
|
||||
used to masturbate right from the top.
|
||||
Whenever he fell,
|
||||
he jerked off like hell.
|
||||
He was good to the very last drop.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A necrophile name of Ned Schultz,
|
||||
often brags of his deed and exults,
|
||||
"Tis legal, it's said,
|
||||
to make love to the dead,
|
||||
if performed by consenting adults."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Have you ever met Jamie McBeezis?
|
||||
He does any damn thing that he pleases.
|
||||
Says Jamie, undaunted,
|
||||
"If you've got it,then flaunt it!"
|
||||
But he's referring to social diseases.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There once was a nearsighted gynie
|
||||
whose glasses were sparkly and shiny;
|
||||
but they stayed in the drawer
|
||||
while he worked on a whore
|
||||
and tied up the tubes of her hiney.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A shepherd named Jimmie Fitzhugh,
|
||||
said to his sweetheart, "It's true.
|
||||
Nothing is moister
|
||||
than a fresh oister,
|
||||
unless, of course, it is ewe."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There's a reason why Barton is queer.
|
||||
When you meet him, the reason is clear.
|
||||
A goddess named Venus
|
||||
gave him a penis,
|
||||
but Mother Nature filled up his brassiere.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Then there was Benjamin Bright,
|
||||
a contestant on "What's My Delight?"
|
||||
They guesses at his habits
|
||||
with little white rabbits,
|
||||
but were stumped by his mouse and his kite.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young man from St. Lutz,
|
||||
who had a remarkable putz.
|
||||
It would sniff, it would hunt,
|
||||
for it only liked cunt.
|
||||
Absolutely no lips, hands, or butts.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Sally's sex life was carefully planned.
|
||||
Said she, "I prefer to be manned.
|
||||
Things that are anal,
|
||||
are always so banal,
|
||||
but things that expand are just grand."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Sally-Jo was exceedingly vexed,
|
||||
when they said she was quite oversexed.
|
||||
She said, "That's not true,
|
||||
I just like to screw,
|
||||
Now, please take a number. Who's next?"
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Sally sued for support; she was claimin'
|
||||
Phil had fathered her baby (named Damon).
|
||||
She said, "I ought to know."
|
||||
as she pointed below.
|
||||
"'Cause this is the box that he came in."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
We will need a computer to tally
|
||||
all the cowboys who scouted our Sally.
|
||||
There were some on her mountains
|
||||
and some on her fountains,
|
||||
and quite a few down in the valley.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A lady who overly lusted
|
||||
was frequently opened and thrusted.
|
||||
When the baby came due
|
||||
it was female too,
|
||||
and its hymen was already busted.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
When writing these verses of mine,
|
||||
I start with a clever last line,
|
||||
then work backward from there,
|
||||
toward the opening pair,
|
||||
with the hope it'll all work out fine.*
|
||||
|
||||
*only sometimes it doesn't.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There once was a whore from St. Paul,
|
||||
who took anyone, wide, short, or tall.
|
||||
She said to her clients,
|
||||
"It's not really science --
|
||||
it's just that one size will fit all!"
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young fellow named Forrest
|
||||
whose cornhole was one of the sorest.
|
||||
Said he, "I don't mind
|
||||
a regular grind
|
||||
-- but I do wish my ass were clitorised."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
When Shakespeare awakes with a scream
|
||||
and his member a-drippin' with cream,
|
||||
'tis just the commission
|
||||
of nocturnal emission,
|
||||
which he dubs, "A Mid-Slumber Night-Stream."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
Sally-Jo taught erotic correction.
|
||||
She told her student to get an erection.
|
||||
"Put your dick in my mouth.
|
||||
Move it north, move it south --
|
||||
Now, you're getting a sense of direction!"
|
||||
|
||||
Her instructions were very explicit,
|
||||
and more than a little illicit:
|
||||
"Please fill up my cunny
|
||||
with fresh clover honey,
|
||||
and butter my buns like a biscuit."
|
||||
|
||||
"Then wrap me up nice in a blanket,
|
||||
and I'll sit on your staff while you crank it.
|
||||
I'll put on some feathers,
|
||||
and laces and leathers,
|
||||
and wiggle my ass while you spank it."
|
||||
|
||||
"Now that your fingers are stinky,
|
||||
tie me up in some chains that are clinky.
|
||||
Bring in goats and a sheik,
|
||||
give my titties a tweak
|
||||
--and _now_, we can start getting kinky!"
|
||||
|
||||
"Forget what the chain and the whip meant.
|
||||
Just get the straps and the slings and a shipment
|
||||
of high-grade Vaseline,
|
||||
and a strong trampoline,
|
||||
and allof the other equipment!"
|
||||
|
||||
"Now, when we get all the bedsprings a-drummin',
|
||||
that's when I'll start in a-hummin',
|
||||
then quickly, my dear,
|
||||
put it into my ear,
|
||||
so I'll hear the sound of it comin'!"
|
||||
|
||||
"I don't know how much this is costing,"
|
||||
said her student, still covered with frosting.
|
||||
"But I can say with affinity
|
||||
that I've lost my virginity.
|
||||
Quite frankly, my dear, you're _exhausting_!"
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a mad pilot named Lizzy,
|
||||
whose manners were said to be skizzy.
|
||||
She could loop, she could twirl,
|
||||
she could make your head whirl.
|
||||
She left all her men fucking dizzy.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
The speed of Ed's seed is unclocked
|
||||
whenever a lady's unfrocked.
|
||||
Tho' his spirit is willin,
|
||||
when a pussy needs fillin',
|
||||
he's a man who goes off half-cocked.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A lady whose name is Tirelli
|
||||
has tits made of dynamite jelli.
|
||||
If you take on this dare,
|
||||
you must fondle with care.
|
||||
(The detonator's south of her belli.)
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
The fame of our Mame was her tushy,
|
||||
and the front of her cunt. (It was bushy.)
|
||||
But I heard that her Mike
|
||||
preferred for his spike
|
||||
the place in her face that was skwooshy.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A whore with a face like a hound
|
||||
complained that her sales were down,
|
||||
till a lover named Michael
|
||||
bought her a cycle,
|
||||
and she peddled it all over town.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
There was a young man named Levine
|
||||
who said to his lady, inclined,
|
||||
"Thanks for the spasm,
|
||||
it felt like orgasm;
|
||||
as a matter of fact, 'twas divine."
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
A king who was mad at the time,
|
||||
decreed limerick writing a crime.
|
||||
but late in the night
|
||||
all the poets woudl write
|
||||
verses without any rhyme or meter.
|
||||
|
||||
From The War Against The Chtorr, (c) David Gerrold, 1984-2000, all
|
||||
rights reserved, used with permission of the author.
|
||||
%
|
||||
@@ -52,7 +52,7 @@
|
||||
.ds doc-str-Lb-libvgl Video Graphics Library (libvgl, \-lvgl)
|
||||
.
|
||||
.\" Default .Os value
|
||||
.ds doc-operating-system FreeBSD\~4.8
|
||||
.ds doc-operating-system FreeBSD\~4.9
|
||||
.
|
||||
.\" FreeBSD releases not found in doc-common
|
||||
.ds doc-operating-system-FreeBSD-4.9 4.9
|
||||
|
||||
@@ -1,338 +0,0 @@
|
||||
/*-
|
||||
* alias_skinny.c
|
||||
*
|
||||
* Copyright (c) 2002, 2003 MarcusCom, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Author: Joe Marcus Clarke <[email protected]>
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/udp.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "alias_local.h"
|
||||
|
||||
/*
|
||||
* alias_skinny.c handles the translation for the Cisco Skinny Station
|
||||
* protocol. Skinny typically uses TCP port 2000 to set up calls between
|
||||
* a Cisco Call Manager and a Cisco IP phone. When a phone comes on line,
|
||||
* it first needs to register with the Call Manager. To do this it sends
|
||||
* a registration message. This message contains the IP address of the
|
||||
* IP phone. This message must then be translated to reflect our global
|
||||
* IP address. Along with the registration message (and usually in the
|
||||
* same packet), the phone sends an IP port message. This message indicates
|
||||
* the TCP port over which it will communicate.
|
||||
*
|
||||
* When a call is placed from the phone, the Call Manager will send an
|
||||
* Open Receive Channel message to the phone to let the caller know someone
|
||||
* has answered. The phone then sends back an Open Receive Channel
|
||||
* Acknowledgement. In this packet, the phone sends its IP address again,
|
||||
* and the UDP port over which the voice traffic should flow. These values
|
||||
* need translation. Right after the Open Receive Channel Acknowledgement,
|
||||
* the Call Manager sends a Start Media Transmission message indicating the
|
||||
* call is connected. This message contains the IP address and UDP port
|
||||
* number of the remote (called) party. Once this message is translated, the
|
||||
* call can commence. The called part sends the first UDP packet to the
|
||||
* calling phone at the pre-arranged UDP port in the Open Receive Channel
|
||||
* Acknowledgement.
|
||||
*
|
||||
* Skinny is a Cisco-proprietary protocol and is a trademark of Cisco Systems,
|
||||
* Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
/* #define DEBUG 1 */
|
||||
|
||||
/* Message types that need translating */
|
||||
#define REG_MSG 0x00000001
|
||||
#define IP_PORT_MSG 0x00000002
|
||||
#define OPNRCVCH_ACK 0x00000022
|
||||
#define START_MEDIATX 0x0000008a
|
||||
|
||||
struct skinny_header {
|
||||
u_int32_t len;
|
||||
u_int32_t reserved;
|
||||
u_int32_t msgId;
|
||||
};
|
||||
|
||||
struct RegisterMessage {
|
||||
u_int32_t msgId;
|
||||
char devName[16];
|
||||
u_int32_t uid;
|
||||
u_int32_t instance;
|
||||
u_int32_t ipAddr;
|
||||
u_char devType;
|
||||
u_int32_t maxStreams;
|
||||
};
|
||||
|
||||
struct IpPortMessage {
|
||||
u_int32_t msgId;
|
||||
u_int32_t stationIpPort; /* Note: Skinny uses 32-bit port
|
||||
* numbers */
|
||||
};
|
||||
|
||||
struct OpenReceiveChannelAck {
|
||||
u_int32_t msgId;
|
||||
u_int32_t status;
|
||||
u_int32_t ipAddr;
|
||||
u_int32_t port;
|
||||
u_int32_t passThruPartyID;
|
||||
};
|
||||
|
||||
struct StartMediaTransmission {
|
||||
u_int32_t msgId;
|
||||
u_int32_t conferenceID;
|
||||
u_int32_t passThruPartyID;
|
||||
u_int32_t remoteIpAddr;
|
||||
u_int32_t remotePort;
|
||||
u_int32_t MSPacket;
|
||||
u_int32_t payloadCap;
|
||||
u_int32_t precedence;
|
||||
u_int32_t silenceSuppression;
|
||||
u_short maxFramesPerPacket;
|
||||
u_int32_t G723BitRate;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
ClientToServer = 0,
|
||||
ServerToClient = 1
|
||||
} ConvDirection;
|
||||
|
||||
|
||||
static int
|
||||
alias_skinny_reg_msg(struct RegisterMessage *reg_msg, struct ip *pip,
|
||||
struct tcphdr *tc, struct alias_link *link,
|
||||
ConvDirection direction)
|
||||
{
|
||||
reg_msg->ipAddr = (u_int32_t) GetAliasAddress(link).s_addr;
|
||||
|
||||
tc->th_sum = 0;
|
||||
tc->th_sum = TcpChecksum(pip);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
alias_skinny_startmedia(struct StartMediaTransmission *start_media,
|
||||
struct ip *pip, struct tcphdr *tc,
|
||||
struct alias_link *link, u_int32_t localIpAddr,
|
||||
ConvDirection direction)
|
||||
{
|
||||
struct in_addr dst, src;
|
||||
|
||||
dst.s_addr = start_media->remoteIpAddr;
|
||||
src.s_addr = localIpAddr;
|
||||
|
||||
/* XXX I should probably handle in bound global translations as well. */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
alias_skinny_port_msg(struct IpPortMessage *port_msg, struct ip *pip,
|
||||
struct tcphdr *tc, struct alias_link *link,
|
||||
ConvDirection direction)
|
||||
{
|
||||
port_msg->stationIpPort = (u_int32_t) ntohs(GetAliasPort(link));
|
||||
|
||||
tc->th_sum = 0;
|
||||
tc->th_sum = TcpChecksum(pip);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
alias_skinny_opnrcvch_ack(struct OpenReceiveChannelAck *opnrcvch_ack,
|
||||
struct ip * pip, struct tcphdr *tc,
|
||||
struct alias_link *link, u_int32_t *localIpAddr,
|
||||
ConvDirection direction)
|
||||
{
|
||||
struct in_addr null_addr;
|
||||
struct alias_link *opnrcv_link;
|
||||
u_int32_t localPort;
|
||||
|
||||
*localIpAddr = (u_int32_t) opnrcvch_ack->ipAddr;
|
||||
localPort = opnrcvch_ack->port;
|
||||
|
||||
null_addr.s_addr = INADDR_ANY;
|
||||
opnrcv_link = FindUdpTcpOut(pip->ip_src, null_addr,
|
||||
htons((u_short) opnrcvch_ack->port), 0,
|
||||
IPPROTO_UDP, 1);
|
||||
opnrcvch_ack->ipAddr = (u_int32_t) GetAliasAddress(opnrcv_link).s_addr;
|
||||
opnrcvch_ack->port = (u_int32_t) ntohs(GetAliasPort(opnrcv_link));
|
||||
|
||||
tc->th_sum = 0;
|
||||
tc->th_sum = TcpChecksum(pip);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
AliasHandleSkinny(struct ip *pip, struct alias_link *link)
|
||||
{
|
||||
int hlen, tlen, dlen;
|
||||
struct tcphdr *tc;
|
||||
u_int32_t msgId, len, t, lip;
|
||||
struct skinny_header *sd;
|
||||
int orig_len, skinny_hdr_len = sizeof(struct skinny_header);
|
||||
ConvDirection direction;
|
||||
|
||||
tc = (struct tcphdr *) ((char *)pip + (pip->ip_hl << 2));
|
||||
hlen = (pip->ip_hl + tc->th_off) << 2;
|
||||
tlen = ntohs(pip->ip_len);
|
||||
dlen = tlen - hlen;
|
||||
|
||||
sd = (struct skinny_header *) ((char *)pip + hlen);
|
||||
|
||||
/*
|
||||
* XXX This direction is reserved for future use. I still need to
|
||||
* handle the scenario where the call manager is on the inside, and
|
||||
* the calling phone is on the global outside.
|
||||
*/
|
||||
if (ntohs(tc->th_dport) == skinnyPort) {
|
||||
direction = ClientToServer;
|
||||
} else if (ntohs(tc->th_sport) == skinnyPort) {
|
||||
direction = ServerToClient;
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,
|
||||
"PacketAlias/Skinny: Invalid port number, not a Skinny packet\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
orig_len = dlen;
|
||||
/*
|
||||
* Skinny packets can contain many messages. We need to loop through
|
||||
* the packet using len to determine message boundaries. This comes
|
||||
* into play big time with port messages being in the same packet as
|
||||
* register messages. Also, open receive channel acks are
|
||||
* usually buried in a pakcet some 400 bytes long.
|
||||
*/
|
||||
while (dlen >= skinny_hdr_len) {
|
||||
len = (sd->len);
|
||||
msgId = (sd->msgId);
|
||||
t = len;
|
||||
|
||||
if (t < 0 || t > orig_len || t > dlen) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,
|
||||
"PacketAlias/Skinny: Not a skinny packet, invalid length \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
switch (msgId) {
|
||||
case REG_MSG:
|
||||
{
|
||||
struct RegisterMessage *reg_mesg;
|
||||
|
||||
if (len < sizeof(struct RegisterMessage)) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,
|
||||
"PacketAlias/Skinny: Not a skinny packet, bad registration message\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
reg_mesg = (struct RegisterMessage *) & sd->msgId;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,
|
||||
"PacketAlias/Skinny: Received a register message");
|
||||
#endif
|
||||
alias_skinny_reg_msg(reg_mesg, pip, tc, link, direction);
|
||||
}
|
||||
break;
|
||||
case IP_PORT_MSG:
|
||||
{
|
||||
struct IpPortMessage *port_mesg;
|
||||
if (len < sizeof(struct IpPortMessage)) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,
|
||||
"PacketAlias/Skinny: Not a skinny packet, port message\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr
|
||||
"PacketAlias/Skinny: Received ipport message\n");
|
||||
#endif
|
||||
port_mesg = (struct IpPortMessage *) & sd->msgId;
|
||||
alias_skinny_port_msg(port_mesg, pip, tc, link, direction);
|
||||
}
|
||||
break;
|
||||
case OPNRCVCH_ACK:
|
||||
{
|
||||
struct OpenReceiveChannelAck *opnrcvchn_ack;
|
||||
|
||||
if (len < sizeof(struct OpenReceiveChannelAck)) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,
|
||||
"PacketAlias/Skinny: Not a skinny packet, packet,OpnRcvChnAckMsg\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,
|
||||
"PacketAlias/Skinny: Received open rcv channel msg\n");
|
||||
#endif
|
||||
opnrcvchn_ack = (struct OpenReceiveChannelAck *) & sd->msgId;
|
||||
alias_skinny_opnrcvch_ack(opnrcvchn_ack, pip, tc, link, &lip, direction);
|
||||
}
|
||||
break;
|
||||
case START_MEDIATX:
|
||||
{
|
||||
struct StartMediaTransmission *startmedia_tx;
|
||||
|
||||
if (len < sizeof(struct StartMediaTransmission)) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,
|
||||
"PacketAlias/Skinny: Not a skinny packet,StartMediaTx Message\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,
|
||||
"PacketAlias/Skinny: Received start media trans msg\n");
|
||||
#endif
|
||||
startmedia_tx = (struct StartMediaTransmission *) & sd->msgId;
|
||||
alias_skinny_startmedia(startmedia_tx, pip, tc, link, lip, direction);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* Place the pointer at the next message in the packet. */
|
||||
dlen -= len + (skinny_hdr_len - sizeof(msgId));
|
||||
sd = (struct skinny_header *) (((char *)&sd->msgId) + len);
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
.\" Copyright (c) 2002, 2003 Tim J. Robbins
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.Dd August 10, 2003
|
||||
.Dt GB18030 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm gb18030
|
||||
.Nd "GB 18030 encoding method for Chinese text"
|
||||
.Sh SYNOPSIS
|
||||
.Nm ENCODING
|
||||
.Qq GB18030
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm GB18030
|
||||
encoding implements GB 18030-2000, a PRC national standard for the encoding of
|
||||
Chinese characters.
|
||||
It is a superset of the older GB\ 2312-1980 and GBK encodings,
|
||||
and incorporates Unicode's Unihan Extension A completely.
|
||||
It also provides code space for all Unicode 3.0 code points.
|
||||
.Pp
|
||||
Multibyte characters in the
|
||||
.Nm GB18030
|
||||
encoding can be one byte, two bytes, or
|
||||
four bytes long.
|
||||
There are a total of over 1.5 million code positions.
|
||||
.Pp
|
||||
.No GB\ 11383-1981 ( Ns
|
||||
.Tn ASCII )
|
||||
characters are represented by single bytes in the range 0x00 to 0x7F.
|
||||
.Pp
|
||||
Chinese characters are represented as either two bytes or four bytes.
|
||||
Characters that are represented by two bytes begin with a byte in the range
|
||||
0x81-0xFE and end with a byte either in the range 0x40-0x7E or 0x80-0xFE.
|
||||
.Pp
|
||||
Characters that are represented by four bytes begin with a byte in the range
|
||||
0x81-0xFE, have a second byte in the range 0x30-0x39, a third byte in the range
|
||||
0x81-0xFE and a fourth byte in the range 0x30-0x39.
|
||||
.Sh SEE ALSO
|
||||
.Xr euc 4 ,
|
||||
.Xr gbk 5 ,
|
||||
.Xr utf8 5
|
||||
.Rs
|
||||
.%T "Chinese National Standard GB 18030-2000: Information Technology -- Chinese ideograms coded character set for information interchange -- Extension for the basic set"
|
||||
.%D "March 2000"
|
||||
.Re
|
||||
.Rs
|
||||
.%Q "The Unicode Consortium"
|
||||
.%T "The Unicode Standard, Version 3.0"
|
||||
.%D "2000"
|
||||
.Re
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm GB18030
|
||||
encoding is believed to be compatible with GB 18030-2000.
|
||||
@@ -1,166 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is contributed to Robin Hu <[email protected]>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <rune.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
rune_t _GB18030_sgetrune(const char *, size_t, char const **);
|
||||
int _GB18030_sputrune(rune_t, char *, size_t, char **);
|
||||
|
||||
int
|
||||
_GB18030_init(rl)
|
||||
_RuneLocale *rl;
|
||||
{
|
||||
rl->sgetrune = _GB18030_sgetrune;
|
||||
rl->sputrune = _GB18030_sputrune;
|
||||
_CurrentRuneLocale = rl;
|
||||
__mb_cur_max = 4;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static inline int
|
||||
_gb18030_check_string(s_, n)
|
||||
const char* s_;
|
||||
int n;
|
||||
{
|
||||
const unsigned char* s = s_;
|
||||
if ((s[0]>=0x81&&s[0]<=0xfe)) {
|
||||
if (n<2) goto bad_string;
|
||||
if ((s[1]>=0x40&&s[1]<=0x7e)||(s[1]>=0x80&&s[1]<=0xfe))
|
||||
return 2;
|
||||
if ((s[1]>=0x30&&s[1]<=0x39)) {
|
||||
if (n<4) goto bad_string;
|
||||
if ((s[2]>=0x81&&s[2]<=0xfe) && (s[3]>=0x30&&s[3]<=0x39))
|
||||
return 4;
|
||||
else
|
||||
goto bad_string;
|
||||
}
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
bad_string:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
_gb18030_check_rune(r)
|
||||
rune_t r;
|
||||
{
|
||||
if (r&0xff000000) {
|
||||
return 4;
|
||||
}
|
||||
if (r&0xff00) {
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
rune_t
|
||||
_GB18030_sgetrune(string, n, result)
|
||||
const char *string;
|
||||
size_t n;
|
||||
char const **result;
|
||||
{
|
||||
rune_t rune = 0;
|
||||
int len;
|
||||
|
||||
len = _gb18030_check_string(string, n);
|
||||
|
||||
if (len == -1) {
|
||||
if (result)
|
||||
*result = string;
|
||||
return (_INVALID_RUNE);
|
||||
}
|
||||
|
||||
while (--len >= 0)
|
||||
rune = (rune << 8) | ((u_int)(*string++) & 0xff);
|
||||
|
||||
rune &= 0x7fffffff;
|
||||
if (result)
|
||||
*result = string;
|
||||
return rune;
|
||||
}
|
||||
|
||||
int
|
||||
_GB18030_sputrune(c, string, n, result)
|
||||
rune_t c;
|
||||
char *string, **result;
|
||||
size_t n;
|
||||
{
|
||||
int len;
|
||||
len = _gb18030_check_rune(c);
|
||||
|
||||
switch (len) {
|
||||
case 1:
|
||||
if (n >= 1) {
|
||||
*string = c & 0xff;
|
||||
if (result)
|
||||
*result = string + 1;
|
||||
return (1);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (n >= 2) {
|
||||
string[0] = (c >> 8) & 0xff;
|
||||
string[1] = c & 0xff;
|
||||
if (result)
|
||||
*result = string + 2;
|
||||
return (2);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (n >= 4) {
|
||||
string[0] = ((c >>24) & 0xff) | 0x80;
|
||||
string[1] = (c >>16) & 0xff;
|
||||
string[2] = (c >>8) & 0xff;
|
||||
string[3] = c & 0xff;
|
||||
if (result)
|
||||
*result = string + 4;
|
||||
return (4);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (result)
|
||||
*result = string;
|
||||
return (0);
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
.\" Copyright (c) 2003 Tim J. Robbins
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.Dd August 10, 2003
|
||||
.Dt GBK 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm gbk
|
||||
.Nd "Guojia biaozhun kuozhan (GBK) encoding method for Chinese text"
|
||||
.Sh SYNOPSIS
|
||||
.Nm ENCODING
|
||||
.Qq GBK
|
||||
.Sh DESCRIPTION
|
||||
GBK is a backwards-compatible extension of the GB\ 2312-1980 encoding
|
||||
method for Chinese text, which adds the characters defined in the
|
||||
Unified Han portion of the Unicode 2.1 standard.
|
||||
.Pp
|
||||
Multibyte characters in the GBK
|
||||
encoding can be one byte or two bytes long.
|
||||
.No GB\ 11383-1981 ( Ns
|
||||
.Tn ASCII )
|
||||
characters are represented by single bytes in the range 0x00 to 0x7F.
|
||||
Chinese characters are represented by two bytes, beginning with a byte in
|
||||
the range 0x80-0xFE and ending with a byte in the range 0x40-0xFE.
|
||||
.Sh SEE ALSO
|
||||
.Xr euc 4 ,
|
||||
.Xr gb18030 5 ,
|
||||
.Xr utf8 5
|
||||
.Rs
|
||||
.%Q "The Unicode Consortium"
|
||||
.%T "The Unicode Standard, Version 2.1"
|
||||
.%D "1999"
|
||||
.Re
|
||||
.Rs
|
||||
.%T "Chinese National Standard GB 18030-2000: Information Technology -- Chinese ideograms coded character set for information interchange -- Extension for the basic set"
|
||||
.%D "March 2000"
|
||||
.Re
|
||||
.Sh STANDARDS
|
||||
GBK is not a standard, but has been superceded by
|
||||
GB\ 18030-2000.
|
||||
@@ -1,116 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Paul Borman at Krystal Technologies.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <rune.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
rune_t _GBK_sgetrune(const char *, size_t, char const **);
|
||||
int _GBK_sputrune(rune_t, char *, size_t, char **);
|
||||
|
||||
int
|
||||
_GBK_init(rl)
|
||||
_RuneLocale *rl;
|
||||
{
|
||||
rl->sgetrune = _GBK_sgetrune;
|
||||
rl->sputrune = _GBK_sputrune;
|
||||
_CurrentRuneLocale = rl;
|
||||
__mb_cur_max = 2;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static inline int
|
||||
_gbk_check(c)
|
||||
u_int c;
|
||||
{
|
||||
c &= 0xff;
|
||||
return ((c >= 0x80 && c <= 0xfe) ? 2 : 1);
|
||||
}
|
||||
|
||||
rune_t
|
||||
_GBK_sgetrune(string, n, result)
|
||||
const char *string;
|
||||
size_t n;
|
||||
char const **result;
|
||||
{
|
||||
rune_t rune = 0;
|
||||
int len;
|
||||
|
||||
if (n < 1 || (len = _gbk_check(*string)) > n) {
|
||||
if (result)
|
||||
*result = string;
|
||||
return (_INVALID_RUNE);
|
||||
}
|
||||
while (--len >= 0)
|
||||
rune = (rune << 8) | ((u_int)(*string++) & 0xff);
|
||||
if (result)
|
||||
*result = string;
|
||||
return rune;
|
||||
}
|
||||
|
||||
int
|
||||
_GBK_sputrune(c, string, n, result)
|
||||
rune_t c;
|
||||
char *string, **result;
|
||||
size_t n;
|
||||
{
|
||||
if (c & 0x8000) {
|
||||
if (n >= 2) {
|
||||
string[0] = (c >> 8) & 0xff;
|
||||
string[1] = c & 0xff;
|
||||
if (result)
|
||||
*result = string + 2;
|
||||
return (2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (n >= 1) {
|
||||
*string = c & 0xff;
|
||||
if (result)
|
||||
*result = string + 1;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
if (result)
|
||||
*result = string;
|
||||
return (0);
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
int lm_init (void);
|
||||
void lm_fini (void);
|
||||
char * lm_find (const char *, const char *);
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
#
|
||||
# Automatic SNAP versioning:
|
||||
DATE != date +%Y%m%d
|
||||
BASE = 4.8
|
||||
BASE = 4.9
|
||||
BUILDNAME?=${BASE}-${DATE}-STABLE
|
||||
#
|
||||
#CHROOTDIR=/junk/release
|
||||
|
||||
@@ -35,16 +35,6 @@
|
||||
(list (list "HREF" "mailto:[email protected]"))
|
||||
(literal "[email protected]"))
|
||||
(literal ">.")
|
||||
(make element gi: "p"
|
||||
attributes: (list (list "align" "center"))
|
||||
(make element gi: "small"
|
||||
(literal "All users of FreeBSD ")
|
||||
(literal (entity-text "release.branch"))
|
||||
(literal " should subscribe to the ")
|
||||
(literal "<")
|
||||
(create-link (list (list "HREF" "mailto:[email protected]"))
|
||||
(literal "[email protected]"))
|
||||
(literal "> mailing list.")))
|
||||
|
||||
(make element gi: "p"
|
||||
attributes: (list (list "align" "center"))
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Original revision: 1.6
|
||||
|
||||
RELN_ROOT?= ${.CURDIR}/../..
|
||||
|
||||
SUBDIR = alpha
|
||||
SUBDIR+= amd64
|
||||
SUBDIR+= ia64
|
||||
SUBDIR+= i386
|
||||
SUBDIR+= sparc64
|
||||
SUBDIR+= pc98
|
||||
|
||||
.include "${RELN_ROOT}/share/mk/doc.relnotes.mk"
|
||||
.include "${DOC_PREFIX}/share/mk/doc.project.mk"
|
||||
@@ -1,19 +0,0 @@
|
||||
<!-- -*- sgml -*- -->
|
||||
<!--
|
||||
$FreeBSD$
|
||||
Original revision: 1.5
|
||||
-->
|
||||
|
||||
<!-- Text constants which probably don't need to be changed.-->
|
||||
|
||||
<!-- Files to be included -->
|
||||
|
||||
<!ENTITY artheader SYSTEM "../common/artheader.sgml">
|
||||
<!ENTITY sect.intro SYSTEM "../common/intro.sgml">
|
||||
<!ENTITY sect.proc.alpha SYSTEM "../alpha/proc-alpha.sgml">
|
||||
<!ENTITY sect.proc.amd64 SYSTEM "../amd64/proc-amd64.sgml">
|
||||
<!ENTITY sect.proc.i386 SYSTEM "../i386/proc-i386.sgml">
|
||||
<!ENTITY sect.proc.ia64 SYSTEM "../ia64/proc-ia64.sgml">
|
||||
<!ENTITY sect.proc.sparc64 SYSTEM "../sparc64/proc-sparc64.sgml">
|
||||
<!ENTITY sect.proc.pc98 SYSTEM "../pc98/proc-pc98.sgml">
|
||||
<!ENTITY sect.dev SYSTEM "../common/dev.sgml">
|
||||
@@ -12,7 +12,7 @@ UNITEXTS= readme errata
|
||||
|
||||
IMAGEDIR= .imagedir
|
||||
RHOST= freefall.freebsd.org
|
||||
RDIR= public_html/relnotes/4-STABLE
|
||||
RDIR= public_html/relnotes/4.9-RELEASE
|
||||
DOCDIR= ./release/doc
|
||||
LANG= en_US.ISO8859-1
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<!-- Version of the OS we're describing. This needs to be updated
|
||||
with each new release. -->
|
||||
<!ENTITY release.current "4.9-RC">
|
||||
<!ENTITY release.current "4.9-RELEASE">
|
||||
|
||||
<!-- The previous version used for comparison in the "What's New"
|
||||
section. For -CURRENT, we might point back to the last
|
||||
@@ -14,26 +14,26 @@
|
||||
<!ENTITY release.prev "4.8-RELEASE">
|
||||
|
||||
<!-- The next version to be released, usually used for snapshots. -->
|
||||
<!ENTITY release.next "4.9-RELEASE">
|
||||
<!ENTITY release.next "4.9.1-RELEASE">
|
||||
|
||||
<!-- The name of this branch. -->
|
||||
<!ENTITY release.branch "4-STABLE">
|
||||
|
||||
<!-- The URL for obtaining this version of FreeBSD. -->
|
||||
<!ENTITY release.url "http://snapshots.jp.FreeBSD.org/">
|
||||
<!ENTITY release.url "ftp://ftp.FreeBSD.org/">
|
||||
|
||||
<!-- The type of release (usually this will be either "snapshot"
|
||||
or "release" -->
|
||||
<!ENTITY release.type "snapshot">
|
||||
<!ENTITY % release.type.snapshot "INCLUDE">
|
||||
<!ENTITY % release.type.release "IGNORE">
|
||||
<!ENTITY release.type "release">
|
||||
<!ENTITY % release.type.snapshot "IGNORE">
|
||||
<!ENTITY % release.type.release "INCLUDE">
|
||||
|
||||
<!-- The manpaths for man page references -->
|
||||
<!ENTITY release.man.url "http://www.FreeBSD.org/cgi/man.cgi">
|
||||
<!ENTITY release.manpath.xfree86 "4.3.0">
|
||||
<!ENTITY release.manpath.netbsd "1.6.1">
|
||||
<!ENTITY release.manpath.freebsd-ports "Ports">
|
||||
<!ENTITY release.manpath.freebsd "4.8-stable">
|
||||
<!ENTITY release.manpath.freebsd "4.9-RELEASE">
|
||||
|
||||
<!-- Text constants which probably don't need to be changed.-->
|
||||
|
||||
|
||||
@@ -1139,6 +1139,8 @@ installVarDefaults(dialogMenuItem *self)
|
||||
variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/links", 0);
|
||||
variable_set2(VAR_FTP_STATE, "passive", 0);
|
||||
variable_set2(VAR_NFS_SECURE, "NO", -1);
|
||||
variable_set2(VAR_NFS_TCP, "NO", -1);
|
||||
variable_set2(VAR_NFS_V3, "YES", -1);
|
||||
if (OnVTY)
|
||||
variable_set2(VAR_FIXIT_TTY, "standard", 0);
|
||||
else
|
||||
|
||||
@@ -60,9 +60,13 @@ mediaInitNFS(Device *dev)
|
||||
return FALSE;
|
||||
|
||||
msgNotify("Mounting %s over NFS on %s", dev->name, mountpoint);
|
||||
if (vsystem("mount_nfs %s %s %s %s",
|
||||
variable_get(VAR_SLOW_ETHER) ? "-r 1024 -w 1024" : "",
|
||||
variable_get(VAR_NFS_SECURE) ? "-P" : "", dev->name, mountpoint)) {
|
||||
if (vsystem("mount_nfs %s %s %s %s %s %s",
|
||||
!variable_cmp(VAR_NFS_TCP, "YES") ? "-T" : "",
|
||||
!variable_cmp(VAR_NFS_V3, "YES") ? "-3" : "",
|
||||
!variable_cmp(VAR_SLOW_ETHER, "YES") ?
|
||||
"-r 1024 -w 1024" : "-r 4096 -w 4096",
|
||||
!variable_cmp(VAR_NFS_SECURE, "YES") ? "-P" : "",
|
||||
dev->name, mountpoint)) {
|
||||
msgConfirm("Error mounting %s on %s: %s.", dev->name, mountpoint, strerror(errno));
|
||||
if (netDevice)
|
||||
DEVICE_SHUTDOWN(netDevice);
|
||||
|
||||
@@ -112,6 +112,10 @@ static Option Options[] = {
|
||||
OPT_IS_VAR, NULL, VAR_NFS_SECURE, varCheck },
|
||||
{ "NFS Slow", "User is using a slow PC or ethernet card",
|
||||
OPT_IS_VAR, NULL, VAR_SLOW_ETHER, varCheck },
|
||||
{ "NFS TCP", "Use TCP protocol for NFS",
|
||||
OPT_IS_VAR, NULL, VAR_NFS_TCP, varCheck },
|
||||
{ "NFS version 3", "Use NFS version 3",
|
||||
OPT_IS_VAR, NULL, VAR_NFS_V3, varCheck },
|
||||
{ "Debugging", "Emit extra debugging output on VTY2 (ALT-F2)",
|
||||
OPT_IS_VAR, NULL, VAR_DEBUG, varCheck },
|
||||
{ "No Warnings", "Don't Warn the user when a setting seems incorrect",
|
||||
|
||||
@@ -147,6 +147,8 @@
|
||||
#define VAR_NEWFS_ARGS "newfsArgs"
|
||||
#define VAR_NFS_PATH "nfs"
|
||||
#define VAR_NFS_HOST "nfsHost"
|
||||
#define VAR_NFS_V3 "nfs_use_v3"
|
||||
#define VAR_NFS_TCP "nfs_use_tcp"
|
||||
#define VAR_NFS_SECURE "nfs_reserved_port_only"
|
||||
#define VAR_NFS_SERVER "nfs_server_enable"
|
||||
#define VAR_NO_CONFIRM "noConfirm"
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
*default host=CHANGE_THIS.FreeBSD.org
|
||||
*default base=/usr
|
||||
*default prefix=/usr
|
||||
*default release=cvs tag=RELENG_4
|
||||
*default release=cvs tag=RELENG_4_9
|
||||
*default delete use-rel-suffix
|
||||
|
||||
# If your network link is a T1 or faster, comment out the following line.
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2003 Stuart Walsh
|
||||
.\"
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd September 4, 2003
|
||||
.Dt BFE 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm bfe
|
||||
.Nd Broadcom BCM4401 Ethernet Device Driver
|
||||
.Sh SYNOPSIS
|
||||
.Cd "device miibus"
|
||||
.Cd "device bfe"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
driver provides support for the Broadcom BCM4401 based Fast Ethernet adapters.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
driver supports the following media types:
|
||||
.Pp
|
||||
.Bl -tag -width xxxxxxxxxxxxxxxxxxxx
|
||||
.It autoselect
|
||||
Enable autoselection of the media type and options
|
||||
.It 10baseT/UTP
|
||||
Set 10Mbps operation
|
||||
.It 100baseTX
|
||||
Set 100Mbps (fast ethernet) operation
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
driver supports the following media options:
|
||||
.Pp
|
||||
.Bl -tag -width xxxxxxxxxxxxxxxxxxxx
|
||||
.It full-duplex
|
||||
Set full duplex operation
|
||||
.El
|
||||
.Pp
|
||||
For further information on configuring this device, see
|
||||
.Xr ifconfig 8 .
|
||||
.Pp
|
||||
.Sh DIAGNOSTICS
|
||||
.Bl -diag
|
||||
.It "bfe%d: couldn't map memory"
|
||||
A fatal initialization error has occurred.
|
||||
.It "bfe%d: couldn't map interrupt"
|
||||
A fatal initialization error has occurred.
|
||||
.It "bfe%d: failed to allocate DMA resources"
|
||||
There are not enough mbuf's available for allocation.
|
||||
.It "bfe%d: watchdog timeout -- resetting"
|
||||
The device has stopped responding to the network, or there is a problem with
|
||||
the network connection (cable).
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr arp 4 ,
|
||||
.Xr miibus 4 ,
|
||||
.Xr netintro 4 ,
|
||||
.Xr ng_ether 4 ,
|
||||
.Xr ifconfig 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
device driver first appeared in
|
||||
.Fx 5.1 .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
The
|
||||
.Nm
|
||||
device driver was written by
|
||||
.An Stuart Walsh
|
||||
and
|
||||
.An Duncan Barclay .
|
||||
This manual page was written by
|
||||
.An Stuart Walsh .
|
||||
@@ -1,917 +0,0 @@
|
||||
.\" Copyright (c) 2001-2003 International Computer Science Institute
|
||||
.\"
|
||||
.\" Permission is hereby granted, free of charge, to any person obtaining a
|
||||
.\" copy of this software and associated documentation files (the "Software"),
|
||||
.\" to deal in the Software without restriction, including without limitation
|
||||
.\" the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
.\" and/or sell copies of the Software, and to permit persons to whom the
|
||||
.\" Software is furnished to do so, subject to the following conditions:
|
||||
.\"
|
||||
.\" The above copyright notice and this permission notice shall be included in
|
||||
.\" all copies or substantial portions of the Software.
|
||||
.\"
|
||||
.\" The names and trademarks of copyright holders may not be used in
|
||||
.\" advertising or publicity pertaining to the software without specific
|
||||
.\" prior permission. Title to copyright in this software and any associated
|
||||
.\" documentation will at all times remain with the copyright holders.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
.\" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
.\" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
.\" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
.\" DEALINGS IN THE SOFTWARE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd September 4, 2003
|
||||
.Dt MULTICAST 4
|
||||
.Os
|
||||
.\"
|
||||
.Sh NAME
|
||||
.Nm multicast
|
||||
.Nd Multicast Routing
|
||||
.\"
|
||||
.Sh SYNOPSIS
|
||||
.Cd "options MROUTING"
|
||||
.Pp
|
||||
.In sys/types.h
|
||||
.In sys/socket.h
|
||||
.In netinet/in.h
|
||||
.In netinet/ip_mroute.h
|
||||
.In netinet6/ip6_mroute.h
|
||||
.Ft int
|
||||
.Fn getsockopt "int s" IPPROTO_IP MRT_INIT "void *optval" "socklen_t *optlen"
|
||||
.Ft int
|
||||
.Fn setsockopt "int s" IPPROTO_IP MRT_INIT "const void *optval" "socklen_t optlen"
|
||||
.Ft int
|
||||
.Fn getsockopt "int s" IPPROTO_IPV6 MRT6_INIT "void *optval" "socklen_t *optlen"
|
||||
.Ft int
|
||||
.Fn setsockopt "int s" IPPROTO_IPV6 MRT6_INIT "const void *optval" "socklen_t optlen"
|
||||
.Sh DESCRIPTION
|
||||
.Tn "Multicast routing"
|
||||
is used to efficiently propagate data
|
||||
packets to a set of multicast listeners in multipoint networks.
|
||||
If unicast is used to replicate the data to all listeners,
|
||||
then some of the network links may carry multiple copies of the same
|
||||
data packets.
|
||||
With multicast routing, the overhead is reduced to one copy
|
||||
(at most) per network link.
|
||||
.Pp
|
||||
All multicast-capable routers must run a common multicast routing
|
||||
protocol.
|
||||
The Distance Vector Multicast Routing Protocol (DVMRP)
|
||||
was the first developed multicast routing protocol.
|
||||
Later, other protocols such as Multicast Extensions to OSPF (MOSPF),
|
||||
Core Based Trees (CBT),
|
||||
Protocol Independent Multicast - Sparse Mode (PIM-SM),
|
||||
and Protocol Independent Multicast - Dense Mode (PIM-DM)
|
||||
were developed as well.
|
||||
.Pp
|
||||
To start multicast routing,
|
||||
the user must enable multicast forwarding in the kernel
|
||||
(see
|
||||
.Sx SYNOPSIS
|
||||
about the kernel configuration options),
|
||||
and must run a multicast routing capable user-level process.
|
||||
From developer's point of view,
|
||||
the programming guide described in the
|
||||
.Sx "Programming Guide"
|
||||
section should be used to control the multicast forwarding in the kernel.
|
||||
.\"
|
||||
.Ss Programming Guide
|
||||
This section provides information about the basic multicast routing API.
|
||||
The so-called
|
||||
.Dq advanced multicast API
|
||||
is described in the
|
||||
.Sx "Advanced Multicast API Programming Guide"
|
||||
section.
|
||||
.Pp
|
||||
First, a multicast routing socket must be open.
|
||||
That socket would be used
|
||||
to control the multicast forwarding in the kernel.
|
||||
Note that most operations below require certain privilege
|
||||
(i.e., root privilege):
|
||||
.Pp
|
||||
.Bd -literal
|
||||
/* IPv4 */
|
||||
int mrouter_s4;
|
||||
mrouter_s4 = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP);
|
||||
.Ed
|
||||
.Pp
|
||||
.Bd -literal
|
||||
int mrouter_s6;
|
||||
mrouter_s6 = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
|
||||
.Ed
|
||||
.Pp
|
||||
Note that if the router needs to open an IGMP or ICMPv6 socket
|
||||
(in case of IPv4 and IPv6 respectively)
|
||||
for sending or receiving of IGMP or MLD multicast group membership messages,
|
||||
then the same mrouter_s4 or mrouter_s6 sockets should be used
|
||||
for sending and receiving respectively IGMP or MLD messages.
|
||||
In case of BSD-derived kernel, it may be possible to open separate sockets
|
||||
for IGMP or MLD messages only.
|
||||
However, some other kernels (e.g., Linux) require that the multicast
|
||||
routing socket must be used for sending and receiving of IGMP or MLD
|
||||
messages.
|
||||
Therefore, for portability reason the multicast
|
||||
routing socket should be reused for IGMP and MLD messages as well.
|
||||
.Pp
|
||||
After the multicast routing socket is open, it can be used to enable
|
||||
or disable multicast forwarding in the kernel:
|
||||
.Bd -literal
|
||||
/* IPv4 */
|
||||
int v = 1; /* 1 to enable, or 0 to disable */
|
||||
setsockopt(mrouter_s4, IPPROTO_IP, MRT_INIT, (void *)&v, sizeof(v));
|
||||
.Ed
|
||||
.Pp
|
||||
.Bd -literal
|
||||
/* IPv6 */
|
||||
int v = 1; /* 1 to enable, or 0 to disable */
|
||||
setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_INIT, (void *)&v, sizeof(v));
|
||||
\&...
|
||||
/* If necessary, filter all ICMPv6 messages */
|
||||
struct icmp6_filter filter;
|
||||
ICMP6_FILTER_SETBLOCKALL(&filter);
|
||||
setsockopt(mrouter_s6, IPPROTO_ICMPV6, ICMP6_FILTER, (void *)&filter,
|
||||
sizeof(filter));
|
||||
.Ed
|
||||
.Pp
|
||||
After multicast forwarding is enabled, the multicast routing socket
|
||||
can be used to enable PIM processing in the kernel if we are running PIM-SM or
|
||||
PIM-DM
|
||||
(see
|
||||
.Xr pim 4 ) .
|
||||
.Pp
|
||||
For each network interface (e.g., physical or a virtual tunnel)
|
||||
that would be used for multicast forwarding, a corresponding
|
||||
multicast interface must be added to the kernel:
|
||||
.Bd -literal
|
||||
/* IPv4 */
|
||||
struct vifctl vc;
|
||||
memset(&vc, 0, sizeof(vc));
|
||||
/* Assign all vifctl fields as appropriate */
|
||||
vc.vifc_vifi = vif_index;
|
||||
vc.vifc_flags = vif_flags;
|
||||
vc.vifc_threshold = min_ttl_threshold;
|
||||
vc.vifc_rate_limit = max_rate_limit;
|
||||
memcpy(&vc.vifc_lcl_addr, &vif_local_address, sizeof(vc.vifc_lcl_addr));
|
||||
if (vc.vifc_flags & VIFF_TUNNEL)
|
||||
memcpy(&vc.vifc_rmt_addr, &vif_remote_address,
|
||||
sizeof(vc.vifc_rmt_addr));
|
||||
setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_VIF, (void *)&vc,
|
||||
sizeof(vc));
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Dq vif_index
|
||||
must be unique per vif.
|
||||
The
|
||||
.Dq vif_flags
|
||||
contains the
|
||||
.Dq VIFF_*
|
||||
flags as defined in <netinet/ip_mroute.h>.
|
||||
The
|
||||
.Dq min_ttl_threshold
|
||||
contains the minimum TTL a multicast data packet must have to be
|
||||
forwarded on that vif.
|
||||
Typically, it would have value of 1.
|
||||
The
|
||||
.Dq max_rate_limit
|
||||
contains the maximum rate (in bits/s) of the multicast data packets forwarded
|
||||
on that vif.
|
||||
Value of 0 means no limit.
|
||||
The
|
||||
.Dq vif_local_address
|
||||
contains the local IP address of the corresponding local interface.
|
||||
The
|
||||
.Dq vif_remote_address
|
||||
contains the remote IP address in case of DVMRP multicast tunnels.
|
||||
.Pp
|
||||
.Bd -literal
|
||||
/* IPv6 */
|
||||
struct mif6ctl mc;
|
||||
memset(&mc, 0, sizeof(mc));
|
||||
/* Assign all mif6ctl fields as appropriate */
|
||||
mc.mif6c_mifi = mif_index;
|
||||
mc.mif6c_flags = mif_flags;
|
||||
mc.mif6c_pifi = pif_index;
|
||||
setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_ADD_MIF, (void *)&mc,
|
||||
sizeof(mc));
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Dq mif_index
|
||||
must be unique per vif.
|
||||
The
|
||||
.Dq mif_flags
|
||||
contains the
|
||||
.Dq MIFF_*
|
||||
flags as defined in <netinet6/ip6_mroute.h>.
|
||||
The
|
||||
.Dq pif_index
|
||||
is the physical interface index of the corresponding local interface.
|
||||
.Pp
|
||||
A multicast interface is deleted by:
|
||||
.Bd -literal
|
||||
/* IPv4 */
|
||||
vifi_t vifi = vif_index;
|
||||
setsockopt(mrouter_s4, IPPROTO_IP, MRT_DEL_VIF, (void *)&vifi,
|
||||
sizeof(vifi));
|
||||
.Ed
|
||||
.Pp
|
||||
.Bd -literal
|
||||
/* IPv6 */
|
||||
mifi_t mifi = mif_index;
|
||||
setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_DEL_MIF, (void *)&mifi,
|
||||
sizeof(mifi));
|
||||
.Ed
|
||||
.Pp
|
||||
After the multicast forwarding is enabled, and the multicast virtual
|
||||
interfaces are
|
||||
added, the kernel may deliver upcall messages (also called signals
|
||||
later in this text) on the multicast routing socket that was open
|
||||
earlier with
|
||||
.Dq MRT_INIT
|
||||
or
|
||||
.Dq MRT6_INIT .
|
||||
The IPv4 upcalls have
|
||||
.Dq struct igmpmsg
|
||||
header (see <netinet/ip_mroute.h>) with field
|
||||
.Dq im_mbz
|
||||
set to zero.
|
||||
Note that this header follows the structure of
|
||||
.Dq struct ip
|
||||
with the protocol field
|
||||
.Dq ip_p
|
||||
set to zero.
|
||||
The IPv6 upcalls have
|
||||
.Dq struct mrt6msg
|
||||
header (see <netinet6/ip6_mroute.h>) with field
|
||||
.Dq im6_mbz
|
||||
set to zero.
|
||||
Note that this header follows the structure of
|
||||
.Dq struct ip6_hdr
|
||||
with the next header field
|
||||
.Dq ip6_nxt
|
||||
set to zero.
|
||||
.Pp
|
||||
The upcall header contains field
|
||||
.Dq im_msgtype
|
||||
and
|
||||
.Dq im6_msgtype
|
||||
with the type of the upcall
|
||||
.Dq IGMPMSG_*
|
||||
and
|
||||
.Dq MRT6MSG_*
|
||||
for IPv4 and IPv6 respectively.
|
||||
The values of the rest of the upcall header fields
|
||||
and the body of the upcall message depend on the particular upcall type.
|
||||
.Pp
|
||||
If the upcall message type is
|
||||
.Dq IGMPMSG_NOCACHE
|
||||
or
|
||||
.Dq MRT6MSG_NOCACHE ,
|
||||
this is an indication that a multicast packet has reached the multicast
|
||||
router, but the router has no forwarding state for that packet.
|
||||
Typically, the upcall would be a signal for the multicast routing
|
||||
user-level process to install the appropriate Multicast Forwarding
|
||||
Cache (MFC) entry in the kernel.
|
||||
.Pp
|
||||
A MFC entry is added by:
|
||||
.Bd -literal
|
||||
/* IPv4 */
|
||||
struct mfcctl mc;
|
||||
memset(&mc, 0, sizeof(mc));
|
||||
memcpy(&mc.mfcc_origin, &source_addr, sizeof(mc.mfcc_origin));
|
||||
memcpy(&mc.mfcc_mcastgrp, &group_addr, sizeof(mc.mfcc_mcastgrp));
|
||||
mc.mfcc_parent = iif_index;
|
||||
for (i = 0; i < maxvifs; i++)
|
||||
mc.mfcc_ttls[i] = oifs_ttl[i];
|
||||
setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_MFC,
|
||||
(void *)&mc, sizeof(mc));
|
||||
.Ed
|
||||
.Pp
|
||||
.Bd -literal
|
||||
/* IPv6 */
|
||||
struct mf6cctl mc;
|
||||
memset(&mc, 0, sizeof(mc));
|
||||
memcpy(&mc.mf6cc_origin, &source_addr, sizeof(mc.mf6cc_origin));
|
||||
memcpy(&mc.mf6cc_mcastgrp, &group_addr, sizeof(mf6cc_mcastgrp));
|
||||
mc.mf6cc_parent = iif_index;
|
||||
for (i = 0; i < maxvifs; i++)
|
||||
if (oifs_ttl[i] > 0)
|
||||
IF_SET(i, &mc.mf6cc_ifset);
|
||||
setsockopt(mrouter_s4, IPPROTO_IPV6, MRT6_ADD_MFC,
|
||||
(void *)&mc, sizeof(mc));
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Dq source_addr
|
||||
and
|
||||
.Dq group_addr
|
||||
are the source and group address of the multicast packet (as set
|
||||
in the upcall message).
|
||||
The
|
||||
.Dq iif_index
|
||||
is the virtual interface index of the multicast interface the multicast
|
||||
packets for this specific source and group address should be received on.
|
||||
The
|
||||
.Dq oifs_ttl[]
|
||||
array contains the minimum TTL (per interface) a multicast packet
|
||||
should have to be forwarded on an outgoing interface.
|
||||
If the TTL value is zero, the corresponding interface is not included
|
||||
in the set of outgoing interfaces.
|
||||
Note that in case of IPv6 only the set of outgoing interfaces can
|
||||
be specified.
|
||||
.Pp
|
||||
A MFC entry is deleted by:
|
||||
.Bd -literal
|
||||
/* IPv4 */
|
||||
struct mfcctl mc;
|
||||
memset(&mc, 0, sizeof(mc));
|
||||
memcpy(&mc.mfcc_origin, &source_addr, sizeof(mc.mfcc_origin));
|
||||
memcpy(&mc.mfcc_mcastgrp, &group_addr, sizeof(mc.mfcc_mcastgrp));
|
||||
setsockopt(mrouter_s4, IPPROTO_IP, MRT_DEL_MFC,
|
||||
(void *)&mc, sizeof(mc));
|
||||
.Ed
|
||||
.Pp
|
||||
.Bd -literal
|
||||
/* IPv6 */
|
||||
struct mf6cctl mc;
|
||||
memset(&mc, 0, sizeof(mc));
|
||||
memcpy(&mc.mf6cc_origin, &source_addr, sizeof(mc.mf6cc_origin));
|
||||
memcpy(&mc.mf6cc_mcastgrp, &group_addr, sizeof(mf6cc_mcastgrp));
|
||||
setsockopt(mrouter_s4, IPPROTO_IPV6, MRT6_DEL_MFC,
|
||||
(void *)&mc, sizeof(mc));
|
||||
.Ed
|
||||
.Pp
|
||||
The following method can be used to get various statistics per
|
||||
installed MFC entry in the kernel (e.g., the number of forwarded
|
||||
packets per source and group address):
|
||||
.Bd -literal
|
||||
/* IPv4 */
|
||||
struct sioc_sg_req sgreq;
|
||||
memset(&sgreq, 0, sizeof(sgreq));
|
||||
memcpy(&sgreq.src, &source_addr, sizeof(sgreq.src));
|
||||
memcpy(&sgreq.grp, &group_addr, sizeof(sgreq.grp));
|
||||
ioctl(mrouter_s4, SIOCGETSGCNT, &sgreq);
|
||||
.Ed
|
||||
.Pp
|
||||
.Bd -literal
|
||||
/* IPv6 */
|
||||
struct sioc_sg_req6 sgreq;
|
||||
memset(&sgreq, 0, sizeof(sgreq));
|
||||
memcpy(&sgreq.src, &source_addr, sizeof(sgreq.src));
|
||||
memcpy(&sgreq.grp, &group_addr, sizeof(sgreq.grp));
|
||||
ioctl(mrouter_s6, SIOCGETSGCNT_IN6, &sgreq);
|
||||
.Ed
|
||||
.Pp
|
||||
The following method can be used to get various statistics per
|
||||
multicast virtual interface in the kernel (e.g., the number of forwarded
|
||||
packets per interface):
|
||||
.Bd -literal
|
||||
/* IPv4 */
|
||||
struct sioc_vif_req vreq;
|
||||
memset(&vreq, 0, sizeof(vreq));
|
||||
vreq.vifi = vif_index;
|
||||
ioctl(mrouter_s4, SIOCGETVIFCNT, &vreq);
|
||||
.Ed
|
||||
.Pp
|
||||
.Bd -literal
|
||||
/* IPv6 */
|
||||
struct sioc_mif_req6 mreq;
|
||||
memset(&mreq, 0, sizeof(mreq));
|
||||
mreq.mifi = vif_index;
|
||||
ioctl(mrouter_s6, SIOCGETMIFCNT_IN6, &mreq);
|
||||
.Ed
|
||||
.Pp
|
||||
.Ss Advanced Multicast API Programming Guide
|
||||
If we want to add new features in the kernel, it becomes difficult
|
||||
to preserve backward compatibility (binary and API),
|
||||
and at the same time to allow user-level processes to take advantage of
|
||||
the new features (if the kernel supports them).
|
||||
.Pp
|
||||
One of the mechanisms that allows us to preserve the backward
|
||||
compatibility is a sort of negotiation
|
||||
between the user-level process and the kernel:
|
||||
.Bl -enum
|
||||
.It
|
||||
The user-level process tries to enable in the kernel the set of new
|
||||
features (and the corresponding API) it would like to use.
|
||||
.It
|
||||
The kernel returns the (sub)set of features it knows about
|
||||
and is willing to be enabled.
|
||||
.It
|
||||
The user-level process uses only that set of features
|
||||
the kernel has agreed on.
|
||||
.El
|
||||
.\"
|
||||
.Pp
|
||||
To support backward compatibility, if the user-level process doesn't
|
||||
ask for any new features, the kernel defaults to the basic
|
||||
multicast API (see the
|
||||
.Sx "Programming Guide"
|
||||
section).
|
||||
.\" XXX: edit as appropriate after the advanced multicast API is
|
||||
.\" supported under IPv6
|
||||
Currently, the advanced multicast API exists only for IPv4;
|
||||
in the future there will be IPv6 support as well.
|
||||
.Pp
|
||||
Below is a summary of the expandable API solution.
|
||||
Note that all new options and structures are defined
|
||||
in <netinet/ip_mroute.h> and <netinet6/ip6_mroute.h>,
|
||||
unless stated otherwise.
|
||||
.Pp
|
||||
The user-level process uses new get/setsockopt() options to
|
||||
perform the API features negotiation with the kernel.
|
||||
This negotiation must be performed right after the multicast routing
|
||||
socket is open.
|
||||
The set of desired/allowed features is stored in a bitset
|
||||
(currently, in uint32_t; i.e., maximum of 32 new features).
|
||||
The new get/setsockopt() options are
|
||||
.Dq MRT_API_SUPPORT
|
||||
and
|
||||
.Dq MRT_API_CONFIG .
|
||||
Example:
|
||||
.Bd -literal
|
||||
uint32_t v;
|
||||
getsockopt(sock, IPPROTO_IP, MRT_API_SUPPORT, (void *)&v, sizeof(v));
|
||||
.Ed
|
||||
.Pp
|
||||
would set in
|
||||
.Dq v
|
||||
the pre-defined bits that the kernel API supports.
|
||||
The eight least significant bits in uint32_t are same as the
|
||||
eight possible flags
|
||||
.Dq MRT_MFC_FLAGS_*
|
||||
that can be used in
|
||||
.Dq mfcc_flags
|
||||
as part of the new definition of
|
||||
.Dq struct mfcctl
|
||||
(see below about those flags), which leaves 24 flags for other new features.
|
||||
The value returned by getsockopt(MRT_API_SUPPORT) is read-only; in other
|
||||
words, setsockopt(MRT_API_SUPPORT) would fail.
|
||||
.Pp
|
||||
To modify the API, and to set some specific feature in the kernel, then:
|
||||
.Bd -literal
|
||||
uint32_t v = MRT_MFC_FLAGS_DISABLE_WRONGVIF;
|
||||
if (setsockopt(sock, IPPROTO_IP, MRT_API_CONFIG, (void *)&v, sizeof(v))
|
||||
!= 0) {
|
||||
return (ERROR);
|
||||
}
|
||||
if (v & MRT_MFC_FLAGS_DISABLE_WRONGVIF)
|
||||
return (OK); /* Success */
|
||||
else
|
||||
return (ERROR);
|
||||
.Ed
|
||||
.Pp
|
||||
In other words, when setsockopt(MRT_API_CONFIG) is called, the
|
||||
argument to it specifies the desired set of features to
|
||||
be enabled in the API and the kernel.
|
||||
The return value in
|
||||
.Dq v
|
||||
is the actual (sub)set of features that were enabled in the kernel.
|
||||
To obtain later the same set of features that were enabled, then:
|
||||
.Bd -literal
|
||||
getsockopt(sock, IPPROTO_IP, MRT_API_CONFIG, (void *)&v, sizeof(v));
|
||||
.Ed
|
||||
.Pp
|
||||
The set of enabled features is global.
|
||||
In other words, setsockopt(MRT_API_CONFIG)
|
||||
should be called right after setsockopt(MRT_INIT).
|
||||
.Pp
|
||||
Currently, the following set of new features is defined:
|
||||
.Bd -literal
|
||||
#define MRT_MFC_FLAGS_DISABLE_WRONGVIF (1 << 0) /* disable WRONGVIF signals */
|
||||
#define MRT_MFC_FLAGS_BORDER_VIF (1 << 1) /* border vif */
|
||||
#define MRT_MFC_RP (1 << 8) /* enable RP address */
|
||||
#define MRT_MFC_BW_UPCALL (1 << 9) /* enable bw upcalls */
|
||||
.Ed
|
||||
.\" .Pp
|
||||
.\" In the future there might be:
|
||||
.\" .Bd -literal
|
||||
.\" #define MRT_MFC_GROUP_SPECIFIC (1 << 10) /* allow (*,G) MFC entries */
|
||||
.\" .Ed
|
||||
.\" .Pp
|
||||
.\" to allow (*,G) MFC entries (i.e., group-specific entries) in the kernel.
|
||||
.\" For now this is left-out until it is clear whether
|
||||
.\" (*,G) MFC support is the preferred solution instead of something more generic
|
||||
.\" solution for example.
|
||||
.\"
|
||||
.\" 2. The newly defined struct mfcctl2.
|
||||
.\"
|
||||
.Pp
|
||||
The advanced multicast API uses a newly defined
|
||||
.Dq struct mfcctl2
|
||||
instead of the traditional
|
||||
.Dq struct mfcctl .
|
||||
The original
|
||||
.Dq struct mfcctl
|
||||
is kept as is.
|
||||
The new
|
||||
.Dq struct mfcctl2
|
||||
is:
|
||||
.Bd -literal
|
||||
/*
|
||||
* The new argument structure for MRT_ADD_MFC and MRT_DEL_MFC overlays
|
||||
* and extends the old struct mfcctl.
|
||||
*/
|
||||
struct mfcctl2 {
|
||||
/* the mfcctl fields */
|
||||
struct in_addr mfcc_origin; /* ip origin of mcasts */
|
||||
struct in_addr mfcc_mcastgrp; /* multicast group associated*/
|
||||
vifi_t mfcc_parent; /* incoming vif */
|
||||
u_char mfcc_ttls[MAXVIFS];/* forwarding ttls on vifs */
|
||||
|
||||
/* extension fields */
|
||||
uint8_t mfcc_flags[MAXVIFS];/* the MRT_MFC_FLAGS_* flags*/
|
||||
struct in_addr mfcc_rp; /* the RP address */
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
The new fields are
|
||||
.Dq mfcc_flags[MAXVIFS]
|
||||
and
|
||||
.Dq mfcc_rp .
|
||||
Note that for compatibility reasons they are added at the end.
|
||||
.Pp
|
||||
The
|
||||
.Dq mfcc_flags[MAXVIFS]
|
||||
field is used to set various flags per
|
||||
interface per (S,G) entry.
|
||||
Currently, the defined flags are:
|
||||
.Bd -literal
|
||||
#define MRT_MFC_FLAGS_DISABLE_WRONGVIF (1 << 0) /* disable WRONGVIF signals */
|
||||
#define MRT_MFC_FLAGS_BORDER_VIF (1 << 1) /* border vif */
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Dq MRT_MFC_FLAGS_DISABLE_WRONGVIF
|
||||
flag is used to explicitly disable the
|
||||
.Dq IGMPMSG_WRONGVIF
|
||||
kernel signal at the (S,G) granularity if a multicast data packet
|
||||
arrives on the wrong interface.
|
||||
Usually, this signal is used to
|
||||
complete the shortest-path switch in case of PIM-SM multicast routing,
|
||||
or to trigger a PIM assert message.
|
||||
However, it should not be delivered for interfaces that are not in
|
||||
the outgoing interface set, and that are not expecting to
|
||||
become an incoming interface.
|
||||
Hence, if the
|
||||
.Dq MRT_MFC_FLAGS_DISABLE_WRONGVIF
|
||||
flag is set for some of the
|
||||
interfaces, then a data packet that arrives on that interface for
|
||||
that MFC entry will NOT trigger a WRONGVIF signal.
|
||||
If that flag is not set, then a signal is triggered (the default action).
|
||||
.Pp
|
||||
The
|
||||
.Dq MRT_MFC_FLAGS_BORDER_VIF
|
||||
flag is used to specify whether the Border-bit in PIM
|
||||
Register messages should be set (in case when the Register encapsulation
|
||||
is performed inside the kernel).
|
||||
If it is set for the special PIM Register kernel virtual interface
|
||||
(see
|
||||
.Xr pim 4 ) ,
|
||||
the Border-bit in the Register messages sent to the RP will be set.
|
||||
.Pp
|
||||
The remaining six bits are reserved for future usage.
|
||||
.Pp
|
||||
The
|
||||
.Dq mfcc_rp
|
||||
field is used to specify the RP address (in case of PIM-SM multicast routing)
|
||||
for a multicast
|
||||
group G if we want to perform kernel-level PIM Register encapsulation.
|
||||
The
|
||||
.Dq mfcc_rp
|
||||
field is used only if the
|
||||
.Dq MRT_MFC_RP
|
||||
advanced API flag/capability has been successfully set by
|
||||
setsockopt(MRT_API_CONFIG).
|
||||
.Pp
|
||||
.\"
|
||||
.\" 3. Kernel-level PIM Register encapsulation
|
||||
.\"
|
||||
If the
|
||||
.Dq MRT_MFC_RP
|
||||
flag was successfully set by
|
||||
setsockopt(MRT_API_CONFIG), then the kernel will attempt to perform
|
||||
the PIM Register encapsulation itself instead of sending the
|
||||
multicast data packets to user level (inside IGMPMSG_WHOLEPKT
|
||||
upcalls) for user-level encapsulation.
|
||||
The RP address would be taken from the
|
||||
.Dq mfcc_rp
|
||||
field
|
||||
inside the new
|
||||
.Dq struct mfcctl2 .
|
||||
However, even if the
|
||||
.Dq MRT_MFC_RP
|
||||
flag was successfully set, if the
|
||||
.Dq mfcc_rp
|
||||
field was set to
|
||||
.Dq INADDR_ANY ,
|
||||
then the
|
||||
kernel will still deliver an IGMPMSG_WHOLEPKT upcall with the
|
||||
multicast data packet to the user-level process.
|
||||
.Pp
|
||||
In addition, if the multicast data packet is too large to fit within
|
||||
a single IP packet after the PIM Register encapsulation (e.g., if
|
||||
its size was on the order of 65500 bytes), the data packet will be
|
||||
fragmented, and then each of the fragments will be encapsulated
|
||||
separately.
|
||||
Note that typically a multicast data packet can be that
|
||||
large only if it was originated locally from the same hosts that
|
||||
performs the encapsulation; otherwise the transmission of the
|
||||
multicast data packet over Ethernet for example would have
|
||||
fragmented it into much smaller pieces.
|
||||
.\"
|
||||
.\" Note that if this code is ported to IPv6, we may need the kernel to
|
||||
.\" perform MTU discovery to the RP, and keep those discoveries inside
|
||||
.\" the kernel so the encapsulating router may send back ICMP
|
||||
.\" Fragmentation Required if the size of the multicast data packet is
|
||||
.\" too large (see "Encapsulating data packets in the Register Tunnel"
|
||||
.\" in Section 4.4.1 in the PIM-SM spec
|
||||
.\" draft-ietf-pim-sm-v2-new-05.{txt,ps}).
|
||||
.\" For IPv4 we may be able to get away without it, but for IPv6 we need
|
||||
.\" that.
|
||||
.\"
|
||||
.\" 4. Mechanism for "multicast bandwidth monitoring and upcalls".
|
||||
.\"
|
||||
.Pp
|
||||
Typically, a multicast routing user-level process would need to know the
|
||||
forwarding bandwidth for some data flow.
|
||||
For example, the multicast routing process may want to timeout idle MFC
|
||||
entries, or in case of PIM-SM it can initiate (S,G) shortest-path switch if
|
||||
the bandwidth rate is above a threshold for example.
|
||||
.Pp
|
||||
The original solution for measuring the bandwidth of a dataflow was
|
||||
that a user-level process would periodically
|
||||
query the kernel about the number of forwarded packets/bytes per
|
||||
(S,G), and then based on those numbers it would estimate whether a source
|
||||
has been idle, or whether the source's transmission bandwidth is above a
|
||||
threshold.
|
||||
That solution is far from being scalable, hence the need for a new
|
||||
mechanism for bandwidth monitoring.
|
||||
.Pp
|
||||
Below is a description of the bandwidth monitoring mechanism.
|
||||
.Bl -bullet
|
||||
.It
|
||||
If the bandwidth of a data flow satisfies some pre-defined filter,
|
||||
the kernel delivers an upcall on the multicast routing socket
|
||||
to the multicast routing process that has installed that filter.
|
||||
.It
|
||||
The bandwidth-upcall filters are installed per (S,G). There can be
|
||||
more than one filter per (S,G).
|
||||
.It
|
||||
Instead of supporting all possible comparison operations
|
||||
(i.e., < <= == != > >= ), there is support only for the
|
||||
<= and >= operations,
|
||||
because this makes the kernel-level implementation simpler,
|
||||
and because practically we need only those two.
|
||||
Further, the missing operations can be simulated by secondary
|
||||
user-level filtering of those <= and >= filters.
|
||||
For example, to simulate !=, then we need to install filter
|
||||
.Dq bw <= 0xffffffff ,
|
||||
and after an
|
||||
upcall is received, we need to check whether
|
||||
.Dq measured_bw != expected_bw .
|
||||
.It
|
||||
The bandwidth-upcall mechanism is enabled by
|
||||
setsockopt(MRT_API_CONFIG) for the MRT_MFC_BW_UPCALL flag.
|
||||
.It
|
||||
The bandwidth-upcall filters are added/deleted by the new
|
||||
setsockopt(MRT_ADD_BW_UPCALL) and setsockopt(MRT_DEL_BW_UPCALL)
|
||||
respectively (with the appropriate
|
||||
.Dq struct bw_upcall
|
||||
argument of course).
|
||||
.El
|
||||
.Pp
|
||||
From application point of view, a developer needs to know about
|
||||
the following:
|
||||
.Bd -literal
|
||||
/*
|
||||
* Structure for installing or delivering an upcall if the
|
||||
* measured bandwidth is above or below a threshold.
|
||||
*
|
||||
* User programs (e.g. daemons) may have a need to know when the
|
||||
* bandwidth used by some data flow is above or below some threshold.
|
||||
* This interface allows the userland to specify the threshold (in
|
||||
* bytes and/or packets) and the measurement interval. Flows are
|
||||
* all packet with the same source and destination IP address.
|
||||
* At the moment the code is only used for multicast destinations
|
||||
* but there is nothing that prevents its use for unicast.
|
||||
*
|
||||
* The measurement interval cannot be shorter than some Tmin (currently, 3s).
|
||||
* The threshold is set in packets and/or bytes per_interval.
|
||||
*
|
||||
* Measurement works as follows:
|
||||
*
|
||||
* For >= measurements:
|
||||
* The first packet marks the start of a measurement interval.
|
||||
* During an interval we count packets and bytes, and when we
|
||||
* pass the threshold we deliver an upcall and we are done.
|
||||
* The first packet after the end of the interval resets the
|
||||
* count and restarts the measurement.
|
||||
*
|
||||
* For <= measurement:
|
||||
* We start a timer to fire at the end of the interval, and
|
||||
* then for each incoming packet we count packets and bytes.
|
||||
* When the timer fires, we compare the value with the threshold,
|
||||
* schedule an upcall if we are below, and restart the measurement
|
||||
* (reschedule timer and zero counters).
|
||||
*/
|
||||
|
||||
struct bw_data {
|
||||
struct timeval b_time;
|
||||
uint64_t b_packets;
|
||||
uint64_t b_bytes;
|
||||
};
|
||||
|
||||
struct bw_upcall {
|
||||
struct in_addr bu_src; /* source address */
|
||||
struct in_addr bu_dst; /* destination address */
|
||||
uint32_t bu_flags; /* misc flags (see below) */
|
||||
#define BW_UPCALL_UNIT_PACKETS (1 << 0) /* threshold (in packets) */
|
||||
#define BW_UPCALL_UNIT_BYTES (1 << 1) /* threshold (in bytes) */
|
||||
#define BW_UPCALL_GEQ (1 << 2) /* upcall if bw >= threshold */
|
||||
#define BW_UPCALL_LEQ (1 << 3) /* upcall if bw <= threshold */
|
||||
#define BW_UPCALL_DELETE_ALL (1 << 4) /* delete all upcalls for s,d*/
|
||||
struct bw_data bu_threshold; /* the bw threshold */
|
||||
struct bw_data bu_measured; /* the measured bw */
|
||||
};
|
||||
|
||||
/* max. number of upcalls to deliver together */
|
||||
#define BW_UPCALLS_MAX 128
|
||||
/* min. threshold time interval for bandwidth measurement */
|
||||
#define BW_UPCALL_THRESHOLD_INTERVAL_MIN_SEC 3
|
||||
#define BW_UPCALL_THRESHOLD_INTERVAL_MIN_USEC 0
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Dq bw_upcall
|
||||
structure is used as an argument to
|
||||
setsockopt(MRT_ADD_BW_UPCALL) and setsockopt(MRT_DEL_BW_UPCALL).
|
||||
Each setsockopt(MRT_ADD_BW_UPCALL) installs a filter in the kernel
|
||||
for the source and destination address in the
|
||||
.Dq bw_upcall
|
||||
argument,
|
||||
and that filter will trigger an upcall according to the following
|
||||
pseudo-algorithm:
|
||||
.Bd -literal
|
||||
if (bw_upcall_oper IS ">=") {
|
||||
if (((bw_upcall_unit & PACKETS == PACKETS) &&
|
||||
(measured_packets >= threshold_packets)) ||
|
||||
((bw_upcall_unit & BYTES == BYTES) &&
|
||||
(measured_bytes >= threshold_bytes)))
|
||||
SEND_UPCALL("measured bandwidth is >= threshold");
|
||||
}
|
||||
if (bw_upcall_oper IS "<=" && measured_interval >= threshold_interval) {
|
||||
if (((bw_upcall_unit & PACKETS == PACKETS) &&
|
||||
(measured_packets <= threshold_packets)) ||
|
||||
((bw_upcall_unit & BYTES == BYTES) &&
|
||||
(measured_bytes <= threshold_bytes)))
|
||||
SEND_UPCALL("measured bandwidth is <= threshold");
|
||||
}
|
||||
.Ed
|
||||
.Pp
|
||||
In the same
|
||||
.Dq bw_upcall
|
||||
the unit can be specified in both BYTES and PACKETS.
|
||||
However, the GEQ and LEQ flags are mutually exclusive.
|
||||
.Pp
|
||||
Basically, an upcall is delivered if the measured bandwidth is >= or
|
||||
<= the threshold bandwidth (within the specified measurement
|
||||
interval).
|
||||
For practical reasons, the smallest value for the measurement
|
||||
interval is 3 seconds.
|
||||
If smaller values are allowed, then the bandwidth
|
||||
estimation may be less accurate, or the potentially very high frequency
|
||||
of the generated upcalls may introduce too much overhead.
|
||||
For the >= operation, the answer may be known before the end of
|
||||
.Dq threshold_interval ,
|
||||
therefore the upcall may be delivered earlier.
|
||||
For the <= operation however, we must wait
|
||||
until the threshold interval has expired to know the answer.
|
||||
.Pp
|
||||
Example of usage:
|
||||
.Bd -literal
|
||||
struct bw_upcall bw_upcall;
|
||||
/* Assign all bw_upcall fields as appropriate */
|
||||
memset(&bw_upcall, 0, sizeof(bw_upcall));
|
||||
memcpy(&bw_upcall.bu_src, &source, sizeof(bw_upcall.bu_src));
|
||||
memcpy(&bw_upcall.bu_dst, &group, sizeof(bw_upcall.bu_dst));
|
||||
bw_upcall.bu_threshold.b_data = threshold_interval;
|
||||
bw_upcall.bu_threshold.b_packets = threshold_packets;
|
||||
bw_upcall.bu_threshold.b_bytes = threshold_bytes;
|
||||
if (is_threshold_in_packets)
|
||||
bw_upcall.bu_flags |= BW_UPCALL_UNIT_PACKETS;
|
||||
if (is_threshold_in_bytes)
|
||||
bw_upcall.bu_flags |= BW_UPCALL_UNIT_BYTES;
|
||||
do {
|
||||
if (is_geq_upcall) {
|
||||
bw_upcall.bu_flags |= BW_UPCALL_GEQ;
|
||||
break;
|
||||
}
|
||||
if (is_leq_upcall) {
|
||||
bw_upcall.bu_flags |= BW_UPCALL_LEQ;
|
||||
break;
|
||||
}
|
||||
return (ERROR);
|
||||
} while (0);
|
||||
setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_BW_UPCALL,
|
||||
(void *)&bw_upcall, sizeof(bw_upcall));
|
||||
.Ed
|
||||
.Pp
|
||||
To delete a single filter, then use MRT_DEL_BW_UPCALL,
|
||||
and the fields of bw_upcall must be set
|
||||
exactly same as when MRT_ADD_BW_UPCALL was called.
|
||||
.Pp
|
||||
To delete all bandwidth filters for a given (S,G), then
|
||||
only the
|
||||
.Dq bu_src
|
||||
and
|
||||
.Dq bu_dst
|
||||
fields in
|
||||
.Dq struct bw_upcall
|
||||
need to be set, and then just set only the
|
||||
.Dq BW_UPCALL_DELETE_ALL
|
||||
flag inside field
|
||||
.Dq bw_upcall.bu_flags .
|
||||
.Pp
|
||||
The bandwidth upcalls are received by aggregating them in the new upcall
|
||||
message:
|
||||
.Bd -literal
|
||||
#define IGMPMSG_BW_UPCALL 4 /* BW monitoring upcall */
|
||||
.Ed
|
||||
.Pp
|
||||
This message is an array of
|
||||
.Dq struct bw_upcall
|
||||
elements (up to BW_UPCALLS_MAX = 128).
|
||||
The upcalls are
|
||||
delivered when there are 128 pending upcalls, or when 1 second has
|
||||
expired since the previous upcall (whichever comes first).
|
||||
In an
|
||||
.Dq struct upcall
|
||||
element, the
|
||||
.Dq bu_measured
|
||||
field is filled-in to
|
||||
indicate the particular measured values.
|
||||
However, because of the way
|
||||
the particular intervals are measured, the user should be careful how
|
||||
bu_measured.b_time is used.
|
||||
For example, if the
|
||||
filter is installed to trigger an upcall if the number of packets
|
||||
is >= 1, then
|
||||
.Dq bu_measured
|
||||
may have a value of zero in the upcalls after the
|
||||
first one, because the measured interval for >= filters is
|
||||
.Dq clocked
|
||||
by the forwarded packets.
|
||||
Hence, this upcall mechanism should not be used for measuring
|
||||
the exact value of the bandwidth of the forwarded data.
|
||||
To measure the exact bandwidth, the user would need to
|
||||
get the forwarded packets statistics with the ioctl(SIOCGETSGCNT)
|
||||
mechanism
|
||||
(see the
|
||||
.Sx Programming Guide
|
||||
section) .
|
||||
.Pp
|
||||
Note that the upcalls for a filter are delivered until the specific
|
||||
filter is deleted, but no more frequently than once per
|
||||
.Dq bu_threshold.b_time .
|
||||
For example, if the filter is specified to
|
||||
deliver a signal if bw >= 1 packet, the first packet will trigger a
|
||||
signal, but the next upcall will be triggered no earlier than
|
||||
.Dq bu_threshold.b_time
|
||||
after the previous upcall.
|
||||
.Pp
|
||||
.\"
|
||||
.Sh SEE ALSO
|
||||
.Xr getsockopt 2 ,
|
||||
.Xr recvfrom 2 ,
|
||||
.Xr recvmsg 2 ,
|
||||
.Xr setsockopt 2 ,
|
||||
.Xr socket 2 ,
|
||||
.Xr icmp6 4 ,
|
||||
.Xr inet 4 ,
|
||||
.Xr inet6 4 ,
|
||||
.Xr intro 4 ,
|
||||
.Xr ip 4 ,
|
||||
.Xr ip6 4 ,
|
||||
.Xr pim 4
|
||||
.\"
|
||||
.Pp
|
||||
.Sh AUTHORS
|
||||
The original multicast code was written by David Waitzman (BBN Labs),
|
||||
and later modified by the following individuals:
|
||||
Steve Deering (Stanford), Mark J. Steiglitz (Stanford),
|
||||
Van Jacobson (LBL), Ajit Thyagarajan (PARC),
|
||||
Bill Fenner (PARC).
|
||||
The IPv6 multicast support was implemented by the KAME project
|
||||
(http://www.kame.net), and was based on the IPv4 multicast code.
|
||||
The advanced multicast API and the multicast bandwidth
|
||||
monitoring were implemented by Pavlin Radoslavov (ICSI)
|
||||
in collaboration with Chris Brown (NextHop).
|
||||
.Pp
|
||||
This manual page was written by Pavlin Radoslavov (ICSI).
|
||||
@@ -1,192 +0,0 @@
|
||||
.\" Copyright (c) 2001-2003 International Computer Science Institute
|
||||
.\"
|
||||
.\" Permission is hereby granted, free of charge, to any person obtaining a
|
||||
.\" copy of this software and associated documentation files (the "Software"),
|
||||
.\" to deal in the Software without restriction, including without limitation
|
||||
.\" the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
.\" and/or sell copies of the Software, and to permit persons to whom the
|
||||
.\" Software is furnished to do so, subject to the following conditions:
|
||||
.\"
|
||||
.\" The above copyright notice and this permission notice shall be included in
|
||||
.\" all copies or substantial portions of the Software.
|
||||
.\"
|
||||
.\" The names and trademarks of copyright holders may not be used in
|
||||
.\" advertising or publicity pertaining to the software without specific
|
||||
.\" prior permission. Title to copyright in this software and any associated
|
||||
.\" documentation will at all times remain with the copyright holders.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
.\" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
.\" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
.\" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
.\" DEALINGS IN THE SOFTWARE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd September 4, 2003
|
||||
.Dt PIM 4
|
||||
.Os
|
||||
.\"
|
||||
.Sh NAME
|
||||
.Nm pim
|
||||
.Nd Protocol Independent Multicast
|
||||
.\"
|
||||
.Sh SYNOPSIS
|
||||
.Cd "options MROUTING"
|
||||
.Cd "options PIM"
|
||||
.Pp
|
||||
.In sys/types.h
|
||||
.In sys/socket.h
|
||||
.In netinet/in.h
|
||||
.In netinet/ip_mroute.h
|
||||
.In netinet/pim.h
|
||||
.Ft int
|
||||
.Fn getsockopt "int s" IPPROTO_IP MRT_PIM "void *optval" "socklen_t *optlen"
|
||||
.Ft int
|
||||
.Fn setsockopt "int s" IPPROTO_IP MRT_PIM "const void *optval" "socklen_t optlen"
|
||||
.Ft int
|
||||
.Fn getsockopt "int s" IPPROTO_IPV6 MRT6_PIM "void *optval" "socklen_t *optlen"
|
||||
.Ft int
|
||||
.Fn setsockopt "int s" IPPROTO_IPV6 MRT6_PIM "const void *optval" "socklen_t optlen"
|
||||
.Sh DESCRIPTION
|
||||
.Tn PIM
|
||||
is the common name for two multicast routing protocols:
|
||||
Protocol Independent Multicast - Sparse Mode (PIM-SM) and
|
||||
Protocol Independent Multicast - Dense Mode (PIM-DM).
|
||||
.Pp
|
||||
PIM-SM is a multicast routing protocol that can use the underlying
|
||||
unicast routing information base or a separate multicast-capable
|
||||
routing information base.
|
||||
It builds unidirectional shared trees rooted at a Rendezvous
|
||||
Point (RP) per group,
|
||||
and optionally creates shortest-path trees per source.
|
||||
.Pp
|
||||
PIM-DM is a multicast routing protocol that uses the underlying
|
||||
unicast routing information base to flood multicast datagrams
|
||||
to all multicast routers.
|
||||
Prune messages are used to prevent future datagrams from propagating
|
||||
to routers with no group membership information.
|
||||
.Pp
|
||||
Both PIM-SM and PIM-DM are fairly complex protocols,
|
||||
though PIM-SM is much more complex.
|
||||
To enable PIM-SM or PIM-DM multicast routing in a router,
|
||||
the user must enable multicast routing and PIM processing in the kernel
|
||||
(see
|
||||
.Sx SYNOPSIS
|
||||
about the kernel configuration options),
|
||||
and must run a PIM-SM or PIM-DM capable user-level process.
|
||||
From developer's point of view,
|
||||
the programming guide described in the
|
||||
.Sx "Programming Guide"
|
||||
section should be used to control the PIM processing in the kernel.
|
||||
.\"
|
||||
.Ss Programming Guide
|
||||
After a multicast routing socket is open and multicast forwarding
|
||||
is enabled in the kernel
|
||||
(see
|
||||
.Xr multicast 4 ) ,
|
||||
one of the following socket options should be used to enable or disable
|
||||
PIM processing in the kernel.
|
||||
Note that those options require certain privilege
|
||||
(i.e., root privilege):
|
||||
.Pp
|
||||
.Bd -literal
|
||||
/* IPv4 */
|
||||
int v = 1; /* 1 to enable, or 0 to disable */
|
||||
setsockopt(mrouter_s4, IPPROTO_IP, MRT_PIM, (void *)&v, sizeof(v));
|
||||
.Ed
|
||||
.Pp
|
||||
.Bd -literal
|
||||
/* IPv6 */
|
||||
int v = 1; /* 1 to enable, or 0 to disable */
|
||||
setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_PIM, (void *)&v, sizeof(v));
|
||||
.Ed
|
||||
.Pp
|
||||
After PIM processing is enabled, the multicast-capable interfaces
|
||||
should be added
|
||||
(see
|
||||
.Xr multicast 4 ) .
|
||||
In case of PIM-SM, the PIM-Register virtual interface must be added
|
||||
as well.
|
||||
This can be accomplished by using the following options:
|
||||
.Bd -literal
|
||||
/* IPv4 */
|
||||
struct vifctl vc;
|
||||
memset(&vc, 0, sizeof(vc));
|
||||
/* Assign all vifctl fields as appropriate */
|
||||
\&...
|
||||
if (is_pim_register_vif)
|
||||
vc.vifc_flags |= VIFF_REGISTER;
|
||||
setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_VIF, (void *)&vc,
|
||||
sizeof(vc));
|
||||
.Ed
|
||||
.Bd -literal
|
||||
/* IPv6 */
|
||||
struct mif6ctl mc;
|
||||
memset(&mc, 0, sizeof(mc));
|
||||
/* Assign all mif6ctl fields as appropriate */
|
||||
\&...
|
||||
if (is_pim_register_vif)
|
||||
mc.mif6c_flags |= MIFF_REGISTER;
|
||||
setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_ADD_MIF, (void *)&mc,
|
||||
sizeof(mc));
|
||||
.Ed
|
||||
.Pp
|
||||
Sending or receiving of PIM packets can be accomplished by
|
||||
opening first a
|
||||
.Dq raw socket
|
||||
(see
|
||||
.Xr socket 2 ) ,
|
||||
with protocol value of
|
||||
.Dq IPPROTO_PIM :
|
||||
.Bd -literal
|
||||
/* IPv4 */
|
||||
int pim_s4;
|
||||
pim_s4 = socket(AF_INET, SOCK_RAW, IPPROTO_PIM);
|
||||
.Ed
|
||||
.Bd -literal
|
||||
/* IPv6 */
|
||||
int pim_s6;
|
||||
pim_s6 = socket(AF_INET6, SOCK_RAW, IPPROTO_PIM);
|
||||
.Ed
|
||||
.Pp
|
||||
Then, the following system calls can be used to send or receive PIM
|
||||
packets:
|
||||
.Xr sendto 2 ,
|
||||
.Xr sendmsg 2 ,
|
||||
.Xr recvfrom 2 ,
|
||||
.Xr recvmsg 2 .
|
||||
.\"
|
||||
.Sh SEE ALSO
|
||||
.Xr getsockopt 2 ,
|
||||
.Xr recvfrom 2 ,
|
||||
.Xr recvmsg 2 ,
|
||||
.Xr sendmsg 2 ,
|
||||
.Xr sendto 2 ,
|
||||
.Xr setsockopt 2 ,
|
||||
.Xr socket 2 ,
|
||||
.Xr inet 4 ,
|
||||
.Xr intro 4 ,
|
||||
.Xr ip 4 ,
|
||||
.Xr multicast 4
|
||||
.\"
|
||||
.Sh STANDARDS
|
||||
.\" XXX the PIM-SM number must be updated after RFC 2362 is
|
||||
.\" replaced by a new RFC by the end of year 2003 or so.
|
||||
The PIM-SM protocol is specified in RFC 2362 (to be replaced by
|
||||
.Xr draft-ietf-pim-sm-v2-new-* ) .
|
||||
The PIM-DM protocol is specified in
|
||||
.Xr draft-ietf-pim-dm-new-v2-* ) .
|
||||
.\"
|
||||
.Sh AUTHORS
|
||||
The original IPv4 PIM kernel support for IRIX and SunOS-4.x was
|
||||
implemented by Ahmed Helmy (USC and SGI).
|
||||
Later the code was ported to various BSD flavors and modified by
|
||||
George Edmond Eddy (Rusty) (ISI),
|
||||
Hitoshi Asaeda (WIDE Project), and Pavlin Radoslavov (USC/ISI and ICSI).
|
||||
The IPv6 PIM kernel support was implemented by the KAME project
|
||||
(http://www.kame.net), and was based on the IPv4 PIM kernel support.
|
||||
.Pp
|
||||
This manual page was written by Pavlin Radoslavov (ICSI).
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* GBK first byte: 81-FE
|
||||
* second byte: 40-7E, 80-FE
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
ENCODING "GBK"
|
||||
/* VARIABLE GBK character set */
|
||||
|
||||
/*
|
||||
* ASCII
|
||||
*/
|
||||
ALPHA 'A' - 'Z' 'a' - 'z'
|
||||
CONTROL 0x00 - 0x1f 0x7f
|
||||
DIGIT '0' - '9'
|
||||
GRAPH 0x21 - 0x7e
|
||||
LOWER 'a' - 'z'
|
||||
PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
|
||||
SPACE 0x09 - 0x0d 0x20
|
||||
UPPER 'A' - 'Z'
|
||||
XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
|
||||
BLANK ' ' '\t'
|
||||
PRINT 0x20 - 0x7e
|
||||
|
||||
MAPLOWER < 'A' - 'Z' : 'a' > < 'a' - 'z' : 'a' >
|
||||
MAPUPPER < 'A' - 'Z' : 'A' > < 'a' - 'z' : 'A' >
|
||||
TODIGIT < '0' - '9' : 0 >
|
||||
TODIGIT < 'A' - 'F' : 10 > < 'a' - 'f' : 10 >
|
||||
|
||||
/*
|
||||
* the real thing
|
||||
*/
|
||||
IDEOGRAM 0x8140 - 0x817e 0x8180 - 0x81fe
|
||||
IDEOGRAM 0x8240 - 0x827e 0x8280 - 0x82fe
|
||||
IDEOGRAM 0x8340 - 0x837e 0x8380 - 0x83fe
|
||||
IDEOGRAM 0x8440 - 0x847e 0x8480 - 0x84fe
|
||||
IDEOGRAM 0x8540 - 0x857e 0x8580 - 0x85fe
|
||||
IDEOGRAM 0x8640 - 0x867e 0x8680 - 0x86fe
|
||||
IDEOGRAM 0x8740 - 0x877e 0x8780 - 0x87fe
|
||||
IDEOGRAM 0x8840 - 0x887e 0x8880 - 0x88fe
|
||||
IDEOGRAM 0x8940 - 0x897e 0x8980 - 0x89fe
|
||||
IDEOGRAM 0x8a40 - 0x8a7e 0x8a80 - 0x8afe
|
||||
IDEOGRAM 0x8b40 - 0x8b7e 0x8b80 - 0x8bfe
|
||||
IDEOGRAM 0x8c40 - 0x8c7e 0x8c80 - 0x8cfe
|
||||
IDEOGRAM 0x8d40 - 0x8d7e 0x8d80 - 0x8dfe
|
||||
IDEOGRAM 0x8e40 - 0x8e7e 0x8e80 - 0x8efe
|
||||
IDEOGRAM 0x8f40 - 0x8f7e 0x8f80 - 0x8ffe
|
||||
IDEOGRAM 0x9040 - 0x907e 0x9080 - 0x90fe
|
||||
IDEOGRAM 0x9140 - 0x917e 0x9180 - 0x91fe
|
||||
IDEOGRAM 0x9240 - 0x927e 0x9280 - 0x92fe
|
||||
IDEOGRAM 0x9340 - 0x937e 0x9380 - 0x93fe
|
||||
IDEOGRAM 0x9440 - 0x947e 0x9480 - 0x94fe
|
||||
IDEOGRAM 0x9540 - 0x957e 0x9580 - 0x95fe
|
||||
IDEOGRAM 0x9640 - 0x967e 0x9680 - 0x96fe
|
||||
IDEOGRAM 0x9740 - 0x977e 0x9780 - 0x97fe
|
||||
IDEOGRAM 0x9840 - 0x987e 0x9880 - 0x98fe
|
||||
IDEOGRAM 0x9940 - 0x997e 0x9980 - 0x99fe
|
||||
IDEOGRAM 0x9a40 - 0x9a7e 0x9a80 - 0x9afe
|
||||
IDEOGRAM 0x9b40 - 0x9b7e 0x9b80 - 0x9bfe
|
||||
IDEOGRAM 0x9c40 - 0x9c7e 0x9c80 - 0x9cfe
|
||||
IDEOGRAM 0x9d40 - 0x9d7e 0x9d80 - 0x9dfe
|
||||
IDEOGRAM 0x9e40 - 0x9e7e 0x9e80 - 0x9efe
|
||||
IDEOGRAM 0x9f40 - 0x9f7e 0x9f80 - 0x9ffe
|
||||
IDEOGRAM 0xa040 - 0xa07e 0xa080 - 0xa0fe
|
||||
|
||||
SPACE 0xa1a1
|
||||
BLANK 0xa1a1
|
||||
PUNCT 0xa1a2 - 0xa1fe
|
||||
|
||||
/* full width 0 1 2 .. 9 */
|
||||
/* ?DIGIT 0xa2a1 - 0xa2aa 0xa2b1 - 0xa2e2 0xa2e5 - 0xa2ee 0xa2f1 - 0xa2fc */
|
||||
|
||||
TODIGIT < 0xa2a1 - 0xa2aa : 1 >
|
||||
TODIGIT < 0xa2b1 - 0xa2c4 : 1 >
|
||||
TODIGIT < 0xa2c5 - 0xa2d8 : 1 >
|
||||
TODIGIT < 0xa2d9 - 0xa2e2 : 1 >
|
||||
TODIGIT < 0xa2e5 - 0xa2ee : 1 >
|
||||
TODIGIT < 0xa2f1 - 0xa2fc : 1 >
|
||||
|
||||
ALPHA 0xa3c1 - 0xa3da 0xa3e1 - 0xa3fa
|
||||
/* ?DIGIT 0xa3b0 - 0xa3b9 */
|
||||
UPPER 0xa3c1 - 0xa3da
|
||||
LOWER 0xa3e1 - 0xa3fa
|
||||
PUNCT 0xa3a1 - 0xa3af 0xa3ba - 0xa3c0 0xa3db - 0xa3e0 0xa3fb - 0xa3fe
|
||||
/* ?XDIGIT 0xa3b0 - 0xa3b9 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6 */
|
||||
|
||||
MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > < 0xa3e1 - 0xa3fa : 0xa3e1 >
|
||||
MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 > < 0xa3b0 - 0xa3b9 : 0xa3c1 >
|
||||
TODIGIT < 0xa3b0 - 0xa3b9 : 0 >
|
||||
TODIGIT < 0xa3c1 - 0xa3c6 : 10 > < 0xa3e1 - 0xa3e6 : 10 >
|
||||
|
||||
PHONOGRAM 0xa4a1 - 0xa4f3 /* Hiragana */
|
||||
PHONOGRAM 0xa5a1 - 0xa5f6 /* Katakana */
|
||||
|
||||
UPPER 0xa6a1 - 0xa6b8 /* Greek */
|
||||
LOWER 0xa6c1 - 0xa6d8 /* Greek */
|
||||
MAPLOWER < 0xa6a1 - 0xa6b8 : 0xa6c1 > < 0xa6c1 - 0xa6d8 : 0xa6c1 >
|
||||
MAPUPPER < 0xa6a1 - 0xa6b8 : 0xa6a1 > < 0xa6c1 - 0xa6d8 : 0xa6a1 >
|
||||
|
||||
UPPER 0xa7a1 - 0xa7c1 /* Cyrillic */
|
||||
LOWER 0xa7d1 - 0xa7f1 /* Cyrillic */
|
||||
MAPLOWER < 0xa7a1 - 0xa7c1 : 0xa7d1 > < 0xa7d1 - 0xa7f1 : 0xa7d1 >
|
||||
MAPUPPER < 0xa7a1 - 0xa7c1 : 0xa7a1 > < 0xa7d1 - 0xa7f1 : 0xa7a1 >
|
||||
|
||||
PUNCT 0xa840 - 0xa853
|
||||
SPECIAL 0xa854 - 0xa877 /* Box drawings */
|
||||
PUNCT 0xa878 - 0xa87e 0xa880 - 0xa895
|
||||
SPECIAL 0xa8a1 - 0xa8c0
|
||||
PHONOGRAM 0xa8c5 - 0xa8e9 /* Pin yin */
|
||||
TODIGIT < 0xa940 - 0xa948 : 1 >
|
||||
SPECIAL 0xa949 - 0xa95a 0xa95c 0xa960 - 0xa97e 0xa980 - 0xa996
|
||||
SPECIAL 0xa9a4 - 0xa9ef /* Box drawings */
|
||||
|
||||
IDEOGRAM 0xaa40 - 0xaa7e 0xaa80 - 0xaaa0
|
||||
IDEOGRAM 0xab40 - 0xab7e 0xab80 - 0xaba0
|
||||
IDEOGRAM 0xac40 - 0xac7e 0xac80 - 0xaca0
|
||||
IDEOGRAM 0xad40 - 0xad7e 0xad80 - 0xada0
|
||||
IDEOGRAM 0xae40 - 0xae7e 0xae80 - 0xaea0
|
||||
IDEOGRAM 0xaf40 - 0xaf7e 0xaf80 - 0xafa0
|
||||
IDEOGRAM 0xb040 - 0xb07e 0xb080 - 0xb0fe
|
||||
IDEOGRAM 0xb140 - 0xb17e 0xb180 - 0xb1fe
|
||||
IDEOGRAM 0xb240 - 0xb27e 0xb280 - 0xb2fe
|
||||
IDEOGRAM 0xb340 - 0xb37e 0xb380 - 0xb3fe
|
||||
IDEOGRAM 0xb440 - 0xb47e 0xb480 - 0xb4fe
|
||||
IDEOGRAM 0xb540 - 0xb57e 0xb580 - 0xb5fe
|
||||
IDEOGRAM 0xb640 - 0xb67e 0xb680 - 0xb6fe
|
||||
IDEOGRAM 0xb740 - 0xb77e 0xb780 - 0xb7fe
|
||||
IDEOGRAM 0xb840 - 0xb87e 0xb880 - 0xb8fe
|
||||
IDEOGRAM 0xb940 - 0xb97e 0xb980 - 0xb9fe
|
||||
IDEOGRAM 0xba40 - 0xba7e 0xba80 - 0xbafe
|
||||
IDEOGRAM 0xbb40 - 0xbb7e 0xbb80 - 0xbbfe
|
||||
IDEOGRAM 0xbc40 - 0xbc7e 0xbc80 - 0xbcfe
|
||||
IDEOGRAM 0xbd40 - 0xbd7e 0xbd80 - 0xbdfe
|
||||
IDEOGRAM 0xbe40 - 0xbe7e 0xbe80 - 0xbefe
|
||||
IDEOGRAM 0xbf40 - 0xbf7e 0xbf80 - 0xbffe
|
||||
IDEOGRAM 0xc040 - 0xc07e 0xc080 - 0xc0fe
|
||||
IDEOGRAM 0xc140 - 0xc17e 0xc180 - 0xc1fe
|
||||
IDEOGRAM 0xc240 - 0xc27e 0xc280 - 0xc2fe
|
||||
IDEOGRAM 0xc340 - 0xc37e 0xc380 - 0xc3fe
|
||||
IDEOGRAM 0xc440 - 0xc47e 0xc480 - 0xc4fe
|
||||
IDEOGRAM 0xc540 - 0xc57e 0xc580 - 0xc5fe
|
||||
IDEOGRAM 0xc640 - 0xc67e 0xc680 - 0xc6fe
|
||||
IDEOGRAM 0xc740 - 0xc77e 0xc780 - 0xc7fe
|
||||
IDEOGRAM 0xc840 - 0xc87e 0xc880 - 0xc8fe
|
||||
IDEOGRAM 0xc940 - 0xc97e 0xc980 - 0xc9fe
|
||||
IDEOGRAM 0xca40 - 0xca7e 0xca80 - 0xcafe
|
||||
IDEOGRAM 0xcb40 - 0xcb7e 0xcb80 - 0xcbfe
|
||||
IDEOGRAM 0xcc40 - 0xcc7e 0xcc80 - 0xccfe
|
||||
IDEOGRAM 0xcd40 - 0xcd7e 0xcd80 - 0xcdfe
|
||||
IDEOGRAM 0xce40 - 0xce7e 0xce80 - 0xcefe
|
||||
IDEOGRAM 0xcf40 - 0xcf7e 0xcf80 - 0xcffe
|
||||
IDEOGRAM 0xd040 - 0xd07e 0xd080 - 0xd0fe
|
||||
IDEOGRAM 0xd140 - 0xd17e 0xd180 - 0xd1fe
|
||||
IDEOGRAM 0xd240 - 0xd27e 0xd280 - 0xd2fe
|
||||
IDEOGRAM 0xd340 - 0xd37e 0xd380 - 0xd3fe
|
||||
IDEOGRAM 0xd440 - 0xd47e 0xd480 - 0xd4fe
|
||||
IDEOGRAM 0xd540 - 0xd57e 0xd580 - 0xd5fe
|
||||
IDEOGRAM 0xd640 - 0xd67e 0xd680 - 0xd6fe
|
||||
IDEOGRAM 0xd740 - 0xd77e 0xd780 - 0xd7fe
|
||||
IDEOGRAM 0xd840 - 0xd87e 0xd880 - 0xd8fe
|
||||
IDEOGRAM 0xd940 - 0xd97e 0xd980 - 0xd9fe
|
||||
IDEOGRAM 0xda40 - 0xda7e 0xda80 - 0xdafe
|
||||
IDEOGRAM 0xdb40 - 0xdb7e 0xdb80 - 0xdbfe
|
||||
IDEOGRAM 0xdc40 - 0xdc7e 0xdc80 - 0xdcfe
|
||||
IDEOGRAM 0xdd40 - 0xdd7e 0xdd80 - 0xddfe
|
||||
IDEOGRAM 0xde40 - 0xde7e 0xde80 - 0xdefe
|
||||
IDEOGRAM 0xdf40 - 0xdf7e 0xdf80 - 0xdffe
|
||||
IDEOGRAM 0xe040 - 0xe07e 0xe080 - 0xe0fe
|
||||
IDEOGRAM 0xe140 - 0xe17e 0xe180 - 0xe1fe
|
||||
IDEOGRAM 0xe240 - 0xe27e 0xe280 - 0xe2fe
|
||||
IDEOGRAM 0xe340 - 0xe37e 0xe380 - 0xe3fe
|
||||
IDEOGRAM 0xe440 - 0xe47e 0xe480 - 0xe4fe
|
||||
IDEOGRAM 0xe540 - 0xe57e 0xe580 - 0xe5fe
|
||||
IDEOGRAM 0xe640 - 0xe67e 0xe680 - 0xe6fe
|
||||
IDEOGRAM 0xe740 - 0xe77e 0xe780 - 0xe7fe
|
||||
IDEOGRAM 0xe840 - 0xe87e 0xe880 - 0xe8fe
|
||||
IDEOGRAM 0xe940 - 0xe97e 0xe980 - 0xe9fe
|
||||
IDEOGRAM 0xea40 - 0xea7e 0xea80 - 0xeafe
|
||||
IDEOGRAM 0xeb40 - 0xeb7e 0xeb80 - 0xebfe
|
||||
IDEOGRAM 0xec40 - 0xec7e 0xec80 - 0xecfe
|
||||
IDEOGRAM 0xed40 - 0xed7e 0xed80 - 0xedfe
|
||||
IDEOGRAM 0xee40 - 0xee7e 0xee80 - 0xeefe
|
||||
IDEOGRAM 0xef40 - 0xef7e 0xef80 - 0xeffe
|
||||
IDEOGRAM 0xf040 - 0xf07e 0xf080 - 0xf0fe
|
||||
IDEOGRAM 0xf140 - 0xf17e 0xf180 - 0xf1fe
|
||||
IDEOGRAM 0xf240 - 0xf27e 0xf280 - 0xf2fe
|
||||
IDEOGRAM 0xf340 - 0xf37e 0xf380 - 0xf3fe
|
||||
IDEOGRAM 0xf440 - 0xf47e 0xf480 - 0xf4fe
|
||||
IDEOGRAM 0xf540 - 0xf57e 0xf580 - 0xf5fe
|
||||
IDEOGRAM 0xf640 - 0xf67e 0xf680 - 0xf6fe
|
||||
IDEOGRAM 0xf740 - 0xf77e 0xf780 - 0xf7fe
|
||||
IDEOGRAM 0xf840 - 0xf87e 0xf880 - 0xf8a0
|
||||
IDEOGRAM 0xf940 - 0xf97e 0xf980 - 0xf9a0
|
||||
IDEOGRAM 0xfa40 - 0xfa7e 0xfa80 - 0xfaa0
|
||||
IDEOGRAM 0xfb40 - 0xfb7e 0xfb80 - 0xfba0
|
||||
IDEOGRAM 0xfc40 - 0xfc7e 0xfc80 - 0xfca0
|
||||
IDEOGRAM 0xfd40 - 0xfd7e 0xfd80 - 0xfda0
|
||||
IDEOGRAM 0xfe40 - 0xfe7e 0xfe80 - 0xfea0
|
||||
@@ -1,36 +0,0 @@
|
||||
# $FreeBSD$
|
||||
#
|
||||
# WARNING: spaces may be essential at the end of lines
|
||||
# WARNING: empty lines are essential too
|
||||
#
|
||||
# int_curr_symbol (last character always SPACE)
|
||||
CNY
|
||||
# currency_symbol
|
||||
£¤
|
||||
# mon_decimal_point
|
||||
.
|
||||
# mon_thousands_sep
|
||||
,
|
||||
# mon_grouping, separated by ;
|
||||
3;3
|
||||
# positive_sign
|
||||
|
||||
# negative_sign
|
||||
-
|
||||
# int_frac_digits
|
||||
0
|
||||
# frac_digits
|
||||
0
|
||||
# p_cs_precedes
|
||||
1
|
||||
# p_sep_by_space
|
||||
0
|
||||
# n_cs_precedes
|
||||
1
|
||||
# n_sep_by_space
|
||||
0
|
||||
# p_sign_posn
|
||||
1
|
||||
# n_sign_posn
|
||||
4
|
||||
# EOF
|
||||
@@ -1,14 +0,0 @@
|
||||
# $FreeBSD$
|
||||
#
|
||||
# WARNING: spaces may be essential at the end of lines
|
||||
# WARNING: empty lines are essential too
|
||||
#
|
||||
# yesexpr
|
||||
^[yYyY是].*
|
||||
# noexpr
|
||||
^[nNnN不否].*
|
||||
# yesstr
|
||||
是
|
||||
# nostr
|
||||
否
|
||||
# EOF
|
||||
@@ -1,102 +0,0 @@
|
||||
# $FreeBSD$
|
||||
#
|
||||
# WARNING: spaces may be essential at the end of lines
|
||||
# WARNING: empty lines are essential too
|
||||
#
|
||||
# Short month names
|
||||
#
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
#
|
||||
# Long month names
|
||||
#
|
||||
一月
|
||||
二月
|
||||
三月
|
||||
四月
|
||||
五月
|
||||
六月
|
||||
七月
|
||||
八月
|
||||
九月
|
||||
十月
|
||||
十一月
|
||||
十二月
|
||||
#
|
||||
# Short weekday names
|
||||
#
|
||||
日
|
||||
一
|
||||
二
|
||||
三
|
||||
四
|
||||
五
|
||||
六
|
||||
#
|
||||
# Long weekday names
|
||||
#
|
||||
星期日
|
||||
星期一
|
||||
星期二
|
||||
星期三
|
||||
星期四
|
||||
星期五
|
||||
星期六
|
||||
#
|
||||
# X_fmt
|
||||
#
|
||||
%H时%M分%S秒
|
||||
#
|
||||
# x_fmt
|
||||
#
|
||||
%Y/%m/%d
|
||||
#
|
||||
# c_fmt
|
||||
#
|
||||
%a %b/%e %T %Y
|
||||
#
|
||||
# am
|
||||
#
|
||||
上午
|
||||
#
|
||||
# pm
|
||||
#
|
||||
下午
|
||||
#
|
||||
# date_fmt
|
||||
#
|
||||
%Y年%b月%e日 %A %X %Z
|
||||
#
|
||||
# Long month names (alternative)
|
||||
#
|
||||
一月
|
||||
二月
|
||||
三月
|
||||
四月
|
||||
五月
|
||||
六月
|
||||
七月
|
||||
八月
|
||||
九月
|
||||
十月
|
||||
十一月
|
||||
十二月
|
||||
#
|
||||
# md_order
|
||||
#
|
||||
md
|
||||
#
|
||||
# ampm_fmt
|
||||
#
|
||||
%I:%M:%S %p
|
||||
# EOF
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
|
||||
TYPE="FreeBSD"
|
||||
REVISION="4.9"
|
||||
BRANCH="RC"
|
||||
BRANCH="RELEASE"
|
||||
RELEASE="${REVISION}-${BRANCH}"
|
||||
VERSION="${TYPE} ${RELEASE}"
|
||||
|
||||
|
||||
@@ -490,12 +490,12 @@ ata_dmainit(struct ata_device *atadev, int apiomode, int wdmamode, int udmamode)
|
||||
int32_t timing;
|
||||
|
||||
switch(ATA_PIO0 + apiomode) {
|
||||
case ATA_PIO0: timing = 0x006d0003;
|
||||
case ATA_PIO1: timing = 0x00580002;
|
||||
case ATA_PIO2: timing = 0x00440001;
|
||||
case ATA_PIO3: timing = 0x00330001;
|
||||
case ATA_PIO4: timing = 0x00310001;
|
||||
default: timing = 0x006d0003;
|
||||
case ATA_PIO0: timing = 0x006d0003; break;
|
||||
case ATA_PIO1: timing = 0x00580002; break;
|
||||
case ATA_PIO2: timing = 0x00440001; break;
|
||||
case ATA_PIO3: timing = 0x00330001; break;
|
||||
case ATA_PIO4: timing = 0x00310001; break;
|
||||
default: timing = 0x006d0003; break;
|
||||
}
|
||||
pci_write_config(parent, 0x58 + (channel << 2), timing, 4);
|
||||
word54 &= ~(0x000f000f << (devno << 2));
|
||||
|
||||
@@ -1,512 +0,0 @@
|
||||
/* Copyright (c) 2003 Stuart Walsh */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#ifndef _BFE_H
|
||||
#define _BFE_H
|
||||
|
||||
/* PCI registers */
|
||||
#define BFE_PCI_MEMLO 0x10
|
||||
#define BFE_PCI_MEMHIGH 0x14
|
||||
#define BFE_PCI_INTLINE 0x3C
|
||||
|
||||
/* Register layout. */
|
||||
#define BFE_DEVCTRL 0x00000000 /* Device Control */
|
||||
#define BFE_PFE 0x00000080 /* Pattern Filtering Enable */
|
||||
#define BFE_IPP 0x00000400 /* Internal EPHY Present */
|
||||
#define BFE_EPR 0x00008000 /* EPHY Reset */
|
||||
#define BFE_PME 0x00001000 /* PHY Mode Enable */
|
||||
#define BFE_PMCE 0x00002000 /* PHY Mode Clocks Enable */
|
||||
#define BFE_PADDR 0x0007c000 /* PHY Address */
|
||||
#define BFE_PADDR_SHIFT 18
|
||||
|
||||
#define BFE_BIST_STAT 0x0000000C /* Built-In Self-Test Status */
|
||||
#define BFE_WKUP_LEN 0x00000010 /* Wakeup Length */
|
||||
|
||||
#define BFE_ISTAT 0x00000020 /* Interrupt Status */
|
||||
#define BFE_ISTAT_PME 0x00000040 /* Power Management Event */
|
||||
#define BFE_ISTAT_TO 0x00000080 /* General Purpose Timeout */
|
||||
#define BFE_ISTAT_DSCE 0x00000400 /* Descriptor Error */
|
||||
#define BFE_ISTAT_DATAE 0x00000800 /* Data Error */
|
||||
#define BFE_ISTAT_DPE 0x00001000 /* Descr. Protocol Error */
|
||||
#define BFE_ISTAT_RDU 0x00002000 /* Receive Descr. Underflow */
|
||||
#define BFE_ISTAT_RFO 0x00004000 /* Receive FIFO Overflow */
|
||||
#define BFE_ISTAT_TFU 0x00008000 /* Transmit FIFO Underflow */
|
||||
#define BFE_ISTAT_RX 0x00010000 /* RX Interrupt */
|
||||
#define BFE_ISTAT_TX 0x01000000 /* TX Interrupt */
|
||||
#define BFE_ISTAT_EMAC 0x04000000 /* EMAC Interrupt */
|
||||
#define BFE_ISTAT_MII_WRITE 0x08000000 /* MII Write Interrupt */
|
||||
#define BFE_ISTAT_MII_READ 0x10000000 /* MII Read Interrupt */
|
||||
#define BFE_ISTAT_ERRORS (BFE_ISTAT_DSCE | BFE_ISTAT_DATAE | BFE_ISTAT_DPE |\
|
||||
BFE_ISTAT_RDU | BFE_ISTAT_RFO | BFE_ISTAT_TFU)
|
||||
|
||||
#define BFE_IMASK 0x00000024 /* Interrupt Mask */
|
||||
#define BFE_IMASK_DEF (BFE_ISTAT_ERRORS | BFE_ISTAT_TO | BFE_ISTAT_RX | \
|
||||
BFE_ISTAT_TX)
|
||||
|
||||
#define BFE_MAC_CTRL 0x000000A8 /* MAC Control */
|
||||
#define BFE_CTRL_CRC32_ENAB 0x00000001 /* CRC32 Generation Enable */
|
||||
#define BFE_CTRL_PDOWN 0x00000004 /* Onchip EPHY Powerdown */
|
||||
#define BFE_CTRL_EDET 0x00000008 /* Onchip EPHY Energy Detected */
|
||||
#define BFE_CTRL_LED 0x000000e0 /* Onchip EPHY LED Control */
|
||||
#define BFE_CTRL_LED_SHIFT 5
|
||||
|
||||
#define BFE_RCV_LAZY 0x00000100 /* Lazy Interrupt Control */
|
||||
#define BFE_LAZY_TO_MASK 0x00ffffff /* Timeout */
|
||||
#define BFE_LAZY_FC_MASK 0xff000000 /* Frame Count */
|
||||
#define BFE_LAZY_FC_SHIFT 24
|
||||
|
||||
#define BFE_DMATX_CTRL 0x00000200 /* DMA TX Control */
|
||||
#define BFE_TX_CTRL_ENABLE 0x00000001 /* Enable */
|
||||
#define BFE_TX_CTRL_SUSPEND 0x00000002 /* Suepend Request */
|
||||
#define BFE_TX_CTRL_LPBACK 0x00000004 /* Loopback Enable */
|
||||
#define BFE_TX_CTRL_FAIRPRI 0x00000008 /* Fair Priority */
|
||||
#define BFE_TX_CTRL_FLUSH 0x00000010 /* Flush Request */
|
||||
|
||||
#define BFE_DMATX_ADDR 0x00000204 /* DMA TX Descriptor Ring Address */
|
||||
#define BFE_DMATX_PTR 0x00000208 /* DMA TX Last Posted Descriptor */
|
||||
#define BFE_DMATX_STAT 0x0000020C /* DMA TX Current Active Desc. + Status */
|
||||
#define BFE_STAT_CDMASK 0x00000fff /* Current Descriptor Mask */
|
||||
#define BFE_STAT_SMASK 0x0000f000 /* State Mask */
|
||||
#define BFE_STAT_DISABLE 0x00000000 /* State Disabled */
|
||||
#define BFE_STAT_SACTIVE 0x00001000 /* State Active */
|
||||
#define BFE_STAT_SIDLE 0x00002000 /* State Idle Wait */
|
||||
#define BFE_STAT_STOPPED 0x00003000 /* State Stopped */
|
||||
#define BFE_STAT_SSUSP 0x00004000 /* State Suspend Pending */
|
||||
#define BFE_STAT_EMASK 0x000f0000 /* Error Mask */
|
||||
#define BFE_STAT_ENONE 0x00000000 /* Error None */
|
||||
#define BFE_STAT_EDPE 0x00010000 /* Error Desc. Protocol Error */
|
||||
#define BFE_STAT_EDFU 0x00020000 /* Error Data FIFO Underrun */
|
||||
#define BFE_STAT_EBEBR 0x00030000 /* Error Bus Error on Buffer Read */
|
||||
#define BFE_STAT_EBEDA 0x00040000 /* Error Bus Error on Desc. Access */
|
||||
#define BFE_STAT_FLUSHED 0x00100000 /* Flushed */
|
||||
|
||||
#define BFE_DMARX_CTRL 0x00000210 /* DMA RX Control */
|
||||
#define BFE_RX_CTRL_ENABLE 0x00000001 /* Enable */
|
||||
#define BFE_RX_CTRL_ROMASK 0x000000fe /* Receive Offset Mask */
|
||||
#define BFE_RX_CTRL_ROSHIFT 1 /* Receive Offset Shift */
|
||||
|
||||
#define BFE_DMARX_ADDR 0x00000214 /* DMA RX Descriptor Ring Address */
|
||||
#define BFE_DMARX_PTR 0x00000218 /* DMA RX Last Posted Descriptor */
|
||||
#define BFE_DMARX_STAT 0x0000021C /* DMA RX Current Active Desc. + Status */
|
||||
|
||||
#define BFE_RXCONF 0x00000400 /* EMAC RX Config */
|
||||
#define BFE_RXCONF_DBCAST 0x00000001 /* Disable Broadcast */
|
||||
#define BFE_RXCONF_ALLMULTI 0x00000002 /* Accept All Multicast */
|
||||
#define BFE_RXCONF_NORXTX 0x00000004 /* Receive Disable While Transmitting */
|
||||
#define BFE_RXCONF_PROMISC 0x00000008 /* Promiscuous Enable */
|
||||
#define BFE_RXCONF_LPBACK 0x00000010 /* Loopback Enable */
|
||||
#define BFE_RXCONF_FLOW 0x00000020 /* Flow Control Enable */
|
||||
#define BFE_RXCONF_ACCEPT 0x00000040 /* Accept Unicast Flow Control Frame */
|
||||
#define BFE_RXCONF_RFILT 0x00000080 /* Reject Filter */
|
||||
|
||||
#define BFE_RXMAXLEN 0x00000404 /* EMAC RX Max Packet Length */
|
||||
#define BFE_TXMAXLEN 0x00000408 /* EMAC TX Max Packet Length */
|
||||
|
||||
#define BFE_MDIO_CTRL 0x00000410 /* EMAC MDIO Control */
|
||||
#define BFE_MDIO_MAXF_MASK 0x0000007f /* MDC Frequency */
|
||||
#define BFE_MDIO_PREAMBLE 0x00000080 /* MII Preamble Enable */
|
||||
|
||||
#define BFE_MDIO_DATA 0x00000414 /* EMAC MDIO Data */
|
||||
#define BFE_MDIO_DATA_DATA 0x0000ffff /* R/W Data */
|
||||
#define BFE_MDIO_TA_MASK 0x00030000 /* Turnaround Value */
|
||||
#define BFE_MDIO_TA_SHIFT 16
|
||||
#define BFE_MDIO_TA_VALID 2
|
||||
|
||||
#define BFE_MDIO_RA_MASK 0x007c0000 /* Register Address */
|
||||
#define BFE_MDIO_PMD_MASK 0x0f800000 /* Physical Media Device */
|
||||
#define BFE_MDIO_OP_MASK 0x30000000 /* Opcode */
|
||||
#define BFE_MDIO_SB_MASK 0xc0000000 /* Start Bits */
|
||||
#define BFE_MDIO_SB_START 0x40000000 /* Start Of Frame */
|
||||
#define BFE_MDIO_RA_SHIFT 18
|
||||
#define BFE_MDIO_PMD_SHIFT 23
|
||||
#define BFE_MDIO_OP_SHIFT 28
|
||||
#define BFE_MDIO_OP_WRITE 1
|
||||
#define BFE_MDIO_OP_READ 2
|
||||
#define BFE_MDIO_SB_SHIFT 30
|
||||
|
||||
#define BFE_EMAC_IMASK 0x00000418 /* EMAC Interrupt Mask */
|
||||
#define BFE_EMAC_ISTAT 0x0000041C /* EMAC Interrupt Status */
|
||||
#define BFE_EMAC_INT_MII 0x00000001 /* MII MDIO Interrupt */
|
||||
#define BFE_EMAC_INT_MIB 0x00000002 /* MIB Interrupt */
|
||||
#define BFE_EMAC_INT_FLOW 0x00000003 /* Flow Control Interrupt */
|
||||
|
||||
#define BFE_CAM_DATA_LO 0x00000420 /* EMAC CAM Data Low */
|
||||
#define BFE_CAM_DATA_HI 0x00000424 /* EMAC CAM Data High */
|
||||
#define BFE_CAM_HI_VALID 0x00010000 /* Valid Bit */
|
||||
|
||||
#define BFE_CAM_CTRL 0x00000428 /* EMAC CAM Control */
|
||||
#define BFE_CAM_ENABLE 0x00000001 /* CAM Enable */
|
||||
#define BFE_CAM_MSEL 0x00000002 /* Mask Select */
|
||||
#define BFE_CAM_READ 0x00000004 /* Read */
|
||||
#define BFE_CAM_WRITE 0x00000008 /* Read */
|
||||
#define BFE_CAM_INDEX_MASK 0x003f0000 /* Index Mask */
|
||||
#define BFE_CAM_BUSY 0x80000000 /* CAM Busy */
|
||||
#define BFE_CAM_INDEX_SHIFT 16
|
||||
|
||||
#define BFE_ENET_CTRL 0x0000042C /* EMAC ENET Control */
|
||||
#define BFE_ENET_ENABLE 0x00000001 /* EMAC Enable */
|
||||
#define BFE_ENET_DISABLE 0x00000002 /* EMAC Disable */
|
||||
#define BFE_ENET_SRST 0x00000004 /* EMAC Soft Reset */
|
||||
#define BFE_ENET_EPSEL 0x00000008 /* External PHY Select */
|
||||
|
||||
#define BFE_TX_CTRL 0x00000430 /* EMAC TX Control */
|
||||
#define BFE_TX_DUPLEX 0x00000001 /* Full Duplex */
|
||||
#define BFE_TX_FMODE 0x00000002 /* Flow Mode */
|
||||
#define BFE_TX_SBENAB 0x00000004 /* Single Backoff Enable */
|
||||
#define BFE_TX_SMALL_SLOT 0x00000008 /* Small Slottime */
|
||||
|
||||
#define BFE_TX_WMARK 0x00000434 /* EMAC TX Watermark */
|
||||
|
||||
#define BFE_MIB_CTRL 0x00000438 /* EMAC MIB Control */
|
||||
#define BFE_MIB_CLR_ON_READ 0x00000001 /* Autoclear on Read */
|
||||
|
||||
/* Status registers */
|
||||
#define BFE_TX_GOOD_O 0x00000500 /* MIB TX Good Octets */
|
||||
#define BFE_TX_GOOD_P 0x00000504 /* MIB TX Good Packets */
|
||||
#define BFE_TX_O 0x00000508 /* MIB TX Octets */
|
||||
#define BFE_TX_P 0x0000050C /* MIB TX Packets */
|
||||
#define BFE_TX_BCAST 0x00000510 /* MIB TX Broadcast Packets */
|
||||
#define BFE_TX_MCAST 0x00000514 /* MIB TX Multicast Packets */
|
||||
#define BFE_TX_64 0x00000518 /* MIB TX <= 64 byte Packets */
|
||||
#define BFE_TX_65_127 0x0000051C /* MIB TX 65 to 127 byte Packets */
|
||||
#define BFE_TX_128_255 0x00000520 /* MIB TX 128 to 255 byte Packets */
|
||||
#define BFE_TX_256_511 0x00000524 /* MIB TX 256 to 511 byte Packets */
|
||||
#define BFE_TX_512_1023 0x00000528 /* MIB TX 512 to 1023 byte Packets */
|
||||
#define BFE_TX_1024_MAX 0x0000052C /* MIB TX 1024 to max byte Packets */
|
||||
#define BFE_TX_JABBER 0x00000530 /* MIB TX Jabber Packets */
|
||||
#define BFE_TX_OSIZE 0x00000534 /* MIB TX Oversize Packets */
|
||||
#define BFE_TX_FRAG 0x00000538 /* MIB TX Fragment Packets */
|
||||
#define BFE_TX_URUNS 0x0000053C /* MIB TX Underruns */
|
||||
#define BFE_TX_TCOLS 0x00000540 /* MIB TX Total Collisions */
|
||||
#define BFE_TX_SCOLS 0x00000544 /* MIB TX Single Collisions */
|
||||
#define BFE_TX_MCOLS 0x00000548 /* MIB TX Multiple Collisions */
|
||||
#define BFE_TX_ECOLS 0x0000054C /* MIB TX Excessive Collisions */
|
||||
#define BFE_TX_LCOLS 0x00000550 /* MIB TX Late Collisions */
|
||||
#define BFE_TX_DEFERED 0x00000554 /* MIB TX Defered Packets */
|
||||
#define BFE_TX_CLOST 0x00000558 /* MIB TX Carrier Lost */
|
||||
#define BFE_TX_PAUSE 0x0000055C /* MIB TX Pause Packets */
|
||||
#define BFE_RX_GOOD_O 0x00000580 /* MIB RX Good Octets */
|
||||
#define BFE_RX_GOOD_P 0x00000584 /* MIB RX Good Packets */
|
||||
#define BFE_RX_O 0x00000588 /* MIB RX Octets */
|
||||
#define BFE_RX_P 0x0000058C /* MIB RX Packets */
|
||||
#define BFE_RX_BCAST 0x00000590 /* MIB RX Broadcast Packets */
|
||||
#define BFE_RX_MCAST 0x00000594 /* MIB RX Multicast Packets */
|
||||
#define BFE_RX_64 0x00000598 /* MIB RX <= 64 byte Packets */
|
||||
#define BFE_RX_65_127 0x0000059C /* MIB RX 65 to 127 byte Packets */
|
||||
#define BFE_RX_128_255 0x000005A0 /* MIB RX 128 to 255 byte Packets */
|
||||
#define BFE_RX_256_511 0x000005A4 /* MIB RX 256 to 511 byte Packets */
|
||||
#define BFE_RX_512_1023 0x000005A8 /* MIB RX 512 to 1023 byte Packets */
|
||||
#define BFE_RX_1024_MAX 0x000005AC /* MIB RX 1024 to max byte Packets */
|
||||
#define BFE_RX_JABBER 0x000005B0 /* MIB RX Jabber Packets */
|
||||
#define BFE_RX_OSIZE 0x000005B4 /* MIB RX Oversize Packets */
|
||||
#define BFE_RX_FRAG 0x000005B8 /* MIB RX Fragment Packets */
|
||||
#define BFE_RX_MISS 0x000005BC /* MIB RX Missed Packets */
|
||||
#define BFE_RX_CRCA 0x000005C0 /* MIB RX CRC Align Errors */
|
||||
#define BFE_RX_USIZE 0x000005C4 /* MIB RX Undersize Packets */
|
||||
#define BFE_RX_CRC 0x000005C8 /* MIB RX CRC Errors */
|
||||
#define BFE_RX_ALIGN 0x000005CC /* MIB RX Align Errors */
|
||||
#define BFE_RX_SYM 0x000005D0 /* MIB RX Symbol Errors */
|
||||
#define BFE_RX_PAUSE 0x000005D4 /* MIB RX Pause Packets */
|
||||
#define BFE_RX_NPAUSE 0x000005D8 /* MIB RX Non-Pause Packets */
|
||||
|
||||
#define BFE_SBIMSTATE 0x00000F90 /* BFE_SB Initiator Agent State */
|
||||
#define BFE_PC 0x0000000f /* Pipe Count */
|
||||
#define BFE_AP_MASK 0x00000030 /* Arbitration Priority */
|
||||
#define BFE_AP_BOTH 0x00000000 /* Use both timeslices and token */
|
||||
#define BFE_AP_TS 0x00000010 /* Use timeslices only */
|
||||
#define BFE_AP_TK 0x00000020 /* Use token only */
|
||||
#define BFE_AP_RSV 0x00000030 /* Reserved */
|
||||
#define BFE_IBE 0x00020000 /* In Band Error */
|
||||
#define BFE_TO 0x00040000 /* Timeout */
|
||||
|
||||
|
||||
/* Seems the bcm440x has a fairly generic core, we only need be concerned with
|
||||
* a couple of these
|
||||
*/
|
||||
#define BFE_SBINTVEC 0x00000F94 /* BFE_SB Interrupt Mask */
|
||||
#define BFE_INTVEC_PCI 0x00000001 /* Enable interrupts for PCI */
|
||||
#define BFE_INTVEC_ENET0 0x00000002 /* Enable interrupts for enet 0 */
|
||||
#define BFE_INTVEC_ILINE20 0x00000004 /* Enable interrupts for iline20 */
|
||||
#define BFE_INTVEC_CODEC 0x00000008 /* Enable interrupts for v90 codec */
|
||||
#define BFE_INTVEC_USB 0x00000010 /* Enable interrupts for usb */
|
||||
#define BFE_INTVEC_EXTIF 0x00000020 /* Enable interrupts for external i/f */
|
||||
#define BFE_INTVEC_ENET1 0x00000040 /* Enable interrupts for enet 1 */
|
||||
|
||||
#define BFE_SBTMSLOW 0x00000F98 /* BFE_SB Target State Low */
|
||||
#define BFE_RESET 0x00000001 /* Reset */
|
||||
#define BFE_REJECT 0x00000002 /* Reject */
|
||||
#define BFE_CLOCK 0x00010000 /* Clock Enable */
|
||||
#define BFE_FGC 0x00020000 /* Force Gated Clocks On */
|
||||
#define BFE_PE 0x40000000 /* Power Management Enable */
|
||||
#define BFE_BE 0x80000000 /* BIST Enable */
|
||||
|
||||
#define BFE_SBTMSHIGH 0x00000F9C /* BFE_SB Target State High */
|
||||
#define BFE_SERR 0x00000001 /* S-error */
|
||||
#define BFE_INT 0x00000002 /* Interrupt */
|
||||
#define BFE_BUSY 0x00000004 /* Busy */
|
||||
#define BFE_GCR 0x20000000 /* Gated Clock Request */
|
||||
#define BFE_BISTF 0x40000000 /* BIST Failed */
|
||||
#define BFE_BISTD 0x80000000 /* BIST Done */
|
||||
|
||||
#define BFE_SBBWA0 0x00000FA0 /* BFE_SB Bandwidth Allocation Table 0 */
|
||||
#define BFE_TAB0_MASK 0x0000ffff /* Lookup Table 0 */
|
||||
#define BFE_TAB1_MASK 0xffff0000 /* Lookup Table 0 */
|
||||
#define BFE_TAB0_SHIFT 0
|
||||
#define BFE_TAB1_SHIFT 16
|
||||
|
||||
#define BFE_SBIMCFGLOW 0x00000FA8 /* BFE_SB Initiator Configuration Low */
|
||||
#define BFE_STO_MASK 0x00000003 /* Service Timeout */
|
||||
#define BFE_RTO_MASK 0x00000030 /* Request Timeout */
|
||||
#define BFE_CID_MASK 0x00ff0000 /* Connection ID */
|
||||
#define BFE_RTO_SHIFT 4
|
||||
#define BFE_CID_SHIFT 16
|
||||
|
||||
#define BFE_SBIMCFGHIGH 0x00000FAC /* BFE_SB Initiator Configuration High */
|
||||
#define BFE_IEM_MASK 0x0000000c /* Inband Error Mode */
|
||||
#define BFE_TEM_MASK 0x00000030 /* Timeout Error Mode */
|
||||
#define BFE_BEM_MASK 0x000000c0 /* Bus Error Mode */
|
||||
#define BFE_TEM_SHIFT 4
|
||||
#define BFE_BEM_SHIFT 6
|
||||
|
||||
#define BFE_SBTMCFGLOW 0x00000FB8 /* BFE_SB Target Configuration Low */
|
||||
#define BFE_LOW_CD_MASK 0x000000ff /* Clock Divide Mask */
|
||||
#define BFE_LOW_CO_MASK 0x0000f800 /* Clock Offset Mask */
|
||||
#define BFE_LOW_IF_MASK 0x00fc0000 /* Interrupt Flags Mask */
|
||||
#define BFE_LOW_IM_MASK 0x03000000 /* Interrupt Mode Mask */
|
||||
#define BFE_LOW_CO_SHIFT 11
|
||||
#define BFE_LOW_IF_SHIFT 18
|
||||
#define BFE_LOW_IM_SHIFT 24
|
||||
|
||||
#define BFE_SBTMCFGHIGH 0x00000FBC /* BFE_SB Target Configuration High */
|
||||
#define BFE_HIGH_BM_MASK 0x00000003 /* Busy Mode */
|
||||
#define BFE_HIGH_RM_MASK 0x0000000C /* Retry Mode */
|
||||
#define BFE_HIGH_SM_MASK 0x00000030 /* Stop Mode */
|
||||
#define BFE_HIGH_EM_MASK 0x00000300 /* Error Mode */
|
||||
#define BFE_HIGH_IM_MASK 0x00000c00 /* Interrupt Mode */
|
||||
#define BFE_HIGH_RM_SHIFT 2
|
||||
#define BFE_HIGH_SM_SHIFT 4
|
||||
#define BFE_HIGH_EM_SHIFT 8
|
||||
#define BFE_HIGH_IM_SHIFT 10
|
||||
|
||||
#define BFE_SBBCFG 0x00000FC0 /* BFE_SB Broadcast Configuration */
|
||||
#define BFE_LAT_MASK 0x00000003 /* BFE_SB Latency */
|
||||
#define BFE_MAX0_MASK 0x000f0000 /* MAX Counter 0 */
|
||||
#define BFE_MAX1_MASK 0x00f00000 /* MAX Counter 1 */
|
||||
#define BFE_MAX0_SHIFT 16
|
||||
#define BFE_MAX1_SHIFT 20
|
||||
|
||||
#define BFE_SBBSTATE 0x00000FC8 /* BFE_SB Broadcast State */
|
||||
#define BFE_SBBSTATE_SRD 0x00000001 /* ST Reg Disable */
|
||||
#define BFE_SBBSTATE_HRD 0x00000002 /* Hold Reg Disable */
|
||||
|
||||
#define BFE_SBACTCNFG 0x00000FD8 /* BFE_SB Activate Configuration */
|
||||
#define BFE_SBFLAGST 0x00000FE8 /* BFE_SB Current BFE_SBFLAGS */
|
||||
|
||||
#define BFE_SBIDLOW 0x00000FF8 /* BFE_SB Identification Low */
|
||||
#define BFE_CS_MASK 0x00000003 /* Config Space Mask */
|
||||
#define BFE_AR_MASK 0x00000038 /* Num Address Ranges Supported */
|
||||
#define BFE_SYNCH 0x00000040 /* Sync */
|
||||
#define BFE_INIT 0x00000080 /* Initiator */
|
||||
#define BFE_MINLAT_MASK 0x00000f00 /* Minimum Backplane Latency */
|
||||
#define BFE_MAXLAT_MASK 0x0000f000 /* Maximum Backplane Latency */
|
||||
#define BFE_FIRST 0x00010000 /* This Initiator is First */
|
||||
#define BFE_CW_MASK 0x000c0000 /* Cycle Counter Width */
|
||||
#define BFE_TP_MASK 0x00f00000 /* Target Ports */
|
||||
#define BFE_IP_MASK 0x0f000000 /* Initiator Ports */
|
||||
#define BFE_AR_SHIFT 3
|
||||
#define BFE_MINLAT_SHIFT 8
|
||||
#define BFE_MAXLAT_SHIFT 12
|
||||
#define BFE_CW_SHIFT 18
|
||||
#define BFE_TP_SHIFT 20
|
||||
#define BFE_IP_SHIFT 24
|
||||
|
||||
#define BFE_SBIDHIGH 0x00000FFC /* BFE_SB Identification High */
|
||||
#define BFE_RC_MASK 0x0000000f /* Revision Code */
|
||||
#define BFE_CC_MASK 0x0000fff0 /* Core Code */
|
||||
#define BFE_VC_MASK 0xffff0000 /* Vendor Code */
|
||||
#define BFE_CC_SHIFT 4
|
||||
#define BFE_VC_SHIFT 16
|
||||
|
||||
#define BFE_CORE_ILINE20 0x801
|
||||
#define BFE_CORE_SDRAM 0x803
|
||||
#define BFE_CORE_PCI 0x804
|
||||
#define BFE_CORE_MIPS 0x805
|
||||
#define BFE_CORE_ENET 0x806
|
||||
#define BFE_CORE_CODEC 0x807
|
||||
#define BFE_CORE_USB 0x808
|
||||
#define BFE_CORE_ILINE100 0x80a
|
||||
#define BFE_CORE_EXTIF 0x811
|
||||
|
||||
/* SSB PCI config space registers. */
|
||||
#define BFE_BAR0_WIN 0x80
|
||||
#define BFE_BAR1_WIN 0x84
|
||||
#define BFE_SPROM_CONTROL 0x88
|
||||
#define BFE_BAR1_CONTROL 0x8c
|
||||
|
||||
/* SSB core and hsot control registers. */
|
||||
#define BFE_SSB_CONTROL 0x00000000
|
||||
#define BFE_SSB_ARBCONTROL 0x00000010
|
||||
#define BFE_SSB_ISTAT 0x00000020
|
||||
#define BFE_SSB_IMASK 0x00000024
|
||||
#define BFE_SSB_MBOX 0x00000028
|
||||
#define BFE_SSB_BCAST_ADDR 0x00000050
|
||||
#define BFE_SSB_BCAST_DATA 0x00000054
|
||||
#define BFE_SSB_PCI_TRANS_0 0x00000100
|
||||
#define BFE_SSB_PCI_TRANS_1 0x00000104
|
||||
#define BFE_SSB_PCI_TRANS_2 0x00000108
|
||||
#define BFE_SSB_SPROM 0x00000800
|
||||
|
||||
#define BFE_SSB_PCI_MEM 0x00000000
|
||||
#define BFE_SSB_PCI_IO 0x00000001
|
||||
#define BFE_SSB_PCI_CFG0 0x00000002
|
||||
#define BFE_SSB_PCI_CFG1 0x00000003
|
||||
#define BFE_SSB_PCI_PREF 0x00000004
|
||||
#define BFE_SSB_PCI_BURST 0x00000008
|
||||
#define BFE_SSB_PCI_MASK0 0xfc000000
|
||||
#define BFE_SSB_PCI_MASK1 0xfc000000
|
||||
#define BFE_SSB_PCI_MASK2 0xc0000000
|
||||
|
||||
#define BFE_DESC_LEN 0x00001fff
|
||||
#define BFE_DESC_CMASK 0x0ff00000 /* Core specific bits */
|
||||
#define BFE_DESC_EOT 0x10000000 /* End of Table */
|
||||
#define BFE_DESC_IOC 0x20000000 /* Interrupt On Completion */
|
||||
#define BFE_DESC_EOF 0x40000000 /* End of Frame */
|
||||
#define BFE_DESC_SOF 0x80000000 /* Start of Frame */
|
||||
|
||||
#define BFE_RX_CP_THRESHOLD 256
|
||||
#define BFE_RX_HEADER_LEN 28
|
||||
|
||||
#define BFE_RX_FLAG_OFIFO 0x00000001 /* FIFO Overflow */
|
||||
#define BFE_RX_FLAG_CRCERR 0x00000002 /* CRC Error */
|
||||
#define BFE_RX_FLAG_SERR 0x00000004 /* Receive Symbol Error */
|
||||
#define BFE_RX_FLAG_ODD 0x00000008 /* Frame has odd number of nibbles */
|
||||
#define BFE_RX_FLAG_LARGE 0x00000010 /* Frame is > RX MAX Length */
|
||||
#define BFE_RX_FLAG_MCAST 0x00000020 /* Dest is Multicast Address */
|
||||
#define BFE_RX_FLAG_BCAST 0x00000040 /* Dest is Broadcast Address */
|
||||
#define BFE_RX_FLAG_MISS 0x00000080 /* Received due to promisc mode */
|
||||
#define BFE_RX_FLAG_LAST 0x00000800 /* Last buffer in frame */
|
||||
#define BFE_RX_FLAG_ERRORS (BFE_RX_FLAG_ODD | BFE_RX_FLAG_SERR | \
|
||||
BFE_RX_FLAG_CRCERR | BFE_RX_FLAG_OFIFO)
|
||||
|
||||
#define BFE_MCAST_TBL_SIZE 32
|
||||
#define BFE_PCI_DMA 0x40000000
|
||||
#define BFE_REG_PCI 0x18002000
|
||||
|
||||
#define BCOM_VENDORID 0x14E4
|
||||
#define BCOM_DEVICEID_BCM4401 0x4401
|
||||
|
||||
#define PCI_SETBIT(dev, reg, x, s) \
|
||||
pci_write_config(dev, reg, (pci_read_config(dev, reg, s) | (x)), s)
|
||||
#define PCI_CLRBIT(dev, reg, x, s) \
|
||||
pci_write_config(dev, reg, (pci_read_config(dev, reg, s) & ~(x)), s)
|
||||
|
||||
#define BFE_RX_RING_SIZE 512
|
||||
#define BFE_TX_RING_SIZE 512
|
||||
#define BFE_LINK_DOWN 5
|
||||
#define BFE_TX_LIST_CNT 511
|
||||
#define BFE_RX_LIST_CNT 511
|
||||
#define BFE_TX_LIST_SIZE BFE_TX_LIST_CNT * sizeof(struct bfe_desc)
|
||||
#define BFE_RX_LIST_SIZE BFE_RX_LIST_CNT * sizeof(struct bfe_desc)
|
||||
#define BFE_RX_OFFSET 30
|
||||
#define BFE_TX_QLEN 256
|
||||
|
||||
#define CSR_READ_4(sc, reg) \
|
||||
bus_space_read_4(sc->bfe_btag, sc->bfe_bhandle, reg)
|
||||
|
||||
#define CSR_WRITE_4(sc, reg, val) \
|
||||
bus_space_write_4(sc->bfe_btag, sc->bfe_bhandle, reg, val)
|
||||
|
||||
#define BFE_OR(sc, name, val) \
|
||||
CSR_WRITE_4(sc, name, CSR_READ_4(sc, name) | val)
|
||||
|
||||
#define BFE_AND(sc, name, val) \
|
||||
CSR_WRITE_4(sc, name, CSR_READ_4(sc, name) & val)
|
||||
|
||||
#define BFE_LOCK(scp) mtx_lock(&sc->bfe_mtx)
|
||||
#define BFE_UNLOCK(scp) mtx_unlock(&sc->bfe_mtx)
|
||||
|
||||
#define BFE_INC(x, y) (x) = ((x) == ((y)-1)) ? 0 : (x)+1
|
||||
|
||||
struct bfe_data {
|
||||
struct mbuf *bfe_mbuf;
|
||||
bus_dmamap_t bfe_map;
|
||||
};
|
||||
|
||||
struct bfe_desc {
|
||||
u_int32_t bfe_ctrl;
|
||||
u_int32_t bfe_addr;
|
||||
};
|
||||
|
||||
struct bfe_rxheader {
|
||||
u_int16_t len;
|
||||
u_int16_t flags;
|
||||
u_int16_t pad[12];
|
||||
};
|
||||
|
||||
struct bfe_hw_stats {
|
||||
u_int32_t tx_good_octets, tx_good_pkts, tx_octets;
|
||||
u_int32_t tx_pkts, tx_broadcast_pkts, tx_multicast_pkts;
|
||||
u_int32_t tx_len_64, tx_len_65_to_127, tx_len_128_to_255;
|
||||
u_int32_t tx_len_256_to_511, tx_len_512_to_1023, tx_len_1024_to_max;
|
||||
u_int32_t tx_jabber_pkts, tx_oversize_pkts, tx_fragment_pkts;
|
||||
u_int32_t tx_underruns, tx_total_cols, tx_single_cols;
|
||||
u_int32_t tx_multiple_cols, tx_excessive_cols, tx_late_cols;
|
||||
u_int32_t tx_defered, tx_carrier_lost, tx_pause_pkts;
|
||||
u_int32_t __pad1[8];
|
||||
|
||||
u_int32_t rx_good_octets, rx_good_pkts, rx_octets;
|
||||
u_int32_t rx_pkts, rx_broadcast_pkts, rx_multicast_pkts;
|
||||
u_int32_t rx_len_64, rx_len_65_to_127, rx_len_128_to_255;
|
||||
u_int32_t rx_len_256_to_511, rx_len_512_to_1023, rx_len_1024_to_max;
|
||||
u_int32_t rx_jabber_pkts, rx_oversize_pkts, rx_fragment_pkts;
|
||||
u_int32_t rx_missed_pkts, rx_crc_align_errs, rx_undersize;
|
||||
u_int32_t rx_crc_errs, rx_align_errs, rx_symbol_errs;
|
||||
u_int32_t rx_pause_pkts, rx_nonpause_pkts;
|
||||
};
|
||||
|
||||
struct bfe_softc
|
||||
{
|
||||
struct arpcom arpcom; /* interface info */
|
||||
device_t bfe_dev;
|
||||
device_t bfe_miibus;
|
||||
bus_space_handle_t bfe_bhandle;
|
||||
vm_offset_t bfe_vhandle;
|
||||
bus_space_tag_t bfe_btag;
|
||||
bus_dma_tag_t bfe_tag;
|
||||
bus_dma_tag_t bfe_parent_tag;
|
||||
bus_dma_tag_t bfe_tx_tag, bfe_rx_tag;
|
||||
bus_dmamap_t bfe_tx_map, bfe_rx_map;
|
||||
void *bfe_intrhand;
|
||||
struct resource *bfe_irq;
|
||||
struct resource *bfe_res;
|
||||
struct callout_handle bfe_stat_ch;
|
||||
struct bfe_hw_stats bfe_hwstats;
|
||||
struct bfe_desc *bfe_tx_list, *bfe_rx_list;
|
||||
struct bfe_data bfe_tx_ring[BFE_TX_LIST_CNT]; /* XXX */
|
||||
struct bfe_data bfe_rx_ring[BFE_RX_LIST_CNT]; /* XXX */
|
||||
struct mtx bfe_mtx;
|
||||
u_int32_t bfe_flags;
|
||||
u_int32_t bfe_imask;
|
||||
u_int32_t bfe_dma_offset;
|
||||
u_int32_t bfe_tx_cnt, bfe_tx_cons, bfe_tx_prod;
|
||||
u_int32_t bfe_rx_cnt, bfe_rx_prod, bfe_rx_cons;
|
||||
u_int32_t bfe_tx_dma, bfe_rx_dma;
|
||||
u_int32_t bfe_link;
|
||||
u_int8_t bfe_phyaddr; /* Address of the card's PHY */
|
||||
u_int8_t bfe_mdc_port;
|
||||
u_int8_t bfe_unit; /* interface number */
|
||||
u_int8_t bfe_core_unit;
|
||||
u_int8_t bfe_up;
|
||||
int bfe_if_flags;
|
||||
char *bfe_vpd_prodname;
|
||||
char *bfe_vpd_readonly;
|
||||
};
|
||||
|
||||
struct bfe_type
|
||||
{
|
||||
u_int16_t bfe_vid;
|
||||
u_int16_t bfe_did;
|
||||
char *bfe_name;
|
||||
};
|
||||
|
||||
#endif /* _BFE_H */
|
||||
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2003
|
||||
* Hidetoshi Shimokawa. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
*
|
||||
* This product includes software developed by Hidetoshi Shimokawa.
|
||||
*
|
||||
* 4. Neither the name of the author nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
struct phyreg_base {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
u_int8_t phy_id:6,
|
||||
r:1,
|
||||
cps:1;
|
||||
u_int8_t rhb:1,
|
||||
ibr:1,
|
||||
gap_count:6;
|
||||
u_int8_t extended:3,
|
||||
num_ports:5;
|
||||
u_int8_t phy_speed:3,
|
||||
:1,
|
||||
delay:4;
|
||||
u_int8_t lctrl:1,
|
||||
c:1,
|
||||
jitter:3,
|
||||
pwr_class:3;
|
||||
u_int8_t wdie:1,
|
||||
isbr:1,
|
||||
ctoi:1,
|
||||
cpsi:1,
|
||||
stoi:1,
|
||||
pei:1,
|
||||
eaa:1,
|
||||
emc:1;
|
||||
u_int8_t legacy_spd:3,
|
||||
blink:1,
|
||||
bridge:2,
|
||||
:2;
|
||||
u_int8_t page_select:3,
|
||||
:1,
|
||||
port_select:4;
|
||||
#else
|
||||
u_int8_t cps:1,
|
||||
r:1,
|
||||
phy_id:6;
|
||||
u_int8_t gap_count:6,
|
||||
ibr:1,
|
||||
rhb:1;
|
||||
u_int8_t num_ports:5,
|
||||
extended:3;
|
||||
u_int8_t delay:4,
|
||||
:1,
|
||||
phy_speed:3;
|
||||
u_int8_t pwr_class:3,
|
||||
jitter:3,
|
||||
c:1,
|
||||
lctrl:1;
|
||||
u_int8_t emc:1,
|
||||
eaa:1,
|
||||
pei:1,
|
||||
stoi:1,
|
||||
cpsi:1,
|
||||
ctoi:1,
|
||||
isbr:1,
|
||||
wdie:1;
|
||||
u_int8_t :2,
|
||||
bridge:2,
|
||||
blink:1,
|
||||
legacy_spd:3;
|
||||
u_int8_t port_select:4,
|
||||
:1,
|
||||
page_select:3;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct phyreg_page0 {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
u_int8_t astat:2,
|
||||
bstat:2,
|
||||
ch:1,
|
||||
con:1,
|
||||
rxok:1,
|
||||
dis:1;
|
||||
u_int8_t negotiated_speed:3,
|
||||
pie:1,
|
||||
fault:1,
|
||||
stanby_fault:1,
|
||||
disscrm:1,
|
||||
b_only:1;
|
||||
u_int8_t dc_connected:1,
|
||||
max_port_speed:3,
|
||||
lpp:1,
|
||||
cable_speed:3;
|
||||
u_int8_t connection_unreliable:1,
|
||||
:3,
|
||||
beta_mode:1,
|
||||
:3;
|
||||
u_int8_t port_error;
|
||||
u_int8_t :5,
|
||||
loop_disable:1,
|
||||
in_standby:1,
|
||||
hard_disable:1;
|
||||
u_int8_t :8;
|
||||
u_int8_t :8;
|
||||
#else
|
||||
u_int8_t dis:1,
|
||||
rxok:1,
|
||||
con:1,
|
||||
ch:1,
|
||||
bstat:2,
|
||||
astat:2;
|
||||
u_int8_t b_only:1,
|
||||
disscrm:1,
|
||||
stanby_fault:1,
|
||||
fault:1,
|
||||
pie:1,
|
||||
negotiated_speed:3;
|
||||
u_int8_t cable_speed:3,
|
||||
lpp:1,
|
||||
max_port_speed:3,
|
||||
dc_connected:1;
|
||||
u_int8_t :3,
|
||||
beta_mode:1,
|
||||
:3,
|
||||
connection_unreliable:1;
|
||||
u_int8_t port_error;
|
||||
u_int8_t hard_disable:1,
|
||||
in_standby:1,
|
||||
loop_disable:1,
|
||||
:5;
|
||||
u_int8_t :8;
|
||||
u_int8_t :8;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct phyreg_page1 {
|
||||
u_int8_t compliance;
|
||||
u_int8_t :8;
|
||||
u_int8_t vendor_id[3];
|
||||
u_int8_t product_id[3];
|
||||
};
|
||||
@@ -1,61 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2002 Adaptec Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Written by: David Jeffery
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/ioccom.h>
|
||||
|
||||
#define IPS_USER_CMD _IOWR(0x81,0x21,ips_user_request)
|
||||
|
||||
#define IPS_IOCTL_READ 1
|
||||
#define IPS_IOCTL_WRITE 2
|
||||
|
||||
#define IPS_REBUILD_STAT_SIZE 116
|
||||
#define IPS_SUBSYS_PARAM_SIZE 128
|
||||
#define IPS_RW_NVRAM_SIZE 128
|
||||
|
||||
#define IPS_IOCTL_BUFFER_SIZE 4096
|
||||
|
||||
|
||||
typedef struct ips_ioctl{
|
||||
ips_generic_cmd * command_buffer;
|
||||
void * data_buffer;
|
||||
ips_cmd_status_t status;
|
||||
int datasize;
|
||||
int readwrite;
|
||||
bus_dma_tag_t dmatag;
|
||||
bus_dmamap_t dmamap;
|
||||
}ips_ioctl_t;
|
||||
|
||||
typedef struct ips_user_request{
|
||||
void * command_buffer;
|
||||
void * data_buffer;
|
||||
u_int32_t status;
|
||||
}ips_user_request;
|
||||
|
||||
@@ -1,316 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2000,2001 Jonathan Chen.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification, immediately at the beginning of the file.
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Driver for the TDK 78Q2120 MII
|
||||
*
|
||||
* References:
|
||||
* Datasheet for the 78Q2120 - http://www.tsc.tdk.com/lan/78q2120.pdf
|
||||
* Most of this code stolen from ukphy.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* The TDK 78Q2120 is found on some Xircom X3201 based cardbus cards. It's just
|
||||
* like any other normal phy, except it does auto negotiation in a different
|
||||
* way.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
#include <machine/clock.h>
|
||||
|
||||
#include <dev/mii/mii.h>
|
||||
#include <dev/mii/miivar.h>
|
||||
#include "miidevs.h"
|
||||
|
||||
#include <dev/mii/tdkphyreg.h>
|
||||
|
||||
#include "miibus_if.h"
|
||||
|
||||
#if 0
|
||||
#if !defined(lint)
|
||||
static const char rcsid[] =
|
||||
"$Id: tdkphy.c,v 1.3 2000/10/14 06:20:56 jon Exp $";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static int tdkphy_probe(device_t);
|
||||
static int tdkphy_attach(device_t);
|
||||
|
||||
static device_method_t tdkphy_methods[] = {
|
||||
/* device interface */
|
||||
DEVMETHOD(device_probe, tdkphy_probe),
|
||||
DEVMETHOD(device_attach, tdkphy_attach),
|
||||
DEVMETHOD(device_detach, mii_phy_detach),
|
||||
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static devclass_t tdkphy_devclass;
|
||||
|
||||
static driver_t tdkphy_driver = {
|
||||
"tdkphy",
|
||||
tdkphy_methods,
|
||||
sizeof(struct mii_softc)
|
||||
};
|
||||
|
||||
DRIVER_MODULE(tdkphy, miibus, tdkphy_driver, tdkphy_devclass, 0, 0);
|
||||
|
||||
static int tdkphy_service(struct mii_softc *, struct mii_data *, int);
|
||||
static void tdkphy_status(struct mii_softc *);
|
||||
|
||||
static int
|
||||
tdkphy_probe(device_t dev)
|
||||
{
|
||||
struct mii_attach_args *ma;
|
||||
ma = device_get_ivars(dev);
|
||||
if ((MII_OUI(ma->mii_id1, ma->mii_id2) != MII_OUI_TDK ||
|
||||
MII_MODEL(ma->mii_id2) != MII_MODEL_TDK_78Q2120))
|
||||
return (ENXIO);
|
||||
|
||||
device_set_desc(dev, MII_STR_TDK_78Q2120);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
tdkphy_attach(device_t dev)
|
||||
{
|
||||
struct mii_softc *sc;
|
||||
struct mii_attach_args *ma;
|
||||
struct mii_data *mii;
|
||||
sc = device_get_softc(dev);
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = device_get_softc(sc->mii_dev);
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
if (bootverbose)
|
||||
device_printf(dev, "OUI 0x%06x, model 0x%04x, rev. %d\n",
|
||||
MII_OUI(ma->mii_id1, ma->mii_id2),
|
||||
MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2));
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = tdkphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
|
||||
BMCR_ISO);
|
||||
#if 0
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
BMCR_LOOP|BMCR_S100);
|
||||
#endif
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_add_media(sc);
|
||||
printf("\n");
|
||||
#undef ADD
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int
|
||||
tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
break;
|
||||
|
||||
switch (IFM_SUBTYPE(ife->ifm_media)) {
|
||||
case IFM_AUTO:
|
||||
/*
|
||||
* If we're already in auto mode, just return.
|
||||
*/
|
||||
if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN)
|
||||
return (0);
|
||||
(void) mii_phy_auto(sc);
|
||||
break;
|
||||
case IFM_100_T4:
|
||||
/*
|
||||
* Not supported on MII
|
||||
*/
|
||||
return (EINVAL);
|
||||
default:
|
||||
/*
|
||||
* BMCR data is stored in the ifmedia entry.
|
||||
*/
|
||||
PHY_WRITE(sc, MII_ANAR,
|
||||
mii_anar(ife->ifm_media));
|
||||
PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update the media status. */
|
||||
tdkphy_status(sc);
|
||||
if (sc->mii_pdata->mii_media_active & IFM_FDX)
|
||||
PHY_WRITE(sc, MII_BMCR, PHY_READ(sc, MII_BMCR) | BMCR_FDX);
|
||||
else
|
||||
PHY_WRITE(sc, MII_BMCR, PHY_READ(sc, MII_BMCR) & ~BMCR_FDX);
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
tdkphy_status(struct mii_softc *phy)
|
||||
{
|
||||
struct mii_data *mii = phy->mii_pdata;
|
||||
int bmsr, bmcr, anlpar, diag;
|
||||
|
||||
mii->mii_media_status = IFM_AVALID;
|
||||
mii->mii_media_active = IFM_ETHER;
|
||||
|
||||
bmsr = PHY_READ(phy, MII_BMSR) | PHY_READ(phy, MII_BMSR);
|
||||
if (bmsr & BMSR_LINK)
|
||||
mii->mii_media_status |= IFM_ACTIVE;
|
||||
|
||||
bmcr = PHY_READ(phy, MII_BMCR);
|
||||
if (bmcr & BMCR_ISO) {
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
mii->mii_media_status = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bmcr & BMCR_LOOP)
|
||||
mii->mii_media_active |= IFM_LOOP;
|
||||
|
||||
if (bmcr & BMCR_AUTOEN) {
|
||||
/*
|
||||
* NWay autonegotiation takes the highest-order common
|
||||
* bit of the ANAR and ANLPAR (i.e. best media advertised
|
||||
* both by us and our link partner).
|
||||
*/
|
||||
if ((bmsr & BMSR_ACOMP) == 0) {
|
||||
/* Erg, still trying, I guess... */
|
||||
mii->mii_media_active |= IFM_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
anlpar = PHY_READ(phy, MII_ANAR) & PHY_READ(phy, MII_ANLPAR);
|
||||
/*
|
||||
* ANLPAR doesn't get set on my card, but we check it anyway,
|
||||
* since it is mentioned in the 78Q2120 specs.
|
||||
*/
|
||||
if (anlpar & ANLPAR_T4)
|
||||
mii->mii_media_active |= IFM_100_T4;
|
||||
else if (anlpar & ANLPAR_TX_FD)
|
||||
mii->mii_media_active |= IFM_100_TX|IFM_FDX;
|
||||
else if (anlpar & ANLPAR_TX)
|
||||
mii->mii_media_active |= IFM_100_TX;
|
||||
else if (anlpar & ANLPAR_10_FD)
|
||||
mii->mii_media_active |= IFM_10_T|IFM_FDX;
|
||||
else if (anlpar & ANLPAR_10)
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
else {
|
||||
/*
|
||||
* ANLPAR isn't set, which leaves two possibilities:
|
||||
* 1) Auto negotiation failed
|
||||
* 2) Auto negotiation completed, but the card forgot
|
||||
* to set ANLPAR.
|
||||
* So we check the MII_DIAG(18) register...
|
||||
*/
|
||||
diag = PHY_READ(phy, MII_DIAG);
|
||||
if (diag & DIAG_NEGFAIL) /* assume 10baseT if no neg */
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
else {
|
||||
if (diag & DIAG_DUPLEX)
|
||||
mii->mii_media_active |= IFM_FDX;
|
||||
if (diag & DIAG_RATE_100)
|
||||
mii->mii_media_active |= IFM_100_TX;
|
||||
else
|
||||
mii->mii_media_active |= IFM_10_T;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mii->mii_media_active = mii_media_from_bmcr(bmcr);
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2000,2001 Jonathan Chen.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification, immediately at the beginning of the file.
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Register definitions for TDK 78Q2120
|
||||
*/
|
||||
|
||||
#ifndef _DEV_MII_TDKPHYREG_H_
|
||||
#define _DEV_MII_TDKPHYREG_H_
|
||||
|
||||
#define MII_VENDOR 16
|
||||
#define VENDOR_RXCC 0x0001
|
||||
#define VENDOR_PCSBP 0x0002
|
||||
#define VENDOR_RVSPOL 0x0010
|
||||
#define VENDOR_NOAPOL 0x0020
|
||||
#define VENDOR_GPIO0DIR 0x0040
|
||||
#define VENDOR_GPIO0DAT 0x0080
|
||||
#define VENDOR_GPIO1DIR 0x0100
|
||||
#define VENDOR_GPIO1DAT 0x0200
|
||||
#define VENDOR_10BTLOOP 0x0400
|
||||
#define VENDOR_NOSQE 0x0800
|
||||
#define VENDOR_TXHIM 0x1000
|
||||
#define VENDOR_INTLVL 0x4000
|
||||
#define VENDOR_RPTR 0x8000
|
||||
|
||||
#define MII_INT 17
|
||||
#define INT_STAT_MASK 0x00ff
|
||||
#define INT_STAT_ACOMP 0x0001
|
||||
#define INT_STAT_RFAULT 0x0002
|
||||
#define INT_STAT_LSCHG 0x0004
|
||||
#define INT_STAT_LPACK 0x0008
|
||||
#define INT_STAT_PDF 0x0010
|
||||
#define INT_STAT_PRX 0x0020
|
||||
#define INT_STAT_RXERR 0x0040
|
||||
#define INT_STAT_JABBER 0x0080
|
||||
#define INT_CTRL_MASK 0xff00
|
||||
#define INT_CTRL_ACOMP 0x0100
|
||||
#define INT_CTRL_RFAULT 0x0200
|
||||
#define INT_CTRL_LSCHG 0x0400
|
||||
#define INT_CTRL_LPACK 0x0800
|
||||
#define INT_CTRL_PDF 0x1000
|
||||
#define INT_CTRL_PRX 0x2000
|
||||
#define INT_CTRL_RXERR 0x4000
|
||||
#define INT_CTRL_JABBER 0x8000
|
||||
|
||||
|
||||
#define MII_DIAG 18
|
||||
#define DIAG_RLOCK 0x0100
|
||||
#define DIAG_RPASS 0x0200
|
||||
#define DIAG_RATE_100 0x0400
|
||||
#define DIAG_DUPLEX 0x0800
|
||||
#define DIAG_NEGFAIL 0x1000
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,291 +0,0 @@
|
||||
/* $NetBSD: ehcireg.h,v 1.13 2001/11/23 01:16:27 augustss Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Lennart Augustsson (lennart@augustsson.net).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The EHCI 0.96 spec can be found at
|
||||
* http://developer.intel.com/technology/usb/download/ehci-r096.pdf
|
||||
* and the USB 2.0 spec at
|
||||
* http://www.usb.org/developers/data/usb_20.zip
|
||||
*/
|
||||
|
||||
#ifndef _DEV_PCI_EHCIREG_H_
|
||||
#define _DEV_PCI_EHCIREG_H_
|
||||
|
||||
/*** PCI config registers ***/
|
||||
|
||||
#define PCI_CBMEM 0x10 /* configuration base MEM */
|
||||
|
||||
#define PCI_INTERFACE_EHCI 0x20
|
||||
|
||||
#define PCI_USBREV 0x60 /* RO USB protocol revision */
|
||||
#define PCI_USBREV_MASK 0xff
|
||||
#define PCI_USBREV_PRE_1_0 0x00
|
||||
#define PCI_USBREV_1_0 0x10
|
||||
#define PCI_USBREV_1_1 0x11
|
||||
#define PCI_USBREV_2_0 0x20
|
||||
|
||||
#define PCI_EHCI_FLADJ 0x61 /*RW Frame len adj, SOF=59488+6*fladj */
|
||||
|
||||
#define PCI_EHCI_PORTWAKECAP 0x62 /* RW Port wake caps (opt) */
|
||||
|
||||
/* Regs ar EECP + offset */
|
||||
#define PCI_EHCI_USBLEGSUP 0x00
|
||||
#define PCI_EHCI_USBLEGCTLSTS 0x04
|
||||
|
||||
/*** EHCI capability registers ***/
|
||||
|
||||
#define EHCI_CAPLENGTH 0x00 /*RO Capability register length field */
|
||||
/* reserved 0x01 */
|
||||
#define EHCI_HCIVERSION 0x02 /* RO Interface version number */
|
||||
|
||||
#define EHCI_HCSPARAMS 0x04 /* RO Structural parameters */
|
||||
#define EHCI_HCS_DEBUGPORT(x) (((x) >> 20) & 0xf)
|
||||
#define EHCI_HCS_P_INCICATOR(x) ((x) & 0x10000)
|
||||
#define EHCI_HCS_N_CC(x) (((x) >> 12) & 0xf) /* # of companion ctlrs */
|
||||
#define EHCI_HCS_N_PCC(x) (((x) >> 8) & 0xf) /* # of ports per comp. */
|
||||
#define EHCI_HCS_PPC(x) ((x) & 0x10) /* port power control */
|
||||
#define EHCI_HCS_N_PORTS(x) ((x) & 0xf) /* # of ports */
|
||||
|
||||
#define EHCI_HCCPARAMS 0x08 /* RO Capability parameters */
|
||||
#define EHCI_HCC_EECP(x) (((x) >> 8) & 0xff) /* extended ports caps */
|
||||
#define EHCI_HCC_IST(x) (((x) >> 4) & 0xf) /* isoc sched threshold */
|
||||
#define EHCI_HCC_ASPC(x) ((x) & 0x4) /* async sched park cap */
|
||||
#define EHCI_HCC_PFLF(x) ((x) & 0x2) /* prog frame list flag */
|
||||
#define EHCI_HCC_64BIT(x) ((x) & 0x1) /* 64 bit address cap */
|
||||
|
||||
#define EHCI_HCSP_PORTROUTE 0x0c /*RO Companion port route description */
|
||||
|
||||
/* EHCI operational registers. Offset given by EHCI_CAPLENGTH register */
|
||||
#define EHCI_USBCMD 0x00 /* RO, RW, WO Command register */
|
||||
#define EHCI_CMD_ITC_M 0x00ff0000 /* RW interrupt threshold ctrl */
|
||||
#define EHCI_CMD_ITC_1 0x00010000
|
||||
#define EHCI_CMD_ITC_2 0x00020000
|
||||
#define EHCI_CMD_ITC_4 0x00040000
|
||||
#define EHCI_CMD_ITC_8 0x00080000
|
||||
#define EHCI_CMD_ITC_16 0x00100000
|
||||
#define EHCI_CMD_ITC_32 0x00200000
|
||||
#define EHCI_CMD_ITC_64 0x00400000
|
||||
#define EHCI_CMD_ASPME 0x00000800 /* RW/RO async park enable */
|
||||
#define EHCI_CMD_ASPMC 0x00000300 /* RW/RO async park count */
|
||||
#define EHCI_CMD_LHCR 0x00000080 /* RW light host ctrl reset */
|
||||
#define EHCI_CMD_IAAD 0x00000040 /* RW intr on async adv door bell */
|
||||
#define EHCI_CMD_ASE 0x00000020 /* RW async sched enable */
|
||||
#define EHCI_CMD_PSE 0x00000010 /* RW periodic sched enable */
|
||||
#define EHCI_CMD_FLS_M 0x0000000c /* RW/RO frame list size */
|
||||
#define EHCI_CMD_FLS(x) (((x) >> 2) & 3) /* RW/RO frame list size */
|
||||
#define EHCI_CMD_HCRESET 0x00000002 /* RW reset */
|
||||
#define EHCI_CMD_RS 0x00000001 /* RW run/stop */
|
||||
|
||||
#define EHCI_USBSTS 0x04 /* RO, RW, RWC Status register */
|
||||
#define EHCI_STS_ASS 0x00008000 /* RO async sched status */
|
||||
#define EHCI_STS_PSS 0x00004000 /* RO periodic sched status */
|
||||
#define EHCI_STS_REC 0x00002000 /* RO reclamation */
|
||||
#define EHCI_STS_HCH 0x00001000 /* RO host controller halted */
|
||||
#define EHCI_STS_IAA 0x00000020 /* RWC interrupt on async adv */
|
||||
#define EHCI_STS_HSE 0x00000010 /* RWC host system error */
|
||||
#define EHCI_STS_FLR 0x00000008 /* RWC frame list rollover */
|
||||
#define EHCI_STS_PCD 0x00000004 /* RWC port change detect */
|
||||
#define EHCI_STS_ERRINT 0x00000002 /* RWC error interrupt */
|
||||
#define EHCI_STS_INT 0x00000001 /* RWC interrupt */
|
||||
#define EHCI_STS_INTRS(x) ((x) & 0x3f)
|
||||
|
||||
#define EHCI_NORMAL_INTRS (EHCI_STS_IAA | EHCI_STS_HSE | EHCI_STS_PCD | EHCI_STS_ERRINT | EHCI_STS_INT)
|
||||
|
||||
#define EHCI_USBINTR 0x08 /* RW Interrupt register */
|
||||
#define EHCI_INTR_IAAE 0x00000020 /* interrupt on async advance ena */
|
||||
#define EHCI_INTR_HSEE 0x00000010 /* host system error ena */
|
||||
#define EHCI_INTR_FLRE 0x00000008 /* frame list rollover ena */
|
||||
#define EHCI_INTR_PCIE 0x00000004 /* port change ena */
|
||||
#define EHCI_INTR_UEIE 0x00000002 /* USB error intr ena */
|
||||
#define EHCI_INTR_UIE 0x00000001 /* USB intr ena */
|
||||
|
||||
#define EHCI_FRINDEX 0x0c /* RW Frame Index register */
|
||||
|
||||
#define EHCI_CTRLDSSEGMENT 0x10 /* RW Control Data Structure Segment */
|
||||
|
||||
#define EHCI_PERIODICLISTBASE 0x14 /* RW Periodic List Base */
|
||||
#define EHCI_ASYNCLISTADDR 0x18 /* RW Async List Base */
|
||||
|
||||
#define EHCI_CONFIGFLAG 0x40 /* RW Configure Flag register */
|
||||
#define EHCI_CONF_CF 0x00000001 /* RW configure flag */
|
||||
|
||||
#define EHCI_PORTSC(n) (0x40+4*(n)) /* RO, RW, RWC Port Status reg */
|
||||
#define EHCI_PS_WKOC_E 0x00400000 /* RW wake on over current ena */
|
||||
#define EHCI_PS_WKDSCNNT_E 0x00200000 /* RW wake on disconnect ena */
|
||||
#define EHCI_PS_WKCNNT_E 0x00100000 /* RW wake on connect ena */
|
||||
#define EHCI_PS_PTC 0x000f0000 /* RW port test control */
|
||||
#define EHCI_PS_PIC 0x0000c000 /* RW port indicator control */
|
||||
#define EHCI_PS_PO 0x00002000 /* RW port owner */
|
||||
#define EHCI_PS_PP 0x00001000 /* RW,RO port power */
|
||||
#define EHCI_PS_LS 0x00000c00 /* RO line status */
|
||||
#define EHCI_PS_IS_LOWSPEED(x) (((x) & EHCI_PS_LS) == 0x00000400)
|
||||
#define EHCI_PS_PR 0x00000100 /* RW port reset */
|
||||
#define EHCI_PS_SUSP 0x00000080 /* RW suspend */
|
||||
#define EHCI_PS_FPR 0x00000040 /* RW force port resume */
|
||||
#define EHCI_PS_OCC 0x00000020 /* RWC over current change */
|
||||
#define EHCI_PS_OCA 0x00000010 /* RO over current active */
|
||||
#define EHCI_PS_PEC 0x00000008 /* RWC port enable change */
|
||||
#define EHCI_PS_PE 0x00000004 /* RW port enable */
|
||||
#define EHCI_PS_CSC 0x00000002 /* RWC connect status change */
|
||||
#define EHCI_PS_CS 0x00000001 /* RO connect status */
|
||||
#define EHCI_PS_CLEAR (EHCI_PS_OCC|EHCI_PS_PEC|EHCI_PS_CSC)
|
||||
|
||||
#define EHCI_PORT_RESET_COMPLETE 2 /* ms */
|
||||
|
||||
#define EHCI_FLALIGN_ALIGN 0x1000
|
||||
|
||||
/* No data structure may cross a page boundary. */
|
||||
#define EHCI_PAGE_SIZE 0x1000
|
||||
#define EHCI_PAGE(x) ((x) &~ 0xfff)
|
||||
#define EHCI_PAGE_OFFSET(x) ((x) & 0xfff)
|
||||
#if defined(__FreeBSD__)
|
||||
#define EHCI_PAGE_MASK(x) ((x) & 0xfff)
|
||||
#endif
|
||||
|
||||
typedef u_int32_t ehci_link_t;
|
||||
#define EHCI_LINK_TERMINATE 0x00000001
|
||||
#define EHCI_LINK_TYPE(x) ((x) & 0x00000006)
|
||||
#define EHCI_LINK_ITD 0x0
|
||||
#define EHCI_LINK_QH 0x2
|
||||
#define EHCI_LINK_SITD 0x4
|
||||
#define EHCI_LINK_FSTN 0x6
|
||||
#define EHCI_LINK_ADDR(x) ((x) &~ 0x1f)
|
||||
|
||||
typedef u_int32_t ehci_physaddr_t;
|
||||
|
||||
/* Isochronous Transfer Descriptor */
|
||||
typedef struct {
|
||||
ehci_link_t itd_next;
|
||||
/* XXX many more */
|
||||
} ehci_itd_t;
|
||||
#define EHCI_ITD_ALIGN 32
|
||||
|
||||
/* Split Transaction Isochronous Transfer Descriptor */
|
||||
typedef struct {
|
||||
ehci_link_t sitd_next;
|
||||
/* XXX many more */
|
||||
} ehci_sitd_t;
|
||||
#define EHCI_SITD_ALIGN 32
|
||||
|
||||
/* Queue Element Transfer Descriptor */
|
||||
#define EHCI_QTD_NBUFFERS 5
|
||||
typedef struct {
|
||||
ehci_link_t qtd_next;
|
||||
ehci_link_t qtd_altnext;
|
||||
u_int32_t qtd_status;
|
||||
#define EHCI_QTD_GET_STATUS(x) (((x) >> 0) & 0xff)
|
||||
#define EHCI_QTD_ACTIVE 0x80
|
||||
#define EHCI_QTD_HALTED 0x40
|
||||
#define EHCI_QTD_BUFERR 0x20
|
||||
#define EHCI_QTD_BABBLE 0x10
|
||||
#define EHCI_QTD_XACTERR 0x08
|
||||
#define EHCI_QTD_MISSEDMICRO 0x04
|
||||
#define EHCI_QTD_SPLITXSTATE 0x02
|
||||
#define EHCI_QTD_PINGSTATE 0x01
|
||||
#define EHCI_QTD_STATERRS 0x7c
|
||||
#define EHCI_QTD_GET_PID(x) (((x) >> 8) & 0x3)
|
||||
#define EHCI_QTD_SET_PID(x) ((x) << 8)
|
||||
#define EHCI_QTD_PID_OUT 0x0
|
||||
#define EHCI_QTD_PID_IN 0x1
|
||||
#define EHCI_QTD_PID_SETUP 0x2
|
||||
#define EHCI_QTD_GET_CERR(x) (((x) >> 10) & 0x3)
|
||||
#define EHCI_QTD_SET_CERR(x) ((x) << 10)
|
||||
#define EHCI_QTD_GET_C_PAGE(x) (((x) >> 12) & 0x7)
|
||||
#define EHCI_QTD_SET_C_PAGE(x) ((x) << 12)
|
||||
#define EHCI_QTD_GET_IOC(x) (((x) >> 15) & 0x1)
|
||||
#define EHCI_QTD_IOC 0x00008000
|
||||
#define EHCI_QTD_GET_BYTES(x) (((x) >> 16) & 0x7fff)
|
||||
#define EHCI_QTD_SET_BYTES(x) ((x) << 16)
|
||||
#define EHCI_QTD_GET_TOGGLE(x) (((x) >> 31) & 0x1)
|
||||
#define EHCI_QTD_TOGGLE 0x80000000
|
||||
ehci_physaddr_t qtd_buffer[EHCI_QTD_NBUFFERS];
|
||||
} ehci_qtd_t;
|
||||
#define EHCI_QTD_ALIGN 32
|
||||
|
||||
/* Queue Head */
|
||||
typedef struct {
|
||||
ehci_link_t qh_link;
|
||||
u_int32_t qh_endp;
|
||||
#define EHCI_QH_GET_ADDR(x) (((x) >> 0) & 0x7f) /* endpoint addr */
|
||||
#define EHCI_QH_SET_ADDR(x) (x)
|
||||
#define EHCI_QH_ADDRMASK 0x0000007f
|
||||
#define EHCI_QH_GET_INACT(x) (((x) >> 7) & 0x01) /* inactivate on next */
|
||||
#define EHCI_QH_INACT 0x00000080
|
||||
#define EHCI_QH_GET_ENDPT(x) (((x) >> 8) & 0x0f) /* endpoint no */
|
||||
#define EHCI_QH_SET_ENDPT(x) ((x) << 8)
|
||||
#define EHCI_QH_GET_EPS(x) (((x) >> 12) & 0x03) /* endpoint speed */
|
||||
#define EHCI_QH_SET_EPS(x) ((x) << 12)
|
||||
#define EHCI_QH_SPEED_FULL 0x0
|
||||
#define EHCI_QH_SPEED_LOW 0x1
|
||||
#define EHCI_QH_SPEED_HIGH 0x2
|
||||
#define EHCI_QH_GET_DTC(x) (((x) >> 14) & 0x01) /* data toggle control */
|
||||
#define EHCI_QH_DTC 0x00004000
|
||||
#define EHCI_QH_GET_HRECL(x) (((x) >> 15) & 0x01) /* head of reclamation */
|
||||
#define EHCI_QH_HRECL 0x00008000
|
||||
#define EHCI_QH_GET_MPL(x) (((x) >> 16) & 0x7ff) /* max packet len */
|
||||
#define EHCI_QH_SET_MPL(x) ((x) << 16)
|
||||
#define EHCI_QG_MPLMASK 0x07ff0000
|
||||
#define EHCI_QH_GET_CTL(x) (((x) >> 26) & 0x01) /* control endpoint */
|
||||
#define EHCI_QH_CTL 0x08000000
|
||||
#define EHCI_QH_GET_NRL(x) (((x) >> 28) & 0x0f) /* NAK reload */
|
||||
#define EHCI_QH_SET_NRL(x) ((x) << 28)
|
||||
u_int32_t qh_endphub;
|
||||
#define EHCI_QH_GET_SMASK(x) (((x) >> 0) & 0xff) /* intr sched mask */
|
||||
#define EHCI_QH_SET_SMASK(x) ((x) << 0)
|
||||
#define EHCI_QH_GET_CMASK(x) (((x) >> 8) & 0xff) /* split completion mask */
|
||||
#define EHCI_QH_SET_CMASK(x) ((x) << 8)
|
||||
#define EHCI_QH_GET_HUBA(x) (((x) >> 16) & 0x7f) /* hub address */
|
||||
#define EHCI_QH_SET_HUBA(x) ((x) << 16)
|
||||
#define EHCI_QH_GET_PORT(x) (((x) >> 23) & 0x7f) /* hub port */
|
||||
#define EHCI_QH_SET_PORT(x) ((x) << 23)
|
||||
#define EHCI_QH_GET_MULT(x) (((x) >> 30) & 0x03) /* pipe multiplier */
|
||||
#define EHCI_QH_SET_MULT(x) ((x) << 30)
|
||||
ehci_link_t qh_curqtd;
|
||||
ehci_qtd_t qh_qtd;
|
||||
} ehci_qh_t;
|
||||
#define EHCI_QH_ALIGN 32
|
||||
|
||||
/* Periodic Frame Span Traversal Node */
|
||||
typedef struct {
|
||||
ehci_link_t fstn_link;
|
||||
ehci_link_t fstn_back;
|
||||
} ehci_fstn_t;
|
||||
#define EHCI_FSTN_ALIGN 32
|
||||
|
||||
#endif /* _DEV_PCI_EHCIREG_H_ */
|
||||
@@ -1,153 +0,0 @@
|
||||
/* $NetBSD: ehcivar.h,v 1.12 2001/12/31 12:16:57 augustss Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Lennart Augustsson (lennart@augustsson.net).
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
typedef struct ehci_soft_qtd {
|
||||
ehci_qtd_t qtd;
|
||||
struct ehci_soft_qtd *nextqtd; /* mirrors nextqtd in TD */
|
||||
ehci_physaddr_t physaddr;
|
||||
usbd_xfer_handle xfer;
|
||||
LIST_ENTRY(ehci_soft_qtd) hnext;
|
||||
u_int16_t len;
|
||||
} ehci_soft_qtd_t;
|
||||
#define EHCI_SQTD_SIZE ((sizeof (struct ehci_soft_qtd) + EHCI_QTD_ALIGN - 1) / EHCI_QTD_ALIGN * EHCI_QTD_ALIGN)
|
||||
#define EHCI_SQTD_CHUNK (EHCI_PAGE_SIZE / EHCI_SQTD_SIZE)
|
||||
|
||||
typedef struct ehci_soft_qh {
|
||||
ehci_qh_t qh;
|
||||
struct ehci_soft_qh *next;
|
||||
struct ehci_soft_qtd *sqtd;
|
||||
ehci_physaddr_t physaddr;
|
||||
} ehci_soft_qh_t;
|
||||
#define EHCI_SQH_SIZE ((sizeof (struct ehci_soft_qh) + EHCI_QH_ALIGN - 1) / EHCI_QH_ALIGN * EHCI_QH_ALIGN)
|
||||
#define EHCI_SQH_CHUNK (EHCI_PAGE_SIZE / EHCI_SQH_SIZE)
|
||||
|
||||
struct ehci_xfer {
|
||||
struct usbd_xfer xfer;
|
||||
struct usb_task abort_task;
|
||||
LIST_ENTRY(ehci_xfer) inext; /* list of active xfers */
|
||||
ehci_soft_qtd_t *sqtdstart;
|
||||
ehci_soft_qtd_t *sqtdend;
|
||||
#ifdef DIAGNOSTIC
|
||||
int isdone;
|
||||
#endif
|
||||
};
|
||||
#define EXFER(xfer) ((struct ehci_xfer *)(xfer))
|
||||
|
||||
|
||||
#define EHCI_HASH_SIZE 128
|
||||
#define EHCI_COMPANION_MAX 8
|
||||
|
||||
typedef struct ehci_softc {
|
||||
struct usbd_bus sc_bus; /* base device */
|
||||
bus_space_tag_t iot;
|
||||
bus_space_handle_t ioh;
|
||||
bus_size_t sc_size;
|
||||
#if defined(__FreeBSD__)
|
||||
void *ih;
|
||||
|
||||
struct resource *io_res;
|
||||
struct resource *irq_res;
|
||||
#endif
|
||||
u_int sc_offs; /* offset to operational regs */
|
||||
|
||||
char sc_vendor[16]; /* vendor string for root hub */
|
||||
int sc_id_vendor; /* vendor ID for root hub */
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
void *sc_powerhook; /* cookie from power hook */
|
||||
void *sc_shutdownhook; /* cookie from shutdown hook */
|
||||
#endif
|
||||
|
||||
u_int sc_ncomp;
|
||||
u_int sc_npcomp;
|
||||
struct usbd_bus *sc_comps[EHCI_COMPANION_MAX];
|
||||
|
||||
usb_dma_t sc_fldma;
|
||||
u_int sc_flsize;
|
||||
|
||||
LIST_HEAD(, ehci_xfer) sc_intrhead;
|
||||
|
||||
ehci_soft_qh_t *sc_freeqhs;
|
||||
ehci_soft_qtd_t *sc_freeqtds;
|
||||
|
||||
int sc_noport;
|
||||
u_int8_t sc_addr; /* device address */
|
||||
u_int8_t sc_conf; /* device configuration */
|
||||
usbd_xfer_handle sc_intrxfer;
|
||||
char sc_isreset;
|
||||
#ifdef USB_USE_SOFTINTR
|
||||
char sc_softwake;
|
||||
#endif /* USB_USE_SOFTINTR */
|
||||
|
||||
u_int32_t sc_eintrs;
|
||||
ehci_soft_qh_t *sc_async_head;
|
||||
|
||||
SIMPLEQ_HEAD(, usbd_xfer) sc_free_xfers; /* free xfers */
|
||||
|
||||
struct lock sc_doorbell_lock;
|
||||
|
||||
usb_callout_t sc_tmo_pcd;
|
||||
|
||||
device_ptr_t sc_child; /* /dev/usb# device */
|
||||
|
||||
char sc_dying;
|
||||
} ehci_softc_t;
|
||||
|
||||
#define EREAD1(sc, a) bus_space_read_1((sc)->iot, (sc)->ioh, (a))
|
||||
#define EREAD2(sc, a) bus_space_read_2((sc)->iot, (sc)->ioh, (a))
|
||||
#define EREAD4(sc, a) bus_space_read_4((sc)->iot, (sc)->ioh, (a))
|
||||
#define EWRITE1(sc, a, x) bus_space_write_1((sc)->iot, (sc)->ioh, (a), (x))
|
||||
#define EWRITE2(sc, a, x) bus_space_write_2((sc)->iot, (sc)->ioh, (a), (x))
|
||||
#define EWRITE4(sc, a, x) bus_space_write_4((sc)->iot, (sc)->ioh, (a), (x))
|
||||
#define EOREAD1(sc, a) bus_space_read_1((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a))
|
||||
#define EOREAD2(sc, a) bus_space_read_2((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a))
|
||||
#define EOREAD4(sc, a) bus_space_read_4((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a))
|
||||
#define EOWRITE1(sc, a, x) bus_space_write_1((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a), (x))
|
||||
#define EOWRITE2(sc, a, x) bus_space_write_2((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a), (x))
|
||||
#define EOWRITE4(sc, a, x) bus_space_write_4((sc)->iot, (sc)->ioh, (sc)->sc_offs+(a), (x))
|
||||
|
||||
usbd_status ehci_init(ehci_softc_t *);
|
||||
int ehci_intr(void *);
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
int ehci_detach(ehci_softc_t *, int);
|
||||
int ehci_activate(device_ptr_t, enum devact);
|
||||
#endif
|
||||
|
||||
#define MS_TO_TICKS(ms) ((ms) * hz / 1000)
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/* $NetBSD: usb/ugraphire_rdesc.h,v 1.1 2000/12/29 01:47:49 augustss Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
/*
|
||||
* Copyright (c) 2000 Nick Hibma <n_hibma@freebsd.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
static uByte uhid_graphire_report_descr[] = {
|
||||
0x05, 0x0d, /* USAGE_PAGE (Digitizers) */
|
||||
0x09, 0x01, /* USAGE (Digitizer) */
|
||||
0xa1, 0x01, /* COLLECTION (Application) */
|
||||
0x85, 0x02, /* REPORT_ID (2) */
|
||||
0x05, 0x0d, /* USAGE_PAGE (Digitizers) */
|
||||
0x09, 0x01, /* USAGE (Digitizer) */
|
||||
0xa1, 0x00, /* COLLECTION (Physical) */
|
||||
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
|
||||
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
|
||||
0x09, 0x33, /* USAGE (Touch) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x81, 0x02, /* INPUT (Data,Var,Abs) */
|
||||
0x09, 0x44, /* USAGE (Barrel Switch) */
|
||||
0x95, 0x02, /* REPORT_COUNT (2) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x81, 0x02, /* INPUT (Data,Var,Abs) */
|
||||
0x09, 0x00, /* USAGE (Undefined) */
|
||||
0x95, 0x02, /* REPORT_COUNT (2) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x81, 0x03, /* INPUT (Cnst,Var,Abs) */
|
||||
0x09, 0x3c, /* USAGE (Invert) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x81, 0x02, /* INPUT (Data,Var,Abs) */
|
||||
0x09, 0x38, /* USAGE (Transducer Index) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x81, 0x02, /* INPUT (Data,Var,Abs) */
|
||||
0x09, 0x32, /* USAGE (In Range) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x81, 0x02, /* INPUT (Data,Var,Abs) */
|
||||
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
|
||||
0x09, 0x30, /* USAGE (X) */
|
||||
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
|
||||
0x26, 0xde, 0x27, /* LOGICAL_MAXIMUM (10206) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x75, 0x10, /* REPORT_SIZE (16) */
|
||||
0x81, 0x02, /* INPUT (Data,Var,Abs) */
|
||||
0x09, 0x31, /* USAGE (Y) */
|
||||
0x26, 0xfe, 0x1c, /* LOGICAL_MAXIMUM (7422) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x75, 0x10, /* REPORT_SIZE (16) */
|
||||
0x81, 0x02, /* INPUT (Data,Var,Abs) */
|
||||
0x05, 0x0d, /* USAGE_PAGE (Digitizers) */
|
||||
0x09, 0x30, /* USAGE (Tip Pressure) */
|
||||
0x26, 0xff, 0x01, /* LOGICAL_MAXIMUM (511) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x75, 0x10, /* REPORT_SIZE (16) */
|
||||
0x81, 0x02, /* INPUT (Data,Var,Abs) */
|
||||
0xc0, /* END_COLLECTION */
|
||||
0x05, 0x0d, /* USAGE_PAGE (Digitizers) */
|
||||
0x09, 0x00, /* USAGE (Undefined) */
|
||||
0x85, 0x02, /* REPORT_ID (2) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0xb1, 0x02, /* FEATURE (Data,Var,Abs) */
|
||||
0x09, 0x00, /* USAGE (Undefined) */
|
||||
0x85, 0x03, /* REPORT_ID (3) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0xb1, 0x02, /* FEATURE (Data,Var,Abs) */
|
||||
0xc0, /* END_COLLECTION */
|
||||
};
|
||||
@@ -1,308 +0,0 @@
|
||||
/* $NetBSD: usb_mem.c,v 1.26 2003/02/01 06:23:40 thorpej Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Lennart Augustsson (lennart@augustsson.net) at
|
||||
* Carlstedt Research & Technology.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* USB DMA memory allocation.
|
||||
* We need to allocate a lot of small (many 8 byte, some larger)
|
||||
* memory blocks that can be used for DMA. Using the bus_dma
|
||||
* routines directly would incur large overheads in space and time.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kernel.h>
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/device.h> /* for usbdivar.h */
|
||||
#include <machine/bus.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/endian.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
#endif
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/endian.h>
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
#include <sys/proc.h>
|
||||
#endif
|
||||
|
||||
#include <dev/usb/usb.h>
|
||||
#include <dev/usb/usbdi.h>
|
||||
#include <dev/usb/usbdivar.h> /* just for usb_dma_t */
|
||||
#include <dev/usb/usb_mem.h>
|
||||
|
||||
#ifdef USB_DEBUG
|
||||
#define DPRINTF(x) if (usbdebug) logprintf x
|
||||
#define DPRINTFN(n,x) if (usbdebug>(n)) logprintf x
|
||||
extern int usbdebug;
|
||||
#else
|
||||
#define DPRINTF(x)
|
||||
#define DPRINTFN(n,x)
|
||||
#endif
|
||||
|
||||
#define USB_MEM_SMALL 64
|
||||
#define USB_MEM_CHUNKS (PAGE_SIZE / USB_MEM_SMALL)
|
||||
#define USB_MEM_BLOCK (USB_MEM_SMALL * USB_MEM_CHUNKS)
|
||||
|
||||
/* This struct is overlayed on free fragments. */
|
||||
struct usb_frag_dma {
|
||||
usb_dma_block_t *block;
|
||||
u_int offs;
|
||||
LIST_ENTRY(usb_frag_dma) next;
|
||||
};
|
||||
|
||||
Static bus_dmamap_callback_t usbmem_callback;
|
||||
Static usbd_status usb_block_allocmem(bus_dma_tag_t, size_t, size_t,
|
||||
usb_dma_block_t **);
|
||||
Static void usb_block_freemem(usb_dma_block_t *);
|
||||
|
||||
Static LIST_HEAD(, usb_dma_block) usb_blk_freelist =
|
||||
LIST_HEAD_INITIALIZER(usb_blk_freelist);
|
||||
Static int usb_blk_nfree = 0;
|
||||
/* XXX should have different free list for different tags (for speed) */
|
||||
Static LIST_HEAD(, usb_frag_dma) usb_frag_freelist =
|
||||
LIST_HEAD_INITIALIZER(usb_frag_freelist);
|
||||
|
||||
Static void
|
||||
usbmem_callback(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
||||
{
|
||||
int i;
|
||||
usb_dma_block_t *p = arg;
|
||||
|
||||
if (error == EFBIG) {
|
||||
printf("usb: mapping to large\n");
|
||||
return;
|
||||
}
|
||||
|
||||
p->nsegs = nseg;
|
||||
for (i = 0; i < nseg && i < sizeof p->segs / sizeof *p->segs; i++)
|
||||
p->segs[i] = segs[i];
|
||||
}
|
||||
|
||||
Static usbd_status
|
||||
usb_block_allocmem(bus_dma_tag_t tag, size_t size, size_t align,
|
||||
usb_dma_block_t **dmap)
|
||||
{
|
||||
usb_dma_block_t *p;
|
||||
int s;
|
||||
|
||||
DPRINTFN(5, ("usb_block_allocmem: size=%lu align=%lu\n",
|
||||
(u_long)size, (u_long)align));
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (!curproc) {
|
||||
printf("usb_block_allocmem: in interrupt context, size=%lu\n",
|
||||
(unsigned long) size);
|
||||
}
|
||||
#endif
|
||||
|
||||
s = splusb();
|
||||
/* First check the free list. */
|
||||
for (p = LIST_FIRST(&usb_blk_freelist); p; p = LIST_NEXT(p, next)) {
|
||||
if (p->tag == tag && p->size >= size && p->align >= align) {
|
||||
LIST_REMOVE(p, next);
|
||||
usb_blk_nfree--;
|
||||
splx(s);
|
||||
*dmap = p;
|
||||
DPRINTFN(6,("usb_block_allocmem: free list size=%lu\n",
|
||||
(u_long)p->size));
|
||||
return (USBD_NORMAL_COMPLETION);
|
||||
}
|
||||
}
|
||||
splx(s);
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (!curproc) {
|
||||
printf("usb_block_allocmem: in interrupt context, failed\n");
|
||||
return (USBD_NOMEM);
|
||||
}
|
||||
#endif
|
||||
|
||||
DPRINTFN(6, ("usb_block_allocmem: no free\n"));
|
||||
p = malloc(sizeof *p, M_USB, M_NOWAIT);
|
||||
if (p == NULL)
|
||||
return (USBD_NOMEM);
|
||||
|
||||
#if __FreeBSD_version >= 500000
|
||||
if (bus_dma_tag_create(tag, align, 0,
|
||||
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
||||
size, sizeof(p->segs) / sizeof(p->segs[0]), size,
|
||||
BUS_DMA_ALLOCNOW, NULL, NULL, &p->tag) == ENOMEM)
|
||||
#else
|
||||
if (bus_dma_tag_create(tag, align, 0,
|
||||
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
||||
size, sizeof(p->segs) / sizeof(p->segs[0]), size,
|
||||
BUS_DMA_ALLOCNOW, &p->tag) == ENOMEM)
|
||||
#endif
|
||||
{
|
||||
goto free;
|
||||
}
|
||||
|
||||
p->size = size;
|
||||
p->align = align;
|
||||
if (bus_dmamem_alloc(p->tag, &p->kaddr,
|
||||
BUS_DMA_NOWAIT|BUS_DMA_COHERENT, &p->map))
|
||||
goto tagfree;
|
||||
|
||||
if (bus_dmamap_load(p->tag, p->map, p->kaddr, p->size,
|
||||
usbmem_callback, p, 0))
|
||||
goto memfree;
|
||||
|
||||
/* XXX - override the tag, ok since we never free it */
|
||||
p->tag = tag;
|
||||
*dmap = p;
|
||||
return (USBD_NORMAL_COMPLETION);
|
||||
|
||||
/*
|
||||
* XXX - do we need to _unload? is the order of _free and _destroy
|
||||
* correct?
|
||||
*/
|
||||
memfree:
|
||||
bus_dmamem_free(p->tag, p->kaddr, p->map);
|
||||
tagfree:
|
||||
bus_dma_tag_destroy(p->tag);
|
||||
free:
|
||||
free(p, M_USB);
|
||||
return (USBD_NOMEM);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do not free the memory unconditionally since we might be called
|
||||
* from an interrupt context and that is BAD.
|
||||
* XXX when should we really free?
|
||||
*/
|
||||
Static void
|
||||
usb_block_freemem(usb_dma_block_t *p)
|
||||
{
|
||||
int s;
|
||||
|
||||
DPRINTFN(6, ("usb_block_freemem: size=%lu\n", (u_long)p->size));
|
||||
s = splusb();
|
||||
LIST_INSERT_HEAD(&usb_blk_freelist, p, next);
|
||||
usb_blk_nfree++;
|
||||
splx(s);
|
||||
}
|
||||
|
||||
usbd_status
|
||||
usb_allocmem(usbd_bus_handle bus, size_t size, size_t align, usb_dma_t *p)
|
||||
{
|
||||
bus_dma_tag_t tag = bus->dmatag;
|
||||
usbd_status err;
|
||||
struct usb_frag_dma *f;
|
||||
usb_dma_block_t *b;
|
||||
int i;
|
||||
int s;
|
||||
|
||||
/* compat w/ Net/OpenBSD */
|
||||
if (align == 0)
|
||||
align = 1;
|
||||
|
||||
/* If the request is large then just use a full block. */
|
||||
if (size > USB_MEM_SMALL || align > USB_MEM_SMALL) {
|
||||
DPRINTFN(1, ("usb_allocmem: large alloc %d\n", (int)size));
|
||||
size = (size + USB_MEM_BLOCK - 1) & ~(USB_MEM_BLOCK - 1);
|
||||
err = usb_block_allocmem(tag, size, align, &p->block);
|
||||
if (!err) {
|
||||
p->block->fullblock = 1;
|
||||
p->offs = 0;
|
||||
p->len = size;
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
|
||||
s = splusb();
|
||||
/* Check for free fragments. */
|
||||
for (f = LIST_FIRST(&usb_frag_freelist); f; f = LIST_NEXT(f, next))
|
||||
if (f->block->tag == tag)
|
||||
break;
|
||||
if (f == NULL) {
|
||||
DPRINTFN(1, ("usb_allocmem: adding fragments\n"));
|
||||
err = usb_block_allocmem(tag, USB_MEM_BLOCK, USB_MEM_SMALL,&b);
|
||||
if (err) {
|
||||
splx(s);
|
||||
return (err);
|
||||
}
|
||||
b->fullblock = 0;
|
||||
/* XXX - override the tag, ok since we never free it */
|
||||
b->tag = tag;
|
||||
KASSERT(sizeof *f <= USB_MEM_SMALL, ("USB_MEM_SMALL(%d) is too small for struct usb_frag_dma(%zd)\n",
|
||||
USB_MEM_SMALL, sizeof *f));
|
||||
for (i = 0; i < USB_MEM_BLOCK; i += USB_MEM_SMALL) {
|
||||
f = (struct usb_frag_dma *)((char *)b->kaddr + i);
|
||||
f->block = b;
|
||||
f->offs = i;
|
||||
LIST_INSERT_HEAD(&usb_frag_freelist, f, next);
|
||||
}
|
||||
f = LIST_FIRST(&usb_frag_freelist);
|
||||
}
|
||||
p->block = f->block;
|
||||
p->offs = f->offs;
|
||||
p->len = USB_MEM_SMALL;
|
||||
LIST_REMOVE(f, next);
|
||||
splx(s);
|
||||
DPRINTFN(5, ("usb_allocmem: use frag=%p size=%d\n", f, (int)size));
|
||||
return (USBD_NORMAL_COMPLETION);
|
||||
}
|
||||
|
||||
void
|
||||
usb_freemem(usbd_bus_handle bus, usb_dma_t *p)
|
||||
{
|
||||
struct usb_frag_dma *f;
|
||||
int s;
|
||||
|
||||
if (p->block->fullblock) {
|
||||
DPRINTFN(1, ("usb_freemem: large free\n"));
|
||||
usb_block_freemem(p->block);
|
||||
return;
|
||||
}
|
||||
f = KERNADDR(p, 0);
|
||||
f->block = p->block;
|
||||
f->offs = p->offs;
|
||||
s = splusb();
|
||||
LIST_INSERT_HEAD(&usb_frag_freelist, f, next);
|
||||
splx(s);
|
||||
DPRINTFN(5, ("usb_freemem: frag=%p\n", f));
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../dev/bfe
|
||||
|
||||
KMOD= if_bfe
|
||||
SRCS= if_bfe.c miibus_if.h miidevs.h opt_bdg.h device_if.h bus_if.h pci_if.h
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
@@ -1,16 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
# Makefile for the SBP-II Target mode
|
||||
|
||||
.PATH: ${.CURDIR}/../../../dev/firewire
|
||||
|
||||
KMOD = sbp_targ
|
||||
SRCS = bus_if.h device_if.h \
|
||||
opt_cam.h opt_scsi.h \
|
||||
sbp_targ.c sbp.h \
|
||||
firewire.h firewirereg.h \
|
||||
iec13213.h
|
||||
|
||||
#CFLAGS += -g
|
||||
.include <bsd.kmod.mk>
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../dev/ips
|
||||
KMOD = ips
|
||||
SRCS = ips.c ips_pci.c ips.h ips_disk.c ips_disk.h ips_commands.c \
|
||||
ips_ioctl.h ips_ioctl.c device_if.h bus_if.h pci_if.h
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
+1
-1
@@ -54,7 +54,7 @@
|
||||
* doc/en_US.ISO8859-1/books/porters-handbook/book.sgml
|
||||
*/
|
||||
#undef __FreeBSD_version
|
||||
#define __FreeBSD_version 480102 /* Master, propagated to newvers */
|
||||
#define __FreeBSD_version 490000 /* Master, propagated to newvers */
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= makewhatis
|
||||
DPADD= ${LIBZ}
|
||||
LDADD= -lz
|
||||
SCRIPTS= makewhatis.local.sh
|
||||
MAN= makewhatis.1 makewhatis.local.8
|
||||
SCRIPTSDIR= /usr/libexec
|
||||
LINKS= ${SCRIPTSDIR}/makewhatis.local ${SCRIPTSDIR}/catman.local
|
||||
MLINKS= makewhatis.local.8 catman.local.8
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,133 +0,0 @@
|
||||
.\" Copyright (c) 2002 John Rochester
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd May 12, 2002
|
||||
.Dt MAKEWHATIS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm makewhatis
|
||||
.Nd "create whatis database"
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl a
|
||||
.Op Fl i Ar column
|
||||
.Op Fl n Ar name
|
||||
.Op Fl o Ar file
|
||||
.Op Fl v
|
||||
.Op Fl L
|
||||
.Op Ar directories ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility collects the names and short descriptions from all the unformatted
|
||||
man pages in the
|
||||
.Ar directories
|
||||
and puts them into a file used by the
|
||||
.Xr whatis 1
|
||||
and
|
||||
.Xr apropos 1
|
||||
commands.
|
||||
Directories may be separated by colons instead of spaces.
|
||||
If no
|
||||
.Ar directories
|
||||
are specified, the contents of the
|
||||
.Ev MANPATH
|
||||
environment variable will be used, or if that is not set, the default directory
|
||||
.Pa /usr/share/man
|
||||
will be processed.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width ".Fl i Ar column"
|
||||
.It Fl a
|
||||
Appends to the output file(s) instead of replacing them.
|
||||
The output
|
||||
will be sorted with duplicate lines removed, but may have obsolete
|
||||
entries.
|
||||
.It Fl i Ar column
|
||||
Indents the description by
|
||||
.Ar column
|
||||
characters.
|
||||
The default value is 24.
|
||||
.It Fl n Ar name
|
||||
Uses
|
||||
.Ar name
|
||||
instead of
|
||||
.Pa whatis .
|
||||
.It Fl o Ar file
|
||||
Outputs all lines to the
|
||||
.Ar file
|
||||
instead of
|
||||
.Pa */man/whatis .
|
||||
.It Fl v
|
||||
Makes
|
||||
.Nm
|
||||
more verbose about what it is doing.
|
||||
.It Fl L
|
||||
Process only localized subdirectories corresponding to the locale specified
|
||||
in the standard environment variables.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width ".Ev MANPATH"
|
||||
.It Ev LC_ALL , LC_CTYPE , LANG
|
||||
These variables control what subdirectories will be processed if the
|
||||
.Fl L
|
||||
option is used.
|
||||
.It Ev MACHINE
|
||||
If set, its value is used to override the current
|
||||
machine type when searching machine specific subdirectories.
|
||||
.It Ev MANPATH
|
||||
Determines the set of directories to be processed if none are given on
|
||||
the command line.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width ".Pa /usr/share/man" -compact
|
||||
.It Pa /usr/share/man
|
||||
Default directory to process if the
|
||||
.Ev MANPATH
|
||||
environment variable is not set.
|
||||
.It Pa */man/whatis
|
||||
The default output file.
|
||||
.El
|
||||
.Sh DIAGNOSTICS
|
||||
.Ex -std
|
||||
.Sh SEE ALSO
|
||||
.Xr apropos 1 ,
|
||||
.Xr whatis 1
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
command appeared in
|
||||
.Fx 2.1 .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
The
|
||||
.Nm
|
||||
program was originally written in Perl and was contributed by
|
||||
.An Wolfram Schneider .
|
||||
The current version of
|
||||
.Nm
|
||||
was rewritten in C by
|
||||
.An John Rochester .
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,82 +0,0 @@
|
||||
.\" Copyright (c) April 1996 Wolfram Schneider <[email protected]>. Berlin.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.Dd April 26, 1996
|
||||
.Dt MAKEWHATIS.LOCAL 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm makewhatis.local , catman.local
|
||||
.Nd start makewhatis or catman for local file systems
|
||||
.Sh SYNOPSIS
|
||||
.Nm /usr/libexec/makewhatis.local
|
||||
.Op options
|
||||
.Ar directories ...
|
||||
.Nm /usr/libexec/catman.local
|
||||
.Op options
|
||||
.Ar directories ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility starts
|
||||
.Xr makewhatis 1
|
||||
only for file systems physically mounted on the system
|
||||
where the
|
||||
.Nm
|
||||
is being executed. Running makewhatis
|
||||
by
|
||||
.Pa periodic weekly
|
||||
for rw nfs-mounted /usr may kill
|
||||
your NFS server -- all NFS clients start makewhatis at the same time!
|
||||
So use this wrapper for
|
||||
.Xr cron 8
|
||||
instead of calling makewhatis directly.
|
||||
The
|
||||
.Nm catman.local
|
||||
utility is using for same purposes as
|
||||
.Nm
|
||||
but for
|
||||
.Xr catman 1 .
|
||||
.Sh FILES
|
||||
.Bl -tag -width /etc/periodic/weekly/320.whatis.XXX -compact
|
||||
.It Pa /etc/periodic/weekly/320.whatis
|
||||
run
|
||||
.Nm
|
||||
every week
|
||||
.It Pa /etc/periodic/weekly/330.catman
|
||||
run
|
||||
.Nm catman.local
|
||||
every week
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr catman 1 ,
|
||||
.Xr find 1 ,
|
||||
.Xr makewhatis 1 ,
|
||||
.Xr cron 8 ,
|
||||
.Xr periodic 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
utility appeared in
|
||||
.Fx 2.2 .
|
||||
@@ -1,58 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) April 1996 Wolfram Schneider <[email protected]>. Berlin.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 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.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# makewhatis.local - start makewhatis(1) only for file systems
|
||||
# physically mounted on the system
|
||||
#
|
||||
# Running makewhatis from /etc/periodic/weekly/320.whatis for rw nfs-mounted
|
||||
# /usr may kill your NFS server -- all clients start makewhatis at the same
|
||||
# time! So use this wrapper instead calling makewhatis directly.
|
||||
#
|
||||
# PS: this wrapper works also for catman(1)
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
PATH=/bin:/usr/bin:$PATH; export PATH
|
||||
opt= dirs= localdirs=
|
||||
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-*) opt="$opt $arg";;
|
||||
*) dirs="$dirs $arg";;
|
||||
esac
|
||||
done
|
||||
|
||||
dirs=`echo $dirs | sed 's/:/ /g'`
|
||||
case X"$dirs" in X) echo "usage: $0 [options] directories ..."; exit 1;; esac
|
||||
|
||||
localdirs=`find -H $dirs -fstype local -type d -prune -print`
|
||||
|
||||
case X"$localdirs" in
|
||||
X) echo "$0: no local-mounted manual directories found: $dirs"
|
||||
exit 1;;
|
||||
*) exec `basename $0 .local` $opt $localdirs;;
|
||||
esac
|
||||
@@ -1,11 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= stat
|
||||
MAN= stat.1
|
||||
SRCS= stat.c
|
||||
WARNS?= 2
|
||||
|
||||
LINKS= ${BINDIR}/stat ${BINDIR}/readlink
|
||||
MLINKS= stat.1 readlink.1
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,522 +0,0 @@
|
||||
.\" $NetBSD: stat.1,v 1.11 2003/05/08 13:07:10 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||
.\" by Andrew Brown and Jan Schaumann.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 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.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by the NetBSD
|
||||
.\" Foundation, Inc. and its contributors.
|
||||
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
.\" contributors may be used to endorse or promote products derived
|
||||
.\" from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd May 8, 2003
|
||||
.Dt STAT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm stat ,
|
||||
.Nm readlink
|
||||
.Nd display file status
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl FLnq
|
||||
.Op Fl f Ar format | Fl l | r | s | x
|
||||
.Op Fl t Ar timefmt
|
||||
.Op Ar
|
||||
.Nm readlink
|
||||
.Op Fl n
|
||||
.Op Ar
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility displays information about the file pointed to by
|
||||
.Ar file .
|
||||
Read, write or execute permissions of the named file are not required, but
|
||||
all directories listed in the path name leading to the file must be
|
||||
searchable.
|
||||
If no argument is given,
|
||||
.Nm
|
||||
displays information about the file descriptor for standard input.
|
||||
.Pp
|
||||
When invoked as
|
||||
.Nm readlink ,
|
||||
only the target of the symbolic link is printed.
|
||||
If the given argument is not a symbolic link,
|
||||
.Nm readlink
|
||||
will print nothing and exit with an error.
|
||||
.Pp
|
||||
The information displayed is obtained by calling
|
||||
.Xr lstat 2
|
||||
with the given argument and evaluating the returned structure.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Fl F
|
||||
As in
|
||||
.Xr ls 1 ,
|
||||
display a slash
|
||||
.Pq Ql /
|
||||
immediately after each pathname that is a directory,
|
||||
an asterisk
|
||||
.Pq Ql *
|
||||
after each that is executable,
|
||||
an at sign
|
||||
.Pq Ql @
|
||||
after each symbolic link,
|
||||
a percent sign
|
||||
.Pq Ql %
|
||||
after each whiteout,
|
||||
an equal sign
|
||||
.Pq Ql =
|
||||
after each socket,
|
||||
and a vertical bar
|
||||
.Pq Ql |
|
||||
after each that is a FIFO.
|
||||
The use of
|
||||
.Fl F
|
||||
implies
|
||||
.Fl l .
|
||||
.It Fl L
|
||||
Use
|
||||
.Xr stat 2
|
||||
instead of
|
||||
.Xr lstat 2 .
|
||||
The information reported by
|
||||
.Nm
|
||||
will refer to the target of
|
||||
.Ar file ,
|
||||
if file is a symbolic link, and not to
|
||||
.Ar file
|
||||
itself.
|
||||
.It Fl n
|
||||
Do not force a newline to appear at the end of each piece of output.
|
||||
.It Fl q
|
||||
Suppress failure messages if calls to
|
||||
.Xr stat 2
|
||||
or
|
||||
.Xr lstat 2
|
||||
fail.
|
||||
When run as
|
||||
.Nm readlink ,
|
||||
error messages are automatically suppressed.
|
||||
.It Fl f Ar format
|
||||
Display information using the specified format.
|
||||
See the
|
||||
.Sx FORMATS
|
||||
section for a description of valid formats.
|
||||
.It Fl l
|
||||
Display output in
|
||||
.Nm ls Fl lT
|
||||
format.
|
||||
.It Fl r
|
||||
Display raw information.
|
||||
That is, for all the fields in the
|
||||
.Vt stat
|
||||
structure,
|
||||
display the raw, numerical value (for example, times in seconds since the
|
||||
epoch, etc.).
|
||||
.It Fl s
|
||||
Display information in
|
||||
.Dq "shell output" ,
|
||||
suitable for initializing variables.
|
||||
.It Fl x
|
||||
Display information in a more verbose way as known from some
|
||||
.Tn Linux
|
||||
distributions.
|
||||
.It Fl t Ar timefmt
|
||||
Display timestamps using the specified format.
|
||||
This format is
|
||||
passed directly to
|
||||
.Xr strftime 3 .
|
||||
.El
|
||||
.Ss Formats
|
||||
Format strings are similar to
|
||||
.Xr printf 3
|
||||
formats in that they start with
|
||||
.Cm % ,
|
||||
are then followed by a sequence of formatting characters, and end in
|
||||
a character that selects the field of the
|
||||
.Vt "struct stat"
|
||||
which is to be formatted.
|
||||
If the
|
||||
.Cm %
|
||||
is immediately followed by one of
|
||||
.Cm n , t , % ,
|
||||
or
|
||||
.Cm @ ,
|
||||
then a newline character, a tab character, a percent character,
|
||||
or the current file number is printed, otherwise the string is
|
||||
examined for the following:
|
||||
.Pp
|
||||
Any of the following optional flags:
|
||||
.Bl -tag -width indent
|
||||
.It Cm #
|
||||
Selects an alternate output form for octal and hexadecimal output.
|
||||
Non-zero octal output will have a leading zero, and non-zero
|
||||
hexadecimal output will have
|
||||
.Dq Li 0x
|
||||
prepended to it.
|
||||
.It Cm +
|
||||
Asserts that a sign indicating whether a number is positive or negative
|
||||
should always be printed.
|
||||
Non-negative numbers are not usually printed
|
||||
with a sign.
|
||||
.It Cm -
|
||||
Aligns string output to the left of the field, instead of to the right.
|
||||
.It Cm 0
|
||||
Sets the fill character for left padding to the
|
||||
.Ql 0
|
||||
character, instead of a space.
|
||||
.It space
|
||||
Reserves a space at the front of non-negative signed output fields.
|
||||
A
|
||||
.Sq Cm +
|
||||
overrides a space if both are used.
|
||||
.El
|
||||
.Pp
|
||||
Then the following fields:
|
||||
.Bl -tag -width indent
|
||||
.It Ar size
|
||||
An optional decimal digit string specifying the minimum field width.
|
||||
.It Ar prec
|
||||
An optional precision composed of a decimal point
|
||||
.Sq Cm \&.
|
||||
and a decimal digit string that indicates the maximum string length,
|
||||
the number of digits to appear after the decimal point in floating point
|
||||
output, or the minimum number of digits to appear in numeric output.
|
||||
.It Ar fmt
|
||||
An optional output format specifier which is one of
|
||||
.Cm D , O , U , X , F ,
|
||||
or
|
||||
.Cm S .
|
||||
These represent signed decimal output, octal output, unsigned decimal
|
||||
output, hexadecimal output, floating point output, and string output,
|
||||
respectively.
|
||||
Some output formats do not apply to all fields.
|
||||
Floating point output only applies to
|
||||
.Vt timespec
|
||||
fields (the
|
||||
.Cm a , m ,
|
||||
and
|
||||
.Cm c
|
||||
fields).
|
||||
.Pp
|
||||
The special output specifier
|
||||
.Cm S
|
||||
may be used to indicate that the output, if
|
||||
applicable, should be in string format.
|
||||
May be used in combination with:
|
||||
.Bl -tag -width indent
|
||||
.It Cm amc
|
||||
Display date in
|
||||
.Xr strftime 3
|
||||
format.
|
||||
.It Cm dr
|
||||
Display actual device name.
|
||||
.It Cm gu
|
||||
Display group or user name.
|
||||
.It Cm p
|
||||
Display the mode of
|
||||
.Ar file
|
||||
as in
|
||||
.Nm ls Fl lTd .
|
||||
.It Cm N
|
||||
Displays the name of
|
||||
.Ar file .
|
||||
.It Cm T
|
||||
Displays the type of
|
||||
.Ar file .
|
||||
.It Cm Y
|
||||
Insert a
|
||||
.Dq Li " -\*[Gt] "
|
||||
into the output.
|
||||
Note that the default output format
|
||||
for
|
||||
.Cm Y
|
||||
is a string, but if specified explicitly, these four characters are
|
||||
prepended.
|
||||
.El
|
||||
.It Ar sub
|
||||
An optional sub field specifier (high, middle, low).
|
||||
Only applies to
|
||||
the
|
||||
.Cm p , d , r ,
|
||||
and
|
||||
.Cm T
|
||||
output formats.
|
||||
It can be one of the following:
|
||||
.Bl -tag -width indent
|
||||
.It Cm H
|
||||
.Dq High
|
||||
\[em]
|
||||
specifies the major number for devices from
|
||||
.Cm r
|
||||
or
|
||||
.Cm d ,
|
||||
the
|
||||
.Dq user
|
||||
bits for permissions from the string form of
|
||||
.Cm p ,
|
||||
the file
|
||||
.Dq type
|
||||
bits from the numeric forms of
|
||||
.Cm p ,
|
||||
and the long output form of
|
||||
.Cm T .
|
||||
.It Cm L
|
||||
.Dq Low
|
||||
\[em]
|
||||
specifies the minor number for devices from
|
||||
.Cm r
|
||||
or
|
||||
.Cm d ,
|
||||
the
|
||||
.Dq other
|
||||
bits for permissions from the string form of
|
||||
.Cm p ,
|
||||
the
|
||||
.Dq user ,
|
||||
.Dq group ,
|
||||
and
|
||||
.Dq other
|
||||
bits from the numeric forms of
|
||||
.Cm p ,
|
||||
and the
|
||||
.Nm ls Fl F
|
||||
style output character for file type when used with
|
||||
.Cm T
|
||||
(the use of
|
||||
.Cm L
|
||||
for this is optional).
|
||||
.It Cm M
|
||||
.Dq Middle
|
||||
\[em]
|
||||
specifies the
|
||||
.Dq group
|
||||
bits for permissions from the
|
||||
string output form of
|
||||
.Cm p ,
|
||||
or the
|
||||
.Dq suid ,
|
||||
.Dq sgid ,
|
||||
and
|
||||
.Dq sticky
|
||||
bits for the numeric forms of
|
||||
.Cm p .
|
||||
.El
|
||||
.It Ar datum
|
||||
A required field specifier, being one of the following:
|
||||
.Bl -tag -width indent
|
||||
.It Cm d
|
||||
Device upon which
|
||||
.Ar file
|
||||
resides.
|
||||
.It Cm i
|
||||
.Ar file Ns 's
|
||||
inode number.
|
||||
.It Cm p
|
||||
File type and permissions.
|
||||
.It Cm l
|
||||
Number of hard links to
|
||||
.Ar file .
|
||||
.It Cm u , g
|
||||
User ID and group ID of
|
||||
.Ar file Ns 's
|
||||
owner.
|
||||
.It Cm r
|
||||
Device number for character and block device special files.
|
||||
.It Cm a , m , c , B
|
||||
The time
|
||||
.Ar file
|
||||
was last accessed or modified, of when the inode was last changed, or
|
||||
the birth time of the inode.
|
||||
.It Cm z
|
||||
The size of
|
||||
.Ar file
|
||||
in bytes.
|
||||
.It Cm b
|
||||
Number of blocks allocated for
|
||||
.Ar file .
|
||||
.It Cm k
|
||||
Optimal file system I/O operation block size.
|
||||
.It Cm f
|
||||
User defined flags for
|
||||
.Ar file .
|
||||
.It Cm v
|
||||
Inode generation number.
|
||||
.El
|
||||
.Pp
|
||||
The following four field specifiers are not drawn directly from the
|
||||
data in
|
||||
.Vt "struct stat" ,
|
||||
but are:
|
||||
.Bl -tag -width indent
|
||||
.It Cm N
|
||||
The name of the file.
|
||||
.It Cm T
|
||||
The file type, either as in
|
||||
.Nm ls Fl F
|
||||
or in a more descriptive form if the
|
||||
.Ar sub
|
||||
field specifier
|
||||
.Cm H
|
||||
is given.
|
||||
.It Cm Y
|
||||
The target of a symbolic link.
|
||||
.It Cm Z
|
||||
Expands to
|
||||
.Dq major,minor
|
||||
from the
|
||||
.Va rdev
|
||||
field for character or block
|
||||
special devices and gives size output for all others.
|
||||
.El
|
||||
.El
|
||||
.Pp
|
||||
Only the
|
||||
.Cm %
|
||||
and the field specifier are required.
|
||||
Most field specifiers default to
|
||||
.Cm U
|
||||
as an output form, with the
|
||||
exception of
|
||||
.Cm p
|
||||
which defaults to
|
||||
.Cm O ,
|
||||
.Cm a , m ,
|
||||
and
|
||||
.Cm c
|
||||
which default to
|
||||
.Cm D ,
|
||||
and
|
||||
.Cm Y , T ,
|
||||
and
|
||||
.Cm N
|
||||
which default to
|
||||
.Cm S .
|
||||
.Sh EXIT STATUS
|
||||
.Ex -std stat readlink
|
||||
.Sh EXAMPLES
|
||||
Given a symbolic link
|
||||
.Pa foo
|
||||
that points from
|
||||
.Pa /tmp/foo
|
||||
to
|
||||
.Pa / ,
|
||||
you would use
|
||||
.Nm
|
||||
as follows:
|
||||
.Bd -literal -offset indent
|
||||
\*[Gt] stat -F /tmp/foo
|
||||
lrwxrwxrwx 1 jschauma cs 1 Apr 24 16:37:28 2002 /tmp/foo@ -\*[Gt] /
|
||||
|
||||
\*[Gt] stat -LF /tmp/foo
|
||||
drwxr-xr-x 16 root wheel 512 Apr 19 10:57:54 2002 /tmp/foo/
|
||||
.Ed
|
||||
.Pp
|
||||
To initialize some shell variables, you could use the
|
||||
.Fl s
|
||||
flag as follows:
|
||||
.Bd -literal -offset indent
|
||||
\*[Gt] csh
|
||||
% eval set `stat -s .cshrc`
|
||||
% echo $st_size $st_mtimespec
|
||||
1148 1015432481
|
||||
|
||||
\*[Gt] sh
|
||||
$ eval $(stat -s .profile)
|
||||
$ echo $st_size $st_mtimespec
|
||||
1148 1015432481
|
||||
.Ed
|
||||
.Pp
|
||||
In order to get a list of the kind of files including files pointed to if the
|
||||
file is a symbolic link, you could use the following format:
|
||||
.Bd -literal -offset indent
|
||||
$ stat -f "%N: %HT%SY" /tmp/*
|
||||
/tmp/bar: Symbolic Link -\*[Gt] /tmp/foo
|
||||
/tmp/output25568: Regular File
|
||||
/tmp/blah: Directory
|
||||
/tmp/foo: Symbolic Link -\*[Gt] /
|
||||
.Ed
|
||||
.Pp
|
||||
In order to get a list of the devices, their types and the major and minor
|
||||
device numbers, formatted with tabs and linebreaks, you could use the
|
||||
following format:
|
||||
.Bd -literal -offset indent
|
||||
stat -f "Name: %N%n%tType: %HT%n%tMajor: %Hr%n%tMinor: %Lr%n%n" /dev/*
|
||||
[...]
|
||||
Name: /dev/wt8
|
||||
Type: Block Device
|
||||
Major: 3
|
||||
Minor: 8
|
||||
|
||||
Name: /dev/zero
|
||||
Type: Character Device
|
||||
Major: 2
|
||||
Minor: 12
|
||||
.Ed
|
||||
.Pp
|
||||
In order to determine the permissions set on a file separately, you could use
|
||||
the following format:
|
||||
.Bd -literal -offset indent
|
||||
\*[Gt] stat -f "%Sp -\*[Gt] owner=%SHp group=%SMp other=%SLp" .
|
||||
drwxr-xr-x -\*[Gt] owner=rwx group=r-x other=r-x
|
||||
.Ed
|
||||
.Pp
|
||||
In order to determine the three files that have been modified most recently,
|
||||
you could use the following format:
|
||||
.Bd -literal -offset indent
|
||||
\*[Gt] stat -f "%m%t%Sm %N" /tmp/* | sort -rn | head -3 | cut -f2-
|
||||
Apr 25 11:47:00 2002 /tmp/blah
|
||||
Apr 25 10:36:34 2002 /tmp/bar
|
||||
Apr 24 16:47:35 2002 /tmp/foo
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr file 1 ,
|
||||
.Xr ls 1 ,
|
||||
.Xr lstat 2 ,
|
||||
.Xr readlink 2 ,
|
||||
.Xr stat 2 ,
|
||||
.Xr printf 3 ,
|
||||
.Xr strftime 3
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
utility appeared in
|
||||
.Nx 1.6 .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An Andrew Brown
|
||||
.Aq [email protected] .
|
||||
This man page was written by
|
||||
.An Jan Schaumann
|
||||
.Aq [email protected] .
|
||||
@@ -1,988 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Andrew Brown.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if 0
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: stat.c,v 1.13 2003/07/25 03:21:17 atatat Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#else /* HAVE_CONFIG_H */
|
||||
#define HAVE_STRUCT_STAT_ST_FLAGS 1
|
||||
#define HAVE_STRUCT_STAT_ST_GEN 1
|
||||
#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
|
||||
#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
|
||||
#define HAVE_DEVNAME 1
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <grp.h>
|
||||
#include <limits.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if HAVE_STRUCT_STAT_ST_FLAGS
|
||||
#define DEF_F "%#Xf "
|
||||
#define RAW_F "%f "
|
||||
#define SHELL_F " st_flags=%f"
|
||||
#else /* HAVE_STRUCT_STAT_ST_FLAGS */
|
||||
#define DEF_F
|
||||
#define RAW_F
|
||||
#define SHELL_F
|
||||
#endif /* HAVE_STRUCT_STAT_ST_FLAGS */
|
||||
|
||||
#if HAVE_STRUCT_STAT_ST_BIRTHTIME
|
||||
#define DEF_B "\"%SB\" "
|
||||
#define RAW_B "%B "
|
||||
#define SHELL_B "st_birthtime=%B "
|
||||
#else /* HAVE_STRUCT_STAT_ST_BIRTHTIME */
|
||||
#define DEF_B
|
||||
#define RAW_B
|
||||
#define SHELL_B
|
||||
#endif /* HAVE_STRUCT_STAT_ST_BIRTHTIME */
|
||||
|
||||
#if HAVE_STRUCT_STAT_ST_ATIM
|
||||
#define st_atimespec st_atim
|
||||
#define st_ctimespec st_ctim
|
||||
#define st_mtimespec st_mtim
|
||||
#endif /* HAVE_STRUCT_STAT_ST_ATIM */
|
||||
|
||||
#define DEF_FORMAT \
|
||||
"%d %i %Sp %l %Su %Sg %r %z \"%Sa\" \"%Sm\" \"%Sc\" " DEF_B \
|
||||
"%k %b " DEF_F "%N"
|
||||
#define RAW_FORMAT "%d %i %#p %l %u %g %r %z %a %m %c " RAW_B \
|
||||
"%k %b " RAW_F "%N"
|
||||
#define LS_FORMAT "%Sp %l %Su %Sg %Z %Sm %N%SY"
|
||||
#define LSF_FORMAT "%Sp %l %Su %Sg %Z %Sm %N%T%SY"
|
||||
#define SHELL_FORMAT \
|
||||
"st_dev=%d st_ino=%i st_mode=%#p st_nlink=%l " \
|
||||
"st_uid=%u st_gid=%g st_rdev=%r st_size=%z " \
|
||||
"st_atime=%a st_mtime=%m st_ctime=%c " SHELL_B \
|
||||
"st_blksize=%k st_blocks=%b" SHELL_F
|
||||
#define LINUX_FORMAT \
|
||||
" File: \"%N\"%n" \
|
||||
" Size: %-11z FileType: %HT%n" \
|
||||
" Mode: (%04OLp/%.10Sp) Uid: (%5u/%8Su) Gid: (%5g/%8Sg)%n" \
|
||||
"Device: %Hd,%Ld Inode: %i Links: %l%n" \
|
||||
"Access: %Sa%n" \
|
||||
"Modify: %Sm%n" \
|
||||
"Change: %Sc"
|
||||
|
||||
#define TIME_FORMAT "%b %e %T %Y"
|
||||
|
||||
#define FLAG_POUND 0x01
|
||||
#define FLAG_SPACE 0x02
|
||||
#define FLAG_PLUS 0x04
|
||||
#define FLAG_ZERO 0x08
|
||||
#define FLAG_MINUS 0x10
|
||||
|
||||
/*
|
||||
* These format characters must all be unique, except the magic one.
|
||||
*/
|
||||
#define FMT_MAGIC '%'
|
||||
#define FMT_DOT '.'
|
||||
|
||||
#define SIMPLE_NEWLINE 'n'
|
||||
#define SIMPLE_TAB 't'
|
||||
#define SIMPLE_PERCENT '%'
|
||||
#define SIMPLE_NUMBER '@'
|
||||
|
||||
#define FMT_POUND '#'
|
||||
#define FMT_SPACE ' '
|
||||
#define FMT_PLUS '+'
|
||||
#define FMT_ZERO '0'
|
||||
#define FMT_MINUS '-'
|
||||
|
||||
#define FMT_DECIMAL 'D'
|
||||
#define FMT_OCTAL 'O'
|
||||
#define FMT_UNSIGNED 'U'
|
||||
#define FMT_HEX 'X'
|
||||
#define FMT_FLOAT 'F'
|
||||
#define FMT_STRING 'S'
|
||||
|
||||
#define FMTF_DECIMAL 0x01
|
||||
#define FMTF_OCTAL 0x02
|
||||
#define FMTF_UNSIGNED 0x04
|
||||
#define FMTF_HEX 0x08
|
||||
#define FMTF_FLOAT 0x10
|
||||
#define FMTF_STRING 0x20
|
||||
|
||||
#define HIGH_PIECE 'H'
|
||||
#define MIDDLE_PIECE 'M'
|
||||
#define LOW_PIECE 'L'
|
||||
|
||||
#define SHOW_st_dev 'd'
|
||||
#define SHOW_st_ino 'i'
|
||||
#define SHOW_st_mode 'p'
|
||||
#define SHOW_st_nlink 'l'
|
||||
#define SHOW_st_uid 'u'
|
||||
#define SHOW_st_gid 'g'
|
||||
#define SHOW_st_rdev 'r'
|
||||
#define SHOW_st_atime 'a'
|
||||
#define SHOW_st_mtime 'm'
|
||||
#define SHOW_st_ctime 'c'
|
||||
#define SHOW_st_btime 'B'
|
||||
#define SHOW_st_size 'z'
|
||||
#define SHOW_st_blocks 'b'
|
||||
#define SHOW_st_blksize 'k'
|
||||
#define SHOW_st_flags 'f'
|
||||
#define SHOW_st_gen 'v'
|
||||
#define SHOW_symlink 'Y'
|
||||
#define SHOW_filetype 'T'
|
||||
#define SHOW_filename 'N'
|
||||
#define SHOW_sizerdev 'Z'
|
||||
|
||||
void usage(const char *);
|
||||
void output(const struct stat *, const char *,
|
||||
const char *, int, int, int);
|
||||
int format1(const struct stat *, /* stat info */
|
||||
const char *, /* the file name */
|
||||
const char *, int, /* the format string itself */
|
||||
char *, size_t, /* a place to put the output */
|
||||
int, int, int, int, /* the parsed format */
|
||||
int, int);
|
||||
|
||||
char *timefmt;
|
||||
int linkfail;
|
||||
|
||||
#define addchar(s, c, nl) \
|
||||
do { \
|
||||
(void)fputc((c), (s)); \
|
||||
(*nl) = ((c) == '\n'); \
|
||||
} while (0/*CONSTCOND*/)
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct stat st;
|
||||
int ch, rc, errs, am_readlink;
|
||||
int lsF, fmtchar, usestat, fn, nonl, quiet;
|
||||
char *statfmt, *options, *synopsis;
|
||||
|
||||
am_readlink = 0;
|
||||
lsF = 0;
|
||||
fmtchar = '\0';
|
||||
usestat = 0;
|
||||
nonl = 0;
|
||||
quiet = 0;
|
||||
linkfail = 0;
|
||||
statfmt = NULL;
|
||||
timefmt = NULL;
|
||||
|
||||
if (strcmp(getprogname(), "readlink") == 0) {
|
||||
am_readlink = 1;
|
||||
options = "n";
|
||||
synopsis = "[-n] [file ...]";
|
||||
statfmt = "%Y";
|
||||
fmtchar = 'f';
|
||||
quiet = 1;
|
||||
} else {
|
||||
options = "f:FlLnqrst:x";
|
||||
synopsis = "[-FlLnqrsx] [-f format] [-t timefmt] [file ...]";
|
||||
}
|
||||
|
||||
while ((ch = getopt(argc, argv, options)) != -1)
|
||||
switch (ch) {
|
||||
case 'F':
|
||||
lsF = 1;
|
||||
break;
|
||||
case 'L':
|
||||
usestat = 1;
|
||||
break;
|
||||
case 'n':
|
||||
nonl = 1;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
case 'f':
|
||||
statfmt = optarg;
|
||||
/* FALLTHROUGH */
|
||||
case 'l':
|
||||
case 'r':
|
||||
case 's':
|
||||
case 'x':
|
||||
if (fmtchar != 0)
|
||||
errx(1, "can't use format '%c' with '%c'",
|
||||
fmtchar, ch);
|
||||
fmtchar = ch;
|
||||
break;
|
||||
case 't':
|
||||
timefmt = optarg;
|
||||
break;
|
||||
default:
|
||||
usage(synopsis);
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
fn = 1;
|
||||
|
||||
if (fmtchar == '\0') {
|
||||
if (lsF)
|
||||
fmtchar = 'l';
|
||||
else {
|
||||
fmtchar = 'f';
|
||||
statfmt = DEF_FORMAT;
|
||||
}
|
||||
}
|
||||
|
||||
if (lsF && fmtchar != 'l')
|
||||
errx(1, "can't use format '%c' with -F", fmtchar);
|
||||
|
||||
switch (fmtchar) {
|
||||
case 'f':
|
||||
/* statfmt already set */
|
||||
break;
|
||||
case 'l':
|
||||
statfmt = lsF ? LSF_FORMAT : LS_FORMAT;
|
||||
break;
|
||||
case 'r':
|
||||
statfmt = RAW_FORMAT;
|
||||
break;
|
||||
case 's':
|
||||
statfmt = SHELL_FORMAT;
|
||||
break;
|
||||
case 'x':
|
||||
statfmt = LINUX_FORMAT;
|
||||
if (timefmt == NULL)
|
||||
timefmt = "%c";
|
||||
break;
|
||||
default:
|
||||
usage(synopsis);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
if (timefmt == NULL)
|
||||
timefmt = TIME_FORMAT;
|
||||
|
||||
errs = 0;
|
||||
do {
|
||||
if (argc == 0)
|
||||
rc = fstat(STDIN_FILENO, &st);
|
||||
else if (usestat)
|
||||
rc = stat(argv[0], &st);
|
||||
else
|
||||
rc = lstat(argv[0], &st);
|
||||
|
||||
if (rc == -1) {
|
||||
errs = 1;
|
||||
linkfail = 1;
|
||||
if (!quiet)
|
||||
warn("%s: stat",
|
||||
argc == 0 ? "(stdin)" : argv[0]);
|
||||
}
|
||||
else
|
||||
output(&st, argv[0], statfmt, fn, nonl, quiet);
|
||||
|
||||
argv++;
|
||||
argc--;
|
||||
fn++;
|
||||
} while (argc > 0);
|
||||
|
||||
return (am_readlink ? linkfail : errs);
|
||||
}
|
||||
|
||||
void
|
||||
usage(const char *synopsis)
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "usage: %s %s\n", getprogname(), synopsis);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Parses a format string.
|
||||
*/
|
||||
void
|
||||
output(const struct stat *st, const char *file,
|
||||
const char *statfmt, int fn, int nonl, int quiet)
|
||||
{
|
||||
int flags, size, prec, ofmt, hilo, what;
|
||||
char buf[PATH_MAX];
|
||||
const char *subfmt;
|
||||
int nl, t, i;
|
||||
|
||||
nl = 1;
|
||||
while (*statfmt != '\0') {
|
||||
|
||||
/*
|
||||
* Non-format characters go straight out.
|
||||
*/
|
||||
if (*statfmt != FMT_MAGIC) {
|
||||
addchar(stdout, *statfmt, &nl);
|
||||
statfmt++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* The current format "substring" starts here,
|
||||
* and then we skip the magic.
|
||||
*/
|
||||
subfmt = statfmt;
|
||||
statfmt++;
|
||||
|
||||
/*
|
||||
* Some simple one-character "formats".
|
||||
*/
|
||||
switch (*statfmt) {
|
||||
case SIMPLE_NEWLINE:
|
||||
addchar(stdout, '\n', &nl);
|
||||
statfmt++;
|
||||
continue;
|
||||
case SIMPLE_TAB:
|
||||
addchar(stdout, '\t', &nl);
|
||||
statfmt++;
|
||||
continue;
|
||||
case SIMPLE_PERCENT:
|
||||
addchar(stdout, '%', &nl);
|
||||
statfmt++;
|
||||
continue;
|
||||
case SIMPLE_NUMBER: {
|
||||
char num[12], *p;
|
||||
|
||||
snprintf(num, sizeof(num), "%d", fn);
|
||||
for (p = &num[0]; *p; p++)
|
||||
addchar(stdout, *p, &nl);
|
||||
statfmt++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This must be an actual format string. Format strings are
|
||||
* similar to printf(3) formats up to a point, and are of
|
||||
* the form:
|
||||
*
|
||||
* % required start of format
|
||||
* [-# +0] opt. format characters
|
||||
* size opt. field width
|
||||
* . opt. decimal separator, followed by
|
||||
* prec opt. precision
|
||||
* fmt opt. output specifier (string, numeric, etc.)
|
||||
* sub opt. sub field specifier (high, middle, low)
|
||||
* datum required field specifier (size, mode, etc)
|
||||
*
|
||||
* Only the % and the datum selector are required. All data
|
||||
* have reasonable default output forms. The "sub" specifier
|
||||
* only applies to certain data (mode, dev, rdev, filetype).
|
||||
* The symlink output defaults to STRING, yet will only emit
|
||||
* the leading " -> " if STRING is explicitly specified. The
|
||||
* sizerdev datum will generate rdev output for character or
|
||||
* block devices, and size output for all others.
|
||||
*/
|
||||
flags = 0;
|
||||
do {
|
||||
if (*statfmt == FMT_POUND)
|
||||
flags |= FLAG_POUND;
|
||||
else if (*statfmt == FMT_SPACE)
|
||||
flags |= FLAG_SPACE;
|
||||
else if (*statfmt == FMT_PLUS)
|
||||
flags |= FLAG_PLUS;
|
||||
else if (*statfmt == FMT_ZERO)
|
||||
flags |= FLAG_ZERO;
|
||||
else if (*statfmt == FMT_MINUS)
|
||||
flags |= FLAG_MINUS;
|
||||
else
|
||||
break;
|
||||
statfmt++;
|
||||
} while (1/*CONSTCOND*/);
|
||||
|
||||
size = -1;
|
||||
if (isdigit((unsigned)*statfmt)) {
|
||||
size = 0;
|
||||
while (isdigit((unsigned)*statfmt)) {
|
||||
size = (size * 10) + (*statfmt - '0');
|
||||
statfmt++;
|
||||
if (size < 0)
|
||||
goto badfmt;
|
||||
}
|
||||
}
|
||||
|
||||
prec = -1;
|
||||
if (*statfmt == FMT_DOT) {
|
||||
statfmt++;
|
||||
|
||||
prec = 0;
|
||||
while (isdigit((unsigned)*statfmt)) {
|
||||
prec = (prec * 10) + (*statfmt - '0');
|
||||
statfmt++;
|
||||
if (prec < 0)
|
||||
goto badfmt;
|
||||
}
|
||||
}
|
||||
|
||||
#define fmtcase(x, y) case (y): (x) = (y); statfmt++; break
|
||||
#define fmtcasef(x, y, z) case (y): (x) = (z); statfmt++; break
|
||||
switch (*statfmt) {
|
||||
fmtcasef(ofmt, FMT_DECIMAL, FMTF_DECIMAL);
|
||||
fmtcasef(ofmt, FMT_OCTAL, FMTF_OCTAL);
|
||||
fmtcasef(ofmt, FMT_UNSIGNED, FMTF_UNSIGNED);
|
||||
fmtcasef(ofmt, FMT_HEX, FMTF_HEX);
|
||||
fmtcasef(ofmt, FMT_FLOAT, FMTF_FLOAT);
|
||||
fmtcasef(ofmt, FMT_STRING, FMTF_STRING);
|
||||
default:
|
||||
ofmt = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (*statfmt) {
|
||||
fmtcase(hilo, HIGH_PIECE);
|
||||
fmtcase(hilo, MIDDLE_PIECE);
|
||||
fmtcase(hilo, LOW_PIECE);
|
||||
default:
|
||||
hilo = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (*statfmt) {
|
||||
fmtcase(what, SHOW_st_dev);
|
||||
fmtcase(what, SHOW_st_ino);
|
||||
fmtcase(what, SHOW_st_mode);
|
||||
fmtcase(what, SHOW_st_nlink);
|
||||
fmtcase(what, SHOW_st_uid);
|
||||
fmtcase(what, SHOW_st_gid);
|
||||
fmtcase(what, SHOW_st_rdev);
|
||||
fmtcase(what, SHOW_st_atime);
|
||||
fmtcase(what, SHOW_st_mtime);
|
||||
fmtcase(what, SHOW_st_ctime);
|
||||
fmtcase(what, SHOW_st_btime);
|
||||
fmtcase(what, SHOW_st_size);
|
||||
fmtcase(what, SHOW_st_blocks);
|
||||
fmtcase(what, SHOW_st_blksize);
|
||||
fmtcase(what, SHOW_st_flags);
|
||||
fmtcase(what, SHOW_st_gen);
|
||||
fmtcase(what, SHOW_symlink);
|
||||
fmtcase(what, SHOW_filetype);
|
||||
fmtcase(what, SHOW_filename);
|
||||
fmtcase(what, SHOW_sizerdev);
|
||||
default:
|
||||
goto badfmt;
|
||||
}
|
||||
#undef fmtcasef
|
||||
#undef fmtcase
|
||||
|
||||
t = format1(st,
|
||||
file,
|
||||
subfmt, statfmt - subfmt,
|
||||
buf, sizeof(buf),
|
||||
flags, size, prec, ofmt, hilo, what);
|
||||
|
||||
for (i = 0; i < t && i < sizeof(buf); i++)
|
||||
addchar(stdout, buf[i], &nl);
|
||||
|
||||
continue;
|
||||
|
||||
badfmt:
|
||||
errx(1, "%.*s: bad format",
|
||||
(int)(statfmt - subfmt + 1), subfmt);
|
||||
}
|
||||
|
||||
if (!nl && !nonl)
|
||||
(void)fputc('\n', stdout);
|
||||
(void)fflush(stdout);
|
||||
}
|
||||
|
||||
/*
|
||||
* Arranges output according to a single parsed format substring.
|
||||
*/
|
||||
int
|
||||
format1(const struct stat *st,
|
||||
const char *file,
|
||||
const char *fmt, int flen,
|
||||
char *buf, size_t blen,
|
||||
int flags, int size, int prec, int ofmt,
|
||||
int hilo, int what)
|
||||
{
|
||||
u_int64_t data;
|
||||
char *sdata, lfmt[24], tmp[20];
|
||||
char smode[12], sid[12], path[PATH_MAX + 4];
|
||||
struct passwd *pw;
|
||||
struct group *gr;
|
||||
const struct timespec *tsp;
|
||||
struct timespec ts;
|
||||
struct tm *tm;
|
||||
int l, small, formats;
|
||||
|
||||
tsp = NULL;
|
||||
formats = 0;
|
||||
small = 0;
|
||||
|
||||
/*
|
||||
* First, pick out the data and tweak it based on hilo or
|
||||
* specified output format (symlink output only).
|
||||
*/
|
||||
switch (what) {
|
||||
case SHOW_st_dev:
|
||||
case SHOW_st_rdev:
|
||||
small = (sizeof(st->st_dev) == 4);
|
||||
data = (what == SHOW_st_dev) ? st->st_dev : st->st_rdev;
|
||||
#if HAVE_DEVNAME
|
||||
sdata = (what == SHOW_st_dev) ?
|
||||
devname(st->st_dev, S_IFBLK) :
|
||||
devname(st->st_rdev,
|
||||
S_ISCHR(st->st_mode) ? S_IFCHR :
|
||||
S_ISBLK(st->st_mode) ? S_IFBLK :
|
||||
0U);
|
||||
if (sdata == NULL)
|
||||
sdata = "???";
|
||||
#endif /* HAVE_DEVNAME */
|
||||
if (hilo == HIGH_PIECE) {
|
||||
data = major(data);
|
||||
hilo = 0;
|
||||
}
|
||||
else if (hilo == LOW_PIECE) {
|
||||
data = minor((unsigned)data);
|
||||
hilo = 0;
|
||||
}
|
||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
|
||||
#if HAVE_DEVNAME
|
||||
FMTF_STRING;
|
||||
#else /* HAVE_DEVNAME */
|
||||
0;
|
||||
#endif /* HAVE_DEVNAME */
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_UNSIGNED;
|
||||
break;
|
||||
case SHOW_st_ino:
|
||||
small = (sizeof(st->st_ino) == 4);
|
||||
data = st->st_ino;
|
||||
sdata = NULL;
|
||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_UNSIGNED;
|
||||
break;
|
||||
case SHOW_st_mode:
|
||||
small = (sizeof(st->st_mode) == 4);
|
||||
data = st->st_mode;
|
||||
strmode(st->st_mode, smode);
|
||||
sdata = smode;
|
||||
l = strlen(sdata);
|
||||
if (sdata[l - 1] == ' ')
|
||||
sdata[--l] = '\0';
|
||||
if (hilo == HIGH_PIECE) {
|
||||
data >>= 12;
|
||||
sdata += 1;
|
||||
sdata[3] = '\0';
|
||||
hilo = 0;
|
||||
}
|
||||
else if (hilo == MIDDLE_PIECE) {
|
||||
data = (data >> 9) & 07;
|
||||
sdata += 4;
|
||||
sdata[3] = '\0';
|
||||
hilo = 0;
|
||||
}
|
||||
else if (hilo == LOW_PIECE) {
|
||||
data &= 0777;
|
||||
sdata += 7;
|
||||
sdata[3] = '\0';
|
||||
hilo = 0;
|
||||
}
|
||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
|
||||
FMTF_STRING;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_OCTAL;
|
||||
break;
|
||||
case SHOW_st_nlink:
|
||||
small = (sizeof(st->st_dev) == 4);
|
||||
data = st->st_nlink;
|
||||
sdata = NULL;
|
||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_UNSIGNED;
|
||||
break;
|
||||
case SHOW_st_uid:
|
||||
small = (sizeof(st->st_uid) == 4);
|
||||
data = st->st_uid;
|
||||
if ((pw = getpwuid(st->st_uid)) != NULL)
|
||||
sdata = pw->pw_name;
|
||||
else {
|
||||
snprintf(sid, sizeof(sid), "(%ld)", (long)st->st_uid);
|
||||
sdata = sid;
|
||||
}
|
||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
|
||||
FMTF_STRING;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_UNSIGNED;
|
||||
break;
|
||||
case SHOW_st_gid:
|
||||
small = (sizeof(st->st_gid) == 4);
|
||||
data = st->st_gid;
|
||||
if ((gr = getgrgid(st->st_gid)) != NULL)
|
||||
sdata = gr->gr_name;
|
||||
else {
|
||||
snprintf(sid, sizeof(sid), "(%ld)", (long)st->st_gid);
|
||||
sdata = sid;
|
||||
}
|
||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
|
||||
FMTF_STRING;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_UNSIGNED;
|
||||
break;
|
||||
case SHOW_st_atime:
|
||||
tsp = &st->st_atimespec;
|
||||
/* FALLTHROUGH */
|
||||
case SHOW_st_mtime:
|
||||
if (tsp == NULL)
|
||||
tsp = &st->st_mtimespec;
|
||||
/* FALLTHROUGH */
|
||||
case SHOW_st_ctime:
|
||||
if (tsp == NULL)
|
||||
tsp = &st->st_ctimespec;
|
||||
/* FALLTHROUGH */
|
||||
#if HAVE_STRUCT_STAT_ST_BIRTHTIME
|
||||
case SHOW_st_btime:
|
||||
if (tsp == NULL)
|
||||
tsp = &st->st_birthtimespec;
|
||||
#endif /* HAVE_STRUCT_STAT_ST_BIRTHTIME */
|
||||
ts = *tsp; /* copy so we can muck with it */
|
||||
small = (sizeof(ts.tv_sec) == 4);
|
||||
data = ts.tv_sec;
|
||||
small = 1;
|
||||
tm = localtime(&ts.tv_sec);
|
||||
(void)strftime(path, sizeof(path), timefmt, tm);
|
||||
sdata = path;
|
||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
|
||||
FMTF_FLOAT | FMTF_STRING;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_DECIMAL;
|
||||
break;
|
||||
case SHOW_st_size:
|
||||
small = (sizeof(st->st_size) == 4);
|
||||
data = st->st_size;
|
||||
sdata = NULL;
|
||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_UNSIGNED;
|
||||
break;
|
||||
case SHOW_st_blocks:
|
||||
small = (sizeof(st->st_blocks) == 4);
|
||||
data = st->st_blocks;
|
||||
sdata = NULL;
|
||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_UNSIGNED;
|
||||
break;
|
||||
case SHOW_st_blksize:
|
||||
small = (sizeof(st->st_blksize) == 4);
|
||||
data = st->st_blksize;
|
||||
sdata = NULL;
|
||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_UNSIGNED;
|
||||
break;
|
||||
#if HAVE_STRUCT_STAT_ST_FLAGS
|
||||
case SHOW_st_flags:
|
||||
small = (sizeof(st->st_flags) == 4);
|
||||
data = st->st_flags;
|
||||
sdata = NULL;
|
||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_UNSIGNED;
|
||||
break;
|
||||
#endif /* HAVE_STRUCT_STAT_ST_FLAGS */
|
||||
#if HAVE_STRUCT_STAT_ST_GEN
|
||||
case SHOW_st_gen:
|
||||
small = (sizeof(st->st_gen) == 4);
|
||||
data = st->st_gen;
|
||||
sdata = NULL;
|
||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_UNSIGNED;
|
||||
break;
|
||||
#endif /* HAVE_STRUCT_STAT_ST_GEN */
|
||||
case SHOW_symlink:
|
||||
small = 0;
|
||||
data = 0;
|
||||
if (S_ISLNK(st->st_mode)) {
|
||||
snprintf(path, sizeof(path), " -> ");
|
||||
l = readlink(file, path + 4, sizeof(path) - 4 - 1);
|
||||
if (l == -1) {
|
||||
linkfail = 1;
|
||||
l = 0;
|
||||
path[0] = '\0';
|
||||
}
|
||||
path[l + 4] = '\0';
|
||||
sdata = path + (ofmt == FMTF_STRING ? 0 : 4);
|
||||
}
|
||||
else {
|
||||
linkfail = 1;
|
||||
sdata = "";
|
||||
}
|
||||
formats = FMTF_STRING;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_STRING;
|
||||
break;
|
||||
case SHOW_filetype:
|
||||
small = 0;
|
||||
data = 0;
|
||||
sdata = smode;
|
||||
sdata[0] = '\0';
|
||||
if (hilo == 0 || hilo == LOW_PIECE) {
|
||||
switch (st->st_mode & S_IFMT) {
|
||||
case S_IFIFO: (void)strcat(sdata, "|"); break;
|
||||
case S_IFDIR: (void)strcat(sdata, "/"); break;
|
||||
case S_IFREG:
|
||||
if (st->st_mode &
|
||||
(S_IXUSR | S_IXGRP | S_IXOTH))
|
||||
(void)strcat(sdata, "*");
|
||||
break;
|
||||
case S_IFLNK: (void)strcat(sdata, "@"); break;
|
||||
case S_IFSOCK: (void)strcat(sdata, "="); break;
|
||||
#ifdef S_IFWHT
|
||||
case S_IFWHT: (void)strcat(sdata, "%"); break;
|
||||
#endif /* S_IFWHT */
|
||||
#ifdef S_IFDOOR
|
||||
case S_IFDOOR: (void)strcat(sdata, ">"); break;
|
||||
#endif /* S_IFDOOR */
|
||||
}
|
||||
hilo = 0;
|
||||
}
|
||||
else if (hilo == HIGH_PIECE) {
|
||||
switch (st->st_mode & S_IFMT) {
|
||||
case S_IFIFO: sdata = "Fifo File"; break;
|
||||
case S_IFCHR: sdata = "Character Device"; break;
|
||||
case S_IFDIR: sdata = "Directory"; break;
|
||||
case S_IFBLK: sdata = "Block Device"; break;
|
||||
case S_IFREG: sdata = "Regular File"; break;
|
||||
case S_IFLNK: sdata = "Symbolic Link"; break;
|
||||
case S_IFSOCK: sdata = "Socket"; break;
|
||||
#ifdef S_IFWHT
|
||||
case S_IFWHT: sdata = "Whiteout File"; break;
|
||||
#endif /* S_IFWHT */
|
||||
#ifdef S_IFDOOR
|
||||
case S_IFDOOR: sdata = "Door"; break;
|
||||
#endif /* S_IFDOOR */
|
||||
default: sdata = "???"; break;
|
||||
}
|
||||
hilo = 0;
|
||||
}
|
||||
formats = FMTF_STRING;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_STRING;
|
||||
break;
|
||||
case SHOW_filename:
|
||||
small = 0;
|
||||
data = 0;
|
||||
if (file == NULL)
|
||||
(void)strncpy(path, "(stdin)", sizeof(path));
|
||||
else
|
||||
(void)strncpy(path, file, sizeof(path));
|
||||
sdata = path;
|
||||
formats = FMTF_STRING;
|
||||
if (ofmt == 0)
|
||||
ofmt = FMTF_STRING;
|
||||
break;
|
||||
case SHOW_sizerdev:
|
||||
if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) {
|
||||
char majdev[20], mindev[20];
|
||||
int l1, l2;
|
||||
|
||||
l1 = format1(st,
|
||||
file,
|
||||
fmt, flen,
|
||||
majdev, sizeof(majdev),
|
||||
flags, size, prec,
|
||||
ofmt, HIGH_PIECE, SHOW_st_rdev);
|
||||
l2 = format1(st,
|
||||
file,
|
||||
fmt, flen,
|
||||
mindev, sizeof(mindev),
|
||||
flags, size, prec,
|
||||
ofmt, LOW_PIECE, SHOW_st_rdev);
|
||||
return (snprintf(buf, blen, "%.*s,%.*s",
|
||||
l1, majdev, l2, mindev));
|
||||
}
|
||||
else {
|
||||
return (format1(st,
|
||||
file,
|
||||
fmt, flen,
|
||||
buf, blen,
|
||||
flags, size, prec,
|
||||
ofmt, 0, SHOW_st_size));
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
default:
|
||||
errx(1, "%.*s: bad format", (int)flen, fmt);
|
||||
}
|
||||
|
||||
/*
|
||||
* If a subdatum was specified but not supported, or an output
|
||||
* format was selected that is not supported, that's an error.
|
||||
*/
|
||||
if (hilo != 0 || (ofmt & formats) == 0)
|
||||
errx(1, "%.*s: bad format", (int)flen, fmt);
|
||||
|
||||
/*
|
||||
* Assemble the format string for passing to printf(3).
|
||||
*/
|
||||
lfmt[0] = '\0';
|
||||
(void)strcat(lfmt, "%");
|
||||
if (flags & FLAG_POUND)
|
||||
(void)strcat(lfmt, "#");
|
||||
if (flags & FLAG_SPACE)
|
||||
(void)strcat(lfmt, " ");
|
||||
if (flags & FLAG_PLUS)
|
||||
(void)strcat(lfmt, "+");
|
||||
if (flags & FLAG_MINUS)
|
||||
(void)strcat(lfmt, "-");
|
||||
if (flags & FLAG_ZERO)
|
||||
(void)strcat(lfmt, "0");
|
||||
|
||||
/*
|
||||
* Only the timespecs support the FLOAT output format, and that
|
||||
* requires work that differs from the other formats.
|
||||
*/
|
||||
if (ofmt == FMTF_FLOAT) {
|
||||
/*
|
||||
* Nothing after the decimal point, so just print seconds.
|
||||
*/
|
||||
if (prec == 0) {
|
||||
if (size != -1) {
|
||||
(void)snprintf(tmp, sizeof(tmp), "%d", size);
|
||||
(void)strcat(lfmt, tmp);
|
||||
}
|
||||
(void)strcat(lfmt, "d");
|
||||
return (snprintf(buf, blen, lfmt, ts.tv_sec));
|
||||
}
|
||||
|
||||
/*
|
||||
* Unspecified precision gets all the precision we have:
|
||||
* 9 digits.
|
||||
*/
|
||||
if (prec == -1)
|
||||
prec = 9;
|
||||
|
||||
/*
|
||||
* Adjust the size for the decimal point and the digits
|
||||
* that will follow.
|
||||
*/
|
||||
size -= prec + 1;
|
||||
|
||||
/*
|
||||
* Any leftover size that's legitimate will be used.
|
||||
*/
|
||||
if (size > 0) {
|
||||
(void)snprintf(tmp, sizeof(tmp), "%d", size);
|
||||
(void)strcat(lfmt, tmp);
|
||||
}
|
||||
(void)strcat(lfmt, "d");
|
||||
|
||||
/*
|
||||
* The stuff after the decimal point always needs zero
|
||||
* filling.
|
||||
*/
|
||||
(void)strcat(lfmt, ".%0");
|
||||
|
||||
/*
|
||||
* We can "print" at most nine digits of precision. The
|
||||
* rest we will pad on at the end.
|
||||
*/
|
||||
(void)snprintf(tmp, sizeof(tmp), "%dd", prec > 9 ? 9 : prec);
|
||||
(void)strcat(lfmt, tmp);
|
||||
|
||||
/*
|
||||
* For precision of less that nine digits, trim off the
|
||||
* less significant figures.
|
||||
*/
|
||||
for (; prec < 9; prec++)
|
||||
ts.tv_nsec /= 10;
|
||||
|
||||
/*
|
||||
* Use the format, and then tack on any zeroes that
|
||||
* might be required to make up the requested precision.
|
||||
*/
|
||||
l = snprintf(buf, blen, lfmt, ts.tv_sec, ts.tv_nsec);
|
||||
for (; prec > 9 && l < blen; prec--, l++)
|
||||
(void)strcat(buf, "0");
|
||||
return (l);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add on size and precision, if specified, to the format.
|
||||
*/
|
||||
if (size != -1) {
|
||||
(void)snprintf(tmp, sizeof(tmp), "%d", size);
|
||||
(void)strcat(lfmt, tmp);
|
||||
}
|
||||
if (prec != -1) {
|
||||
(void)snprintf(tmp, sizeof(tmp), ".%d", prec);
|
||||
(void)strcat(lfmt, tmp);
|
||||
}
|
||||
|
||||
/*
|
||||
* String output uses the temporary sdata.
|
||||
*/
|
||||
if (ofmt == FMTF_STRING) {
|
||||
if (sdata == NULL)
|
||||
errx(1, "%.*s: bad format", (int)flen, fmt);
|
||||
(void)strcat(lfmt, "s");
|
||||
return (snprintf(buf, blen, lfmt, sdata));
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure that sign extension does not cause bad looking output
|
||||
* for some forms.
|
||||
*/
|
||||
if (small && ofmt != FMTF_DECIMAL)
|
||||
data = (u_int32_t)data;
|
||||
|
||||
/*
|
||||
* The four "numeric" output forms.
|
||||
*/
|
||||
(void)strcat(lfmt, "ll");
|
||||
switch (ofmt) {
|
||||
case FMTF_DECIMAL: (void)strcat(lfmt, "d"); break;
|
||||
case FMTF_OCTAL: (void)strcat(lfmt, "o"); break;
|
||||
case FMTF_UNSIGNED: (void)strcat(lfmt, "u"); break;
|
||||
case FMTF_HEX: (void)strcat(lfmt, "x"); break;
|
||||
}
|
||||
|
||||
return (snprintf(buf, blen, lfmt, data));
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2000 Dan Papasian. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void usage(void);
|
||||
static int print_matches(char *, char *);
|
||||
|
||||
int silent;
|
||||
int allpaths;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *p, *path;
|
||||
ssize_t pathlen;
|
||||
int opt, status;
|
||||
|
||||
status = EXIT_SUCCESS;
|
||||
|
||||
/* If called without args, die silently to conform */
|
||||
if (argc < 2)
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
while ((opt = getopt(argc, argv, "as")) != -1) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
allpaths = 1;
|
||||
break;
|
||||
case 's':
|
||||
silent = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
|
||||
if ((p = getenv("PATH")) == NULL)
|
||||
exit(EXIT_FAILURE);
|
||||
pathlen = strlen(p) + 1;
|
||||
path = malloc(pathlen);
|
||||
if (path == NULL)
|
||||
err(EXIT_FAILURE, NULL);
|
||||
|
||||
if (argc == 0)
|
||||
status = EXIT_FAILURE;
|
||||
|
||||
while (argc > 0) {
|
||||
memcpy(path, p, pathlen);
|
||||
|
||||
if (strlen(*argv) >= FILENAME_MAX ||
|
||||
print_matches(path, *argv) == -1)
|
||||
status = EXIT_FAILURE;
|
||||
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
|
||||
exit(status);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
|
||||
errx(EXIT_FAILURE, "usage: which [-as] program ...");
|
||||
}
|
||||
|
||||
static int
|
||||
is_there(char *candidate)
|
||||
{
|
||||
struct stat fin;
|
||||
|
||||
/* XXX work around access(2) false positives for superuser */
|
||||
if (access(candidate, X_OK) == 0 &&
|
||||
stat(candidate, &fin) == 0 &&
|
||||
S_ISREG(fin.st_mode) &&
|
||||
(getuid() != 0 ||
|
||||
(fin.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0)) {
|
||||
if (!silent)
|
||||
printf("%s\n", candidate);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
print_matches(char *path, char *filename)
|
||||
{
|
||||
char candidate[PATH_MAX];
|
||||
const char *d;
|
||||
int found;
|
||||
|
||||
if (strchr(filename, '/') != NULL)
|
||||
return (is_there(filename) ? 0 : -1);
|
||||
found = 0;
|
||||
while ((d = strsep(&path, ":")) != NULL) {
|
||||
if (*d == '\0')
|
||||
d = ".";
|
||||
if (snprintf(candidate, sizeof(candidate), "%s/%s", d,
|
||||
filename) >= (int)sizeof(candidate))
|
||||
continue;
|
||||
if (is_there(candidate)) {
|
||||
found = 1;
|
||||
if (!allpaths)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (found ? 0 : -1);
|
||||
}
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
/*-
|
||||
* ------+---------+---------+---------+---------+---------+---------+---------*
|
||||
* Copyright (c) 2003 - Garance Alistair Drosehn <gad@FreeBSD.org>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation
|
||||
* are those of the authors and should not be interpreted as representing
|
||||
* official policies, either expressed or implied, of the FreeBSD Project.
|
||||
*
|
||||
* ------+---------+---------+---------+---------+---------+---------+---------*
|
||||
* $FreeBSD$
|
||||
* ------+---------+---------+---------+---------+---------+---------+---------*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <time.h>
|
||||
|
||||
#define PTM_PARSE_ISO8601 0x0001 /* Parse ISO-standard format */
|
||||
#define PTM_PARSE_DWM 0x0002 /* Parse Day-Week-Month format */
|
||||
#define PTM_PARSE_MATCHDOM 0x0004 /* If the user specifies a day-of-month,
|
||||
* then the result should be a month
|
||||
* which actually has that day. Eg:
|
||||
* the user requests "day 31" when
|
||||
* the present month is February. */
|
||||
|
||||
struct ptime_data;
|
||||
|
||||
/* Some global variables from newsyslog.c which might be of interest */
|
||||
extern int dbg_at_times; /* cmdline debugging option */
|
||||
extern int noaction; /* command-line option */
|
||||
extern int verbose; /* command-line option */
|
||||
extern struct ptime_data *dbg_timenow;
|
||||
|
||||
__BEGIN_DECLS
|
||||
struct ptime_data *ptime_init(const struct ptime_data *_optsrc);
|
||||
int ptime_adjust4dst(struct ptime_data *_ptime, const struct
|
||||
ptime_data *_dstsrc);
|
||||
int ptime_free(struct ptime_data *_ptime);
|
||||
int ptime_relparse(struct ptime_data *_ptime, int _parseopts,
|
||||
time_t _basetime, const char *_str);
|
||||
const char *ptimeget_ctime(const struct ptime_data *_ptime);
|
||||
double ptimeget_diff(const struct ptime_data *_minuend,
|
||||
const struct ptime_data *_subtrahend);
|
||||
time_t ptimeget_secs(const struct ptime_data *_ptime);
|
||||
int ptimeset_nxtime(struct ptime_data *_ptime);
|
||||
int ptimeset_time(struct ptime_data *_ptime, time_t _secs);
|
||||
__END_DECLS
|
||||
@@ -1,619 +0,0 @@
|
||||
/*-
|
||||
* ------+---------+---------+---------+---------+---------+---------+---------*
|
||||
* Initial version of parse8601 was originally added to newsyslog.c in
|
||||
* FreeBSD on Jan 22, 1999 by Garrett Wollman <wollman@FreeBSD.org>.
|
||||
* Initial version of parseDWM was originally added to newsyslog.c in
|
||||
* FreeBSD on Apr 4, 2000 by Hellmuth Michaelis <hm@FreeBSD.org>.
|
||||
*
|
||||
* Copyright (c) 2003 - Garance Alistair Drosehn <gad@FreeBSD.org>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation
|
||||
* are those of the authors and should not be interpreted as representing
|
||||
* official policies, either expressed or implied, of the FreeBSD Project.
|
||||
*
|
||||
* ------+---------+---------+---------+---------+---------+---------+---------*
|
||||
* This is intended to be a set of general-purpose routines to process times.
|
||||
* Right now it probably still has a number of assumptions in it, such that
|
||||
* it works fine for newsyslog but might not work for other uses.
|
||||
* ------+---------+---------+---------+---------+---------+---------+---------*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
#define SECS_PER_HOUR 3600
|
||||
|
||||
/*
|
||||
* Bit-values which indicate which components of time were specified
|
||||
* by the string given to parse8601 or parseDWM. These are needed to
|
||||
* calculate what time-in-the-future will match that string.
|
||||
*/
|
||||
#define TSPEC_YEAR 0x0001
|
||||
#define TSPEC_MONTHOFYEAR 0x0002
|
||||
#define TSPEC_LDAYOFMONTH 0x0004
|
||||
#define TSPEC_DAYOFMONTH 0x0008
|
||||
#define TSPEC_DAYOFWEEK 0x0010
|
||||
#define TSPEC_HOUROFDAY 0x0020
|
||||
|
||||
#define TNYET_ADJ4DST -10 /* DST has "not yet" been adjusted */
|
||||
|
||||
struct ptime_data {
|
||||
time_t basesecs; /* Base point for relative times */
|
||||
time_t tsecs; /* Time in seconds */
|
||||
struct tm basetm; /* Base Time expanded into fields */
|
||||
struct tm tm; /* Time expanded into fields */
|
||||
int did_adj4dst; /* Track calls to ptime_adjust4dst */
|
||||
int parseopts; /* Options given for parsing */
|
||||
int tmspec; /* Indicates which time fields had
|
||||
* been specified by the user */
|
||||
};
|
||||
|
||||
static int days_pmonth(int month, int year);
|
||||
static int parse8601(struct ptime_data *ptime, const char *str);
|
||||
static int parseDWM(struct ptime_data *ptime, const char *str);
|
||||
|
||||
/*
|
||||
* Simple routine to calculate the number of days in a given month.
|
||||
*/
|
||||
static int
|
||||
days_pmonth(int month, int year)
|
||||
{
|
||||
static const int mtab[] = {31, 28, 31, 30, 31, 30, 31, 31,
|
||||
30, 31, 30, 31};
|
||||
int ndays;
|
||||
|
||||
ndays = mtab[month];
|
||||
|
||||
if (month == 1) {
|
||||
/*
|
||||
* We are usually called with a 'tm-year' value
|
||||
* (ie, the value = the number of years past 1900).
|
||||
*/
|
||||
if (year < 1900)
|
||||
year += 1900;
|
||||
if (year % 4 == 0) {
|
||||
/*
|
||||
* This is a leap year, as long as it is not a
|
||||
* multiple of 100, or if it is a multiple of
|
||||
* both 100 and 400.
|
||||
*/
|
||||
if (year % 100 != 0)
|
||||
ndays++; /* not multiple of 100 */
|
||||
else if (year % 400 == 0)
|
||||
ndays++; /* is multiple of 100 and 400 */
|
||||
}
|
||||
}
|
||||
return (ndays);
|
||||
}
|
||||
|
||||
/*-
|
||||
* Parse a limited subset of ISO 8601. The specific format is as follows:
|
||||
*
|
||||
* [CC[YY[MM[DD]]]][THH[MM[SS]]] (where `T' is the literal letter)
|
||||
*
|
||||
* We don't accept a timezone specification; missing fields (including timezone)
|
||||
* are defaulted to the current date but time zero.
|
||||
*/
|
||||
static int
|
||||
parse8601(struct ptime_data *ptime, const char *s)
|
||||
{
|
||||
char *t;
|
||||
long l;
|
||||
struct tm tm;
|
||||
|
||||
l = strtol(s, &t, 10);
|
||||
if (l < 0 || l >= INT_MAX || (*t != '\0' && *t != 'T'))
|
||||
return (-1);
|
||||
|
||||
/*
|
||||
* Now t points either to the end of the string (if no time was
|
||||
* provided) or to the letter `T' which separates date and time in
|
||||
* ISO 8601. The pointer arithmetic is the same for either case.
|
||||
*/
|
||||
tm = ptime->tm;
|
||||
ptime->tmspec = TSPEC_HOUROFDAY;
|
||||
switch (t - s) {
|
||||
case 8:
|
||||
tm.tm_year = ((l / 1000000) - 19) * 100;
|
||||
l = l % 1000000;
|
||||
case 6:
|
||||
ptime->tmspec |= TSPEC_YEAR;
|
||||
tm.tm_year -= tm.tm_year % 100;
|
||||
tm.tm_year += l / 10000;
|
||||
l = l % 10000;
|
||||
case 4:
|
||||
ptime->tmspec |= TSPEC_MONTHOFYEAR;
|
||||
tm.tm_mon = (l / 100) - 1;
|
||||
l = l % 100;
|
||||
case 2:
|
||||
ptime->tmspec |= TSPEC_DAYOFMONTH;
|
||||
tm.tm_mday = l;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* sanity check */
|
||||
if (tm.tm_year < 70 || tm.tm_mon < 0 || tm.tm_mon > 12
|
||||
|| tm.tm_mday < 1 || tm.tm_mday > 31)
|
||||
return (-1);
|
||||
|
||||
if (*t != '\0') {
|
||||
s = ++t;
|
||||
l = strtol(s, &t, 10);
|
||||
if (l < 0 || l >= INT_MAX || (*t != '\0' && !isspace(*t)))
|
||||
return (-1);
|
||||
|
||||
switch (t - s) {
|
||||
case 6:
|
||||
tm.tm_sec = l % 100;
|
||||
l /= 100;
|
||||
case 4:
|
||||
tm.tm_min = l % 100;
|
||||
l /= 100;
|
||||
case 2:
|
||||
ptime->tmspec |= TSPEC_HOUROFDAY;
|
||||
tm.tm_hour = l;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* sanity check */
|
||||
if (tm.tm_sec < 0 || tm.tm_sec > 60 || tm.tm_min < 0
|
||||
|| tm.tm_min > 59 || tm.tm_hour < 0 || tm.tm_hour > 23)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
ptime->tm = tm;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*-
|
||||
* Parse a cyclic time specification, the format is as follows:
|
||||
*
|
||||
* [Dhh] or [Wd[Dhh]] or [Mdd[Dhh]]
|
||||
*
|
||||
* to rotate a logfile cyclic at
|
||||
*
|
||||
* - every day (D) within a specific hour (hh) (hh = 0...23)
|
||||
* - once a week (W) at a specific day (d) OR (d = 0..6, 0 = Sunday)
|
||||
* - once a month (M) at a specific day (d) (d = 1..31,l|L)
|
||||
*
|
||||
* We don't accept a timezone specification; missing fields
|
||||
* are defaulted to the current date but time zero.
|
||||
*/
|
||||
static int
|
||||
parseDWM(struct ptime_data *ptime, const char *s)
|
||||
{
|
||||
int daysmon, Dseen, WMseen;
|
||||
const char *endval;
|
||||
char *tmp;
|
||||
long l;
|
||||
struct tm tm;
|
||||
|
||||
/* Save away the number of days in this month */
|
||||
tm = ptime->tm;
|
||||
daysmon = days_pmonth(tm.tm_mon, tm.tm_year);
|
||||
|
||||
WMseen = Dseen = 0;
|
||||
ptime->tmspec = TSPEC_HOUROFDAY;
|
||||
for (;;) {
|
||||
endval = NULL;
|
||||
switch (*s) {
|
||||
case 'D':
|
||||
if (Dseen)
|
||||
return (-1);
|
||||
Dseen++;
|
||||
ptime->tmspec |= TSPEC_HOUROFDAY;
|
||||
s++;
|
||||
l = strtol(s, &tmp, 10);
|
||||
if (l < 0 || l > 23)
|
||||
return (-1);
|
||||
endval = tmp;
|
||||
tm.tm_hour = l;
|
||||
break;
|
||||
|
||||
case 'W':
|
||||
if (WMseen)
|
||||
return (-1);
|
||||
WMseen++;
|
||||
ptime->tmspec |= TSPEC_DAYOFWEEK;
|
||||
s++;
|
||||
l = strtol(s, &tmp, 10);
|
||||
if (l < 0 || l > 6)
|
||||
return (-1);
|
||||
endval = tmp;
|
||||
if (l != tm.tm_wday) {
|
||||
int save;
|
||||
|
||||
if (l < tm.tm_wday) {
|
||||
save = 6 - tm.tm_wday;
|
||||
save += (l + 1);
|
||||
} else {
|
||||
save = l - tm.tm_wday;
|
||||
}
|
||||
|
||||
tm.tm_mday += save;
|
||||
|
||||
if (tm.tm_mday > daysmon) {
|
||||
tm.tm_mon++;
|
||||
tm.tm_mday = tm.tm_mday - daysmon;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
if (WMseen)
|
||||
return (-1);
|
||||
WMseen++;
|
||||
ptime->tmspec |= TSPEC_DAYOFMONTH;
|
||||
s++;
|
||||
if (tolower(*s) == 'l') {
|
||||
/* User wants the last day of the month. */
|
||||
ptime->tmspec |= TSPEC_LDAYOFMONTH;
|
||||
tm.tm_mday = daysmon;
|
||||
endval = s + 1;
|
||||
} else {
|
||||
l = strtol(s, &tmp, 10);
|
||||
if (l < 1 || l > 31)
|
||||
return (-1);
|
||||
|
||||
if (l > daysmon)
|
||||
return (-1);
|
||||
endval = tmp;
|
||||
tm.tm_mday = l;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return (-1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (endval == NULL)
|
||||
return (-1);
|
||||
else if (*endval == '\0' || isspace(*endval))
|
||||
break;
|
||||
else
|
||||
s = endval;
|
||||
}
|
||||
|
||||
ptime->tm = tm;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize a new ptime-related data area.
|
||||
*/
|
||||
struct ptime_data *
|
||||
ptime_init(const struct ptime_data *optsrc)
|
||||
{
|
||||
struct ptime_data *newdata;
|
||||
|
||||
newdata = malloc(sizeof(struct ptime_data));
|
||||
if (optsrc != NULL) {
|
||||
memcpy(newdata, optsrc, sizeof(struct ptime_data));
|
||||
} else {
|
||||
memset(newdata, '\0', sizeof(struct ptime_data));
|
||||
newdata->did_adj4dst = TNYET_ADJ4DST;
|
||||
}
|
||||
|
||||
return (newdata);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adjust a given time if that time is in a different timezone than
|
||||
* some other time.
|
||||
*/
|
||||
int
|
||||
ptime_adjust4dst(struct ptime_data *ptime, const struct ptime_data *dstsrc)
|
||||
{
|
||||
struct ptime_data adjtime;
|
||||
|
||||
if (ptime == NULL)
|
||||
return (-1);
|
||||
|
||||
/*
|
||||
* Changes are not made to the given time until after all
|
||||
* of the calculations have been successful.
|
||||
*/
|
||||
adjtime = *ptime;
|
||||
|
||||
/* Check to see if this adjustment was already made */
|
||||
if ((adjtime.did_adj4dst != TNYET_ADJ4DST) &&
|
||||
(adjtime.did_adj4dst == dstsrc->tm.tm_isdst))
|
||||
return (0); /* yes, so don't make it twice */
|
||||
|
||||
/* See if daylight-saving has changed between the two times. */
|
||||
if (dstsrc->tm.tm_isdst != adjtime.tm.tm_isdst) {
|
||||
if (adjtime.tm.tm_isdst == 1)
|
||||
adjtime.tsecs -= SECS_PER_HOUR;
|
||||
else if (adjtime.tm.tm_isdst == 0)
|
||||
adjtime.tsecs += SECS_PER_HOUR;
|
||||
adjtime.tm = *(localtime(&adjtime.tsecs));
|
||||
/* Remember that this adjustment has been made */
|
||||
adjtime.did_adj4dst = dstsrc->tm.tm_isdst;
|
||||
/*
|
||||
* XXX - Should probably check to see if changing the
|
||||
* hour also changed the value of is_dst. What
|
||||
* should we do in that case?
|
||||
*/
|
||||
}
|
||||
|
||||
*ptime = adjtime;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ptime_relparse(struct ptime_data *ptime, int parseopts, time_t basetime,
|
||||
const char *str)
|
||||
{
|
||||
int dpm, pres;
|
||||
struct tm temp_tm;
|
||||
|
||||
ptime->parseopts = parseopts;
|
||||
ptime->basesecs = basetime;
|
||||
ptime->basetm = *(localtime(&ptime->basesecs));
|
||||
ptime->tm = ptime->basetm;
|
||||
ptime->tm.tm_hour = ptime->tm.tm_min = ptime->tm.tm_sec = 0;
|
||||
|
||||
/*
|
||||
* Call a routine which sets ptime.tm and ptime.tspecs based
|
||||
* on the given string and parsing-options. Note that the
|
||||
* routine should not call mktime to set ptime.tsecs.
|
||||
*/
|
||||
if (parseopts & PTM_PARSE_DWM)
|
||||
pres = parseDWM(ptime, str);
|
||||
else
|
||||
pres = parse8601(ptime, str);
|
||||
if (pres < 0) {
|
||||
ptime->tsecs = (time_t)pres;
|
||||
return (pres);
|
||||
}
|
||||
|
||||
/*
|
||||
* Before calling mktime, check to see if we ended up with a
|
||||
* "day-of-month" that does not exist in the selected month.
|
||||
* If we did call mktime with that info, then mktime will
|
||||
* make it look like the user specifically requested a day
|
||||
* in the following month (eg: Feb 31 turns into Mar 3rd).
|
||||
*/
|
||||
dpm = days_pmonth(ptime->tm.tm_mon, ptime->tm.tm_year);
|
||||
if ((parseopts & PTM_PARSE_MATCHDOM) &&
|
||||
(ptime->tmspec & TSPEC_DAYOFMONTH) &&
|
||||
(ptime->tm.tm_mday> dpm)) {
|
||||
/*
|
||||
* ptime_nxtime() will want a ptime->tsecs value,
|
||||
* but we need to avoid mktime resetting all the
|
||||
* ptime->tm values.
|
||||
*/
|
||||
if (verbose && dbg_at_times > 1)
|
||||
fprintf(stderr,
|
||||
"\t-- dom fixed: %4d/%02d/%02d %02d:%02d (%02d)",
|
||||
ptime->tm.tm_year, ptime->tm.tm_mon,
|
||||
ptime->tm.tm_mday, ptime->tm.tm_hour,
|
||||
ptime->tm.tm_min, dpm);
|
||||
temp_tm = ptime->tm;
|
||||
ptime->tsecs = mktime(&temp_tm);
|
||||
if (ptime->tsecs > (time_t)-1)
|
||||
ptimeset_nxtime(ptime);
|
||||
if (verbose && dbg_at_times > 1)
|
||||
fprintf(stderr,
|
||||
" to: %4d/%02d/%02d %02d:%02d\n",
|
||||
ptime->tm.tm_year, ptime->tm.tm_mon,
|
||||
ptime->tm.tm_mday, ptime->tm.tm_hour,
|
||||
ptime->tm.tm_min);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert the ptime.tm into standard time_t seconds. Check
|
||||
* for invalid times, which includes things like the hour lost
|
||||
* when switching from "standard time" to "daylight saving".
|
||||
*/
|
||||
ptime->tsecs = mktime(&ptime->tm);
|
||||
if (ptime->tsecs == (time_t)-1) {
|
||||
ptime->tsecs = (time_t)-2;
|
||||
return (-2);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ptime_free(struct ptime_data *ptime)
|
||||
{
|
||||
|
||||
if (ptime == NULL)
|
||||
return (-1);
|
||||
|
||||
free(ptime);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Some trivial routines so ptime_data can remain a completely
|
||||
* opaque type.
|
||||
*/
|
||||
const char *
|
||||
ptimeget_ctime(const struct ptime_data *ptime)
|
||||
{
|
||||
|
||||
if (ptime == NULL)
|
||||
return ("Null time in ptimeget_ctime()\n");
|
||||
|
||||
return (ctime(&ptime->tsecs));
|
||||
}
|
||||
|
||||
double
|
||||
ptimeget_diff(const struct ptime_data *minuend, const struct
|
||||
ptime_data *subtrahend)
|
||||
{
|
||||
|
||||
/* Just like difftime(), we have no good error-return */
|
||||
if (minuend == NULL || subtrahend == NULL)
|
||||
return (0.0);
|
||||
|
||||
return (difftime(minuend->tsecs, subtrahend->tsecs));
|
||||
}
|
||||
|
||||
time_t
|
||||
ptimeget_secs(const struct ptime_data *ptime)
|
||||
{
|
||||
|
||||
if (ptime == NULL)
|
||||
return (-1);
|
||||
|
||||
return (ptime->tsecs);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate an approximate timestamp for the next event, based on
|
||||
* what parts of time were specified by the original parameter to
|
||||
* ptime_relparse(). The result may be -1 if there is no obvious
|
||||
* "next time" which will work.
|
||||
*/
|
||||
int
|
||||
ptimeset_nxtime(struct ptime_data *ptime)
|
||||
{
|
||||
int moredays, tdpm, tmon, tyear;
|
||||
struct ptime_data nextmatch;
|
||||
|
||||
if (ptime == NULL)
|
||||
return (-1);
|
||||
|
||||
/*
|
||||
* Changes are not made to the given time until after all
|
||||
* of the calculations have been successful.
|
||||
*/
|
||||
nextmatch = *ptime;
|
||||
/*
|
||||
* If the user specified a year and we're already past that
|
||||
* time, then there will never be another one!
|
||||
*/
|
||||
if (ptime->tmspec & TSPEC_YEAR)
|
||||
return (-1);
|
||||
|
||||
/*
|
||||
* The caller gave us a time in the past. Calculate how much
|
||||
* time is needed to go from that valid rotate time to the
|
||||
* next valid rotate time. We only need to get to the nearest
|
||||
* hour, because newsyslog is only run once per hour.
|
||||
*/
|
||||
moredays = 0;
|
||||
if (ptime->tmspec & TSPEC_MONTHOFYEAR) {
|
||||
/* Special case: Feb 29th does not happen every year. */
|
||||
if (ptime->tm.tm_mon == 1 && ptime->tm.tm_mday == 29) {
|
||||
nextmatch.tm.tm_year += 4;
|
||||
if (days_pmonth(1, nextmatch.tm.tm_year) < 29)
|
||||
nextmatch.tm.tm_year += 4;
|
||||
} else {
|
||||
nextmatch.tm.tm_year += 1;
|
||||
}
|
||||
nextmatch.tm.tm_isdst = -1;
|
||||
nextmatch.tsecs = mktime(&nextmatch.tm);
|
||||
|
||||
} else if (ptime->tmspec & TSPEC_LDAYOFMONTH) {
|
||||
/*
|
||||
* Need to get to the last day of next month. Origtm is
|
||||
* already at the last day of this month, so just add to
|
||||
* it number of days in the next month.
|
||||
*/
|
||||
if (ptime->tm.tm_mon < 11)
|
||||
moredays = days_pmonth(ptime->tm.tm_mon + 1,
|
||||
ptime->tm.tm_year);
|
||||
else
|
||||
moredays = days_pmonth(0, ptime->tm.tm_year + 1);
|
||||
|
||||
} else if (ptime->tmspec & TSPEC_DAYOFMONTH) {
|
||||
/* Jump to the same day in the next month */
|
||||
moredays = days_pmonth(ptime->tm.tm_mon, ptime->tm.tm_year);
|
||||
/*
|
||||
* In some cases, the next month may not *have* the
|
||||
* desired day-of-the-month. If that happens, then
|
||||
* move to the next month that does have enough days.
|
||||
*/
|
||||
tmon = ptime->tm.tm_mon;
|
||||
tyear = ptime->tm.tm_year;
|
||||
for (;;) {
|
||||
if (tmon < 11)
|
||||
tmon += 1;
|
||||
else {
|
||||
tmon = 0;
|
||||
tyear += 1;
|
||||
}
|
||||
tdpm = days_pmonth(tmon, tyear);
|
||||
if (tdpm >= ptime->tm.tm_mday)
|
||||
break;
|
||||
moredays += tdpm;
|
||||
}
|
||||
|
||||
} else if (ptime->tmspec & TSPEC_DAYOFWEEK) {
|
||||
moredays = 7;
|
||||
} else if (ptime->tmspec & TSPEC_HOUROFDAY) {
|
||||
moredays = 1;
|
||||
}
|
||||
|
||||
if (moredays != 0) {
|
||||
nextmatch.tsecs += SECS_PER_HOUR * 24 * moredays;
|
||||
nextmatch.tm = *(localtime(&nextmatch.tsecs));
|
||||
}
|
||||
|
||||
/*
|
||||
* The new time will need to be adjusted if the setting of
|
||||
* daylight-saving has changed between the two times.
|
||||
*/
|
||||
ptime_adjust4dst(&nextmatch, ptime);
|
||||
|
||||
/* Everything worked. Update the given time and return. */
|
||||
*ptime = nextmatch;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ptimeset_time(struct ptime_data *ptime, time_t secs)
|
||||
{
|
||||
|
||||
if (ptime == NULL)
|
||||
return (-1);
|
||||
|
||||
ptime->tsecs = secs;
|
||||
ptime->tm = *(localtime(&ptime->tsecs));
|
||||
ptime->parseopts = 0;
|
||||
/* ptime->tmspec = ? */
|
||||
return (0);
|
||||
}
|
||||
@@ -59,6 +59,8 @@ struct {
|
||||
{ 460000, 460001, "/packages-4.6-release" },
|
||||
{ 460002, 460099, "/packages-4.6.2-release" },
|
||||
{ 470000, 470099, "/packages-4.7-release" },
|
||||
{ 480000, 480099, "/packages-4.8-release" },
|
||||
{ 490000, 490099, "/packages-4.9-release" },
|
||||
{ 300000, 399000, "/packages-3-stable" },
|
||||
{ 400000, 499000, "/packages-4-stable" },
|
||||
{ 510000, 599000, "/packages-5-stable" },
|
||||
|
||||
Reference in new issue
Block a user