Ignore:
Timestamp:
2024-12-13T08:44:05Z (15 months ago)
Author:
Nataliia Korop <n.corop08@…>
Children:
e5b2777
Parents:
467d2b9
git-author:
Nataliia Korop <n.corop08@…> (2024-11-16 11:14:06)
git-committer:
Nataliia Korop <n.corop08@…> (2024-12-13 08:44:05)
Message:

set ops as number and with start req

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/pcap/src/pcapdump_client.c

    r467d2b9 re1e8f7a  
    4141#include <ctype.h>
    4242#include "pcapdump_client.h"
    43 #include "pcapdump_srv.h"
     43#include "pcapdump_ipc.h"
    4444
    4545/** Finish an async exchange on the pcapctl session
     
    100100        }
    101101        if (*index + 1 > (int)count || *index < 0) {
     102                return EINVAL;
     103        }
     104        return EOK;
     105}
     106
     107
     108errno_t pcapctl_is_valid_ops_number(int *index, pcapctl_sess_t* sess)
     109{
     110        async_exch_t *exch = async_exchange_begin(sess->sess);
     111        ipc_call_t answer;
     112        aid_t req = async_send_0(exch, PCAP_CONTROL_GET_OPS_NUM, &answer);
     113
     114        async_exchange_end(exch);
     115
     116        errno_t retval;
     117        async_wait_for(req, &retval);
     118
     119        if (retval != EOK) {
     120                return retval;
     121        }
     122
     123        int ops_count = (int)ipc_get_arg1(&answer);
     124        if (*index + 1 > ops_count || *index < 0)
     125        {
    102126                return EINVAL;
    103127        }
     
    149173                return ENOMEM;
    150174
    151         printf("number: %d\n", *index);
    152175        if (*index == -1) {
    153176                *index = 0;
     
    190213 * @return EOK on success or an error code
    191214 */
    192 errno_t pcapctl_dump_start(const char *name, pcapctl_sess_t *sess)
     215errno_t pcapctl_dump_start(const char *name, int *ops_index, pcapctl_sess_t *sess)
    193216{
    194217        errno_t rc;
     
    196219
    197220        size_t size = str_size(name);
    198         aid_t req = async_send_0(exch, PCAP_CONTROL_SET_START, NULL);
     221        aid_t req = async_send_1(exch, PCAP_CONTROL_SET_START, *ops_index, NULL);
    199222
    200223        rc = async_data_write_start(exch, name, size);
     
    227250}
    228251
    229 errno_t pcapctl_dump_set_ops(const char *ops_name, pcapctl_sess_t *sess)
    230 {
    231         errno_t rc;
    232         async_exch_t *exch = async_exchange_begin(sess->sess);
    233 
    234         size_t size = str_size(ops_name);
    235         aid_t req = async_send_0(exch, PCAP_CONTROL_SET_OPS, NULL);
    236 
    237         rc = async_data_write_start(exch, ops_name, size);
    238 
    239         pcapctl_dump_exchange_end(exch);
    240 
    241         if (rc != EOK) {
    242                 async_forget(req);
    243                 return rc;
    244         }
    245 
    246         errno_t retval;
    247         async_wait_for(req, &retval);
    248         return retval;
    249 }
    250252
    251253/** @}
Note: See TracChangeset for help on using the changeset viewer.