| 924 | } |
| 925 | |
| 926 | int |
| 927 | debugnet_parse_ddb_cmd(const char *cmd, struct debugnet_ddb_config *result) |
| 928 | { |
| 929 | struct ifnet *ifp; |
| 930 | int t, error; |
| 931 | bool want_ifp; |
| 932 | char ch; |
| 933 | |
| 934 | struct my_inet_opt opt_client = { |
| 935 | .printname = "client", |
| 936 | .result = &result->dd_client, |
| 937 | }, |
| 938 | opt_server = { |
| 939 | .printname = "server", |
| 940 | .result = &result->dd_server, |
| 941 | }, |
| 942 | opt_gateway = { |
| 943 | .printname = "gateway", |
| 944 | .result = &result->dd_gateway, |
| 945 | }, |
| 946 | *cur_inet_opt; |
| 947 | |
| 948 | ifp = NULL; |
| 949 | memset(result, 0, sizeof(*result)); |
| 950 | |
| 951 | /* |
| 952 | * command [space] [-] [opt] [[space] [optarg]] ... |
| 953 | * |
| 954 | * db_command has already lexed 'command' for us. |
| 955 | */ |
| 956 | t = db_read_token_flags(DRT_WSPACE); |
| 957 | if (t == tWSPACE) |
| 958 | t = db_read_token_flags(DRT_WSPACE); |
| 959 | |
| 960 | while (t != tEOL) { |
| 961 | if (t != tMINUS) { |
| 962 | db_printf("%s: Bad syntax; expected '-', got %d\n", |
| 963 | cmd, t); |
| 964 | goto usage; |
| 965 | } |
| 966 | |
| 967 | t = db_read_token_flags(DRT_WSPACE); |
| 968 | if (t != tIDENT) { |
| 969 | db_printf("%s: Bad syntax; expected tIDENT, got %d\n", |
| 970 | cmd, t); |
| 971 | goto usage; |
| 972 | } |
| 973 | |
| 974 | if (strlen(db_tok_string) > 1) { |
| 975 | db_printf("%s: Bad syntax; expected single option " |
| 976 | "flag, got '%s'\n", cmd, db_tok_string); |
| 977 | goto usage; |
| 978 | } |
| 979 | |
| 980 | want_ifp = false; |
| 981 | cur_inet_opt = NULL; |
| 982 | switch ((ch = db_tok_string[0])) { |
| 983 | default: |
no test coverage detected