open-switch / opx-cps

https://openswitch.net
6 stars 15 forks source link

C SDK example #103

Closed jimmymagemtek closed 5 years ago

jimmymagemtek commented 6 years ago

Hi Could you provide a C SDK for us to build C applications on CPS ? Thanks.

Jimmy

jeff-yin commented 6 years ago

Hi @jimmymagemtek , can I ask what you're looking for specifically? Like, anything beyond the current CPS API in opx-cps and the YANG objects defined in opx-base-model? Thanks!

jimmymagemtek commented 6 years ago

Hi Jeff, I suppose that any kinds of applications are all using opx-cps API. And I need to develop application using C, for the good of the integration with other applications, like OvS.

According to the illustration on the web, applications could be written in Python, C or C++. There are C applications examples inside "docs" folder, but I see no C CPS libraries and don't know which libraries to link. (although there are python libraries)

That's why I need a C SDK, if possible.

Thanks. Jimmy

jeff-yin commented 5 years ago

@jimmymagemtek have you checked out the developer's guide in the OPX documentation? http://archive.openswitch.net/docs/3.0.0/openswitch_opx_300_dev_guide.pdf

jimmymagemtek commented 5 years ago

Hi Jeff, Yes, I do see C examples inside this document, while it didn't mention how to build it. Please advise. Thanks.

Jimmy

jeff-yin commented 5 years ago

@atanu-mandal @theucke do you guys know if we provide any guidance on how to develop a C application using CPS from scratch? We provide application examples in the developer guides, but I haven't found any guidance about configuring Makefiles, files to #include and what not.

atanu-mandal commented 5 years ago

Hi @jimmymagemtek , I believe you would want to build your application as a binary and are looking for the procedure to do that.

Essentially OPX uses standard automake infra.

You can create a target for you application binary using "bin_PROGRAMS" and add the corresponding sources/dependent libraries/flags,etc using that target. For example, please refer the code at https://github.com/open-switch/opx-nas-l3/blob/master/Makefile.am and check how "base_nbr_mgr_svc" binary target is used.

After you build your application the binary should be available at /usr/bin/ on the target. This is a good example of how C/C++ sources are built as an application target.

Hope that helps.

jimmymagemtek commented 5 years ago

Hi @atanu-mandal , Got it. Thanks.

Jimmy