1 /* 2 * Conditions Of Use 3 * 4 * This software was developed by employees of the National Institute of 5 * Standards and Technology (NIST), an agency of the Federal Government. 6 * Pursuant to title 15 Untied States Code Section 105, works of NIST 7 * employees are not subject to copyright protection in the United States 8 * and are considered to be in the public domain. As a result, a formal 9 * license is not needed to use the software. 10 * 11 * This software is provided by NIST as a service and is expressly 12 * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED 13 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF 14 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT 15 * AND DATA ACCURACY. NIST does not warrant or make any representations 16 * regarding the use of the software or the results thereof, including but 17 * not limited to the correctness, accuracy, reliability or usefulness of 18 * the software. 19 * 20 * Permission to use this software is contingent upon your acceptance 21 * of the terms of this agreement 22 * 23 * . 24 * 25 */ 26 /************************************************************************************************ 27 * PRODUCT OF PT INOVACAO - EST DEPARTMENT and Telecommunications Institute (Aveiro, Portugal) * 28 ************************************************************************************************/ 29 30 package gov.nist.javax.sip.parser.ims; 31 32 33 import java.text.ParseException; 34 35 import gov.nist.javax.sip.header.ims.PAccessNetworkInfo; 36 import gov.nist.javax.sip.header.ims.SIPHeaderNamesIms; 37 import gov.nist.core.Token; 38 import gov.nist.core.NameValue; 39 import gov.nist.javax.sip.header.SIPHeader; 40 import gov.nist.javax.sip.parser.HeaderParser; 41 import gov.nist.javax.sip.parser.Lexer; 42 import gov.nist.javax.sip.parser.ParametersParser; 43 import gov.nist.javax.sip.parser.TokenTypes; 44 45 46 /** 47 * P-Access-Network-Info header parser. 48 * 49 * <p>RFC 3455 - Private Header (P-Header) Extensions to the Session Initiation 50 * Protocol (SIP) for the 3rd-Generation Partnership Project (3GPP) </p> 51 * 52 * <p>Sintax (RFC 3455):</p> 53 * <pre> 54 * P-Access-Network-Info = "P-Access-Network-Info" HCOLON access-net-spec 55 * access-net-spec = access-type *(SEMI access-info) 56 * access-type = "IEEE-802.11a" / "IEEE-802.11b" / 57 * "3GPP-GERAN" / "3GPP-UTRAN-FDD" / 58 * "3GPP-UTRAN-TDD" / "3GPP-CDMA2000" / token 59 * access-info = cgi-3gpp / utran-cell-id-3gpp / extension-access-info 60 * extension-access-info = gen-value 61 * cgi-3gpp = "cgi-3gpp" EQUAL (token / quoted-string) 62 * utran-cell-id-3gpp = "utran-cell-id-3gpp" EQUAL (token / quoted-string) 63 * </pre> 64 * 65 * @author Miguel Freitas (IT) PT-Inovacao 66 */ 67 68 69 public class PAccessNetworkInfoParser 70 extends HeaderParser 71 implements TokenTypes 72 { 73 PAccessNetworkInfoParser(String accessNetwork)74 public PAccessNetworkInfoParser(String accessNetwork) { 75 76 super(accessNetwork); 77 78 } 79 80 PAccessNetworkInfoParser(Lexer lexer)81 protected PAccessNetworkInfoParser(Lexer lexer) { 82 super(lexer); 83 84 } 85 86 parse()87 public SIPHeader parse() throws ParseException 88 { 89 90 if (debug) 91 dbg_enter("AccessNetworkInfoParser.parse"); 92 try { 93 headerName(TokenTypes.P_ACCESS_NETWORK_INFO); 94 PAccessNetworkInfo accessNetworkInfo = new PAccessNetworkInfo(); 95 accessNetworkInfo.setHeaderName(SIPHeaderNamesIms.P_ACCESS_NETWORK_INFO); 96 97 this.lexer.SPorHT(); 98 lexer.match(TokenTypes.ID); 99 Token token = lexer.getNextToken(); 100 accessNetworkInfo.setAccessType(token.getTokenValue()); 101 102 this.lexer.SPorHT(); 103 while (lexer.lookAhead(0) == ';') { 104 this.lexer.match(';'); 105 this.lexer.SPorHT(); 106 107 NameValue nv = super.nameValue('='); 108 accessNetworkInfo.setParameter(nv); 109 this.lexer.SPorHT(); 110 } 111 this.lexer.SPorHT(); 112 this.lexer.match('\n'); 113 114 115 return accessNetworkInfo; 116 } finally { 117 if (debug) 118 dbg_leave("AccessNetworkInfoParser.parse"); 119 } 120 121 } 122 123 124 125 126 } 127