├── LICENSE ├── README.md ├── core ├── CoreLexer.go ├── CoreParser.go ├── Debug.go ├── Host.go ├── HostNameParser.go ├── HostNameParser_test.go ├── HostPort.go ├── Lexer.go ├── LogWriter.go ├── NameValue.go ├── NameValueList.go ├── ParameterNames.go ├── StringTokenizer.go └── Token.go ├── rtp ├── README.md ├── address.go ├── collisionlist.go ├── hostaddress.go ├── ipaddress.go ├── ntptime.go ├── random.go ├── rawpacket.go ├── rtcpapppacket.go ├── rtcpbyepacket.go ├── rtcppacket.go ├── rtp.go ├── rtppacket.go ├── rtptime.go ├── transmissioninfo.go └── transmissionparams.go ├── sdp └── README.md └── sip ├── ClientTransaction.go ├── Dialog.go ├── DialogState.go ├── ListeningPoint.go ├── README.md ├── RequestEvent.go ├── ResponseEvent.go ├── ServerTransaction.go ├── SipListener.go ├── SipProvider.go ├── SipStack.go ├── Timeout.go ├── TimeoutEvent.go ├── Transaction.go ├── TransactionState.go ├── address ├── Address.go ├── AddressFactory.go ├── AddressImpl.go ├── Authority.go ├── Hop.go ├── SipURI.go ├── SipURIImpl.go ├── TelURL.go ├── TelURLImpl.go ├── TelphoneNumber.go ├── URI.go ├── URIImpl.go └── UserInfo.go ├── header ├── AcceptEncodingHeader.go ├── AcceptEncodingImpl.go ├── AcceptEncodingList.go ├── AcceptHeader.go ├── AcceptImpl.go ├── AcceptLanguageHeader.go ├── AcceptLanguageImpl.go ├── AcceptLanguageList.go ├── AcceptList.go ├── AddressHeader.go ├── AddressParametersHeader.go ├── AddressParametersImpl.go ├── AlertInfoHeader.go ├── AlertInfoImpl.go ├── AlertInfoList.go ├── AllowEventsHeader.go ├── AllowEventsImpl.go ├── AllowEventsList.go ├── AllowHeader.go ├── AllowImpl.go ├── AllowList.go ├── AuthenticationHeader.go ├── AuthenticationImpl.go ├── AuthenticationInfoHeader.go ├── AuthenticationInfoImpl.go ├── AuthorizationHeader.go ├── AuthorizationImpl.go ├── CSeqHeader.go ├── CSeqImpl.go ├── CallIdHeader.go ├── CallIdImpl.go ├── CallIdentifier.go ├── CallInfoHeader.go ├── CallInfoImpl.go ├── CallInfoList.go ├── Challenge.go ├── ContactHeader.go ├── ContactImpl.go ├── ContactListImpl.go ├── ContentDispositionHeader.go ├── ContentDispositionImpl.go ├── ContentEncodingHeader.go ├── ContentEncodingImpl.go ├── ContentEncodingList.go ├── ContentLanguageHeader.go ├── ContentLanguageImpl.go ├── ContentLanguageList.go ├── ContentLengthHeader.go ├── ContentLengthImpl.go ├── ContentTypeHeader.go ├── ContentTypeImpl.go ├── DateHeader.go ├── DateImpl.go ├── Encoding.go ├── ErrorInfoHeader.go ├── ErrorInfoImpl.go ├── ErrorInfoList.go ├── EventHeader.go ├── EventImpl.go ├── ExpiresHeader.go ├── ExpiresImpl.go ├── ExtensionHeader.go ├── ExtensionImpl.go ├── ExtensionList.go ├── FromHeader.go ├── FromImpl.go ├── InReplyToHeader.go ├── InReplyToImpl.go ├── InReplyToList.go ├── MaxForwardsHeader.go ├── MaxForwardsImpl.go ├── MediaRange.go ├── MediaType.go ├── MimeVersionHeader.go ├── MimeVersionImpl.go ├── MinExpiresHeader.go ├── MinExpiresImpl.go ├── OptionTag.go ├── OrganizationHeader.go ├── OrganizationImpl.go ├── ParametersHeader.go ├── ParametersImpl.go ├── PriorityHeader.go ├── PriorityImpl.go ├── Protocol.go ├── ProxyAuthenticateHeader.go ├── ProxyAuthenticateImpl.go ├── ProxyAuthenticateList.go ├── ProxyAuthorizationHeader.go ├── ProxyAuthorizationImpl.go ├── ProxyRequireHeader.go ├── ProxyRequireImpl.go ├── ProxyRequireList.go ├── QValue.go ├── RAckHeader.go ├── RAckImpl.go ├── RSeqHeader.go ├── RSeqImpl.go ├── ReasonHeader.go ├── ReasonImpl.go ├── ReasonList.go ├── RecordRouteHeader.go ├── RecordRouteImpl.go ├── RecordRouteList.go ├── ReferToHeader.go ├── ReferToImpl.go ├── ReplyToHeader.go ├── ReplyToImpl.go ├── RequestLine.go ├── RequireHeader.go ├── RequireImpl.go ├── RequireList.go ├── RetryAfterHeader.go ├── RetryAfterImpl.go ├── RouteHeader.go ├── RouteImpl.go ├── RouteList.go ├── SIPHeaderHeader.go ├── SIPHeaderImpl.go ├── SIPHeaderList.go ├── ServerHeader.go ├── ServerImpl.go ├── StatusLine.go ├── SubjectHeader.go ├── SubjectImpl.go ├── SubscriptionStateHeader.go ├── SubscriptionStateImpl.go ├── SupportedHeader.go ├── SupportedImpl.go ├── SupportedList.go ├── TimeStampHeader.go ├── TimeStampImpl.go ├── ToHeader.go ├── ToImpl.go ├── UnsupportedHeader.go ├── UnsupportedImpl.go ├── UnsupportedList.go ├── UserAgentHeader.go ├── UserAgentImpl.go ├── ViaHeader.go ├── ViaImpl.go ├── ViaList.go ├── WWWAuthenticateHeader.go ├── WWWAuthenticateImpl.go ├── WWWAuthenticateList.go ├── WarningHeader.go ├── WarningImpl.go └── WarningList.go ├── message ├── Message.go ├── Request.go ├── Response.go ├── Router.go ├── SIPMessage.go ├── SIPRequest.go ├── SIPResponse.go └── Utils.go └── parser ├── AcceptEncodingParser.go ├── AcceptEncodingParser_test.go ├── AcceptLanguageParser.go ├── AcceptLanguageParser_test.go ├── AcceptParser.go ├── AcceptParser_test.go ├── AddressParametersParser.go ├── AddressParser.go ├── AddressParser_test.go ├── AlertInfoParser.go ├── AlertInfoParser_test.go ├── AllowEventsParser.go ├── AllowEventsParser_test.go ├── AllowParser.go ├── AllowParser_test.go ├── AuthenticationInfoParser.go ├── AuthenticationInfoParser_test.go ├── AuthorizationParser.go ├── AuthorizationParser_test.go ├── CSeqParser.go ├── CSeqParser_test.go ├── CallIdParser.go ├── CallIdParser_test.go ├── CallInfoParser.go ├── CallInfoParser_test.go ├── ChallengeParser.go ├── ContactParser.go ├── ContactParser_test.go ├── ContentDispositionParser.go ├── ContentDispositionParser_test.go ├── ContentEncodingParser.go ├── ContentEncodingParser_test.go ├── ContentLanguageParser.go ├── ContentLanguageParser_test.go ├── ContentLengthParser.go ├── ContentLengthParser_test.go ├── ContentTypeParser.go ├── ContentTypeParser_test.go ├── DateParser.go ├── DateParser_test.go ├── ErrorInfoParser.go ├── ErrorInfoParser_test.go ├── EventParser.go ├── EventParser_test.go ├── ExpiresParser.go ├── ExpiresParser_test.go ├── FromParser.go ├── FromParser_test.go ├── HeaderPareser_test.go ├── HeaderParser.go ├── InReplyToParser.go ├── InReplyToParser_test.go ├── MaxForwardsParser.go ├── MaxForwardsParser_test.go ├── MimeVersionParser.go ├── MimeVersionParser_test.go ├── MinExpiresParser.go ├── MinExpiresParser_test.go ├── OrganizationParser.go ├── OrganizationParser_test.go ├── ParametersParser.go ├── ParseExceptionListener.go ├── ParserFactory.go ├── PriorityParser.go ├── PriorityParser_test.go ├── ProxyAuthenticateParser.go ├── ProxyAuthenticateParser_test.go ├── ProxyAuthorizationParser.go ├── ProxyAuthorizationParser_test.go ├── ProxyRequireParser.go ├── ProxyRequireParser_test.go ├── RAckParser.go ├── RAckParser_test.go ├── RSeqParser.go ├── RSeqParser_test.go ├── ReasonParser.go ├── ReasonParser_test.go ├── RecordRouteParser.go ├── RecordRouteParser_test.go ├── ReferToParser.go ├── ReferToParser_test.go ├── ReplyToParser.go ├── ReplyToParser_test.go ├── RequestLineParser.go ├── RequestLineParser_test.go ├── RequireParser.go ├── RequireParser_test.go ├── RetryAfterParser.go ├── RetryAfterParser_test.go ├── RouteParser.go ├── RouteParser_test.go ├── SIPLexer.go ├── SIPParser.go ├── ServerParser.go ├── ServerParser_test.go ├── StatusLineParser.go ├── StatusLineParser_test.go ├── StringMsgParser.go ├── StringMsgParser_test.go ├── SubjectParser.go ├── SubjectParser_test.go ├── SubscriptionStateParser.go ├── SubscriptionStateParser_test.go ├── SupportedParser.go ├── SupportedParser_test.go ├── TimeStampParser.go ├── TimeStampParser_test.go ├── ToParser.go ├── ToParser_test.go ├── Torture1_test.go ├── Torture2_test.go ├── Torture3_test.go ├── Torture4_test.go ├── Torture5_test.go ├── URLParser.go ├── URLParser_test.go ├── UnsupportedParser.go ├── UnsupportedParser_test.go ├── UserAgentParser.go ├── UserAgentParser_test.go ├── ViaParser.go ├── ViaParser_test.go ├── WWWAuthenticateParser.go ├── WWWAuthenticateParser_test.go ├── WarningParser.go └── WarningParser_test.go /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Rain Liu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | GoSIPs 2 | ====== 3 | Go SIP Stack (http://www.GoSIPs.org) 4 | 5 | The objective of GoSIPs is to develop a Golang stack interface and implementation to the Session Initiation Protocol (SIP) that can be used independently or by higher level programming entities and environments. 6 | 7 | 8 | GoSIPs is still in heavy development stage. Currently, SIP Message Parser/Encoder is almost done, but it still need more polish and torture-test. 9 | 10 | -------------------------------------------------------------------------------- /core/Debug.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | /** 4 | * A class to do debug printfs 5 | */ 6 | 7 | type Debugger struct { 8 | Debug bool 9 | ParserDebug bool 10 | } 11 | 12 | var Debug = Debugger{true, false} 13 | 14 | func (this *Debugger) print(s string) { 15 | if this.Debug { 16 | LogWrite.LogMessage(s) 17 | } 18 | } 19 | 20 | func (this *Debugger) println(s string) { 21 | if this.Debug { 22 | LogWrite.LogMessage(s + "\n") 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/HostNameParser_test.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestHostNameParser(t *testing.T) { 8 | var hostNames = []string{"foo.bar.com:1234", 9 | "proxima.chaplin.bt.co.uk", 10 | "129.6.55.181:2345", 11 | ":2345", 12 | } 13 | 14 | for i := 0; i < len(hostNames); i++ { 15 | hnp := NewHostNameParser(hostNames[i]) 16 | if hnp == nil { 17 | t.Fail() 18 | } else { 19 | hp, err := hnp.GetHostPort() 20 | if err != nil { 21 | t.Fail() 22 | } else { 23 | t.Log(hp.String()) 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/Lexer.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | type LexerMap map[string]int 4 | 5 | type Lexer interface { 6 | //StringTokenizer 7 | Consume() 8 | ConsumeK(k int) 9 | HasMoreChars() bool 10 | IsAlpha(ch byte) bool 11 | IsDigit(ch byte) bool 12 | IsHexDigit(ch byte) bool 13 | LookAhead() (byte, error) 14 | LookAheadK(k int) (byte, error) 15 | PeekLine() string 16 | GetLine() string 17 | GetNextTokenByDelim(delim byte) (string, error) 18 | 19 | //Lexer 20 | SetLexerName(lexerName string) 21 | GetLexerName() string 22 | AddKeyword(name string, value int) 23 | AddLexer(lexerName string) LexerMap 24 | ByteStringNoComma() string 25 | ByteStringNoSemicolon() string 26 | CharAsString(ch byte) string 27 | NCharAsString(nchars int) string 28 | Comment() (s string, ParseException error) 29 | CurrentLexer() LexerMap 30 | GetBuffer() string 31 | GetNextId() string 32 | GetNextToken() *Token 33 | GetPtr() int 34 | GetRest() string 35 | GetString(c byte) (s string, ParseException error) 36 | LookupToken(value int) string 37 | MarkInputPosition() int 38 | Match(tok int) (t *Token, ParseException error) 39 | Number() (n int, ParseException error) 40 | PeekNextId() string 41 | PeekNextToken() (*Token, error) 42 | PeekNextTokenK(ntokens int) ([]*Token, error) 43 | QuotedString() (s string, ParseException error) 44 | RewindInputPosition(position int) 45 | SPorHT() 46 | SelectLexer(lexerName string) 47 | StartsId() bool 48 | Ttoken() string 49 | TtokenAllowSpace() string 50 | } 51 | -------------------------------------------------------------------------------- /core/Token.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "strconv" 5 | ) 6 | 7 | type Token struct { 8 | tokenValue string 9 | tokenType int 10 | } 11 | 12 | func NewToken(tvalue string, ttype int) *Token { 13 | return &Token{tokenValue: tvalue, tokenType: ttype} 14 | } 15 | 16 | func (this *Token) GetTokenValue() string { 17 | return this.tokenValue 18 | } 19 | func (this *Token) GetTokenType() int { 20 | return this.tokenType 21 | } 22 | func (this *Token) SetTokenValue(tvalue string) { 23 | this.tokenValue = tvalue 24 | } 25 | func (this *Token) SetTokenType(ttype int) { 26 | this.tokenType = ttype 27 | } 28 | 29 | func (this *Token) String() string { 30 | return "tokenValue = " + this.tokenValue + " / tokenType = " + strconv.Itoa(this.tokenType) 31 | } 32 | 33 | func (this *Token) Clone() interface{} { 34 | retval := &Token{} 35 | 36 | retval.tokenType = this.tokenType 37 | retval.tokenValue = this.tokenValue 38 | 39 | return retval 40 | } 41 | -------------------------------------------------------------------------------- /rtp/README.md: -------------------------------------------------------------------------------- 1 | RTP/RTCP Stack 2 | -------------------------------------------------------------------------------- /rtp/address.go: -------------------------------------------------------------------------------- 1 | package rtp 2 | 3 | /** Identifies the actual implementation being used. */ 4 | type AddressType uint8 5 | 6 | const ( 7 | IPv4AddressType AddressType = iota /**< Used by the UDP over IPv4 transmitter. */ 8 | IPv6AddressType /**< Used by the UDP over IPv6 transmitter. */ 9 | HostAddressType /**< A very general type of address, consisting of a port number and a number of bytes representing the host address. */ 10 | UserDefinedAddressType /**< Can be useful for a user-defined transmitter. */ 11 | ) 12 | 13 | /** This class is an abstract class which is used to specify destinations, multicast groups etc. */ 14 | type Address interface { 15 | /** Returns the type of address the actual implementation represents. */ 16 | GetAddressType() AddressType 17 | 18 | /** Creates a copy of the RTPAddress instance. 19 | * Creates a copy of the RTPAddress instance. If \c mgr is not NULL, the 20 | * corresponding memory manager will be used to allocate the memory for the address 21 | * copy. 22 | */ 23 | Clone() Address 24 | 25 | /** Checks if the address \c addr is the same address as the one this instance represents. 26 | * Checks if the address \c addr is the same address as the one this instance represents. 27 | * Implementations must be able to handle a NULL argument. 28 | */ 29 | IsSameAddress(addr Address) bool 30 | 31 | /** Checks if the address \c addr represents the same host as this instance. 32 | * Checks if the address \c addr represents the same host as this instance. Implementations 33 | * must be able to handle a NULL argument. 34 | */ 35 | IsFromSameHost(addr Address) bool 36 | 37 | String() string 38 | } 39 | -------------------------------------------------------------------------------- /rtp/hostaddress.go: -------------------------------------------------------------------------------- 1 | package rtp 2 | 3 | import "fmt" 4 | 5 | /** A very general kind of address consisting of a port number and a number of bytes describing the host address. */ 6 | type HostAddress struct { 7 | host string 8 | port uint16 9 | } 10 | 11 | /** Creates an instance of the class using \c addrlen bytes of \c hostaddress as host identification, 12 | * and using \c port as the port number. */ 13 | func NewHostAddress(host string, port uint16) *HostAddress { 14 | return &HostAddress{host: host, port: port} 15 | } 16 | 17 | /** Sets the host address to the first \c addrlen bytes of \c hostaddress. */ 18 | func (this *HostAddress) SetHost(host string) { 19 | this.host = host 20 | } 21 | 22 | /** Sets the port number to \c port. */ 23 | func (this *HostAddress) SetPort(port uint16) { 24 | this.port = port 25 | } 26 | 27 | /** Returns a pointer to the stored host address. */ 28 | func (this *HostAddress) GetHost() string { 29 | return this.host 30 | } 31 | 32 | /** Returns the port number stored in this instance. */ 33 | func (this *HostAddress) GetPort() uint16 { 34 | return this.port 35 | } 36 | 37 | ///////////////////////////////// 38 | func (this *HostAddress) GetAddressType() AddressType { 39 | return HostAddressType 40 | } 41 | 42 | func (this *HostAddress) IsSameAddress(addr Address) bool { 43 | if addr2, ok := addr.(*HostAddress); ok { 44 | if addr2.host == this.host && addr2.port == this.port { 45 | return true 46 | } 47 | } 48 | return false 49 | } 50 | 51 | func (this *HostAddress) IsFromSameHost(addr Address) bool { 52 | if addr2, ok := addr.(*HostAddress); ok { 53 | if addr2.host == this.host { 54 | return true 55 | } 56 | } 57 | return false 58 | } 59 | 60 | func (this *HostAddress) Clone() Address { 61 | return &HostAddress{host: this.host, port: this.port} 62 | } 63 | 64 | func (this *HostAddress) String() string { 65 | return fmt.Sprintf("%s:%d", this.host, this.port) 66 | } 67 | -------------------------------------------------------------------------------- /rtp/ntptime.go: -------------------------------------------------------------------------------- 1 | package rtp 2 | 3 | const NTPTIMEOFFSET = 2208988800 4 | 5 | /** 6 | * This is a simple wrapper for the most significant word (MSW) and least 7 | * significant word (LSW) of an NTP timestamp. 8 | */ 9 | type NTPTime struct { 10 | msw uint32 11 | lsw uint32 12 | } 13 | 14 | func NewNTPTime(m, l uint32) *NTPTime { 15 | this := &NTPTime{msw: m, lsw: l} 16 | return this 17 | } 18 | 19 | /** Returns the most significant word. */ 20 | func (this *NTPTime) GetMSW() uint32 { 21 | return this.msw 22 | } 23 | 24 | /** Returns the least significant word. */ 25 | func (this *NTPTime) GetLSW() uint32 { 26 | return this.lsw 27 | } 28 | -------------------------------------------------------------------------------- /sdp/README.md: -------------------------------------------------------------------------------- 1 | SDP Stack 2 | -------------------------------------------------------------------------------- /sip/README.md: -------------------------------------------------------------------------------- 1 | SIP Stack 2 | -------------------------------------------------------------------------------- /sip/address/Hop.go: -------------------------------------------------------------------------------- 1 | package address 2 | 3 | /** 4 | * The Hop interface defines a location a request can transit on the way to 5 | * its destination, i.e. a route. It defines the host, port and transport of 6 | * the location. This interface is used to identify locations in the 7 | * {@link Router} interface. 8 | * 9 | * @see Router 10 | * 11 | */ 12 | type Hop interface { 13 | /** 14 | * Returns the host part of this Hop. 15 | * 16 | * @return the string value of the host. 17 | */ 18 | GetHost() string 19 | 20 | /** 21 | * Returns the port part of this Hop. 22 | * 23 | * @return the integer value of the port. 24 | */ 25 | GetPort() int 26 | 27 | /** 28 | * Returns the transport part of this Hop. 29 | * 30 | * @return the string value of the transport. 31 | */ 32 | GetTransport() string 33 | 34 | /** 35 | * This method returns the Hop as a string. 36 | * 37 | * @return the stringified version of the Hop 38 | */ 39 | String() string 40 | } 41 | -------------------------------------------------------------------------------- /sip/address/URI.go: -------------------------------------------------------------------------------- 1 | package address 2 | 3 | import () 4 | 5 | /** 6 | * This class represents a generic URI. This is the base interface for any 7 | * type of URI. These are used in SIP requests to identify the callee and also 8 | * in Contact, From, and To headers. 9 | *
10 | * The generic syntax of URIs is defined in 11 | * RFC 2396. 12 | * 13 | * @see TelURL 14 | * @see SipURI 15 | */ 16 | 17 | type URI interface { // extends Cloneable, Serializable{ 18 | 19 | /** 20 | * Returns the value of the "scheme" of this URI, for example "sip", "sips" 21 | * or "tel". 22 | * 23 | * @return the scheme paramter of the URI 24 | */ 25 | GetScheme() string 26 | 27 | /** 28 | * Creates and returns a deep copy of the URI. This methods must ensure a 29 | * deep copy of the URI, so that when a URI is cloned the URI can be 30 | * modified without effecting the original URI. This provides useful 31 | * functionality for proxying Requests and Responses. This method overrides 32 | * the clone method in java.lang.Object. 33 | * 34 | * @return a deep copy of URI 35 | */ 36 | Clone() interface{} 37 | 38 | /** 39 | * This method determines if this is a URI with a scheme of "sip" or "sips". 40 | * 41 | * @return true if the scheme is "sip" or "sips", false otherwise. 42 | */ 43 | IsSipURI() bool 44 | 45 | /** 46 | * This method returns the URI as a string. 47 | * 48 | * @return String The stringified version of the URI 49 | */ 50 | String() string 51 | } 52 | -------------------------------------------------------------------------------- /sip/address/URIImpl.go: -------------------------------------------------------------------------------- 1 | package address 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | /** Implementation of the URI class. This relies on the 1.4 URI class. 8 | */ 9 | type URIImpl struct { 10 | uriString string 11 | 12 | scheme string 13 | } 14 | 15 | /** Constructor given the URI string 16 | * @param uriString The imbedded URI string. 17 | * @throws URISyntaxException When there is a syntaz error in the imbedded URI. 18 | */ 19 | func NewURIImpl(uriString string) *URIImpl { 20 | i := strings.Index(uriString, ":") 21 | if i > 0 { 22 | return &URIImpl{uriString: uriString, scheme: uriString[0:i]} 23 | } 24 | 25 | return nil 26 | } 27 | 28 | /** Encode the URI. 29 | * @return The encoded URI 30 | */ 31 | func (this *URIImpl) String() string { 32 | return this.uriString 33 | 34 | } 35 | 36 | /** Encode this URI. 37 | * @return The encoded URI 38 | */ 39 | /*func (this *URIImpl) ToString() string { 40 | return this.Encode(); 41 | 42 | }*/ 43 | 44 | /** Overrides the base clone method 45 | * @return The Cloned strucutre, 46 | */ 47 | func (this *URIImpl) Clone() interface{} { 48 | return NewURIImpl(this.uriString) 49 | } 50 | 51 | /** Returns the value of the "scheme" of 52 | * this URI, for example "sip", "sips" or "tel". 53 | * 54 | * @return the scheme paramter of the URI 55 | */ 56 | func (this *URIImpl) GetScheme() string { 57 | return this.scheme 58 | } 59 | 60 | /** This method determines if this is a URI with a scheme of 61 | * "sip" or "sips". 62 | * 63 | * @return true if the scheme is "sip" or "sips", false otherwise. 64 | */ 65 | func (this *URIImpl) IsSipURI() bool { 66 | var uri URI = this 67 | _, ok := uri.(SipURI) 68 | return ok 69 | } 70 | -------------------------------------------------------------------------------- /sip/header/AcceptEncodingHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | /** 4 | * This interface represents the Accept-Encoding request-header. 5 | * A client includes an AcceptEncodingHeader in a Request to tell the server 6 | * what coding schemes are acceptable in the Response e.g. compress, gzip. 7 | *
8 | * If an AcceptEncodingHeader is present, and if the server cannot send a 9 | * Response which is acceptable according to the AcceptEncodingHeader, then 10 | * the server should return a Response with a status code of NOT_ACCEPTABLE. 11 | *
12 | * An empty Accept-Encoding header field is permissible, it is equivalent to
13 | * Accept-Encoding: identity
, meaning no encoding is permissible.
14 | *
15 | * If no Accept-Encoding header field is present, the server SHOULD assume a 16 | * default value of identity. 17 | *
18 | * For Example:
19 | * Accept-Encoding: gzip
20 | *
21 | */
22 | type AcceptEncodingHeader interface {
23 | ParametersHeader
24 | Encoding
25 | QValue
26 | }
27 |
--------------------------------------------------------------------------------
/sip/header/AcceptEncodingList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | )
6 |
7 | /**
8 | * AcceptEncodingList of AccepEncoding headers.
9 | */
10 | type AcceptEncodingList struct {
11 | SIPHeaderList
12 | }
13 |
14 | /** default constructor
15 | */
16 | func NewAcceptEncodingList() *AcceptEncodingList {
17 | this := &AcceptEncodingList{}
18 | this.SIPHeaderList.super(core.SIPHeaderNames_ACCEPT_ENCODING)
19 | return this
20 | }
21 |
--------------------------------------------------------------------------------
/sip/header/AcceptLanguageHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 |
5 | * The Accept-Language header field is used in requests to indicate the
6 |
7 | * preferred languages for reason phrases, session descriptions, or
8 |
9 | * status responses carried as message bodies in the response. If no
10 |
11 | * Accept-Language header field is present, the server SHOULD assume all
12 |
13 | * languages are acceptable to the client. The q-value is used in a similar
14 |
15 | * manner to AcceptHeader to indicate degrees of preference.
16 |
17 | *
18 |
19 | * For Example:
20 |
21 | * Accept-Language: da, en-gb;q=0.8, en;q=0.7
22 |
23 | *
24 |
25 | * @see AcceptHeader
26 |
27 | */
28 |
29 | type AcceptLanguageHeader interface {
30 | ParametersHeader
31 | QValue
32 | /**
33 |
34 | * Gets the language value of the AcceptLanguageHeader.
35 |
36 | *
37 |
38 | * @return the language Locale value of this AcceptLanguageHeader
39 |
40 | */
41 |
42 | GetAcceptLanguage() string
43 |
44 | /**
45 |
46 | * Sets the language parameter of this AcceptLanguageHeader.
47 |
48 | *
49 |
50 | * @param language - the new Locale value of the language of
51 |
52 | * AcceptLanguageHeader
53 | */
54 |
55 | SetAcceptLanguage(language string)
56 | }
57 |
--------------------------------------------------------------------------------
/sip/header/AcceptLanguageList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | )
6 |
7 | /**
8 | * AcceptLanguageList: Strings together a list of AcceptLanguage SIPHeaders.
9 | */
10 | type AcceptLanguageList struct {
11 | SIPHeaderList
12 | }
13 |
14 | func NewAcceptLanguageList() *AcceptLanguageList {
15 | this := &AcceptLanguageList{}
16 | this.SIPHeaderList.super(core.SIPHeaderNames_ACCEPT_LANGUAGE)
17 | return this
18 | }
19 |
20 | func (this *AcceptLanguageList) GetFirst() Header {
21 | retval := this.SIPHeaderList.Front().Value.(Header)
22 | if retval != nil {
23 | return retval
24 | } else {
25 | return NewAcceptLanguage()
26 | }
27 | }
28 |
29 | func (this *AcceptLanguageList) GetLast() Header {
30 | retval := this.SIPHeaderList.Back().Value.(Header)
31 | if retval != nil {
32 | return retval
33 | } else {
34 | return NewAcceptLanguage()
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sip/header/AcceptList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | )
6 |
7 | /**
8 | * Accept List of SIP headers.
9 | *@see Accept
10 | */
11 | type AcceptList struct {
12 | SIPHeaderList
13 | }
14 |
15 | /** default constructor
16 | */
17 | func NewAcceptList() *AcceptList {
18 | this := &AcceptList{}
19 | this.SIPHeaderList.super(core.SIPHeaderNames_ACCEPT)
20 | return this
21 | }
22 |
--------------------------------------------------------------------------------
/sip/header/AddressHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/sip/address"
5 | )
6 |
7 | /**
8 | * This interface represents methods for manipulating Address object
9 | * values for any header that contains a Address value.
10 | *
11 | * When the header field value contains a display name encapsulated in the 12 | * Address, the URI including all URI parameters is enclosed in "<" and ">". 13 | * If no "<" and ">" are present, all parameters after the URI are header 14 | * parameters, not URI parameters. The display name can be tokens, or a 15 | * quoted string, if a larger character set is desired. 16 | * 17 | * @see Address 18 | * @see ContactHeader 19 | * @see FromHeader 20 | * @see RecordRouteHeader 21 | * @see ReplyToHeader 22 | * @see RouteHeader 23 | * @see ToHeader 24 | */ 25 | type AddressHeader interface { 26 | 27 | /** 28 | * Sets the Address parameter of this Address. 29 | * 30 | * @param address - the Address object that represents the new 31 | * address of this Address. 32 | */ 33 | SetAddress(addr address.Address) 34 | 35 | /** 36 | * Gets the address parameter of this Address. 37 | * 38 | * @return the Address of this Address 39 | */ 40 | GetAddress() address.Address 41 | } 42 | -------------------------------------------------------------------------------- /sip/header/AddressParametersHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | type AddressParametersHeader interface { 4 | ParametersHeader 5 | AddressHeader 6 | } 7 | -------------------------------------------------------------------------------- /sip/header/AddressParametersImpl.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | import ( 4 | "gosips/sip/address" 5 | ) 6 | 7 | /** An abstract class for headers that take an address and parameters. 8 | */ 9 | type AddressParameters struct { 10 | Parameters 11 | 12 | addr address.Address 13 | } 14 | 15 | /** Constructor given the name of the header. 16 | */ 17 | func NewAddressParameters(name string) *AddressParameters { 18 | this := &AddressParameters{} 19 | this.Parameters.super(name) 20 | return this 21 | } 22 | 23 | func (this *AddressParameters) super(name string) { 24 | this.Parameters.super(name) 25 | } 26 | 27 | /** get the Address field 28 | * @return the imbedded Address 29 | */ 30 | func (this *AddressParameters) GetAddress() address.Address { 31 | return this.addr 32 | } 33 | 34 | /** set the Address field 35 | * @param address Address to set 36 | */ 37 | func (this *AddressParameters) SetAddress(addr address.Address) { 38 | this.addr = addr 39 | } 40 | -------------------------------------------------------------------------------- /sip/header/AlertInfoHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | import ( 4 | "gosips/sip/address" 5 | ) 6 | 7 | /** 8 | * When present in an INVITE request, the Alert-Info header field 9 | * specifies an alternative ring tone to the UAS. When present in a 180 10 | * (Ringing) response, the Alert-Info header field specifies an 11 | * alternative ringback tone to the UAC. A typical usage is for a proxy 12 | * to insert this header field to provide a distinctive ring feature. 13 | *
14 | * The Alert-Info header field can introduce security risks, which are 15 | * identical to the Call-Info header field risk, see section 20.9 of 16 | * RFC3261. 17 | * In addition, a user SHOULD be able to disable this feature selectively. 18 | * This helps prevent disruptions that could result from the use of this 19 | * header field by untrusted elements. 20 | *
21 | * For Example:
22 | * Alert-Info:
23 | */
24 |
25 | type AlertInfoHeader interface {
26 | ParametersHeader
27 |
28 | /**
29 | * Sets the AlertInfo of the AlertInfoHeader to the alertInfo
30 | * parameter value.
31 | *
32 | * @param alertInfo the new Alert Info URI of this AlertInfoHeader.
33 | */
34 | SetAlertInfo(alertInfo address.URI)
35 |
36 | /**
37 | * Returns the AlertInfo value of this AlertInfoHeader.
38 | *
39 | * @return the URI representing the AlertInfo.
40 | */
41 | GetAlertInfo() address.URI
42 | }
43 |
--------------------------------------------------------------------------------
/sip/header/AlertInfoImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "bytes"
5 | "gosips/core"
6 | "gosips/sip/address"
7 | )
8 |
9 | /**
10 | * AlertInfo SIP Header.
11 | */
12 | type AlertInfo struct {
13 | Parameters
14 |
15 | /** URI field
16 | */
17 | uri *address.URIImpl
18 | }
19 |
20 | /** Constructor
21 | */
22 | func NewAlertInfo() *AlertInfo {
23 | this := &AlertInfo{}
24 | this.Parameters.super(core.SIPHeaderNames_ALERT_INFO)
25 | return this
26 | }
27 |
28 | func (this *AlertInfo) String() string {
29 | return this.headerName + core.SIPSeparatorNames_COLON +
30 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE
31 | }
32 |
33 | /**
34 | * Return value encoding in canonical form.
35 | * @return The value of the header in canonical encoding.
36 | */
37 | func (this *AlertInfo) EncodeBody() string {
38 | var encoding bytes.Buffer
39 | encoding.WriteString(core.SIPSeparatorNames_LESS_THAN)
40 | encoding.WriteString(this.uri.String())
41 | encoding.WriteString(core.SIPSeparatorNames_GREATER_THAN)
42 |
43 | if this.parameters != nil && this.parameters.Len() > 0 {
44 | encoding.WriteString(core.SIPSeparatorNames_SEMICOLON)
45 | encoding.WriteString(this.parameters.String())
46 | }
47 | return encoding.String()
48 |
49 | }
50 |
51 | /**
52 | * Set the uri member
53 | * @param u URI to set
54 | */
55 | func (this *AlertInfo) SetAlertInfo(uri address.URI) {
56 | this.uri = uri.(*address.URIImpl)
57 | }
58 |
59 | /**
60 | * Returns the AlertInfo value of this AlertInfoHeader.
61 | *
62 | *
63 | *
64 | * @return the URI representing the AlertInfo.
65 | *
66 | */
67 | func (this *AlertInfo) GetAlertInfo() address.URI {
68 | return this.uri
69 | }
70 |
--------------------------------------------------------------------------------
/sip/header/AlertInfoList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | )
6 |
7 | /**
8 | * AlertInfo Header - there can be several AlertInfo headers.
9 | */
10 | type AlertInfoList struct {
11 | SIPHeaderList
12 | }
13 |
14 | /** default constructor
15 | */
16 | func NewAlertInfoList() *AlertInfoList {
17 | this := &AlertInfoList{}
18 | this.SIPHeaderList.super(core.SIPHeaderNames_ALERT_INFO)
19 | return this
20 | }
21 |
--------------------------------------------------------------------------------
/sip/header/AllowEventsHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import ()
4 |
5 | /**
6 | * This interface represents the AllowEvents SIP header, as defined by
7 | * RFC3265, this header is
8 | * not part of RFC3261.
9 | *
10 | * The AllowEventsHeader includes a list of tokens which indicates the event 11 | * packages supported by the client (if sent in a request) or server (if sent 12 | * in a response). In other words, a node sending an AllowEventsHeader is 13 | * advertising that it can process SUBSCRIBE requests and generate NOTIFY 14 | * requests for all of the event packages listed in that header. 15 | *
16 | * Any node implementing one or more event packages SHOULD include an appropriate 17 | * AllowEventsHeader indicating all supported events in all methods which 18 | * initiate dialogs and their responses (such as INVITE) and OPTIONS responses. 19 | * This information is very useful, for example, in allowing user agents to 20 | * render particular interface elements appropriately according to whether the 21 | * events required to implement the features they represent are supported by 22 | * the appropriate nodes. 23 | *
24 | * Note that "Allow-Events" headers MUST NOT be inserted by proxies. 25 | */ 26 | 27 | type AllowEventsHeader interface { 28 | Header 29 | 30 | /** 31 | * Sets the eventType defined in this AllowEventsHeader. 32 | * 33 | * @param eventType - the String defining the method supported 34 | * in this AllowEventsHeader 35 | * @throws ParseException which signals that an error has been reached 36 | * unexpectedly while parsing the Strings defining the eventType supported 37 | */ 38 | SetEventType(eventType string) (ParseException error) 39 | 40 | /** 41 | * Gets the eventType of the AllowEventsHeader. 42 | * 43 | * @return the String object identifing the eventTypes of AllowEventsHeader. 44 | */ 45 | GetEventType() string 46 | } 47 | -------------------------------------------------------------------------------- /sip/header/AllowHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | /** 4 | * The Allow header field lists the set of methods supported by the User Agent 5 | * generating the message. All methods, including ACK and CANCEL, understood 6 | * by the User Agent MUST be included in the list of methods in the Allow header 7 | * field, when present. 8 | * The absence of an Allow header field MUST NOT be interpreted to mean that 9 | * the User Agent sending the message supports no methods. Rather, it implies 10 | * that the User Agent is not providing any information on what methods it 11 | * supports. Supplying an Allow header field in responses to methods other than 12 | * OPTIONS reduces the number of messages needed. 13 | *
14 | * For Example:
15 | * Allow: INVITE, ACK, OPTIONS, CANCEL, BYE
16 | */
17 | type AllowHeader interface {
18 | Header
19 |
20 | /**
21 | * Sets the method supported by this AllowHeader.
22 | *
23 | * @param method - the String defining the method supported
24 | * in this AllowHeader
25 | * @throws ParseException which signals that an error has been reached
26 | * unexpectedly while parsing the method supported.
27 | */
28 | SetMethod(method string) (ParseException error)
29 |
30 | /**
31 | * Gets the method of the AllowHeader. Returns null if no method is
32 | * defined in this Allow Header.
33 | *
34 | * @return the string identifing the method of AllowHeader.
35 | */
36 | GetMethod() string
37 | }
38 |
--------------------------------------------------------------------------------
/sip/header/AllowImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "errors"
5 | "gosips/core"
6 | )
7 |
8 | /**
9 | * Allow Header.
10 | */
11 | type Allow struct {
12 | SIPHeader
13 |
14 | /** method field
15 | */
16 | method string
17 | }
18 |
19 | /** default constructor
20 | */
21 | func NewAllow() *Allow {
22 | this := &Allow{}
23 | this.SIPHeader.super(core.SIPHeaderNames_ALLOW)
24 | return this
25 | }
26 |
27 | /** constructor
28 | * @param m String to set
29 | */
30 | func NewAllowFromString(m string) *Allow {
31 | this := &Allow{}
32 | this.SIPHeader.super(core.SIPHeaderNames_ALLOW)
33 | this.method = m
34 | return this
35 | }
36 |
37 | /** get the method field
38 | * @return String
39 | */
40 | func (this *Allow) GetMethod() string {
41 | return this.method
42 | }
43 |
44 | /**
45 | * Set the method member
46 | * @param method method to set.
47 | */
48 | func (this *Allow) SetMethod(method string) (ParseException error) {
49 | if method == "" {
50 | return errors.New("NullPointerException: the method parameter is null")
51 | }
52 | this.method = method
53 | return nil
54 | }
55 |
56 | func (this *Allow) String() string {
57 | return this.headerName + core.SIPSeparatorNames_COLON +
58 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE
59 | }
60 |
61 | /** Return body encoded in canonical form.
62 | * @return body encoded as a string.
63 | */
64 | func (this *Allow) EncodeBody() string {
65 | return this.method
66 | }
67 |
--------------------------------------------------------------------------------
/sip/header/AllowList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "container/list"
5 | "errors"
6 | "gosips/core"
7 | )
8 |
9 | /**
10 | * List of ALLOW headers. The sip message can have multiple Allow headers
11 | *
12 | */
13 | type AllowList struct {
14 | SIPHeaderList
15 | }
16 |
17 | /** default constructor
18 | */
19 | func NewAllowList() *AllowList {
20 | this := &AllowList{}
21 | this.SIPHeaderList.super(core.SIPHeaderNames_ALLOW)
22 | return this
23 | }
24 |
25 | /**
26 | * Gets an Iterator of all the methods of the AllowHeader. Returns an empty
27 | *
28 | * Iterator if no methods are defined in this Allow Header.
29 | *
30 | *
31 | *
32 | * @return Iterator of String objects each identifing the methods of
33 | *
34 | * AllowHeader.
35 | *
36 | */
37 |
38 | func (this *AllowList) GetMethods() *list.List {
39 | ll := list.New()
40 | for e := this.Front(); e != nil; e = e.Next() {
41 | ll.PushBack(e.Value.(*Allow).GetMethod())
42 | }
43 | return ll
44 | }
45 |
46 | /**
47 | * Sets the methods supported defined by this AllowHeader.
48 | *
49 | *
50 | *
51 | * @param methods - the Iterator of Strings defining the methods supported
52 | *
53 | * in this AllowHeader
54 | *
55 | * @throws ParseException which signals that an error has been reached
56 | *
57 | * unexpectedly while parsing the Strings defining the methods supported.
58 | *
59 | */
60 |
61 | func (this *AllowList) SetMethods(methods *list.List) (ParseException error) {
62 |
63 | for e := methods.Front(); e != nil; e = e.Next() {
64 | allow := NewAllow()
65 | if str, ok := e.Value.(string); ok {
66 | if ParseException = allow.SetMethod(str); ParseException != nil {
67 | return ParseException
68 | }
69 | } else {
70 | return errors.New("ParseException: the method parameter is not string")
71 | }
72 |
73 | this.PushBack(allow)
74 | }
75 | return nil
76 | }
77 |
--------------------------------------------------------------------------------
/sip/header/AuthorizationHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 | * The Authorization header is used when a user agent wishes to authenticate
5 | * itself with a server - usually, but not necessarily, after receiving an
6 | * UNAUTHORIZED Response - by including an AuthorizationHeader with the
7 | * Request. The AuthorizationHeader consists of credentials
8 | * containing the authentication information of the user agent for the
9 | * realm of the resource being requested.
10 | *
11 | * This header field, along with Proxy-Authorization, breaks the general 12 | * rules about multiple header field values. Although not a comma- 13 | * separated list, this header field name may be present multiple times, 14 | * and MUST NOT be combined into a single header line. 15 | *
16 | * For Example:
17 | * Authorization: Digest username="Alice", realm="atlanta.com",
20 | *
21 | * @see Parameters
22 | * @see WWWAuthenticateHeader
23 | * @see ProxyAuthorizationHeader
24 | *
25 | */
26 |
27 | type AuthorizationHeader interface {
28 | AuthenticationHeader
29 | }
30 |
--------------------------------------------------------------------------------
/sip/header/AuthorizationImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "gosips/core"
4 |
5 | /**
6 | * Authorization SIP header.
7 | *
8 | * @see ProxyAuthorization
9 | */
10 | type Authorization struct {
11 | Authentication
12 | }
13 |
14 | /** Default constructor.
15 | */
16 | func NewAuthorization() *Authorization {
17 | this := &Authorization{}
18 | this.Authentication.super(core.SIPHeaderNames_AUTHORIZATION)
19 | return this
20 | }
21 |
--------------------------------------------------------------------------------
/sip/header/CallInfoList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | )
6 |
7 | /**
8 | * A list of CallInfo headers (there can be multiple in a message).
9 | */
10 | type CallInfoList struct {
11 | SIPHeaderList
12 | }
13 |
14 | /** Default constructor
15 | */
16 | func NewCallInfoList() *CallInfoList {
17 | this := &CallInfoList{}
18 | this.SIPHeaderList.super(core.SIPHeaderNames_CALL_INFO)
19 | return this
20 | }
21 |
--------------------------------------------------------------------------------
/sip/header/ContactListImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | )
6 |
7 | /**
8 | * List of contact headers.ContactLists are also maintained in a hashtable for quick lookup.
9 | */
10 | type ContactList struct {
11 | SIPHeaderList
12 | }
13 |
14 | /**
15 | * Constructor.
16 | */
17 | func NewContactList() *ContactList {
18 | this := &ContactList{}
19 | this.SIPHeaderList.super(core.SIPHeaderNames_CONTACT)
20 | return this
21 | }
22 |
23 | func (this *ContactList) super(hname string) {
24 | this.SIPHeaderList.super(hname)
25 | }
26 |
27 | /**
28 | * add a new contact header. Store it in the hashtable also
29 | * @param contact -- contact to add to this list.
30 | * @throws IllegalArgumentException if Duplicate Contact for same addr
31 | */
32 | func (this *ContactList) AddContact(contact ContactHeader) (IllegalArgumentException error) {
33 | // Concatenate my lists.
34 | this.SIPHeaderList.PushBack(contact)
35 | return nil
36 | }
37 |
38 | /**
39 | * make a clone of this contact list.
40 | * @return Object cloned list.
41 | */
42 | func (this *ContactList) Clone() interface{} {
43 | retval := NewContactList()
44 | for c := this.Front(); c != nil; c = c.Next() {
45 | newc := c.Value.(ContactHeader).Clone().(*Contact)
46 | retval.PushBack(newc)
47 | }
48 | return retval
49 | }
50 |
51 | /**
52 | * Get an array of contact addresses.
53 | *
54 | * @return array of contacts.
55 | *
56 | */
57 | func (this *ContactList) GetContacts() []ContactHeader {
58 | retval := make([]ContactHeader, this.Len())
59 |
60 | i := 0
61 | for e := this.Front(); e != nil; e = e.Next() {
62 | nextContact := e.Value.(ContactHeader)
63 | retval[i] = nextContact
64 | i++
65 | }
66 | return retval
67 | }
68 |
--------------------------------------------------------------------------------
/sip/header/ContentEncodingHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 | * A ContentEncodingHeader is used as a modifier to the "media-type". When
5 | * present, its value indicates what additional content codings have been
6 | * applied to the entity-body, and thus what decoding mechanisms must be
7 | * applied in order to obtain the media-type referenced by the
8 | * ContentTypeHeader. The ContentEncodingHeader is primarily used to allow a
9 | * body to be compressed without losing the identity of its underlying media
10 | * type.
11 | *
18 | * nonce="84a4cc6f3082121f32b42a2187831a9e",
19 | * response="7587245234b3434cc3412213e5f113a5432"
12 | * If multiple encodings have been applied to an entity, the ContentEncodings 13 | * must be listed in the order in which they were applied. All content-coding 14 | * values are case-insensitive. Clients MAY apply content encodings to the body 15 | * in requests. A server MAY 16 | * apply content encodings to the bodies in responses. The server MUST only 17 | * use encodings listed in the Accept-Encoding header field in the request. 18 | * If the server is not capable of decoding the body, or does not recognize any 19 | * of the content-coding values, it must send a UNSUPPORTED_MEDIA_TYPE 20 | * Response, listing acceptable encodings in an AcceptEncodingHeader. 21 | * 22 | * @see ContentDispositionHeader 23 | * @see ContentLengthHeader 24 | * @see ContentTypeHeader 25 | * @see ContentLanguageHeader 26 | */ 27 | 28 | type ContentEncodingHeader interface { 29 | Header 30 | Encoding 31 | } 32 | -------------------------------------------------------------------------------- /sip/header/ContentEncodingList.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | import ( 4 | "gosips/core" 5 | ) 6 | 7 | /** 8 | * Content Encoding SIP header List. Keeps a list of ContentEncoding headers 9 | */ 10 | type ContentEncodingList struct { 11 | SIPHeaderList 12 | } 13 | 14 | /** Default constructor. 15 | */ 16 | func NewContentEncodingList() *ContentEncodingList { 17 | this := &ContentEncodingList{} 18 | this.SIPHeaderList.super(core.SIPHeaderNames_CONTENT_ENCODING) 19 | return this 20 | } 21 | -------------------------------------------------------------------------------- /sip/header/ContentLanguageHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | /** 4 | * The Content-Language header field is used to indicate the language of the 5 | * message body. 6 | *
7 | * For Example:
8 | * Content-Language: fr
9 | *
10 | * @see ContentDispositionHeader
11 | * @see ContentLengthHeader
12 | * @see ContentEncodingHeader
13 | * @see ContentTypeHeader
14 | *
15 | */
16 | type ContentLanguageHeader interface {
17 | Header
18 |
19 | /**
20 | * Gets the language value of the ContentLanguageHeader.
21 | *
22 | * @return the Locale value of this ContentLanguageHeader
23 | */
24 | GetContentLanguage() string
25 |
26 | /**
27 | * Sets the language parameter of this ContentLanguageHeader.
28 | *
29 | * @param language - the new Locale value of the language of
30 | * ContentLanguageHeader
31 | */
32 | SetContentLanguage(language string)
33 | }
34 |
--------------------------------------------------------------------------------
/sip/header/ContentLanguageList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | )
6 |
7 | /**
8 | * ContentLanguage list of headers. (Should this be a list?)
9 | */
10 | type ContentLanguageList struct {
11 | SIPHeaderList
12 | }
13 |
14 | /** Default constructor
15 | */
16 | func NewContentLanguageList() *ContentLanguageList {
17 | this := &ContentLanguageList{}
18 | this.SIPHeaderList.super(core.SIPHeaderNames_CONTENT_LANGUAGE)
19 | return this
20 | }
21 |
--------------------------------------------------------------------------------
/sip/header/ContentLengthHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 |
5 | * The Content-Length header field indicates the size of the message-body, in
6 |
7 | * decimal number of octets, sent to the recipient. Applications SHOULD use
8 |
9 | * this field to indicate the size of the message-body to be transferred,
10 |
11 | * regardless of the media type of the entity. If a stream-based protocol
12 |
13 | * (such as TCP) is used as transport, the header field MUST be used.
14 |
15 | *
16 | 17 | * The size of the message-body does not include the CRLF separating header 18 | 19 | * fields and body. Any Content-Length greater than or equal to zero is a 20 | 21 | * valid value. If no body is present in a message, then the Content-Length 22 | 23 | * header field value MUST be set to zero. 24 | 25 | * 26 | 27 | * @see ContentDispositionHeader 28 | 29 | * @see ContentTypeHeader 30 | 31 | * @see ContentEncodingHeader 32 | 33 | * @see ContentLanguageHeader 34 | 35 | */ 36 | 37 | type ContentLengthHeader interface { 38 | Header 39 | 40 | /** 41 | 42 | * Set content-length of ContentLengthHeader. The content-length must be 43 | 44 | * greater than or equal to zero. 45 | 46 | * 47 | 48 | * @param contentLength the content-length of the message body 49 | 50 | * as a decimal number of octets. 51 | 52 | * @throws InvalidArgumentException if contentLength is less than zero. 53 | 54 | */ 55 | 56 | SetContentLength(contentLength int) (InvalidArgumentException error) 57 | 58 | /** 59 | 60 | * Gets content-length of the message body. 61 | 62 | * 63 | 64 | * @return content-length of the message body as a decimal number of octets. 65 | 66 | */ 67 | 68 | GetContentLength() int 69 | } 70 | -------------------------------------------------------------------------------- /sip/header/ContentTypeHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | /** 4 | * The Content-Type header field indicates the media type of the message-body 5 | * sent to the recipient. The Content-Type header field MUST be present if the 6 | * body is not empty. If the body is empty, and a Content-Type header field is 7 | * present, it indicates that the body of the specific type has zero length 8 | * (for example, an empty audio file). 9 | *
10 | * For Example:
11 | * Content-Type: application/sdp
12 | *
13 | * @see ContentDispositionHeader
14 | * @see ContentLengthHeader
15 | * @see ContentEncodingHeader
16 | * @see ContentLanguageHeader
17 | */
18 |
19 | type ContentTypeHeader interface {
20 | ParametersHeader
21 | MediaType
22 | }
23 |
--------------------------------------------------------------------------------
/sip/header/DateHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "time"
4 |
5 | /**
6 | * The Date header field reflects the time when the request or response is
7 | * first sent. Retransmissions have the same Date header field value as the
8 | * original. The Date header field contains the date and time. Unlike
9 | * HTTP/1.1, SIP only supports the most recent
10 | * RFC 1123 format for dates.
11 | * SIP restricts the time zone in SIP-date to "GMT", while RFC 1123 allows any
12 | * time zone.
13 | *
14 | * The Date header field can be used by simple end systems without a 15 | * battery-backed clock to acquire a notion of current time. However, in its 16 | * GMT form, it requires clients to know their offset from GMT. 17 | *
18 | * Example:
19 | * Date: Sat, 13 Nov 2010 23:29:00 GMT
20 | */
21 |
22 | type DateHeader interface {
23 | Header
24 |
25 | /**
26 |
27 | * Sets date of DateHeader. The date is repesented by the Calendar object.
28 |
29 | *
30 |
31 | * @param date the Calendar object date of this header.
32 |
33 | */
34 |
35 | SetDate(date *time.Time)
36 |
37 | /**
38 |
39 | * Gets the date of DateHeader. The date is repesented by the Calender
40 |
41 | * object.
42 |
43 | *
44 |
45 | * @return the Calendar object representing the date of DateHeader
46 |
47 | */
48 |
49 | GetDate() *time.Time
50 | }
51 |
--------------------------------------------------------------------------------
/sip/header/DateImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | "time"
6 | )
7 |
8 | /**
9 | * Date Header.
10 | */
11 | type Date struct {
12 | SIPHeader
13 |
14 | /** date field
15 | */
16 | date *time.Time
17 | }
18 |
19 | /** Default constructor.
20 | */
21 | func NewDate() *Date {
22 | this := &Date{}
23 | this.SIPHeader.super(core.SIPHeaderNames_DATE)
24 | return this
25 | }
26 |
27 | func (this *Date) String() string {
28 | return this.headerName + core.SIPSeparatorNames_COLON +
29 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE
30 | }
31 |
32 | /** Encode the header into a String.
33 | * @return String
34 | */
35 | func (this *Date) EncodeBody() string {
36 | return this.date.Format(time.RFC1123)
37 | }
38 |
39 | /**
40 | * Set the date member
41 | * @param d SIPDate to set
42 | */
43 | func (this *Date) SetDate(d *time.Time) {
44 | this.date = d
45 | }
46 |
47 | /**
48 | * Gets the date of DateHeader. The date is repesented by the Calender
49 | * object.
50 | *
51 | * @return the Calendar object representing the date of DateHeader
52 | */
53 | func (this *Date) GetDate() *time.Time {
54 | return this.date
55 | }
56 |
--------------------------------------------------------------------------------
/sip/header/Encoding.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import ()
4 |
5 | /**
6 | * This interface represents encoding methods for any header that contains an
7 | * encoding value.
8 | *
9 | * @see AcceptEncodingHeader
10 | * @see ContentEncodingHeader
11 | */
12 | type Encoding interface {
13 |
14 | /**
15 | * Sets the encoding of an EncodingHeader.
16 | *
17 | * @param encoding - the new string value defining the encoding.
18 | * @throws ParseException which signals that an error has been reached
19 | * unexpectedly while parsing the encoding value.
20 | */
21 |
22 | SetEncoding(encoding string) (ParseException error)
23 |
24 | /**
25 | * Gets the encoding of an EncodingHeader. Returns null if no
26 | * encoding is defined in an EncodingHeader.
27 | *
28 | * @return the string value identifing the encoding
29 | */
30 | GetEncoding() string
31 | }
32 |
--------------------------------------------------------------------------------
/sip/header/ErrorInfoList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | )
6 |
7 | /**
8 | * Error Info sip header.
9 | *@see ErrorInfoList
10 | *
11 | * 12 | * 6.24 Error-Info 13 | * 14 | * The Error-Info response header provides a pointer to additional 15 | * information about the error status response. This header field is 16 | * only contained in 3xx, 4xx, 5xx and 6xx responses. 17 | * 18 | * 19 | * 20 | * Error-Info = "Error-Info" ":" # ( "<" URI ">" *( ";" generic-param )) 21 | *22 | * 23 | */ 24 | type ErrorInfoList struct { 25 | SIPHeaderList 26 | } 27 | 28 | /** Default constructor. 29 | */ 30 | func NewErrorInfoList() *ErrorInfoList { 31 | this := &ErrorInfoList{} 32 | this.SIPHeaderList.super(core.SIPHeaderNames_ERROR_INFO) 33 | return this 34 | } 35 | -------------------------------------------------------------------------------- /sip/header/ExpiresImpl.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | import ( 4 | "errors" 5 | "gosips/core" 6 | "strconv" 7 | ) 8 | 9 | /** 10 | * Expires SIP Header. 11 | */ 12 | type Expires struct { 13 | SIPHeader 14 | 15 | /** expires field 16 | */ 17 | expires int 18 | } 19 | 20 | /** default constructor 21 | */ 22 | func NewExpires() *Expires { 23 | this := &Expires{} 24 | this.SIPHeader.super(core.SIPHeaderNames_EXPIRES) 25 | return this 26 | } 27 | 28 | func (this *Expires) String() string { 29 | return this.headerName + core.SIPSeparatorNames_COLON + 30 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE 31 | } 32 | 33 | /** 34 | * Return canonical form. 35 | * @return String 36 | */ 37 | func (this *Expires) EncodeBody() string { 38 | return strconv.Itoa(this.expires) 39 | } 40 | 41 | /** 42 | * Gets the expires value of the ExpiresHeader. This expires value is 43 | * 44 | * relative time. 45 | * 46 | * 47 | * 48 | * @return the expires value of the ExpiresHeader. 49 | * 50 | */ 51 | func (this *Expires) GetExpires() int { 52 | return this.expires 53 | } 54 | 55 | /** 56 | * Sets the relative expires value of the ExpiresHeader. 57 | * The expires value MUST be greater than zero and MUST be 58 | * less than 2**31. 59 | * 60 | * @param expires - the new expires value of this ExpiresHeader 61 | * 62 | * @throws InvalidArgumentException if supplied value is less than zero. 63 | * 64 | */ 65 | func (this *Expires) SetExpires(expires int) (InvalidArgumentException error) { 66 | if expires < 0 { 67 | return errors.New("InvalidArgumentException: bad argument") 68 | } 69 | this.expires = expires 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /sip/header/ExtensionHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | /** 4 | * This interface represents an Extension SIP header that is not currently 5 | * defined by JAIN SIP. Extension Headers can be added as required by extending 6 | * this interface assuming other endpoints understand the Header. Any Header that 7 | * extends this class must define a "NAME" String constant identifying the name 8 | * of the extension Header. A server must ignore Headers that it does not 9 | * understand. A proxy must not remove or modify Headers that it does not 10 | * understand. 11 | */ 12 | 13 | type ExtensionHeader interface { 14 | Header 15 | 16 | /** 17 | * Sets the value parameter of the ExtensionHeader. 18 | * 19 | * @param value - the new value of the ExtensionHeader 20 | * @throws ParseException which signals that an error has been reached 21 | * unexpectedly while parsing the value parameter. 22 | */ 23 | SetValue(value string) (ParseException error) 24 | 25 | /** 26 | * Gets the value of the ExtensionHeader. 27 | * 28 | * @return the string of the value parameter. 29 | */ 30 | //GetValue() string //redefine in Header 31 | } 32 | -------------------------------------------------------------------------------- /sip/header/ExtensionList.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | import "bytes" 4 | 5 | type ExtensionHeaderLister interface { 6 | SIPHeaderLister 7 | } 8 | 9 | /** 10 | * A generic extension header list. 11 | */ 12 | 13 | type ExtensionHeaderList struct { 14 | SIPHeaderList 15 | } 16 | 17 | func NewExtensionHeaderList(hName string) *ExtensionHeaderList { 18 | this := &ExtensionHeaderList{} 19 | this.SIPHeaderList.super(hName) 20 | return this 21 | } 22 | 23 | func (this *ExtensionHeaderList) String() string { 24 | var encoding bytes.Buffer 25 | for e := this.Front(); e != nil; e = e.Next() { 26 | eh := e.Value.(*Extension) 27 | encoding.WriteString(eh.String()) 28 | } 29 | return encoding.String() 30 | } 31 | -------------------------------------------------------------------------------- /sip/header/InReplyToHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | /** 4 | * The In-Reply-To header field enumerates the Call-IDs that this call 5 | * references or returns. These Call-IDs may have been cached by the client 6 | * then included in this header field in a return call. 7 | *
8 | * This allows automatic call distribution systems to route return calls to the 9 | * originator of the first call. This also allows callees to filter calls, so 10 | * that only return calls for calls they originated will be accepted. This 11 | * field is not a substitute for request authentication. 12 | *
13 | * For Example:
14 | * In-Reply-To: 70710@saturn.jcp.org, 17320@saturn.jcp.org
15 | */
16 | type InReplyToHeader interface {
17 | Header
18 |
19 | /**
20 | * Sets the Call-Id of the InReplyToHeader. The CallId parameter uniquely
21 | * identifies a serious of messages within a dialogue.
22 | *
23 | * @param callId - the string value of the Call-Id of this InReplyToHeader.
24 | * @throws ParseException which signals that an error has been reached
25 | * unexpectedly while parsing the callId value.
26 | */
27 | SetCallId(callId string) (ParseException error)
28 |
29 | /**
30 | * Returns the Call-Id of InReplyToHeader. The CallId parameter uniquely
31 | * identifies a series of messages within a dialogue.
32 | *
33 | * @return the String value of the Call-Id of this InReplyToHeader
34 | */
35 | GetCallId() string
36 | }
37 |
--------------------------------------------------------------------------------
/sip/header/InReplyToList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | )
6 |
7 | /**
8 | * In-Reply-To SIP header. Keeps a list of CallIdentifiers
9 | */
10 | type InReplyToList struct {
11 | SIPHeaderList
12 | }
13 |
14 | /** Default constructor
15 | */
16 | func NewInReplyToList() *InReplyToList {
17 | this := &InReplyToList{}
18 | this.SIPHeaderList.super(core.SIPHeaderNames_IN_REPLY_TO)
19 | return this
20 | }
21 |
--------------------------------------------------------------------------------
/sip/header/MediaRange.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | )
6 |
7 | /**
8 | * Media Range
9 | * @see Accept
10 | *
11 | * media-range = ( "STAR/STAR" 12 | * | ( type "/" STAR ) 13 | * | ( type "/" subtype ) 14 | * ) *( ";" parameter ) 15 | * 16 | * HTTP RFC 2616 Section 14.1 17 | *18 | */ 19 | type MediaRange struct { 20 | /** type field 21 | */ 22 | mtype string 23 | 24 | /** subtype field 25 | */ 26 | subtype string 27 | } 28 | 29 | /** Default constructor 30 | */ 31 | func NewMediaRange() *MediaRange { 32 | this := &MediaRange{} 33 | return this 34 | } 35 | 36 | /** get type field 37 | * @return String 38 | */ 39 | func (this *MediaRange) GetType() string { 40 | return this.mtype 41 | } 42 | 43 | /** get the subType field. 44 | * @return String 45 | */ 46 | func (this *MediaRange) GetSubtype() string { 47 | return this.subtype 48 | } 49 | 50 | /** 51 | * Set the type member 52 | * @param t String to set 53 | */ 54 | func (this *MediaRange) SetType(t string) { 55 | this.mtype = t 56 | } 57 | 58 | /** 59 | * Set the subtype member 60 | * @param s String to set 61 | */ 62 | func (this *MediaRange) SetSubtype(s string) { 63 | this.subtype = s 64 | } 65 | 66 | /** 67 | * Encode the object. 68 | * @return String 69 | */ 70 | func (this *MediaRange) String() string { 71 | encoding := this.mtype + core.SIPSeparatorNames_SLASH + this.subtype 72 | return encoding 73 | } 74 | -------------------------------------------------------------------------------- /sip/header/MediaType.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | import () 4 | 5 | /** 6 | * This interface represents media type methods for any header that contain 7 | * content type and content sub-type values. 8 | * 9 | * @see AcceptHeader 10 | * @see ContentTypeHeader 11 | */ 12 | 13 | type MediaType interface { 14 | 15 | /** 16 | * Sets value of media type of Header with Content Type. 17 | * 18 | * @param contentType - the new string value of the content type 19 | * @throws ParseException which signals that an error has been reached 20 | * unexpectedly while parsing the contentType value. 21 | */ 22 | SetContentType(contentType string) (ParseException error) 23 | 24 | /** 25 | * Gets media type of Header with Content type. 26 | * 27 | * @return media type of Header with Content type. 28 | */ 29 | GetContentType() string 30 | 31 | /** 32 | * Sets value of media subtype of Header with Content sub-type. 33 | * 34 | * @param contentSubType - the new string value of the content sub-type. 35 | * @throws ParseException which signals that an error has been reached 36 | * unexpectedly while parsing the contentSubType value. 37 | */ 38 | SetContentSubType(contentSubType string) (ParseException error) 39 | 40 | /** 41 | * Gets media sub-type of Header with Content sub-type. 42 | * 43 | * @return media sub-type of Header with Content sub-type. 44 | */ 45 | GetContentSubType() string 46 | } 47 | -------------------------------------------------------------------------------- /sip/header/MimeVersionHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | /** 4 | * SIP messages MAY include a single MIME-Version general-header field to 5 | * indicate what version of the MIME protocol was used to construct the 6 | * message. Use of the MIME-Version header field indicates that the message is 7 | * in full compliance with the MIME protocol as defined in 8 | * RFC2045. Proxies/gateways 9 | * are responsible for ensuring full compliance (where possible) when exporting 10 | * SIP messages to strict MIME environments. 11 | *
12 | * For Example:
13 | * MIME-Version: 1.0
14 | */
15 | type MimeVersionHeader interface {
16 | Header
17 |
18 | /**
19 | * Gets the Minor version value of this MimeVersionHeader.
20 | *
21 | * @return the Minor version of this MimeVersionHeader
22 | */
23 | GetMinorVersion() int
24 |
25 | /**
26 | * Sets the Minor-Version argument of this MimeVersionHeader to the supplied
27 | * minorVersion value.
28 | *
29 | * @param minorVersion - the new minor MIME version
30 | * @throws InvalidArgumentException if the supplied value is less than zero.
31 | */
32 | SetMinorVersion(minorVersion int) (InvalidArgumentException error)
33 |
34 | /**
35 | * Gets the Major version value of this MimeVersionHeader.
36 | *
37 | * @return the Major version of this MimeVersionHeader
38 | */
39 | GetMajorVersion() int
40 |
41 | /**
42 | * Sets the Major-Version argument of this MimeVersionHeader to the supplied
43 | * majorVersion value.
44 | *
45 | * @param majorVersion - the new major MIME version
46 | * @throws InvalidArgumentException if the supplied version is less than zero.
47 | */
48 | SetMajorVersion(majorVersion int) (InvalidArgumentException error)
49 | }
50 |
--------------------------------------------------------------------------------
/sip/header/MinExpiresHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 |
5 | * The Min-Expires header field conveys the minimum refresh interval supported
6 |
7 | * for soft-state elements managed by that server. This includes Contact
8 |
9 | * header fields that are stored by a registrar. The header field contains a
10 |
11 | * decimal integer number of seconds from 0 to (2**32)-1.
12 |
13 | *
14 | 15 | * Allowing the registrar to set the registration interval protects it against 16 | 17 | * excessively frequent registration refreshes while limiting the state that it 18 | 19 | * needs to maintain and decreasing the likelihood of registrations going 20 | 21 | * stale. The expiration interval of a registration is frequently used in the 22 | 23 | * creation of services. An example is a follow-me service, where the user may 24 | 25 | * only be available at a terminal for a brief period. Therefore, registrars 26 | 27 | * should accept brief registrations; a request should only be rejected if the 28 | 29 | * interval is so short that the refreshes would degrade registrar performance. 30 | 31 | *
32 | 33 | * If a User Agent receives a 423 (Interval Too Brief) response to a REGISTER request, 34 | 35 | * it MAY retry the registration after making the expiration interval of all 36 | 37 | * contact addresses in the REGISTER request equal to or greater than the 38 | 39 | * expiration interval within the Min-Expires header field of the 423 40 | 41 | * (Interval Too Brief) response. The Min-Expires header field that states the 42 | 43 | * minimum expiration interval the registrar is willing to honor. 44 | 45 | *
46 |
47 | * For Example:
48 |
49 | * Min-Expires: 60
50 |
51 | */
52 |
53 | type MinExpiresHeader interface {
54 | ExpiresHeader
55 | }
56 |
--------------------------------------------------------------------------------
/sip/header/MinExpiresImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "errors"
5 | "gosips/core"
6 | "strconv"
7 | )
8 |
9 | /**
10 | * MinExpires SIP Header.
11 | */
12 | type MinExpires struct {
13 | SIPHeader
14 |
15 | /** expires field
16 | */
17 | expires int
18 | }
19 |
20 | /** default constructor
21 | */
22 | func NewMinExpires() *MinExpires {
23 | this := &MinExpires{}
24 | this.SIPHeader.super(core.SIPHeaderNames_MIN_EXPIRES)
25 | return this
26 | }
27 |
28 | func (this *MinExpires) String() string {
29 | return this.headerName + core.SIPSeparatorNames_COLON +
30 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE
31 | }
32 |
33 | /**
34 | * Return canonical form.
35 | * @return String
36 | */
37 | func (this *MinExpires) EncodeBody() string {
38 | return strconv.Itoa(this.expires)
39 | }
40 |
41 | /**
42 | * Gets the expires value of the ExpiresHeader. This expires value is
43 | *
44 | * relative time.
45 | *
46 | *
47 | *
48 | * @return the expires value of the ExpiresHeader.
49 | *
50 | */
51 | func (this *MinExpires) GetExpires() int {
52 | return this.expires
53 | }
54 |
55 | /**
56 | * Sets the relative expires value of the ExpiresHeader.
57 | * The expires value MUST be greater than zero and MUST be
58 | * less than 2**31.
59 | *
60 | * @param expires - the new expires value of this ExpiresHeader
61 | *
62 | * @throws InvalidArgumentException if supplied value is less than zero.
63 | *
64 | */
65 | func (this *MinExpires) SetExpires(expires int) (InvalidArgumentException error) {
66 | if expires < 0 {
67 | return errors.New("InvalidArgumentException: bad argument")
68 | }
69 | this.expires = expires
70 | return nil
71 | }
72 |
--------------------------------------------------------------------------------
/sip/header/OptionTag.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 | * This interface represents methods for manipulating OptionTags
5 | * values for any header that contains an OptionTag value. Option tags are
6 | * unique identifiers used to designate new options (extensions) in SIP. Note
7 | * that these options appear as parameters in those header fields in an
8 | * option-tag = token form. Option tags are defined in standards track RFCs.
9 | * This is a change from past practice, and is instituted to ensure continuing
10 | * multi-vendor interoperability.
11 | *
12 | * @see ProxyRequireHeader
13 | * @see RequireHeader
14 | * @see UnsupportedHeader
15 | * @see SupportedHeader
16 | */
17 |
18 | type OptionTag interface {
19 |
20 | /**
21 | * Sets the option tag value to the new supplied optionTag
22 | * parameter.
23 | *
24 | * @param optionTag - the new string value of the option tag.
25 | * @throws ParseException which signals that an error has been reached
26 | * unexpectedly while parsing the optionTag value.
27 | */
28 | SetOptionTag(optionTag string) (ParseException error)
29 |
30 | /**
31 | * Gets the option tag of this OptionTag class.
32 | *
33 | * @return the string that identifies the option tag value.
34 | */
35 | GetOptionTag() string
36 | }
37 |
--------------------------------------------------------------------------------
/sip/header/OrganizationHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 |
5 | * The OrganizationHeader conveys the name of the organization to which the
6 |
7 | * entity issuing the Request or Response belongs. It may be used by client
8 |
9 | * software to filter calls.
10 |
11 | */
12 |
13 | type OrganizationHeader interface {
14 | Header
15 |
16 | /**
17 |
18 | * Sets the organization value of the OrganizationHeader to the
19 |
20 | * organization parameter supplied.
21 |
22 | *
23 |
24 | * @param organization - the new string organization value
25 |
26 | * @throws ParseException which signals that an error has been reached
27 |
28 | * unexpectedly while parsing the organization value.
29 |
30 | */
31 |
32 | SetOrganization(organization string) (ParseException error)
33 |
34 | /**
35 |
36 | * Gets the organization value of OrganizationHeader.
37 |
38 | *
39 |
40 | * @return organization of OrganizationHeader
41 |
42 | */
43 |
44 | GetOrganization() string
45 | }
46 |
--------------------------------------------------------------------------------
/sip/header/OrganizationImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "errors"
5 | "gosips/core"
6 | )
7 |
8 | /**
9 | *Organization SIP Header.
10 | */
11 | type Organization struct {
12 | SIPHeader
13 |
14 | /** organization field
15 | */
16 | organization string
17 | }
18 |
19 | /** Default constructor
20 | */
21 | func NewOrganization() *Organization {
22 | this := &Organization{}
23 | this.SIPHeader.super(core.SIPHeaderNames_ORGANIZATION)
24 | return this
25 | }
26 |
27 | func (this *Organization) String() string {
28 | return this.headerName + core.SIPSeparatorNames_COLON +
29 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE
30 | }
31 |
32 | /**
33 | * Return encoding of value of the header.
34 | * @return String
35 | */
36 | func (this *Organization) EncodeBody() string {
37 | return this.organization
38 | }
39 |
40 | /** get the organization field.
41 | * @return String
42 | */
43 | func (this *Organization) GetOrganization() string {
44 | return this.organization
45 | }
46 |
47 | /**
48 | * Set the organization member
49 | * @param o String to set
50 | */
51 | func (this *Organization) SetOrganization(o string) (ParseException error) {
52 | if o == "" {
53 | return errors.New("NullPointerException: the organization parameter is null")
54 | }
55 | this.organization = o
56 | return nil
57 | }
58 |
--------------------------------------------------------------------------------
/sip/header/ParametersHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "container/list"
5 | "gosips/core"
6 | )
7 |
8 | type ParametersHeader interface {
9 | Header
10 | GetParameter(name string) string
11 | GetParameterValue(name string) string //interface{} TODO
12 | GetParameterNames() *list.List
13 | HasParameters() bool
14 | RemoveParameter(name string)
15 | SetParameter(name, value string) (ParseException error)
16 | SetQuotedParameter(name, value string)
17 | HasParameter(parameterName string) bool
18 | RemoveParameters()
19 | GetParameters() *core.NameValueList
20 | SetParameters(parameters *core.NameValueList)
21 | GetNameValue(parameterName string) *core.NameValue
22 | }
23 |
--------------------------------------------------------------------------------
/sip/header/PriorityHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 |
5 | * The Priority header field indicates the urgency of the request as perceived
6 |
7 | * by the client. The Priority header field describes the priority that the
8 |
9 | * SIP request should have to the receiving human or its agent. For example,
10 |
11 | * it may be factored into decisions about call routing and acceptance. For
12 |
13 | * these decisions, a message containing no Priority header field SHOULD be
14 |
15 | * treated as if it specified a Priority of "Normal".
16 |
17 | *
18 | 19 | * The Priority header field does not influence the use of communications 20 | 21 | * resources such as packet forwarding priority in routers or access to 22 | 23 | * circuits in PSTN gateways. 24 | 25 | *
26 | 27 | * The currently defined priority values are: 28 | 29 | *
Subject: Weekend plans
44 |
45 | * Priority: non-urgent
46 |
47 | */
48 |
49 | type PriorityHeader interface {
50 | Header
51 |
52 | /**
53 |
54 | * Set priority of PriorityHeader
55 |
56 | *
57 |
58 | * @param priority - the new string priority value
59 |
60 | * @throws ParseException which signals that an error has been reached
61 |
62 | * unexpectedly while parsing the priority value.
63 |
64 | */
65 |
66 | SetPriority(priority string) (ParseException error)
67 |
68 | /**
69 |
70 | * Gets the string priority value of the PriorityHeader.
71 |
72 | *
73 |
74 | * @return the string priority value of the PriorityHeader
75 |
76 | */
77 |
78 | GetPriority() string
79 | }
80 |
--------------------------------------------------------------------------------
/sip/header/PriorityImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "errors"
5 | "gosips/core"
6 | )
7 |
8 | /**
9 | * the Priority header.
10 | */
11 | type Priority struct {
12 | SIPHeader
13 |
14 | /** priority field
15 | */
16 | priority string
17 | }
18 |
19 | /** Default constructor
20 | */
21 | func NewPriority() *Priority {
22 | this := &Priority{}
23 | this.SIPHeader.super(core.SIPHeaderNames_PRIORITY)
24 | return this
25 | }
26 |
27 | func (this *Priority) String() string {
28 | return this.headerName + core.SIPSeparatorNames_COLON +
29 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE
30 | }
31 |
32 | /**
33 | * Encode into canonical form.
34 | * @return String
35 | */
36 | func (this *Priority) EncodeBody() string {
37 | return this.priority
38 | }
39 |
40 | /**
41 | * get the priority value.
42 | * @return String
43 | */
44 | func (this *Priority) GetPriority() string {
45 | return this.priority
46 | }
47 |
48 | /**
49 | * Set the priority member
50 | * @param p String to set
51 | */
52 | func (this *Priority) SetPriority(p string) (ParseException error) {
53 | if p == "" {
54 | return errors.New("NullPointerException: the priority parameter is null")
55 | }
56 | this.priority = p
57 | return nil
58 | }
59 |
--------------------------------------------------------------------------------
/sip/header/ProxyAuthenticateImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | )
6 |
7 | /**
8 | * Proxy Authenticate SIP (HTTP ) header.
9 | */
10 | type ProxyAuthenticate struct {
11 | Authentication
12 | }
13 |
14 | /** Default Constructor
15 | */
16 | func NewProxyAuthenticate() *ProxyAuthenticate {
17 | this := &ProxyAuthenticate{}
18 | this.Authentication.super(core.SIPHeaderNames_PROXY_AUTHENTICATE)
19 | return this
20 | }
21 |
--------------------------------------------------------------------------------
/sip/header/ProxyAuthenticateList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "gosips/core"
4 |
5 | /**
6 | * List of ProxyAuthenticate headers.
7 | */
8 | type ProxyAuthenticateList struct {
9 | SIPHeaderList
10 | }
11 |
12 | /** Default constructor
13 | */
14 | func NewProxyAuthenticateList() *ProxyAuthenticateList {
15 | this := &ProxyAuthenticateList{}
16 | this.SIPHeaderList.super(core.SIPHeaderNames_PROXY_AUTHENTICATE)
17 | return this
18 | }
19 |
--------------------------------------------------------------------------------
/sip/header/ProxyAuthorizationImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "gosips/core"
4 |
5 | /**
6 | * ProxyAuthorization SIP header.
7 | */
8 | type ProxyAuthorization struct {
9 | Authentication
10 | }
11 |
12 | /** Default constructor.
13 | */
14 | func NewProxyAuthorization() *ProxyAuthorization {
15 | this := &ProxyAuthorization{}
16 | this.Authentication.super(core.SIPHeaderNames_PROXY_AUTHORIZATION)
17 | return this
18 | }
19 |
--------------------------------------------------------------------------------
/sip/header/ProxyRequireHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 |
5 | * The Proxy-Require header field is used to indicate proxy-sensitive features
6 |
7 | * that must be supported by the proxy. The Proxy-Require header field contains
8 |
9 | * a list of option tags. Each option tag defines a SIP extension that MUST be
10 |
11 | * understood by the proxy to process the request. Any ProxyRequireHeader
12 |
13 | * features that are not supported by the proxy must be negatively acknowledged
14 |
15 | * by the proxy to the client if not supported. Proxy servers treat this field
16 |
17 | * identically to the RequireHeader.
18 |
19 | *
20 |
21 | * For Example:
22 |
23 | * Proxy-Require: foo
24 |
25 | *
26 |
27 | * @see RequireHeader
28 |
29 | */
30 |
31 | type ProxyRequireHeader interface {
32 | RequireHeader
33 | }
34 |
--------------------------------------------------------------------------------
/sip/header/ProxyRequireImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "errors"
5 | "gosips/core"
6 | )
7 |
8 | /**
9 | * ProxyRequire Header.
10 | */
11 | type ProxyRequire struct {
12 | SIPHeader
13 |
14 | /** optiontag field
15 | */
16 | optionTag string
17 | }
18 |
19 | /** Default Constructor
20 | * @param s String to set
21 | */
22 | func NewProxyRequire() *ProxyRequire {
23 | this := &ProxyRequire{}
24 | this.SIPHeader.super(core.SIPHeaderNames_PROXY_REQUIRE)
25 | return this
26 | }
27 |
28 | /** Constructor
29 | * @param s String to set
30 | */
31 | func NewProxyRequireFromString(s string) *ProxyRequire {
32 | this := &ProxyRequire{}
33 | this.SIPHeader.super(core.SIPHeaderNames_PROXY_REQUIRE)
34 | this.optionTag = s
35 | return this
36 | }
37 |
38 | func (this *ProxyRequire) String() string {
39 | return this.headerName + core.SIPSeparatorNames_COLON +
40 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE
41 | }
42 |
43 | /**
44 | * Encode in canonical form.
45 | * @return String
46 | */
47 | func (this *ProxyRequire) EncodeBody() string {
48 | return this.optionTag
49 | }
50 |
51 | /**
52 | * Sets the option tag value to the new supplied optionTag
53 | * parameter.
54 | *
55 | * @param optionTag - the new string value of the option tag.
56 | * @throws ParseException which signals that an error has been reached
57 | * unexpectedly while parsing the optionTag value.
58 | */
59 | func (this *ProxyRequire) SetOptionTag(optionTag string) (ParseException error) {
60 | if optionTag == "" {
61 | return errors.New("NullPointerException: the optionTag parameter is null")
62 | }
63 | this.optionTag = optionTag
64 | return nil
65 | }
66 |
67 | /**
68 | * Gets the option tag of this OptionTag class.
69 | *
70 | * @return the string that identifies the option tag value.
71 | */
72 | func (this *ProxyRequire) GetOptionTag() string {
73 | return this.optionTag
74 | }
75 |
--------------------------------------------------------------------------------
/sip/header/ProxyRequireList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "gosips/core"
4 |
5 | /**
6 | * Proxy Require SIPSIPObject (list of option tags)
7 | */
8 | type ProxyRequireList struct {
9 | SIPHeaderList
10 | }
11 |
12 | /** Default Constructor
13 | */
14 | func NewProxyRequireList() *ProxyRequireList {
15 | this := &ProxyRequireList{}
16 | this.SIPHeaderList.super(core.SIPHeaderNames_PROXY_REQUIRE)
17 | return this
18 | }
19 |
--------------------------------------------------------------------------------
/sip/header/QValue.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | type QValue interface {
4 |
5 | /**
6 |
7 | * Gets q-value of the media-range in AcceptLanguageHeader. A value of
8 |
9 | * -1
indicates theq-value
is not set.
10 |
11 | *
12 |
13 | * @return q-value of media-range, -1 if q-value is not set.
14 |
15 | */
16 |
17 | GetQValue() float32
18 |
19 | /**
20 |
21 | * Sets q-value for media-range in AcceptLanguageHeader. Q-values allow the
22 |
23 | * user to indicate the relative degree of preference for that media-range,
24 |
25 | * using the qvalue scale from 0 to 1. If no q-value is present, the
26 |
27 | * media-range should be treated as having a q-value of 1.
28 |
29 | *
30 |
31 | * @param qValue - the new float value of the q-value
32 |
33 | * @throws InvalidArgumentException if the q parameter value is not between 0 and 1
.
34 |
35 | */
36 |
37 | SetQValue(qValue float32) (InvalidArgumentException error)
38 |
39 | RemoveQValue()
40 |
41 | HasQValue() bool
42 | }
43 |
--------------------------------------------------------------------------------
/sip/header/RSeqHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 | * This interface represents the RSeq header, as defined by
5 | * RFC3262, this
6 | * header is not part of RFC3261.
7 | *
8 | * The RSeq header is used in provisional responses in order to transmit them 9 | * reliably. It contains a single numeric value from 1 to 2**32-1. The value of 10 | * the RSeq in each subsequent reliable provisional response for the same request 11 | * MUST be greater by exactly one. RSeq numbers MUST NOT wrap around. Because 12 | * the initial one is chosen to be less than 2**31 - 1, but the maximum is 13 | * 2**32 - 1, there can be up to 2**31 reliable provisional responses per 14 | * request, which is more than sufficient. As the RSeq numbering space is within 15 | * a single transaction. This means that provisional responses for different 16 | * requests MAY use the same values for the RSeq number. 17 | *
18 | * A server must ignore Headers that it does not understand. A proxy must not 19 | * remove or modify Headers that it does not understand. 20 | */ 21 | 22 | type RSeqHeader interface { 23 | Header 24 | 25 | /** 26 | * Sets the sequence number value of the RSeqHeader of the provisional 27 | * response. The sequence number MUST be expressible as a 32-bit unsigned 28 | * integer and MUST be less than 2**31. 29 | * 30 | * @param sequenceNumber - the new Sequence number of this RSeqHeader 31 | * @throws InvalidArgumentException if supplied value is less than zero. 32 | */ 33 | SetSequenceNumber(sequenceNumber int) (InvalidArgumentException error) 34 | 35 | /** 36 | * Gets the sequence number of this RSeqHeader. 37 | * 38 | * @return the integer value of the Sequence number of the RSeqHeader 39 | */ 40 | GetSequenceNumber() int 41 | } 42 | -------------------------------------------------------------------------------- /sip/header/RSeqImpl.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | import ( 4 | "errors" 5 | "gosips/core" 6 | "strconv" 7 | ) 8 | 9 | type RSeq struct { 10 | SIPHeader 11 | 12 | sequenceNumber int 13 | } 14 | 15 | /** Creates a new instance of RSeq */ 16 | func NewRSeq() *RSeq { 17 | this := &RSeq{} 18 | this.SIPHeader.super(core.SIPHeaderNames_RSEQ) 19 | return this 20 | } 21 | 22 | /** Gets the sequence number of this RSeqHeader. 23 | * 24 | * @return the integer value of the Sequence number of the RSeqHeader 25 | */ 26 | func (this *RSeq) GetSequenceNumber() int { 27 | return this.sequenceNumber 28 | } 29 | 30 | /** Sets the sequence number value of the RSeqHeader of the provisional 31 | * response. The sequence number MUST be expressible as a 32-bit unsigned 32 | * integer and MUST be less than 2**31. 33 | * 34 | * @param sequenceNumber - the new Sequence number of this RSeqHeader 35 | * @throws InvalidArgumentException if supplied value is less than zero. 36 | */ 37 | func (this *RSeq) SetSequenceNumber(sequenceNumber int) (InvalidArgumentException error) { 38 | if sequenceNumber <= 0 { 39 | return errors.New("InvalidArgumentException: Bad seq number") 40 | } 41 | this.sequenceNumber = sequenceNumber 42 | return nil 43 | } 44 | 45 | func (this *RSeq) String() string { 46 | return this.headerName + core.SIPSeparatorNames_COLON + 47 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE 48 | } 49 | 50 | /** Encode the body of this header (the stuff that follows headerName). 51 | * A.K.A headerValue. 52 | */ 53 | func (this *RSeq) EncodeBody() string { 54 | return strconv.Itoa(this.sequenceNumber) 55 | } 56 | -------------------------------------------------------------------------------- /sip/header/ReasonList.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | import "gosips/core" 4 | 5 | /** 6 | * List of Reason headers. 7 | */ 8 | type ReasonList struct { 9 | SIPHeaderList 10 | } 11 | 12 | /** Default constructor 13 | */ 14 | func NewReasonList() *ReasonList { 15 | this := &ReasonList{} 16 | this.SIPHeaderList.super(core.SIPHeaderNames_REASON) 17 | return this 18 | } 19 | -------------------------------------------------------------------------------- /sip/header/RecordRouteHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | /** 4 | * The Record-Route header field is inserted by proxies in a request to force 5 | * future requests in the dialog to be routed through the proxy. The 6 | * SipProvider (as opposed to the application) should attach Record-Route 7 | * headers to messages explicitly when forwarding them if necessary. 8 | *
9 | * The RecordRouteHeader is added to a Request by any proxy that insists on being 10 | * in the path of subsequent Requests for the same call leg. It contains 11 | * a globally reachable RequestURI that identifies the proxy server. Each proxy 12 | * server adds its Address URI to the beginning of the list. 13 | *
14 | * The calling user agent client copies the RecordRouteHeaders into 15 | * RouteHeaders of subsequent Requests within the same call leg, reversing the 16 | * order, so that the first entry is closest to the user agent client. If the 17 | * Response contained a ContactHeader field, the calling user agent adds its 18 | * content as the last RouteHeader. Unless this would cause a loop, a client 19 | * must send subsequent Requests for this call leg to the Address URI in the 20 | * first RouteHeader and remove that entry. 21 | *
22 | * Some proxies, such as those controlling firewalls or in an automatic call 23 | * distribution (ACD) system, need to maintain call state and thus need to 24 | * receive any BYE and ACK Requests for the call. 25 | *
26 | * For Example:
27 | * Record-Route: sip:server10.jcp.org;lr,
28 | * sip:bigbox3.duke.jcp.org;lr
29 | *
30 | * @see RouteHeader
31 | * @see AddressHeader
32 | * @see Parameters
33 | */
34 | type RecordRouteHeader interface {
35 | AddressHeader
36 | ParametersHeader
37 | }
38 |
--------------------------------------------------------------------------------
/sip/header/RecordRouteImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "bytes"
5 | "gosips/core"
6 | "gosips/sip/address"
7 | )
8 |
9 | /** The Request-Route header is added to a request by any proxy that insists on
10 | * being in the path of subsequent requests for the same call leg.
11 | */
12 | type RecordRoute struct {
13 | AddressParameters
14 | }
15 |
16 | /** constructor
17 | * @param addr address to set
18 | */
19 | func NewRecordRouteFromAddress(addr address.Address) *RecordRoute {
20 | this := &RecordRoute{}
21 | this.AddressParameters.super(core.SIPHeaderNames_RECORD_ROUTE)
22 | this.addr = addr
23 | return this
24 | }
25 |
26 | /** default constructor
27 | */
28 | func NewRecordRoute() *RecordRoute {
29 | this := &RecordRoute{}
30 | this.AddressParameters.super(core.SIPHeaderNames_RECORD_ROUTE)
31 | return this
32 | }
33 |
34 | func (this *RecordRoute) String() string {
35 | return this.headerName + core.SIPSeparatorNames_COLON +
36 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE
37 | }
38 |
39 | /** Encode into canonical form.
40 | *@return String containing the canonicaly encoded header.
41 | */
42 | func (this *RecordRoute) EncodeBody() string {
43 | var encoding bytes.Buffer
44 | addr, _ := this.addr.(*address.AddressImpl)
45 | if addr.GetAddressType() == address.ADDRESS_SPEC {
46 | encoding.WriteString(core.SIPSeparatorNames_LESS_THAN)
47 | }
48 | encoding.WriteString(this.addr.String())
49 | if addr.GetAddressType() == address.ADDRESS_SPEC {
50 | encoding.WriteString(core.SIPSeparatorNames_GREATER_THAN)
51 | }
52 |
53 | if this.parameters != nil && this.parameters.Len() > 0 {
54 | encoding.WriteString(core.SIPSeparatorNames_SEMICOLON)
55 | encoding.WriteString(this.parameters.String())
56 | }
57 | return encoding.String()
58 | }
59 |
--------------------------------------------------------------------------------
/sip/header/RecordRouteList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "gosips/core"
4 |
5 | /**
6 | * RecordRoute List of SIP headers (a collection of Addresses)
7 | */
8 | type RecordRouteList struct {
9 | SIPHeaderList
10 | }
11 |
12 | /** Default constructor
13 | */
14 | func NewRecordRouteList() *RecordRouteList {
15 | this := &RecordRouteList{}
16 | this.SIPHeaderList.super(core.SIPHeaderNames_RECORD_ROUTE)
17 | return this
18 | }
19 |
--------------------------------------------------------------------------------
/sip/header/ReferToHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 | * This interface represents the ReferTo SIP header, as defined by
5 | * RFC3515, this header is
6 | * not part of RFC3261.
7 | *
8 | * A ReferToHeader only appears in a REFER request. It provides a URL to 9 | * reference. The ReferToHeader field MAY be encrypted as part of end-to-end 10 | * encryption. The resource identified by the Refer-To URI is contacted using 11 | * the normal mechanisms for that URI type. 12 | */ 13 | type ReferToHeader interface { 14 | AddressHeader 15 | ParametersHeader 16 | } 17 | -------------------------------------------------------------------------------- /sip/header/ReferToImpl.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | import ( 4 | "bytes" 5 | "gosips/core" 6 | "gosips/sip/address" 7 | ) 8 | 9 | /** 10 | *ReferTo SIP Header. 11 | */ 12 | 13 | type ReferTo struct { 14 | AddressParameters 15 | } 16 | 17 | /** default Constructor. 18 | */ 19 | func NewReferTo() *ReferTo { 20 | this := &ReferTo{} 21 | this.AddressParameters.super(core.SIPHeaderNames_REFER_TO) 22 | return this 23 | } 24 | 25 | func (this *ReferTo) String() string { 26 | return this.headerName + core.SIPSeparatorNames_COLON + 27 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE 28 | } 29 | 30 | /** 31 | * Encode the header content into a String. 32 | * @return String 33 | */ 34 | func (this *ReferTo) EncodeBody() string { 35 | var encoding bytes.Buffer 36 | addr, _ := this.addr.(*address.AddressImpl) 37 | if addr.GetAddressType() == address.ADDRESS_SPEC { 38 | encoding.WriteString(core.SIPSeparatorNames_LESS_THAN) 39 | } 40 | encoding.WriteString(this.addr.String()) 41 | if addr.GetAddressType() == address.ADDRESS_SPEC { 42 | encoding.WriteString(core.SIPSeparatorNames_GREATER_THAN) 43 | } 44 | 45 | if this.parameters != nil && this.parameters.Len() > 0 { 46 | encoding.WriteString(core.SIPSeparatorNames_SEMICOLON) 47 | encoding.WriteString(this.parameters.String()) 48 | } 49 | return encoding.String() 50 | } 51 | -------------------------------------------------------------------------------- /sip/header/ReplyToHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | /** 4 | 5 | * The Reply-To header field contains a logical return URI that may be 6 | 7 | * different from the From header field. For example, the URI MAY be used to 8 | 9 | * return missed calls or unestablished sessions. If the user wished to remain 10 | 11 | * anonymous, the header field SHOULD either be omitted from the request or 12 | 13 | * populated in such a way that does not reveal any private information. 14 | 15 | *
16 |
17 | * For Example:
18 |
19 | * Reply-To: Bob sip:bob@biloxi.com
20 |
21 | *
22 |
23 | * @see AddressHeader
24 |
25 | * @see Parameters
26 |
27 | */
28 |
29 | type ReplyToHeader interface {
30 | AddressHeader
31 | ParametersHeader
32 | }
33 |
--------------------------------------------------------------------------------
/sip/header/RequireHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 |
5 | * The Require header field is used by UACs to tell UASs about options that
6 |
7 | * the UAC expects the UAS to support in order to process the request.
8 |
9 | * Although an optional header field, the Require MUST NOT be ignored if it
10 |
11 | * is present.
12 |
13 | *
14 | 15 | * The Require header field contains a list of option tags. Each option tag 16 | 17 | * defines a SIP extension that MUST be understood to process the request. 18 | 19 | * Frequently, this is used to indicate that a specific set of extension 20 | 21 | * header fields need to be understood. A UAC compliant to this specification 22 | 23 | * MUST only include option tags corresponding to standards-track RFCs. 24 | 25 | *
26 | 27 | * If a server does not understand the option, it must respond by returning a 28 | 29 | * BAD_EXTENSION Response and list those options it does not understand in 30 | 31 | * the UnsupportedHeader. 32 | 33 | *
34 | 35 | * Proxy and redirect servers must ignore features that are not understood. If 36 | 37 | * a particular extension requires that intermediate devices support it, the 38 | 39 | * extension must be tagged in the ProxyRequireHeader as well. 40 | 41 | *
42 |
43 | * For Example:
44 |
45 | * Require: 100rel
46 |
47 | *
48 |
49 | * @see ProxyRequireHeader
50 |
51 | * @see OptionTag
52 |
53 | */
54 |
55 | type RequireHeader interface {
56 | OptionTag
57 | Header
58 | }
59 |
--------------------------------------------------------------------------------
/sip/header/RequireImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "errors"
5 | "gosips/core"
6 | )
7 |
8 | /**
9 | *Require SIP Header.
10 | */
11 | type Require struct {
12 | SIPHeader
13 |
14 | /** optionTag field
15 | */
16 | optionTag string
17 | }
18 |
19 | /** Default constructor
20 | * @param s String to set
21 | */
22 | func NewRequire() *Require {
23 | this := &Require{}
24 | this.SIPHeader.super(core.SIPHeaderNames_REQUIRE)
25 | return this
26 | }
27 |
28 | /** constructor
29 | * @param s String to set
30 | */
31 | func NewRequireFromString(s string) *Require {
32 | this := &Require{}
33 | this.SIPHeader.super(core.SIPHeaderNames_REQUIRE)
34 | this.optionTag = s
35 | return this
36 | }
37 |
38 | func (this *Require) String() string {
39 | return this.headerName + core.SIPSeparatorNames_COLON +
40 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE
41 | }
42 |
43 | /**
44 | * Encode in canonical form.
45 | * @return String
46 | */
47 | func (this *Require) EncodeBody() string {
48 | return this.optionTag
49 | }
50 |
51 | /**
52 | * Sets the option tag value to the new supplied optionTag
53 | * parameter.
54 | *
55 | * @param optionTag - the new string value of the option tag.
56 | * @throws ParseException which signals that an error has been reached
57 | * unexpectedly while parsing the optionTag value.
58 | */
59 | func (this *Require) SetOptionTag(optionTag string) (ParseException error) {
60 | if optionTag == "" {
61 | return errors.New("NullPointerException: the optionTag parameter is null")
62 | }
63 | this.optionTag = optionTag
64 | return nil
65 | }
66 |
67 | /**
68 | * Gets the option tag of this OptionTag class.
69 | *
70 | * @return the string that identifies the option tag value.
71 | */
72 | func (this *Require) GetOptionTag() string {
73 | return this.optionTag
74 | }
75 |
--------------------------------------------------------------------------------
/sip/header/RequireList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "gosips/core"
4 |
5 | /**
6 | * List of Require headers.
7 | *
8 | * Require = "Require" ":" 1#option-tag 9 | *10 | */ 11 | type RequireList struct { 12 | SIPHeaderList 13 | } 14 | 15 | /** Default constructor 16 | */ 17 | func NewRequireList() *RequireList { 18 | this := &RequireList{} 19 | this.SIPHeaderList.super(core.SIPHeaderNames_REQUIRE) 20 | return this 21 | } 22 | -------------------------------------------------------------------------------- /sip/header/RouteHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | /** 4 | * The Route header field is used to force routing for a request through the 5 | * listed set of proxies. Each host removes the first entry and then proxies 6 | * the Request to the host listed in that entry using it as the RequestURI. 7 | *
8 | * Explicit Route assignment (if needed) for the initial dialog establishment 9 | * is the applications responsibility, but once established Routes are 10 | * maintained by the dialog layer and should not be manupulated by the 11 | * application. For example the SipProvider queries the dialog for Route 12 | * assignment and adds these to the outgoing message as needed. The 13 | * {@link javax.sip.address.Router} may be used by the application to determine 14 | * the initial Route of the message. 15 | * 16 | * @see RecordRouteHeader 17 | * @see AddressHeader 18 | * @see Parameters 19 | * 20 | */ 21 | type RouteHeader interface { 22 | AddressHeader 23 | ParametersHeader 24 | } 25 | -------------------------------------------------------------------------------- /sip/header/RouteList.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | import "gosips/core" 4 | 5 | /** 6 | * A list of Route Headers. 7 | */ 8 | type RouteList struct { 9 | SIPHeaderList 10 | 11 | //private HashSet routeSet; 12 | } 13 | 14 | /** default constructor 15 | */ 16 | func NewRouteList() *RouteList { 17 | this := &RouteList{} 18 | this.SIPHeaderList.super(core.SIPHeaderNames_ROUTE) 19 | //this.routeSet = new HashSet(); 20 | return this 21 | } 22 | 23 | // public boolean add(Object rh) { 24 | // if (! routeSet.contains(rh) ) { 25 | // this.routeSet.add(rh); 26 | // return super.add(rh); 27 | // } else return false; 28 | // } 29 | 30 | /** Constructor 31 | * @param sip SIPObjectList to set 32 | */ 33 | // public RouteList (SIPObjectList sip) { 34 | // super(sip, RouteHeader.NAME); 35 | // } 36 | 37 | /** 38 | * Order is important when comparing route lists. 39 | */ 40 | // public boolean equals(Object other) { 41 | // if (!(other instanceof RouteList)) return false; 42 | // RouteList that = (RouteList) other; 43 | // if (this.size() != that.size()) return false; 44 | // ListIterator it = this.listIterator(); 45 | // ListIterator it1 = that.listIterator(); 46 | // while (it.hasNext()) { 47 | // Route route = (Route) it.next(); 48 | // Route route1 = (Route) it1.next(); 49 | // if (! route.equals(route1)) return false; 50 | // } 51 | // return true; 52 | // } 53 | -------------------------------------------------------------------------------- /sip/header/ServerHeader.go: -------------------------------------------------------------------------------- 1 | package header 2 | 3 | import "container/list" 4 | 5 | /** 6 | * The Server header field contains information about the software used by 7 | * the UAS to handle the request. Revealing the specific software version of 8 | * the server might allow the server to become more vulnerable to attacks 9 | * against software that is known to contain security holes. Implementers 10 | * SHOULD make the Server header field a configurable option. If the Response 11 | * is being forwarded through a proxy, the proxy application must not modify 12 | * the ServerHeaders. Instead, it should include a ViaHeader. 13 | *
14 | * For Example:
15 | * Server: HomeServer v2
16 | *
17 | * @see ViaHeader
18 | * @see UserAgentHeader
19 | */
20 | type ServerHeader interface {
21 | Header
22 |
23 | /**
24 | * Returns a ListIterator over the List of product values.
25 | *
26 | * @return a ListIterator over the List of strings identifying the
27 | * software of this ServerHeader
28 | */
29 | GetProduct() *list.List
30 |
31 | /**
32 | * Sets the List of product values of the ServerHeader.
33 | *
34 | * @param product - a List of Strings specifying the product values
35 | * @throws ParseException which signals that an error has been reached
36 | * unexpectedly while parsing the List of product value strings.
37 | */
38 | SetProduct(product *list.List) (ParseException error)
39 | }
40 |
--------------------------------------------------------------------------------
/sip/header/SubjectHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 |
5 | * The Subject header field provides a summary or indicates the nature of the
6 |
7 | * call, allowing call filtering without having to parse the session
8 |
9 | * description. The session description does not have to use the same subject
10 |
11 | * indication as the invitation.
12 |
13 | *
14 |
15 | * For Example:
16 |
17 | * Subject: Where is the Moscone?
18 |
19 | */
20 |
21 | type SubjectHeader interface {
22 | Header
23 |
24 | /**
25 |
26 | * Sets the subject value of the SubjectHeader to the supplied string
27 |
28 | * subject value.
29 |
30 | *
31 |
32 | * @param subject - the new subject value of this header.
33 |
34 | * @throws ParseException which signals that an error has been reached
35 |
36 | * unexpectedly while parsing the subject value.
37 |
38 | */
39 |
40 | SetSubject(subject string) (ParseException error)
41 |
42 | /**
43 |
44 | * Gets the subject value of SubjectHeader.
45 |
46 | *
47 |
48 | * @return subject of SubjectHeader.
49 |
50 | */
51 |
52 | GetSubject() string
53 | }
54 |
--------------------------------------------------------------------------------
/sip/header/SubjectImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "errors"
5 | "gosips/core"
6 | )
7 |
8 | /**
9 | *Supported SIP Header.
10 | */
11 | type Subject struct {
12 | SIPHeader
13 |
14 | /** subject field
15 | */
16 | subject string
17 | }
18 |
19 | /** Default Constructor.
20 | */
21 | func NewSubject() *Subject {
22 | this := &Subject{}
23 | this.SIPHeader.super(core.SIPHeaderNames_SUBJECT)
24 | return this
25 | }
26 |
27 | func (this *Subject) String() string {
28 | return this.headerName + core.SIPSeparatorNames_COLON +
29 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE
30 | }
31 |
32 | /**
33 | * Generate the canonical form.
34 | * @return String.
35 | */
36 | func (this *Subject) EncodeBody() string {
37 | return this.subject
38 | }
39 |
40 | /**
41 |
42 | * Sets the subject value of the SubjectHeader to the supplied string
43 |
44 | * subject value.
45 |
46 | *
47 |
48 | * @param subject - the new subject value of this header
49 |
50 | * @throws ParseException which signals that an error has been reached
51 |
52 | * unexpectedly while parsing the subject value.
53 |
54 | */
55 |
56 | func (this *Subject) SetSubject(subject string) (ParseException error) {
57 | if subject == "" {
58 | return errors.New("NullPointerException: the subject parameter is null")
59 | }
60 | this.subject = subject
61 | return nil
62 | }
63 |
64 | /**
65 |
66 | * Gets the subject value of SubjectHeader
67 |
68 | *
69 |
70 | * @return subject of SubjectHeader
71 |
72 | */
73 |
74 | func (this *Subject) GetSubject() string {
75 | return this.subject
76 | }
77 |
--------------------------------------------------------------------------------
/sip/header/SupportedHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 |
5 | * The Supported header field enumerates all the extensions supported by
6 |
7 | * the UAC or UAS. The Supported header field contains a list of option tags,
8 |
9 | * that are understood by the UAC or UAS. A User Agent compliant to this specification
10 |
11 | * MUST only include option tags corresponding to standards-track RFCs. If
12 |
13 | * empty, it means that no extensions are supported.
14 |
15 | *
16 |
17 | * For Example:
18 |
19 | * Supported: 100rel
20 |
21 | *
22 |
23 | * @see OptionTag
24 |
25 | * @see UnsupportedHeader
26 |
27 | */
28 |
29 | type SupportedHeader interface {
30 | OptionTag
31 | Header
32 | }
33 |
--------------------------------------------------------------------------------
/sip/header/SupportedList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "gosips/core"
4 |
5 | /**
6 | * A list of supported headers.
7 | *@see Supported
8 | */
9 |
10 | type SupportedList struct {
11 | SIPHeaderList
12 | }
13 |
14 | /** Default Constructor
15 | */
16 | func NewSupportedList() *SupportedList {
17 | this := &SupportedList{}
18 | this.SIPHeaderList.super(core.SIPHeaderNames_SUPPORTED)
19 | return this
20 | }
21 |
--------------------------------------------------------------------------------
/sip/header/UnsupportedHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | /**
4 | * The Unsupported header field lists the features not supported by the UAS.
5 | * If a server does not understand the option, it must respond by returning a
6 | * 420 (Bad Extension) Response and list those options it does not understand in
7 | * the UnsupportedHeader.
8 | *
9 | * @see SupportedHeader
10 | * @see RequireHeader
11 | */
12 |
13 | type UnsupportedHeader interface {
14 | OptionTag
15 | Header
16 | }
17 |
--------------------------------------------------------------------------------
/sip/header/UnsupportedImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "errors"
5 | "gosips/core"
6 | )
7 |
8 | /**
9 | * the Unsupported header.
10 | */
11 | type Unsupported struct {
12 | SIPHeader
13 |
14 | /** option-Tag field.
15 | */
16 | optionTag string
17 | }
18 |
19 | /** Default Constructor.
20 | */
21 | func NewUnsupported() *Unsupported {
22 | this := &Unsupported{}
23 | this.SIPHeader.super(core.SIPHeaderNames_UNSUPPORTED)
24 | return this
25 | }
26 |
27 | /** Constructor
28 | * @param ot String to set
29 | */
30 | func NewUnsupportedFromString(ot string) *Unsupported {
31 | this := &Unsupported{}
32 | this.SIPHeader.super(core.SIPHeaderNames_UNSUPPORTED)
33 | this.optionTag = ot
34 | return this
35 | }
36 |
37 | func (this *Unsupported) String() string {
38 | return this.headerName + core.SIPSeparatorNames_COLON +
39 | core.SIPSeparatorNames_SP + this.EncodeBody() + core.SIPSeparatorNames_NEWLINE
40 | }
41 |
42 | /**
43 | * Return a canonical value.
44 | * @return String.
45 | */
46 | func (this *Unsupported) EncodeBody() string {
47 | return this.optionTag
48 | }
49 |
50 | /** get the option tag field
51 | * @return option Tag field
52 | */
53 | func (this *Unsupported) GetOptionTag() string {
54 | return this.optionTag
55 | }
56 |
57 | /**
58 | * Set the option member
59 | * @param o String to set
60 | */
61 | func (this *Unsupported) SetOptionTag(o string) (ParseException error) {
62 | if o == "" {
63 | return errors.New("NullPointerException: The option tag parameter is null")
64 | }
65 | this.optionTag = o
66 | return nil
67 | }
68 |
--------------------------------------------------------------------------------
/sip/header/UnsupportedList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "gosips/core"
4 |
5 | /**
6 | * List of Unsupported headers.
7 | */
8 | type UnsupportedList struct {
9 | SIPHeaderList
10 | }
11 |
12 | /** Default Constructor
13 | */
14 | func NewUnsupportedList() *UnsupportedList {
15 | this := &UnsupportedList{}
16 | this.SIPHeaderList.super(core.SIPHeaderNames_UNSUPPORTED)
17 | return this
18 | }
19 |
--------------------------------------------------------------------------------
/sip/header/UserAgentHeader.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "container/list"
4 |
5 | /**
6 | * The User-Agent header field contains information about the UAC originating
7 | * the request. This is for statistical purposes, the tracing of protocol
8 | * violations, and automated recognition of user agents for the sake of
9 | * tailoring Responses to avoid particular user agent limitations. However
10 | * revealing the specific software version of the user agent might allow the
11 | * user agent to become more vulnerable to attacks against software that is
12 | * known to contain security holes. Implementers SHOULD make the User-Agent
13 | * header field a configurable option.
14 | *
15 | * For Example:
16 | * User-Agent: Softphone Beta1.5
17 | *
18 | * @see ServerHeader
19 | * @see ViaHeader
20 | */
21 | type UserAgentHeader interface {
22 | Header
23 |
24 | /**
25 | * Returns the List of product values.
26 | *
27 | * @return the List of strings identifying the software of this ServerHeader
28 | */
29 | GetProduct() *list.List
30 |
31 | /**
32 | * Sets the List of product values of the ServerHeader.
33 | *
34 | * @param product - a List of Strings specifying the product values
35 | * @throws ParseException which signals that an error has been reached
36 | * unexpectedly while parsing the List of product value strings.
37 | */
38 | SetProduct(product *list.List) (ParseException error)
39 | }
40 |
--------------------------------------------------------------------------------
/sip/header/ViaList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import (
4 | "gosips/core"
5 | )
6 |
7 | /**
8 | * Keeps a list and a hashtable of via header functions.
9 | */
10 | type ViaList struct {
11 | SIPHeaderList
12 |
13 | stringRep string
14 | }
15 |
16 | /**
17 | * Default Constructor.
18 | */
19 | func NewViaList() *ViaList {
20 | this := &ViaList{}
21 | this.SIPHeaderList.super(core.SIPHeaderNames_VIA)
22 | return this
23 | }
24 |
25 | func (this *ViaList) super(name string) {
26 | this.SIPHeaderList.super(name)
27 | }
28 |
29 | /**
30 | * make a clone of this header list. This supercedes the parent
31 | * function of the same signature - here for speed. Cloning based
32 | * on introspection is slower.
33 | *
34 | * @return clone of this Header list.
35 | */
36 | func (this *ViaList) Clone() interface{} {
37 | vlist := NewViaList()
38 | //ListIterator it = this.listIterator();
39 | for e := this.Front(); e != nil; e = e.Next() {
40 | v := e.Value.(*Via).Clone().(*Via)
41 | vlist.PushBack(v)
42 | }
43 | return vlist
44 | }
45 |
--------------------------------------------------------------------------------
/sip/header/WWWAuthenticateImpl.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "gosips/core"
4 |
5 | /** The WWWAuthenticate SIP header.
6 | * @see WWWAuthenticateList SIPHeader which strings these together.
7 | */
8 |
9 | type WWWAuthenticate struct {
10 | Authentication
11 | }
12 |
13 | /**
14 | * Default Constructor.
15 | */
16 | func NewWWWAuthenticate() *WWWAuthenticate {
17 | this := &WWWAuthenticate{}
18 | this.Authentication.super(core.SIPHeaderNames_WWW_AUTHENTICATE)
19 | return this
20 | }
21 |
--------------------------------------------------------------------------------
/sip/header/WWWAuthenticateList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "gosips/core"
4 |
5 | /**
6 | * WWWAuthenticate SIPHeader (of which there can be several?)
7 | */
8 | type WWWAuthenticateList struct {
9 | SIPHeaderList
10 | }
11 |
12 | /**
13 | * constructor.
14 | */
15 | func NewWWWAuthenticateList() *WWWAuthenticateList {
16 | this := &WWWAuthenticateList{}
17 | this.SIPHeaderList.super(core.SIPHeaderNames_WWW_AUTHENTICATE)
18 | return this
19 | }
20 |
--------------------------------------------------------------------------------
/sip/header/WarningList.go:
--------------------------------------------------------------------------------
1 | package header
2 |
3 | import "gosips/core"
4 |
5 | /**
6 | * A Warning SIPObject. (A list of Warning headers).
7 | */
8 | type WarningList struct {
9 | SIPHeaderList
10 | }
11 |
12 | /** Constructor.
13 | *
14 | */
15 | func NewWarningList() *WarningList {
16 | this := &WarningList{}
17 | this.SIPHeaderList.super(core.SIPHeaderNames_WARNING)
18 | return this
19 | }
20 |
--------------------------------------------------------------------------------
/sip/parser/AcceptEncodingParser_test.go:
--------------------------------------------------------------------------------
1 | package parser
2 |
3 | import (
4 | "testing"
5 | )
6 |
7 | func TestAcceptEncodingParser(t *testing.T) {
8 | var tvi = []string{
9 | "Accept-Encoding: compress,gzip\n",
10 | "Accept-Encoding:\n",
11 | "Accept-Encoding: *\n",
12 | "Accept-Encoding: compress;q=0.5,gzip;q=1.0\n",
13 | "Accept-Encoding: gzip;q=1.0,identity;q=0.5,*;q=0\n",
14 | }
15 | var tvo = []string{
16 | "Accept-Encoding: compress,gzip\n",
17 | "Accept-Encoding:\n",
18 | "Accept-Encoding: *\n",
19 | "Accept-Encoding: compress;q=0.5,gzip;q=1\n",
20 | "Accept-Encoding: gzip;q=1,identity;q=0.5,*;q=0\n",
21 | }
22 |
23 | for i := 0; i < len(tvi); i++ {
24 | shp := NewAcceptEncodingParser(tvi[i])
25 | testHeaderParser(t, shp, tvo[i])
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/sip/parser/AcceptLanguageParser_test.go:
--------------------------------------------------------------------------------
1 | package parser
2 |
3 | import (
4 | "testing"
5 | )
6 |
7 | func TestAcceptLanguageParser(t *testing.T) {
8 | var tvi = []string{
9 | "Accept-Language: da \n",
10 | "Accept-Language: \n",
11 | "Accept-Language: da,en-gb;q=0.8\n",
12 | "Accept-Language: * \n"}
13 | var tvo = []string{
14 | "Accept-Language: da \n",
15 | "Accept-Language: \n",
16 | "Accept-Language: da,en-gb;q=0.8\n",
17 | "Accept-Language: * \n"}
18 |
19 | for i := 0; i < len(tvi); i++ {
20 | shp := NewAcceptLanguageParser(tvi[i])
21 | testHeaderParser(t, shp, tvo[i])
22 | }
23 | }
24 |
25 | /**
26 | public static void main(String args[]) throws ParseException {
27 | String acceptLanguage[] = {
28 | "Accept-Language: da \n",
29 | "Accept-Language:\n",
30 | "Accept-Language: da, en-gb;q=0.8\n",
31 | "Accept-Language: *\n" };
32 |
33 | for (int i =0 ; i < acceptLanguage.length; i++) {
34 | AcceptLanguageParser alp = new AcceptLanguageParser
35 | (acceptLanguage[i]);
36 | AcceptLanguageList all = (AcceptLanguageList)
37 | alp.parse();
38 | System.out.println(all.toString());
39 | }
40 | }
41 | **/
42 |
--------------------------------------------------------------------------------
/sip/parser/AcceptParser_test.go:
--------------------------------------------------------------------------------
1 | package parser
2 |
3 | import (
4 | "testing"
5 | )
6 |
7 | func TestAcceptParser(t *testing.T) {
8 | var tvi = []string{
9 | "Accept: application/sdp;level=1,application/x-private,text/html\n",
10 | }
11 | var tvo = []string{
12 | "Accept: application/sdp;level=1,application/x-private,text/html\n",
13 | }
14 |
15 | for i := 0; i < len(tvi); i++ {
16 | shp := NewAcceptParser(tvi[i])
17 | testHeaderParser(t, shp, tvo[i])
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/sip/parser/AddressParametersParser.go:
--------------------------------------------------------------------------------
1 | package parser
2 |
3 | import (
4 | "gosips/core"
5 | "gosips/sip/address"
6 | "gosips/sip/header"
7 | )
8 |
9 | /** Address parameters parser.
10 | */
11 | type AddressParametersParser struct {
12 | ParametersParser
13 | }
14 |
15 | func NewAddressParametersParserFromLexer(lexer core.Lexer) *AddressParametersParser {
16 | this := &AddressParametersParser{}
17 | this.ParametersParser.superFromLexer(lexer)
18 | return this
19 | }
20 |
21 | func NewAddressParametersParser(buffer string) *AddressParametersParser {
22 | this := &AddressParametersParser{}
23 | this.ParametersParser.super(buffer)
24 | return this
25 | }
26 |
27 | func (this *AddressParametersParser) super(buffer string) {
28 | this.ParametersParser.super(buffer)
29 | }
30 |
31 | func (this *AddressParametersParser) superFromLexer(lexer core.Lexer) {
32 | this.ParametersParser.superFromLexer(lexer)
33 | }
34 |
35 | func (this *AddressParametersParser) Parse(addressParametersHeader header.AddressParametersHeader) (ParseException error) {
36 | addressParser := NewAddressParserFromLexer(this.GetLexer())
37 | var addr *address.AddressImpl
38 | if addr, ParseException = addressParser.Address(); ParseException != nil {
39 | return ParseException
40 | }
41 | addressParametersHeader.SetAddress(addr)
42 | ParseException = this.ParametersParser.Parse(addressParametersHeader)
43 | return ParseException
44 | }
45 |
--------------------------------------------------------------------------------
/sip/parser/AddressParser_test.go:
--------------------------------------------------------------------------------
1 | package parser
2 |
3 | import (
4 | "strings"
5 | "testing"
6 | )
7 |
8 | func TestAddressParser(t *testing.T) {
9 | var tvi = []string{
10 | "