Adam B. Roach ([EMAIL PROTECTED]):

> >> >  Right now, my NAPT SIP code [...] doesn't re-modify the topmost
> >> >  Via on responses. [...]
> >>
> > [...]
>
> I suppose I should clarify. We have our SIP stack as an isolated
> library, which the client is built upon. The stack itself performs
> this sanity check. It's a fast way to verify "is this message actually
> intended for me, or has some bozo server just started flinging
> messages in random directions?"

  Right, but my real question was, when will this check pay off?  What's
the pain in trying to parse the messages from the bozo server?  What if
you're the one at fault- the stack wasn't told about a name that
actually resolves to the right host, and some bozo UA you're talking to
changed the address on you?

  I'm just trying to convince you that it's not a good idea to check the
hostname.

> >  The real reason I'm not adding my own Via header (and also not
> >demasquerading the via header) is because if I don't, I can get away
> >without modifying incoming SIP messages from the Internet.
> >Otherwise, I have to find out if the request is a response, and if it
> >is, strip out the Via.
> 
> After thinking about it further, I'm becoming more convinced that
> you *should* be inserting your own Via header.

  AOL.

> If you just leave the IP address alone, but tweak the port, you'll
> need to tweak the port *back* on the response, or risk rejection by
> the next downstream host.

  Well, only to interoperate with you, but we'll assume that other
stacks perform the same sanity check for the sake of argument. :)

> While stripping the via will incur a very slight performance hit, you
> can minimize this by using vector writes (which should avoid
> unnecessary copying). I'd actually recommend against the use of
> regexes (use a tiny FSM instead), but it makes my example more consise
> and easy to understand.  Add bounds checking as necessary.  This is a
> fairly cheap way to do it; you end up scanning each character once, up
> to the end of the first Via header. Everything else is constant time.

  You write beautiful code.  However, your code also demonstrates
another reason why I wanted to avoid doing this.  Your code doesn't take
into account line folding, and will also kill the entire line of the
topmost via, even if it's a comma-separated list.

  You might ask, why would anyone modify the via I put in?  Wouldn't it
make alot of sense to just memcpy it directly?  I can think of a few
valid reasons for doing this, and lots of silly ones which I bet people
are doing anyways.

  Still, you're right, this is the clean thing to do, and it won't be
all that difficult anyways.

-- 
Billy Biggs, 3Com               Email: [EMAIL PROTECTED]
http://www.div8.net/billy/      Phone: [EMAIL PROTECTED]

Reply via email to