• Home
  • Raw
  • Download

Lines Matching +full:localhost +full:- +full:test +full:- +full:linux

1 LTP C Test Network API
5 … https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines[Test Writing Guidelines],
6 https://github.com/linux-test-project/ltp/wiki/C-Test-Case-Tutorial[C Test Case Tutorial],
7 https://github.com/linux-test-project/ltp/wiki/C-Test-API[C Test API],
8 https://github.com/linux-test-project/ltp/wiki/Shell-Test-API[Shell Test API].
14 ---------------------
24 https://github.com/linux-test-project/ltp/wiki/C-Test-API[C Test API]. The
29 - +SAFE_SOCKET()+
30 - +SAFE_SOCKETPAIR()+
31 - +SAFE_GETSOCKOPT()+
32 - +SAFE_SETSOCKOPT()+
33 - +SAFE_BIND()+
34 - +SAFE_LISTEN()+
35 - +SAFE_ACCEPT()+
36 - +SAFE_CONNECT()+
37 - +SAFE_GETSOCKNAME()+
38 - +SAFE_GETHOSTNAME()+
39 - +SAFE_GETADDRINFO()+
47 ** If +strict+ is non-zero, the return value must be equal to the data length
48 argument. Otherwise the test will fail and exit.
53 ** If +msg_len+ is non-zero, the return value must be equal to the +msg_len+
54 argument. Otherwise the test will fail and exit.
58 - +int SAFE_SETSOCKOPT_INT(int sockfd, int level, int optname, int value)+ –
61 - +int TST_GETSOCKPORT(int sockfd)+ – Get port number (in host byte order) of a
64 - +unsigned short TST_GET_UNUSED_PORT(int family, int type)+ – Get a random
67 the test is still running. The test user is responsible for setting up test
78 - +void tst_get_in_addr(const char *ip_str, struct in_addr *ip)+ – Convert
79 human-readable IPv4 address string +ip_str+ to binary representation in
82 - +void tst_get_in6_addr(const char *ip_str, struct in6_addr *ip6)+ – Convert
83 human-readable IPv6 address string +ip_str+ to binary representation in
86 - +socklen_t tst_get_connect_address(int sock, struct sockaddr_storage *addr)+ –
89 function automatically converts wildcard bind address to localhost. Returns
92 - +void tst_init_sockaddr_inet(struct sockaddr_in *sa, const char *ip_str,
94 human-readable IPv4 address +ip_str+ and port number +port+ in host byte
97 - +void tst_init_sockaddr_inet_bin(struct sockaddr_in *sa, uint32_t ip_val,
101 - +void tst_init_sockaddr_inet6(struct sockaddr_in6 *sa, const char *ip_str,
103 human-readable IPv6 address +ip_str+ and port number +port+ in host byte
106 - +void tst_init_sockaddr_inet6_bin(struct sockaddr_in6 *sa, const struct
114 -------------------------------------------------------------------------------
123 static int sockfd = -1;
136 -------------------------------------------------------------------------------
139 -----------------------------
143 When opening a localhost socket isn't enough and the test needs special device
149 otherwise. Error values described below are returned only during test cleanup
155 - +int NETDEV_INDEX_BY_NAME(const char *ifname)+ – Returns the device index for
156 the given device name, or -1 on error.
158 - +int NETDEV_SET_STATE(const char *ifname, int up)+ – Enable or disable a
159 network device +ifname+. Returns 0 on success, -1 on error.
161 - +int CREATE_VETH_PAIR(const char *ifname1, const char *ifname2)+ – Creates a
163 on success, 0 on error. Add +"CONFIG_VETH"+ to +test.needs_kconfigs+ if your
164 test calls this function.
166 - +int NETDEV_ADD_DEVICE(const char *ifname, const char *devtype)+ - Creates
170 - +int NETDEV_REMOVE_DEVICE(const char *ifname)+ – Removes network device
176 - +int NETDEV_ADD_ADDRESS(const char \*ifname, unsigned int family, const void
178 new address to network device +ifname+. This is a low-level function which
185 - +int NETDEV_ADD_ADDRESS_INET(const char *ifname, in_addr_t address, unsigned
190 - +int NETDEV_REMOVE_ADDRESS(const char *ifname, unsigned int family, const
195 - +int NETDEV_REMOVE_ADDRESS_INET(const char *ifname, in_addr_t address)+ –
206 - +int NETDEV_CHANGE_NS_FD(const char *ifname, int nsfd)+ – Moves network
210 - +int NETDEV_CHANGE_NS_PID(const char *ifname, pid_t nspid)+ – Moves network
217 - +int NETDEV_ADD_ROUTE(const char *ifname, unsigned int family, const void
220 gatewaylen)+ – Adds new route to the main routing table. This is a low-level
229 - +int NETDEV_ADD_ROUTE_INET(const char *ifname, in_addr_t srcaddr, unsigned
237 - +int NETDEV_REMOVE_ROUTE(const char *ifname, unsigned int family, const void
244 - +int NETDEV_REMOVE_ROUTE_INET(const char *ifname, in_addr_t srcaddr,
253 -------------------------------------------------------------------------------
255 #include <linux/if_addr.h>
275 -------------------------------------------------------------------------------
278 -------------
286 otherwise. Error values described below are returned only during test cleanup
293 -------------------------------------------------------------------------------
309 -------------------------------------------------------------------------------
321 - +type+ is the attribute type that will be stored in +struct nlattr.nla_type+
324 - +data+ contains arbitrary attribute payload.
326 - +len+ contains length of the +data+ attribute in bytes. If +data+ is +NULL+,
329 - +sublist+ contains a nested attribute list which will be appended after
340 - +header+ is the netlink header structure of the message. +NULL+ in the header
343 - +err+ points to the payload of +NLMSG_ERROR+ messages. It is set to +NULL+
346 - +payload+ is a pointer to message data.
348 - +payload_size+ is the length of +payload+ data in bytes.
353 - +struct tst_netlink_context *NETLINK_CREATE_CONTEXT(int protocol)+ – Creates
357 - +void NETLINK_FREE_MESSAGE(struct tst_netlink_message *msg)+ – Frees
360 - +void NETLINK_DESTROY_CONTEXT(struct tst_netlink_context *ctx)+ – Closes a
363 - +int NETLINK_SEND(struct tst_netlink_context *ctx)+ – Sends all messages
368 - +int NETLINK_SEND_VALIDATE(struct tst_netlink_context *ctx)+ – Sends all
372 return error status without terminating the test if one of the received
376 - +int NETLINK_WAIT(struct tst_netlink_context *ctx)+ – Waits until data becomes
378 if there is data to read, 0 on timeout or -1 on error.
380 - +struct tst_netlink_message *NETLINK_RECV(struct tst_netlink_context *ctx)+ –
382 in non-blocking mode so calling +NETLINK_WAIT()+ first is recommended.
388 - +int NETLINK_CHECK_ACKS(struct tst_netlink_context *ctx,
395 this function will call +tst_brk()+ (or return 0 during test cleanup phase).
396 If any of the response messages has non-zero error code, this function will
397 return 0 and store the first non-zero error code in global variable
398 +tst_netlink_errno+ (sign-flipped just like regular libc +errno+).
403 - +int NETLINK_ADD_MESSAGE(struct tst_netlink_context *ctx, const struct
416 - +int NETLINK_ADD_ATTR(struct tst_netlink_context *ctx, unsigned short type,
424 - +int NETLINK_ADD_ATTR_STRING(struct tst_netlink_context *ctx, unsigned short
430 - +int NETLINK_ADD_ATTR_LIST(struct tst_netlink_context *ctx, const struct
435 counted), -1 on error.
437 - +int RTNL_ADD_ATTR(struct tst_netlink_context *ctx, unsigned short type,
445 - +int RTNL_ADD_ATTR_STRING(struct tst_netlink_context *ctx, unsigned short
451 - +int RTNL_ADD_ATTR_LIST(struct tst_netlink_context *ctx, const struct
456 counted), -1 on error.
461 -------------------------------------------------------------------------------
463 #include <linux/netlink.h>
464 #include <linux/rtnetlink.h>
506 -------------------------------------------------------------------------------