├── CMakeLists.txt ├── COPYING ├── README.md ├── Uninstall.cmake ├── config.h.in ├── libvdeslirp.c ├── libvdeslirp.h ├── man ├── CMakeLists.txt ├── Makefile ├── libvdeslirp.3 ├── libvdeslirp.3.md ├── libvdeslirpcfg.3 ├── libvdeslirpcfg.3.md ├── libvdeslirpfwd.3 ├── libvdeslirpfwd.3.md ├── vdeslirp_add_cmdexec.3 ├── vdeslirp_add_fwd.3 ├── vdeslirp_add_unixfwd.3 ├── vdeslirp_close.3 ├── vdeslirp_fd.3 ├── vdeslirp_init.3 ├── vdeslirp_open.3 ├── vdeslirp_recv.3 ├── vdeslirp_remove_fwd.3 ├── vdeslirp_remove_unixfwd.3 ├── vdeslirp_send.3 ├── vdeslirp_setvprefix.3 └── vdeslirp_setvprefix6.3 └── vdeslirp.pc.in /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | project("vdeslirp" 3 | DESCRIPTION "libslirp for Linux made easy peasy" 4 | HOMEPAGE_URL "https://github.com/rd235/libvdeslirp" 5 | VERSION 0.1.1 6 | LANGUAGES C) 7 | 8 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2 -O2 -pedantic -Wall -Wextra") 9 | 10 | include(GNUInstallDirs) 11 | include(CheckIncludeFile) 12 | include(CheckSymbolExists) 13 | 14 | set(LIBS_REQUIRED slirp pthread) 15 | set(HEADERS_REQUIRED libvdeplug.h slirp/libslirp.h) 16 | set(CMAKE_REQUIRED_QUIET TRUE) 17 | set(CMAKE_REQUIRED_LIBRARIES slirp) 18 | 19 | check_symbol_exists("slirp_add_exec" "slirp/libslirp.h" HAS_ADD_EXEC) 20 | check_symbol_exists("slirp_add_unix" "slirp/libslirp.h" HAS_ADD_UNIX) 21 | check_symbol_exists("slirp_remove_guestfwd" "slirp/libslirp.h" HAS_REMOVE_GUESTFWD) 22 | 23 | foreach(THISLIB IN LISTS LIBS_REQUIRED) 24 | find_library(LIB${THISLIB}_OK ${THISLIB}) 25 | if(NOT LIB${THISLIB}_OK) 26 | message(FATAL_ERROR "library lib${THISLIB} not found") 27 | endif() 28 | endforeach(THISLIB) 29 | 30 | foreach(HEADER IN LISTS HEADERS_REQUIRED) 31 | check_include_file(${HEADER} ${HEADER}_OK) 32 | if(NOT ${HEADER}_OK) 33 | message(FATAL_ERROR "header file ${HEADER} not found") 34 | endif() 35 | endforeach(HEADER) 36 | 37 | add_definitions(-D_GNU_SOURCE) 38 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 39 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) 40 | 41 | add_library(vdeslirp SHARED libvdeslirp.c) 42 | target_link_libraries(vdeslirp slirp pthread) 43 | 44 | set_target_properties(vdeslirp PROPERTIES VERSION ${PROJECT_VERSION} 45 | SOVERSION ${PROJECT_VERSION_MAJOR}) 46 | 47 | configure_file(vdeslirp.pc.in vdeslirp.pc @ONLY) 48 | configure_file(config.h.in config.h) 49 | 50 | install(TARGETS vdeslirp DESTINATION ${CMAKE_INSTALL_LIBDIR}) 51 | install(FILES libvdeslirp.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/slirp) 52 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/vdeslirp.pc 53 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 54 | 55 | add_subdirectory(man) 56 | 57 | add_custom_target(uninstall 58 | "${CMAKE_COMMAND}" -P "${PROJECT_SOURCE_DIR}/Uninstall.cmake") 59 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libvdeslirp 2 | libslirp for Linux made easy peasy 3 | 4 | ## Slirp 5 | 6 | Originally designed to provide PPP/SLIP over terminal lines, slirp is a general purpose TCP-IP emulator widely used 7 | by virtual machine hypervisors to provide virtual networking services. 8 | 9 | Qemu, virtualbox, user-mode linux include slirp to provide the guest os with a virtual network while requiring neither 10 | configuration nor privileged services on the host. 11 | 12 | The qemu team has split their implementation of slirp from the main Qemu project and released it as a library 13 | named `libslirp`. 14 | 15 | This project wraps the libslirp code in a library featuring a clean and simple interface. 16 | 17 | ## Installation Prerequisites: 18 | 19 | [libslirp](https://gitlab.freedesktop.org/slirp/libslirp). 20 | 21 | Libslirp can be installed from its git repository. 22 | Alternatively, it is a package in Debian Sid thus users of this distribution can simply add the packet: 23 | 24 | ```sh 25 | apt-get install libslirp0 libslirp-dev 26 | ``` 27 | 28 | ## install libvdeslirp 29 | 30 | ```sh 31 | $ mkdir build 32 | $ cd build 33 | $ cmake .. 34 | $ make 35 | $sudo make install 36 | ``` 37 | 38 | ## libvdeslirp tutorial 39 | 40 | ### libvdesplirp's Hello World 41 | 42 | The simplest way to use the library is the following: 43 | 44 | setup: 45 | ```C 46 | #include 47 | ... 48 | SlirpConfig slirpcfg; 49 | struct vdeslirp *myslirp; 50 | vdeslirp_init(&slirpcfg, VDE_INIT_DEFAULT); 51 | myslirp = vdeslirp_open(&slirpcfg); 52 | ``` 53 | send and receive packets (ethernet packets as if it were a tap interface): 54 | ```C 55 | n = vdeslirp_send(myslirp, sendbuf, sendlen); 56 | ... 57 | n = vdeslirp_recv(myslirp, recvbuf, recvlen); 58 | ``` 59 | 60 | poll/select or similar system calls can be used to wait for new incoming packets, 61 | use the return value of `vdeslirp_fd(myslirp)` as the file descriptor. 62 | 63 | at the end: 64 | ```C 65 | vdeslirp_close(myslirp); 66 | ``` 67 | ## step by step tutorial 68 | 69 | ### step 1: include the header file 70 | 71 | ```C 72 | #include 73 | ``` 74 | 75 | ### step 2: set up slirp configuration 76 | 77 | The confuguration parameters for Slirp are defined in a `SlirpConfig` structure (as defined by libslirp): 78 | ```C 79 | typedef struct SlirpConfig { 80 | /* Version must be provided */ 81 | uint32_t version; 82 | /* 83 | * Fields introduced in SlirpConfig version 1 begin 84 | */ 85 | int restricted; 86 | bool in_enabled; 87 | struct in_addr vnetwork; 88 | struct in_addr vnetmask; 89 | struct in_addr vhost; 90 | bool in6_enabled; 91 | struct in6_addr vprefix_addr6; 92 | uint8_t vprefix_len; 93 | struct in6_addr vhost6; 94 | const char *vhostname; 95 | const char *tftp_server_name; 96 | const char *tftp_path; 97 | const char *bootfile; 98 | struct in_addr vdhcp_start; 99 | struct in_addr vnameserver; 100 | struct in6_addr vnameserver6; 101 | const char **vdnssearch; 102 | const char *vdomainname; 103 | /* Default: IF_MTU_DEFAULT */ 104 | size_t if_mtu; 105 | /* Default: IF_MRU_DEFAULT */ 106 | size_t if_mru; 107 | /* Prohibit connecting to 127.0.0.1:* */ 108 | bool disable_host_loopback; 109 | /* 110 | * Enable emulation code (*warning*: this code isn't safe, it is not 111 | * recommended to enable it) 112 | */ 113 | bool enable_emu; 114 | /* 115 | * Fields introduced in SlirpConfig version 2 begin 116 | */ 117 | } SlirpConfig; 118 | ``` 119 | 120 | Programmers can set all the fields one by one if they wish. libvdeslirp provides some functions to ease this task. 121 | 122 | ```C 123 | void vdeslirp_init(SlirpConfig *cfg, int flags); 124 | ``` 125 | 126 | The simplest way to set up a `SlirpConfig` structure is: 127 | 128 | ```C 129 | SlirpConfig slirpcfg; 130 | vdeslirp_init(&slirpcfg, VDE_INIT_DEFAULT); 131 | ``` 132 | 133 | This provides suitable default values for all the parameters: 134 | ``` 135 | SLIRP configuration 136 | version 1 137 | ipv4-enable 1 138 | ipv4-network 10.0.2.0 139 | ipv4-netmask 255.255.255.0 140 | ipv4-host 10.0.2.2 141 | ipv6-enabled 1 142 | ipv6-prefix fd00:: 143 | ipv6-preflen 64 144 | ipv6-host fd00::2 145 | hostname slirp 146 | tftp-servname (null) 147 | tftp-path (null) 148 | bootfile (null) 149 | dhcp-start 10.0.2.15 150 | ipv4-vDNS 10.0.2.3 151 | ipv6-vDNS fd00::3 152 | vDNS-search 153 | vdomainname (null) 154 | MTU(0=def) 0 155 | MTU(0=def) 0 156 | disable-lback 0 157 | enable-emu 0 158 | ``` 159 | 160 | Obviously, each field of the structure can be updated to fit the usage needs. 161 | 162 | A different approach is to initialize an empty structure and then set the fields one by one. 163 | The following code cleans the slirpcfg structure (just the version field is set to 1. 164 | ```C 165 | SlirpConfig slirpcfg; 166 | vdeslirp_init(&slirpcfg, 0); 167 | ``` 168 | 169 | The functions `vdeslirp_setvprefix` and `vdeslirp_setvprefix6` define the netmasks and prefixes for IPv4 and IPv6. 170 | These function are usually called after the redefinition of `vhost` or `vhost6`. 171 | `vdeslirp_setvprefix` redefines the network prefix of `vnetwork`, `vdhcp_start` and `vnameserver` while 172 | `vdeslirp_setvprefix6` redefines the network prefix for `vprefix_addr6` and `vnameserver6`. 173 | 174 | e.g.: 175 | ```C 176 | SlirpConfig slirpcfg; 177 | vdeslirp_init(&slirpcfg, VDE_INIT_DEFAULT); 178 | inet_pton(AF_INET,"10.1.1.2", &(slirpcfg.vhost)); 179 | vdeslirp_setvprefix(&slirpcfg, 24); 180 | ``` 181 | redefines the ipv4 addresses as follows: 182 | ``` 183 | ipv4-network 10.1.1.0 184 | ipv4-netmask 255.255.255.0 185 | ipv4-host 10.1.1.2 186 | dhcp-start 10.1.1.15 187 | ipv4-vDNS 10.1.1.3 188 | ``` 189 | 190 | ### step 3: start slirp 191 | 192 | ```C 193 | myslirp = vdeslirp_open(&slirpcfg); 194 | ``` 195 | 196 | ### step 4: use slirp 197 | 198 | send and receive packets (ethernet packets as if it were a tap interface): 199 | ```C 200 | n = vdeslirp_send(myslirp, sendbuf, sendlen); 201 | ... 202 | n = vdeslirp_recv(myslirp, recvbuf, recvlen); 203 | ``` 204 | 205 | poll/select or similar system calls can be used to wait for new incoming packets, 206 | use the return value of `vdeslirp_fd(myslirp)` as the file descriptor. 207 | 208 | ### step 4 terminate slirp 209 | ```C 210 | vdeslirp_close(myslirp); 211 | ``` 212 | 213 | ## Port forward 214 | 215 | The function `vdeslirp_add_fwd` redirects a UDP or TCP port of the host to a port to a virtual service 216 | connected to the slirp network. 217 | 218 | e.g. 219 | ```C 220 | in_addr ipv4_any; 221 | in_addr ipv4_host; 222 | inet_pton(AF_INET,"0.0.0.0", &(ipv4_any)); 223 | inet_pton(AF_INET,"10.0.2.15", &(ipv4_host)); 224 | vdeslirp_add_fwd(myslirp, 0, ipv4_any, 2222, ipv4_host, 22); 225 | ``` 226 | 227 | All the TCP connections addressed to host's port 2222 will be redirected to 10.0.2.15 to port 22. 228 | 229 | The function `vdeslirp_remove_fwd` deletes a port forward definition. 230 | -------------------------------------------------------------------------------- /Uninstall.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | set(MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt") 3 | 4 | if(NOT EXISTS ${MANIFEST}) 5 | message(FATAL_ERROR "Cannot find install manifest: '${MANIFEST}'") 6 | endif() 7 | 8 | file(STRINGS ${MANIFEST} files) 9 | foreach(file ${files}) 10 | if(EXISTS ${file} OR IS_SYMLINK ${file}) 11 | message(STATUS "Removing: ${file}") 12 | 13 | execute_process( 14 | COMMAND rm -f ${file} 15 | RESULT_VARIABLE retcode 16 | ) 17 | 18 | if(NOT "${retcode}" STREQUAL "0") 19 | message(WARNING "Failed to remove: ${file}") 20 | endif() 21 | endif() 22 | endforeach(file) 23 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H 2 | #define CONFIG_H 3 | 4 | #cmakedefine HAS_ADD_EXEC 5 | #cmakedefine HAS_ADD_UNIX 6 | #cmakedefine HAS_REMOVE_GUESTFWD 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libvdeslirp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * VDE - libvdeslirp: libslirp made easy peasy for Linux 3 | * Copyright (C) 2019 Renzo Davoli VirtualSquare 4 | * thanks to Simone Fabbri for early prototype testing 5 | * 6 | * This library is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation version 2.1 of the License, or (at 9 | * your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | 35 | //#define FUTURE_SLIRP_fWD_FEATURES 36 | #define JUMBOMTU 9014 37 | 38 | #define LIBSLIRP_POLLFD_SIZE_INCREASE 16 39 | #define APPSIDE 0 40 | #define DAEMONSIDE 1 41 | 42 | struct vdeslirp_timer { 43 | struct vdeslirp_timer *next; 44 | uint64_t expire_time; 45 | SlirpTimerCb handler; 46 | void *opaque; 47 | }; 48 | 49 | struct vdeslirp { 50 | Slirp *slirp; 51 | pthread_t daemon; 52 | int channel[2]; 53 | int pfd_len; 54 | int pfd_size; 55 | struct pollfd *pfd; 56 | struct vdeslirp_timer *timer_head; 57 | }; 58 | 59 | static ssize_t vdeslirp_output(const void *buf, size_t len, void *opaque); 60 | static void vdeslirp_guest_error(const char *msg, void *opaque); 61 | static int64_t vdeslirp_clock_get_ns(void *opaque); 62 | static void *vdeslirp_timer_new(SlirpTimerCb cb, void *cb_opaque, void *opaque); 63 | static void vdeslirp_timer_free(void *timer, void *opaque); 64 | static void vdeslirp_timer_mod(void *timer, int64_t expire_time, void *opaque); 65 | static void vdeslirp_register_poll_fd(int fd, void *opaque); 66 | static void vdeslirp_unregister_poll_fd(int fd, void *opaque); 67 | static void vdeslirp_notify(void *opaque); 68 | 69 | struct SlirpCb callbacks = { 70 | .send_packet = vdeslirp_output, 71 | .guest_error = vdeslirp_guest_error, 72 | .clock_get_ns = vdeslirp_clock_get_ns, 73 | .timer_new = vdeslirp_timer_new, 74 | .timer_free = vdeslirp_timer_free, 75 | .timer_mod = vdeslirp_timer_mod, 76 | .register_poll_fd = vdeslirp_register_poll_fd, 77 | .unregister_poll_fd = vdeslirp_unregister_poll_fd, 78 | .notify = vdeslirp_notify, 79 | }; 80 | 81 | #define SLIRP_ADD_FWD 0x11 82 | #define SLIRP_DEL_FWD 0x12 83 | #define SLIRP_ADD_UNIXFWD 0x21 84 | #define SLIRP_DEL_UNIXFWD 0x22 85 | #define SLIRP_ADD_EXEC 0x31 86 | #define SLIRP_DEL_EXEC 0x32 87 | 88 | struct slirp_request { 89 | int tag; 90 | int pipefd[2]; 91 | int intarg; 92 | const void *ptrarg; 93 | void *host_addr; 94 | int host_port; 95 | void *guest_addr; 96 | int guest_port; 97 | }; 98 | 99 | static void vdeslirp_guest_error(const char *msg, void *opaque){ 100 | (void) opaque; 101 | fprintf(stderr, "vdeslirp: %s\n", msg); 102 | } 103 | 104 | /* FWD MANAGEMENT DAEMON SIDE */ 105 | 106 | void slirp_do_req(Slirp *slirp, struct slirp_request *preq) { 107 | int rval; 108 | struct in_addr *host_addr = preq->host_addr; 109 | struct in_addr *guest_addr = preq->guest_addr; 110 | switch (preq->tag) { 111 | case SLIRP_ADD_FWD: 112 | rval = slirp_add_hostfwd(slirp, preq->intarg, 113 | *host_addr, preq->host_port, 114 | *guest_addr, preq->guest_port); 115 | break; 116 | case SLIRP_DEL_FWD: 117 | rval = slirp_remove_hostfwd(slirp, preq->intarg, 118 | *host_addr, preq->host_port); 119 | break; 120 | #ifdef HAS_ADD_UNIX 121 | /* currently unsupported by libslirp */ 122 | case SLIRP_ADD_UNIXFWD: 123 | rval = slirp_add_unix(slirp, preq->ptrarg, 124 | guest_addr, preq->guest_port); 125 | break; 126 | #else 127 | #ifdef HAS_ADD_EXEC 128 | /* warkaround */ 129 | case SLIRP_ADD_UNIXFWD: 130 | { 131 | size_t cmdlen = strlen(preq->ptrarg) + 8; 132 | char cmd[cmdlen]; 133 | snprintf(cmd, cmdlen, "nc -UN %s", (char *) preq->ptrarg); 134 | rval = slirp_add_exec(slirp, cmd, 135 | guest_addr, preq->guest_port); 136 | } 137 | break; 138 | #endif 139 | #endif 140 | #ifdef HAS_ADD_EXEC 141 | case SLIRP_ADD_EXEC: 142 | rval = slirp_add_exec(slirp, preq->ptrarg, 143 | guest_addr, preq->guest_port); 144 | break; 145 | #endif 146 | #ifdef HAS_REMOVE_GUESTFWD 147 | case SLIRP_DEL_UNIXFWD: 148 | case SLIRP_DEL_EXEC: 149 | rval = slirp_remove_guestfwd(slirp, 150 | *guest_addr, preq->guest_port); 151 | break; 152 | #endif 153 | default: 154 | rval = -ENOSYS; 155 | } 156 | rval = write(preq->pipefd[DAEMONSIDE],&rval,sizeof(rval)); 157 | } 158 | 159 | 160 | /* FWD MANAGEMENT APP SIDE */ 161 | static int slirp_send_req(struct vdeslirp *slirp, struct slirp_request *preq) { 162 | int rval; 163 | if (pipe(preq->pipefd) < 0) { 164 | return -1; 165 | } else { 166 | rval = write(slirp->channel[APPSIDE], &preq, sizeof(struct slirp_request *)); 167 | if (rval >= 0) 168 | rval = read(preq->pipefd[APPSIDE],&rval,sizeof(rval)); 169 | close(preq->pipefd[0]); 170 | close(preq->pipefd[1]); 171 | return rval < 0 ? (errno = -rval, -1) : 0; 172 | } 173 | } 174 | 175 | int vdeslirp_add_fwd(struct vdeslirp *slirp, int is_udp, 176 | struct in_addr host_addr, int host_port, 177 | struct in_addr guest_addr, int guest_port) { 178 | struct slirp_request req = { 179 | .tag = SLIRP_ADD_FWD, 180 | .intarg = is_udp, 181 | .host_addr = &host_addr, 182 | .host_port = host_port, 183 | .guest_addr = &guest_addr, 184 | .guest_port = guest_port }; 185 | return slirp_send_req(slirp, &req); 186 | } 187 | 188 | int vdeslirp_remove_fwd(struct vdeslirp *slirp, int is_udp, 189 | struct in_addr host_addr, int host_port) { 190 | struct slirp_request req = { 191 | .tag = SLIRP_DEL_FWD, 192 | .intarg = is_udp, 193 | .host_addr = &host_addr, 194 | .host_port = host_port}; 195 | return slirp_send_req(slirp, &req); 196 | } 197 | 198 | int vdeslirp_add_unixfwd(struct vdeslirp *slirp, char *path, 199 | struct in_addr *guest_addr, int guest_port) { 200 | struct slirp_request req = { 201 | .tag = SLIRP_ADD_UNIXFWD, 202 | .guest_addr = guest_addr, 203 | .guest_port = guest_port, 204 | .ptrarg = path }; 205 | return slirp_send_req(slirp, &req); 206 | } 207 | 208 | int vdeslirp_remove_unixfwd(struct vdeslirp *slirp, 209 | struct in_addr guest_addr, int guest_port) { 210 | struct slirp_request req = { 211 | .tag = SLIRP_DEL_UNIXFWD, 212 | .guest_addr = &guest_addr, 213 | .guest_port = guest_port}; 214 | return slirp_send_req(slirp, &req); 215 | } 216 | 217 | int vdeslirp_add_cmdexec(struct vdeslirp *slirp, const char *cmdline, 218 | struct in_addr *guest_addr, int guest_port) { 219 | struct slirp_request req = { 220 | .tag = SLIRP_ADD_EXEC, 221 | .ptrarg = cmdline, 222 | .guest_addr = guest_addr, 223 | .guest_port = guest_port }; 224 | return slirp_send_req(slirp, &req); 225 | } 226 | 227 | int vdeslirp_remove_cmdexec(struct vdeslirp *slirp, 228 | struct in_addr guest_addr, int guest_port) { 229 | struct slirp_request req = { 230 | .tag = SLIRP_DEL_EXEC, 231 | .guest_addr = &guest_addr, 232 | .guest_port = guest_port}; 233 | return slirp_send_req(slirp, &req); 234 | } 235 | 236 | /* TIMER MANAGEMENT */ 237 | static int64_t vdeslirp_clock_get_ns(void *opaque){ 238 | (void) opaque; 239 | struct timespec ts; 240 | clock_gettime(CLOCK_MONOTONIC, &ts); 241 | return ts.tv_sec * 1000000000LL + ts.tv_nsec; 242 | } 243 | 244 | static void *vdeslirp_timer_new(SlirpTimerCb cb, void *cb_opaque, void *opaque){ 245 | struct vdeslirp *slirp = opaque; 246 | struct vdeslirp_timer *qt = malloc(sizeof(*qt)); 247 | if (qt) { 248 | qt->next = slirp->timer_head; 249 | qt->expire_time = -1; 250 | qt->handler = cb; 251 | qt->opaque = cb_opaque; 252 | slirp->timer_head=qt; 253 | } 254 | return qt; 255 | } 256 | 257 | static void vdeslirp_timer_free(void *timer, void *opaque){ 258 | struct vdeslirp *slirp = opaque; 259 | struct vdeslirp_timer *qt = timer; 260 | struct vdeslirp_timer **scan; 261 | for (scan = &slirp->timer_head; *scan != NULL && *scan != qt; scan = &((*scan) ->next)) 262 | ; 263 | if (*scan) { 264 | *scan = qt->next; 265 | free(qt); 266 | } 267 | } 268 | 269 | static void vdeslirp_timer_mod(void *timer, int64_t expire_time, void *opaque){ 270 | (void) opaque; 271 | struct vdeslirp_timer *qt = timer; 272 | qt->expire_time = expire_time; 273 | } 274 | 275 | static void update_ra_timeout(uint32_t *timeout, void *opaque) { 276 | struct vdeslirp *slirp = opaque; 277 | struct vdeslirp_timer *qt; 278 | int64_t now_ms = vdeslirp_clock_get_ns(opaque) / 1000000; 279 | for (qt = slirp->timer_head; qt != NULL; qt = qt->next) { 280 | if (qt->expire_time != -1UL) { 281 | int64_t diff = qt->expire_time - now_ms; 282 | if (diff < 0) diff = 0; 283 | if (diff < *timeout) *timeout = diff; 284 | } 285 | } 286 | } 287 | 288 | static void check_ra_timeout(void *opaque) { 289 | struct vdeslirp *slirp = opaque; 290 | struct vdeslirp_timer *qt; 291 | int64_t now_ms = vdeslirp_clock_get_ns(opaque) / 1000000; 292 | for (qt = slirp->timer_head; qt != NULL; qt = qt->next) { 293 | if (qt->expire_time != -1UL) { 294 | int64_t diff = qt->expire_time - now_ms; 295 | if (diff <= 0) { 296 | qt->expire_time = -1UL; 297 | qt->handler(qt->opaque); 298 | } 299 | } 300 | } 301 | } 302 | 303 | 304 | /* POLL MANAGEMENT */ 305 | static int vdeslirp_slirp_to_poll(int events) { 306 | int ret = 0; 307 | if (events & SLIRP_POLL_IN) ret |= POLLIN; 308 | if (events & SLIRP_POLL_OUT) ret |= POLLOUT; 309 | if (events & SLIRP_POLL_PRI) ret |= POLLPRI; 310 | if (events & SLIRP_POLL_ERR) ret |= POLLERR; 311 | if (events & SLIRP_POLL_HUP) ret |= POLLHUP; 312 | return ret; 313 | } 314 | 315 | static int vdeslirp_poll_to_slirp(int events) { 316 | int ret = 0; 317 | if (events & POLLIN) ret |= SLIRP_POLL_IN; 318 | if (events & POLLOUT) ret |= SLIRP_POLL_OUT; 319 | if (events & POLLPRI) ret |= SLIRP_POLL_PRI; 320 | if (events & POLLERR) ret |= SLIRP_POLL_ERR; 321 | if (events & POLLHUP) ret |= SLIRP_POLL_HUP; 322 | return ret; 323 | } 324 | 325 | static int vdeslirp_add_poll(int fd, int events, void *opaque) { 326 | struct vdeslirp *slirp = opaque; 327 | if (slirp->pfd_len >= slirp->pfd_size) { 328 | int newsize = slirp->pfd_size + LIBSLIRP_POLLFD_SIZE_INCREASE; 329 | struct pollfd *new = realloc(slirp->pfd, newsize * sizeof(struct pollfd)); 330 | if (new) { 331 | slirp->pfd = new; 332 | slirp->pfd_size = newsize; 333 | } 334 | } 335 | if (slirp->pfd_len < slirp->pfd_size) { 336 | int idx = slirp->pfd_len++; 337 | slirp->pfd[idx].fd = fd; 338 | slirp->pfd[idx].events = vdeslirp_slirp_to_poll(events); 339 | return idx; 340 | } else 341 | return -1; 342 | } 343 | 344 | static int vdeslirp_get_revents(int idx, void *opaque) { 345 | struct vdeslirp *slirp = opaque; 346 | return vdeslirp_poll_to_slirp(slirp->pfd[idx].revents); 347 | } 348 | 349 | static void vdeslirp_register_poll_fd(int fd, void *opaque){ 350 | (void) fd; 351 | (void) opaque; 352 | } 353 | 354 | static void vdeslirp_unregister_poll_fd(int fd, void *opaque){ 355 | (void) fd; 356 | (void) opaque; 357 | } 358 | 359 | static void vdeslirp_notify(void *opaque){ 360 | (void) opaque; 361 | } 362 | 363 | static ssize_t vdeslirp_output(const void *buf, size_t len, void *opaque) { 364 | struct vdeslirp *slirp = opaque; 365 | return write(slirp->channel[DAEMONSIDE], buf, len); 366 | } 367 | 368 | static void vdeslirp_cleanup(struct vdeslirp *slirp) { 369 | slirp_cleanup(slirp->slirp); 370 | while(slirp->timer_head) 371 | vdeslirp_timer_free(slirp->timer_head, slirp); 372 | close(slirp->channel[DAEMONSIDE]); 373 | free(slirp->pfd); 374 | free(slirp); 375 | } 376 | 377 | static void *slirp_daemon(void *opaque) { 378 | struct vdeslirp *slirp = opaque; 379 | vdeslirp_add_poll(slirp->channel[DAEMONSIDE], SLIRP_POLL_IN | SLIRP_POLL_HUP, slirp); 380 | for(;;) { 381 | int pollout; 382 | uint32_t timeout = -1; 383 | slirp->pfd_len = 1; 384 | slirp_pollfds_fill(slirp->slirp, &timeout, vdeslirp_add_poll, slirp); 385 | update_ra_timeout(&timeout, slirp); 386 | pollout = poll(slirp->pfd, slirp->pfd_len, timeout); 387 | if (slirp->pfd[0].revents) { 388 | uint8_t buf[JUMBOMTU]; 389 | size_t len = read(slirp->channel[DAEMONSIDE], buf, JUMBOMTU); 390 | if (len <= 0) 391 | break; 392 | if (len == sizeof(struct slirp_request *)) 393 | slirp_do_req(slirp->slirp, *((struct slirp_request **) buf)); 394 | else 395 | slirp_input(slirp->slirp, buf, len); 396 | } 397 | slirp_pollfds_poll(slirp->slirp, (pollout <= 0), vdeslirp_get_revents, slirp); 398 | check_ra_timeout(slirp); 399 | } 400 | return NULL; 401 | } 402 | 403 | static void *memmask(void *mask, size_t len, size_t prefix) { 404 | uint8_t *bufmask = mask; 405 | size_t i; 406 | for (i = 0; (i < len) & (prefix >= 8); i++, prefix -= 8) 407 | bufmask[i] = 0xff; 408 | for (; (i < len) & (prefix > 0); i++, prefix -= 8) 409 | bufmask[i] = ~((1 << (8 - prefix)) - 1); 410 | for (; i < len; i++, prefix -= 8) 411 | bufmask[i] = 0x0; 412 | return bufmask; 413 | } 414 | 415 | static void *memmaskcpy(void *dest, const void *src, const void *mask, size_t n) { 416 | uint8_t *bufdest = dest; 417 | const uint8_t *bufsrc = src; 418 | const uint8_t *bufmask = mask; 419 | size_t i; 420 | for (i = 0; i < n; i++) 421 | bufdest[i] = (bufsrc[i] & bufmask[i]) | (bufdest[i] & ~bufmask[i]); 422 | return bufdest; 423 | } 424 | 425 | void vdeslirp_init(SlirpConfig *cfg, int flags) { 426 | memset(cfg, 0, sizeof(*cfg)); 427 | cfg->version = 1; 428 | 429 | if (flags & VDE_INIT_DEFAULT) { 430 | cfg->restricted = 0; 431 | cfg->in_enabled = 1; 432 | inet_pton(AF_INET,"10.0.2.0", &(cfg->vnetwork)); 433 | inet_pton(AF_INET,"255.255.255.0", &(cfg->vnetmask)); 434 | inet_pton(AF_INET,"10.0.2.2", &(cfg->vhost)); 435 | cfg->in6_enabled = 1; 436 | inet_pton(AF_INET6, "fd00::", &cfg->vprefix_addr6); 437 | cfg->vprefix_len = 64; 438 | inet_pton(AF_INET6, "fd00::2", &cfg->vhost6); 439 | cfg->vhostname = "slirp"; 440 | cfg->tftp_server_name = NULL; 441 | cfg->tftp_path = NULL; 442 | cfg->bootfile = NULL; 443 | inet_pton(AF_INET,"10.0.2.15", &(cfg->vdhcp_start)); 444 | inet_pton(AF_INET,"10.0.2.3", &(cfg->vnameserver)); 445 | inet_pton(AF_INET6, "fd00::3", &cfg->vnameserver6); 446 | cfg->vdnssearch = NULL; 447 | cfg->vdomainname = NULL; 448 | cfg->if_mtu = 0; // IF_MTU_DEFAULT 449 | cfg->if_mru = 0; // IF_MTU_DEFAULT 450 | 451 | cfg->disable_host_loopback = 0; 452 | } 453 | } 454 | 455 | void vdeslirp_setvprefix(SlirpConfig *cfg, int prefix) { 456 | static const struct in_addr inaddr_any = {.s_addr = INADDR_ANY}; 457 | memmask(&cfg->vnetmask, sizeof(struct in_addr), prefix); 458 | cfg->vnetwork = inaddr_any; 459 | memmaskcpy(&cfg->vnetwork, &cfg->vhost, &cfg->vnetmask, sizeof(struct in_addr)); 460 | if (cfg->vdhcp_start.s_addr != inaddr_any.s_addr) 461 | memmaskcpy(&cfg->vdhcp_start, &cfg->vhost, &cfg->vnetmask, sizeof(struct in_addr)); 462 | if (cfg->vnameserver.s_addr != inaddr_any.s_addr) 463 | memmaskcpy(&cfg->vnameserver, &cfg->vhost, &cfg->vnetmask, sizeof(struct in_addr)); 464 | } 465 | 466 | void vdeslirp_setvprefix6(SlirpConfig *cfg, int prefix6) { 467 | struct in6_addr vnetmask6; 468 | cfg->vprefix_len = prefix6; 469 | memmask(&vnetmask6, sizeof(struct in6_addr), prefix6); 470 | cfg->vprefix_addr6 = in6addr_any; 471 | memmaskcpy(&cfg->vprefix_addr6, &cfg->vhost6, &vnetmask6, sizeof(struct in6_addr)); 472 | if (memcmp(&cfg->vnameserver6, &in6addr_any, sizeof(struct in6_addr)) != 0) 473 | memmaskcpy(&cfg->vnameserver6, &cfg->vhost6, &vnetmask6, sizeof(struct in6_addr)); 474 | } 475 | 476 | struct vdeslirp *vdeslirp_open(SlirpConfig *cfg) { 477 | struct vdeslirp *slirp = calloc(1, sizeof(struct vdeslirp)); 478 | if (slirp) { 479 | if (socketpair(AF_LOCAL, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, slirp->channel) < 0) 480 | goto nosocketpair; 481 | if ((slirp->slirp = slirp_new(cfg, &callbacks, slirp)) == NULL) 482 | goto noslirp; 483 | if (pthread_create(&slirp->daemon, NULL, slirp_daemon, slirp) != 0) 484 | goto nopthread; 485 | } 486 | return slirp; 487 | nopthread: 488 | slirp_cleanup(slirp->slirp); 489 | noslirp: 490 | close(slirp->channel[APPSIDE]); 491 | close(slirp->channel[DAEMONSIDE]); 492 | nosocketpair: 493 | free(slirp); 494 | return NULL; 495 | } 496 | 497 | ssize_t vdeslirp_send(struct vdeslirp *slirp, const void *buf, size_t count) { 498 | if (count > sizeof(void *)) { 499 | return write(slirp->channel[APPSIDE], buf, count); 500 | } else 501 | return errno = EINVAL, -1; 502 | } 503 | 504 | ssize_t vdeslirp_recv(struct vdeslirp *slirp, void *buf, size_t count) { 505 | return read(slirp->channel[APPSIDE], buf, count); 506 | } 507 | 508 | int vdeslirp_fd(struct vdeslirp *slirp) { 509 | return slirp->channel[APPSIDE]; 510 | } 511 | 512 | int vdeslirp_close(struct vdeslirp *slirp) { 513 | void *retval; 514 | int rv = close(slirp->channel[APPSIDE]); 515 | pthread_join(slirp->daemon, &retval); 516 | vdeslirp_cleanup(slirp); 517 | return rv; 518 | } 519 | 520 | -------------------------------------------------------------------------------- /libvdeslirp.h: -------------------------------------------------------------------------------- 1 | #ifndef VDESLIRP_H 2 | #define VDESLIRP_H 3 | #include 4 | 5 | struct vdeslirp; 6 | 7 | #define VDE_INIT_DEFAULT 1 8 | void vdeslirp_init(SlirpConfig *cfg, int flags); 9 | 10 | void vdeslirp_setvprefix(SlirpConfig *cfg, int prefix); 11 | void vdeslirp_setvprefix6(SlirpConfig *cfg, int prefix6); 12 | 13 | struct vdeslirp *vdeslirp_open(SlirpConfig *cfg); 14 | ssize_t vdeslirp_send(struct vdeslirp *slirp, const void *buf, size_t count); 15 | ssize_t vdeslirp_recv(struct vdeslirp *slirp, void *buf, size_t count); 16 | int vdeslirp_fd(struct vdeslirp *slirp); 17 | int vdeslirp_close(struct vdeslirp *slirp); 18 | 19 | int vdeslirp_add_fwd(struct vdeslirp *slirp, int is_udp, 20 | struct in_addr host_addr, int host_port, 21 | struct in_addr guest_addr, int guest_port); 22 | int vdeslirp_remove_fwd(struct vdeslirp *slirp, int is_udp, 23 | struct in_addr host_addr, int host_port); 24 | 25 | int vdeslirp_add_unixfwd(struct vdeslirp *slirp, char *path, 26 | struct in_addr *guest_addr, int guest_port); 27 | int vdeslirp_remove_unixfwd(struct vdeslirp *slirp, 28 | struct in_addr guest_addr, int guest_port); 29 | 30 | int vdeslirp_add_cmdexec(struct vdeslirp *slirp, const char *cmdline, 31 | struct in_addr *guest_addr, int guest_port); 32 | int vdeslirp_remove_cmdexec(struct vdeslirp *slirp, 33 | struct in_addr guest_addr, int guest_port); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /man/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | 3 | set(PANDOC_ORG "VirtualSquare") 4 | 5 | # ### pandoc pages 6 | 7 | file(GLOB VU_PANDOC_PAGES ${CMAKE_CURRENT_SOURCE_DIR}/*.[1-8].md) 8 | set(VU_MAN_FILES) 9 | foreach(VU_PANDOC_PATH IN LISTS VU_PANDOC_PAGES) 10 | # VU_PANDOCPAGE: basename of VU_PANDOC_PATH 11 | get_filename_component(VU_PANDOCPAGE ${VU_PANDOC_PATH} NAME) 12 | # VU_MANPAGE: VU_PANDOCPAGE without the suffix 13 | string(REGEX REPLACE "\.md$" "" VU_MANPAGE ${VU_PANDOCPAGE}) 14 | list(APPEND VU_MAN_FILES ${VU_MANPAGE}) 15 | endforeach(VU_PANDOC_PATH) 16 | 17 | add_custom_target(${PROJECT_NAME}_manpages ALL make PANDOC_ORG="${PANDOC_ORG}" ${VU_MAN_FILES} 18 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 19 | 20 | ### man pages 21 | file(GLOB VU_MAN_PAGES ${CMAKE_CURRENT_SOURCE_DIR}/*.[1-8]) 22 | foreach(VU_MAN_PATH IN LISTS VU_MAN_PAGES) 23 | get_filename_component(VU_MANPAGE ${VU_MAN_PATH} NAME) 24 | string(REGEX REPLACE ".*\\." "" MAN_CHAPTER ${VU_MANPAGE}) 25 | install(FILES ${VU_MAN_PATH} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_CHAPTER}) 26 | endforeach(VU_MAN_PATH) 27 | -------------------------------------------------------------------------------- /man/Makefile: -------------------------------------------------------------------------------- 1 | MAKEFLAGS += --silent 2 | PANDOC=pandoc 3 | PANDOCOK := $(shell command -v ${PANDOC} 2> /dev/null) 4 | PANDOCMINVER=3.1.7 5 | 6 | ifdef PANDOCOK 7 | PANDOCVER := $(shell ${PANDOC} -v | head -1 | cut -d ' ' -f 2) 8 | PANDOCVEROK := $(shell printf '%s\n' ${PANDOCMINVER} ${PANDOCVER} | sort -C -V; echo $$?) 9 | endif 10 | 11 | none: 12 | 13 | % : %.md 14 | ifdef PANDOCOK 15 | ifeq (${PANDOCVEROK}, 1) 16 | echo "${PANDOC} ${PANDOCVER} < ${PANDOCMINVER}. $@ can create font warnings with man/groff" >/dev/stderr >&2 17 | endif 18 | # copy copyright notice 19 | grep "^\.\\\\\"" $< > $@ || true 20 | # run pandoc 21 | $(eval SECTION := $(subst .,,$(suffix $@))) 22 | $(eval BASENAME := $(basename $@)) 23 | $(eval TITLE := $(shell echo "${BASENAME}\(${SECTION}\)" | tr [:lower:] [:upper:])) 24 | $(eval HEADER := "$(shell man ${SECTION} intro | head -1 | sed -e 's/^[^[:blank:]]*[[:blank:]]*//' -e 's/[[:blank:]]*[^[:blank:]]*$$//' )") 25 | $(PANDOC) -standalone -M title=${TITLE} -M section=${SECTION} -M header=${HEADER} -M footer=${PANDOC_ORG} -M "date=`date +\"%B %Y\"`" --to man $< >> $@ 26 | # workaround for boldface rendering 27 | sed -i -e 's/\\f\[CR\]/\\f\[CB\]/g' $@ || true 28 | echo "$@ manpage updated" >/dev/stderr >&2 29 | else 30 | echo "${PANDOC} is not available. Manpage $@ cannot be updated" >/dev/stderr >&2 31 | endif 32 | -------------------------------------------------------------------------------- /man/libvdeslirp.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2019 VirtualSquare. Project Leader: Renzo Davoli 2 | .\" 3 | .\" This is free documentation; you can redistribute it and/or 4 | .\" modify it under the terms of the GNU General Public License, 5 | .\" as published by the Free Software Foundation, either version 2 6 | .\" of the License, or (at your option) any later version. 7 | .\" 8 | .\" The GNU General Public License's references to "object code" 9 | .\" and "executables" are to be interpreted as the output of any 10 | .\" document formatting or typesetting system, including 11 | .\" intermediate and printed output. 12 | .\" 13 | .\" This manual is distributed in the hope that it will be useful, 14 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | .\" GNU General Public License for more details. 17 | .\" 18 | .\" You should have received a copy of the GNU General Public 19 | .\" License along with this manual; if not, write to the Free 20 | .\" Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 21 | .\" MA 02110-1301 USA. 22 | .\" 23 | .\" Automatically generated by Pandoc 3.1.11 24 | .\" 25 | .TH "LIBVDESLIRP" "3" "January 2024" "VirtualSquare" "Library Functions Manual" 26 | .SH NAME 27 | vdeslirp_open, vdeslirp_send, vdeslirp_recv, vdeslirp_fd, vdeslirp_close 28 | \- simple API for slirp 29 | .SH SYNOPSIS 30 | \f[CB]#include *libvdeslirp.h*\f[R] 31 | .PP 32 | \f[CB]struct vdeslirp *vdeslirp_open(SlirpConfig *\f[R]\f[I]cfg\f[R]\f[CB]);\f[R] 33 | .PP 34 | \f[CB]ssize_t vdeslirp_send(struct vdeslirp *\f[R]\f[I]slirp\f[R]\f[CB], const void *\f[R]\f[I]buf\f[R]\f[CB], size_t\f[R] 35 | \f[I]count\f[R]\f[CB]);\f[R] 36 | .PP 37 | \f[CB]ssize_t vdeslirp_recv(struct vdeslirp *\f[R]\f[I]slirp\f[R]\f[CB], void *\f[R]\f[I]buf\f[R]\f[CB], size_t\f[R] 38 | \f[I]count\f[R]\f[CB]);\f[R] 39 | .PP 40 | \f[CB]int vdeslirp_fd(struct vdeslirp *\f[R]\f[I]slirp\f[R]\f[CB]);\f[R] 41 | .PP 42 | \f[CB]int vdeslirp_close(struct vdeslirp *\f[R]\f[I]slirp\f[R]\f[CB]);\f[R] 43 | .PP 44 | These functions are provided by libvdeslirp. 45 | Link with \-lvdeslirp. 46 | .SH DESCRIPTION 47 | Slirp is a TCP/IP emulator. 48 | Slirp generates a virtual network using standard user privileges (no 49 | need for root access or CAP_NET_ADMIN). 50 | This implementation uses libslirp. 51 | .PP 52 | \f[CB]vdeslirp_open\f[R] creates a slirp network. 53 | The \f[CB]SlirpConfig\f[R] structure is defined by libslirp and contains 54 | the following fields: 55 | .IP 56 | .EX 57 | typedef struct SlirpConfig { 58 | /* Version must be provided */ 59 | uint32_t version; 60 | /* 61 | * Fields introduced in SlirpConfig version 1 begin 62 | */ 63 | int restricted; 64 | bool in_enabled; 65 | struct in_addr vnetwork; 66 | struct in_addr vnetmask; 67 | struct in_addr vhost; 68 | bool in6_enabled; 69 | struct in6_addr vprefix_addr6; 70 | uint8_t vprefix_len; 71 | struct in6_addr vhost6; 72 | const char *vhostname; 73 | const char *tftp_server_name; 74 | const char *tftp_path; 75 | const char *bootfile; 76 | struct in_addr vdhcp_start; 77 | struct in_addr vnameserver; 78 | struct in6_addr vnameserver6; 79 | const char **vdnssearch; 80 | const char *vdomainname; 81 | /* Default: IF_MTU_DEFAULT */ 82 | size_t if_mtu; 83 | /* Default: IF_MRU_DEFAULT */ 84 | size_t if_mru; 85 | /* Prohibit connecting to 127.0.0.1:* */ 86 | bool disable_host_loopback; 87 | /* 88 | * Enable emulation code (*warning*: this code isn\[aq]t safe, it is not 89 | * recommended to enable it) 90 | */ 91 | bool enable_emu; 92 | /* 93 | * Fields introduced in SlirpConfig version 2 begin 94 | */ 95 | } SlirpConfig; 96 | .EE 97 | .PP 98 | \f[CB]libvdeslirp\f[R] provides helper functions to fill in the fields 99 | of this structure, see \f[CB]libvdeslirpcfg\f[R](3). 100 | .PP 101 | Programs using \f[CB]libvdeslirp\f[R] can send and receive packets using 102 | \f[CB]vdeslirp_send\f[R] and \f[CB]vdeslirp_recv\f[R] as if they were 103 | connected to host network (commonly the Internet) by a NAT/Masquerading 104 | router. 105 | \f[CB]vdeslirp_fd\f[R] provides a valid file descriptor which can be 106 | used to wait for incoming packets (using select or poll) and 107 | \f[CB]vdeslirp_close\f[R] terminates a slirp network created by 108 | \f[CB]vdeslirp_open\f[R]. 109 | .SH RETURN VALUE 110 | \f[CB]vdeslirp_open\f[R] returns the \f[CB]struct vdeslirp\f[R] pointer 111 | in case of success. 112 | NULL is returned otherwise. 113 | The return value of \f[CB]vdeslirp_open\f[R] is the descriptor that must 114 | be passed as first argument to all the other functions of this man page. 115 | \f[CB]vdeslirp_send\f[R] and \f[CB]vdeslirp_recv\f[R] return the number 116 | of bytes sent or received, \-1 in case of error. 117 | \f[CB]vdeslirp_fd\f[R] returns a valid file descriptor which can be used 118 | to wait for incoming packets (using select or poll). 119 | \f[CB]vdeslirp_close\f[R] returns zero in case of success, \-1 in case 120 | of error. 121 | In case of failure, \f[CB]errno\f[R] is set to indicate the type of 122 | error. 123 | .SH SEE ALSO 124 | \f[CB]libvdeslirpfwd\f[R](3), \f[CB]libvdeslirpcfg\f[R](3) 125 | .SH BUGS 126 | Bug reports should be addressed to *info\[at]virtualsquare.org* 127 | .SH AUTHOR 128 | VirtualSquare. 129 | Project leader: Renzo Davoli. 130 | -------------------------------------------------------------------------------- /man/libvdeslirp.3.md: -------------------------------------------------------------------------------- 1 | 25 | 26 | # NAME 27 | 28 | vdeslirp_open, vdeslirp_send, vdeslirp_recv, vdeslirp_fd, vdeslirp_close - simple API for slirp 29 | 30 | # SYNOPSIS 31 | 32 | `#include *libvdeslirp.h*` 33 | 34 | `struct vdeslirp *vdeslirp_open(SlirpConfig *`_cfg_`);` 35 | 36 | `ssize_t vdeslirp_send(struct vdeslirp *`_slirp_`, const void *`_buf_`, size_t ` _count_`);` 37 | 38 | `ssize_t vdeslirp_recv(struct vdeslirp *`_slirp_`, void *`_buf_`, size_t ` _count_`);` 39 | 40 | `int vdeslirp_fd(struct vdeslirp *`_slirp_`);` 41 | 42 | `int vdeslirp_close(struct vdeslirp *`_slirp_`);` 43 | 44 | These functions are provided by libvdeslirp. Link with -lvdeslirp. 45 | 46 | # DESCRIPTION 47 | 48 | Slirp is a TCP/IP emulator. Slirp generates a virtual network using standard 49 | user privileges (no need for root access or CAP_NET_ADMIN). 50 | This implementation uses libslirp. 51 | 52 | `vdeslirp_open` creates a slirp network. 53 | The `SlirpConfig` structure is defined by libslirp and contains the following fields: 54 | 55 | ```C 56 | typedef struct SlirpConfig { 57 | /* Version must be provided */ 58 | uint32_t version; 59 | /* 60 | * Fields introduced in SlirpConfig version 1 begin 61 | */ 62 | int restricted; 63 | bool in_enabled; 64 | struct in_addr vnetwork; 65 | struct in_addr vnetmask; 66 | struct in_addr vhost; 67 | bool in6_enabled; 68 | struct in6_addr vprefix_addr6; 69 | uint8_t vprefix_len; 70 | struct in6_addr vhost6; 71 | const char *vhostname; 72 | const char *tftp_server_name; 73 | const char *tftp_path; 74 | const char *bootfile; 75 | struct in_addr vdhcp_start; 76 | struct in_addr vnameserver; 77 | struct in6_addr vnameserver6; 78 | const char **vdnssearch; 79 | const char *vdomainname; 80 | /* Default: IF_MTU_DEFAULT */ 81 | size_t if_mtu; 82 | /* Default: IF_MRU_DEFAULT */ 83 | size_t if_mru; 84 | /* Prohibit connecting to 127.0.0.1:* */ 85 | bool disable_host_loopback; 86 | /* 87 | * Enable emulation code (*warning*: this code isn't safe, it is not 88 | * recommended to enable it) 89 | */ 90 | bool enable_emu; 91 | /* 92 | * Fields introduced in SlirpConfig version 2 begin 93 | */ 94 | } SlirpConfig; 95 | ``` 96 | 97 | `libvdeslirp` provides helper functions to fill in the fields of this structure, see `libvdeslirpcfg`(3). 98 | 99 | Programs using `libvdeslirp` can send and receive packets using `vdeslirp_send` 100 | and `vdeslirp_recv` as if they were connected to host network (commonly the 101 | Internet) by a NAT/Masquerading router. `vdeslirp_fd` provides a valid 102 | file descriptor which can be used to wait for incoming packets (using 103 | select or poll) and `vdeslirp_close` terminates a slirp network created by 104 | `vdeslirp_open`. 105 | 106 | # RETURN VALUE 107 | 108 | `vdeslirp_open` returns the `struct vdeslirp` pointer in case of success. NULL is returned otherwise. 109 | The return value of `vdeslirp_open` is the descriptor that must be passed as first argument to 110 | all the other functions of this man page. 111 | `vdeslirp_send` and `vdeslirp_recv` return the number of bytes sent or received, -1 112 | in case of error. `vdeslirp_fd` returns a valid file descriptor which can be 113 | used to wait for incoming packets (using select or poll). `vdeslirp_close` 114 | returns zero in case of success, -1 in case of error. In case of failure, 115 | `errno` is set to indicate the type of error. 116 | 117 | # SEE ALSO 118 | 119 | `libvdeslirpfwd`(3), `libvdeslirpcfg`(3) 120 | 121 | # BUGS 122 | 123 | Bug reports should be addressed to *info@virtualsquare.org\* 124 | 125 | # AUTHOR 126 | 127 | VirtualSquare. Project leader: Renzo Davoli. 128 | 129 | -------------------------------------------------------------------------------- /man/libvdeslirpcfg.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2019 VirtualSquare. Project Leader: Renzo Davoli 2 | .\" 3 | .\" This is free documentation; you can redistribute it and/or 4 | .\" modify it under the terms of the GNU General Public License, 5 | .\" as published by the Free Software Foundation, either version 2 6 | .\" of the License, or (at your option) any later version. 7 | .\" 8 | .\" The GNU General Public License's references to "object code" 9 | .\" and "executables" are to be interpreted as the output of any 10 | .\" document formatting or typesetting system, including 11 | .\" intermediate and printed output. 12 | .\" 13 | .\" This manual is distributed in the hope that it will be useful, 14 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | .\" GNU General Public License for more details. 17 | .\" 18 | .\" You should have received a copy of the GNU General Public 19 | .\" License along with this manual; if not, write to the Free 20 | .\" Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 21 | .\" MA 02110-1301 USA. 22 | .\" 23 | .\" Automatically generated by Pandoc 3.1.11 24 | .\" 25 | .TH "LIBVDESLIRPCFG" "3" "January 2024" "VirtualSquare" "Library Functions Manual" 26 | .SH NAME 27 | vdeslirp_init, vdeslirp_setvprefix, vdeslirp_setvprefix6 \- simple API 28 | for slirp: configuration helpers 29 | .SH SYNOPSIS 30 | \f[CB]#include *libvdeslirp.h*\f[R] 31 | .PP 32 | \f[CB]#define VDE_INIT_DEFAULT 1\f[R] 33 | .PP 34 | \f[CB]void vdeslirp_init(SlirpConfig *\f[R]\f[I]cfg\f[R]\f[CB], int\f[R] 35 | \f[I]flags\f[R]\f[CB]);\f[R] 36 | .PP 37 | \f[CB]void vdeslirp_setvprefix(SlirpConfig *\f[R]\f[I]cfg\f[R]\f[CB], int\f[R] 38 | \f[I]prefix\f[R]\f[CB]);\f[R] 39 | .PP 40 | \f[CB]void vdeslirp_setvprefix6(SlirpConfig *\f[R]\f[I]cfg\f[R]\f[CB], int\f[R] 41 | \f[I]prefix6\f[R]\f[CB]);\f[R] 42 | .PP 43 | These functions are provided by libvdeslirp. 44 | Link with \-lvdeslirp. 45 | .SH DESCRIPTION 46 | These functions are configuration helpers for \f[CB]libvdeslirp\f[R](3). 47 | The fields of the SlirpConfig has been described in the 48 | \f[CB]libvdeslirp\f[R](3) manpage. 49 | .PP 50 | \f[CB]vdeslirp_init\f[R] clears the \f[CB]SlirpConfig\f[R] configuration 51 | structure \f[CB]cfg\f[R] and sets the version number. 52 | If \f[CB]flags\f[R] is set to \f[CB]VDE_INIT_DEFAULT\f[R] then it sets 53 | default values to all the fields of \f[CB]cfg\f[R]. 54 | These default values are suitable for most applications. 55 | .IP 56 | .EX 57 | SLIRP configuration 58 | version 1 59 | ipv4\-enable 1 60 | ipv4\-network 10.0.2.0 61 | ipv4\-netmask 255.255.255.0 62 | ipv4\-host 10.0.2.2 63 | ipv6\-enabled 1 64 | ipv6\-prefix fd00:: 65 | ipv6\-preflen 64 66 | ipv6\-host fd00::2 67 | hostname slirp 68 | tftp\-servname (null) 69 | tftp\-path (null) 70 | bootfile (null) 71 | dhcp\-start 10.0.2.15 72 | ipv4\-vDNS 10.0.2.3 73 | ipv6\-vDNS fd00::3 74 | vDNS\-search 75 | vdomainname (null) 76 | MTU(0=def) 0 77 | MRU(0=def) 0 78 | disable\-lback 0 79 | enable\-emu 0 80 | .EE 81 | .PP 82 | The functions \f[CB]vdeslirp_setvprefix\f[R] and 83 | \f[CB]vdeslirp_setvprefix6\f[R] define the netmasks and prefixes for 84 | IPv4 and IPv6. 85 | These function are usually called after the redefinition of 86 | \f[CB]vhost\f[R] or \f[CB]vhost6\f[R]. 87 | \f[CB]vdeslirp_setvprefix\f[R] redefines the network prefix of 88 | \f[CB]vnetwork\f[R], \f[CB]vdhcp_start\f[R] and \f[CB]vnameserver\f[R] 89 | while \f[CB]vdeslirp_setvprefix6\f[R] redefines the network prefix for 90 | \f[CB]vprefix_addr6\f[R] and \f[CB]vnameserver6\f[R]. 91 | .SH SEE ALSO 92 | \f[CB]libvdeslirp\f[R](3) 93 | .SH BUGS 94 | Bug reports should be addressed to *info\[at]virtualsquare.org* 95 | .SH AUTHOR 96 | VirtualSquare. 97 | Project leader: Renzo Davoli. 98 | -------------------------------------------------------------------------------- /man/libvdeslirpcfg.3.md: -------------------------------------------------------------------------------- 1 | 25 | 26 | # NAME 27 | 28 | vdeslirp_init, vdeslirp_setvprefix, vdeslirp_setvprefix6 - simple API for slirp: configuration helpers 29 | 30 | # SYNOPSIS 31 | 32 | `#include *libvdeslirp.h*` 33 | 34 | `#define VDE_INIT_DEFAULT 1` 35 | 36 | `void vdeslirp_init(SlirpConfig *`_cfg_`, int ` _flags_`);` 37 | 38 | `void vdeslirp_setvprefix(SlirpConfig *`_cfg_`, int ` _prefix_`);` 39 | 40 | `void vdeslirp_setvprefix6(SlirpConfig *`_cfg_`, int ` _prefix6_`);` 41 | 42 | These functions are provided by libvdeslirp. Link with -lvdeslirp. 43 | 44 | # DESCRIPTION 45 | 46 | These functions are configuration helpers for `libvdeslirp`(3). 47 | The fields of the SlirpConfig has been described in the `libvdeslirp`(3) manpage. 48 | 49 | `vdeslirp_init` clears the `SlirpConfig` configuration structure `cfg` and sets the 50 | version number. If `flags` is set to `VDE_INIT_DEFAULT` then it sets default values to 51 | all the fields of `cfg`. These default values are suitable for most applications. 52 | 53 | ``` 54 | SLIRP configuration 55 | version 1 56 | ipv4-enable 1 57 | ipv4-network 10.0.2.0 58 | ipv4-netmask 255.255.255.0 59 | ipv4-host 10.0.2.2 60 | ipv6-enabled 1 61 | ipv6-prefix fd00:: 62 | ipv6-preflen 64 63 | ipv6-host fd00::2 64 | hostname slirp 65 | tftp-servname (null) 66 | tftp-path (null) 67 | bootfile (null) 68 | dhcp-start 10.0.2.15 69 | ipv4-vDNS 10.0.2.3 70 | ipv6-vDNS fd00::3 71 | vDNS-search 72 | vdomainname (null) 73 | MTU(0=def) 0 74 | MRU(0=def) 0 75 | disable-lback 0 76 | enable-emu 0 77 | ``` 78 | 79 | The functions `vdeslirp_setvprefix` and `vdeslirp_setvprefix6` define the 80 | netmasks and prefixes for IPv4 and IPv6. These function are usually called 81 | after the redefinition of `vhost` or `vhost6`. `vdeslirp_setvprefix` redefines 82 | the network prefix of `vnetwork`, `vdhcp_start` and `vnameserver` while 83 | `vdeslirp_setvprefix6` redefines the network prefix for `vprefix_addr6` and 84 | `vnameserver6`. 85 | 86 | # SEE ALSO 87 | 88 | `libvdeslirp`(3) 89 | 90 | # BUGS 91 | 92 | Bug reports should be addressed to *info@virtualsquare.org\* 93 | 94 | # AUTHOR 95 | 96 | VirtualSquare. Project leader: Renzo Davoli. 97 | 98 | -------------------------------------------------------------------------------- /man/libvdeslirpfwd.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2019 VirtualSquare. Project Leader: Renzo Davoli 2 | .\" 3 | .\" This is free documentation; you can redistribute it and/or 4 | .\" modify it under the terms of the GNU General Public License, 5 | .\" as published by the Free Software Foundation, either version 2 6 | .\" of the License, or (at your option) any later version. 7 | .\" 8 | .\" The GNU General Public License's references to "object code" 9 | .\" and "executables" are to be interpreted as the output of any 10 | .\" document formatting or typesetting system, including 11 | .\" intermediate and printed output. 12 | .\" 13 | .\" This manual is distributed in the hope that it will be useful, 14 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | .\" GNU General Public License for more details. 17 | .\" 18 | .\" You should have received a copy of the GNU General Public 19 | .\" License along with this manual; if not, write to the Free 20 | .\" Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 21 | .\" MA 02110-1301 USA. 22 | .\" 23 | .\" Automatically generated by Pandoc 3.1.11 24 | .\" 25 | .TH "LIBVDESLIRPFWD" "3" "January 2024" "VirtualSquare" "Library Functions Manual" 26 | .SH NAME 27 | vdeslirp_add_fwd, vdeslirp_remove_fwd, vdeslirp_add_unixfwd, 28 | vdeslirp_remove_unixfwd, vdeslirp_add_cmdexec \- simple API for slirp, 29 | port forwarding 30 | .SH SYNOPSIS 31 | \f[CB]#include *libvdeslirp.h*\f[R] 32 | .PP 33 | \f[CB]int vdeslirp_add_fwd(struct vdeslirp *\f[R]\f[I]slirp\f[R]\f[CB], int\f[R] 34 | \f[I]is_udp\f[R]\f[CB], struct in_addr\f[R] 35 | \f[I]host_addr\f[R]\f[CB], int\f[R] 36 | \f[I]host_port\f[R]\f[CB], struct in_addr\f[R] 37 | \f[I]guest_addr\f[R]\f[CB], int\f[R] \f[I]guest_port\f[R]\f[CB]);\f[R] 38 | .PP 39 | \f[CB]int vdeslirp_remove_fwd(struct vdeslirp *\f[R]\f[I]slirp\f[R]\f[CB], int\f[R] 40 | \f[I]is_udp\f[R]\f[CB], struct in_addr\f[R] 41 | \f[I]host_addr\f[R]\f[CB], int\f[R] \f[I]host_port\f[R]\f[CB]);\f[R] 42 | .PP 43 | \f[CB]int vdeslirp_add_unixfwd(struct vdeslirp *\f[R]\f[I]slirp\f[R]\f[CB], char *\f[R]\f[I]path\f[R]\f[CB], struct in_addr\f[R] 44 | \f[I]guest_addr\f[R]\f[CB], int\f[R] \f[I]guest_port\f[R]\f[CB]);\f[R] 45 | .PP 46 | \f[CB]int vdeslirp_remove_unixfwd(struct vdeslirp *\f[R]\f[I]slirp\f[R]\f[CB], struct in_addr\f[R] 47 | \f[I]guest_addr\f[R]\f[CB], int\f[R] \f[I]guest_port\f[R]\f[CB]);\f[R] 48 | .PP 49 | \f[CB]int vdeslirp_add_cmdexec(struct vdeslirp *\f[R]\f[I]slirp\f[R]\f[CB], const char *\f[R]\f[I]cmdline\f[R]\f[CB], struct in_addr *\f[R]\f[I]guest_addr\f[R]\f[CB], int\f[R] 50 | \f[I]guest_port\f[R]\f[CB]);\f[R] 51 | .PP 52 | \f[CB]int vdeslirp_remove_cmdexec(struct vdeslirp *\f[R]\f[I]slirp\f[R]\f[CB], struct in_addr\f[R] 53 | \f[I]guest_addr\f[R]\f[CB], int\f[R] \f[I]guest_port\f[R]\f[CB]);\f[R] 54 | .SH DESCRIPTION 55 | Slirp, see libvdelirp(3), is a TCP/IP emulator. 56 | Slirp generates a virtual network using standard user privileges (no 57 | need for root access of CAP_NET_ADMIN). 58 | These functions manage port forwarding services. 59 | .PP 60 | \f[CB]vdeslirp_add_fwd\f[R] and \f[CB]vdeslirp_remove_fwd\f[R] 61 | respectively add and remove udp or tcp port forwarding services 62 | (depending upon the value of is_udp). 63 | \f[I]host_addr\f[R] and \f[I]host_port\f[R] are the IP address and port 64 | number bound for the service in the host system. 65 | All the connections or datagrams to \f[I]host_addr\f[R] and 66 | \f[I]host_port\f[R] will be diverted to \f[I]guest_addr\f[R] and 67 | \f[I]guest_port\f[R] in the slirp virtual network. 68 | .PP 69 | \f[CB]vdeslirp_add_unixfwd\f[R] and \f[CB]vdeslirp_remove_unixfwd\f[R] 70 | respectively add and remove a forwarding service towards a 71 | \f[CB]PF_UNIX\f[R] stream socket on the hosting system. 72 | All the connections from a node of the virtual network to 73 | \f[I]guest_addr\f[R] and \f[I]guest_port\f[R] will be diverted to the 74 | \f[CB]PF_UNIX\f[R] bound to the pathname path. 75 | This feature is commonly used to run X\-window clients in the virtual 76 | network (e.g.\ the value of path could be 77 | \f[CB]/tmp/.X11\-unix/X0\f[R]). 78 | .PP 79 | If libslirp does not support \f[CB]slirp_add_unix\f[R], 80 | \f[CB]vdeslirp_add_unixfwd\f[R] is implemented by a workaround based on 81 | \f[CB]nc\f[R](1). 82 | .PP 83 | \f[CB]vdeslirp_cmd_fwd\f[R] adds a forwarding service to a command. 84 | A TCP connection to \f[I]guest_addr\f[R] and \f[I]guest_port\f[R] 85 | activates the command \f[I]cmdline\f[R]. 86 | Data exchanged on the TCP connection is forwarded as stdin/stdout to the 87 | command. 88 | .PP 89 | \f[CB]vdeslirp_remove_cmdexec\f[R] removes a command forwarding service. 90 | .SH RETURN VALUE 91 | All these functions return 0 in case of success, \-1 otherwise (and 92 | \f[CB]errno\f[R] is set consequently). 93 | \f[CB]vdeslirp_remove_cmdexec\f[R] and 94 | \f[CB]vdeslirp_remove_unixfwd\f[R] return \-1 and set errno to 95 | \f[CB]ENOSYS\f[R] if libslirp does not support 96 | \f[CB]slirp_remove_guestfwd\f[R]. 97 | .SH SEE ALSO 98 | \f[CB]libvdeslirp\f[R](3), \f[CB]libvdeslirpcfg\f[R](3) 99 | .SH BUGS 100 | Bug reports should be addressed to *info\[at]virtualsquare.org* 101 | .SH AUTHOR 102 | VirtualSquare. 103 | Project leader: Renzo Davoli. 104 | -------------------------------------------------------------------------------- /man/libvdeslirpfwd.3.md: -------------------------------------------------------------------------------- 1 | 25 | 26 | # NAME 27 | 28 | vdeslirp_add_fwd, vdeslirp_remove_fwd, vdeslirp_add_unixfwd, vdeslirp_remove_unixfwd, vdeslirp_add_cmdexec - simple API for slirp, port forwarding 29 | 30 | # SYNOPSIS 31 | 32 | `#include *libvdeslirp.h*` 33 | 34 | `int vdeslirp_add_fwd(struct vdeslirp *`_slirp_`, int ` _is_udp_`, struct in_addr ` _host_addr_`, int ` _host_port_`, struct in_addr ` _guest_addr_`, int ` _guest_port_`);` 35 | 36 | `int vdeslirp_remove_fwd(struct vdeslirp *`_slirp_`, int ` _is_udp_`, struct in_addr ` _host_addr_`, int ` _host_port_`); ` 37 | 38 | `int vdeslirp_add_unixfwd(struct vdeslirp *`_slirp_`, char *`_path_`, struct in_addr ` _guest_addr_`, int ` _guest_port_`); ` 39 | 40 | `int vdeslirp_remove_unixfwd(struct vdeslirp *`_slirp_`, struct in_addr ` _guest_addr_`, int ` _guest_port_`); ` 41 | 42 | `int vdeslirp_add_cmdexec(struct vdeslirp *`_slirp_`, const char *`_cmdline_`, struct in_addr *`_guest_addr_`, int ` _guest_port_`);` 43 | 44 | `int vdeslirp_remove_cmdexec(struct vdeslirp *`_slirp_`, struct in_addr ` _guest_addr_`, int ` _guest_port_`); ` 45 | 46 | # DESCRIPTION 47 | 48 | Slirp, see libvdelirp(3), is a TCP/IP emulator. Slirp generates a virtual 49 | network using standard user privileges (no need for root access of 50 | CAP_NET_ADMIN). These functions manage port forwarding services. 51 | 52 | `vdeslirp_add_fwd` and `vdeslirp_remove_fwd` respectively add and remove 53 | udp or tcp port forwarding services (depending upon the value of is_udp). 54 | _host_addr_ and _host_port_ are the IP address and port number bound for the 55 | service in the host system. All the connections or datagrams to 56 | _host_addr_ and _host_port_ will be diverted to _guest_addr_ and _guest_port_ 57 | in the slirp virtual network. 58 | 59 | `vdeslirp_add_unixfwd` and `vdeslirp_remove_unixfwd` respectively add and 60 | remove a forwarding service towards a `PF_UNIX` stream socket on the hosting 61 | system. All the connections from a node of the virtual network to _guest_addr_ 62 | and _guest_port_ will be diverted to the `PF_UNIX` bound to the pathname 63 | path. This feature is commonly used to run X-window clients in the virtual 64 | network (e.g. the value of path could be `/tmp/.X11-unix/X0`). 65 | 66 | If libslirp does not support `slirp_add_unix`, `vdeslirp_add_unixfwd` is implemented 67 | by a workaround based on `nc`(1). 68 | 69 | `vdeslirp_cmd_fwd` adds a forwarding service to a command. A TCP connection to 70 | _guest_addr_ and _guest_port_ activates the command _cmdline_. Data exchanged 71 | on the TCP connection is forwarded as stdin/stdout to the command. 72 | 73 | `vdeslirp_remove_cmdexec` removes a command forwarding service. 74 | 75 | # RETURN VALUE 76 | 77 | All these functions return 0 in case of success, -1 otherwise (and `errno` is set consequently). 78 | `vdeslirp_remove_cmdexec` and `vdeslirp_remove_unixfwd` return -1 and 79 | set errno to `ENOSYS` if libslirp does not support `slirp_remove_guestfwd`. 80 | 81 | # SEE ALSO 82 | 83 | `libvdeslirp`(3), `libvdeslirpcfg`(3) 84 | 85 | # BUGS 86 | 87 | Bug reports should be addressed to *info@virtualsquare.org\* 88 | 89 | # AUTHOR 90 | 91 | VirtualSquare. Project leader: Renzo Davoli. 92 | -------------------------------------------------------------------------------- /man/vdeslirp_add_cmdexec.3: -------------------------------------------------------------------------------- 1 | libvdeslirpfwd.3 -------------------------------------------------------------------------------- /man/vdeslirp_add_fwd.3: -------------------------------------------------------------------------------- 1 | libvdeslirpfwd.3 -------------------------------------------------------------------------------- /man/vdeslirp_add_unixfwd.3: -------------------------------------------------------------------------------- 1 | libvdeslirpfwd.3 -------------------------------------------------------------------------------- /man/vdeslirp_close.3: -------------------------------------------------------------------------------- 1 | libvdeslirp.3 -------------------------------------------------------------------------------- /man/vdeslirp_fd.3: -------------------------------------------------------------------------------- 1 | libvdeslirp.3 -------------------------------------------------------------------------------- /man/vdeslirp_init.3: -------------------------------------------------------------------------------- 1 | libvdeslirpcfg.3 -------------------------------------------------------------------------------- /man/vdeslirp_open.3: -------------------------------------------------------------------------------- 1 | libvdeslirp.3 -------------------------------------------------------------------------------- /man/vdeslirp_recv.3: -------------------------------------------------------------------------------- 1 | libvdeslirp.3 -------------------------------------------------------------------------------- /man/vdeslirp_remove_fwd.3: -------------------------------------------------------------------------------- 1 | libvdeslirpfwd.3 -------------------------------------------------------------------------------- /man/vdeslirp_remove_unixfwd.3: -------------------------------------------------------------------------------- 1 | libvdeslirpfwd.3 -------------------------------------------------------------------------------- /man/vdeslirp_send.3: -------------------------------------------------------------------------------- 1 | libvdeslirp.3 -------------------------------------------------------------------------------- /man/vdeslirp_setvprefix.3: -------------------------------------------------------------------------------- 1 | libvdeslirpcfg.3 -------------------------------------------------------------------------------- /man/vdeslirp_setvprefix6.3: -------------------------------------------------------------------------------- 1 | libvdeslirpcfg.3 -------------------------------------------------------------------------------- /vdeslirp.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix="${prefix}/@CMAKE_INSTALL_BINDIR@" 3 | libdir="${prefix}/@CMAKE_INSTALL_LIBDIR@" 4 | includedir="${prefix}/@CMAKE_INSTALL_INCLUDEDIR@" 5 | 6 | Name: @PROJECT_NAME@ 7 | Description: @PROJECT_DESCRIPTION@ 8 | Version: @PROJECT_VERSION@ 9 | 10 | Requires: @PROJECT_PC_REQUIRES@ 11 | 12 | Cflags: -I${includedir} 13 | Libs: -L${libdir} -l@PROJECT_NAME@ @PRIVATE_LIBS@ 14 | --------------------------------------------------------------------------------