]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Sockets/GetServByPort/GetServByPort.c
2 Translate the port number into a service name
4 Copyright (c) 2011, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #include <Library/DebugLib.h>
23 #include <Library/UefiLib.h>
25 #include <sys/socket.h>
31 Translate the port number into a service name
33 @param [in] Argc The number of arguments
34 @param [in] Argv The argument value array
36 @retval 0 The application exited normally.
37 @retval Other An error occurred.
47 struct servent
* pService
;
50 // Determine if the service name is specified
54 || ( 1 != sscanf ( Argv
[1], "%d", &PortNumber
))) {
55 Print ( L
"%a <port number>\r\n", Argv
[0]);
59 // Translate the port number
61 pService
= getservbyport ( htons ( PortNumber
), NULL
);
62 if ( NULL
== pService
) {
63 Print ( L
"ERROR - service not found, errno: %d\r\n", errno
);
66 Print ( L
"%a: %d, %a\r\n",