From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.arccn.ru (vpn.arccn.ru [95.182.74.2]) by dpdk.org (Postfix) with SMTP id 26F9D7E75 for ; Fri, 14 Nov 2014 12:37:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.arccn.ru (Postfix) with ESMTP id 433CDA0092 for ; Fri, 14 Nov 2014 15:47:24 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=arccn.ru; h= x-mailer:to:references:message-id:content-transfer-encoding:date :date:in-reply-to:from:from:subject:subject:mime-version :content-type:content-type; s=dkim; t=1415965636; x=1416829636; bh=fC+8FWbQxiIAwmiiiZV1co+p0blvxAzG97d9kV+KusE=; b=s+lTggybvG6t uwAPeTW8LyxC4SMo78mMbc5raD0CVVwUwuR809TdmrW9n+plRSE+FhpWkQkxK8tx ah79ok9olQGob1juqH/RyJ42FlcrxMaaR+67nDNHDzc2cTQRUa/sEujIz+Cbz8FC RM3oxrdXqkuLutjnGTXeZRe+r+qFljg= X-Virus-Scanned: Debian amavisd-new at mail.arccn.ru Received: from mail.arccn.ru ([127.0.0.1]) by localhost (mail.arccn.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WusYj3-JgCOT for ; Fri, 14 Nov 2014 14:47:16 +0300 (MSK) Received: from [10.30.40.85] (unknown [10.30.40.85]) by mail.arccn.ru (Postfix) with ESMTPSA id 95DC4A0091; Fri, 14 Nov 2014 14:47:16 +0300 (MSK) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) From: Igor Ryzhov In-Reply-To: <5465E3F8.5070606@6wind.com> Date: Fri, 14 Nov 2014 14:47:14 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <5465E3F8.5070606@6wind.com> To: Olivier MATZ X-Mailer: Apple Mail (2.1990.1) Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] Question about librte_cmdline X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Nov 2014 11:37:21 -0000 Thank you. That=E2=80=99s not a really big problem that we need it=E2=80=99s own = structure for every command, but the lack of optional parameters is a = problem. For example: object add IP [port] it=E2=80=99s just one command, but we need two different = structures - with and without =C2=ABport=C2=BB Maybe I=E2=80=99ll work on it sometime later. > 14 =D0=BD=D0=BE=D1=8F=D0=B1. 2014 =D0=B3., =D0=B2 14:14, Olivier MATZ = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0= ): >=20 > Hi Igor, >=20 > Adding-back the list to the discussion, I removed it by mistake in my > first answer. >=20 >>> 14 =D0=BD=D0=BE=D1=8F=D0=B1. 2014 =D0=B3., =D0=B2 12:20, Olivier = MATZ =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0= =B0): >>>=20 >>> Hi Igor, >>>=20 >>> On 11/14/2014 09:52 AM, Igor Ryzhov wrote: >>>> Are there any docs with detailed description of cmdline library? >>>> I found only some information in =C2=ABDPDK Sample Apps=C2=BB = document, but it describes only a couple of features. >>>=20 >>> In my knowledge, there is no such documentation. >>> You can also refer to testpmd that gives a lot of different = commands. >>>=20 >>> If you have any question, you can ask on the list. >>>=20 >>> Regards, >>> Olivier >>=20 >> Thank you, I=E2=80=99ll check testpmd. >>=20 >> At the moment I have a question - is there a possibility to have = optional tokens in one command? >>=20 >> For example: >>=20 >> I have one command - =C2=ABobject=C2=BB and two subcommands - =C2=ABadd= =C2=BB and =C2=ABdel=C2=BB: >>=20 >> object add name IP >> object del name >>=20 >> And the question is - can I have just one context instruction for = this? Something like that: >>=20 >> Result struct: >>=20 >> struct object_result { >> cmdline_fixed_string_t object; >> cmdline_fixed_string_t cmd; >> cmdline_fixed_string_t name; >> cmdline_ipaddr_t ip; // I need it optional - = only for =C2=ABadd=C2=BB case >> } >>=20 >> And tokens: >>=20 >> cmdline_parse_token_string_t object =3D >> TOKEN_STRING_INITIALIZER(struct object_result, object, = "object"); >> cmdline_parse_token_string_t cmd =3D >> TOKEN_STRING_INITIALIZER(struct object_result, cmd, "add#del"); >> cmdline_parse_token_string_t name =3D >> TOKEN_STRING_INITIALIZER(struct object_result, name, NULL); >> cmdline_parse_token_ipaddr_t ip =3D >> TOKEN_IPV4_INITIALIZER(struct object_result, ip, NULL); >>=20 >> As I understand investigating the code of sample application - all = tokens are required (because there are two different instructions - for = =C2=ABadd=C2=BB and for =C2=ABdel/show=C2=BB). >> And in this example configuration there is no possibility for string = =C2=ABobject del name=C2=BB without last IP token. >> So I need to have two different context instructions - one for = =C2=ABadd=C2=BB and one for =C2=ABdel=C2=BB. >> Am I right? >=20 > Right, there is no way to declare an optional token in one = instruction. > But if there are few case (ex: a "set" and a "show" intructions), you > can factorize the structure and the callback function. There is an > example in my latest TSO patch: > http://dpdk.org/ml/archives/dev/2014-November/007962.html >=20 > Regards, > Olivier